Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorslewis2015-07-15 16:24:34 -0400
committerslewis2015-07-15 16:24:34 -0400
commit2d72f4ebceb0b7e679dbf7d6d375c0756c2af7f1 (patch)
tree0d0460fb4ec192d32ab064edb655eb33085f1e1e /tests
parente750f2f97a9f1c78dbf5b36676debc08972ec610 (diff)
downloadorg.eclipse.ecf-2d72f4ebceb0b7e679dbf7d6d375c0756c2af7f1.tar.gz
org.eclipse.ecf-2d72f4ebceb0b7e679dbf7d6d375c0756c2af7f1.tar.xz
org.eclipse.ecf-2d72f4ebceb0b7e679dbf7d6d375c0756c2af7f1.zip
Partial fix for enhancement
https://bugs.eclipse.org/bugs/show_bug.cgi?id=472772 Change-Id: Ic4bc4c51474efa51d0fc11b8d4d7b881ee66482d
Diffstat (limited to 'tests')
-rwxr-xr-xtests/bundles/org.eclipse.ecf.tests/META-INF/MANIFEST.MF2
-rw-r--r--tests/bundles/org.eclipse.ecf.tests/org.eclipse.ecf.tests.launch2
-rw-r--r--tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/SSLContainerAbstractTestCase.java24
-rw-r--r--tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/connect/SSLClientContainerConnectTest.java194
4 files changed, 220 insertions, 2 deletions
diff --git a/tests/bundles/org.eclipse.ecf.tests/META-INF/MANIFEST.MF b/tests/bundles/org.eclipse.ecf.tests/META-INF/MANIFEST.MF
index 5bb76b952..cd532883e 100755
--- a/tests/bundles/org.eclipse.ecf.tests/META-INF/MANIFEST.MF
+++ b/tests/bundles/org.eclipse.ecf.tests/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %plugin.name
Bundle-SymbolicName: org.eclipse.ecf.tests;singleton:=true
-Bundle-Version: 2.1.0.qualifier
+Bundle-Version: 2.2.0.qualifier
Bundle-Activator: org.eclipse.ecf.internal.tests.Activator
Bundle-Vendor: %plugin.provider
Bundle-Localization: plugin
diff --git a/tests/bundles/org.eclipse.ecf.tests/org.eclipse.ecf.tests.launch b/tests/bundles/org.eclipse.ecf.tests/org.eclipse.ecf.tests.launch
index 177df1c14..8cc0f06f1 100644
--- a/tests/bundles/org.eclipse.ecf.tests/org.eclipse.ecf.tests.launch
+++ b/tests/bundles/org.eclipse.ecf.tests/org.eclipse.ecf.tests.launch
@@ -30,7 +30,7 @@
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.ecf.tests"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
-<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m -Xmx512m"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m &#13;&#10;-Xmx512m&#13;&#10;-Djavax.net.ssl.keyStore=security/server.ks&#13;&#10;-Djavax.net.ssl.keyStorePassword=server&#13;&#10;-Djavax.net.ssl.trustStore=security/server.ks&#13;&#10;-Djavax.net.debug=all"/>
<stringAttribute key="pde.version" value="3.3"/>
<stringAttribute key="product" value="org.eclipse.sdk.ide"/>
<booleanAttribute key="run_in_ui_thread" value="true"/>
diff --git a/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/SSLContainerAbstractTestCase.java b/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/SSLContainerAbstractTestCase.java
new file mode 100644
index 000000000..8870ef4c1
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/SSLContainerAbstractTestCase.java
@@ -0,0 +1,24 @@
+/****************************************************************************
+ * Copyright (c) 2012 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;
+
+public abstract class SSLContainerAbstractTestCase extends ContainerAbstractTestCase {
+
+ protected void setUp() throws Exception {
+ genericServerName = "ecf.generic.ssl.server";
+ genericClientName = "ecf.generic.ssl.client";
+ genericServerPort = 40000;
+ genericServerIdentity = "ecfssl://localhost:{0}/secureserver";
+ super.setUp();
+ }
+
+}
diff --git a/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/connect/SSLClientContainerConnectTest.java b/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/connect/SSLClientContainerConnectTest.java
new file mode 100644
index 000000000..5a953ba75
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/connect/SSLClientContainerConnectTest.java
@@ -0,0 +1,194 @@
+/****************************************************************************
+ * 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.connect;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.ecf.core.IContainer;
+import org.eclipse.ecf.core.IContainerListener;
+import org.eclipse.ecf.core.events.IContainerConnectedEvent;
+import org.eclipse.ecf.core.events.IContainerConnectingEvent;
+import org.eclipse.ecf.core.events.IContainerDisconnectedEvent;
+import org.eclipse.ecf.core.events.IContainerDisconnectingEvent;
+import org.eclipse.ecf.core.events.IContainerEvent;
+import org.eclipse.ecf.core.security.IConnectContext;
+import org.eclipse.ecf.tests.SSLContainerAbstractTestCase;
+
+public class SSLClientContainerConnectTest extends SSLContainerAbstractTestCase {
+
+ List serverConnectEvents = new ArrayList();
+
+ List serverDisconnectEvents = new ArrayList();
+
+ List clientConnectingEvents = new ArrayList();
+
+ List clientConnectedEvents = new ArrayList();
+
+ List clientDisconnectingEvents = new ArrayList();
+
+ List clientDisconnectedEvents = new ArrayList();
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.tests.connect.ContainerConnectTestCase#createServerAndClients()
+ */
+ protected void createServerAndClients() throws Exception {
+ clientCount = 5;
+ super.createServerAndClients();
+ getServer().addListener(new IContainerListener() {
+ public void handleEvent(IContainerEvent event) {
+ if (event instanceof IContainerConnectedEvent)
+ serverConnectEvents.add(event);
+ if (event instanceof IContainerDisconnectedEvent)
+ serverDisconnectEvents.add(event);
+ }
+ });
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ createServerAndClients();
+ }
+
+ protected void clearClientEvents() {
+ clientConnectingEvents.clear();
+ clientConnectedEvents.clear();
+ clientDisconnectingEvents.clear();
+ clientDisconnectedEvents.clear();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ cleanUpServerAndClients();
+ super.tearDown();
+ serverConnectEvents.clear();
+ serverDisconnectEvents.clear();
+ clearClientEvents();
+ }
+
+ public void testConnectClients() throws Exception {
+ connectClients();
+ assertTrue(serverConnectEvents.size() == getClientCount());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.tests.ContainerAbstractTestCase#getConnectContext(int)
+ */
+ protected IConnectContext getConnectContext(int client) {
+ return null;
+ }
+
+ public void testClientsDisconnect() throws Exception {
+ connectClients();
+ assertTrue(serverConnectEvents.size() == getClientCount());
+ disconnectClients();
+ assertTrue(serverDisconnectEvents.size() == getClientCount());
+ }
+
+ public void testGetConnectedID() throws Exception {
+ final IContainer client = getClients()[0];
+ assertNull(client.getConnectedID());
+ client.connect(createServerID(), null);
+ assertNotNull(client.getConnectedID());
+ client.disconnect();
+ assertNull(client.getConnectedID());
+ }
+
+ protected IContainerListener createListener() {
+ return new IContainerListener() {
+
+ public void handleEvent(IContainerEvent event) {
+ if (event instanceof IContainerConnectingEvent)
+ clientConnectingEvents.add(event);
+ if (event instanceof IContainerConnectedEvent)
+ clientConnectedEvents.add(event);
+ if (event instanceof IContainerDisconnectingEvent)
+ clientDisconnectingEvents.add(event);
+ if (event instanceof IContainerDisconnectedEvent)
+ clientDisconnectedEvents.add(event);
+ }
+
+ };
+ }
+
+ public void testClientListener() throws Exception {
+ final IContainer client = getClients()[0];
+ client.addListener(createListener());
+ assertTrue(clientConnectingEvents.size() == 0);
+ assertTrue(clientConnectedEvents.size() == 0);
+ client.connect(createServerID(), null);
+ assertTrue(clientConnectingEvents.size() == 1);
+ assertTrue(clientConnectedEvents.size() == 1);
+ assertTrue(clientDisconnectingEvents.size() == 0);
+ assertTrue(clientDisconnectedEvents.size() == 0);
+ sleep(2000);
+ client.disconnect();
+ assertTrue(clientDisconnectingEvents.size() == 1);
+ assertTrue(clientDisconnectedEvents.size() == 1);
+ }
+
+ public void testListenerConnecting() throws Exception {
+ final IContainer client = getClients()[0];
+ client.addListener(createListener());
+ client.connect(createServerID(), null);
+ final Object o = clientConnectingEvents.get(0);
+ assertTrue(o instanceof IContainerConnectingEvent);
+ final IContainerConnectingEvent cco = (IContainerConnectingEvent) o;
+ assertTrue(cco.getLocalContainerID().equals(client.getID()));
+ assertTrue(cco.getTargetID().equals(createServerID()));
+ assertTrue(cco.getData() == null);
+ }
+
+ public void testListenerConnected() throws Exception {
+ final IContainer client = getClients()[0];
+ client.addListener(createListener());
+ client.connect(createServerID(), null);
+ final Object o = clientConnectedEvents.get(0);
+ assertTrue(o instanceof IContainerConnectedEvent);
+ final IContainerConnectedEvent cco = (IContainerConnectedEvent) o;
+ assertTrue(cco.getLocalContainerID().equals(client.getID()));
+ assertTrue(cco.getTargetID().equals(createServerID()));
+ }
+
+ public void testListenerDisconnected() throws Exception {
+ final IContainer client = getClients()[0];
+ client.addListener(createListener());
+ client.connect(createServerID(), null);
+ client.disconnect();
+ final Object o = clientDisconnectedEvents.get(0);
+ assertTrue(o instanceof IContainerDisconnectedEvent);
+ final IContainerDisconnectedEvent cco = (IContainerDisconnectedEvent) o;
+ assertTrue(cco.getLocalContainerID().equals(client.getID()));
+ assertTrue(cco.getTargetID().equals(createServerID()));
+ }
+
+ public void testRemoveListener() throws Exception {
+ final IContainer client = getClients()[0];
+ final IContainerListener l = createListener();
+ client.addListener(l);
+ client.removeListener(l);
+ client.connect(createServerID(), null);
+ assertTrue(clientConnectingEvents.size() == 0);
+ }
+
+}

Back to the top