mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-12-22 20:47:57 +01:00
Create low-level inttest accounts with test run ID
This commit is contained in:
parent
26b16665e5
commit
814cc1fdde
8 changed files with 31 additions and 28 deletions
|
@ -29,6 +29,8 @@ import eu.geekplace.javapinning.java7.Java7Pinning;
|
|||
|
||||
public abstract class AbstractSmackLowLevelIntegrationTest extends AbstractSmackIntTest {
|
||||
|
||||
private final SmackIntegrationTestEnvironment environment;
|
||||
|
||||
/**
|
||||
* The configuration
|
||||
*/
|
||||
|
@ -38,9 +40,10 @@ public abstract class AbstractSmackLowLevelIntegrationTest extends AbstractSmack
|
|||
|
||||
protected final DomainBareJid service;
|
||||
|
||||
public AbstractSmackLowLevelIntegrationTest(Configuration configuration, String testRunId) {
|
||||
this.configuration = configuration;
|
||||
this.testRunId = testRunId;
|
||||
public AbstractSmackLowLevelIntegrationTest(SmackIntegrationTestEnvironment environment) {
|
||||
this.environment = environment;
|
||||
this.configuration = environment.configuration;
|
||||
this.testRunId = environment.testRunId;
|
||||
this.service = configuration.service;
|
||||
}
|
||||
|
||||
|
@ -56,7 +59,7 @@ public abstract class AbstractSmackLowLevelIntegrationTest extends AbstractSmack
|
|||
}
|
||||
|
||||
protected void performCheck(ConnectionCallback callback) throws Exception {
|
||||
XMPPTCPConnection connection = SmackIntegrationTestFramework.getConnectedConnection(configuration);
|
||||
XMPPTCPConnection connection = SmackIntegrationTestFramework.getConnectedConnection(environment, -1);
|
||||
try {
|
||||
callback.connectionCallback(connection);
|
||||
} finally {
|
||||
|
|
|
@ -44,8 +44,9 @@ public class IntTestUtil {
|
|||
private static final Logger LOGGER = Logger.getLogger(IntTestUtil.class.getName());
|
||||
|
||||
|
||||
public static UsernameAndPassword registerAccount(XMPPTCPConnection connection, Configuration config) throws InterruptedException, XMPPException, SmackException, IOException {
|
||||
return registerAccount(connection, StringUtils.insecureRandomString(12), StringUtils.insecureRandomString(12), config);
|
||||
public static UsernameAndPassword registerAccount(XMPPTCPConnection connection, SmackIntegrationTestEnvironment environment, int connectionId) throws InterruptedException, XMPPException, SmackException, IOException {
|
||||
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,
|
||||
|
|
|
@ -290,7 +290,7 @@ public class SmackIntegrationTestFramework {
|
|||
Constructor<? extends AbstractSmackLowLevelIntegrationTest> cons;
|
||||
try {
|
||||
cons = ((Class<? extends AbstractSmackLowLevelIntegrationTest>) testClass).getConstructor(
|
||||
Configuration.class, String.class);
|
||||
SmackIntegrationTestEnvironment.class);
|
||||
}
|
||||
catch (NoSuchMethodException | SecurityException e) {
|
||||
LOGGER.log(Level.WARNING,
|
||||
|
@ -300,7 +300,7 @@ public class SmackIntegrationTestFramework {
|
|||
}
|
||||
|
||||
try {
|
||||
test = cons.newInstance(config, testRunResult.testRunId);
|
||||
test = cons.newInstance(environment);
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
Throwable cause = e.getCause();
|
||||
|
@ -442,7 +442,7 @@ public class SmackIntegrationTestFramework {
|
|||
}
|
||||
connections = new XMPPTCPConnection[numberOfConnections];
|
||||
for (int i = 0; i < numberOfConnections; ++i) {
|
||||
connections[i] = getConnectedConnection(config);
|
||||
connections[i] = getConnectedConnection(environment, i);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
@ -563,9 +563,10 @@ public class SmackIntegrationTestFramework {
|
|||
return connection;
|
||||
}
|
||||
|
||||
static XMPPTCPConnection getConnectedConnection(Configuration config)
|
||||
static XMPPTCPConnection getConnectedConnection(SmackIntegrationTestEnvironment environment, int connectionId)
|
||||
throws KeyManagementException, NoSuchAlgorithmException, InterruptedException,
|
||||
SmackException, IOException, XMPPException {
|
||||
Configuration config = environment.configuration;
|
||||
XMPPTCPConnectionConfiguration.Builder builder = XMPPTCPConnectionConfiguration.builder();
|
||||
if (config.serviceTlsPin != null) {
|
||||
SSLContext sc = Java7Pinning.forPin(config.serviceTlsPin);
|
||||
|
@ -575,7 +576,7 @@ public class SmackIntegrationTestFramework {
|
|||
builder.setXmppDomain(config.service);
|
||||
XMPPTCPConnection connection = new XMPPTCPConnection(builder.build());
|
||||
connection.connect();
|
||||
UsernameAndPassword uap = IntTestUtil.registerAccount(connection, config);
|
||||
UsernameAndPassword uap = IntTestUtil.registerAccount(connection, environment, connectionId);
|
||||
connection.login(uap.username, uap.password);
|
||||
return connection;
|
||||
}
|
||||
|
|
|
@ -24,8 +24,8 @@ import java.security.KeyManagementException;
|
|||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import org.igniterealtime.smack.inttest.AbstractSmackLowLevelIntegrationTest;
|
||||
import org.igniterealtime.smack.inttest.Configuration;
|
||||
import org.igniterealtime.smack.inttest.SmackIntegrationTest;
|
||||
import org.igniterealtime.smack.inttest.SmackIntegrationTestEnvironment;
|
||||
import org.jivesoftware.smack.sasl.SASLError;
|
||||
import org.jivesoftware.smack.sasl.SASLErrorException;
|
||||
import org.jivesoftware.smack.tcp.XMPPTCPConnection;
|
||||
|
@ -34,8 +34,8 @@ import org.jivesoftware.smack.util.StringUtils;
|
|||
|
||||
public class LoginIntegrationTest extends AbstractSmackLowLevelIntegrationTest {
|
||||
|
||||
public LoginIntegrationTest(Configuration configuration, String testRunId) {
|
||||
super(configuration, testRunId);
|
||||
public LoginIntegrationTest(SmackIntegrationTestEnvironment environment) {
|
||||
super(environment);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,8 +22,8 @@ import static org.junit.Assert.assertNotNull;
|
|||
import java.io.IOException;
|
||||
|
||||
import org.igniterealtime.smack.inttest.AbstractSmackLowLevelIntegrationTest;
|
||||
import org.igniterealtime.smack.inttest.Configuration;
|
||||
import org.igniterealtime.smack.inttest.SmackIntegrationTest;
|
||||
import org.igniterealtime.smack.inttest.SmackIntegrationTestEnvironment;
|
||||
import org.igniterealtime.smack.inttest.TestNotPossibleException;
|
||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
import org.jivesoftware.smack.filter.AndFilter;
|
||||
|
@ -34,9 +34,8 @@ import org.jivesoftware.smack.tcp.XMPPTCPConnection;
|
|||
|
||||
public class StreamManagementTest extends AbstractSmackLowLevelIntegrationTest {
|
||||
|
||||
public StreamManagementTest(Configuration configuration, String testRunId)
|
||||
throws Exception {
|
||||
super(configuration, testRunId);
|
||||
public StreamManagementTest(SmackIntegrationTestEnvironment environment) throws Exception {
|
||||
super(environment);
|
||||
performCheck(new ConnectionCallback() {
|
||||
@Override
|
||||
public void connectionCallback(XMPPTCPConnection connection) throws Exception {
|
||||
|
|
|
@ -21,14 +21,14 @@ import static org.junit.Assert.assertTrue;
|
|||
import java.lang.reflect.Field;
|
||||
|
||||
import org.igniterealtime.smack.inttest.AbstractSmackLowLevelIntegrationTest;
|
||||
import org.igniterealtime.smack.inttest.Configuration;
|
||||
import org.igniterealtime.smack.inttest.SmackIntegrationTest;
|
||||
import org.igniterealtime.smack.inttest.SmackIntegrationTestEnvironment;
|
||||
import org.jivesoftware.smack.tcp.XMPPTCPConnection;
|
||||
|
||||
public class WaitForClosingStreamElementTest extends AbstractSmackLowLevelIntegrationTest {
|
||||
|
||||
public WaitForClosingStreamElementTest(Configuration configuration, String testRunId) {
|
||||
super(configuration, testRunId);
|
||||
public WaitForClosingStreamElementTest(SmackIntegrationTestEnvironment environment) {
|
||||
super(environment);
|
||||
}
|
||||
|
||||
@SmackIntegrationTest
|
||||
|
|
|
@ -20,8 +20,8 @@ package org.jivesoftware.smack.roster;
|
|||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import org.igniterealtime.smack.inttest.AbstractSmackLowLevelIntegrationTest;
|
||||
import org.igniterealtime.smack.inttest.Configuration;
|
||||
import org.igniterealtime.smack.inttest.SmackIntegrationTest;
|
||||
import org.igniterealtime.smack.inttest.SmackIntegrationTestEnvironment;
|
||||
import org.igniterealtime.smack.inttest.util.SimpleResultSyncPoint;
|
||||
import org.jivesoftware.smack.packet.Presence;
|
||||
import org.jivesoftware.smack.tcp.XMPPTCPConnection;
|
||||
|
@ -29,8 +29,8 @@ import org.jxmpp.jid.FullJid;
|
|||
|
||||
public class LowLevelRosterIntegrationTest extends AbstractSmackLowLevelIntegrationTest {
|
||||
|
||||
public LowLevelRosterIntegrationTest(Configuration configuration, String testRunId) {
|
||||
super(configuration, testRunId);
|
||||
public LowLevelRosterIntegrationTest(SmackIntegrationTestEnvironment environment) {
|
||||
super(environment);
|
||||
}
|
||||
|
||||
@SmackIntegrationTest
|
||||
|
|
|
@ -16,14 +16,13 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.muc;
|
||||
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.igniterealtime.smack.inttest.AbstractSmackLowLevelIntegrationTest;
|
||||
import org.igniterealtime.smack.inttest.Configuration;
|
||||
import org.igniterealtime.smack.inttest.SmackIntegrationTest;
|
||||
import org.igniterealtime.smack.inttest.SmackIntegrationTestEnvironment;
|
||||
import org.igniterealtime.smack.inttest.TestNotPossibleException;
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
|
@ -39,8 +38,8 @@ import org.jxmpp.jid.parts.Resourcepart;
|
|||
|
||||
public class MultiUserChatLowLevelIntegrationTest extends AbstractSmackLowLevelIntegrationTest {
|
||||
|
||||
public MultiUserChatLowLevelIntegrationTest(Configuration configuration, String testRunId) throws Exception {
|
||||
super(configuration, testRunId);
|
||||
public MultiUserChatLowLevelIntegrationTest(SmackIntegrationTestEnvironment environment) throws Exception {
|
||||
super(environment);
|
||||
performCheck(new ConnectionCallback() {
|
||||
@Override
|
||||
public void connectionCallback(XMPPTCPConnection connection) throws Exception {
|
||||
|
|
Loading…
Reference in a new issue