Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2007-03-18 20:42:30 -0400
committerslewis2007-03-18 20:42:30 -0400
commit84b4e9e225125687c7471d4f337b44324ca96ccc (patch)
tree8f53f3af0f578cfad27c3885f094a4e15f200c03 /tests/bundles/org.eclipse.ecf.tests.presence
parentb520384c9b2e5475c9c164b8417fd19312d46e82 (diff)
downloadorg.eclipse.ecf-84b4e9e225125687c7471d4f337b44324ca96ccc.tar.gz
org.eclipse.ecf-84b4e9e225125687c7471d4f337b44324ca96ccc.tar.xz
org.eclipse.ecf-84b4e9e225125687c7471d4f337b44324ca96ccc.zip
Added to presence tests
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.java67
-rwxr-xr-xtests/bundles/org.eclipse.ecf.tests.presence/src/org/eclipse/ecf/tests/presence/PresenceContainerConnectTest.java60
2 files changed, 127 insertions, 0 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
new file mode 100755
index 000000000..94cee0bba
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.presence/src/org/eclipse/ecf/tests/presence/PresenceAbstractTestCase.java
@@ -0,0 +1,67 @@
+/****************************************************************************
+ * Copyright (c) 2004 Composent, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.ecf.tests.presence;
+
+import org.eclipse.ecf.core.IContainer;
+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;
+
+/**
+ *
+ */
+public abstract class PresenceAbstractTestCase extends ContainerAbstractTestCase {
+
+ static final String XMPP_CONTAINER = "ecf.xmpp.smack";
+
+ protected String getClientContainerName() {
+ return XMPP_CONTAINER;
+ }
+
+ protected void setUp() throws Exception {
+ setClientCount(2);
+ 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();
+ try {
+ return IDFactory.getDefault().createID(connectNamespace,username);
+ } catch (IDCreateException e) {
+ fail("Could not create server connect ID");
+ return null;
+ }
+ }
+
+ 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
new file mode 100755
index 000000000..951196409
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.presence/src/org/eclipse/ecf/tests/presence/PresenceContainerConnectTest.java
@@ -0,0 +1,60 @@
+/****************************************************************************
+ * Copyright (c) 2004 Composent, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+
+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];
+ assertNull(client.getConnectedID());
+ ID serverConnectID = getServerConnectID(client);
+ assertNotNull(serverConnectID);
+ IConnectContext connectContext = getConnectContext(client);
+ connectClient(client, serverConnectID, connectContext);
+ assertEquals(serverConnectID, client.getConnectedID());
+ sleep(3000);
+ 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());
+ sleep(3000);
+
+ clientone.disconnect();
+ assertNull(clientone.getConnectedID());
+ clienttwo.disconnect();
+ assertNull(clienttwo.getConnectedID());
+ }
+
+}

Back to the top