Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkuppe2008-11-07 14:35:34 -0500
committermkuppe2008-11-07 14:35:34 -0500
commitff7ffd98d2b02033dc79f7cf7b8bfe9ce59d8fbf (patch)
tree7e12438d3299cdefd75202fded683d82986795b8
parentd64bbcec0967bcd4d8e6d7abf6b57b46cd904bed (diff)
downloadorg.eclipse.ecf-ff7ffd98d2b02033dc79f7cf7b8bfe9ce59d8fbf.tar.gz
org.eclipse.ecf-ff7ffd98d2b02033dc79f7cf7b8bfe9ce59d8fbf.tar.xz
org.eclipse.ecf-ff7ffd98d2b02033dc79f7cf7b8bfe9ce59d8fbf.zip
NEW - bug 236828: [Discovery] Composite container may register previously registered services with new providers
https://bugs.eclipse.org/bugs/show_bug.cgi?id=236828
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.provider.discovery/src/org/eclipse/ecf/tests/provider/discovery/CompositeDiscoveryContainerTest.java47
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.provider.discovery/src/org/eclipse/ecf/tests/provider/discovery/TestDiscoveryContainer.java133
2 files changed, 180 insertions, 0 deletions
diff --git a/tests/bundles/org.eclipse.ecf.tests.provider.discovery/src/org/eclipse/ecf/tests/provider/discovery/CompositeDiscoveryContainerTest.java b/tests/bundles/org.eclipse.ecf.tests.provider.discovery/src/org/eclipse/ecf/tests/provider/discovery/CompositeDiscoveryContainerTest.java
index 5c815eeb7..da1c8a208 100644
--- a/tests/bundles/org.eclipse.ecf.tests.provider.discovery/src/org/eclipse/ecf/tests/provider/discovery/CompositeDiscoveryContainerTest.java
+++ b/tests/bundles/org.eclipse.ecf.tests.provider.discovery/src/org/eclipse/ecf/tests/provider/discovery/CompositeDiscoveryContainerTest.java
@@ -10,12 +10,59 @@
******************************************************************************/
package org.eclipse.ecf.tests.provider.discovery;
+import java.util.List;
+
+import org.eclipse.ecf.core.util.ECFException;
+import org.eclipse.ecf.provider.discovery.CompositeDiscoveryContainer;
import org.eclipse.ecf.tests.discovery.DiscoveryTest;
public class CompositeDiscoveryContainerTest extends DiscoveryTest {
+ private TestDiscoveryContainer testDiscoveryContainer;
+
public CompositeDiscoveryContainerTest() {
super("ecf.discovery.*");
setComparator(new CompositeServiceInfoComporator());
}
+
+ /**
+ * Check if
+ */
+ public void testAddContainerWithRegisteredServices() {
+ try {
+ discoveryContainer.registerService(serviceInfo);
+ } catch (ECFException e) {
+ fail("Registering a service failed on a new IDCA");
+ }
+ CompositeDiscoveryContainer cdc = (CompositeDiscoveryContainer) discoveryContainer;
+ testDiscoveryContainer = new TestDiscoveryContainer();
+ assertTrue(cdc.addContainer(testDiscoveryContainer));
+ List registeredServices = testDiscoveryContainer.getRegisteredServices();
+ assertEquals("registerService(aService) wasn't called on TestDiscoveryContainer", serviceInfo, registeredServices.get(0));
+ }
+
+ public void testAddContainerWithoutRegisteredServices() {
+ try {
+ discoveryContainer.registerService(serviceInfo);
+ discoveryContainer.unregisterService(serviceInfo);
+ } catch (ECFException e) {
+ fail("Re-/Unregistering a service failed on a new IDCA");
+ }
+ CompositeDiscoveryContainer cdc = (CompositeDiscoveryContainer) discoveryContainer;
+ testDiscoveryContainer = new TestDiscoveryContainer();
+ assertTrue(cdc.addContainer(testDiscoveryContainer));
+ List registeredServices = testDiscoveryContainer.getRegisteredServices();
+ assertTrue(registeredServices.isEmpty());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.tests.discovery.DiscoveryTest#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ if(testDiscoveryContainer != null){
+ CompositeDiscoveryContainer cdc = (CompositeDiscoveryContainer) discoveryContainer;
+ assertTrue(cdc.removeContainer(testDiscoveryContainer));
+ }
+ super.tearDown();
+ }
}
diff --git a/tests/bundles/org.eclipse.ecf.tests.provider.discovery/src/org/eclipse/ecf/tests/provider/discovery/TestDiscoveryContainer.java b/tests/bundles/org.eclipse.ecf.tests.provider.discovery/src/org/eclipse/ecf/tests/provider/discovery/TestDiscoveryContainer.java
new file mode 100644
index 000000000..69fe91bbf
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.provider.discovery/src/org/eclipse/ecf/tests/provider/discovery/TestDiscoveryContainer.java
@@ -0,0 +1,133 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Versant Corp.
+ * 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:
+ * Markus Kuppe (mkuppe <at> versant <dot> com) - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.ecf.tests.provider.discovery;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.ecf.core.identity.Namespace;
+import org.eclipse.ecf.core.util.ECFException;
+import org.eclipse.ecf.discovery.IDiscoveryContainerAdapter;
+import org.eclipse.ecf.discovery.IServiceInfo;
+import org.eclipse.ecf.discovery.IServiceListener;
+import org.eclipse.ecf.discovery.IServiceTypeListener;
+import org.eclipse.ecf.discovery.identity.IServiceID;
+import org.eclipse.ecf.discovery.identity.IServiceTypeID;
+
+public class TestDiscoveryContainer implements IDiscoveryContainerAdapter {
+
+ private List services = new ArrayList();
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#addServiceListener(org.eclipse.ecf.discovery.IServiceListener)
+ */
+ public void addServiceListener(IServiceListener listener) {
+ throw new UnsupportedOperationException();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#addServiceListener(org.eclipse.ecf.discovery.identity.IServiceTypeID, org.eclipse.ecf.discovery.IServiceListener)
+ */
+ public void addServiceListener(IServiceTypeID type,
+ IServiceListener listener) {
+ throw new UnsupportedOperationException();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#addServiceTypeListener(org.eclipse.ecf.discovery.IServiceTypeListener)
+ */
+ public void addServiceTypeListener(IServiceTypeListener listener) {
+ throw new UnsupportedOperationException();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#getServiceInfo(org.eclipse.ecf.discovery.identity.IServiceID)
+ */
+ public IServiceInfo getServiceInfo(IServiceID service) {
+ throw new UnsupportedOperationException();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#getServiceTypes()
+ */
+ public IServiceTypeID[] getServiceTypes() {
+ throw new UnsupportedOperationException();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#getServices()
+ */
+ public IServiceInfo[] getServices() {
+ throw new UnsupportedOperationException();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#getServices(org.eclipse.ecf.discovery.identity.IServiceTypeID)
+ */
+ public IServiceInfo[] getServices(IServiceTypeID type) {
+ throw new UnsupportedOperationException();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#getServicesNamespace()
+ */
+ public Namespace getServicesNamespace() {
+ throw new UnsupportedOperationException();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#registerService(org.eclipse.ecf.discovery.IServiceInfo)
+ */
+ public void registerService(IServiceInfo serviceInfo) throws ECFException {
+ this.services.add(serviceInfo);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#removeServiceListener(org.eclipse.ecf.discovery.IServiceListener)
+ */
+ public void removeServiceListener(IServiceListener listener) {
+ throw new UnsupportedOperationException();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#removeServiceListener(org.eclipse.ecf.discovery.identity.IServiceTypeID, org.eclipse.ecf.discovery.IServiceListener)
+ */
+ public void removeServiceListener(IServiceTypeID type,
+ IServiceListener listener) {
+ throw new UnsupportedOperationException();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#removeServiceTypeListener(org.eclipse.ecf.discovery.IServiceTypeListener)
+ */
+ public void removeServiceTypeListener(IServiceTypeListener listener) {
+ throw new UnsupportedOperationException();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#unregisterService(org.eclipse.ecf.discovery.IServiceInfo)
+ */
+ public void unregisterService(IServiceInfo serviceInfo) throws ECFException {
+ this.services.remove(serviceInfo);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+ */
+ public Object getAdapter(Class adapter) {
+ throw new UnsupportedOperationException();
+ }
+
+ public List getRegisteredServices() {
+ return services;
+ }
+}

Back to the top