1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-29 17:52:06 +01:00

Create low-level inttest accounts with test run ID

This commit is contained in:
Florian Schmaus 2016-12-19 18:10:04 +01:00
parent 26b16665e5
commit 814cc1fdde
8 changed files with 31 additions and 28 deletions

View file

@ -29,6 +29,8 @@ import eu.geekplace.javapinning.java7.Java7Pinning;
public abstract class AbstractSmackLowLevelIntegrationTest extends AbstractSmackIntTest { public abstract class AbstractSmackLowLevelIntegrationTest extends AbstractSmackIntTest {
private final SmackIntegrationTestEnvironment environment;
/** /**
* The configuration * The configuration
*/ */
@ -38,9 +40,10 @@ public abstract class AbstractSmackLowLevelIntegrationTest extends AbstractSmack
protected final DomainBareJid service; protected final DomainBareJid service;
public AbstractSmackLowLevelIntegrationTest(Configuration configuration, String testRunId) { public AbstractSmackLowLevelIntegrationTest(SmackIntegrationTestEnvironment environment) {
this.configuration = configuration; this.environment = environment;
this.testRunId = testRunId; this.configuration = environment.configuration;
this.testRunId = environment.testRunId;
this.service = configuration.service; this.service = configuration.service;
} }
@ -56,7 +59,7 @@ public abstract class AbstractSmackLowLevelIntegrationTest extends AbstractSmack
} }
protected void performCheck(ConnectionCallback callback) throws Exception { protected void performCheck(ConnectionCallback callback) throws Exception {
XMPPTCPConnection connection = SmackIntegrationTestFramework.getConnectedConnection(configuration); XMPPTCPConnection connection = SmackIntegrationTestFramework.getConnectedConnection(environment, -1);
try { try {
callback.connectionCallback(connection); callback.connectionCallback(connection);
} finally { } finally {

View file

@ -44,8 +44,9 @@ public class IntTestUtil {
private static final Logger LOGGER = Logger.getLogger(IntTestUtil.class.getName()); private static final Logger LOGGER = Logger.getLogger(IntTestUtil.class.getName());
public static UsernameAndPassword registerAccount(XMPPTCPConnection connection, Configuration config) throws InterruptedException, XMPPException, SmackException, IOException { public static UsernameAndPassword registerAccount(XMPPTCPConnection connection, SmackIntegrationTestEnvironment environment, int connectionId) throws InterruptedException, XMPPException, SmackException, IOException {
return registerAccount(connection, StringUtils.insecureRandomString(12), StringUtils.insecureRandomString(12), config); String username = "sinttest-" + environment.testRunId + "-" + connectionId;
return registerAccount(connection, username, StringUtils.insecureRandomString(12), environment.configuration);
} }
public static UsernameAndPassword registerAccount(XMPPTCPConnection connection, String accountUsername, String accountPassword, public static UsernameAndPassword registerAccount(XMPPTCPConnection connection, String accountUsername, String accountPassword,

View file

@ -290,7 +290,7 @@ public class SmackIntegrationTestFramework {
Constructor<? extends AbstractSmackLowLevelIntegrationTest> cons; Constructor<? extends AbstractSmackLowLevelIntegrationTest> cons;
try { try {
cons = ((Class<? extends AbstractSmackLowLevelIntegrationTest>) testClass).getConstructor( cons = ((Class<? extends AbstractSmackLowLevelIntegrationTest>) testClass).getConstructor(
Configuration.class, String.class); SmackIntegrationTestEnvironment.class);
} }
catch (NoSuchMethodException | SecurityException e) { catch (NoSuchMethodException | SecurityException e) {
LOGGER.log(Level.WARNING, LOGGER.log(Level.WARNING,
@ -300,7 +300,7 @@ public class SmackIntegrationTestFramework {
} }
try { try {
test = cons.newInstance(config, testRunResult.testRunId); test = cons.newInstance(environment);
} }
catch (InvocationTargetException e) { catch (InvocationTargetException e) {
Throwable cause = e.getCause(); Throwable cause = e.getCause();
@ -442,7 +442,7 @@ public class SmackIntegrationTestFramework {
} }
connections = new XMPPTCPConnection[numberOfConnections]; connections = new XMPPTCPConnection[numberOfConnections];
for (int i = 0; i < numberOfConnections; ++i) { for (int i = 0; i < numberOfConnections; ++i) {
connections[i] = getConnectedConnection(config); connections[i] = getConnectedConnection(environment, i);
} }
} }
catch (Exception e) { catch (Exception e) {
@ -563,9 +563,10 @@ public class SmackIntegrationTestFramework {
return connection; return connection;
} }
static XMPPTCPConnection getConnectedConnection(Configuration config) static XMPPTCPConnection getConnectedConnection(SmackIntegrationTestEnvironment environment, int connectionId)
throws KeyManagementException, NoSuchAlgorithmException, InterruptedException, throws KeyManagementException, NoSuchAlgorithmException, InterruptedException,
SmackException, IOException, XMPPException { SmackException, IOException, XMPPException {
Configuration config = environment.configuration;
XMPPTCPConnectionConfiguration.Builder builder = XMPPTCPConnectionConfiguration.builder(); XMPPTCPConnectionConfiguration.Builder builder = XMPPTCPConnectionConfiguration.builder();
if (config.serviceTlsPin != null) { if (config.serviceTlsPin != null) {
SSLContext sc = Java7Pinning.forPin(config.serviceTlsPin); SSLContext sc = Java7Pinning.forPin(config.serviceTlsPin);
@ -575,7 +576,7 @@ public class SmackIntegrationTestFramework {
builder.setXmppDomain(config.service); builder.setXmppDomain(config.service);
XMPPTCPConnection connection = new XMPPTCPConnection(builder.build()); XMPPTCPConnection connection = new XMPPTCPConnection(builder.build());
connection.connect(); connection.connect();
UsernameAndPassword uap = IntTestUtil.registerAccount(connection, config); UsernameAndPassword uap = IntTestUtil.registerAccount(connection, environment, connectionId);
connection.login(uap.username, uap.password); connection.login(uap.username, uap.password);
return connection; return connection;
} }

View file

@ -24,8 +24,8 @@ import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import org.igniterealtime.smack.inttest.AbstractSmackLowLevelIntegrationTest; import org.igniterealtime.smack.inttest.AbstractSmackLowLevelIntegrationTest;
import org.igniterealtime.smack.inttest.Configuration;
import org.igniterealtime.smack.inttest.SmackIntegrationTest; import org.igniterealtime.smack.inttest.SmackIntegrationTest;
import org.igniterealtime.smack.inttest.SmackIntegrationTestEnvironment;
import org.jivesoftware.smack.sasl.SASLError; import org.jivesoftware.smack.sasl.SASLError;
import org.jivesoftware.smack.sasl.SASLErrorException; import org.jivesoftware.smack.sasl.SASLErrorException;
import org.jivesoftware.smack.tcp.XMPPTCPConnection; import org.jivesoftware.smack.tcp.XMPPTCPConnection;
@ -34,8 +34,8 @@ import org.jivesoftware.smack.util.StringUtils;
public class LoginIntegrationTest extends AbstractSmackLowLevelIntegrationTest { public class LoginIntegrationTest extends AbstractSmackLowLevelIntegrationTest {
public LoginIntegrationTest(Configuration configuration, String testRunId) { public LoginIntegrationTest(SmackIntegrationTestEnvironment environment) {
super(configuration, testRunId); super(environment);
} }
/** /**

View file

@ -22,8 +22,8 @@ import static org.junit.Assert.assertNotNull;
import java.io.IOException; import java.io.IOException;
import org.igniterealtime.smack.inttest.AbstractSmackLowLevelIntegrationTest; import org.igniterealtime.smack.inttest.AbstractSmackLowLevelIntegrationTest;
import org.igniterealtime.smack.inttest.Configuration;
import org.igniterealtime.smack.inttest.SmackIntegrationTest; import org.igniterealtime.smack.inttest.SmackIntegrationTest;
import org.igniterealtime.smack.inttest.SmackIntegrationTestEnvironment;
import org.igniterealtime.smack.inttest.TestNotPossibleException; import org.igniterealtime.smack.inttest.TestNotPossibleException;
import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.filter.AndFilter; import org.jivesoftware.smack.filter.AndFilter;
@ -34,9 +34,8 @@ import org.jivesoftware.smack.tcp.XMPPTCPConnection;
public class StreamManagementTest extends AbstractSmackLowLevelIntegrationTest { public class StreamManagementTest extends AbstractSmackLowLevelIntegrationTest {
public StreamManagementTest(Configuration configuration, String testRunId) public StreamManagementTest(SmackIntegrationTestEnvironment environment) throws Exception {
throws Exception { super(environment);
super(configuration, testRunId);
performCheck(new ConnectionCallback() { performCheck(new ConnectionCallback() {
@Override @Override
public void connectionCallback(XMPPTCPConnection connection) throws Exception { public void connectionCallback(XMPPTCPConnection connection) throws Exception {

View file

@ -21,14 +21,14 @@ import static org.junit.Assert.assertTrue;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import org.igniterealtime.smack.inttest.AbstractSmackLowLevelIntegrationTest; import org.igniterealtime.smack.inttest.AbstractSmackLowLevelIntegrationTest;
import org.igniterealtime.smack.inttest.Configuration;
import org.igniterealtime.smack.inttest.SmackIntegrationTest; import org.igniterealtime.smack.inttest.SmackIntegrationTest;
import org.igniterealtime.smack.inttest.SmackIntegrationTestEnvironment;
import org.jivesoftware.smack.tcp.XMPPTCPConnection; import org.jivesoftware.smack.tcp.XMPPTCPConnection;
public class WaitForClosingStreamElementTest extends AbstractSmackLowLevelIntegrationTest { public class WaitForClosingStreamElementTest extends AbstractSmackLowLevelIntegrationTest {
public WaitForClosingStreamElementTest(Configuration configuration, String testRunId) { public WaitForClosingStreamElementTest(SmackIntegrationTestEnvironment environment) {
super(configuration, testRunId); super(environment);
} }
@SmackIntegrationTest @SmackIntegrationTest

View file

@ -20,8 +20,8 @@ package org.jivesoftware.smack.roster;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
import org.igniterealtime.smack.inttest.AbstractSmackLowLevelIntegrationTest; import org.igniterealtime.smack.inttest.AbstractSmackLowLevelIntegrationTest;
import org.igniterealtime.smack.inttest.Configuration;
import org.igniterealtime.smack.inttest.SmackIntegrationTest; import org.igniterealtime.smack.inttest.SmackIntegrationTest;
import org.igniterealtime.smack.inttest.SmackIntegrationTestEnvironment;
import org.igniterealtime.smack.inttest.util.SimpleResultSyncPoint; import org.igniterealtime.smack.inttest.util.SimpleResultSyncPoint;
import org.jivesoftware.smack.packet.Presence; import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.tcp.XMPPTCPConnection; import org.jivesoftware.smack.tcp.XMPPTCPConnection;
@ -29,8 +29,8 @@ import org.jxmpp.jid.FullJid;
public class LowLevelRosterIntegrationTest extends AbstractSmackLowLevelIntegrationTest { public class LowLevelRosterIntegrationTest extends AbstractSmackLowLevelIntegrationTest {
public LowLevelRosterIntegrationTest(Configuration configuration, String testRunId) { public LowLevelRosterIntegrationTest(SmackIntegrationTestEnvironment environment) {
super(configuration, testRunId); super(environment);
} }
@SmackIntegrationTest @SmackIntegrationTest

View file

@ -16,14 +16,13 @@
*/ */
package org.jivesoftware.smackx.muc; package org.jivesoftware.smackx.muc;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import java.io.IOException; import java.io.IOException;
import org.igniterealtime.smack.inttest.AbstractSmackLowLevelIntegrationTest; import org.igniterealtime.smack.inttest.AbstractSmackLowLevelIntegrationTest;
import org.igniterealtime.smack.inttest.Configuration;
import org.igniterealtime.smack.inttest.SmackIntegrationTest; import org.igniterealtime.smack.inttest.SmackIntegrationTest;
import org.igniterealtime.smack.inttest.SmackIntegrationTestEnvironment;
import org.igniterealtime.smack.inttest.TestNotPossibleException; import org.igniterealtime.smack.inttest.TestNotPossibleException;
import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
@ -39,8 +38,8 @@ import org.jxmpp.jid.parts.Resourcepart;
public class MultiUserChatLowLevelIntegrationTest extends AbstractSmackLowLevelIntegrationTest { public class MultiUserChatLowLevelIntegrationTest extends AbstractSmackLowLevelIntegrationTest {
public MultiUserChatLowLevelIntegrationTest(Configuration configuration, String testRunId) throws Exception { public MultiUserChatLowLevelIntegrationTest(SmackIntegrationTestEnvironment environment) throws Exception {
super(configuration, testRunId); super(environment);
performCheck(new ConnectionCallback() { performCheck(new ConnectionCallback() {
@Override @Override
public void connectionCallback(XMPPTCPConnection connection) throws Exception { public void connectionCallback(XMPPTCPConnection connection) throws Exception {