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

Create sinntest configuration to connection configuration method

This also fixes the bug that only low level integration tests handled
the debugger sinttest setting.
This commit is contained in:
Florian Schmaus 2018-05-09 18:10:11 +02:00
parent 96f75a1857
commit f4f072c4cb

View file

@ -559,16 +559,11 @@ public class SmackIntegrationTestFramework {
if (StringUtils.isNullOrEmpty(accountPassword)) { if (StringUtils.isNullOrEmpty(accountPassword)) {
accountPassword = StringUtils.insecureRandomString(16); accountPassword = StringUtils.insecureRandomString(16);
} }
// @formatter:off
Builder builder = XMPPTCPConnectionConfiguration.builder() Builder builder = getConnectionConfigurationBuilder(config);
.setXmppDomain(config.service) builder.setUsernameAndPassword(accountUsername, accountPassword)
.setUsernameAndPassword(accountUsername, accountPassword) .setResource(middlefix + '-' + testRunResult.testRunId);
.setResource(middlefix + '-' + testRunResult.testRunId)
.setSecurityMode(config.securityMode);
// @formatter:on
if (config.tlsContext != null) {
builder.setCustomSSLContext(config.tlsContext);
}
XMPPTCPConnection connection = new XMPPTCPConnection(builder.build()); XMPPTCPConnection connection = new XMPPTCPConnection(builder.build());
connection.connect(); connection.connect();
if (config.isAccountRegistrationPossible()) { if (config.isAccountRegistrationPossible()) {
@ -588,10 +583,7 @@ public class SmackIntegrationTestFramework {
return connection; return connection;
} }
static XMPPTCPConnection getConnectedConnection(SmackIntegrationTestEnvironment environment, int connectionId) static XMPPTCPConnectionConfiguration.Builder getConnectionConfigurationBuilder(Configuration config) {
throws KeyManagementException, NoSuchAlgorithmException, InterruptedException,
SmackException, IOException, XMPPException {
Configuration config = environment.configuration;
XMPPTCPConnectionConfiguration.Builder builder = XMPPTCPConnectionConfiguration.builder(); XMPPTCPConnectionConfiguration.Builder builder = XMPPTCPConnectionConfiguration.builder();
if (config.tlsContext != null) { if (config.tlsContext != null) {
builder.setCustomSSLContext(config.tlsContext); builder.setCustomSSLContext(config.tlsContext);
@ -611,6 +603,15 @@ public class SmackIntegrationTestFramework {
break; break;
} }
return builder;
}
static XMPPTCPConnection getConnectedConnection(SmackIntegrationTestEnvironment environment, int connectionId)
throws KeyManagementException, NoSuchAlgorithmException, InterruptedException,
SmackException, IOException, XMPPException {
Configuration config = environment.configuration;
XMPPTCPConnectionConfiguration.Builder builder = getConnectionConfigurationBuilder(config);
XMPPTCPConnection connection = new XMPPTCPConnection(builder.build()); XMPPTCPConnection connection = new XMPPTCPConnection(builder.build());
connection.connect(); connection.connect();
UsernameAndPassword uap = IntTestUtil.registerAccount(connection, environment, connectionId); UsernameAndPassword uap = IntTestUtil.registerAccount(connection, environment, connectionId);