Author: ngn
Date: Mon Aug 17 07:59:22 2009
New Revision: 804892
URL: http://svn.apache.org/viewvc?rev=804892&view=rev
Log:
Allow for multiple clients for integration tests
Modified:
mina/sandbox/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0199_xmppping/AbstractIntegrationTestCase.java
mina/sandbox/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0199_xmppping/XmppPingIntegrationTestCase.java
mina/sandbox/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0199_xmppping/XmppPingNoSupportIntegrationTestCase.java
Modified:
mina/sandbox/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0199_xmppping/AbstractIntegrationTestCase.java
URL:
http://svn.apache.org/viewvc/mina/sandbox/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0199_xmppping/AbstractIntegrationTestCase.java?rev=804892&r1=804891&r2=804892&view=diff
==============================================================================
---
mina/sandbox/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0199_xmppping/AbstractIntegrationTestCase.java
(original)
+++
mina/sandbox/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0199_xmppping/AbstractIntegrationTestCase.java
Mon Aug 17 07:59:22 2009
@@ -45,13 +45,17 @@
private final Logger logger =
LoggerFactory.getLogger(AbstractIntegrationTestCase.class);
protected static final String SERVER_DOMAIN = "vysper.org";
- protected static final String TEST_USERNAME = "[email protected]";
- protected static final String TEST_PASSWORD = "test";
+
+ protected static final String TEST_USERNAME1 = "[email protected]";
+ protected static final String TEST_PASSWORD1 = "password";
+ protected static final String TEST_USERNAME2 = "[email protected]";
+ protected static final String TEST_PASSWORD2 = "password";
private static final int DEFAULT_SERVER_PORT = 25222;
protected XMPPConnection client;
private XMPPServer server;
+ protected int port;
protected void addModules(XMPPServer server) {
// default, do nothing
@@ -59,18 +63,19 @@
@Override
protected void setUp() throws Exception {
- int port = findFreePort();
+ port = findFreePort();
startServer(port);
- connectClient(port);
+ client = connectClient(port, TEST_USERNAME1, TEST_PASSWORD1);
}
private void startServer(int port) throws Exception {
StorageProviderRegistry providerRegistry = new
MemoryStorageProviderRegistry();
AccountManagement accountManagement = (AccountManagement)
providerRegistry.retrieve(AccountManagement.class);
- accountManagement.addUser(TEST_USERNAME, TEST_PASSWORD);
+ accountManagement.addUser(TEST_USERNAME1, TEST_PASSWORD1);
+ accountManagement.addUser(TEST_USERNAME2, TEST_PASSWORD2);
server = new XMPPServer(SERVER_DOMAIN);
@@ -86,7 +91,7 @@
addModules(server);
}
- private void connectClient(int port) throws Exception {
+ protected XMPPConnection connectClient(int port, String username, String
password) throws Exception {
ConnectionConfiguration connectionConfiguration = new
ConnectionConfiguration("localhost", port);
connectionConfiguration.setCompressionEnabled(false);
connectionConfiguration.setSecurityMode(ConnectionConfiguration.SecurityMode.required);
@@ -94,11 +99,12 @@
connectionConfiguration.setDebuggerEnabled(false);
XMPPConnection.DEBUG_ENABLED = true;
- client = new XMPPConnection(connectionConfiguration);
+ XMPPConnection client = new XMPPConnection(connectionConfiguration);
client.connect();
- client.login(TEST_USERNAME, TEST_PASSWORD);
+ client.login(username, password);
+ return client;
}
protected Packet sendSync(XMPPConnection client, Packet request) {
Modified:
mina/sandbox/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0199_xmppping/XmppPingIntegrationTestCase.java
URL:
http://svn.apache.org/viewvc/mina/sandbox/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0199_xmppping/XmppPingIntegrationTestCase.java?rev=804892&r1=804891&r2=804892&view=diff
==============================================================================
---
mina/sandbox/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0199_xmppping/XmppPingIntegrationTestCase.java
(original)
+++
mina/sandbox/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0199_xmppping/XmppPingIntegrationTestCase.java
Mon Aug 17 07:59:22 2009
@@ -36,13 +36,13 @@
PingPacket pingRequest = new PingPacket();
pingRequest.setType(IQ.Type.GET);
pingRequest.setTo(SERVER_DOMAIN);
- pingRequest.setFrom(TEST_USERNAME);
+ pingRequest.setFrom(TEST_USERNAME1);
IQ result = (IQ)sendSync(client, pingRequest);
assertNotNull(result);
assertEquals(IQ.Type.RESULT, result.getType());
assertEquals(SERVER_DOMAIN, result.getFrom());
- assertEquals(TEST_USERNAME, result.getTo());
+ assertEquals(TEST_USERNAME1, result.getTo());
}
}
Modified:
mina/sandbox/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0199_xmppping/XmppPingNoSupportIntegrationTestCase.java
URL:
http://svn.apache.org/viewvc/mina/sandbox/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0199_xmppping/XmppPingNoSupportIntegrationTestCase.java?rev=804892&r1=804891&r2=804892&view=diff
==============================================================================
---
mina/sandbox/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0199_xmppping/XmppPingNoSupportIntegrationTestCase.java
(original)
+++
mina/sandbox/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/modules/extension/xep0199_xmppping/XmppPingNoSupportIntegrationTestCase.java
Mon Aug 17 07:59:22 2009
@@ -35,7 +35,7 @@
PingPacket pingRequest = new PingPacket();
pingRequest.setType(IQ.Type.GET);
pingRequest.setTo(SERVER_DOMAIN);
- pingRequest.setFrom(TEST_USERNAME);
+ pingRequest.setFrom(TEST_USERNAME1);
IQ result = (IQ)sendSync(client, pingRequest);
@@ -43,7 +43,7 @@
assertNotNull(result);
assertEquals(IQ.Type.ERROR, result.getType());
assertEquals(SERVER_DOMAIN, result.getFrom());
- assertEquals(TEST_USERNAME, result.getTo());
+ assertEquals(TEST_USERNAME1, result.getTo());
assertEquals("service-unavailable", result.getError().getCondition());
}
}