Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2007-02-13 19:49:22 -0500
committerslewis2007-02-13 19:49:22 -0500
commit52fa82320c141352c480fdb84ba589cdc23461db (patch)
treea67b58beb65c76900b04dcc8ac427caa22a9983f /tests/bundles/org.eclipse.ecf.tests.discovery
parent512aae66d65810a789ed3d9c994c0017efcb8d5a (diff)
downloadorg.eclipse.ecf-52fa82320c141352c480fdb84ba589cdc23461db.tar.gz
org.eclipse.ecf-52fa82320c141352c480fdb84ba589cdc23461db.tar.xz
org.eclipse.ecf-52fa82320c141352c480fdb84ba589cdc23461db.zip
Initial checkin of new project
Diffstat (limited to 'tests/bundles/org.eclipse.ecf.tests.discovery')
-rwxr-xr-xtests/bundles/org.eclipse.ecf.tests.discovery/.classpath7
-rwxr-xr-xtests/bundles/org.eclipse.ecf.tests.discovery/.cvsignore1
-rwxr-xr-xtests/bundles/org.eclipse.ecf.tests.discovery/.project28
-rwxr-xr-xtests/bundles/org.eclipse.ecf.tests.discovery/META-INF/MANIFEST.MF12
-rwxr-xr-xtests/bundles/org.eclipse.ecf.tests.discovery/build.properties4
-rwxr-xr-xtests/bundles/org.eclipse.ecf.tests.discovery/src/org/eclipse/ecf/tests/discovery/Activator.java50
-rwxr-xr-xtests/bundles/org.eclipse.ecf.tests.discovery/src/org/eclipse/ecf/tests/discovery/JMDNSDiscoveryTest.java106
7 files changed, 208 insertions, 0 deletions
diff --git a/tests/bundles/org.eclipse.ecf.tests.discovery/.classpath b/tests/bundles/org.eclipse.ecf.tests.discovery/.classpath
new file mode 100755
index 000000000..751c8f2e5
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.discovery/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/tests/bundles/org.eclipse.ecf.tests.discovery/.cvsignore b/tests/bundles/org.eclipse.ecf.tests.discovery/.cvsignore
new file mode 100755
index 000000000..ba077a403
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.discovery/.cvsignore
@@ -0,0 +1 @@
+bin
diff --git a/tests/bundles/org.eclipse.ecf.tests.discovery/.project b/tests/bundles/org.eclipse.ecf.tests.discovery/.project
new file mode 100755
index 000000000..3c4828639
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.discovery/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.ecf.tests.discovery</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/tests/bundles/org.eclipse.ecf.tests.discovery/META-INF/MANIFEST.MF b/tests/bundles/org.eclipse.ecf.tests.discovery/META-INF/MANIFEST.MF
new file mode 100755
index 000000000..4bb77870c
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.discovery/META-INF/MANIFEST.MF
@@ -0,0 +1,12 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Discovery Tests Plug-in
+Bundle-SymbolicName: org.eclipse.ecf.tests.discovery
+Bundle-Version: 1.0.0.20070212
+Bundle-Activator: org.eclipse.ecf.tests.discovery.Activator
+Bundle-Vendor: eclipse.org
+Require-Bundle: org.eclipse.core.runtime,
+ org.junit,
+ org.eclipse.ecf,
+ org.eclipse.ecf.discovery
+Eclipse-LazyStart: true
diff --git a/tests/bundles/org.eclipse.ecf.tests.discovery/build.properties b/tests/bundles/org.eclipse.ecf.tests.discovery/build.properties
new file mode 100755
index 000000000..34d2e4d2d
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.discovery/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/tests/bundles/org.eclipse.ecf.tests.discovery/src/org/eclipse/ecf/tests/discovery/Activator.java b/tests/bundles/org.eclipse.ecf.tests.discovery/src/org/eclipse/ecf/tests/discovery/Activator.java
new file mode 100755
index 000000000..f73dd5913
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.discovery/src/org/eclipse/ecf/tests/discovery/Activator.java
@@ -0,0 +1,50 @@
+package org.eclipse.ecf.tests.discovery;
+
+import org.eclipse.core.runtime.Plugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends Plugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.ecf.tests.discovery";
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/tests/bundles/org.eclipse.ecf.tests.discovery/src/org/eclipse/ecf/tests/discovery/JMDNSDiscoveryTest.java b/tests/bundles/org.eclipse.ecf.tests.discovery/src/org/eclipse/ecf/tests/discovery/JMDNSDiscoveryTest.java
new file mode 100755
index 000000000..d7a767cbd
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.discovery/src/org/eclipse/ecf/tests/discovery/JMDNSDiscoveryTest.java
@@ -0,0 +1,106 @@
+/****************************************************************************
+* 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.discovery;
+
+import java.net.InetAddress;
+import java.util.Properties;
+
+import junit.framework.TestCase;
+
+import org.eclipse.ecf.core.ContainerFactory;
+import org.eclipse.ecf.core.IContainer;
+import org.eclipse.ecf.discovery.IDiscoveryContainerAdapter;
+import org.eclipse.ecf.discovery.IServiceEvent;
+import org.eclipse.ecf.discovery.IServiceListener;
+import org.eclipse.ecf.discovery.IServiceTypeListener;
+import org.eclipse.ecf.discovery.ServiceInfo;
+import org.eclipse.ecf.discovery.ServiceProperties;
+import org.eclipse.ecf.discovery.identity.ServiceID;
+
+public class JMDNSDiscoveryTest extends TestCase {
+
+ static IContainer container = null;
+ static IDiscoveryContainerAdapter discoveryContainer = null;
+ static final String TEST_SERVICE_TYPE = "_ecftcp._tcp.local.";
+ static final String TEST_PROTOCOL = "ecftcp";
+ static final String TEST_HOST = "localhost";
+ static final int TEST_PORT = 3282;
+ static final String TEST_SERVICE_NAME = System.getProperty("user.name") + "." + TEST_PROTOCOL;
+
+ public void testContainerCreate() throws Exception {
+ container = ContainerFactory.getDefault().createContainer(
+ "ecf.discovery.jmdns");
+ assertNotNull(container);
+ }
+
+ public void testContainerConnect() throws Exception {
+ container.connect(null, null);
+ }
+ public void testDiscoveryContainerAdapter() throws Exception {
+ discoveryContainer = (IDiscoveryContainerAdapter) container
+ .getAdapter(IDiscoveryContainerAdapter.class);
+ assertNotNull(discoveryContainer);
+ }
+
+ public void testAddServiceTypeListener() throws Exception {
+ discoveryContainer
+ .addServiceTypeListener(new CollabServiceTypeListener());
+ }
+
+ public void testRegisterServiceType() throws Exception {
+ discoveryContainer.registerServiceType(TEST_SERVICE_TYPE);
+ System.out.println("registered service type "+TEST_SERVICE_TYPE+" waiting 5s");
+ Thread.sleep(5000);
+ }
+
+ public void testRegisterService() throws Exception {
+ Properties props = new Properties();
+ String protocol = TEST_PROTOCOL;
+ InetAddress host = InetAddress.getByName(TEST_HOST);
+ int port = TEST_PORT;
+ String svcName = System.getProperty("user.name") + "."
+ + protocol;
+ ServiceInfo svcInfo = new ServiceInfo(host, new ServiceID(
+ TEST_SERVICE_TYPE, svcName), port,
+ 0, 0, new ServiceProperties(props));
+ discoveryContainer.registerService(svcInfo);
+ }
+ public final void testDiscovery() throws Exception {
+
+ System.out.println("Discovery started. Waiting 10s for discovered services");
+ Thread.sleep(10000);
+ }
+
+ class CollabServiceTypeListener implements IServiceTypeListener {
+ public void serviceTypeAdded(IServiceEvent event) {
+ System.out.println("serviceTypeAdded(" + event + ")");
+ ServiceID svcID = event.getServiceInfo().getServiceID();
+ discoveryContainer.addServiceListener(svcID,
+ new CollabServiceListener());
+ discoveryContainer.registerServiceType(svcID);
+ }
+ }
+ class CollabServiceListener implements IServiceListener {
+ public void serviceAdded(IServiceEvent event) {
+ System.out.println("serviceAdded(" + event + ")");
+ discoveryContainer.requestServiceInfo(event.getServiceInfo()
+ .getServiceID(), 3000);
+ }
+ public void serviceRemoved(IServiceEvent event) {
+ System.out.println("serviceRemoved(" + event + ")");
+ }
+ public void serviceResolved(IServiceEvent event) {
+ System.out.println("serviceResolved(" + event + ")");
+ }
+ }
+
+}

Back to the top