Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2007-03-19 19:10:39 -0400
committerslewis2007-03-19 19:10:39 -0400
commit14537d0cdf8017a8db567ed3ac9283a9d93acb79 (patch)
treee180da91d94e7d4cd5c21f5f4bd2fd6375c82e49 /tests/bundles/org.eclipse.ecf.tests.presence
parenta7ca08517900bb31dc3da207f200a872cc71b3d8 (diff)
downloadorg.eclipse.ecf-14537d0cdf8017a8db567ed3ac9283a9d93acb79.tar.gz
org.eclipse.ecf-14537d0cdf8017a8db567ed3ac9283a9d93acb79.tar.xz
org.eclipse.ecf-14537d0cdf8017a8db567ed3ac9283a9d93acb79.zip
Generalized presence test cases and abstract class support code
Diffstat (limited to 'tests/bundles/org.eclipse.ecf.tests.presence')
-rwxr-xr-xtests/bundles/org.eclipse.ecf.tests.presence/src/org/eclipse/ecf/tests/presence/PresenceAbstractTestCase.java21
-rwxr-xr-xtests/bundles/org.eclipse.ecf.tests.presence/src/org/eclipse/ecf/tests/presence/PresenceContainerConnectTest.java54
2 files changed, 32 insertions, 43 deletions
diff --git a/tests/bundles/org.eclipse.ecf.tests.presence/src/org/eclipse/ecf/tests/presence/PresenceAbstractTestCase.java b/tests/bundles/org.eclipse.ecf.tests.presence/src/org/eclipse/ecf/tests/presence/PresenceAbstractTestCase.java
index 94cee0bba..4448e8dd4 100755
--- a/tests/bundles/org.eclipse.ecf.tests.presence/src/org/eclipse/ecf/tests/presence/PresenceAbstractTestCase.java
+++ b/tests/bundles/org.eclipse.ecf.tests.presence/src/org/eclipse/ecf/tests/presence/PresenceAbstractTestCase.java
@@ -16,7 +16,6 @@ import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.identity.IDCreateException;
import org.eclipse.ecf.core.identity.IDFactory;
import org.eclipse.ecf.core.identity.Namespace;
-import org.eclipse.ecf.core.security.IConnectContext;
import org.eclipse.ecf.presence.IPresenceContainerAdapter;
import org.eclipse.ecf.tests.ContainerAbstractTestCase;
@@ -36,17 +35,10 @@ public abstract class PresenceAbstractTestCase extends ContainerAbstractTestCase
clients = createClients();
}
- protected String getSecondUsername() {
- return System.getProperty("secondusername");
- }
-
- protected String getSecondPassword() {
- return System.getProperty("secondpassword");
- }
-
- protected ID getServerConnectID(IContainer client) {
- Namespace connectNamespace = client.getConnectNamespace();
- String username = (client.getID().equals(getClients()[0].getID()))?getUsername():getSecondUsername();
+ protected ID getServerConnectID(int client) {
+ IContainer container = getClient(client);
+ Namespace connectNamespace = container.getConnectNamespace();
+ String username = getUsername(client);
try {
return IDFactory.getDefault().createID(connectNamespace,username);
} catch (IDCreateException e) {
@@ -55,11 +47,6 @@ public abstract class PresenceAbstractTestCase extends ContainerAbstractTestCase
}
}
- protected IConnectContext getConnectContext(IContainer client) {
- String password = (client.getID().equals(getClients()[0].getID()))?getPassword():getSecondPassword();
- return createPasswordConnectContext(password);
- }
-
protected IPresenceContainerAdapter getPresenceAdapter() {
return (IPresenceContainerAdapter) getClients()[0].getAdapter(IPresenceContainerAdapter.class);
}
diff --git a/tests/bundles/org.eclipse.ecf.tests.presence/src/org/eclipse/ecf/tests/presence/PresenceContainerConnectTest.java b/tests/bundles/org.eclipse.ecf.tests.presence/src/org/eclipse/ecf/tests/presence/PresenceContainerConnectTest.java
index 951196409..6a6a74d04 100755
--- a/tests/bundles/org.eclipse.ecf.tests.presence/src/org/eclipse/ecf/tests/presence/PresenceContainerConnectTest.java
+++ b/tests/bundles/org.eclipse.ecf.tests.presence/src/org/eclipse/ecf/tests/presence/PresenceContainerConnectTest.java
@@ -13,48 +13,50 @@ package org.eclipse.ecf.tests.presence;
import org.eclipse.ecf.core.IContainer;
import org.eclipse.ecf.core.identity.ID;
-import org.eclipse.ecf.core.security.IConnectContext;
/**
*
*/
public class PresenceContainerConnectTest extends PresenceAbstractTestCase {
- public void testConnectClient() throws Exception {
- IContainer client = getClients()[0];
+ public static final int CLIENT_COUNT = 2;
+ public static final int WAITTIME= 3000;
+
+ protected void setUp() throws Exception {
+ setClientCount(CLIENT_COUNT);
+ clients = createClients();
+ }
+
+ public void testConnectOneClient() throws Exception {
+ int clientIndex = 0;
+ IContainer client = getClient(clientIndex);
assertNull(client.getConnectedID());
- ID serverConnectID = getServerConnectID(client);
+ ID serverConnectID = getServerConnectID(clientIndex);
assertNotNull(serverConnectID);
- IConnectContext connectContext = getConnectContext(client);
- connectClient(client, serverConnectID, connectContext);
+ connectClient(client, serverConnectID, getConnectContext(clientIndex));
assertEquals(serverConnectID, client.getConnectedID());
- sleep(3000);
+ sleep(WAITTIME);
client.disconnect();
assertNull(client.getConnectedID());
}
public void testConnectTwoClients() throws Exception {
- IContainer clientone = getClients()[0];
- assertNull(clientone.getConnectedID());
- ID serverConnectID = getServerConnectID(clientone);
- assertNotNull(serverConnectID);
- IConnectContext connectContext = getConnectContext(clientone);
- connectClient(clientone, serverConnectID, connectContext);
- assertEquals(serverConnectID, clientone.getConnectedID());
-
- IContainer clienttwo = getClients()[1];
- assertNull(clienttwo.getConnectedID());
- serverConnectID = getServerConnectID(clienttwo);
- assertNotNull(serverConnectID);
- connectContext = getConnectContext(clienttwo);
- connectClient(clienttwo, serverConnectID, connectContext);
- assertEquals(serverConnectID, clienttwo.getConnectedID());
+ for(int i=0; i < 2; i++) {
+ IContainer client = getClient(i);
+ assertNull(client.getConnectedID());
+ ID serverConnectID = getServerConnectID(i);
+ assertNotNull(serverConnectID);
+ connectClient(client, serverConnectID, getConnectContext(i));
+ assertEquals(serverConnectID, client.getConnectedID());
+ }
+
sleep(3000);
- clientone.disconnect();
- assertNull(clientone.getConnectedID());
- clienttwo.disconnect();
- assertNull(clienttwo.getConnectedID());
+ for(int i=0; i < 2; i++) {
+ IContainer client = getClient(i);
+ client.disconnect();
+ assertNull(client.getConnectedID());
+ }
}
}

Back to the top