Skip to content

Commit

Permalink
Merge 73ed9d3 into f65cf45
Browse files Browse the repository at this point in the history
  • Loading branch information
guusdk committed Jan 19, 2023
2 parents f65cf45 + 73ed9d3 commit 796a848
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.List;

import org.jivesoftware.smack.AbstractXMPPConnection;
import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
Expand All @@ -40,13 +41,19 @@ public abstract class AbstractSmackLowLevelIntegrationTest extends AbstractSmack

protected final DomainBareJid service;

protected XmppConnectionDescriptor<? extends AbstractXMPPConnection, ? extends ConnectionConfiguration, ? extends ConnectionConfiguration.Builder<?, ?>> defaultConnectionDescriptor;

protected AbstractSmackLowLevelIntegrationTest(SmackIntegrationTestEnvironment environment) {
super(environment);
this.environment = environment;
this.configuration = environment.configuration;
this.service = configuration.service;
}

public void overrideDefaultConnectionDescriptor(XmppConnectionDescriptor<? extends AbstractXMPPConnection, ? extends ConnectionConfiguration, ? extends ConnectionConfiguration.Builder<?, ?>> defaultConnectionDescriptor) {
this.defaultConnectionDescriptor = defaultConnectionDescriptor;
}

protected AbstractXMPPConnection getConnectedConnection() throws InterruptedException, XMPPException, SmackException, IOException {
AbstractXMPPConnection connection = getUnconnectedConnection();
connection.connect().login();
Expand All @@ -55,7 +62,11 @@ protected AbstractXMPPConnection getConnectedConnection() throws InterruptedExce

protected AbstractXMPPConnection getUnconnectedConnection()
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
return environment.connectionManager.constructConnection();
if (defaultConnectionDescriptor == null) {
return environment.connectionManager.constructConnection();
} else {
return environment.connectionManager.constructConnection(defaultConnectionDescriptor);
}
}

protected List<AbstractXMPPConnection> getUnconnectedConnections(int count)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,7 @@ private void invoke(AbstractSmackLowLevelIntegrationTest test,
connectionCount = testMethod.getParameterCount();
}

test.overrideDefaultConnectionDescriptor(connectionDescriptor);
List<? extends AbstractXMPPConnection> connections = connectionManager.constructConnectedConnections(
connectionDescriptor, connectionCount);

Expand Down

0 comments on commit 796a848

Please sign in to comment.