1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-12 02:29:38 +02:00

Compare commits

..

No commits in common. "32ae0d88268184efe105300cdef0aab0abf285fd" and "adfca965b5c9e8e75f7481fb7bd9aa9420650dc1" have entirely different histories.

194 changed files with 616 additions and 1229 deletions

View file

@ -23,8 +23,8 @@ apply plugin: 'org.kordamp.gradle.markdown'
apply from: 'version.gradle'
allprojects {
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'java-test-fixtures'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'jacoco'
@ -123,12 +123,15 @@ allprojects {
androidJavadocOffline = { getAndroidJavadocOffline() }
junit4Projects = [
':smack-core',
':smack-extensions',
':smack-im',
':smack-integration-test',
':smack-omemo',
':smack-omemo-signal',
':smack-openpgp',
].collect { project(it) }
junitVersion = '5.6.0'
powerMockVersion = '2.0.2'
commonsIoVersion = '2.6'
if (project.hasProperty("useSonatype")) {
useSonatype = project.getProperty("useSonatype").toBoolean()
@ -264,16 +267,10 @@ allprojects {
}
dependencies {
testFixturesApi "org.junit.jupiter:junit-jupiter-api:$junitVersion"
testImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion"
testImplementation "org.junit.jupiter:junit-jupiter-params:$junitVersion"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion"
// The smack-extensions subproject uses mockito in its fest
// fixtures, and we want to have mockito also available in
// test, so we use API here.
testFixturesApi "org.mockito:mockito-core:3.3.3"
testImplementation 'com.jamesmurty.utils:java-xmlbuilder:1.2'
errorprone 'com.google.errorprone:error_prone_core:2.3.3'
errorproneJavac('com.google.errorprone:javac:9+181-r4173-1')
}
@ -286,6 +283,9 @@ allprojects {
configure (junit4Projects) {
dependencies {
testImplementation "org.junit.vintage:junit-vintage-engine:$junitVersion"
testImplementation "org.powermock:powermock-module-junit4:$powerMockVersion"
testImplementation "org.powermock:powermock-module-junit4-rule:$powerMockVersion"
testImplementation "org.powermock:powermock-api-mockito2:$powerMockVersion"
}
}

View file

@ -9,5 +9,5 @@ it disabled until gradle uses a checkstyle version where this is fixed
<suppress checks="GenericWhitespace"
files="Protocol.java" />
<!-- Suppress JavadocPackage in the test packages -->
<suppress checks="JavadocPackage" files="[\\/]test(Fixtures)?[\\/]"/>
<suppress checks="JavadocPackage" files="[\\/]test[\\/]"/>
</suppressions>

View file

@ -10,19 +10,10 @@ dependencies {
compile "org.jxmpp:jxmpp-core:$jxmppVersion"
compile "org.jxmpp:jxmpp-jid:$jxmppVersion"
compile "org.minidns:minidns-core:$miniDnsVersion"
testFixturesImplementation project(':smack-xmlparser-stax')
testFixturesImplementation project(':smack-xmlparser-xpp3')
// Bouncy Castle is setup by SmackTestSuite. We deliberately use
// 'implementation' here since there is no need to shadow it
// outside of the fixtures compilation classpath. That is, no test
// should ever setup Bouncy Castle as security provider explicitly.
testFixturesImplementation 'org.bouncycastle:bcprov-jdk15on:1.64'
testFixturesImplementation 'org.apache.commons:commons-lang3:3.10'
testFixturesApi "org.jxmpp:jxmpp-jid:$jxmppVersion:tests"
testFixturesApi "org.xmlunit:xmlunit-core:$xmlUnitVersion"
testCompile project(':smack-xmlparser-stax')
testCompile project(':smack-xmlparser-xpp3')
testCompile "org.jxmpp:jxmpp-jid:$jxmppVersion:tests"
testCompile "org.xmlunit:xmlunit-core:$xmlUnitVersion"
// Explictily add assertj-core which is a dependency of
// xmlunit-assertj, but gradle fails to resolves it with:
// Execution failed for task ':smack-core:compileTestJava'.
@ -30,9 +21,12 @@ dependencies {
// > Could not find org.assertj:assertj-core:.
// Required by:
// project :smack-core > org.xmlunit:xmlunit-assertj:2.6.2
testFixturesApi "org.assertj:assertj-core:3.11.1"
testFixturesApi "org.xmlunit:xmlunit-assertj:$xmlUnitVersion"
testFixturesApi 'org.hamcrest:hamcrest-library:2.2'
testCompile "org.assertj:assertj-core:3.11.1"
testCompile "org.xmlunit:xmlunit-assertj:$xmlUnitVersion"
testCompile 'com.jamesmurty.utils:java-xmlbuilder:1.2'
testCompile 'org.bouncycastle:bcprov-jdk15on:1.64'
testCompile 'com.google.guava:guava:28.2-jre'
testCompile 'org.jgrapht:jgrapht-io:1.3.1'
}
class CreateFileTask extends DefaultTask {

View file

@ -2154,7 +2154,6 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
CACHED_EXECUTOR_SERVICE.execute(runnable);
}
@SuppressWarnings("static-method")
protected final SmackReactor getReactor() {
return SMACK_REACTOR;
}

View file

@ -338,7 +338,7 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
/**
* Returns the first extension of this stanza that has the given namespace.
* <p>
* When possible, use {@link #getExtensionElement(String, String)} instead.
* When possible, use {@link #getExtension(String, String)} instead.
* </p>
*
* @param namespace the namespace of the extension that is desired.
@ -350,18 +350,15 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
/**
* Returns the first extension that matches the specified element name and
* namespace, or <code>null</code> if it doesn't exist. Extensions are
* namespace, or <code>null</code> if it doesn't exist. If the provided elementName is null,
* only the namespace is matched. Extensions are
* are arbitrary XML elements in standard XMPP stanzas.
* <p>
* Note that it is recommended to use {@link #getExtension(Class)} instead of this method.
* The {@link #getExtension(Class)} is more robust, as it is type safe.
* </p>
*
* @param elementName the XML element name of the extension.
* @param elementName the XML element name of the extension. (May be null)
* @param namespace the XML element namespace of the extension.
* @return the extension, or <code>null</code> if it doesn't exist.
*/
public final ExtensionElement getExtensionElement(String elementName, String namespace) {
public final ExtensionElement getExtension(String elementName, String namespace) {
if (namespace == null) {
return null;
}
@ -373,22 +370,6 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
return packetExtension;
}
/**
* This method is deprecated. Use preferably {@link #getExtension(Class)} or {@link #getExtensionElement(String, String)}.
*
* @param <E> the type to cast to.
* @param elementName the XML element name of the extension. (May be null)
* @param namespace the XML element namespace of the extension.
* @return the extension, or <code>null</code> if it doesn't exist.
* @deprecated use {@link #getExtension(Class)} or {@link #getExtensionElement(String, String)} isntead.
*/
// TODO: Remove in Smack 4.5.
@SuppressWarnings("unchecked")
@Deprecated
public final <E extends ExtensionElement> E getExtension(String elementName, String namespace) {
return (E) getExtensionElement(elementName, namespace);
}
@Override
public final ExtensionElement getExtension(QName qname) {
synchronized (extensionElements) {

View file

@ -87,14 +87,10 @@ public interface StanzaView extends XmlLangElement {
return false;
}
@SuppressWarnings("unchecked")
default <E extends ExtensionElement> E getExtension(Class<E> extensionElementClass) {
QName qname = XmppElementUtil.getQNameFor(extensionElementClass);
ExtensionElement extensionElement = getExtension(qname);
if (!extensionElementClass.isInstance(extensionElement)) {
return null;
}
return extensionElementClass.cast(extensionElement);
return (E) getExtension(qname);
}
/**

View file

@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.smack;
import java.io.IOException;

View file

@ -1,6 +1,6 @@
/**
*
* Copyright © 2014-2020 Florian Schmaus
* Copyright © 2014 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -17,6 +17,7 @@
package org.jivesoftware.smack.test.util;
import org.hamcrest.Description;
import org.hamcrest.Factory;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
@ -39,6 +40,7 @@ public class CharSequenceEquals extends TypeSafeMatcher<CharSequence> {
return charSequenceString.equals(itemString);
}
@Factory
public static Matcher<CharSequence> equalsCharSequence(CharSequence charSequence) {
return new CharSequenceEquals(charSequence);
}

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2019-2020 Florian Schmaus
* Copyright 2019 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -14,9 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.smack.test.util;
package org.jivesoftware.smack.util;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.fail;
import java.lang.ref.PhantomReference;
@ -129,7 +129,7 @@ public class MemoryLeakTestUtil {
}
Reference<?> reference = referenceQueue.poll();
assertNull(reference, "Reference queue is not empty when it should be");
assertNull("Reference queue is not empty when it should be", reference);
}
private static void assertReferencesQueueIsEmpty(ReferenceQueue<?> referenceQueue) {

View file

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.smack.test.util;
package org.jivesoftware.smack.util;
import java.io.IOException;
import java.net.BindException;

View file

@ -1,44 +0,0 @@
/**
*
* 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.test.util;
import java.lang.reflect.Field;
import org.apache.commons.lang3.reflect.FieldUtils;
public class Whitebox {
public static <T> T getInternalState(Object object, String fieldName, Class<T> fieldType) {
Class<?> objectClass = object.getClass();
Field field = FieldUtils.getField(objectClass, fieldName, true);
Object res;
try {
res = field.get(object);
} catch (IllegalArgumentException | IllegalAccessException e) {
throw new AssertionError(e);
}
if (!fieldType.isInstance(res)) {
throw new AssertionError(res + " is not a (sub)type of " + fieldType);
}
return fieldType.cast(res);
}
}

View file

@ -6,4 +6,5 @@ Connect your favourite slf4j backend of choice to get output inside of it"""
dependencies {
compile project(':smack-core')
compile 'org.slf4j:slf4j-api:[1.7,1.8)'
testCompile project(path: ":smack-core", configuration: "testRuntime")
}

View file

@ -4,4 +4,5 @@ Inspect the exchanged XMPP stanzas."""
dependencies {
compile project(':smack-core')
testCompile project(path: ":smack-core", configuration: "testRuntime")
}

View file

@ -7,8 +7,8 @@ between patch versions."""
dependencies {
compile project(':smack-core')
compile project(':smack-extensions')
testCompile project(path: ":smack-core", configuration: "testRuntime")
testCompile project(path: ":smack-extensions", configuration: "testRuntime")
compile "org.hsluv:hsluv:0.2"
testFixturesApi(testFixtures(project(":smack-extensions")))
}

View file

@ -114,9 +114,9 @@ public class CarbonExtension implements ExtensionElement {
* @return a Carbon if available, null otherwise.
*/
public static CarbonExtension from(Message msg) {
CarbonExtension cc = (CarbonExtension) msg.getExtensionElement(Direction.received.name(), NAMESPACE);
CarbonExtension cc = (CarbonExtension) msg.getExtension(Direction.received.name(), NAMESPACE);
if (cc == null)
cc = (CarbonExtension) msg.getExtensionElement(Direction.sent.name(), NAMESPACE);
cc = (CarbonExtension) msg.getExtension(Direction.sent.name(), NAMESPACE);
return cc;
}

View file

@ -60,7 +60,7 @@ public final class DnsOverXmppManager extends Manager {
private static DnsOverXmppResolver defaultResolver;
public static void setDefaultDnsOverXmppResolver(DnsOverXmppResolver resolver) {
public void setDefaultDnsOverXmppResolver(DnsOverXmppResolver resolver) {
defaultResolver = resolver;
}

View file

@ -48,7 +48,7 @@ public final class NoCopyHint extends MessageProcessingHint {
}
public static NoCopyHint from(Message message) {
return (NoCopyHint) message.getExtensionElement(ELEMENT, NAMESPACE);
return (NoCopyHint) message.getExtension(ELEMENT, NAMESPACE);
}
public static boolean hasHint(Message message) {

View file

@ -48,7 +48,7 @@ public final class NoPermanentStoreHint extends MessageProcessingHint {
}
public static NoPermanentStoreHint from(Message message) {
return (NoPermanentStoreHint) message.getExtensionElement(ELEMENT, NAMESPACE);
return (NoPermanentStoreHint) message.getExtension(ELEMENT, NAMESPACE);
}
public static boolean hasHint(Message message) {

View file

@ -48,7 +48,7 @@ public final class NoStoreHint extends MessageProcessingHint {
}
public static NoStoreHint from(Message message) {
return (NoStoreHint) message.getExtensionElement(ELEMENT, NAMESPACE);
return (NoStoreHint) message.getExtension(ELEMENT, NAMESPACE);
}
public static boolean hasHint(Message message) {

View file

@ -46,7 +46,6 @@ 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;

View file

@ -28,7 +28,6 @@ import org.jivesoftware.smack.xml.XmlPullParserException;
import org.jivesoftware.smackx.hashes.element.HashElement;
import org.jivesoftware.smackx.hashes.provider.HashElementProvider;
import org.jivesoftware.smackx.jingle.element.JingleContentDescription;
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionChildElement;
import org.jivesoftware.smackx.jingle.provider.JingleContentDescriptionProvider;
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransfer;
@ -102,7 +101,7 @@ public class JingleFileTransferProvider
builder = JingleFileTransferChild.getBuilder();
break;
case JingleContentDescription.ELEMENT:
case JingleFileTransfer.ELEMENT:
return new JingleFileTransfer(payloads);
}
break;

View file

@ -43,7 +43,6 @@ import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.util.Objects;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smackx.commands.AdHocCommandManager;
import org.jivesoftware.smackx.commands.RemoteCommand;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;

View file

@ -140,7 +140,7 @@ public class MamElements {
}
public static MamResultExtension from(Message message) {
return (MamResultExtension) message.getExtensionElement(ELEMENT, NAMESPACE);
return (MamResultExtension) message.getExtension(ELEMENT, NAMESPACE);
}
}

View file

@ -32,7 +32,6 @@ import org.jivesoftware.smackx.message_markup.element.BlockQuoteElement;
import org.jivesoftware.smackx.message_markup.element.CodeBlockElement;
import org.jivesoftware.smackx.message_markup.element.ListElement;
import org.jivesoftware.smackx.message_markup.element.MarkupElement;
import org.jivesoftware.smackx.message_markup.element.MarkupElement.MarkupChildElement;
import org.jivesoftware.smackx.message_markup.element.SpanElement;
public class MarkupElementProvider extends ExtensionElementProvider<MarkupElement> {
@ -56,26 +55,26 @@ public class MarkupElementProvider extends ExtensionElementProvider<MarkupElemen
case START_ELEMENT:
switch (name) {
case BlockQuoteElement.ELEMENT:
start = ParserUtils.getIntegerAttributeOrThrow(parser, MarkupChildElement.ATTR_START,
start = ParserUtils.getIntegerAttributeOrThrow(parser, BlockQuoteElement.ATTR_START,
"Message Markup BlockQuoteElement MUST contain a 'start' attribute.");
end = ParserUtils.getIntegerAttributeOrThrow(parser, MarkupChildElement.ATTR_END,
end = ParserUtils.getIntegerAttributeOrThrow(parser, BlockQuoteElement.ATTR_END,
"Message Markup BlockQuoteElement MUST contain a 'end' attribute.");
markup.setBlockQuote(start, end);
break;
case CodeBlockElement.ELEMENT:
start = ParserUtils.getIntegerAttributeOrThrow(parser, MarkupChildElement.ATTR_START,
start = ParserUtils.getIntegerAttributeOrThrow(parser, CodeBlockElement.ATTR_START,
"Message Markup CodeBlockElement MUST contain a 'start' attribute.");
end = ParserUtils.getIntegerAttributeOrThrow(parser, MarkupChildElement.ATTR_END,
end = ParserUtils.getIntegerAttributeOrThrow(parser, CodeBlockElement.ATTR_END,
"Message Markup CodeBlockElement MUST contain a 'end' attribute.");
markup.setCodeBlock(start, end);
break;
case SpanElement.ELEMENT:
spanStyles = new HashSet<>();
spanStart = ParserUtils.getIntegerAttributeOrThrow(parser, MarkupChildElement.ATTR_START,
spanStart = ParserUtils.getIntegerAttributeOrThrow(parser, SpanElement.ATTR_START,
"Message Markup SpanElement MUST contain a 'start' attribute.");
spanEnd = ParserUtils.getIntegerAttributeOrThrow(parser, MarkupChildElement.ATTR_END,
spanEnd = ParserUtils.getIntegerAttributeOrThrow(parser, SpanElement.ATTR_END,
"Message Markup SpanElement MUST contain a 'end' attribute.");
break;
@ -93,14 +92,14 @@ public class MarkupElementProvider extends ExtensionElementProvider<MarkupElemen
case ListElement.ELEMENT:
lis = new ArrayList<>();
listStart = ParserUtils.getIntegerAttributeOrThrow(parser, MarkupChildElement.ATTR_START,
listStart = ParserUtils.getIntegerAttributeOrThrow(parser, ListElement.ATTR_START,
"Message Markup ListElement MUST contain a 'start' attribute.");
listEnd = ParserUtils.getIntegerAttributeOrThrow(parser, MarkupChildElement.ATTR_END,
listEnd = ParserUtils.getIntegerAttributeOrThrow(parser, ListElement.ATTR_END,
"Message Markup ListElement MUST contain a 'end' attribute.");
break;
case ListElement.ELEM_LI:
start = ParserUtils.getIntegerAttributeOrThrow(parser, MarkupChildElement.ATTR_START,
start = ParserUtils.getIntegerAttributeOrThrow(parser, ListElement.ATTR_START,
"Message Markup ListElement 'li' MUST contain a 'start' attribute.");
lis.add(new ListElement.ListEntryElement(start));
break;

View file

@ -147,6 +147,7 @@ public class MultiUserChatLight {
* for the newly created chat.
* @return new Chat for sending private messages to a given room occupant.
*/
@SuppressWarnings("deprecation")
@Deprecated
// Do not re-use Chat API, which was designed for XMPP-IM 1:1 chats and not MUClight private chats.
public org.jivesoftware.smack.chat.Chat createPrivateChat(EntityJid occupant, ChatMessageListener listener) {

View file

@ -233,7 +233,7 @@ public abstract class MUCLightElements {
}
public static ConfigurationsChangeExtension from(Message message) {
return (ConfigurationsChangeExtension) message.getExtensionElement(ConfigurationsChangeExtension.ELEMENT, ConfigurationsChangeExtension.NAMESPACE);
return (ConfigurationsChangeExtension) message.getExtension(ConfigurationsChangeExtension.ELEMENT, ConfigurationsChangeExtension.NAMESPACE);
}
}

View file

@ -82,7 +82,7 @@ public class OriginIdElement extends StableAndUniqueIdElement {
* @return origin-id element
*/
public static OriginIdElement getOriginId(Message message) {
return (OriginIdElement) message.getExtensionElement(OriginIdElement.ELEMENT, StableUniqueStanzaIdManager.NAMESPACE);
return (OriginIdElement) message.getExtension(OriginIdElement.ELEMENT, StableUniqueStanzaIdManager.NAMESPACE);
}
@Override

View file

@ -21,7 +21,6 @@ import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smackx.sid.element.OriginIdElement;
import org.jivesoftware.smackx.sid.element.StableAndUniqueIdElement;
public class OriginIdProvider extends ExtensionElementProvider<OriginIdElement> {
@ -33,6 +32,6 @@ public class OriginIdProvider extends ExtensionElementProvider<OriginIdElement>
@Override
public OriginIdElement parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) {
return new OriginIdElement(parser.getAttributeValue(null, StableAndUniqueIdElement.ATTR_ID));
return new OriginIdElement(parser.getAttributeValue(null, OriginIdElement.ATTR_ID));
}
}

View file

@ -20,7 +20,6 @@ import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smackx.sid.element.StableAndUniqueIdElement;
import org.jivesoftware.smackx.sid.element.StanzaIdElement;
public class StanzaIdProvider extends ExtensionElementProvider<StanzaIdElement> {
@ -29,7 +28,7 @@ public class StanzaIdProvider extends ExtensionElementProvider<StanzaIdElement>
@Override
public StanzaIdElement parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) {
String id = parser.getAttributeValue(null, StableAndUniqueIdElement.ATTR_ID);
String id = parser.getAttributeValue(null, StanzaIdElement.ATTR_ID);
String by = parser.getAttributeValue(null, StanzaIdElement.ATTR_BY);
return new StanzaIdElement(id, by);
}

View file

@ -18,9 +18,12 @@ package org.jivesoftware.smackx.hashes;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.security.Security;
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smack.util.StringUtils;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.junit.jupiter.api.Test;
/**
@ -30,6 +33,10 @@ import org.junit.jupiter.api.Test;
*/
public class HashTest extends SmackTestSuite {
static {
Security.addProvider(new BouncyCastleProvider());
}
private static final String testString = "Hello World!";
private static final String md5sum = "ed076287532e86365e841e92bfc50d8c";
private static final String sha1sum = "2ef7bde608ce5404e97d5f042f95f89f1c232871";

View file

@ -21,13 +21,13 @@ import java.lang.reflect.Method;
import org.jivesoftware.smack.DummyConnection;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smackx.InitExtensions;
import org.jivesoftware.smackx.xdata.packet.DataForm;
import org.junit.jupiter.api.BeforeAll;
public class MamTest extends SmackTestSuite {
public class MamTest extends InitExtensions {
protected static XMPPConnection connection;
protected static String queryId;

View file

@ -44,7 +44,7 @@ public class SpoilerTest extends SmackTestSuite {
Message message = StanzaBuilder.buildMessage().build();
SpoilerElement.addSpoiler(message);
SpoilerElement empty = (SpoilerElement) message.getExtensionElement(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 = (SpoilerElement) message.getExtensionElement(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 = (SpoilerElement) message.getExtensionElement(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());

View file

@ -10,6 +10,5 @@ dependencies {
// Some implementations need APIs provided by smack-im,
// e.g. message delivery receipts the roster
compile project(':smack-im')
testFixturesApi(testFixtures(project(":smack-core")))
//testCompile project(path: ":smack-core", configuration: "testRuntime")
testCompile project(path: ":smack-core", configuration: "testRuntime")
}

View file

@ -91,7 +91,7 @@ public class BoBExtension extends XHTMLExtension {
}
public static BoBExtension from(Message message) {
return (BoBExtension) message.getExtensionElement(ELEMENT, NAMESPACE);
return (BoBExtension) message.getExtension(ELEMENT, NAMESPACE);
}
}

View file

@ -1,26 +0,0 @@
/**
*
* Copyright 2020 Aditya Borikar.
*
* 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.smackx.geoloc;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smackx.geoloc.packet.GeoLocation;
import org.jxmpp.jid.BareJid;
public interface GeoLocationListener {
void onGeoLocationUpdated(BareJid jid, GeoLocation geoLocation, Message message);
}

View file

@ -16,13 +16,9 @@
*/
package org.jivesoftware.smackx.geoloc;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.WeakHashMap;
import java.util.concurrent.CopyOnWriteArraySet;
import org.jivesoftware.smack.AsyncButOrdered;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.SmackException.NoResponseException;
@ -30,53 +26,22 @@ import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPConnectionRegistry;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
import org.jivesoftware.smackx.geoloc.packet.GeoLocation;
import org.jivesoftware.smackx.geoloc.provider.GeoLocationProvider;
import org.jivesoftware.smackx.pep.PepListener;
import org.jivesoftware.smackx.pep.PepManager;
import org.jivesoftware.smackx.pubsub.EventElement;
import org.jivesoftware.smackx.pubsub.ItemsExtension;
import org.jivesoftware.smackx.pubsub.LeafNode;
import org.jivesoftware.smackx.pubsub.PayloadItem;
import org.jivesoftware.smackx.pubsub.PubSubException.NotALeafNodeException;
import org.jivesoftware.smackx.pubsub.PubSubManager;
import org.jivesoftware.smackx.xdata.provider.FormFieldChildElementProviderManager;
import org.jxmpp.jid.BareJid;
import org.jxmpp.jid.EntityBareJid;
import org.jxmpp.jid.Jid;
/**
* Entry point for Smacks API for XEP-0080: User Location.
* <br>
* To publish a UserLocation, please use {@link #sendGeolocation(GeoLocation)} method. This will publish the node.
* <br>
* To stop publishing a UserLocation, please use {@link #stopPublishingGeolocation()} method. This will send a disble publishing signal.
* <br>
* To add a {@link GeoLocationListener} in order to remain updated with other users GeoLocation, use {@link #addGeoLocationListener(GeoLocationListener)} method.
* <br>
* To link a GeoLocation with {@link Message}, use `message.addExtension(geoLocation)`.
* <br>
* An example for illustration is provided inside GeoLocationTest inside the test package.
* <br>
* @see <a href="https://xmpp.org/extensions/xep-0080.html">
* XEP-0080: User Location</a>
*/
public final class GeoLocationManager extends Manager {
public static final String GEOLOCATION_NODE = "http://jabber.org/protocol/geoloc";
public static final String GEOLOCATION_NOTIFY = GEOLOCATION_NODE + "+notify";
private static final Map<XMPPConnection, GeoLocationManager> INSTANCES = new WeakHashMap<>();
private static boolean ENABLE_USER_LOCATION_NOTIFICATIONS_BY_DEFAULT = true;
private final Set<GeoLocationListener> geoLocationListeners = new CopyOnWriteArraySet<>();
private final AsyncButOrdered<BareJid> asyncButOrdered = new AsyncButOrdered<BareJid>();
private final ServiceDiscoveryManager serviceDiscoveryManager;
private final PepManager pepManager;
static {
FormFieldChildElementProviderManager.addFormFieldChildElementProvider(
GeoLocationProvider.GeoLocationFormFieldChildElementProvider.INSTANCE);
@ -89,6 +54,11 @@ public final class GeoLocationManager extends Manager {
});
}
public GeoLocationManager(XMPPConnection connection) {
super(connection);
}
/**
* Retrieves a {@link GeoLocationManager} for the specified {@link XMPPConnection}, creating one if it doesn't
* already exist.
@ -105,36 +75,6 @@ public final class GeoLocationManager extends Manager {
return geoLocationManager;
}
private GeoLocationManager(XMPPConnection connection) {
super(connection);
pepManager = PepManager.getInstanceFor(connection);
pepManager.addPepListener(new PepListener() {
@Override
public void eventReceived(EntityBareJid from, EventElement event, Message message) {
if (!GEOLOCATION_NODE.equals(event.getEvent().getNode())) {
return;
}
final BareJid contact = from.asBareJid();
asyncButOrdered.performAsyncButOrdered(contact, () -> {
ItemsExtension itemsExtension = (ItemsExtension) event.getEvent();
List<ExtensionElement> items = itemsExtension.getExtensions();
@SuppressWarnings("unchecked")
PayloadItem<GeoLocation> payload = (PayloadItem<GeoLocation>) items.get(0);
GeoLocation geoLocation = payload.getPayload();
for (GeoLocationListener listener : geoLocationListeners) {
listener.onGeoLocationUpdated(contact, geoLocation, message);
}
});
}
});
serviceDiscoveryManager = ServiceDiscoveryManager.getInstanceFor(connection);
if (ENABLE_USER_LOCATION_NOTIFICATIONS_BY_DEFAULT) {
enableUserLocationNotifications();
}
}
public void sendGeoLocationToJid(GeoLocation geoLocation, Jid jid) throws InterruptedException,
NotConnectedException {
@ -171,7 +111,7 @@ public final class GeoLocationManager extends Manager {
*/
public void sendGeolocation(GeoLocation geoLocation)
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, NotALeafNodeException {
pepManager.publish(GeoLocation.NAMESPACE, new PayloadItem<GeoLocation>(geoLocation));
getNode().publish(new PayloadItem<GeoLocation>(geoLocation));
}
/**
@ -185,25 +125,13 @@ public final class GeoLocationManager extends Manager {
*/
public void stopPublishingGeolocation()
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, NotALeafNodeException {
pepManager.publish(GeoLocation.NAMESPACE, new PayloadItem<GeoLocation>(GeoLocation.EMPTY_GEO_LOCATION));
GeoLocation emptyGeolocation = new GeoLocation.Builder().build();
getNode().publish(new PayloadItem<GeoLocation>(emptyGeolocation));
}
public static void setGeoLocationNotificationsEnabledByDefault(boolean bool) {
ENABLE_USER_LOCATION_NOTIFICATIONS_BY_DEFAULT = bool;
private LeafNode getNode()
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, NotALeafNodeException {
return PubSubManager.getInstanceFor(connection()).getOrCreateLeafNode(GeoLocation.NAMESPACE);
}
public void enableUserLocationNotifications() {
serviceDiscoveryManager.addFeature(GEOLOCATION_NOTIFY);
}
public void disableGeoLocationNotifications() {
serviceDiscoveryManager.removeFeature(GEOLOCATION_NOTIFY);
}
public boolean addGeoLocationListener(GeoLocationListener geoLocationListener) {
return geoLocationListeners.add(geoLocationListener);
}
public boolean removeGeoLocationListener(GeoLocationListener geoLocationListener) {
return geoLocationListeners.remove(geoLocationListener);
}
}

View file

@ -48,8 +48,6 @@ public final class GeoLocation implements Serializable, ExtensionElement, FormFi
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
public static final GeoLocation EMPTY_GEO_LOCATION = GeoLocation.builder().build();
private static final Logger LOGGER = Logger.getLogger(GeoLocation.class.getName());
private final Double accuracy;
@ -266,10 +264,6 @@ public final class GeoLocation implements Serializable, ExtensionElement, FormFi
return NAMESPACE;
}
/**
* Returns a new instance of {@link Builder}.
* @return Builder
*/
public static Builder builder() {
return new GeoLocation.Builder();
}
@ -279,35 +273,14 @@ public final class GeoLocation implements Serializable, ExtensionElement, FormFi
return true;
}
/**
* Returns the first GeoLocation, or <code>null</code> if it doesn't exist in {@link Message}.
* <br>
* @param message The Message stanza containing GeoLocation
* @return GeoLocation
*/
public static GeoLocation from(Message message) {
return message.getExtension(GeoLocation.class);
}
/**
* Returns the first GeoLocation, or <code>null</code> if it doesn't exist in {@link FormField}.
* <br>
* @param formField the Formfield containing GeoLocation
* @return GeoLocation
*/
public static GeoLocation from(FormField formField) {
return (GeoLocation) formField.getFormFieldChildElement(QNAME);
}
/**
* This class defines a builder class for {@link GeoLocation}.
* <br>
* {@link GeoLocation} instance can be obtained using {@link #build()} method as follows.<br><br>
* <code>GeoLocation.Builder builder = GeoLocation.builder(); <br>
* GeoLocation geoLocation = builder.build();</code>
* <br><br>
* To set GeoLocation parameters, use their respective setters.
*/
public static class Builder {
private Double accuracy;
@ -335,285 +308,133 @@ public final class GeoLocation implements Serializable, ExtensionElement, FormFi
private String tzo;
private URI uri;
/**
* Sets accuracy of horizontal GPS error in meters.
*
* @param accuracy accuracy in meters
* @return Builder
*/
public Builder setAccuracy(Double accuracy) {
this.accuracy = accuracy;
return this;
}
/**
* Sets Altitude in meters above or below sea level.
*
* @param alt altitude in meters
* @return Builder
*/
public Builder setAlt(Double alt) {
this.alt = alt;
return this;
}
/**
* Sets Vertical GPS error in meters.
*
* @param altAccuracy altAccuracy in meters
* @return Builder
*/
public Builder setAltAccuracy(Double altAccuracy) {
this.altAccuracy = altAccuracy;
return this;
}
/**
* Sets a named area such as a campus or neighborhood.
*
* @param area the named area
* @return Builder
*/
public Builder setArea(String area) {
this.area = area;
return this;
}
/**
* Sets GPS bearing (direction in which the entity is heading<br>
* to reach its next waypoint), measured in decimal degrees,<br>
* relative to true north.
*
* @param bearing bearing in decimal degrees
* @return Builder
*/
public Builder setBearing(Double bearing) {
this.bearing = bearing;
return this;
}
/**
* Sets a specific building on a street or in an area.
*
* @param building name of the building
* @return Builder
*/
public Builder setBuilding(String building) {
this.building = building;
return this;
}
/**
* Sets the nation where the user is located.
*
* @param country user's country of location
* @return Builder
*/
public Builder setCountry(String country) {
this.country = country;
return this;
}
/**
* Sets The ISO 3166 two-letter country code.
*
* @param countryCode two-letter country code
* @return Builder
*/
public Builder setCountryCode(String countryCode) {
this.countryCode = countryCode;
return this;
}
/**
* Sets GPS Datum.
*
* @param datum GPS datum
* @return Builder
*/
public Builder setDatum(String datum) {
this.datum = datum;
return this;
}
/**
* Sets A natural-language name for or description of the location.
*
* @param description description of the location
* @return Builder
*/
public Builder setDescription(String description) {
this.description = description;
return this;
}
/**
* Sets Horizontal GPS error in arc minutes;<br>
* this element is deprecated in favor of accuracy.
*
* @param error error in arc minutes
* @return Builder
*/
public Builder setError(Double error) {
this.error = error;
return this;
}
/**
* Sets a particular floor in a building.
*
* @param floor floor in a building
* @return Builder
*/
public Builder setFloor(String floor) {
this.floor = floor;
return this;
}
/**
* Sets Latitude in decimal degrees North.
*
* @param lat latitude in decimal degrees
* @return Builder
*/
public Builder setLat(Double lat) {
this.lat = lat;
return this;
}
/**
* Sets Locality within the administrative region,<br>
* such as a town or city.
*
* @param locality locality in a region
* @return Builder
*/
public Builder setLocality(String locality) {
this.locality = locality;
return this;
}
/**
* Sets Longitude in decimal degrees East.
*
* @param lon longitude in decimal degrees
* @return Builder
*/
public Builder setLon(Double lon) {
this.lon = lon;
return this;
}
/**
* Sets PostalCode used for postal delivery.
*
* @param postalcode code for postal delivery
* @return Builder
*/
public Builder setPostalcode(String postalcode) {
this.postalcode = postalcode;
return this;
}
/**
* Sets an administrative region of the nation,<br>
* such as a state or province.
*
* @param region an administrative region
* @return Builder
*/
public Builder setRegion(String region) {
this.region = region;
return this;
}
/**
* Sets a particular room in a building.
*
* @param room room inside a building
* @return Builder
*/
public Builder setRoom(String room) {
this.room = room;
return this;
}
/**
* Sets Speed at which the entity is moving, in meters per second.
*
* @param speed speed in meters per second
* @return Builder
*/
public Builder setSpeed(Double speed) {
this.speed = speed;
return this;
}
/**
* Sets a thoroughfare within the locality, or a crossing of two thoroughfares.
*
* @param street name of the street
* @return Builder
*/
public Builder setStreet(String street) {
this.street = street;
return this;
}
/**
* Sets a catch-all element that captures any other information about the location.
*
* @param text distinctive feature about the location
* @return Builder
*/
public Builder setText(String text) {
this.text = text;
return this;
}
/**
* Sets UTC timestamp specifying the moment when the reading was taken.
*
* @param timestamp timestamp of the reading
* @return Builder
*/
public Builder setTimestamp(Date timestamp) {
this.timestamp = timestamp;
return this;
}
/**
* Sets the time zone offset from UTC for the current location.
*
* @param tzo time zone offset
* @return Builder
*/
public Builder setTzo(String tzo) {
this.tzo = tzo;
return this;
}
/**
* Sets URI or URL pointing to information about the location.
*
* @param uri uri to the location
* @return Builder
*/
public Builder setUri(URI uri) {
this.uri = uri;
return this;
}
/**
* This method is called to build {@link GeoLocation} from the Builder.
*
* @return GeoLocation
*/
public GeoLocation build() {
return new GeoLocation(accuracy, alt, altAccuracy, area, bearing, building, country, countryCode, datum, description,
error, floor, lat, locality, lon, postalcode, region, room, speed, street, text, timestamp,
tzo, uri);
}
}
}

View file

@ -32,7 +32,6 @@ import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
import org.jivesoftware.smackx.jingle.element.JingleContentTransportCandidate;
import org.jivesoftware.smackx.jingle.provider.JingleContentTransportProvider;
import org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements.JingleS5BTransport;
import org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements.JingleS5BTransportCandidate;
@ -67,7 +66,7 @@ public class JingleS5BTransportProvider extends JingleContentTransportProvider<J
case START_ELEMENT: {
switch (name) {
case JingleContentTransportCandidate.ELEMENT:
case JingleS5BTransportCandidate.ELEMENT:
cb = JingleS5BTransportCandidate.getBuilder();
cb.setCandidateId(parser.getAttributeValue(null, ATTR_CID));
cb.setHost(parser.getAttributeValue(null, ATTR_HOST));

View file

@ -91,7 +91,7 @@ public final class MoodManager extends Manager {
@Override
public void run() {
ItemsExtension items = (ItemsExtension) event.getExtensions().get(0);
PayloadItem<?> payload = (PayloadItem<?>) items.getItems().get(0);
PayloadItem<?> payload = (PayloadItem) items.getItems().get(0);
MoodElement mood = (MoodElement) payload.getPayload();
for (MoodListener listener : moodListeners) {

View file

@ -57,7 +57,7 @@ public class MoodProvider extends ExtensionElementProvider<MoodElement> {
if (!MoodElement.NAMESPACE.equals(namespace)) {
LOGGER.log(Level.FINE, "Foreign namespace " + namespace + " detected. Try to find suitable MoodConcretisationProvider.");
MoodConcretisationProvider<?> provider = (MoodConcretisationProvider<?>) ProviderManager.getExtensionProvider(name, namespace);
MoodConcretisationProvider<?> provider = (MoodConcretisationProvider) ProviderManager.getExtensionProvider(name, namespace);
if (provider != null) {
concretisation = provider.parse(parser);
} else {

View file

@ -53,7 +53,7 @@ public class Occupant {
}
Occupant(Presence presence) {
MUCUser mucUser = (MUCUser) presence.getExtensionElement("x",
MUCUser mucUser = (MUCUser) presence.getExtension("x",
"http://jabber.org/protocol/muc#user");
MUCItem item = mucUser.getItem();
this.jid = item.getJid();

View file

@ -236,6 +236,7 @@ public class LeafNode extends Node {
* @throws NoResponseException if there was no response from the remote entity.
* @deprecated use {@link #publish(Item)} instead.
*/
@SuppressWarnings("unchecked")
@Deprecated
public <T extends Item> void send(T item) throws NotConnectedException, InterruptedException, NoResponseException, XMPPErrorException {
publish(item);

View file

@ -686,7 +686,7 @@ public abstract class Node {
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public void processStanza(Stanza packet) {
EventElement event = (EventElement) packet.getExtensionElement("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 = (EventElement) packet.getExtensionElement("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 = (EventElement) packet.getExtensionElement("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?)

View file

@ -503,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 = (SubscriptionsExtension) reply.getExtensionElement(PubSubElementType.SUBSCRIPTIONS.getElementName(), PubSubElementType.SUBSCRIPTIONS.getNamespace().getXmlns());
SubscriptionsExtension subElem = (SubscriptionsExtension) reply.getExtension(PubSubElementType.SUBSCRIPTIONS.getElementName(), PubSubElementType.SUBSCRIPTIONS.getNamespace().getXmlns());
return subElem.getSubscriptions();
}

View file

@ -51,7 +51,7 @@ public class PubSub extends IQ {
@SuppressWarnings("unchecked")
public <PE extends ExtensionElement> PE getExtension(PubSubElementType elem) {
return (PE) getExtensionElement(elem.getElementName(), elem.getNamespace().getXmlns());
return (PE) getExtension(elem.getElementName(), elem.getNamespace().getXmlns());
}
/**

View file

@ -37,7 +37,7 @@ public class NodeUtils {
* @return The configuration form
*/
public static ConfigureForm getFormFromPacket(Stanza packet, PubSubElementType elem) {
FormNode config = (FormNode) packet.getExtensionElement(elem.getElementName(), elem.getNamespace().getXmlns());
FormNode config = (FormNode) packet.getExtension(elem.getElementName(), elem.getNamespace().getXmlns());
Form formReply = config.getForm();
return new ConfigureForm(formReply);
}

View file

@ -151,7 +151,7 @@ public class RSMSet implements ExtensionElement {
}
public static RSMSet from(Stanza packet) {
return (RSMSet) packet.getExtensionElement(ELEMENT, NAMESPACE);
return (RSMSet) packet.getExtension(ELEMENT, NAMESPACE);
}
public static RSMSet newAfter(String after) {

View file

@ -89,7 +89,7 @@ public class XHTMLManager {
* @return a boolean indicating whether the message is an XHTML message
*/
public static boolean isXHTMLMessage(Message message) {
return message.getExtensionElement(XHTMLExtension.ELEMENT, XHTMLExtension.NAMESPACE) != null;
return message.getExtension(XHTMLExtension.ELEMENT, XHTMLExtension.NAMESPACE) != null;
}
/**

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2020 Florian Schmaus
* Copyright 2014 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -14,8 +14,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.smackx;
/**
* Java annotations for Smack's Integration Test Framework.
*/
package org.igniterealtime.smack.inttest.annotations;
import org.jivesoftware.smack.extensions.ExtensionsInitializer;
import org.jivesoftware.smack.test.util.SmackTestSuite;
public class InitExtensions extends SmackTestSuite {
static {
new ExtensionsInitializer().initialize();
}
}

View file

@ -20,7 +20,7 @@ import static org.jivesoftware.smack.test.util.XmlUnitUtils.assertXmlSimilar;
import org.jivesoftware.smackx.attention.packet.AttentionExtension;
import org.junit.jupiter.api.Test;
import org.junit.Test;
public class AttentionElementTest {

View file

@ -23,22 +23,22 @@ import static org.mockito.Mockito.verify;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.StanzaError;
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smack.test.util.Whitebox;
import org.jivesoftware.smackx.InitExtensions;
import org.jivesoftware.smackx.bytestreams.ibb.packet.Close;
import org.junit.jupiter.api.Test;
import org.jxmpp.jid.Jid;
import org.jxmpp.jid.JidTestUtil;
import org.mockito.ArgumentCaptor;
import org.powermock.reflect.Whitebox;
/**
* Test for the CloseListener class.
*
* @author Henning Staib
*/
public class CloseListenerTest extends SmackTestSuite {
public class CloseListenerTest extends InitExtensions {
private static final Jid initiatorJID = JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE;
private static final Jid targetJID = JidTestUtil.FULL_JID_1_RESOURCE_1;
@ -59,7 +59,7 @@ public class CloseListenerTest extends SmackTestSuite {
InBandBytestreamManager byteStreamManager = InBandBytestreamManager.getByteStreamManager(connection);
// get the CloseListener from InBandByteStreamManager
CloseListener closeListener = Whitebox.getInternalState(byteStreamManager, "closeListener",
CloseListener closeListener = Whitebox.getInternalState(byteStreamManager,
CloseListener.class);
Close close = new Close("unknownSessionId");

View file

@ -23,9 +23,8 @@ import static org.mockito.Mockito.verify;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.StanzaError;
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smack.test.util.Whitebox;
import org.jivesoftware.smackx.InitExtensions;
import org.jivesoftware.smackx.bytestreams.ibb.packet.Data;
import org.jivesoftware.smackx.bytestreams.ibb.packet.DataPacketExtension;
@ -33,13 +32,14 @@ import org.junit.jupiter.api.Test;
import org.jxmpp.jid.Jid;
import org.jxmpp.jid.JidTestUtil;
import org.mockito.ArgumentCaptor;
import org.powermock.reflect.Whitebox;
/**
* Test for the CloseListener class.
*
* @author Henning Staib
*/
public class DataListenerTest extends SmackTestSuite {
public class DataListenerTest extends InitExtensions {
private static final Jid initiatorJID = JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE;
private static final Jid targetJID = JidTestUtil.FULL_JID_1_RESOURCE_1;
@ -60,7 +60,7 @@ public class DataListenerTest extends SmackTestSuite {
InBandBytestreamManager byteStreamManager = InBandBytestreamManager.getByteStreamManager(connection);
// get the DataListener from InBandByteStreamManager
DataListener dataListener = Whitebox.getInternalState(byteStreamManager, "dataListener",
DataListener dataListener = Whitebox.getInternalState(byteStreamManager,
DataListener.class);
DataPacketExtension dpe = new DataPacketExtension("unknownSessionID", 0, "Data");

View file

@ -29,8 +29,8 @@ import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.StanzaError;
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smackx.InitExtensions;
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager.StanzaType;
import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
@ -47,7 +47,7 @@ import org.jxmpp.jid.JidTestUtil;
*
* @author Henning Staib
*/
public class InBandBytestreamManagerTest extends SmackTestSuite {
public class InBandBytestreamManagerTest extends InitExtensions {
// settings
private static final EntityFullJid initiatorJID = JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE;

View file

@ -25,8 +25,8 @@ import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.StanzaError;
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smackx.InitExtensions;
import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
import org.junit.jupiter.api.BeforeEach;
@ -40,7 +40,7 @@ import org.mockito.ArgumentCaptor;
*
* @author Henning Staib
*/
public class InBandBytestreamRequestTest extends SmackTestSuite {
public class InBandBytestreamRequestTest extends InitExtensions {
private static final Jid initiatorJID = JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE;
private static final Jid targetJID = JidTestUtil.FULL_JID_1_RESOURCE_1;

View file

@ -32,10 +32,9 @@ import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.StanzaBuilder;
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smack.test.util.Whitebox;
import org.jivesoftware.smack.util.stringencoder.Base64;
import org.jivesoftware.smackx.InitExtensions;
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager.StanzaType;
import org.jivesoftware.smackx.bytestreams.ibb.packet.DataPacketExtension;
import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
@ -47,6 +46,7 @@ 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;
/**
* Test for InBandBytestreamSession.
@ -55,7 +55,7 @@ import org.jxmpp.jid.JidTestUtil;
*
* @author Henning Staib
*/
public class InBandBytestreamSessionMessageTest extends SmackTestSuite {
public class InBandBytestreamSessionMessageTest extends InitExtensions {
// settings
private static final EntityFullJid initiatorJID = JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE;
@ -262,7 +262,7 @@ public class InBandBytestreamSessionMessageTest extends SmackTestSuite {
InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream,
initiatorJID);
InputStream inputStream = session.getInputStream();
StanzaListener listener = Whitebox.getInternalState(inputStream, "dataPacketListener", StanzaListener.class);
StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class);
// build invalid packet with out of order sequence
String base64Data = Base64.encode("Data");
@ -303,7 +303,7 @@ public class InBandBytestreamSessionMessageTest extends SmackTestSuite {
InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream,
initiatorJID);
InputStream inputStream = session.getInputStream();
StanzaListener listener = Whitebox.getInternalState(inputStream, "dataPacketListener", StanzaListener.class);
StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class);
// verify data packet and notify listener
for (int i = 0; i < controlData.length / blockSize; i++) {
@ -349,7 +349,7 @@ public class InBandBytestreamSessionMessageTest extends SmackTestSuite {
InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream,
initiatorJID);
InputStream inputStream = session.getInputStream();
StanzaListener listener = Whitebox.getInternalState(inputStream, "dataPacketListener", StanzaListener.class);
StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class);
// verify data packet and notify listener
for (int i = 0; i < controlData.length / blockSize; i++) {

View file

@ -31,10 +31,9 @@ import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.StanzaError;
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smack.test.util.Whitebox;
import org.jivesoftware.smack.util.stringencoder.Base64;
import org.jivesoftware.smackx.InitExtensions;
import org.jivesoftware.smackx.bytestreams.ibb.packet.Data;
import org.jivesoftware.smackx.bytestreams.ibb.packet.DataPacketExtension;
import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
@ -46,6 +45,7 @@ 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;
/**
* Test for InBandBytestreamSession.
@ -55,7 +55,7 @@ import org.jxmpp.jid.JidTestUtil;
*
* @author Henning Staib
*/
public class InBandBytestreamSessionTest extends SmackTestSuite {
public class InBandBytestreamSessionTest extends InitExtensions {
// settings
private static final EntityFullJid initiatorJID = JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE;
@ -309,7 +309,7 @@ public class InBandBytestreamSessionTest extends SmackTestSuite {
// insert data to read
InputStream inputStream = session.getInputStream();
StanzaListener listener = Whitebox.getInternalState(inputStream, "dataPacketListener", StanzaListener.class);
StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class);
String base64Data = Base64.encode("Data");
DataPacketExtension dpe = new DataPacketExtension(sessionID, 0, base64Data);
Data data = new Data(dpe);
@ -343,7 +343,7 @@ public class InBandBytestreamSessionTest extends SmackTestSuite {
InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream,
initiatorJID);
InputStream inputStream = session.getInputStream();
StanzaListener listener = Whitebox.getInternalState(inputStream, "dataPacketListener", StanzaListener.class);
StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class);
String base64Data = Base64.encode("Data");
DataPacketExtension dpe = new DataPacketExtension(sessionID, 0, base64Data);
@ -381,7 +381,7 @@ public class InBandBytestreamSessionTest extends SmackTestSuite {
InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream,
initiatorJID);
InputStream inputStream = session.getInputStream();
StanzaListener listener = Whitebox.getInternalState(inputStream, "dataPacketListener", StanzaListener.class);
StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class);
// build data packets
String base64Data = Base64.encode("Data");
@ -420,7 +420,7 @@ public class InBandBytestreamSessionTest extends SmackTestSuite {
InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream,
initiatorJID);
InputStream inputStream = session.getInputStream();
StanzaListener listener = Whitebox.getInternalState(inputStream, "dataPacketListener", StanzaListener.class);
StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class);
// build data packets
DataPacketExtension dpe = new DataPacketExtension(sessionID, 0, "AA=BB");
@ -454,7 +454,7 @@ public class InBandBytestreamSessionTest extends SmackTestSuite {
InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream,
initiatorJID);
InputStream inputStream = session.getInputStream();
StanzaListener listener = Whitebox.getInternalState(inputStream, "dataPacketListener", StanzaListener.class);
StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class);
// build invalid packet with out of order sequence
String base64Data = Base64.encode("Data");
@ -495,7 +495,7 @@ public class InBandBytestreamSessionTest extends SmackTestSuite {
InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream,
initiatorJID);
InputStream inputStream = session.getInputStream();
StanzaListener listener = Whitebox.getInternalState(inputStream, "dataPacketListener", StanzaListener.class);
StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class);
// set data packet acknowledgment and notify listener
for (int i = 0; i < controlData.length / blockSize; i++) {
@ -542,7 +542,7 @@ public class InBandBytestreamSessionTest extends SmackTestSuite {
InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream,
initiatorJID);
InputStream inputStream = session.getInputStream();
StanzaListener listener = Whitebox.getInternalState(inputStream, "dataPacketListener", StanzaListener.class);
StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class);
// set data packet acknowledgment and notify listener
for (int i = 0; i < controlData.length / blockSize; i++) {
@ -583,7 +583,7 @@ public class InBandBytestreamSessionTest extends SmackTestSuite {
InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream,
initiatorJID);
InputStream inputStream = session.getInputStream();
StanzaListener listener = Whitebox.getInternalState(inputStream, "dataPacketListener", StanzaListener.class);
StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class);
// build data packet
String base64Data = Base64.encode("Data");
@ -626,7 +626,7 @@ public class InBandBytestreamSessionTest extends SmackTestSuite {
InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream,
initiatorJID);
final InputStream inputStream = session.getInputStream();
StanzaListener listener = Whitebox.getInternalState(inputStream, "dataPacketListener", StanzaListener.class);
StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class);
// build data packet
String base64Data = Base64.encode("Data");

View file

@ -24,9 +24,8 @@ import static org.mockito.Mockito.verify;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.StanzaError;
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smack.test.util.Whitebox;
import org.jivesoftware.smackx.InitExtensions;
import org.jivesoftware.smackx.bytestreams.BytestreamRequest;
import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
@ -36,13 +35,14 @@ import org.jxmpp.jid.EntityFullJid;
import org.jxmpp.jid.JidTestUtil;
import org.jxmpp.jid.impl.JidCreate;
import org.mockito.ArgumentCaptor;
import org.powermock.reflect.Whitebox;
/**
* Test for the InitiationListener class.
*
* @author Henning Staib
*/
public class InitiationListenerTest extends SmackTestSuite {
public class InitiationListenerTest extends InitExtensions {
private static final EntityFullJid initiatorJID = JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE;
private static final EntityFullJid targetJID = JidTestUtil.FULL_JID_1_RESOURCE_1;
@ -66,7 +66,7 @@ public class InitiationListenerTest extends SmackTestSuite {
byteStreamManager = InBandBytestreamManager.getByteStreamManager(connection);
// get the InitiationListener from InBandByteStreamManager
initiationListener = Whitebox.getInternalState(byteStreamManager, "initiationListener", InitiationListener.class);
initiationListener = Whitebox.getInternalState(byteStreamManager, InitiationListener.class);
// create a In-Band Bytestream open packet
initBytestream = new Open(sessionID, 4096);

View file

@ -24,7 +24,8 @@ import java.util.Properties;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.StreamOpen;
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smackx.InitExtensions;
import com.jamesmurty.utils.XMLBuilder;
import org.junit.jupiter.api.Test;
@ -35,7 +36,7 @@ import org.jxmpp.jid.impl.JidCreate;
*
* @author Henning Staib
*/
public class CloseTest extends SmackTestSuite {
public class CloseTest extends InitExtensions {
@Test
public void shouldNotInstantiateWithInvalidArguments1() {

View file

@ -24,7 +24,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import java.nio.charset.StandardCharsets;
import java.util.Properties;
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smackx.InitExtensions;
import com.jamesmurty.utils.XMLBuilder;
import org.junit.jupiter.api.Test;
@ -34,7 +34,7 @@ import org.junit.jupiter.api.Test;
*
* @author Henning Staib
*/
public class DataPacketExtensionTest extends SmackTestSuite {
public class DataPacketExtensionTest extends InitExtensions {
@Test
public void shouldNotInstantiateWithInvalidArgument1() {

View file

@ -25,9 +25,10 @@ import java.util.Properties;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.StreamOpen;
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smack.util.stringencoder.Base64;
import org.jivesoftware.smackx.InitExtensions;
import com.jamesmurty.utils.XMLBuilder;
import org.junit.jupiter.api.Test;
import org.jxmpp.jid.impl.JidCreate;
@ -37,7 +38,7 @@ import org.jxmpp.jid.impl.JidCreate;
*
* @author Henning Staib
*/
public class DataTest extends SmackTestSuite {
public class DataTest extends InitExtensions {
@Test
public void shouldNotInstantiateWithInvalidArgument() {

View file

@ -24,11 +24,12 @@ import java.util.Properties;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.StreamOpen;
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smackx.InitExtensions;
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager.StanzaType;
import com.jamesmurty.utils.XMLBuilder;
import org.junit.jupiter.api.Test;
import org.jxmpp.jid.impl.JidCreate;
@ -37,7 +38,7 @@ import org.jxmpp.jid.impl.JidCreate;
*
* @author Henning Staib
*/
public class OpenTest extends SmackTestSuite {
public class OpenTest extends InitExtensions {
@Test
public void shouldNotInstantiateWithInvalidArguments1() {

View file

@ -20,10 +20,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Properties;
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smack.util.PacketParserUtils;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smackx.InitExtensions;
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager.StanzaType;
import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
@ -35,7 +35,7 @@ import org.junit.jupiter.api.Test;
*
* @author Henning Staib
*/
public class OpenIQProviderTest extends SmackTestSuite {
public class OpenIQProviderTest extends InitExtensions {
private static final Properties outputProperties = new Properties();
{

View file

@ -25,7 +25,6 @@ import static org.mockito.Mockito.verify;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.StanzaError;
import org.jivesoftware.smack.test.util.Whitebox;
import org.jivesoftware.smackx.bytestreams.BytestreamRequest;
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream;
@ -38,6 +37,7 @@ import org.jxmpp.jid.EntityFullJid;
import org.jxmpp.jid.JidTestUtil;
import org.jxmpp.jid.impl.JidCreate;
import org.mockito.ArgumentCaptor;
import org.powermock.reflect.Whitebox;
/**
* Test for the InitiationListener class.
@ -75,7 +75,7 @@ public class InitiationListenerTest {
byteStreamManager = Socks5BytestreamManager.getBytestreamManager(connection);
// get the InitiationListener from Socks5ByteStreamManager
initiationListener = Whitebox.getInternalState(byteStreamManager, "initiationListener", InitiationListener.class);
initiationListener = Whitebox.getInternalState(byteStreamManager, InitiationListener.class);
// create a SOCKS5 Bytestream initiation packet
initBytestream = Socks5PacketUtils.createBytestreamInitiation(initiatorJID, targetJID,

View file

@ -41,8 +41,8 @@ import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.ErrorIQ;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.StanzaError;
import org.jivesoftware.smack.test.util.NetworkUtil;
import org.jivesoftware.smack.util.ExceptionUtil;
import org.jivesoftware.smack.util.NetworkUtil;
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream;
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream.StreamHost;

View file

@ -31,7 +31,7 @@ import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.StanzaError;
import org.jivesoftware.smack.test.util.NetworkUtil;
import org.jivesoftware.smack.util.NetworkUtil;
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream;

View file

@ -28,7 +28,7 @@ import java.net.Socket;
import java.nio.charset.StandardCharsets;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.test.util.NetworkUtil;
import org.jivesoftware.smack.util.NetworkUtil;
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream.StreamHost;

View file

@ -19,7 +19,7 @@ package org.jivesoftware.smackx.bytestreams.socks5;
import java.io.IOException;
import java.net.ServerSocket;
import org.jivesoftware.smack.test.util.NetworkUtil;
import org.jivesoftware.smack.util.NetworkUtil;
/**
* Simple SOCKS5 proxy for testing purposes. It is almost the same as the Socks5Proxy class but the

View file

@ -26,11 +26,11 @@ import java.util.Collection;
import java.util.LinkedList;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smack.util.stringencoder.Base32;
import org.jivesoftware.smack.util.stringencoder.StringEncoder;
import org.jivesoftware.smackx.InitExtensions;
import org.jivesoftware.smackx.caps.cache.EntityCapsPersistentCache;
import org.jivesoftware.smackx.caps.cache.SimpleDirectoryPersistentCache;
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
@ -43,7 +43,7 @@ import org.jxmpp.jid.impl.JidCreate;
import org.jxmpp.stringprep.XmppStringprepException;
public class EntityCapsManagerTest extends SmackTestSuite {
public class EntityCapsManagerTest extends InitExtensions {
/**
* <a href="http://xmpp.org/extensions/xep-0115.html#ver-gen-complex">XEP-

View file

@ -18,15 +18,15 @@ package org.jivesoftware.smackx.caps.provider;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smack.test.util.SmackTestUtil;
import org.jivesoftware.smackx.InitExtensions;
import org.jivesoftware.smackx.caps.packet.CapsExtension;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;
public class CapsExtensionProviderTest extends SmackTestSuite {
public class CapsExtensionProviderTest extends InitExtensions {
@ParameterizedTest
@EnumSource(SmackTestUtil.XmlPullParserKind.class)

View file

@ -31,11 +31,11 @@ import java.util.TimeZone;
import javax.xml.parsers.FactoryConfigurationError;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smack.util.PacketParserUtils;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import org.jivesoftware.smackx.InitExtensions;
import org.jivesoftware.smackx.delay.DelayInformationManager;
import org.jivesoftware.smackx.delay.packet.DelayInformation;
@ -43,7 +43,7 @@ import com.jamesmurty.utils.XMLBuilder;
import org.junit.jupiter.api.Test;
import org.jxmpp.util.XmppDateTime;
public class DelayInformationTest extends SmackTestSuite {
public class DelayInformationTest extends InitExtensions {
private static final Calendar calendar = new GregorianCalendar(2002, 9 - 1, 10, 23, 8, 25);
private static Properties outputProperties = new Properties();

View file

@ -21,8 +21,8 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import org.jivesoftware.smack.DummyConnection;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smackx.InitExtensions;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
import org.junit.jupiter.api.AfterEach;
@ -30,7 +30,7 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.jxmpp.jid.JidTestUtil;
public class FileTransferNegotiatorTest extends SmackTestSuite {
public class FileTransferNegotiatorTest extends InitExtensions {
private DummyConnection connection;
@BeforeEach

View file

@ -24,9 +24,9 @@ import java.util.Calendar;
import java.util.TimeZone;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smack.util.PacketParserUtils;
import org.jivesoftware.smackx.InitExtensions;
import org.jivesoftware.smackx.time.packet.Time;
import org.junit.jupiter.api.Test;
@ -37,7 +37,7 @@ import org.jxmpp.util.XmppDateTime;
*
* @author Ishan Khanna
*/
public class GeoLocationTest extends SmackTestSuite {
public class GeoLocationTest extends InitExtensions {
@Test
public void negativeTimezoneTest() {

View file

@ -23,15 +23,15 @@ import static org.junit.jupiter.api.Assertions.assertNull;
import java.net.URI;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smack.util.PacketParserUtils;
import org.jivesoftware.smackx.InitExtensions;
import org.jivesoftware.smackx.geoloc.packet.GeoLocation;
import org.junit.jupiter.api.Test;
import org.jxmpp.util.XmppDateTime;
public class GeoLocationProviderTest extends SmackTestSuite {
public class GeoLocationProviderTest extends InitExtensions {
@Test
public void testGeoLocationProviderWithNoDatumSet() throws Exception {

View file

@ -22,15 +22,15 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import org.jivesoftware.smack.DummyConnection;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smack.util.PacketParserUtils;
import org.jivesoftware.smackx.InitExtensions;
import org.jivesoftware.smackx.iqlast.packet.LastActivity;
import com.jamesmurty.utils.XMLBuilder;
import org.junit.jupiter.api.Test;
public class LastActivityTest extends SmackTestSuite {
public class LastActivityTest extends InitExtensions {
@Test
public void checkProvider() throws Exception {

View file

@ -24,14 +24,14 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import org.jivesoftware.smack.DummyConnection;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smack.util.PacketParserUtils;
import org.jivesoftware.smackx.InitExtensions;
import org.jivesoftware.smackx.iqversion.packet.Version;
import org.junit.jupiter.api.Test;
public class VersionTest extends SmackTestSuite {
public class VersionTest extends InitExtensions {
@Test
public void checkProvider() throws Exception {
// @formatter:off

View file

@ -16,16 +16,24 @@
*/
package org.jivesoftware.smackx.jingle;
import org.jivesoftware.smack.DummyConnection;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smackx.jingle.element.Jingle;
import org.jivesoftware.smackx.jingle.element.JingleContent;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.jxmpp.jid.FullJid;
import org.jxmpp.jid.impl.JidCreate;
import org.jxmpp.stringprep.XmppStringprepException;
/**
* Test the JingleUtil class.
*/
public class JingleUtilTest extends SmackTestSuite {
// TODO: Finish the test.
/*
private XMPPConnection connection;
private JingleUtil jutil;
@ -94,5 +102,4 @@ public class JingleUtilTest extends SmackTestSuite {
"</iq>";
// TODO: Finish test
}
*/
}

View file

@ -20,16 +20,16 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smack.util.PacketParserUtils;
import org.jivesoftware.smackx.InitExtensions;
import org.jivesoftware.smackx.jiveproperties.packet.JivePropertiesExtension;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class JivePropertiesExtensionTest extends SmackTestSuite {
public class JivePropertiesExtensionTest extends InitExtensions {
@BeforeEach
public void setUp() {

View file

@ -16,8 +16,8 @@
*/
package org.jivesoftware.smackx.muc;
import org.jivesoftware.smack.test.util.MemoryLeakTestUtil;
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smack.util.MemoryLeakTestUtil;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

View file

@ -17,20 +17,19 @@
package org.jivesoftware.smackx.nick;
import static org.jivesoftware.smack.test.util.XmlUnitUtils.assertXmlSimilar;
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.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThrows;
import java.io.IOException;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.test.util.SmackTestUtil;
import org.jivesoftware.smack.xml.XmlPullParserException;
import org.jivesoftware.smackx.nick.packet.Nick;
import org.jivesoftware.smackx.nick.provider.NickProvider;
import org.junit.jupiter.api.Test;
import org.junit.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;
@ -42,16 +41,14 @@ public class NickTest {
@Test
public void disallowEmptyNickTest() {
assertThrows(IllegalArgumentException.class,
() -> new Nick(""),
"Empty String as argument MUST cause IllegalArgumentException.");
assertThrows("Empty String as argument MUST cause IllegalArgumentException.",
IllegalArgumentException.class, () -> new Nick(""));
}
@Test
public void disallowNullNickTest() {
assertThrows(IllegalArgumentException.class,
() -> new Nick(null),
"Null argument MUST cause IllegalArgumentException.");
assertThrows("Null argument MUST cause IllegalArgumentException.",
IllegalArgumentException.class, () -> new Nick(null));
}

View file

@ -33,14 +33,14 @@ import org.jivesoftware.smack.ThreadedDummyConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smack.util.PacketParserUtils;
import org.jivesoftware.smackx.InitExtensions;
import org.jivesoftware.smackx.ping.packet.Ping;
import org.junit.jupiter.api.Test;
public class PingTest extends SmackTestSuite {
public class PingTest extends InitExtensions {
@Test
public void checkProvider() throws Exception {

View file

@ -23,15 +23,15 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smack.util.PacketParserUtils;
import org.jivesoftware.smackx.InitExtensions;
import org.jivesoftware.smackx.privacy.packet.Privacy;
import org.jivesoftware.smackx.privacy.packet.PrivacyItem;
import org.junit.jupiter.api.Test;
public class PrivacyProviderTest extends SmackTestSuite {
public class PrivacyProviderTest extends InitExtensions {
@Test
public void parsePrivacyList() throws Exception {

View file

@ -31,8 +31,8 @@ import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.StanzaError;
import org.jivesoftware.smack.packet.StanzaError.Condition;
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smackx.InitExtensions;
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
import org.jivesoftware.smackx.disco.packet.DiscoverInfo.Identity;
import org.jivesoftware.smackx.disco.packet.DiscoverInfoBuilder;
@ -46,7 +46,7 @@ import org.junit.jupiter.api.Test;
* @author Robin Collier
*
*/
public class ConfigureFormTest extends SmackTestSuite {
public class ConfigureFormTest extends InitExtensions {
@Test
public void checkChildrenAssocPolicy() {
ConfigureForm form = new ConfigureForm(DataForm.Type.submit);

View file

@ -24,10 +24,10 @@ import org.jivesoftware.smack.ThreadedDummyConnection;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.NamedElement;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smack.util.PacketParserUtils;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smackx.InitExtensions;
import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace;
import org.junit.jupiter.api.AfterEach;
@ -39,7 +39,7 @@ import org.junit.jupiter.api.Test;
* @author Robin Collier
*
*/
public class ItemValidationTest extends SmackTestSuite {
public class ItemValidationTest extends InitExtensions {
private ThreadedDummyConnection connection;
@BeforeEach

View file

@ -30,18 +30,18 @@ import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.MessageBuilder;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.StanzaBuilder;
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smack.test.util.WaitForPacketListener;
import org.jivesoftware.smack.util.PacketParserUtils;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smackx.InitExtensions;
import org.jivesoftware.smackx.receipts.DeliveryReceiptManager.AutoReceiptMode;
import com.jamesmurty.utils.XMLBuilder;
import org.junit.jupiter.api.Test;
import org.jxmpp.jid.Jid;
public class DeliveryReceiptTest extends SmackTestSuite {
public class DeliveryReceiptTest extends InitExtensions {
private static Properties outputProperties = new Properties();
static {

View file

@ -20,14 +20,14 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smack.util.PacketParserUtils;
import org.jivesoftware.smackx.InitExtensions;
import org.jivesoftware.smackx.rsm.packet.RSMSet;
import org.junit.jupiter.api.Test;
public class RSMSetProviderTest extends SmackTestSuite {
public class RSMSetProviderTest extends InitExtensions {
@Test
public void testRsmSetProvider() throws Exception {

View file

@ -22,11 +22,11 @@ import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smackx.InitExtensions;
import org.junit.jupiter.api.Test;
public class TimeTest extends SmackTestSuite {
public class TimeTest extends InitExtensions {
@Test
public void parseCurrentTimeTest() {

View file

@ -21,15 +21,15 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Arrays;
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smack.util.PacketParserUtils;
import org.jivesoftware.smack.util.stringencoder.Base64;
import org.jivesoftware.smackx.InitExtensions;
import org.jivesoftware.smackx.vcardtemp.packet.VCard;
import org.junit.jupiter.api.Test;
public class VCardTest extends SmackTestSuite {
public class VCardTest extends InitExtensions {
@Test
public void testParseFullVCardIQStanza() throws Throwable {

View file

@ -7,5 +7,5 @@ Roster, Chat and other functionality."""
// sourceSet.test of the core subproject
dependencies {
compile project(':smack-core')
testImplementation(testFixtures(project(":smack-core")))
testCompile project(path: ":smack-core", configuration: "testRuntime")
}

View file

@ -12,8 +12,15 @@ dependencies {
compile 'org.reflections:reflections:0.9.11'
compile 'eu.geekplace.javapinning:java-pinning-java7:1.1.0-alpha1'
compile group: 'commons-io', name: 'commons-io', version: "$commonsIoVersion"
api "org.junit.jupiter:junit-jupiter-api:$junitVersion"
testFixturesApi(testFixtures(project(":smack-core")))
// Note that the junit-vintage-engine runtime dependency is not
// directly required, but it declares a dependency to
// junit:junit:4.12, which we currently need in sinttest, since it
// (ab)uses @Before from org.junit
compile "org.junit.vintage:junit-vintage-engine:$junitVersion"
compile 'junit:junit:4.12'
// Add Junit 5 API for e.g. assertThrows()
implementation "org.junit.jupiter:junit-jupiter-api:$junitVersion"
testCompile project(path: ":smack-core", configuration: "testRuntime")
testCompile "org.jxmpp:jxmpp-jid:$jxmppVersion:tests"
}

Some files were not shown because too many files have changed in this diff Show more