1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-23 23:02:05 +01:00

Introduce test fixtures

This also removes the powermock dependency. Although powermock is a
fine library, it currently prevents dropping Junit4. And since we only
use the Whitebox API of powermock, this simply replaced powermock's
Whitebox with our own.
This commit is contained in:
Florian Schmaus 2020-04-11 21:59:21 +02:00
parent 4a99f7252c
commit b5f9d4d7a3
51 changed files with 123 additions and 80 deletions

View file

@ -24,6 +24,7 @@ apply from: 'version.gradle'
allprojects { allprojects {
apply plugin: 'java-library' apply plugin: 'java-library'
apply plugin: 'java-test-fixtures'
apply plugin: 'eclipse' apply plugin: 'eclipse'
apply plugin: 'idea' apply plugin: 'idea'
apply plugin: 'jacoco' apply plugin: 'jacoco'
@ -130,7 +131,6 @@ allprojects {
':smack-openpgp', ':smack-openpgp',
].collect { project(it) } ].collect { project(it) }
junitVersion = '5.6.0' junitVersion = '5.6.0'
powerMockVersion = '2.0.2'
commonsIoVersion = '2.6' commonsIoVersion = '2.6'
if (project.hasProperty("useSonatype")) { if (project.hasProperty("useSonatype")) {
useSonatype = project.getProperty("useSonatype").toBoolean() useSonatype = project.getProperty("useSonatype").toBoolean()
@ -266,10 +266,16 @@ allprojects {
} }
dependencies { dependencies {
testImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion" testFixturesApi "org.junit.jupiter:junit-jupiter-api:$junitVersion"
testImplementation "org.junit.jupiter:junit-jupiter-params:$junitVersion" testImplementation "org.junit.jupiter:junit-jupiter-params:$junitVersion"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$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' errorprone 'com.google.errorprone:error_prone_core:2.3.3'
errorproneJavac('com.google.errorprone:javac:9+181-r4173-1') errorproneJavac('com.google.errorprone:javac:9+181-r4173-1')
} }
@ -282,9 +288,6 @@ allprojects {
configure (junit4Projects) { configure (junit4Projects) {
dependencies { dependencies {
testImplementation "org.junit.vintage:junit-vintage-engine:$junitVersion" 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" <suppress checks="GenericWhitespace"
files="Protocol.java" /> files="Protocol.java" />
<!-- Suppress JavadocPackage in the test packages --> <!-- Suppress JavadocPackage in the test packages -->
<suppress checks="JavadocPackage" files="[\\/]test[\\/]"/> <suppress checks="JavadocPackage" files="[\\/]test(Fixtures)?[\\/]"/>
</suppressions> </suppressions>

View file

@ -10,10 +10,19 @@ dependencies {
compile "org.jxmpp:jxmpp-core:$jxmppVersion" compile "org.jxmpp:jxmpp-core:$jxmppVersion"
compile "org.jxmpp:jxmpp-jid:$jxmppVersion" compile "org.jxmpp:jxmpp-jid:$jxmppVersion"
compile "org.minidns:minidns-core:$miniDnsVersion" compile "org.minidns:minidns-core:$miniDnsVersion"
testCompile project(':smack-xmlparser-stax')
testCompile project(':smack-xmlparser-xpp3') testFixturesImplementation project(':smack-xmlparser-stax')
testCompile "org.jxmpp:jxmpp-jid:$jxmppVersion:tests" testFixturesImplementation project(':smack-xmlparser-xpp3')
testCompile "org.xmlunit:xmlunit-core:$xmlUnitVersion"
// 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"
// Explictily add assertj-core which is a dependency of // Explictily add assertj-core which is a dependency of
// xmlunit-assertj, but gradle fails to resolves it with: // xmlunit-assertj, but gradle fails to resolves it with:
// Execution failed for task ':smack-core:compileTestJava'. // Execution failed for task ':smack-core:compileTestJava'.
@ -21,12 +30,9 @@ dependencies {
// > Could not find org.assertj:assertj-core:. // > Could not find org.assertj:assertj-core:.
// Required by: // Required by:
// project :smack-core > org.xmlunit:xmlunit-assertj:2.6.2 // project :smack-core > org.xmlunit:xmlunit-assertj:2.6.2
testCompile "org.assertj:assertj-core:3.11.1" testFixturesApi "org.assertj:assertj-core:3.11.1"
testCompile "org.xmlunit:xmlunit-assertj:$xmlUnitVersion" testFixturesApi "org.xmlunit:xmlunit-assertj:$xmlUnitVersion"
testCompile 'com.jamesmurty.utils:java-xmlbuilder:1.2' testFixturesApi 'org.hamcrest:hamcrest-library:2.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 { class CreateFileTask extends DefaultTask {

View file

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

View file

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

View file

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

View file

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

View file

@ -0,0 +1,44 @@
/**
*
* 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,5 +6,4 @@ Connect your favourite slf4j backend of choice to get output inside of it"""
dependencies { dependencies {
compile project(':smack-core') compile project(':smack-core')
compile 'org.slf4j:slf4j-api:[1.7,1.8)' compile 'org.slf4j:slf4j-api:[1.7,1.8)'
testCompile project(path: ":smack-core", configuration: "testRuntime")
} }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -32,6 +32,7 @@ import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.StanzaBuilder; import org.jivesoftware.smack.packet.StanzaBuilder;
import org.jivesoftware.smack.test.util.Whitebox;
import org.jivesoftware.smack.util.stringencoder.Base64; import org.jivesoftware.smack.util.stringencoder.Base64;
import org.jivesoftware.smackx.InitExtensions; import org.jivesoftware.smackx.InitExtensions;
@ -46,7 +47,6 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.jxmpp.jid.EntityFullJid; import org.jxmpp.jid.EntityFullJid;
import org.jxmpp.jid.JidTestUtil; import org.jxmpp.jid.JidTestUtil;
import org.powermock.reflect.Whitebox;
/** /**
* Test for InBandBytestreamSession. * Test for InBandBytestreamSession.
@ -262,7 +262,7 @@ public class InBandBytestreamSessionMessageTest extends InitExtensions {
InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream,
initiatorJID); initiatorJID);
InputStream inputStream = session.getInputStream(); InputStream inputStream = session.getInputStream();
StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class); StanzaListener listener = Whitebox.getInternalState(inputStream, "dataPacketListener", StanzaListener.class);
// build invalid packet with out of order sequence // build invalid packet with out of order sequence
String base64Data = Base64.encode("Data"); String base64Data = Base64.encode("Data");
@ -303,7 +303,7 @@ public class InBandBytestreamSessionMessageTest extends InitExtensions {
InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream,
initiatorJID); initiatorJID);
InputStream inputStream = session.getInputStream(); InputStream inputStream = session.getInputStream();
StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class); StanzaListener listener = Whitebox.getInternalState(inputStream, "dataPacketListener", StanzaListener.class);
// verify data packet and notify listener // verify data packet and notify listener
for (int i = 0; i < controlData.length / blockSize; i++) { for (int i = 0; i < controlData.length / blockSize; i++) {
@ -349,7 +349,7 @@ public class InBandBytestreamSessionMessageTest extends InitExtensions {
InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream,
initiatorJID); initiatorJID);
InputStream inputStream = session.getInputStream(); InputStream inputStream = session.getInputStream();
StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class); StanzaListener listener = Whitebox.getInternalState(inputStream, "dataPacketListener", StanzaListener.class);
// verify data packet and notify listener // verify data packet and notify listener
for (int i = 0; i < controlData.length / blockSize; i++) { for (int i = 0; i < controlData.length / blockSize; i++) {

View file

@ -31,6 +31,7 @@ import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.StanzaError; import org.jivesoftware.smack.packet.StanzaError;
import org.jivesoftware.smack.test.util.Whitebox;
import org.jivesoftware.smack.util.stringencoder.Base64; import org.jivesoftware.smack.util.stringencoder.Base64;
import org.jivesoftware.smackx.InitExtensions; import org.jivesoftware.smackx.InitExtensions;
@ -45,7 +46,6 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.jxmpp.jid.EntityFullJid; import org.jxmpp.jid.EntityFullJid;
import org.jxmpp.jid.JidTestUtil; import org.jxmpp.jid.JidTestUtil;
import org.powermock.reflect.Whitebox;
/** /**
* Test for InBandBytestreamSession. * Test for InBandBytestreamSession.
@ -309,7 +309,7 @@ public class InBandBytestreamSessionTest extends InitExtensions {
// insert data to read // insert data to read
InputStream inputStream = session.getInputStream(); InputStream inputStream = session.getInputStream();
StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class); StanzaListener listener = Whitebox.getInternalState(inputStream, "dataPacketListener", StanzaListener.class);
String base64Data = Base64.encode("Data"); String base64Data = Base64.encode("Data");
DataPacketExtension dpe = new DataPacketExtension(sessionID, 0, base64Data); DataPacketExtension dpe = new DataPacketExtension(sessionID, 0, base64Data);
Data data = new Data(dpe); Data data = new Data(dpe);
@ -343,7 +343,7 @@ public class InBandBytestreamSessionTest extends InitExtensions {
InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream,
initiatorJID); initiatorJID);
InputStream inputStream = session.getInputStream(); InputStream inputStream = session.getInputStream();
StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class); StanzaListener listener = Whitebox.getInternalState(inputStream, "dataPacketListener", StanzaListener.class);
String base64Data = Base64.encode("Data"); String base64Data = Base64.encode("Data");
DataPacketExtension dpe = new DataPacketExtension(sessionID, 0, base64Data); DataPacketExtension dpe = new DataPacketExtension(sessionID, 0, base64Data);
@ -381,7 +381,7 @@ public class InBandBytestreamSessionTest extends InitExtensions {
InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream,
initiatorJID); initiatorJID);
InputStream inputStream = session.getInputStream(); InputStream inputStream = session.getInputStream();
StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class); StanzaListener listener = Whitebox.getInternalState(inputStream, "dataPacketListener", StanzaListener.class);
// build data packets // build data packets
String base64Data = Base64.encode("Data"); String base64Data = Base64.encode("Data");
@ -420,7 +420,7 @@ public class InBandBytestreamSessionTest extends InitExtensions {
InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream,
initiatorJID); initiatorJID);
InputStream inputStream = session.getInputStream(); InputStream inputStream = session.getInputStream();
StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class); StanzaListener listener = Whitebox.getInternalState(inputStream, "dataPacketListener", StanzaListener.class);
// build data packets // build data packets
DataPacketExtension dpe = new DataPacketExtension(sessionID, 0, "AA=BB"); DataPacketExtension dpe = new DataPacketExtension(sessionID, 0, "AA=BB");
@ -454,7 +454,7 @@ public class InBandBytestreamSessionTest extends InitExtensions {
InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream,
initiatorJID); initiatorJID);
InputStream inputStream = session.getInputStream(); InputStream inputStream = session.getInputStream();
StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class); StanzaListener listener = Whitebox.getInternalState(inputStream, "dataPacketListener", StanzaListener.class);
// build invalid packet with out of order sequence // build invalid packet with out of order sequence
String base64Data = Base64.encode("Data"); String base64Data = Base64.encode("Data");
@ -495,7 +495,7 @@ public class InBandBytestreamSessionTest extends InitExtensions {
InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream,
initiatorJID); initiatorJID);
InputStream inputStream = session.getInputStream(); InputStream inputStream = session.getInputStream();
StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class); StanzaListener listener = Whitebox.getInternalState(inputStream, "dataPacketListener", StanzaListener.class);
// set data packet acknowledgment and notify listener // set data packet acknowledgment and notify listener
for (int i = 0; i < controlData.length / blockSize; i++) { for (int i = 0; i < controlData.length / blockSize; i++) {
@ -542,7 +542,7 @@ public class InBandBytestreamSessionTest extends InitExtensions {
InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream,
initiatorJID); initiatorJID);
InputStream inputStream = session.getInputStream(); InputStream inputStream = session.getInputStream();
StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class); StanzaListener listener = Whitebox.getInternalState(inputStream, "dataPacketListener", StanzaListener.class);
// set data packet acknowledgment and notify listener // set data packet acknowledgment and notify listener
for (int i = 0; i < controlData.length / blockSize; i++) { for (int i = 0; i < controlData.length / blockSize; i++) {
@ -583,7 +583,7 @@ public class InBandBytestreamSessionTest extends InitExtensions {
InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream,
initiatorJID); initiatorJID);
InputStream inputStream = session.getInputStream(); InputStream inputStream = session.getInputStream();
StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class); StanzaListener listener = Whitebox.getInternalState(inputStream, "dataPacketListener", StanzaListener.class);
// build data packet // build data packet
String base64Data = Base64.encode("Data"); String base64Data = Base64.encode("Data");
@ -626,7 +626,7 @@ public class InBandBytestreamSessionTest extends InitExtensions {
InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream, InBandBytestreamSession session = new InBandBytestreamSession(connection, initBytestream,
initiatorJID); initiatorJID);
final InputStream inputStream = session.getInputStream(); final InputStream inputStream = session.getInputStream();
StanzaListener listener = Whitebox.getInternalState(inputStream, StanzaListener.class); StanzaListener listener = Whitebox.getInternalState(inputStream, "dataPacketListener", StanzaListener.class);
// build data packet // build data packet
String base64Data = Base64.encode("Data"); String base64Data = Base64.encode("Data");

View file

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

View file

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

View file

@ -28,7 +28,7 @@ import java.net.Socket;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.util.NetworkUtil; import org.jivesoftware.smack.test.util.NetworkUtil;
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream.StreamHost; 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.io.IOException;
import java.net.ServerSocket; import java.net.ServerSocket;
import org.jivesoftware.smack.util.NetworkUtil; import org.jivesoftware.smack.test.util.NetworkUtil;
/** /**
* Simple SOCKS5 proxy for testing purposes. It is almost the same as the Socks5Proxy class but the * Simple SOCKS5 proxy for testing purposes. It is almost the same as the Socks5Proxy class but the

View file

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

View file

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

View file

@ -20,7 +20,7 @@ dependencies {
compile 'junit:junit:4.12' compile 'junit:junit:4.12'
// Add Junit 5 API for e.g. assertThrows() // Add Junit 5 API for e.g. assertThrows()
implementation "org.junit.jupiter:junit-jupiter-api:$junitVersion" implementation "org.junit.jupiter:junit-jupiter-api:$junitVersion"
testCompile project(path: ":smack-core", configuration: "testRuntime") testFixturesApi(testFixtures(project(":smack-core")))
testCompile "org.jxmpp:jxmpp-jid:$jxmppVersion:tests" testCompile "org.jxmpp:jxmpp-jid:$jxmppVersion:tests"
} }

View file

@ -15,7 +15,8 @@ dependencies {
api project(':smack-resolver-minidns-dox') api project(':smack-resolver-minidns-dox')
api project(':smack-tcp') api project(':smack-tcp')
testImplementation project(path: ":smack-core", configuration: "testRuntime") testImplementation 'com.google.guava:guava:28.2-jre'
testImplementation 'org.jgrapht:jgrapht-io:1.3.1'
} }
task printModularXmppClientToServerConnectionStateGraph(type: JavaExec) { task printModularXmppClientToServerConnectionStateGraph(type: JavaExec) {

View file

@ -7,5 +7,4 @@ dependencies {
compile project(':smack-extensions') compile project(':smack-extensions')
compile 'javax.media:jmf:2.1.1e' compile 'javax.media:jmf:2.1.1e'
compile files('libs/jspeex-0.9.7-jfcom.jar', 'libs/jstun.jar', 'libs/Speex.jar') compile files('libs/jspeex-0.9.7-jfcom.jar', 'libs/jstun.jar', 'libs/Speex.jar')
testCompile project(path: ":smack-core", configuration: "testRuntime")
} }

View file

@ -6,5 +6,6 @@ Usually XEPs in the state 'retracted', 'rejected', 'deprecated',
dependencies { dependencies {
compile project(':smack-core') compile project(':smack-core')
compile project(':smack-extensions') compile project(':smack-extensions')
testCompile project(path: ":smack-core", configuration: "testRuntime")
testFixturesApi(testFixtures(project(":smack-core")))
} }

View file

@ -8,6 +8,6 @@ dependencies {
compile project(":smack-omemo") compile project(":smack-omemo")
compile 'org.whispersystems:signal-protocol-java:2.6.2' compile 'org.whispersystems:signal-protocol-java:2.6.2'
testCompile project(path: ":smack-core", configuration: "testRuntime") testFixturesApi(testFixtures(project(":smack-core")))
testCompile project(path: ":smack-omemo", configuration: "testRuntime") testCompile project(path: ":smack-omemo", configuration: "testRuntime")
} }

View file

@ -7,5 +7,5 @@ dependencies {
compile project(":smack-extensions") compile project(":smack-extensions")
compile project(":smack-experimental") compile project(":smack-experimental")
testCompile project(path: ":smack-core", configuration: "testRuntime") testFixturesApi(testFixtures(project(":smack-core")))
} }

View file

@ -10,6 +10,6 @@ dependencies {
compile 'org.pgpainless:pgpainless-core:0.0.1-alpha7' compile 'org.pgpainless:pgpainless-core:0.0.1-alpha7'
testCompile project(path: ":smack-core", configuration: "testRuntime") testFixturesApi(testFixtures(project(":smack-core")))
testCompile group: 'commons-io', name: 'commons-io', version: "$commonsIoVersion" testCompile group: 'commons-io', name: 'commons-io', version: "$commonsIoVersion"
} }

View file

@ -17,8 +17,6 @@ dependencies {
compile "org.scala-lang:scala-library:$scalaVersion" compile "org.scala-lang:scala-library:$scalaVersion"
compile "com.lihaoyi:ammonite_$scalaVersion:1.3.2" compile "com.lihaoyi:ammonite_$scalaVersion:1.3.2"
testCompile project(path: ":smack-core", configuration: "testRuntime")
} }
scalaStyle { scalaStyle {

View file

@ -4,5 +4,4 @@ DNS over XMPP (DoX) support using MiniDNS."""
dependencies { dependencies {
compile project(path: ':smack-resolver-minidns') compile project(path: ':smack-resolver-minidns')
compile project(path: ':smack-experimental') compile project(path: ':smack-experimental')
testCompile project(path: ":smack-core", configuration: "testRuntime")
} }

View file

@ -4,5 +4,6 @@ Use javax.security.sasl for SASL."""
dependencies { dependencies {
compile project(':smack-core') compile project(':smack-core')
testCompile project(path: ":smack-core", configuration: "testRuntime")
testFixturesApi(testFixtures(project(":smack-core")))
} }

View file

@ -4,5 +4,6 @@ Use Smack provided code for SASL."""
dependencies { dependencies {
compile project(':smack-core') compile project(':smack-core')
testCompile project(path: ":smack-core", configuration: "testRuntime")
testFixturesApi(testFixtures(project(":smack-core")))
} }

View file

@ -3,5 +3,6 @@ Smack for standard XMPP connections over TCP."""
dependencies { dependencies {
compile project(':smack-core') compile project(':smack-core')
testCompile project(path: ":smack-core", configuration: "testRuntime")
testFixturesApi(testFixtures(project(":smack-core")))
} }

View file

@ -3,5 +3,5 @@ Smack XML parser using Stax."""
dependencies { dependencies {
compile project(':smack-xmlparser') compile project(':smack-xmlparser')
testCompile project(path: ":smack-xmlparser", configuration: "testRuntime") //testCompile project(path: ":smack-xmlparser", configuration: "testRuntime")
} }

View file

@ -9,5 +9,5 @@ dependencies {
api "xpp3:xpp3_min:$xpp3Version" api "xpp3:xpp3_min:$xpp3Version"
implementation "xpp3:xpp3:$xpp3Version" implementation "xpp3:xpp3:$xpp3Version"
api project(':smack-xmlparser') api project(':smack-xmlparser')
testCompile project(path: ":smack-xmlparser", configuration: "testRuntime") //testCompile project(path: ":smack-xmlparser", configuration: "testRuntime")
} }