mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-25 21:42:07 +01:00
Compare commits
26 commits
12e20c2d6c
...
10aee6c787
Author | SHA1 | Date | |
---|---|---|---|
|
10aee6c787 | ||
|
e2d393d00d | ||
|
51b167c0d4 | ||
|
bfff412112 | ||
|
9c7f62ec07 | ||
|
dfa61c3058 | ||
|
a564620383 | ||
|
5b805336ce | ||
|
d4c1216fb1 | ||
|
3b27eb520f | ||
|
398cba330b | ||
|
5169e887ad | ||
|
ea944a8dc6 | ||
|
078cb5cc8f | ||
|
8b0de5ff85 | ||
|
69e9f3c044 | ||
|
0967019a5f | ||
|
07da9ffb48 | ||
|
62916b8490 | ||
|
8d432e2303 | ||
|
5380e5705f | ||
|
3382cbdf44 | ||
|
439e29a1c7 | ||
|
14c351397d | ||
|
f9fb4d7627 | ||
5ed594fe73 |
160 changed files with 951 additions and 966 deletions
33
build.gradle
33
build.gradle
|
@ -134,6 +134,12 @@ allprojects {
|
|||
junitVersion = '5.6.0'
|
||||
powerMockVersion = '2.0.2'
|
||||
commonsIoVersion = '2.6'
|
||||
if (project.hasProperty("useSonatype")) {
|
||||
useSonatype = project.getProperty("useSonatype").toBoolean()
|
||||
} else {
|
||||
// Default to true
|
||||
useSonatype = true
|
||||
}
|
||||
}
|
||||
group = 'org.igniterealtime.smack'
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
|
@ -159,12 +165,6 @@ allprojects {
|
|||
ext.sharedManifest = manifest {
|
||||
attributes('Implementation-Version': version,
|
||||
'Implementation-GitRevision': ext.gitCommit,
|
||||
// According to OSGi core 5.0 section 3.2.5 the qualifier (the fourth
|
||||
// version element) must begin with a dot. So we replace only the
|
||||
// first occurence of an dash with a dot.
|
||||
// For example 4.0.0-rc1 becomes 4.0.0.rc1, but
|
||||
// 4.0.0-SNAPSHOT-2014-05-01 becomes 4.0.0.SNAPSHOT-2014-05-01
|
||||
'Bundle-Version': version.replaceFirst("-", "."),
|
||||
'Built-Date': ext.builtDate,
|
||||
'Built-JDK': System.getProperty('java.version'),
|
||||
'Built-Gradle': gradle.gradleVersion,
|
||||
|
@ -463,15 +463,30 @@ subprojects {
|
|||
}
|
||||
}
|
||||
repositories {
|
||||
maven {
|
||||
url isSnapshot ? sonatypeSnapshotUrl : sonatypeStagingUrl
|
||||
if (sonatypeCredentialsAvailable) {
|
||||
if (sonatypeCredentialsAvailable && useSonatype) {
|
||||
maven {
|
||||
url isSnapshot ? sonatypeSnapshotUrl : sonatypeStagingUrl
|
||||
credentials {
|
||||
username = sonatypeUsername
|
||||
password = sonatypePassword
|
||||
}
|
||||
}
|
||||
}
|
||||
// Use
|
||||
// gradle publish -P customRepoUrl=https://www.igniterealtime.org/archiva/repository/maven -P customRepoUsername=bamboo -P customRepoPassword=hidden -P useSonatype=false
|
||||
// to deploy to this repo.
|
||||
if (project.hasProperty("customRepoUrl")) {
|
||||
maven {
|
||||
name 'customRepo'
|
||||
url customRepoUrl
|
||||
if (project.hasProperty("customRepoUsername")) {
|
||||
credentials {
|
||||
username customRepoUsername
|
||||
password customRepoPassword
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
rootProject.distributionZip {
|
||||
|
|
|
@ -80,6 +80,7 @@ debugger=console
|
|||
| disabledConnections | List of disabled connection's nicknames |
|
||||
| testPackages | List of packages with tests |
|
||||
| verbose | If `true` set output to verbose |
|
||||
| dnsResolver | One of 'minidns', 'javax' or 'dnsjava'. Defaults to 'minidns'. |
|
||||
|
||||
### Where to place the properties file
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2003-2007 Jive Software, 2014-2016 Florian Schmaus
|
||||
* Copyright 2003-2007 Jive Software, 2014-2020 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -36,9 +36,11 @@ import org.jivesoftware.smack.compression.zlib.ZlibXmppCompressionFactory;
|
|||
import org.jivesoftware.smack.initializer.SmackInitializer;
|
||||
import org.jivesoftware.smack.isr.InstantStreamResumptionModuleDescriptor;
|
||||
import org.jivesoftware.smack.packet.Bind;
|
||||
import org.jivesoftware.smack.packet.Message.Body;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.provider.BindIQProvider;
|
||||
import org.jivesoftware.smack.provider.BodyElementProvider;
|
||||
import org.jivesoftware.smack.provider.MessageSubjectElementProvider;
|
||||
import org.jivesoftware.smack.provider.MessageThreadElementProvider;
|
||||
import org.jivesoftware.smack.provider.ProviderManager;
|
||||
import org.jivesoftware.smack.provider.SaslChallengeProvider;
|
||||
import org.jivesoftware.smack.provider.SaslFailureProvider;
|
||||
|
@ -54,7 +56,6 @@ import org.jivesoftware.smack.util.FileUtils;
|
|||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
|
||||
|
||||
public final class SmackInitialization {
|
||||
static final String SMACK_VERSION;
|
||||
|
||||
|
@ -129,7 +130,9 @@ public final class SmackInitialization {
|
|||
SASLAuthentication.registerSASLMechanism(new SASLAnonymous());
|
||||
|
||||
ProviderManager.addIQProvider(Bind.ELEMENT, Bind.NAMESPACE, new BindIQProvider());
|
||||
ProviderManager.addExtensionProvider(Body.ELEMENT, Body.NAMESPACE, new BodyElementProvider());
|
||||
ProviderManager.addExtensionProvider(Message.Body.ELEMENT, Message.Body.NAMESPACE, new BodyElementProvider());
|
||||
ProviderManager.addExtensionProvider(Message.Thread.ELEMENT, Message.Thread.NAMESPACE, new MessageThreadElementProvider());
|
||||
ProviderManager.addExtensionProvider(Message.Subject.ELEMENT, Message.Subject.NAMESPACE, new MessageSubjectElementProvider());
|
||||
|
||||
ProviderManager.addNonzaProvider(SaslChallengeProvider.INSTANCE);
|
||||
ProviderManager.addNonzaProvider(SaslSuccessProvider.INSTANCE);
|
||||
|
|
|
@ -1,138 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2003-2007 Jive Software.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jivesoftware.smack.packet;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
||||
/**
|
||||
* Default implementation of the ExtensionElement interface. Unless a ExtensionElementProvider
|
||||
* is registered with {@link org.jivesoftware.smack.provider.ProviderManager ProviderManager},
|
||||
* instances of this class will be returned when getting stanza extensions.<p>
|
||||
*
|
||||
* This class provides a very simple representation of an XML sub-document. Each element
|
||||
* is a key in a Map with its CDATA being the value. For example, given the following
|
||||
* XML sub-document:
|
||||
*
|
||||
* <pre>
|
||||
* <foo xmlns="http://bar.com">
|
||||
* <color>blue</color>
|
||||
* <food>pizza</food>
|
||||
* </foo></pre>
|
||||
*
|
||||
* In this case, getValue("color") would return "blue", and getValue("food") would
|
||||
* return "pizza". This parsing mechanism is very simplistic and will not work
|
||||
* as desired in all cases (for example, if some of the elements have attributes. In those
|
||||
* cases, a custom ExtensionElementProvider should be used.
|
||||
*
|
||||
* @author Matt Tucker
|
||||
* @deprecated use {@link org.jivesoftware.smack.packet.StandardExtensionElement} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public class DefaultExtensionElement implements ExtensionElement {
|
||||
|
||||
private String elementName;
|
||||
private String namespace;
|
||||
private Map<String, String> map;
|
||||
|
||||
/**
|
||||
* Creates a new generic stanza extension.
|
||||
*
|
||||
* @param elementName the name of the element of the XML sub-document.
|
||||
* @param namespace the namespace of the element.
|
||||
*/
|
||||
public DefaultExtensionElement(String elementName, String namespace) {
|
||||
this.elementName = elementName;
|
||||
this.namespace = namespace;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the XML element name of the extension sub-packet root element.
|
||||
*
|
||||
* @return the XML element name of the stanza extension.
|
||||
*/
|
||||
@Override
|
||||
public String getElementName() {
|
||||
return elementName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the XML namespace of the extension sub-packet root element.
|
||||
*
|
||||
* @return the XML namespace of the stanza extension.
|
||||
*/
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return namespace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder buf = new XmlStringBuilder();
|
||||
buf.halfOpenElement(elementName).xmlnsAttribute(namespace).rightAngleBracket();
|
||||
for (String name : getNames()) {
|
||||
String value = getValue(name);
|
||||
buf.element(name, value);
|
||||
}
|
||||
buf.closeElement(elementName);
|
||||
return buf;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an unmodifiable collection of the names that can be used to get
|
||||
* values of the stanza extension.
|
||||
*
|
||||
* @return the names.
|
||||
*/
|
||||
public synchronized Collection<String> getNames() {
|
||||
if (map == null) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
return Collections.unmodifiableSet(new HashMap<String, String>(map).keySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a stanza extension value given a name.
|
||||
*
|
||||
* @param name the name.
|
||||
* @return the value.
|
||||
*/
|
||||
public synchronized String getValue(String name) {
|
||||
if (map == null) {
|
||||
return null;
|
||||
}
|
||||
return map.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a stanza extension value using the given name.
|
||||
*
|
||||
* @param name the name.
|
||||
* @param value the value.
|
||||
*/
|
||||
public synchronized void setValue(String name, String value) {
|
||||
if (map == null) {
|
||||
map = new HashMap<String, String>();
|
||||
}
|
||||
map.put(name, value);
|
||||
}
|
||||
}
|
|
@ -29,6 +29,7 @@ import javax.xml.namespace.QName;
|
|||
import org.jivesoftware.smack.util.EqualsUtil;
|
||||
import org.jivesoftware.smack.util.HashCode;
|
||||
import org.jivesoftware.smack.util.Objects;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jivesoftware.smack.util.TypedCloneable;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
||||
|
@ -67,7 +68,6 @@ public final class Message extends MessageOrPresence<MessageBuilder>
|
|||
public static final String BODY = "body";
|
||||
|
||||
private Type type;
|
||||
private String thread = null;
|
||||
|
||||
/**
|
||||
* Creates a new, "normal" message.
|
||||
|
@ -150,7 +150,6 @@ public final class Message extends MessageOrPresence<MessageBuilder>
|
|||
Message(MessageBuilder messageBuilder) {
|
||||
super(messageBuilder);
|
||||
type = messageBuilder.type;
|
||||
thread = messageBuilder.thread;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -165,7 +164,6 @@ public final class Message extends MessageOrPresence<MessageBuilder>
|
|||
public Message(Message other) {
|
||||
super(other);
|
||||
this.type = other.type;
|
||||
this.thread = other.thread;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -502,7 +500,11 @@ public final class Message extends MessageOrPresence<MessageBuilder>
|
|||
* @return the thread id of the message, or <code>null</code> if it doesn't exist.
|
||||
*/
|
||||
public String getThread() {
|
||||
return thread;
|
||||
Message.Thread thread = getExtension(Message.Thread.class);
|
||||
if (thread == null) {
|
||||
return null;
|
||||
}
|
||||
return thread.getThread();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -515,7 +517,7 @@ public final class Message extends MessageOrPresence<MessageBuilder>
|
|||
@Deprecated
|
||||
// TODO: Remove when stanza builder is ready.
|
||||
public void setThread(String thread) {
|
||||
this.thread = thread;
|
||||
addExtension(new Message.Thread(thread));
|
||||
}
|
||||
|
||||
private String determineLanguage(String language) {
|
||||
|
@ -559,7 +561,6 @@ public final class Message extends MessageOrPresence<MessageBuilder>
|
|||
buf.optAttribute("type", type);
|
||||
buf.rightAngleBracket();
|
||||
|
||||
buf.optElement("thread", thread);
|
||||
// Append the error subpacket if the message type is an error.
|
||||
if (type == Type.error) {
|
||||
appendErrorIfExists(buf);
|
||||
|
@ -754,6 +755,60 @@ public final class Message extends MessageOrPresence<MessageBuilder>
|
|||
|
||||
}
|
||||
|
||||
@SuppressWarnings("JavaLangClash")
|
||||
public static class Thread implements ExtensionElement {
|
||||
public static final String ELEMENT = "thread";
|
||||
public static final String NAMESPACE = StreamOpen.CLIENT_NAMESPACE;
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
public static final String PARENT_ATTRIBUTE_NAME = "parent";
|
||||
|
||||
private final String thread;
|
||||
private final String parent;
|
||||
|
||||
public Thread(String thread) {
|
||||
this(thread, null);
|
||||
}
|
||||
|
||||
public Thread(String thread, String parent) {
|
||||
this.thread = StringUtils.requireNotNullNorEmpty(thread, "thread must not be null nor empty");
|
||||
this.parent = StringUtils.requireNullOrNotEmpty(parent, "parent must be null or not empty");
|
||||
}
|
||||
|
||||
public String getThread() {
|
||||
return thread;
|
||||
}
|
||||
|
||||
public String getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElementName() {
|
||||
return ELEMENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return NAMESPACE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QName getQName() {
|
||||
return QNAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(XmlEnvironment xmlEnvironment) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this, xmlEnvironment);
|
||||
xml.optAttribute(PARENT_ATTRIBUTE_NAME, parent);
|
||||
xml.rightAngleBracket();
|
||||
xml.escape(thread);
|
||||
xml.closeElement(this);
|
||||
return xml;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the type of a message.
|
||||
*/
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2019 Florian Schmaus
|
||||
* Copyright 2019-2020 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -29,8 +29,6 @@ public final class MessageBuilder extends MessageOrPresenceBuilder<Message, Mess
|
|||
|
||||
Message.Type type;
|
||||
|
||||
String thread;
|
||||
|
||||
MessageBuilder(Message message, String stanzaId) {
|
||||
super(message, stanzaId);
|
||||
copyFromMessage(message);
|
||||
|
@ -51,13 +49,11 @@ public final class MessageBuilder extends MessageOrPresenceBuilder<Message, Mess
|
|||
|
||||
private void copyFromMessage(Message message) {
|
||||
type = message.getType();
|
||||
thread = message.getThread();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addStanzaSpecificAttributes(ToStringUtil.Builder builder) {
|
||||
builder.addValue("type", type)
|
||||
.addValue("thread", thread)
|
||||
;
|
||||
}
|
||||
|
||||
|
@ -67,7 +63,11 @@ public final class MessageBuilder extends MessageOrPresenceBuilder<Message, Mess
|
|||
}
|
||||
|
||||
public MessageBuilder setThread(String thread) {
|
||||
this.thread = thread;
|
||||
return setThread(thread, null);
|
||||
}
|
||||
|
||||
public MessageBuilder setThread(String thread, String parent) {
|
||||
addExtension(new Message.Thread(thread, parent));
|
||||
return getThis();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,229 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2003-2007 Jive Software.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jivesoftware.smack.packet;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Deprecated interface of pre Smack 4.1 Stanzas.
|
||||
* @deprecated use {@link Stanza} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public interface Packet extends TopLevelStreamElement {
|
||||
|
||||
String TEXT = "text";
|
||||
String ITEM = "item";
|
||||
|
||||
/**
|
||||
* Returns the unique ID of the stanza. The returned value could be <code>null</code>.
|
||||
*
|
||||
* @return the packet's unique ID or <code>null</code> if the id is not available.
|
||||
*/
|
||||
String getStanzaId();
|
||||
|
||||
/**
|
||||
* Get the stanza id.
|
||||
* @return the stanza id.
|
||||
* @deprecated use {@link #getStanzaId()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
String getPacketID();
|
||||
|
||||
/**
|
||||
* Sets the unique ID of the packet. To indicate that a stanza has no id
|
||||
* pass <code>null</code> as the packet's id value.
|
||||
*
|
||||
* @param id the unique ID for the packet.
|
||||
*/
|
||||
void setStanzaId(String id);
|
||||
|
||||
/**
|
||||
* Set the stanza ID.
|
||||
* @param packetID TODO javadoc me please
|
||||
* @deprecated use {@link #setStanzaId(String)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
void setPacketID(String packetID);
|
||||
|
||||
/**
|
||||
* Returns who the stanza is being sent "to", or <code>null</code> if
|
||||
* the value is not set. The XMPP protocol often makes the "to"
|
||||
* attribute optional, so it does not always need to be set.<p>
|
||||
*
|
||||
* @return who the stanza is being sent to, or <code>null</code> if the
|
||||
* value has not been set.
|
||||
*/
|
||||
String getTo();
|
||||
|
||||
/**
|
||||
* Sets who the stanza is being sent "to". The XMPP protocol often makes
|
||||
* the "to" attribute optional, so it does not always need to be set.
|
||||
*
|
||||
* @param to who the stanza is being sent to.
|
||||
*/
|
||||
void setTo(String to);
|
||||
|
||||
/**
|
||||
* Returns who the stanza is being sent "from" or <code>null</code> if
|
||||
* the value is not set. The XMPP protocol often makes the "from"
|
||||
* attribute optional, so it does not always need to be set.<p>
|
||||
*
|
||||
* @return who the stanza is being sent from, or <code>null</code> if the
|
||||
* value has not been set.
|
||||
*/
|
||||
String getFrom();
|
||||
|
||||
/**
|
||||
* Sets who the stanza is being sent "from". The XMPP protocol often
|
||||
* makes the "from" attribute optional, so it does not always need to
|
||||
* be set.
|
||||
*
|
||||
* @param from who the stanza is being sent to.
|
||||
*/
|
||||
void setFrom(String from);
|
||||
|
||||
/**
|
||||
* Returns the error associated with this packet, or <code>null</code> if there are
|
||||
* no errors.
|
||||
*
|
||||
* @return the error sub-packet or <code>null</code> if there isn't an error.
|
||||
*/
|
||||
StanzaError getError();
|
||||
/**
|
||||
* Sets the error for this packet.
|
||||
*
|
||||
* @param error the error to associate with this packet.
|
||||
*/
|
||||
void setError(StanzaError error);
|
||||
|
||||
@Override
|
||||
String getLanguage();
|
||||
|
||||
/**
|
||||
* Sets the xml:lang of this Stanza.
|
||||
*
|
||||
* @param language the xml:lang of this Stanza.
|
||||
*/
|
||||
void setLanguage(String language);
|
||||
|
||||
/**
|
||||
* Returns a copy of the stanza extensions attached to the packet.
|
||||
*
|
||||
* @return the stanza extensions.
|
||||
*/
|
||||
List<ExtensionElement> getExtensions();
|
||||
|
||||
/**
|
||||
* Return a set of all extensions with the given element name <i>and</i> namespace.
|
||||
* <p>
|
||||
* Changes to the returned set will update the stanza extensions, if the returned set is not the empty set.
|
||||
* </p>
|
||||
*
|
||||
* @param elementName the element name, must not be null.
|
||||
* @param namespace the namespace of the element(s), must not be null.
|
||||
* @return a set of all matching extensions.
|
||||
* @since 4.1
|
||||
*/
|
||||
Set<ExtensionElement> getExtensions(String elementName, String namespace);
|
||||
|
||||
/**
|
||||
* Returns the first extension of this stanza that has the given namespace.
|
||||
* <p>
|
||||
* When possible, use {@link #getExtension(String, String)} instead.
|
||||
* </p>
|
||||
*
|
||||
* @param namespace the namespace of the extension that is desired.
|
||||
* @return the stanza extension with the given namespace.
|
||||
*/
|
||||
ExtensionElement getExtension(String namespace);
|
||||
|
||||
/**
|
||||
* Returns the first stanza extension that matches the specified element name and
|
||||
* namespace, or <code>null</code> if it doesn't exist. If the provided elementName is null,
|
||||
* only the namespace is matched. Stanza extensions are
|
||||
* are arbitrary XML sub-documents in standard XMPP packets. By default, a
|
||||
* DefaultPacketExtension instance will be returned for each extension. However,
|
||||
* PacketExtensionProvider instances can be registered with the
|
||||
* {@link org.jivesoftware.smack.provider.ProviderManager ProviderManager}
|
||||
* class to handle custom parsing. In that case, the type of the Object
|
||||
* will be determined by the provider.
|
||||
*
|
||||
* @param elementName the XML element name of the stanza extension. (May be null)
|
||||
* @param namespace the XML element namespace of the stanza extension.
|
||||
* @param <PE> type of the ExtensionElement.
|
||||
* @return the extension, or <code>null</code> if it doesn't exist.
|
||||
*/
|
||||
<PE extends ExtensionElement> PE getExtension(String elementName, String namespace);
|
||||
/**
|
||||
* Adds a stanza extension to the packet. Does nothing if extension is null.
|
||||
*
|
||||
* @param extension a stanza extension.
|
||||
*/
|
||||
void addExtension(ExtensionElement extension);
|
||||
|
||||
/**
|
||||
* Adds a collection of stanza extensions to the packet. Does nothing if extensions is null.
|
||||
*
|
||||
* @param extensions a collection of stanza extensions
|
||||
*/
|
||||
void addExtensions(Collection<ExtensionElement> extensions);
|
||||
|
||||
/**
|
||||
* Check if a stanza extension with the given element and namespace exists.
|
||||
* <p>
|
||||
* The argument <code>elementName</code> may be null.
|
||||
* </p>
|
||||
*
|
||||
* @param elementName TODO javadoc me please
|
||||
* @param namespace TODO javadoc me please
|
||||
* @return true if a stanza extension exists, false otherwise.
|
||||
*/
|
||||
boolean hasExtension(String elementName, String namespace);
|
||||
|
||||
/**
|
||||
* Check if a stanza extension with the given namespace exists.
|
||||
*
|
||||
* @param namespace TODO javadoc me please
|
||||
* @return true if a stanza extension exists, false otherwise.
|
||||
*/
|
||||
boolean hasExtension(String namespace);
|
||||
|
||||
/**
|
||||
* Remove the stanza extension with the given elementName and namespace.
|
||||
*
|
||||
* @param elementName TODO javadoc me please
|
||||
* @param namespace TODO javadoc me please
|
||||
* @return the removed stanza extension or null.
|
||||
*/
|
||||
ExtensionElement removeExtension(String elementName, String namespace);
|
||||
|
||||
/**
|
||||
* Removes a stanza extension from the packet.
|
||||
*
|
||||
* @param extension the stanza extension to remove.
|
||||
* @return the removed stanza extension or null.
|
||||
*/
|
||||
ExtensionElement removeExtension(ExtensionElement extension);
|
||||
|
||||
@Override
|
||||
// NOTE When Smack is using Java 8, then this method should be moved in Element as "Default Method".
|
||||
String toString();
|
||||
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2003-2007 Jive Software.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jivesoftware.smack.packet;
|
||||
|
||||
/**
|
||||
* Interface to represent extension elements.
|
||||
* <p>
|
||||
* An extension element is an XML subdocument
|
||||
* with a root element name and namespace. Extension elements are used to provide
|
||||
* extended functionality beyond what is in the base XMPP specification. Examples of
|
||||
* extensions elements include message events, message properties, and extra presence data.
|
||||
* IQ stanzas have limited support for extension elements.
|
||||
* <p>
|
||||
* This class is used primarily for extended content in XMPP Stanzas, to act as so called "extension elements". For more
|
||||
* information see <a href="https://tools.ietf.org/html/rfc6120#section-8.4">RFC 6120 § 8.4 Extended Content</a>.
|
||||
* </p>
|
||||
*
|
||||
* @see DefaultExtensionElement
|
||||
* @see org.jivesoftware.smack.provider.ExtensionElementProvider
|
||||
* @author Matt Tucker
|
||||
* @deprecated use {@link ExtensionElement} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface PacketExtension extends ExtensionElement {
|
||||
|
||||
}
|
|
@ -356,11 +356,9 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
|
|||
*
|
||||
* @param elementName the XML element name of the extension. (May be null)
|
||||
* @param namespace the XML element namespace of the extension.
|
||||
* @param <PE> type of the ExtensionElement.
|
||||
* @return the extension, or <code>null</code> if it doesn't exist.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public final <PE extends ExtensionElement> PE getExtension(String elementName, String namespace) {
|
||||
public final ExtensionElement getExtension(String elementName, String namespace) {
|
||||
if (namespace == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -369,14 +367,13 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
|
|||
if (packetExtension == null) {
|
||||
return null;
|
||||
}
|
||||
return (PE) packetExtension;
|
||||
return packetExtension;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public final <E extends ExtensionElement> E getExtension(QName qname) {
|
||||
public final ExtensionElement getExtension(QName qname) {
|
||||
synchronized (extensionElements) {
|
||||
return (E) extensionElements.getFirst(qname);
|
||||
return extensionElements.getFirst(qname);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -211,10 +211,9 @@ public abstract class StanzaBuilder<B extends StanzaBuilder<B>> implements Stanz
|
|||
return stanzaError;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public final <E extends ExtensionElement> E getExtension(QName qname) {
|
||||
return (E) extensionElements.getFirst(qname);
|
||||
public final ExtensionElement getExtension(QName qname) {
|
||||
return extensionElements.getFirst(qname);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2019 Florian Schmaus
|
||||
* Copyright 2019-2020 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -61,12 +61,16 @@ public interface StanzaView extends XmlLangElement {
|
|||
*/
|
||||
StanzaError getError();
|
||||
|
||||
<E extends ExtensionElement> E getExtension(QName qname);
|
||||
ExtensionElement getExtension(QName qname);
|
||||
|
||||
default boolean hasExtension(QName qname) {
|
||||
return getExtension(qname) != null;
|
||||
}
|
||||
|
||||
default boolean hasExtension(Class<? extends ExtensionElement> extensionElementClass) {
|
||||
return getExtension(extensionElementClass) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a extension element with the given namespace exists.
|
||||
*
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2020 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jivesoftware.smack.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||
import org.jivesoftware.smack.parsing.SmackParsingException;
|
||||
import org.jivesoftware.smack.util.ParserUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
import org.jivesoftware.smack.xml.XmlPullParserException;
|
||||
|
||||
public class MessageSubjectElementProvider extends ExtensionElementProvider<Message.Subject> {
|
||||
|
||||
@Override
|
||||
public Message.Subject parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
|
||||
throws XmlPullParserException, IOException, SmackParsingException {
|
||||
String xmlLangSubject = ParserUtils.getXmlLang(parser);
|
||||
String subject = parser.nextText();
|
||||
|
||||
return new Message.Subject(xmlLangSubject, subject);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2020 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jivesoftware.smack.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||
import org.jivesoftware.smack.parsing.SmackParsingException;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
import org.jivesoftware.smack.xml.XmlPullParserException;
|
||||
|
||||
public class MessageThreadElementProvider extends ExtensionElementProvider<Message.Thread> {
|
||||
|
||||
@Override
|
||||
public Message.Thread parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
|
||||
throws XmlPullParserException, IOException, SmackParsingException {
|
||||
String parent = parser.getAttributeValue(Message.Thread.PARENT_ATTRIBUTE_NAME);
|
||||
String thread = parser.nextText();
|
||||
|
||||
return new Message.Thread(thread, parent);
|
||||
}
|
||||
|
||||
}
|
|
@ -179,7 +179,6 @@ public class PacketParserUtils {
|
|||
// Parse sub-elements. We include extra logic to make sure the values
|
||||
// are only read once. This is because it's possible for the names to appear
|
||||
// in arbitrary sub-elements.
|
||||
String thread = null;
|
||||
outerloop: while (true) {
|
||||
XmlPullParser.Event eventType = parser.next();
|
||||
switch (eventType) {
|
||||
|
@ -187,18 +186,6 @@ public class PacketParserUtils {
|
|||
String elementName = parser.getName();
|
||||
String namespace = parser.getNamespace();
|
||||
switch (elementName) {
|
||||
case "subject":
|
||||
String xmlLangSubject = ParserUtils.getXmlLang(parser);
|
||||
String subject = parseElementText(parser);
|
||||
|
||||
Message.Subject subjectExtensionElement = new Message.Subject(xmlLangSubject, subject);
|
||||
message.addExtension(subjectExtensionElement);
|
||||
break;
|
||||
case "thread":
|
||||
if (thread == null) {
|
||||
thread = parser.nextText();
|
||||
}
|
||||
break;
|
||||
case "error":
|
||||
message.setError(parseError(parser, messageXmlEnvironment));
|
||||
break;
|
||||
|
@ -217,8 +204,6 @@ public class PacketParserUtils {
|
|||
}
|
||||
}
|
||||
|
||||
message.setThread(thread);
|
||||
|
||||
// TODO check for duplicate body elements. This means we need to check for duplicate xml:lang pairs and for
|
||||
// situations where we have a body element with an explicit xml lang set and once where the value is inherited
|
||||
// and both values are equal.
|
||||
|
|
|
@ -61,6 +61,20 @@ public class TLSUtils {
|
|||
public static final String PROTO_TLSV1 = TLS + "v1";
|
||||
public static final String PROTO_TLSV1_1 = TLS + "v1.1";
|
||||
public static final String PROTO_TLSV1_2 = TLS + "v1.2";
|
||||
public static final String PROTO_TLSV1_3 = TLS + "v1.3";
|
||||
|
||||
/**
|
||||
* Enable the recommended TLS protocols.
|
||||
*
|
||||
* @param builder the configuration builder to apply this setting to
|
||||
* @param <B> Type of the ConnectionConfiguration builder.
|
||||
*
|
||||
* @return the given builder
|
||||
*/
|
||||
public static <B extends ConnectionConfiguration.Builder<B, ?>> B setEnabledTlsProtocolsToRecommended(B builder) {
|
||||
builder.setEnabledSSLProtocols(new String[] { PROTO_TLSV1_3, PROTO_TLSV1_2 });
|
||||
return builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable only TLS. Connections created with the given ConnectionConfiguration will only support TLS.
|
||||
|
@ -76,7 +90,10 @@ public class TLSUtils {
|
|||
* @param <B> Type of the ConnectionConfiguration builder.
|
||||
*
|
||||
* @return the given builder
|
||||
* @deprecated use {@link #setEnabledTlsProtocolsToRecommended(org.jivesoftware.smack.ConnectionConfiguration.Builder)} instead.
|
||||
*/
|
||||
// TODO: Remove in Smack 4.5.
|
||||
@Deprecated
|
||||
public static <B extends ConnectionConfiguration.Builder<B, ?>> B setTLSOnly(B builder) {
|
||||
builder.setEnabledSSLProtocols(new String[] { PROTO_TLSV1_2, PROTO_TLSV1_1, PROTO_TLSV1 });
|
||||
return builder;
|
||||
|
@ -96,7 +113,10 @@ public class TLSUtils {
|
|||
* @param <B> Type of the ConnectionConfiguration builder.
|
||||
*
|
||||
* @return the given builder
|
||||
* @deprecated use {@link #setEnabledTlsProtocolsToRecommended(org.jivesoftware.smack.ConnectionConfiguration.Builder)} instead.
|
||||
*/
|
||||
// TODO: Remove in Smack 4.5.
|
||||
@Deprecated
|
||||
public static <B extends ConnectionConfiguration.Builder<B, ?>> B setSSLv3AndTLSOnly(B builder) {
|
||||
builder.setEnabledSSLProtocols(new String[] { PROTO_TLSV1_2, PROTO_TLSV1_1, PROTO_TLSV1, PROTO_SSL3 });
|
||||
return builder;
|
||||
|
|
|
@ -245,17 +245,6 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a right angle bracket '>'.
|
||||
*
|
||||
* @return a reference to this object
|
||||
* @deprecated use {@link #rightAngleBracket()} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public XmlStringBuilder rightAngelBracket() {
|
||||
return rightAngleBracket();
|
||||
}
|
||||
|
||||
/**
|
||||
* Does nothing if value is null.
|
||||
*
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2018-2019 Florian Schmaus
|
||||
* Copyright 2018-2020 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -49,7 +49,7 @@ public class XmppElementUtil {
|
|||
namespace = (String) fullyQualifiedElement.getField("NAMESPACE").get(null);
|
||||
}
|
||||
catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
throw new IllegalArgumentException("The class" + fullyQualifiedElement + " has no ELEMENT, NAMSEPACE or QNAME member. Consider adding QNAME", e);
|
||||
}
|
||||
|
||||
return new QName(namespace, element);
|
||||
|
|
|
@ -223,6 +223,7 @@ public class PacketParserUtilsTest {
|
|||
|
||||
// message has default language, subject has no language
|
||||
control = XMLBuilder.create("message")
|
||||
.ns(StreamOpen.CLIENT_NAMESPACE)
|
||||
.a("from", "romeo@montague.lit/orchard")
|
||||
.a("to", "juliet@capulet.lit/balcony")
|
||||
.a("id", "zid615d9")
|
||||
|
@ -239,10 +240,11 @@ public class PacketParserUtilsTest {
|
|||
assertTrue(message.getSubjectLanguages().isEmpty());
|
||||
assertEquals(defaultLanguage, message.getSubject(defaultLanguage));
|
||||
assertNull(message.getSubject(otherLanguage));
|
||||
assertXmlSimilar(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
assertXmlSimilar(control, message.toXML());
|
||||
|
||||
// message has non-default language, subject has no language
|
||||
control = XMLBuilder.create("message")
|
||||
.ns(StreamOpen.CLIENT_NAMESPACE)
|
||||
.a("from", "romeo@montague.lit/orchard")
|
||||
.a("to", "juliet@capulet.lit/balcony")
|
||||
.a("id", "zid615d9")
|
||||
|
@ -258,10 +260,11 @@ public class PacketParserUtilsTest {
|
|||
assertTrue(message.getSubjectLanguages().isEmpty());
|
||||
assertEquals(otherLanguage, message.getSubject(otherLanguage));
|
||||
assertNull(message.getSubject(defaultLanguage));
|
||||
assertXmlSimilar(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
assertXmlSimilar(control, message.toXML());
|
||||
|
||||
// message has no language, subject has no language
|
||||
control = XMLBuilder.create("message")
|
||||
.ns(StreamOpen.CLIENT_NAMESPACE)
|
||||
.a("from", "romeo@montague.lit/orchard")
|
||||
.a("to", "juliet@capulet.lit/balcony")
|
||||
.a("id", "zid615d9")
|
||||
|
@ -276,10 +279,11 @@ public class PacketParserUtilsTest {
|
|||
assertTrue(message.getSubjectLanguages().isEmpty());
|
||||
assertEquals(defaultLanguage, message.getSubject(null));
|
||||
assertNull(message.getSubject(otherLanguage));
|
||||
assertXmlSimilar(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
assertXmlSimilar(control, message.toXML());
|
||||
|
||||
// message has no language, subject has default language
|
||||
control = XMLBuilder.create("message")
|
||||
.ns(StreamOpen.CLIENT_NAMESPACE)
|
||||
.a("from", "romeo@montague.lit/orchard")
|
||||
.a("to", "juliet@capulet.lit/balcony")
|
||||
.a("id", "zid615d9")
|
||||
|
@ -295,10 +299,11 @@ public class PacketParserUtilsTest {
|
|||
assertEquals(defaultLanguage, message.getSubject(defaultLanguage));
|
||||
assertNull(message.getSubject(otherLanguage));
|
||||
|
||||
assertXmlSimilar(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
assertXmlSimilar(control, message.toXML());
|
||||
|
||||
// message has no language, subject has non-default language
|
||||
control = XMLBuilder.create("message")
|
||||
.ns(StreamOpen.CLIENT_NAMESPACE)
|
||||
.a("from", "romeo@montague.lit/orchard")
|
||||
.a("to", "juliet@capulet.lit/balcony")
|
||||
.a("id", "zid615d9")
|
||||
|
@ -315,10 +320,11 @@ public class PacketParserUtilsTest {
|
|||
assertTrue(message.getSubjectLanguages().contains(otherLanguage));
|
||||
assertEquals(otherLanguage, message.getSubject(otherLanguage));
|
||||
assertNull(message.getSubject(defaultLanguage));
|
||||
assertXmlSimilar(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
assertXmlSimilar(control, message.toXML());
|
||||
|
||||
// message has default language, subject has non-default language
|
||||
control = XMLBuilder.create("message")
|
||||
.ns(StreamOpen.CLIENT_NAMESPACE)
|
||||
.a("from", "romeo@montague.lit/orchard")
|
||||
.a("to", "juliet@capulet.lit/balcony")
|
||||
.a("id", "zid615d9")
|
||||
|
@ -336,10 +342,11 @@ public class PacketParserUtilsTest {
|
|||
assertTrue(message.getSubjectLanguages().contains(otherLanguage));
|
||||
assertEquals(otherLanguage, message.getSubject(otherLanguage));
|
||||
assertNull(message.getSubject(defaultLanguage));
|
||||
assertXmlSimilar(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
assertXmlSimilar(control, message.toXML());
|
||||
|
||||
// message has non-default language, subject has default language
|
||||
control = XMLBuilder.create("message")
|
||||
.ns(StreamOpen.CLIENT_NAMESPACE)
|
||||
.a("from", "romeo@montague.lit/orchard")
|
||||
.a("to", "juliet@capulet.lit/balcony")
|
||||
.a("id", "zid615d9")
|
||||
|
@ -357,7 +364,7 @@ public class PacketParserUtilsTest {
|
|||
assertTrue(message.getSubjectLanguages().contains(defaultLanguage));
|
||||
assertEquals(defaultLanguage, message.getSubject(defaultLanguage));
|
||||
assertNull(message.getSubject(otherLanguage));
|
||||
assertXmlSimilar(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
assertXmlSimilar(control, message.toXML());
|
||||
|
||||
}
|
||||
|
||||
|
@ -523,6 +530,7 @@ public class PacketParserUtilsTest {
|
|||
|
||||
// message has default language, first subject no language, second subject other language
|
||||
control = XMLBuilder.create("message")
|
||||
.ns(StreamOpen.CLIENT_NAMESPACE)
|
||||
.a("from", "romeo@montague.lit/orchard")
|
||||
.a("to", "juliet@capulet.lit/balcony")
|
||||
.a("id", "zid615d9")
|
||||
|
@ -544,10 +552,11 @@ public class PacketParserUtilsTest {
|
|||
assertEquals(2, message.getSubjects().size());
|
||||
assertEquals(1, message.getSubjectLanguages().size());
|
||||
assertTrue(message.getSubjectLanguages().contains(otherLanguage));
|
||||
assertXmlSimilar(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
assertXmlSimilar(control, message.toXML());
|
||||
|
||||
// message has non-default language, first subject no language, second subject default language
|
||||
control = XMLBuilder.create("message")
|
||||
.ns(StreamOpen.CLIENT_NAMESPACE)
|
||||
.a("from", "romeo@montague.lit/orchard")
|
||||
.a("to", "juliet@capulet.lit/balcony")
|
||||
.a("id", "zid615d9")
|
||||
|
@ -569,7 +578,7 @@ public class PacketParserUtilsTest {
|
|||
assertEquals(2, message.getSubjects().size());
|
||||
assertEquals(1, message.getSubjectLanguages().size());
|
||||
assertTrue(message.getSubjectLanguages().contains(defaultLanguage));
|
||||
assertXmlSimilar(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
|
||||
assertXmlSimilar(control, message.toXML());
|
||||
|
||||
/*
|
||||
// message has no language, first subject no language, second subject default language
|
||||
|
|
|
@ -114,9 +114,9 @@ public class CarbonExtension implements ExtensionElement {
|
|||
* @return a Carbon if available, null otherwise.
|
||||
*/
|
||||
public static CarbonExtension from(Message msg) {
|
||||
CarbonExtension cc = msg.getExtension(Direction.received.name(), NAMESPACE);
|
||||
CarbonExtension cc = (CarbonExtension) msg.getExtension(Direction.received.name(), NAMESPACE);
|
||||
if (cc == null)
|
||||
cc = msg.getExtension(Direction.sent.name(), NAMESPACE);
|
||||
cc = (CarbonExtension) msg.getExtension(Direction.sent.name(), NAMESPACE);
|
||||
return cc;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2016 Fernando Ramirez, 2018 Florian Schmaus
|
||||
* Copyright © 2016 Fernando Ramirez, 2018-2020 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.chat_markers.element;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
|
@ -46,11 +48,11 @@ public class ChatMarkersElements {
|
|||
public static final class MarkableExtension implements ExtensionElement {
|
||||
|
||||
public static final MarkableExtension INSTANCE = new MarkableExtension();
|
||||
|
||||
/**
|
||||
* markable element.
|
||||
*/
|
||||
public static final String ELEMENT = ChatMarkersState.markable.toString();
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
private MarkableExtension() {
|
||||
}
|
||||
|
@ -73,7 +75,7 @@ public class ChatMarkersElements {
|
|||
}
|
||||
|
||||
public static MarkableExtension from(Message message) {
|
||||
return (MarkableExtension) message.getExtension(ELEMENT, NAMESPACE);
|
||||
return message.getExtension(MarkableExtension.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,6 +118,7 @@ public class ChatMarkersElements {
|
|||
* received element.
|
||||
*/
|
||||
public static final String ELEMENT = ChatMarkersState.received.toString();
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
public ReceivedExtension(String id) {
|
||||
super(id);
|
||||
|
@ -132,7 +135,7 @@ public class ChatMarkersElements {
|
|||
}
|
||||
|
||||
public static ReceivedExtension from(Message message) {
|
||||
return (ReceivedExtension) message.getExtension(ELEMENT, NAMESPACE);
|
||||
return message.getExtension(ReceivedExtension.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -150,6 +153,7 @@ public class ChatMarkersElements {
|
|||
* displayed element.
|
||||
*/
|
||||
public static final String ELEMENT = ChatMarkersState.displayed.toString();
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
public DisplayedExtension(String id) {
|
||||
super(id);
|
||||
|
@ -166,7 +170,7 @@ public class ChatMarkersElements {
|
|||
}
|
||||
|
||||
public static DisplayedExtension from(Message message) {
|
||||
return (DisplayedExtension) message.getExtension(ELEMENT, NAMESPACE);
|
||||
return message.getExtension(DisplayedExtension.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -184,6 +188,7 @@ public class ChatMarkersElements {
|
|||
* acknowledged element.
|
||||
*/
|
||||
public static final String ELEMENT = ChatMarkersState.acknowledged.toString();
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
public AcknowledgedExtension(String id) {
|
||||
super(id);
|
||||
|
@ -200,7 +205,7 @@ public class ChatMarkersElements {
|
|||
}
|
||||
|
||||
public static AcknowledgedExtension from(Message message) {
|
||||
return (AcknowledgedExtension) message.getExtension(ELEMENT, NAMESPACE);
|
||||
return message.getExtension(AcknowledgedExtension.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ public class ExplicitMessageEncryptionElement implements ExtensionElement {
|
|||
}
|
||||
|
||||
public static ExplicitMessageEncryptionElement from(Message message) {
|
||||
return message.getExtension(ELEMENT, NAMESPACE);
|
||||
return message.getExtension(ExplicitMessageEncryptionElement.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2014 Florian Schmaus
|
||||
* Copyright © 2014-2020 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.gcm.packet;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
|
||||
import org.jivesoftware.smackx.json.packet.AbstractJsonPacketExtension;
|
||||
|
@ -33,6 +35,7 @@ public class GcmPacketExtension extends AbstractJsonPacketExtension {
|
|||
|
||||
public static final String ELEMENT = "gcm";
|
||||
public static final String NAMESPACE = "google:mobile:data";
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
public GcmPacketExtension(String json) {
|
||||
super(json);
|
||||
|
@ -55,6 +58,6 @@ public class GcmPacketExtension extends AbstractJsonPacketExtension {
|
|||
* @return the GCM stanza extension or null.
|
||||
*/
|
||||
public static GcmPacketExtension from(Stanza packet) {
|
||||
return packet.getExtension(ELEMENT, NAMESPACE);
|
||||
return packet.getExtension(GcmPacketExtension.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2017 Florian Schmaus
|
||||
* Copyright 2017-2020 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -48,7 +48,7 @@ public final class NoCopyHint extends MessageProcessingHint {
|
|||
}
|
||||
|
||||
public static NoCopyHint from(Message message) {
|
||||
return message.getExtension(ELEMENT, NAMESPACE);
|
||||
return (NoCopyHint) message.getExtension(ELEMENT, NAMESPACE);
|
||||
}
|
||||
|
||||
public static boolean hasHint(Message message) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2017 Florian Schmaus
|
||||
* Copyright 2017-2020 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -48,7 +48,7 @@ public final class NoPermanentStoreHint extends MessageProcessingHint {
|
|||
}
|
||||
|
||||
public static NoPermanentStoreHint from(Message message) {
|
||||
return message.getExtension(ELEMENT, NAMESPACE);
|
||||
return (NoPermanentStoreHint) message.getExtension(ELEMENT, NAMESPACE);
|
||||
}
|
||||
|
||||
public static boolean hasHint(Message message) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2017 Florian Schmaus
|
||||
* Copyright 2017-2020 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -48,7 +48,7 @@ public final class NoStoreHint extends MessageProcessingHint {
|
|||
}
|
||||
|
||||
public static NoStoreHint from(Message message) {
|
||||
return message.getExtension(ELEMENT, NAMESPACE);
|
||||
return (NoStoreHint) message.getExtension(ELEMENT, NAMESPACE);
|
||||
}
|
||||
|
||||
public static boolean hasHint(Message message) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2017-2019 Florian Schmaus
|
||||
* Copyright 2017-2020 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -53,7 +53,7 @@ public final class StoreHint extends MessageProcessingHint {
|
|||
}
|
||||
|
||||
public static StoreHint from(MessageView message) {
|
||||
return message.getExtension(QNAME);
|
||||
return message.getExtension(StoreHint.class);
|
||||
}
|
||||
|
||||
public static boolean hasHint(MessageView message) {
|
||||
|
|
|
@ -21,12 +21,14 @@ import java.io.File;
|
|||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
@ -43,7 +45,7 @@ import org.jivesoftware.smack.SmackException;
|
|||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPConnectionRegistry;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
||||
import org.jivesoftware.smackx.httpfileupload.UploadService.Version;
|
||||
|
@ -245,7 +247,7 @@ public final class HttpFileUploadManager extends Manager {
|
|||
* Note that this is a synchronous call -- Smack must wait for the server response.
|
||||
*
|
||||
* @param file file to be uploaded
|
||||
* @param listener upload progress listener of null
|
||||
* @param listener Upload progress listener or null
|
||||
* @return public URL for sharing uploaded file
|
||||
*
|
||||
* @throws InterruptedException if the calling thread was interrupted.
|
||||
|
@ -259,12 +261,56 @@ public final class HttpFileUploadManager extends Manager {
|
|||
throw new FileNotFoundException("The path " + file.getAbsolutePath() + " is not a file");
|
||||
}
|
||||
final Slot slot = requestSlot(file.getName(), file.length(), "application/octet-stream");
|
||||
|
||||
uploadFile(file, slot, listener);
|
||||
|
||||
final long fileSize = file.length();
|
||||
// Construct the FileInputStream first to make sure we can actually read the file.
|
||||
final FileInputStream fis = new FileInputStream(file);
|
||||
upload(fis, fileSize, slot, listener);
|
||||
return slot.getGetUrl();
|
||||
}
|
||||
|
||||
/**
|
||||
* Request slot and uploaded stream to HTTP upload service.
|
||||
*
|
||||
* You don't need to request slot and upload input stream separately, this method will do both.
|
||||
* Note that this is a synchronous call -- Smack must wait for the server response.
|
||||
*
|
||||
* @param inputStream Input stream used for the upload.
|
||||
* @param fileName Name of the file.
|
||||
* @param fileSize Size of the file.
|
||||
* @return public URL for sharing uploaded file
|
||||
* @throws XMPPErrorException XMPPErrorException if there was an XMPP error returned.
|
||||
* @throws InterruptedException If the calling thread was interrupted.
|
||||
* @throws SmackException If Smack detected an exceptional situation.
|
||||
* @throws IOException If an I/O error occurred.
|
||||
*/
|
||||
public URL uploadFile(InputStream inputStream, String fileName, long fileSize) throws XMPPErrorException, InterruptedException, SmackException, IOException {
|
||||
return uploadFile(inputStream, fileName, fileSize, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Request slot and uploaded stream to HTTP upload service.
|
||||
*
|
||||
* You don't need to request slot and upload input stream separately, this method will do both.
|
||||
* Note that this is a synchronous call -- Smack must wait for the server response.
|
||||
*
|
||||
* @param inputStream Input stream used for the upload.
|
||||
* @param fileName Name of the file.
|
||||
* @param fileSize file size in bytes.
|
||||
* @param listener upload progress listener or null.
|
||||
* @return public URL for sharing uploaded file
|
||||
* @throws XMPPErrorException XMPPErrorException if there was an XMPP error returned.
|
||||
* @throws InterruptedException If the calling thread was interrupted.
|
||||
* @throws SmackException If Smack detected an exceptional situation.
|
||||
* @throws IOException If an I/O error occurred.
|
||||
*/
|
||||
public URL uploadFile(InputStream inputStream, String fileName, long fileSize, UploadProgressListener listener) throws XMPPErrorException, InterruptedException, SmackException, IOException {
|
||||
Objects.requireNonNull(inputStream, "Input Stream cannot be null");
|
||||
Objects.requireNonNull(fileName, "Filename Stream cannot be null");
|
||||
Objects.requireNonNull(fileSize, "Filesize Stream cannot be null");
|
||||
final Slot slot = requestSlot(fileName, fileSize, "application/octet-stream");
|
||||
upload(inputStream, fileSize, slot, listener);
|
||||
return slot.getGetUrl();
|
||||
}
|
||||
|
||||
/**
|
||||
* Request a new upload slot from default upload service (if discovered). When you get slot you should upload file
|
||||
|
@ -385,12 +431,7 @@ public final class HttpFileUploadManager extends Manager {
|
|||
setTlsContext(sslContext);
|
||||
}
|
||||
|
||||
private void uploadFile(final File file, final Slot slot, UploadProgressListener listener) throws IOException {
|
||||
final long fileSize = file.length();
|
||||
|
||||
// Construct the FileInputStream first to make sure we can actually read the file.
|
||||
final FileInputStream fis = new FileInputStream(file);
|
||||
|
||||
private void upload(InputStream iStream, long fileSize, Slot slot, UploadProgressListener listener) throws IOException {
|
||||
final URL putUrl = slot.getPutUrl();
|
||||
|
||||
final HttpURLConnection urlConnection = (HttpURLConnection) putUrl.openConnection();
|
||||
|
@ -419,7 +460,7 @@ public final class HttpFileUploadManager extends Manager {
|
|||
listener.onUploadProgress(0, fileSize);
|
||||
}
|
||||
|
||||
BufferedInputStream inputStream = new BufferedInputStream(fis);
|
||||
BufferedInputStream inputStream = new BufferedInputStream(iStream);
|
||||
|
||||
// TODO Factor in extra static method (and re-use e.g. in bytestream code).
|
||||
byte[] buffer = new byte[4096];
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2016 Florian Schmaus
|
||||
* Copyright © 2016-2020 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -20,6 +20,8 @@ import java.util.Collections;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
@ -30,6 +32,7 @@ public class IoTFieldsExtension implements ExtensionElement {
|
|||
|
||||
public static final String ELEMENT = "fields";
|
||||
public static final String NAMESPACE = Constants.IOT_SENSORDATA_NAMESPACE;
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
private final int seqNr;
|
||||
private final boolean done;
|
||||
|
@ -88,6 +91,6 @@ public class IoTFieldsExtension implements ExtensionElement {
|
|||
}
|
||||
|
||||
public static IoTFieldsExtension from(Message message) {
|
||||
return message.getExtension(ELEMENT, NAMESPACE);
|
||||
return message.getExtension(IoTFieldsExtension.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2016 Florian Schmaus
|
||||
* Copyright © 2016-2020 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.iot.provisioning.element;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.util.Objects;
|
||||
|
@ -27,6 +29,7 @@ public class Friend implements ExtensionElement {
|
|||
|
||||
public static final String ELEMENT = "friend";
|
||||
public static final String NAMESPACE = Constants.IOT_PROVISIONING_NAMESPACE;
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
private final BareJid friend;
|
||||
|
||||
|
@ -57,6 +60,6 @@ public class Friend implements ExtensionElement {
|
|||
}
|
||||
|
||||
public static Friend from(Message message) {
|
||||
return message.getExtension(ELEMENT, NAMESPACE);
|
||||
return message.getExtension(Friend.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2016 Florian Schmaus
|
||||
* Copyright © 2016-2020 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.iot.provisioning.element;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
@ -25,6 +27,7 @@ import org.jxmpp.jid.BareJid;
|
|||
public class Unfriend implements ExtensionElement {
|
||||
public static final String ELEMENT = "UNFRIEND";
|
||||
public static final String NAMESPACE = Constants.IOT_PROVISIONING_NAMESPACE;
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
private final BareJid jid;
|
||||
|
||||
|
@ -55,6 +58,6 @@ public class Unfriend implements ExtensionElement {
|
|||
}
|
||||
|
||||
public static Unfriend from(Message message) {
|
||||
return message.getExtension(ELEMENT, NAMESPACE);
|
||||
return message.getExtension(Unfriend.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2014 Florian Schmaus
|
||||
* Copyright © 2014-2020 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.json.packet;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
|
||||
/**
|
||||
|
@ -27,6 +29,7 @@ public class JsonPacketExtension extends AbstractJsonPacketExtension {
|
|||
|
||||
public static final String ELEMENT = "json";
|
||||
public static final String NAMESPACE = "urn:xmpp:json:0";
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
public JsonPacketExtension(String json) {
|
||||
super(json);
|
||||
|
@ -49,6 +52,6 @@ public class JsonPacketExtension extends AbstractJsonPacketExtension {
|
|||
* @return the JSON stanza extension or null.
|
||||
*/
|
||||
public static JsonPacketExtension from(Stanza packet) {
|
||||
return packet.getExtension(ELEMENT, NAMESPACE);
|
||||
return packet.getExtension(JsonPacketExtension.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@ import java.util.HashMap;
|
|||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.Element;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
|
@ -44,6 +46,7 @@ public abstract class MUCLightElements {
|
|||
|
||||
public static final String ELEMENT = DataForm.ELEMENT;
|
||||
public static final String NAMESPACE = MultiUserChatLight.NAMESPACE + MultiUserChatLight.AFFILIATIONS;
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
private final HashMap<Jid, MUCLightAffiliation> affiliations;
|
||||
private final String prevVersion;
|
||||
|
@ -112,7 +115,7 @@ public abstract class MUCLightElements {
|
|||
}
|
||||
|
||||
public static AffiliationsChangeExtension from(Message message) {
|
||||
return message.getExtension(AffiliationsChangeExtension.ELEMENT, AffiliationsChangeExtension.NAMESPACE);
|
||||
return message.getExtension(AffiliationsChangeExtension.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -230,7 +233,7 @@ public abstract class MUCLightElements {
|
|||
}
|
||||
|
||||
public static ConfigurationsChangeExtension from(Message message) {
|
||||
return message.getExtension(ConfigurationsChangeExtension.ELEMENT, ConfigurationsChangeExtension.NAMESPACE);
|
||||
return (ConfigurationsChangeExtension) message.getExtension(ConfigurationsChangeExtension.ELEMENT, ConfigurationsChangeExtension.NAMESPACE);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.push_notifications.element;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
@ -40,6 +42,7 @@ public class PushNotificationsElements {
|
|||
|
||||
public static final String NAMESPACE = PubSub.NAMESPACE;
|
||||
public static final String ELEMENT = PubSub.ELEMENT;
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
private final String node;
|
||||
private final Jid userJid;
|
||||
|
@ -94,7 +97,7 @@ public class PushNotificationsElements {
|
|||
}
|
||||
|
||||
public static RemoteDisablingExtension from(Message message) {
|
||||
return message.getExtension(ELEMENT, NAMESPACE);
|
||||
return message.getExtension(RemoteDisablingExtension.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ public class OriginIdElement extends StableAndUniqueIdElement {
|
|||
* @return origin-id element
|
||||
*/
|
||||
public static OriginIdElement getOriginId(Message message) {
|
||||
return message.getExtension(OriginIdElement.ELEMENT, StableUniqueStanzaIdManager.NAMESPACE);
|
||||
return (OriginIdElement) message.getExtension(OriginIdElement.ELEMENT, StableUniqueStanzaIdManager.NAMESPACE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.sid.element;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
||||
|
@ -24,6 +26,8 @@ import org.jivesoftware.smackx.sid.StableUniqueStanzaIdManager;
|
|||
public class StanzaIdElement extends StableAndUniqueIdElement {
|
||||
|
||||
public static final String ELEMENT = "stanza-id";
|
||||
public static final String NAMESPACE = StableUniqueStanzaIdManager.NAMESPACE;
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
public static final String ATTR_BY = "by";
|
||||
|
||||
private final String by;
|
||||
|
@ -55,7 +59,7 @@ public class StanzaIdElement extends StableAndUniqueIdElement {
|
|||
* @return stanza-id element of a jid, or null if absent.
|
||||
*/
|
||||
public static StanzaIdElement getStanzaId(Message message) {
|
||||
return message.getExtension(StanzaIdElement.ELEMENT, StableUniqueStanzaIdManager.NAMESPACE);
|
||||
return message.getExtension(StanzaIdElement.class);
|
||||
}
|
||||
|
||||
public String getBy() {
|
||||
|
|
|
@ -44,7 +44,7 @@ public class SpoilerTest extends SmackTestSuite {
|
|||
Message message = StanzaBuilder.buildMessage().build();
|
||||
SpoilerElement.addSpoiler(message);
|
||||
|
||||
SpoilerElement empty = message.getExtension(SpoilerElement.ELEMENT, SpoilerManager.NAMESPACE_0);
|
||||
SpoilerElement empty = (SpoilerElement) message.getExtension(SpoilerElement.ELEMENT, SpoilerManager.NAMESPACE_0);
|
||||
|
||||
assertNull(empty.getHint());
|
||||
assertNull(empty.getLanguage());
|
||||
|
@ -63,7 +63,7 @@ public class SpoilerTest extends SmackTestSuite {
|
|||
Message message = StanzaBuilder.buildMessage().build();
|
||||
SpoilerElement.addSpoiler(message, "Love story end");
|
||||
|
||||
SpoilerElement withHint = message.getExtension(SpoilerElement.ELEMENT, SpoilerManager.NAMESPACE_0);
|
||||
SpoilerElement withHint = (SpoilerElement) message.getExtension(SpoilerElement.ELEMENT, SpoilerManager.NAMESPACE_0);
|
||||
|
||||
assertEquals("Love story end", withHint.getHint());
|
||||
assertNull(withHint.getLanguage());
|
||||
|
@ -83,7 +83,7 @@ public class SpoilerTest extends SmackTestSuite {
|
|||
Message message = StanzaBuilder.buildMessage().build();
|
||||
SpoilerElement.addSpoiler(message, "de", "Der Kuchen ist eine Lüge!");
|
||||
|
||||
SpoilerElement i18nHint = message.getExtension(SpoilerElement.ELEMENT, SpoilerManager.NAMESPACE_0);
|
||||
SpoilerElement i18nHint = (SpoilerElement) message.getExtension(SpoilerElement.ELEMENT, SpoilerManager.NAMESPACE_0);
|
||||
|
||||
assertEquals("Der Kuchen ist eine Lüge!", i18nHint.getHint());
|
||||
assertEquals("de", i18nHint.getLanguage());
|
||||
|
|
|
@ -203,7 +203,7 @@ public class MultipleRecipientManager {
|
|||
* if none was found.
|
||||
*/
|
||||
public static MultipleRecipientInfo getMultipleRecipientInfo(Stanza packet) {
|
||||
MultipleAddresses extension = packet.getExtension(MultipleAddresses.ELEMENT, MultipleAddresses.NAMESPACE);
|
||||
MultipleAddresses extension = packet.getExtension(MultipleAddresses.class);
|
||||
return extension == null ? null : new MultipleRecipientInfo(extension);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@ package org.jivesoftware.smackx.address.packet;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
||||
|
@ -34,6 +36,7 @@ public class MultipleAddresses implements ExtensionElement {
|
|||
|
||||
public static final String NAMESPACE = "http://jabber.org/protocol/address";
|
||||
public static final String ELEMENT = "addresses";
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
public enum Type {
|
||||
bcc,
|
||||
|
|
|
@ -91,7 +91,7 @@ public class BoBExtension extends XHTMLExtension {
|
|||
}
|
||||
|
||||
public static BoBExtension from(Message message) {
|
||||
return message.getExtension(ELEMENT, NAMESPACE);
|
||||
return (BoBExtension) message.getExtension(ELEMENT, NAMESPACE);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -535,8 +535,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
public void processStanza(Stanza packet) {
|
||||
// get data packet extension
|
||||
DataPacketExtension data = packet.getExtension(
|
||||
DataPacketExtension.ELEMENT,
|
||||
DataPacketExtension.NAMESPACE);
|
||||
DataPacketExtension.class);
|
||||
|
||||
// check if encoded data is valid
|
||||
if (data.getDecodedData() == null) {
|
||||
|
@ -590,8 +589,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
} else {
|
||||
// stanza contains data packet extension
|
||||
data = packet.getExtension(
|
||||
DataPacketExtension.ELEMENT,
|
||||
DataPacketExtension.NAMESPACE);
|
||||
DataPacketExtension.class);
|
||||
if (data == null) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.bytestreams.ibb.packet;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.IQ.IQChildElementXmlStringBuilder;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
@ -39,6 +41,8 @@ public class DataPacketExtension implements ExtensionElement {
|
|||
*/
|
||||
public static final String NAMESPACE = "http://jabber.org/protocol/ibb";
|
||||
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
/* unique session ID identifying this In-Band Bytestream */
|
||||
private final String sessionID;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2009 Jonas Ådahl, 2011-2014 Florian Schmaus
|
||||
* Copyright © 2009 Jonas Ådahl, 2011-2020 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.caps.packet;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
@ -26,6 +28,7 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
|
|||
public class CapsExtension implements ExtensionElement {
|
||||
public static final String NAMESPACE = "http://jabber.org/protocol/caps";
|
||||
public static final String ELEMENT = "c";
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
private final String node, ver, hash;
|
||||
|
||||
|
@ -77,6 +80,6 @@ public class CapsExtension implements ExtensionElement {
|
|||
}
|
||||
|
||||
public static CapsExtension from(Stanza stanza) {
|
||||
return stanza.getExtension(ELEMENT, NAMESPACE);
|
||||
return stanza.getExtension(CapsExtension.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2014 Florian Schmaus
|
||||
* Copyright © 2014-2020 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -18,6 +18,8 @@ package org.jivesoftware.smackx.delay;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
|
||||
|
@ -34,6 +36,7 @@ public class DelayInformationManager {
|
|||
|
||||
public static final String LEGACY_DELAYED_DELIVERY_NAMESPACE = "jabber:x:delay";
|
||||
public static final String LEGACY_DELAYED_DELIVERY_ELEMENT = "x";
|
||||
public static final QName QNAME = new QName(LEGACY_DELAYED_DELIVERY_NAMESPACE, LEGACY_DELAYED_DELIVERY_ELEMENT);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -57,7 +60,7 @@ public class DelayInformationManager {
|
|||
* @return the Delayed Delivery information or <code>null</code>
|
||||
*/
|
||||
public static DelayInformation getLegacyDelayInformation(Stanza packet) {
|
||||
return packet.getExtension(LEGACY_DELAYED_DELIVERY_ELEMENT, LEGACY_DELAYED_DELIVERY_NAMESPACE);
|
||||
return packet.getExtension(DelayInformation.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,6 +18,8 @@ package org.jivesoftware.smackx.delay.packet;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
@ -39,6 +41,7 @@ import org.jxmpp.util.XmppDateTime;
|
|||
public class DelayInformation implements ExtensionElement {
|
||||
public static final String ELEMENT = "delay";
|
||||
public static final String NAMESPACE = "urn:xmpp:delay";
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
private final Date stamp;
|
||||
private final String from;
|
||||
|
@ -129,6 +132,6 @@ public class DelayInformation implements ExtensionElement {
|
|||
* @return the DelayInformation or null
|
||||
*/
|
||||
public static DelayInformation from(Stanza packet) {
|
||||
return packet.getExtension(ELEMENT, NAMESPACE);
|
||||
return packet.getExtension(DelayInformation.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@ import java.util.ArrayList;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
|
@ -36,6 +38,7 @@ import org.jivesoftware.smackx.delay.packet.DelayInformation;
|
|||
public class Forwarded implements ExtensionElement {
|
||||
public static final String NAMESPACE = "urn:xmpp:forward:0";
|
||||
public static final String ELEMENT = "forwarded";
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
private final DelayInformation delay;
|
||||
private final Stanza forwardedPacket;
|
||||
|
@ -80,17 +83,6 @@ public class Forwarded implements ExtensionElement {
|
|||
return xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the stanza forwarded by this stanza.
|
||||
*
|
||||
* @return the {@link Stanza} instance (typically a message) that was forwarded.
|
||||
* @deprecated use @{link {@link #getForwardedStanza()}} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public Stanza getForwardedPacket() {
|
||||
return forwardedPacket;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the forwarded Stanza found in this extension.
|
||||
*
|
||||
|
@ -115,7 +107,7 @@ public class Forwarded implements ExtensionElement {
|
|||
* @return the Forwarded extension or null
|
||||
*/
|
||||
public static Forwarded from(Stanza packet) {
|
||||
return packet.getExtension(ELEMENT, NAMESPACE);
|
||||
return packet.getExtension(Forwarded.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -274,7 +274,7 @@ public final class GeoLocation implements Serializable, ExtensionElement, FormFi
|
|||
}
|
||||
|
||||
public static GeoLocation from(Message message) {
|
||||
return message.getExtension(ELEMENT, NAMESPACE);
|
||||
return message.getExtension(GeoLocation.class);
|
||||
}
|
||||
|
||||
public static GeoLocation from(FormField formField) {
|
||||
|
|
|
@ -95,7 +95,7 @@ public class JivePropertiesManager {
|
|||
*/
|
||||
public static Object getProperty(StanzaView packet, String name) {
|
||||
Object res = null;
|
||||
JivePropertiesExtension jpe = (JivePropertiesExtension) packet.getExtension(JivePropertiesExtension.QNAME);
|
||||
JivePropertiesExtension jpe = packet.getExtension(JivePropertiesExtension.class);
|
||||
if (jpe != null) {
|
||||
res = jpe.getProperty(name);
|
||||
}
|
||||
|
|
|
@ -213,6 +213,6 @@ public class JivePropertiesExtension implements ExtensionElement {
|
|||
* @since 4.2
|
||||
*/
|
||||
public static JivePropertiesExtension from(Message message) {
|
||||
return message.getExtension(ELEMENT, NAMESPACE);
|
||||
return message.getExtension(JivePropertiesExtension.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@ package org.jivesoftware.smackx.last_interaction.element;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Presence;
|
||||
import org.jivesoftware.smack.util.Objects;
|
||||
|
@ -27,6 +29,7 @@ public class IdleElement implements ExtensionElement {
|
|||
|
||||
public static final String NAMESPACE = "urn:xmpp:idle:1";
|
||||
public static final String ELEMENT = "idle";
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
public static final String ATTR_SINCE = "since";
|
||||
|
||||
private final Date since;
|
||||
|
@ -70,7 +73,7 @@ public class IdleElement implements ExtensionElement {
|
|||
* @return idleElement from presence or null
|
||||
*/
|
||||
public static IdleElement fromPresence(Presence presence) {
|
||||
return presence.getExtension(ELEMENT, NAMESPACE);
|
||||
return presence.getExtension(IdleElement.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.message_correct.element;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
|
@ -44,6 +46,8 @@ public class MessageCorrectExtension implements ExtensionElement {
|
|||
*/
|
||||
public static final String NAMESPACE = "urn:xmpp:message-correct:0";
|
||||
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
/**
|
||||
* The id tag of a 'message correct' extension.
|
||||
*/
|
||||
|
@ -81,7 +85,7 @@ public class MessageCorrectExtension implements ExtensionElement {
|
|||
}
|
||||
|
||||
public static MessageCorrectExtension from(Message message) {
|
||||
return message.getExtension(ELEMENT, NAMESPACE);
|
||||
return message.getExtension(MessageCorrectExtension.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.mood.element;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.FullyQualifiedElement;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
|
@ -36,6 +38,8 @@ public class MoodElement implements ExtensionElement {
|
|||
|
||||
public static final String NAMESPACE = "http://jabber.org/protocol/mood";
|
||||
public static final String ELEMENT = "mood";
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
public static final String ELEM_TEXT = "text";
|
||||
|
||||
private final MoodSubjectElement mood;
|
||||
|
@ -136,7 +140,7 @@ public class MoodElement implements ExtensionElement {
|
|||
* @return {@link MoodElement} or null.
|
||||
*/
|
||||
public static MoodElement fromMessage(Message message) {
|
||||
return message.getExtension(ELEMENT, NAMESPACE);
|
||||
return message.getExtension(MoodElement.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,6 +19,8 @@ package org.jivesoftware.smackx.muc.packet;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||
|
@ -68,6 +70,8 @@ public class GroupChatInvitation implements ExtensionElement {
|
|||
*/
|
||||
public static final String NAMESPACE = "jabber:x:conference";
|
||||
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
private final String roomAddress;
|
||||
|
||||
/**
|
||||
|
@ -111,24 +115,13 @@ public class GroupChatInvitation implements ExtensionElement {
|
|||
return xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @param packet TODO javadoc me please
|
||||
* @return the GroupChatInvitation or null
|
||||
* @deprecated use {@link #from(Stanza)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static GroupChatInvitation getFrom(Stanza packet) {
|
||||
return from(packet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the group chat invitation from the given stanza.
|
||||
* @param packet TODO javadoc me please
|
||||
* @return the GroupChatInvitation or null
|
||||
*/
|
||||
public static GroupChatInvitation from(Stanza packet) {
|
||||
return packet.getExtension(ELEMENT, NAMESPACE);
|
||||
return packet.getExtension(GroupChatInvitation.class);
|
||||
}
|
||||
|
||||
public static class Provider extends ExtensionElementProvider<GroupChatInvitation> {
|
||||
|
|
|
@ -19,6 +19,8 @@ package org.jivesoftware.smackx.muc.packet;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.NamedElement;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
|
@ -42,6 +44,7 @@ public class MUCInitialPresence implements ExtensionElement {
|
|||
|
||||
public static final String ELEMENT = "x";
|
||||
public static final String NAMESPACE = "http://jabber.org/protocol/muc";
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
// TODO make those fields final once deprecated setter methods have been removed.
|
||||
private String password;
|
||||
|
@ -156,7 +159,7 @@ public class MUCInitialPresence implements ExtensionElement {
|
|||
* @return the MUCInitialPresence PacketExtension or {@code null}
|
||||
*/
|
||||
public static MUCInitialPresence from(Stanza packet) {
|
||||
return packet.getExtension(ELEMENT, NAMESPACE);
|
||||
return packet.getExtension(MUCInitialPresence.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,6 +22,8 @@ import java.util.HashSet;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.NamedElement;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
|
@ -41,6 +43,7 @@ public class MUCUser implements ExtensionElement {
|
|||
|
||||
public static final String ELEMENT = "x";
|
||||
public static final String NAMESPACE = MUCInitialPresence.NAMESPACE + "#user";
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
private final Set<Status> statusCodes = new HashSet<>(4);
|
||||
|
||||
|
@ -236,7 +239,7 @@ public class MUCUser implements ExtensionElement {
|
|||
* @return the MUCUser PacketExtension or {@code null}
|
||||
*/
|
||||
public static MUCUser from(Stanza packet) {
|
||||
return packet.getExtension(ELEMENT, NAMESPACE);
|
||||
return packet.getExtension(MUCUser.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,9 +19,12 @@ package org.jivesoftware.smackx.offline;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.jivesoftware.smack.Manager;
|
||||
import org.jivesoftware.smack.SmackException.NoResponseException;
|
||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
import org.jivesoftware.smack.StanzaCollector;
|
||||
|
@ -58,19 +61,31 @@ import org.jivesoftware.smackx.xdata.Form;
|
|||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class OfflineMessageManager {
|
||||
public final class OfflineMessageManager extends Manager {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(OfflineMessageManager.class.getName());
|
||||
|
||||
private static final String namespace = "http://jabber.org/protocol/offline";
|
||||
|
||||
private final XMPPConnection connection;
|
||||
private static final Map<XMPPConnection, OfflineMessageManager> INSTANCES = new WeakHashMap<>();
|
||||
|
||||
private static final StanzaFilter PACKET_FILTER = new AndFilter(new StanzaExtensionFilter(
|
||||
new OfflineMessageInfo()), StanzaTypeFilter.MESSAGE);
|
||||
|
||||
public OfflineMessageManager(XMPPConnection connection) {
|
||||
this.connection = connection;
|
||||
private ServiceDiscoveryManager serviceDiscoveryManager;
|
||||
|
||||
private OfflineMessageManager(XMPPConnection connection) {
|
||||
super(connection);
|
||||
this.serviceDiscoveryManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||
}
|
||||
|
||||
public static synchronized OfflineMessageManager getInstanceFor(XMPPConnection connection) {
|
||||
OfflineMessageManager manager = INSTANCES.get(connection);
|
||||
if (manager == null) {
|
||||
manager = new OfflineMessageManager(connection);
|
||||
INSTANCES.put(connection, manager);
|
||||
}
|
||||
return manager;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -85,7 +100,7 @@ public class OfflineMessageManager {
|
|||
* @throws InterruptedException if the calling thread was interrupted.
|
||||
*/
|
||||
public boolean supportsFlexibleRetrieval() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
return ServiceDiscoveryManager.getInstanceFor(connection).serverSupportsFeature(namespace);
|
||||
return serviceDiscoveryManager.serverSupportsFeature(namespace);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -99,8 +114,7 @@ public class OfflineMessageManager {
|
|||
* @throws InterruptedException if the calling thread was interrupted.
|
||||
*/
|
||||
public int getMessageCount() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
DiscoverInfo info = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(null,
|
||||
namespace);
|
||||
DiscoverInfo info = serviceDiscoveryManager.discoverInfo(null, namespace);
|
||||
Form extendedInfo = Form.getFormFrom(info);
|
||||
if (extendedInfo != null) {
|
||||
String value = extendedInfo.getField("number_of_messages").getFirstValue();
|
||||
|
@ -124,8 +138,7 @@ public class OfflineMessageManager {
|
|||
*/
|
||||
public List<OfflineMessageHeader> getHeaders() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
List<OfflineMessageHeader> answer = new ArrayList<>();
|
||||
DiscoverItems items = ServiceDiscoveryManager.getInstanceFor(connection).discoverItems(
|
||||
null, namespace);
|
||||
DiscoverItems items = serviceDiscoveryManager.discoverItems(null, namespace);
|
||||
for (DiscoverItems.Item item : items.getItems()) {
|
||||
answer.add(new OfflineMessageHeader(item));
|
||||
}
|
||||
|
@ -159,14 +172,13 @@ public class OfflineMessageManager {
|
|||
StanzaFilter messageFilter = new AndFilter(PACKET_FILTER, new StanzaFilter() {
|
||||
@Override
|
||||
public boolean accept(Stanza packet) {
|
||||
OfflineMessageInfo info = packet.getExtension("offline",
|
||||
namespace);
|
||||
OfflineMessageInfo info = packet.getExtension(OfflineMessageInfo.class);
|
||||
return nodes.contains(info.getNode());
|
||||
}
|
||||
});
|
||||
int pendingNodes = nodes.size();
|
||||
try (StanzaCollector messageCollector = connection.createStanzaCollector(messageFilter)) {
|
||||
connection.createStanzaCollectorAndSend(request).nextResultOrThrow();
|
||||
try (StanzaCollector messageCollector = connection().createStanzaCollector(messageFilter)) {
|
||||
connection().createStanzaCollectorAndSend(request).nextResultOrThrow();
|
||||
// Collect the received offline messages
|
||||
Message message;
|
||||
do {
|
||||
|
@ -199,11 +211,11 @@ public class OfflineMessageManager {
|
|||
OfflineMessageRequest request = new OfflineMessageRequest();
|
||||
request.setFetch(true);
|
||||
|
||||
StanzaCollector resultCollector = connection.createStanzaCollectorAndSend(request);
|
||||
StanzaCollector resultCollector = connection().createStanzaCollectorAndSend(request);
|
||||
StanzaCollector.Configuration messageCollectorConfiguration = StanzaCollector.newConfiguration().setStanzaFilter(PACKET_FILTER).setCollectorToReset(resultCollector);
|
||||
|
||||
List<Message> messages;
|
||||
try (StanzaCollector messageCollector = connection.createStanzaCollector(messageCollectorConfiguration)) {
|
||||
try (StanzaCollector messageCollector = connection().createStanzaCollector(messageCollectorConfiguration)) {
|
||||
resultCollector.nextResultOrThrow();
|
||||
// Be extra safe, cancel the message collector right here so that it does not collector
|
||||
// other messages that eventually match (although I've no idea how this could happen in
|
||||
|
@ -237,7 +249,7 @@ public class OfflineMessageManager {
|
|||
item.setAction("remove");
|
||||
request.addItem(item);
|
||||
}
|
||||
connection.createStanzaCollectorAndSend(request).nextResultOrThrow();
|
||||
connection().createStanzaCollectorAndSend(request).nextResultOrThrow();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -253,6 +265,6 @@ public class OfflineMessageManager {
|
|||
OfflineMessageRequest request = new OfflineMessageRequest();
|
||||
request.setType(IQ.Type.set);
|
||||
request.setPurge(true);
|
||||
connection.createStanzaCollectorAndSend(request).nextResultOrThrow();
|
||||
connection().createStanzaCollectorAndSend(request).nextResultOrThrow();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@ package org.jivesoftware.smackx.pubsub;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
@ -44,6 +46,8 @@ public class EventElement implements EmbeddedPacketExtension {
|
|||
*/
|
||||
public static final String NAMESPACE = PubSubNamespace.event.getXmlns();
|
||||
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
private final EventElementType type;
|
||||
private final NodeExtension ext;
|
||||
|
||||
|
@ -85,6 +89,6 @@ public class EventElement implements EmbeddedPacketExtension {
|
|||
}
|
||||
|
||||
public static EventElement from(Stanza stanza) {
|
||||
return stanza.getExtension(ELEMENT, NAMESPACE);
|
||||
return stanza.getExtension(EventElement.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -656,7 +656,7 @@ public abstract class Node {
|
|||
|
||||
|
||||
private static List<String> getSubscriptionIds(Stanza packet) {
|
||||
HeadersExtension headers = packet.getExtension("headers", "http://jabber.org/protocol/shim");
|
||||
HeadersExtension headers = packet.getExtension(HeadersExtension.class);
|
||||
List<String> values = null;
|
||||
|
||||
if (headers != null) {
|
||||
|
@ -686,7 +686,7 @@ public abstract class Node {
|
|||
@Override
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public void processStanza(Stanza packet) {
|
||||
EventElement event = packet.getExtension("event", PubSubNamespace.event.getXmlns());
|
||||
EventElement event = (EventElement) packet.getExtension("event", PubSubNamespace.event.getXmlns());
|
||||
ItemsExtension itemsElem = (ItemsExtension) event.getEvent();
|
||||
ItemPublishEvent eventItems = new ItemPublishEvent(itemsElem.getNode(), itemsElem.getItems(), getSubscriptionIds(packet), DelayInformationManager.getDelayTimestamp(packet));
|
||||
// TODO: Use AsyncButOrdered (with Node as Key?)
|
||||
|
@ -710,7 +710,7 @@ public abstract class Node {
|
|||
@Override
|
||||
public void processStanza(Stanza packet) {
|
||||
// CHECKSTYLE:OFF
|
||||
EventElement event = packet.getExtension("event", PubSubNamespace.event.getXmlns());
|
||||
EventElement event = (EventElement) packet.getExtension("event", PubSubNamespace.event.getXmlns());
|
||||
|
||||
List<ExtensionElement> extList = event.getExtensions();
|
||||
|
||||
|
@ -749,7 +749,7 @@ public abstract class Node {
|
|||
|
||||
@Override
|
||||
public void processStanza(Stanza packet) {
|
||||
EventElement event = packet.getExtension("event", PubSubNamespace.event.getXmlns());
|
||||
EventElement event = (EventElement) packet.getExtension("event", PubSubNamespace.event.getXmlns());
|
||||
ConfigurationEvent config = (ConfigurationEvent) event.getEvent();
|
||||
|
||||
// TODO: Use AsyncButOrdered (with Node as Key?)
|
||||
|
|
|
@ -25,6 +25,8 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.Manager;
|
||||
import org.jivesoftware.smack.SmackException.NoResponseException;
|
||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
|
@ -213,7 +215,8 @@ public final class PubSubManager extends Manager {
|
|||
*/
|
||||
public LeafNode createNode() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
PubSub reply = sendPubsubPacket(Type.set, new NodeExtension(PubSubElementType.CREATE), null);
|
||||
NodeExtension elem = reply.getExtension("create", PubSubNamespace.basic.getXmlns());
|
||||
QName qname = new QName(PubSubNamespace.basic.getXmlns(), "create");
|
||||
NodeExtension elem = (NodeExtension) reply.getExtension(qname);
|
||||
|
||||
LeafNode newNode = new LeafNode(this, elem.getNode());
|
||||
nodeMap.put(newNode.getId(), newNode);
|
||||
|
@ -500,7 +503,7 @@ public final class PubSubManager extends Manager {
|
|||
*/
|
||||
public List<Subscription> getSubscriptions() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
Stanza reply = sendPubsubPacket(Type.get, new NodeExtension(PubSubElementType.SUBSCRIPTIONS), null);
|
||||
SubscriptionsExtension subElem = reply.getExtension(PubSubElementType.SUBSCRIPTIONS.getElementName(), PubSubElementType.SUBSCRIPTIONS.getNamespace().getXmlns());
|
||||
SubscriptionsExtension subElem = (SubscriptionsExtension) reply.getExtension(PubSubElementType.SUBSCRIPTIONS.getElementName(), PubSubElementType.SUBSCRIPTIONS.getNamespace().getXmlns());
|
||||
return subElem.getSubscriptions();
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ public class NodeUtils {
|
|||
* @return The configuration form
|
||||
*/
|
||||
public static ConfigureForm getFormFromPacket(Stanza packet, PubSubElementType elem) {
|
||||
FormNode config = packet.getExtension(elem.getElementName(), elem.getNamespace().getXmlns());
|
||||
FormNode config = (FormNode) packet.getExtension(elem.getElementName(), elem.getNamespace().getXmlns());
|
||||
Form formReply = config.getForm();
|
||||
return new ConfigureForm(formReply);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@ package org.jivesoftware.smackx.receipts;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.provider.EmbeddedExtensionProvider;
|
||||
|
@ -33,6 +35,7 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
|
|||
public class DeliveryReceipt implements ExtensionElement {
|
||||
public static final String NAMESPACE = "urn:xmpp:receipts";
|
||||
public static final String ELEMENT = "received";
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
/**
|
||||
* original ID of the delivered message
|
||||
|
@ -89,7 +92,7 @@ public class DeliveryReceipt implements ExtensionElement {
|
|||
* @return the {@link DeliveryReceipt} extension or {@code null}
|
||||
*/
|
||||
public static DeliveryReceipt from(Message message) {
|
||||
return message.getExtension(ELEMENT, NAMESPACE);
|
||||
return message.getExtension(DeliveryReceipt.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,6 +18,8 @@ package org.jivesoftware.smackx.receipts;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.MessageBuilder;
|
||||
|
@ -35,6 +37,8 @@ import org.jivesoftware.smack.xml.XmlPullParserException;
|
|||
*/
|
||||
public class DeliveryReceiptRequest implements ExtensionElement {
|
||||
public static final String ELEMENT = "request";
|
||||
public static final String NAMESPACE = DeliveryReceipt.NAMESPACE;
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
@Override
|
||||
public String getElementName() {
|
||||
|
@ -70,7 +74,7 @@ public class DeliveryReceiptRequest implements ExtensionElement {
|
|||
* @return the {@link DeliveryReceiptRequest} extension or {@code null}
|
||||
*/
|
||||
public static DeliveryReceiptRequest from(Stanza packet) {
|
||||
return packet.getExtension(ELEMENT, DeliveryReceipt.NAMESPACE);
|
||||
return packet.getExtension(DeliveryReceiptRequest.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2014 Florian Schmaus
|
||||
* Copyright © 2014-2020 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.rsm.packet;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
@ -24,6 +26,7 @@ public class RSMSet implements ExtensionElement {
|
|||
|
||||
public static final String ELEMENT = "set";
|
||||
public static final String NAMESPACE = "http://jabber.org/protocol/rsm";
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
private final String after;
|
||||
private final String before;
|
||||
|
|
|
@ -204,7 +204,7 @@ public class UserSearch extends SimpleIQ {
|
|||
done = true;
|
||||
}
|
||||
}
|
||||
if (search.getExtension("x", "jabber:x:data") == null) {
|
||||
if (search.getExtension(DataForm.class) == null) {
|
||||
search.addExtension(dataForm);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@ package org.jivesoftware.smackx.shim.packet;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
@ -33,6 +35,7 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
|
|||
public class HeadersExtension implements ExtensionElement {
|
||||
public static final String ELEMENT = "headers";
|
||||
public static final String NAMESPACE = "http://jabber.org/protocol/shim";
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
private final List<Header> headers;
|
||||
|
||||
|
@ -74,6 +77,6 @@ public class HeadersExtension implements ExtensionElement {
|
|||
* @return the headers extension or null.
|
||||
*/
|
||||
public static HeadersExtension from(Stanza packet) {
|
||||
return packet.getExtension(ELEMENT, NAMESPACE);
|
||||
return packet.getExtension(HeadersExtension.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@ package org.jivesoftware.smackx.usertune.element;
|
|||
|
||||
import java.net.URI;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.jivesoftware.smack.datatypes.UInt16;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
|
@ -35,6 +37,7 @@ public final class UserTuneElement implements ExtensionElement {
|
|||
|
||||
public static final String NAMESPACE = "http://jabber.org/protocol/tune";
|
||||
public static final String ELEMENT = "tune";
|
||||
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||
|
||||
private final String artist;
|
||||
private final UInt16 length;
|
||||
|
@ -116,11 +119,11 @@ public final class UserTuneElement implements ExtensionElement {
|
|||
}
|
||||
|
||||
public static boolean hasUserTuneElement(Message message) {
|
||||
return message.hasExtension(ELEMENT, NAMESPACE);
|
||||
return message.hasExtension(UserTuneElement.class);
|
||||
}
|
||||
|
||||
public static UserTuneElement from(Message message) {
|
||||
return message.getExtension(ELEMENT, NAMESPACE);
|
||||
return message.getExtension(UserTuneElement.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -361,7 +361,7 @@ public class DataForm implements ExtensionElement {
|
|||
* @return the DataForm or null
|
||||
*/
|
||||
public static DataForm from(StanzaView stanzaView) {
|
||||
return (DataForm) stanzaView.getExtension(QNAME);
|
||||
return stanzaView.getExtension(DataForm.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -130,6 +130,6 @@ public class XHTMLExtension implements ExtensionElement {
|
|||
}
|
||||
|
||||
public static XHTMLExtension from(MessageView message) {
|
||||
return message.getExtension(QNAME);
|
||||
return message.getExtension(XHTMLExtension.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,13 +16,13 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smack.extensions.ExtensionsInitializer;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class ExtensionsInitializerTest {
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.amp;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -30,15 +30,15 @@ import org.jivesoftware.smack.xml.XmlPullParser;
|
|||
import org.jivesoftware.smackx.amp.packet.AMPExtension;
|
||||
import org.jivesoftware.smackx.amp.provider.AMPExtensionProvider;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class AMPExtensionTest {
|
||||
|
||||
private InputStream CORRECT_SENDING_STANZA_STREAM;
|
||||
private InputStream INCORRECT_RECEIVING_STANZA_STREAM;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
CORRECT_SENDING_STANZA_STREAM = getClass().getResourceAsStream("correct_stanza_test.xml");
|
||||
INCORRECT_RECEIVING_STANZA_STREAM = getClass().getResourceAsStream("incorrect_stanza_test.xml");
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.jivesoftware.smack.util.PacketParserUtils;
|
|||
|
||||
import org.jivesoftware.smackx.blocking.element.BlockContactsIQ;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.Jid;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.jivesoftware.smack.util.PacketParserUtils;
|
|||
|
||||
import org.jivesoftware.smackx.blocking.element.BlockedErrorExtension;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class BlockedErrorExtensionTest {
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.jivesoftware.smack.util.PacketParserUtils;
|
|||
|
||||
import org.jivesoftware.smackx.blocking.element.BlockListIQ;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
|
||||
public class GetBlockingListTest {
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.jivesoftware.smack.util.PacketParserUtils;
|
|||
|
||||
import org.jivesoftware.smackx.blocking.element.UnblockContactsIQ;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.Jid;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.jivesoftware.smack.util.PacketParserUtils;
|
|||
|
||||
import org.jivesoftware.smackx.bob.element.BoBIQ;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
|
||||
public class BoBIQTest extends SmackTestSuite {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.bytestreams.ibb;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
|
@ -27,7 +27,7 @@ import org.jivesoftware.smack.packet.StanzaError;
|
|||
import org.jivesoftware.smackx.InitExtensions;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.Close;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.Jid;
|
||||
import org.jxmpp.jid.JidTestUtil;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.bytestreams.ibb;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
|
@ -28,7 +28,7 @@ import org.jivesoftware.smackx.InitExtensions;
|
|||
import org.jivesoftware.smackx.bytestreams.ibb.packet.Data;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.DataPacketExtension;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.Jid;
|
||||
import org.jxmpp.jid.JidTestUtil;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
|
|
@ -16,10 +16,11 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.bytestreams.ibb;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
|
@ -36,8 +37,8 @@ import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
|
|||
import org.jivesoftware.util.ConnectionUtils;
|
||||
import org.jivesoftware.util.Protocol;
|
||||
import org.jivesoftware.util.Verification;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.EntityFullJid;
|
||||
import org.jxmpp.jid.JidTestUtil;
|
||||
|
||||
|
@ -65,7 +66,7 @@ public class InBandBytestreamManagerTest extends InitExtensions {
|
|||
* @throws SmackException if Smack detected an exceptional situation.
|
||||
* @throws InterruptedException if the calling thread was interrupted.
|
||||
*/
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() throws XMPPException, SmackException, InterruptedException {
|
||||
|
||||
// build protocol verifier
|
||||
|
@ -130,10 +131,12 @@ public class InBandBytestreamManagerTest extends InitExtensions {
|
|||
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void shouldNotAllowTooBigDefaultBlockSize() {
|
||||
InBandBytestreamManager byteStreamManager = InBandBytestreamManager.getByteStreamManager(connection);
|
||||
byteStreamManager.setDefaultBlockSize(1000000);
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
byteStreamManager.setDefaultBlockSize(1000000);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -143,10 +146,12 @@ public class InBandBytestreamManagerTest extends InitExtensions {
|
|||
assertEquals(1024, byteStreamManager.getDefaultBlockSize());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void shouldNotAllowTooBigMaximumBlockSize() {
|
||||
InBandBytestreamManager byteStreamManager = InBandBytestreamManager.getByteStreamManager(connection);
|
||||
byteStreamManager.setMaximumBlockSize(1000000);
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
byteStreamManager.setMaximumBlockSize(1000000);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.bytestreams.ibb;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
|
@ -29,8 +29,8 @@ import org.jivesoftware.smack.packet.StanzaError;
|
|||
import org.jivesoftware.smackx.InitExtensions;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.Jid;
|
||||
import org.jxmpp.jid.JidTestUtil;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
@ -53,7 +53,7 @@ public class InBandBytestreamRequestTest extends InitExtensions {
|
|||
/**
|
||||
* Initialize fields used in the tests.
|
||||
*/
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
|
||||
// mock connection
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.bytestreams.ibb;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -42,8 +42,8 @@ import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
|
|||
import org.jivesoftware.util.ConnectionUtils;
|
||||
import org.jivesoftware.util.Protocol;
|
||||
import org.jivesoftware.util.Verification;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.EntityFullJid;
|
||||
import org.jxmpp.jid.JidTestUtil;
|
||||
import org.powermock.reflect.Whitebox;
|
||||
|
@ -80,7 +80,7 @@ public class InBandBytestreamSessionMessageTest extends InitExtensions {
|
|||
* @throws SmackException if Smack detected an exceptional situation.
|
||||
* @throws InterruptedException if the calling thread was interrupted.
|
||||
*/
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() throws XMPPException, SmackException, InterruptedException {
|
||||
|
||||
// build protocol verifier
|
||||
|
@ -101,7 +101,7 @@ public class InBandBytestreamSessionMessageTest extends InitExtensions {
|
|||
@Override
|
||||
public void verify(Message request, IQ response) {
|
||||
DataPacketExtension dpe = request.getExtension(
|
||||
DataPacketExtension.ELEMENT, DataPacketExtension.NAMESPACE);
|
||||
DataPacketExtension.class);
|
||||
assertEquals(lastSeq++, dpe.getSeq());
|
||||
}
|
||||
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.bytestreams.ibb;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -41,8 +41,8 @@ import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
|
|||
import org.jivesoftware.util.ConnectionUtils;
|
||||
import org.jivesoftware.util.Protocol;
|
||||
import org.jivesoftware.util.Verification;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.EntityFullJid;
|
||||
import org.jxmpp.jid.JidTestUtil;
|
||||
import org.powermock.reflect.Whitebox;
|
||||
|
@ -80,7 +80,7 @@ public class InBandBytestreamSessionTest extends InitExtensions {
|
|||
* @throws SmackException if Smack detected an exceptional situation.
|
||||
* @throws InterruptedException if the calling thread was interrupted.
|
||||
*/
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() throws XMPPException, SmackException, InterruptedException {
|
||||
|
||||
// build protocol verifier
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.bytestreams.ibb;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
@ -29,8 +29,8 @@ import org.jivesoftware.smackx.InitExtensions;
|
|||
import org.jivesoftware.smackx.bytestreams.BytestreamRequest;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.EntityFullJid;
|
||||
import org.jxmpp.jid.JidTestUtil;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
|
@ -56,7 +56,7 @@ public class InitiationListenerTest extends InitExtensions {
|
|||
/**
|
||||
* Initialize fields used in the tests.
|
||||
*/
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
|
||||
// mock connection
|
||||
|
|
|
@ -17,7 +17,8 @@
|
|||
package org.jivesoftware.smackx.bytestreams.ibb.packet;
|
||||
|
||||
import static org.jivesoftware.smack.test.util.XmlUnitUtils.assertXmlSimilar;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
|
@ -27,7 +28,7 @@ import org.jivesoftware.smack.packet.StreamOpen;
|
|||
import org.jivesoftware.smackx.InitExtensions;
|
||||
|
||||
import com.jamesmurty.utils.XMLBuilder;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
|
||||
/**
|
||||
|
@ -37,14 +38,18 @@ import org.jxmpp.jid.impl.JidCreate;
|
|||
*/
|
||||
public class CloseTest extends InitExtensions {
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void shouldNotInstantiateWithInvalidArguments1() {
|
||||
new Close(null);
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
new Close(null);
|
||||
});
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void shouldNotInstantiateWithInvalidArguments2() {
|
||||
new Close("");
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
new Close("");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -17,8 +17,9 @@
|
|||
package org.jivesoftware.smackx.bytestreams.ibb.packet;
|
||||
|
||||
import static org.jivesoftware.smack.test.util.XmlUnitUtils.assertXmlSimilar;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Properties;
|
||||
|
@ -26,7 +27,7 @@ import java.util.Properties;
|
|||
import org.jivesoftware.smackx.InitExtensions;
|
||||
|
||||
import com.jamesmurty.utils.XMLBuilder;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Test for the DataPacketExtension class.
|
||||
|
@ -35,29 +36,39 @@ import org.junit.Test;
|
|||
*/
|
||||
public class DataPacketExtensionTest extends InitExtensions {
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void shouldNotInstantiateWithInvalidArgument1() {
|
||||
new DataPacketExtension(null, 0, "data");
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
new DataPacketExtension(null, 0, "data");
|
||||
});
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void shouldNotInstantiateWithInvalidArgument2() {
|
||||
new DataPacketExtension("", 0, "data");
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
new DataPacketExtension("", 0, "data");
|
||||
});
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void shouldNotInstantiateWithInvalidArgument3() {
|
||||
new DataPacketExtension("sessionID", -1, "data");
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
new DataPacketExtension("sessionID", -1, "data");
|
||||
});
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void shouldNotInstantiateWithInvalidArgument4() {
|
||||
new DataPacketExtension("sessionID", 70000, "data");
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
new DataPacketExtension("sessionID", 70000, "data");
|
||||
});
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void shouldNotInstantiateWithInvalidArgument5() {
|
||||
new DataPacketExtension("sessionID", 0, null);
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
new DataPacketExtension("sessionID", 0, null);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -17,7 +17,8 @@
|
|||
package org.jivesoftware.smackx.bytestreams.ibb.packet;
|
||||
|
||||
import static org.jivesoftware.smack.test.util.XmlUnitUtils.assertXmlSimilar;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import java.util.Properties;
|
||||
|
@ -29,7 +30,7 @@ import org.jivesoftware.smack.util.stringencoder.Base64;
|
|||
import org.jivesoftware.smackx.InitExtensions;
|
||||
|
||||
import com.jamesmurty.utils.XMLBuilder;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
|
||||
/**
|
||||
|
@ -39,9 +40,11 @@ import org.jxmpp.jid.impl.JidCreate;
|
|||
*/
|
||||
public class DataTest extends InitExtensions {
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void shouldNotInstantiateWithInvalidArgument() {
|
||||
new Data(null);
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
new Data(null);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -17,7 +17,8 @@
|
|||
package org.jivesoftware.smackx.bytestreams.ibb.packet;
|
||||
|
||||
import static org.jivesoftware.smack.test.util.XmlUnitUtils.assertXmlSimilar;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
|
@ -28,7 +29,8 @@ import org.jivesoftware.smackx.InitExtensions;
|
|||
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager.StanzaType;
|
||||
|
||||
import com.jamesmurty.utils.XMLBuilder;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
|
||||
/**
|
||||
|
@ -38,19 +40,25 @@ import org.jxmpp.jid.impl.JidCreate;
|
|||
*/
|
||||
public class OpenTest extends InitExtensions {
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void shouldNotInstantiateWithInvalidArguments1() {
|
||||
new Open(null, 1);
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
new Open(null, 1);
|
||||
});
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void shouldNotInstantiateWithInvalidArguments2() {
|
||||
new Open("", 1);
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
new Open("", 1);
|
||||
});
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void shouldNotInstantiateWithInvalidArguments3() {
|
||||
new Open("sessionID", -1);
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
new Open("sessionID", -1);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.bytestreams.ibb.provider;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
|
@ -28,7 +28,7 @@ import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager.StanzaTyp
|
|||
import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
|
||||
|
||||
import com.jamesmurty.utils.XMLBuilder;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Test for the OpenIQProvider class.
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.bytestreams.socks5;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.timeout;
|
||||
|
@ -30,8 +30,8 @@ import org.jivesoftware.smackx.bytestreams.BytestreamRequest;
|
|||
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream;
|
||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.DomainBareJid;
|
||||
import org.jxmpp.jid.EntityFullJid;
|
||||
import org.jxmpp.jid.JidTestUtil;
|
||||
|
@ -62,7 +62,7 @@ public class InitiationListenerTest {
|
|||
/**
|
||||
* Initialize fields used in the tests.
|
||||
*/
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
|
||||
// mock connection
|
||||
|
|
|
@ -16,13 +16,13 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.bytestreams.socks5;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -56,7 +56,7 @@ import org.jivesoftware.smackx.disco.packet.DiscoverItems.Item;
|
|||
import org.jivesoftware.util.ConnectionUtils;
|
||||
import org.jivesoftware.util.Protocol;
|
||||
import org.jivesoftware.util.Verification;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.DomainBareJid;
|
||||
import org.jxmpp.jid.EntityFullJid;
|
||||
import org.jxmpp.jid.JidTestUtil;
|
||||
|
@ -611,8 +611,7 @@ public class Socks5ByteStreamManagerTest {
|
|||
// initiator can't connect to proxy because it is not running
|
||||
protocol.verifyAll();
|
||||
Throwable actualCause = e.getCause();
|
||||
assertEquals("Unexpected throwable: " + actualCause + '.' + ExceptionUtil.getStackTrace(actualCause),
|
||||
TimeoutException.class, actualCause.getClass());
|
||||
assertEquals(TimeoutException.class, actualCause.getClass(), "Unexpected throwable: " + actualCause + '.' + ExceptionUtil.getStackTrace(actualCause));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.bytestreams.socks5;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
@ -37,7 +37,7 @@ import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream;
|
|||
|
||||
import org.jivesoftware.util.ConnectionUtils;
|
||||
import org.jivesoftware.util.Protocol;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.DomainBareJid;
|
||||
import org.jxmpp.jid.EntityFullJid;
|
||||
import org.jxmpp.jid.JidTestUtil;
|
||||
|
|
|
@ -16,10 +16,10 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.bytestreams.socks5;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
@ -41,7 +41,7 @@ import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream.StreamHost;
|
|||
import org.jivesoftware.util.ConnectionUtils;
|
||||
import org.jivesoftware.util.Protocol;
|
||||
import org.jivesoftware.util.Verification;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.DomainBareJid;
|
||||
import org.jxmpp.jid.EntityFullJid;
|
||||
import org.jxmpp.jid.JidTestUtil;
|
||||
|
|
|
@ -16,10 +16,10 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.bytestreams.socks5;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
|
@ -32,9 +32,9 @@ import org.jivesoftware.smack.util.NetworkUtil;
|
|||
|
||||
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream.StreamHost;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.DomainBareJid;
|
||||
import org.jxmpp.jid.JidTestUtil;
|
||||
|
||||
|
@ -57,7 +57,7 @@ public class Socks5ClientTest {
|
|||
*
|
||||
* @throws Exception should not happen
|
||||
*/
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() throws Exception {
|
||||
// create SOCKS5 proxy server socket
|
||||
serverSocket = NetworkUtil.getSocketOnLoopback();
|
||||
|
@ -333,7 +333,7 @@ public class Socks5ClientTest {
|
|||
*
|
||||
* @throws Exception should not happen
|
||||
*/
|
||||
@After
|
||||
@AfterEach
|
||||
public void cleanup() throws Exception {
|
||||
// Avoid NPE if serverSocket could not get created for whateve reason.
|
||||
if (serverSocket != null) {
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.bytestreams.socks5;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
@ -35,7 +35,7 @@ import java.util.Iterator;
|
|||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Test for Socks5Proxy class.
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.caps;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -38,7 +38,7 @@ import org.jivesoftware.smackx.disco.packet.DiscoverInfoBuilder;
|
|||
import org.jivesoftware.smackx.xdata.FormField;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
import org.jxmpp.stringprep.XmppStringprepException;
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.caps.provider;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import org.jivesoftware.smack.test.util.SmackTestUtil;
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.commands.provider;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
|
@ -26,7 +26,7 @@ import org.jivesoftware.smack.util.PacketParserUtils;
|
|||
import org.jivesoftware.smackx.commands.AdHocCommand;
|
||||
import org.jivesoftware.smackx.commands.packet.AdHocCommandData;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class CommandsProviderTest {
|
||||
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.delay.provider;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
@ -40,7 +40,7 @@ import org.jivesoftware.smackx.delay.DelayInformationManager;
|
|||
import org.jivesoftware.smackx.delay.packet.DelayInformation;
|
||||
|
||||
import com.jamesmurty.utils.XMLBuilder;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.util.XmppDateTime;
|
||||
|
||||
public class DelayInformationTest extends InitExtensions {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.filetransfer;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.jivesoftware.smack.DummyConnection;
|
||||
import org.jivesoftware.smack.SmackException.NoResponseException;
|
||||
|
@ -25,15 +25,15 @@ import org.jivesoftware.smack.packet.Stanza;
|
|||
import org.jivesoftware.smackx.InitExtensions;
|
||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.JidTestUtil;
|
||||
|
||||
public class FileTransferNegotiatorTest extends InitExtensions {
|
||||
private DummyConnection connection;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
connection = new DummyConnection();
|
||||
connection.connect();
|
||||
|
@ -41,7 +41,7 @@ public class FileTransferNegotiatorTest extends InitExtensions {
|
|||
ServiceDiscoveryManager.getInstanceFor(connection);
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void tearDown() throws Exception {
|
||||
if (connection != null)
|
||||
connection.disconnect();
|
||||
|
|
|
@ -18,8 +18,9 @@ package org.jivesoftware.smackx.forward;
|
|||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.jivesoftware.smack.test.util.CharSequenceEquals.equalsCharSequence;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
|
@ -31,7 +32,7 @@ import org.jivesoftware.smackx.forward.packet.Forwarded;
|
|||
import org.jivesoftware.smackx.forward.provider.ForwardedProvider;
|
||||
|
||||
import com.jamesmurty.utils.XMLBuilder;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class ForwardedTest {
|
||||
|
||||
|
@ -94,7 +95,7 @@ public class ForwardedTest {
|
|||
assertEquals("forwarded", parser.getName());
|
||||
}
|
||||
|
||||
@Test(expected = Exception.class)
|
||||
@Test
|
||||
public void forwardedEmptyTest() throws Exception {
|
||||
XmlPullParser parser;
|
||||
String control;
|
||||
|
@ -104,6 +105,8 @@ public class ForwardedTest {
|
|||
.asString(outputProperties);
|
||||
|
||||
parser = PacketParserUtils.getParserFor(control);
|
||||
new ForwardedProvider().parse(parser);
|
||||
assertThrows(Exception.class, () -> {
|
||||
new ForwardedProvider().parse(parser);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.geoloc.packet;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Calendar;
|
||||
|
@ -29,7 +29,7 @@ import org.jivesoftware.smack.util.PacketParserUtils;
|
|||
import org.jivesoftware.smackx.InitExtensions;
|
||||
import org.jivesoftware.smackx.time.packet.Time;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.util.XmppDateTime;
|
||||
|
||||
/**
|
||||
|
@ -117,8 +117,7 @@ public class GeoLocationTest extends InitExtensions {
|
|||
Message messageWithGeoLocation = PacketParserUtils.parseStanza(geoLocationMessageString);
|
||||
assertNotNull(messageWithGeoLocation);
|
||||
|
||||
GeoLocation geoLocation = messageWithGeoLocation.getExtension(GeoLocation.ELEMENT,
|
||||
GeoLocation.NAMESPACE);
|
||||
GeoLocation geoLocation = messageWithGeoLocation.getExtension(GeoLocation.class);
|
||||
assertNotNull(geoLocation);
|
||||
assertNotNull(geoLocation.toXML());
|
||||
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.geoloc.provider;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
|
@ -28,7 +28,7 @@ import org.jivesoftware.smack.util.PacketParserUtils;
|
|||
import org.jivesoftware.smackx.InitExtensions;
|
||||
import org.jivesoftware.smackx.geoloc.packet.GeoLocation;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.util.XmppDateTime;
|
||||
|
||||
public class GeoLocationProviderTest extends InitExtensions {
|
||||
|
@ -69,8 +69,7 @@ public class GeoLocationProviderTest extends InitExtensions {
|
|||
Message messageWithGeoLocation = PacketParserUtils.parseStanza(geoLocationString);
|
||||
assertNotNull(messageWithGeoLocation);
|
||||
|
||||
GeoLocation geoLocation = messageWithGeoLocation.getExtension(GeoLocation.ELEMENT,
|
||||
GeoLocation.NAMESPACE);
|
||||
GeoLocation geoLocation = messageWithGeoLocation.getExtension(GeoLocation.class);
|
||||
assertNotNull(geoLocation);
|
||||
|
||||
assertEquals((Double) 23d, geoLocation.getAccuracy());
|
||||
|
@ -138,8 +137,7 @@ public class GeoLocationProviderTest extends InitExtensions {
|
|||
Message messageWithGeoLocation = PacketParserUtils.parseStanza(geoLocationString);
|
||||
assertNotNull(messageWithGeoLocation);
|
||||
|
||||
GeoLocation geoLocation = messageWithGeoLocation.getExtension(GeoLocation.ELEMENT,
|
||||
GeoLocation.NAMESPACE);
|
||||
GeoLocation geoLocation = messageWithGeoLocation.getExtension(GeoLocation.class);
|
||||
assertNotNull(geoLocation);
|
||||
|
||||
assertEquals((Double) 23d, geoLocation.getAccuracy());
|
||||
|
@ -183,8 +181,7 @@ public class GeoLocationProviderTest extends InitExtensions {
|
|||
|
||||
Message messageWithGeoLocation = PacketParserUtils.parseStanza(geoLocationString);
|
||||
|
||||
GeoLocation geoLocation = messageWithGeoLocation.getExtension(GeoLocation.ELEMENT,
|
||||
GeoLocation.NAMESPACE);
|
||||
GeoLocation geoLocation = messageWithGeoLocation.getExtension(GeoLocation.class);
|
||||
|
||||
assertEquals((Double) 90d, geoLocation.getError());
|
||||
}
|
||||
|
@ -203,8 +200,7 @@ public class GeoLocationProviderTest extends InitExtensions {
|
|||
|
||||
Message messageWithGeoLocation = PacketParserUtils.parseStanza(geoLocationString);
|
||||
|
||||
GeoLocation geoLocation = messageWithGeoLocation.getExtension(GeoLocation.ELEMENT,
|
||||
GeoLocation.NAMESPACE);
|
||||
GeoLocation geoLocation = messageWithGeoLocation.getExtension(GeoLocation.class);
|
||||
|
||||
assertEquals((Double) 90d, geoLocation.getAccuracy());
|
||||
}
|
||||
|
@ -224,8 +220,7 @@ public class GeoLocationProviderTest extends InitExtensions {
|
|||
|
||||
Message messageWithGeoLocation = PacketParserUtils.parseStanza(geoLocationString);
|
||||
|
||||
GeoLocation geoLocation = messageWithGeoLocation.getExtension(GeoLocation.ELEMENT,
|
||||
GeoLocation.NAMESPACE);
|
||||
GeoLocation geoLocation = messageWithGeoLocation.getExtension(GeoLocation.class);
|
||||
|
||||
assertEquals((Double) 90d, geoLocation.getAccuracy());
|
||||
assertNull(geoLocation.getError());
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue