1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2025-12-06 05:01:12 +01:00

Initial cut of constructor re-factor (SMACK-184).

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@6532 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Matt Tucker 2007-01-04 23:00:58 +00:00 committed by matt
parent 3915eae215
commit 92d1de2dce
12 changed files with 81 additions and 292 deletions

View file

@ -107,6 +107,24 @@ public abstract class SmackTestCase extends TestCase {
return connections[index];
}
/**
* Creates a new XMPPConnection using the connection preferences. This is useful when
* not using a connection from the connection pool in a test case.
*
* @return a new XMPP connection.
*/
protected XMPPConnection createConnection() {
// Create the configuration for this new connection
ConnectionConfiguration config = new ConnectionConfiguration(host, port);
config.setTLSEnabled(true);
config.setCompressionEnabled(Boolean.getBoolean("test.compressionEnabled"));
config.setSASLAuthenticationEnabled(true);
if (getSocketFactory() == null) {
config.setSocketFactory(getSocketFactory());
}
return new XMPPConnection(config);
}
/**
* Returns the name of the user (e.g. johndoe) that is using the connection
* located at the requested position.
@ -183,17 +201,7 @@ public abstract class SmackTestCase extends TestCase {
try {
// Connect to the server
for (int i = 0; i < getMaxConnections(); i++) {
// Create the configuration for this new connection
ConnectionConfiguration config = new ConnectionConfiguration(host, port);
config.setTLSEnabled(true);
config.setCompressionEnabled(Boolean.getBoolean("test.compressionEnabled"));
config.setSASLAuthenticationEnabled(true);
if (getSocketFactory() == null) {
connections[i] = new XMPPConnection(config);
}
else {
connections[i] = new XMPPConnection(config, getSocketFactory());
}
connections[i] = createConnection();
connections[i].connect();
}
// Use the host name that the server reports. This is a good idea in most