Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkuppe2010-09-12 05:38:33 -0400
committermkuppe2010-09-12 05:38:33 -0400
commit8045b6584eba749247b681b2d22a4173106374cd (patch)
tree872e95d5478a8e5d4e92cb0f24f3614b175bef11
parenta507257003da972f418e54591b0dbd8aa237f87f (diff)
downloadorg.eclipse.ecf-8045b6584eba749247b681b2d22a4173106374cd.tar.gz
org.eclipse.ecf-8045b6584eba749247b681b2d22a4173106374cd.tar.xz
org.eclipse.ecf-8045b6584eba749247b681b2d22a4173106374cd.zip
RESOLVED - bug 319126: [RemoteSvcs] Wildcard causes IRemoteServiceContainerAdapter.registerRemoteService(String[], Object, Dictionary) to failI-Release_3_3-platform_feature-7-2010_09_13Release_3_3
https://bugs.eclipse.org/bugs/show_bug.cgi?id=319126
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.osgi.services.distribution/src/org/eclipse/ecf/tests/osgi/services/distribution/AbstractRemoteServiceAccessTest.java237
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.osgi.services.distribution/src/org/eclipse/ecf/tests/osgi/services/distribution/AbstractRemoteServiceRegisterTest.java70
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.osgi.services.distribution/src/org/eclipse/ecf/tests/osgi/services/distribution/AbstractServicePublicationTest.java36
3 files changed, 139 insertions, 204 deletions
diff --git a/tests/bundles/org.eclipse.ecf.tests.osgi.services.distribution/src/org/eclipse/ecf/tests/osgi/services/distribution/AbstractRemoteServiceAccessTest.java b/tests/bundles/org.eclipse.ecf.tests.osgi.services.distribution/src/org/eclipse/ecf/tests/osgi/services/distribution/AbstractRemoteServiceAccessTest.java
index db3037bb9..a307a8bb6 100644
--- a/tests/bundles/org.eclipse.ecf.tests.osgi.services.distribution/src/org/eclipse/ecf/tests/osgi/services/distribution/AbstractRemoteServiceAccessTest.java
+++ b/tests/bundles/org.eclipse.ecf.tests.osgi.services.distribution/src/org/eclipse/ecf/tests/osgi/services/distribution/AbstractRemoteServiceAccessTest.java
@@ -26,17 +26,50 @@ import org.osgi.util.tracker.ServiceTracker;
public abstract class AbstractRemoteServiceAccessTest extends
AbstractDistributionTest {
- private static final String TESTPROP1_VALUE = "baz";
- private static final String TESTPROP_VALUE = "foobar";
- private static final String TESTPROP1_NAME = "org.eclipse.ecf.testprop1";
- private static final String TESTPROP_NAME = "org.eclipse.ecf.testprop";
protected static final int REGISTER_WAIT = Integer.parseInt(System.getProperty("waittime","15000"));
+ private final String classname = TestServiceInterface1.class.getName();
+ private ServiceTracker st;
+ private ServiceRegistration registration;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.tests.osgi.services.distribution.AbstractDistributionTest#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ // Unregister on server
+ if (registration != null) {
+ registration.unregister();
+ registration = null;
+ }
+ if (st != null) {
+ st.close();
+ st = null;
+ }
+ Thread.sleep(REGISTER_WAIT);
+
+ super.tearDown();
+ }
+
+ protected void createServiceTrackerAndRegister(final Properties props) throws Exception {
+ // Setup service tracker for client
+ st = createProxyServiceTracker(classname);
+
+ // Actually register
+ registration = registerService(classname,
+ new TestService1(), props);
+
+ // Wait
+ Thread.sleep(REGISTER_WAIT);
+ }
+
+ protected void createServiceTrackerAndRegister() throws Exception {
+ createServiceTrackerAndRegister(getServiceProperties());
+ }
+
protected Properties getServiceProperties() {
- Properties props = new Properties();
+ final Properties props = new Properties();
props.put(SERVICE_EXPORTED_CONFIGS, getServerContainerName());
- props.put(SERVICE_EXPORTED_INTERFACES,
- new String[] { SERVICE_EXPORTED_INTERFACES_WILDCARD });
+ props.put(SERVICE_EXPORTED_INTERFACES, SERVICE_EXPORTED_INTERFACES_WILDCARD);
return props;
}
@@ -60,177 +93,113 @@ public abstract class AbstractRemoteServiceAccessTest extends
public void testGetRemoteServiceReference() throws Exception {
- String classname = TestServiceInterface1.class.getName();
- // Setup service tracker for client container
- ServiceTracker st = createProxyServiceTracker(classname);
- // Get service properties...and allow subclasses to override to add
- // other service properties
- Properties props = getServiceProperties();
- // Service Host: register service
- ServiceRegistration registration = registerService(classname,
- new TestService1(), props);
- // Wait
- Thread.sleep(REGISTER_WAIT);
-
+ createServiceTrackerAndRegister();
+
// Service Consumer - Get (remote) ervice references
- ServiceReference[] remoteReferences = st.getServiceReferences();
+ final ServiceReference[] remoteReferences = st.getServiceReferences();
assertReferencesValidAndFirstHasCorrectType(remoteReferences, classname);
// Spec requires that the 'service.imported' property be set
assertTrue(remoteReferences[0].getProperty(SERVICE_IMPORTED) != null);
-
- if (registration != null) registration.unregister();
- st.close();
- Thread.sleep(REGISTER_WAIT);
}
public void testGetRemoteServiceReferenceWithExtraProperties() throws Exception {
- String classname = TestServiceInterface1.class.getName();
- // Setup service tracker for client container
- ServiceTracker st = createProxyServiceTracker(classname);
- // Get service properties...and allow subclasses to override to add
- // other service properties
- Properties props = getServiceProperties();
+ final String TESTPROP1_VALUE = "baz";
+ final String TESTPROP_VALUE = "foobar";
+ final String TESTPROP1_NAME = "org.eclipse.ecf.testprop1";
+ final String TESTPROP_NAME = "org.eclipse.ecf.testprop";
+
+ final Properties props = getServiceProperties();
// Add other properties
props.put(TESTPROP_NAME, TESTPROP_VALUE);
props.put(TESTPROP1_NAME,TESTPROP1_VALUE);
- // Service Host: register service
- ServiceRegistration registration = registerService(classname,
- new TestService1(), props);
- // Wait
- Thread.sleep(REGISTER_WAIT);
+ createServiceTrackerAndRegister(props);
// Service Consumer - Get (remote) ervice references
- ServiceReference[] remoteReferences = st.getServiceReferences();
+ final ServiceReference[] remoteReferences = st.getServiceReferences();
assertReferencesValidAndFirstHasCorrectType(remoteReferences, classname);
// Spec requires that the 'service.imported' property be set
assertTrue(remoteReferences[0].getProperty(SERVICE_IMPORTED) != null);
- String testProp = (String) remoteReferences[0].getProperty(TESTPROP_NAME);
- String testProp1 = (String) remoteReferences[0].getProperty(TESTPROP1_NAME);
+ final String testProp = (String) remoteReferences[0].getProperty(TESTPROP_NAME);
+ final String testProp1 = (String) remoteReferences[0].getProperty(TESTPROP1_NAME);
assertTrue(TESTPROP_VALUE.equals(testProp));
assertTrue(TESTPROP1_VALUE.equals(testProp1));
- if (registration != null) registration.unregister();
- st.close();
- Thread.sleep(REGISTER_WAIT);
}
public void testProxy() throws Exception {
- String classname = TestServiceInterface1.class.getName();
- // Setup service tracker for client
- ServiceTracker st = createProxyServiceTracker(classname);
-
- // Actually register and wait a while
- ServiceRegistration registration = registerService(classname,
- new TestService1(), getServiceProperties());
- Thread.sleep(REGISTER_WAIT);
-
+ createServiceTrackerAndRegister();
+
// Client - Get service references from service tracker
- ServiceReference[] remoteReferences = st.getServiceReferences();
+ final ServiceReference[] remoteReferences = st.getServiceReferences();
assertReferencesValidAndFirstHasCorrectType(remoteReferences, classname);
// Get proxy/service
- TestServiceInterface1 proxy = (TestServiceInterface1) getContext()
+ final TestServiceInterface1 proxy = (TestServiceInterface1) getContext()
.getService(remoteReferences[0]);
assertNotNull(proxy);
// Now use proxy
- String result = proxy.doStuff1();
+ final String result = proxy.doStuff1();
Trace.trace(Activator.PLUGIN_ID, "proxy.doStuff1 result=" + result);
assertTrue(TestServiceInterface1.TEST_SERVICE_STRING1.equals(result));
-
- // Unregister on server and wait
- if (registration != null) registration.unregister();
- st.close();
- Thread.sleep(REGISTER_WAIT);
}
public void testCallSyncFromProxy() throws Exception {
- String classname = TestServiceInterface1.class.getName();
- // Setup service tracker for client
- ServiceTracker st = createProxyServiceTracker(classname);
-
- // Actually register and wait a while
- ServiceRegistration registration = registerService(classname,
- new TestService1(), getServiceProperties());
- Thread.sleep(REGISTER_WAIT);
-
+ createServiceTrackerAndRegister();
+
// Client - Get service references from service tracker
- ServiceReference[] remoteReferences = st.getServiceReferences();
+ final ServiceReference[] remoteReferences = st.getServiceReferences();
assertReferencesValidAndFirstHasCorrectType(remoteReferences, classname);
// Get proxy
- TestServiceInterface1 proxy = (TestServiceInterface1) getContext()
+ final TestServiceInterface1 proxy = (TestServiceInterface1) getContext()
.getService(remoteReferences[0]);
assertProxyValid(proxy);
// Get IRemoteService from proxy
- IRemoteService remoteService = getRemoteServiceFromProxy(proxy);
+ final IRemoteService remoteService = getRemoteServiceFromProxy(proxy);
// Call remote service synchronously
- Object result = remoteService.callSync(createRemoteCall());
+ final Object result = remoteService.callSync(createRemoteCall());
Trace.trace(Activator.PLUGIN_ID, "proxy.doStuff1 result=" + result);
assertStringResultValid(result, TestServiceInterface1.TEST_SERVICE_STRING1);
-
- // Unregister on server and wait
- if (registration != null) registration.unregister();
- st.close();
- Thread.sleep(REGISTER_WAIT);
}
public void testCallSync() throws Exception {
- String classname = TestServiceInterface1.class.getName();
- // Setup service tracker for client
- ServiceTracker st = createProxyServiceTracker(classname);
-
- // Actually register and wait a while
- ServiceRegistration registration = registerService(classname,
- new TestService1(), getServiceProperties());
- Thread.sleep(REGISTER_WAIT);
-
+ createServiceTrackerAndRegister();
+
// Client - Get service references from service tracker
- ServiceReference[] remoteReferences = st.getServiceReferences();
+ final ServiceReference[] remoteReferences = st.getServiceReferences();
assertReferencesValidAndFirstHasCorrectType(remoteReferences, classname);
- Object o = remoteReferences[0].getProperty(SERVICE_IMPORTED);
+ final Object o = remoteReferences[0].getProperty(SERVICE_IMPORTED);
assertNotNull(o);
assertTrue(o instanceof IRemoteService);
- IRemoteService rs = (IRemoteService) o;
+ final IRemoteService rs = (IRemoteService) o;
// Call synchronously
- Object result = rs.callSync(createRemoteCall());
+ final Object result = rs.callSync(createRemoteCall());
Trace.trace(Activator.PLUGIN_ID, "callSync.doStuff1 result=" + result);
assertStringResultValid(result, TestServiceInterface1.TEST_SERVICE_STRING1);
-
- // Unregister on server
- if (registration != null) registration.unregister();
- st.close();
- Thread.sleep(REGISTER_WAIT);
}
public void testCallAsync() throws Exception {
- String classname = TestServiceInterface1.class.getName();
- // Setup service tracker for client
- ServiceTracker st = createProxyServiceTracker(classname);
-
- // Actually register and wait a while
- ServiceRegistration registration = registerService(classname,
- new TestService1(), getServiceProperties());
- Thread.sleep(REGISTER_WAIT);
-
+ createServiceTrackerAndRegister();
+
// Client - Get service references from service tracker
- ServiceReference[] remoteReferences = st.getServiceReferences();
+ final ServiceReference[] remoteReferences = st.getServiceReferences();
assertReferencesValid(remoteReferences);
- Object o = remoteReferences[0].getProperty(SERVICE_IMPORTED);
+ final Object o = remoteReferences[0].getProperty(SERVICE_IMPORTED);
assertNotNull(o);
assertTrue(o instanceof IRemoteService);
- IRemoteService rs = (IRemoteService) o;
+ final IRemoteService rs = (IRemoteService) o;
// Call asynchronously
rs.callAsync(createRemoteCall(), new IRemoteCallListener() {
- public void handleEvent(IRemoteCallEvent event) {
+ public void handleEvent(final IRemoteCallEvent event) {
if (event instanceof IRemoteCallCompleteEvent) {
- Object result = ((IRemoteCallCompleteEvent) event)
+ final Object result = ((IRemoteCallCompleteEvent) event)
.getResponse();
Trace.trace(Activator.PLUGIN_ID,
"callSync.doStuff1 result=" + result);
@@ -241,69 +210,41 @@ public abstract class AbstractRemoteServiceAccessTest extends
});
syncWaitForNotify(REGISTER_WAIT);
- // Unregister on server
- registration.unregister();
- st.close();
- Thread.sleep(REGISTER_WAIT);
}
public void testCallFuture() throws Exception {
- String classname = TestServiceInterface1.class.getName();
- // Setup service tracker for client
- ServiceTracker st = createProxyServiceTracker(classname);
-
- // Actually register and wait a while
- ServiceRegistration registration = registerService(classname,
- new TestService1(), getServiceProperties());
- Thread.sleep(REGISTER_WAIT);
-
+ createServiceTrackerAndRegister();
+
// Client - Get service references from service tracker
- ServiceReference[] remoteReferences = st.getServiceReferences();
+ final ServiceReference[] remoteReferences = st.getServiceReferences();
assertReferencesValid(remoteReferences);
- Object o = remoteReferences[0].getProperty(SERVICE_IMPORTED);
+ final Object o = remoteReferences[0].getProperty(SERVICE_IMPORTED);
assertNotNull(o);
assertTrue(o instanceof IRemoteService);
- IRemoteService rs = (IRemoteService) o;
+ final IRemoteService rs = (IRemoteService) o;
// Call asynchronously
- IFuture futureResult = rs.callAsync(createRemoteCall());
+ final IFuture futureResult = rs.callAsync(createRemoteCall());
// now get result from futureResult
- Object result = futureResult.get();
+ final Object result = futureResult.get();
Trace.trace(Activator.PLUGIN_ID, "callSync.doStuff1 result=" + result);
assertStringResultValid(result, TestServiceInterface1.TEST_SERVICE_STRING1);
-
- // Unregister on server
- if (registration != null) registration.unregister();
- st.close();
- Thread.sleep(REGISTER_WAIT);
}
public void testFireAsync() throws Exception {
- String classname = TestServiceInterface1.class.getName();
- // Setup service tracker for client
- ServiceTracker st = createProxyServiceTracker(classname);
-
- // Actually register and wait a while
- ServiceRegistration registration = registerService(classname,
- new TestService1(), getServiceProperties());
- Thread.sleep(REGISTER_WAIT);
-
+ createServiceTrackerAndRegister();
+
// Client - Get service references from service tracker
- ServiceReference[] remoteReferences = st.getServiceReferences();
+ final ServiceReference[] remoteReferences = st.getServiceReferences();
assertReferencesValid(remoteReferences);
- Object o = remoteReferences[0].getProperty(SERVICE_IMPORTED);
+ final Object o = remoteReferences[0].getProperty(SERVICE_IMPORTED);
assertNotNull(o);
assertTrue(o instanceof IRemoteService);
- IRemoteService rs = (IRemoteService) o;
+ final IRemoteService rs = (IRemoteService) o;
// Call asynchronously
rs.fireAsync(createRemoteCall());
- Thread.sleep(5000);
- // Unregister on server
- if (registration != null) registration.unregister();
- st.close();
Thread.sleep(REGISTER_WAIT);
}
-
}
diff --git a/tests/bundles/org.eclipse.ecf.tests.osgi.services.distribution/src/org/eclipse/ecf/tests/osgi/services/distribution/AbstractRemoteServiceRegisterTest.java b/tests/bundles/org.eclipse.ecf.tests.osgi.services.distribution/src/org/eclipse/ecf/tests/osgi/services/distribution/AbstractRemoteServiceRegisterTest.java
index e353d65c7..fba70b723 100644
--- a/tests/bundles/org.eclipse.ecf.tests.osgi.services.distribution/src/org/eclipse/ecf/tests/osgi/services/distribution/AbstractRemoteServiceRegisterTest.java
+++ b/tests/bundles/org.eclipse.ecf.tests.osgi.services.distribution/src/org/eclipse/ecf/tests/osgi/services/distribution/AbstractRemoteServiceRegisterTest.java
@@ -24,11 +24,20 @@ public abstract class AbstractRemoteServiceRegisterTest extends
AbstractDistributionTest {
protected static final int REGISTER_WAIT = 2000;
+ private ServiceRegistration registration;
protected abstract String getServerContainerTypeName();
protected void tearDown() throws Exception {
+ // Then unregister
+ if(registration != null) {
+ registration.unregister();
+ registration = null;
+ }
+ Thread.sleep(REGISTER_WAIT);
+
super.tearDown();
+
IContainer [] containers = getContainerManager().getAllContainers();
for(int i=0; i < containers.length; i++) {
containers[i].dispose();
@@ -39,14 +48,13 @@ public abstract class AbstractRemoteServiceRegisterTest extends
protected void registerWaitAndUnregister(Properties props, boolean verifyRegistration) throws Exception {
// Actually register with default service (IConcatService)
- ServiceRegistration registration = registerDefaultService(props);
+ registration = registerDefaultService(props);
// Wait a while
Thread.sleep(REGISTER_WAIT);
// Verify
- if (verifyRegistration) verifyRemoteServiceRegisteredWithServer();
- // Then unregister
- registration.unregister();
- Thread.sleep(REGISTER_WAIT);
+ if (verifyRegistration) {
+ verifyRemoteServiceRegisteredWithServer();
+ }
}
private void verifyRemoteServiceRegisteredWithServer() throws Exception {
@@ -75,20 +83,23 @@ public abstract class AbstractRemoteServiceRegisterTest extends
}
public void testRegisterOnCreatedServer() throws Exception {
- Properties props = new Properties();
- props.put(SERVICE_EXPORTED_CONFIGS, getServerContainerTypeName());
- props.put(SERVICE_EXPORTED_INTERFACES, new String[] {SERVICE_EXPORTED_INTERFACES_WILDCARD});
+ Properties props = getServiceProperties();
registerWaitAndUnregister(props, true);
}
- public void testRegisterOnCreatedServerWithIdentity() throws Exception {
+ private Properties getServiceProperties() {
Properties props = new Properties();
// Set config to the server container name/provider config name (e.g. ecf.generic.server)
props.put(SERVICE_EXPORTED_CONFIGS, getServerContainerTypeName());
+ // Set the service exported interfaces to all
+ props.put(SERVICE_EXPORTED_INTERFACES, SERVICE_EXPORTED_INTERFACES_WILDCARD);
+ return props;
+ }
+
+ public void testRegisterOnCreatedServerWithIdentity() throws Exception {
+ Properties props = getServiceProperties();
// set the container factory arguments to the server identity (e.g. ecftcp://localhost:3282/server)
props.put(SERVICE_EXPORTED_CONTAINER_FACTORY_ARGUMENTS, new String[] { getServerIdentity() } );
- // Set the service exported interfaces to all
- props.put(SERVICE_EXPORTED_INTERFACES, new String[] {SERVICE_EXPORTED_INTERFACES_WILDCARD});
registerWaitAndUnregister(props, true);
}
@@ -97,9 +108,7 @@ public abstract class AbstractRemoteServiceRegisterTest extends
// Create server container
this.server = ContainerFactory.getDefault().createContainer(getServerContainerTypeName(),new Object[] {createServerID()});
- Properties props = new Properties();
- props.put(SERVICE_EXPORTED_CONFIGS, getServerContainerTypeName());
- props.put(SERVICE_EXPORTED_INTERFACES, new String[] {SERVICE_EXPORTED_INTERFACES_WILDCARD});
+ Properties props = getServiceProperties();
registerWaitAndUnregister(props, true);
}
@@ -108,9 +117,7 @@ public abstract class AbstractRemoteServiceRegisterTest extends
// Create server container
this.server = ContainerFactory.getDefault().createContainer(getServerContainerTypeName(),new Object[] {createServerID()});
- Properties props = new Properties();
- props.put(SERVICE_EXPORTED_CONFIGS, getServerContainerTypeName());
- props.put(SERVICE_EXPORTED_INTERFACES, new String[] {SERVICE_EXPORTED_INTERFACES_WILDCARD});
+ Properties props = getServiceProperties();
// Add intents
props.put(SERVICE_INTENTS, "passByValue");
registerWaitAndUnregister(props, true);
@@ -120,9 +127,7 @@ public abstract class AbstractRemoteServiceRegisterTest extends
// Create server container
this.server = ContainerFactory.getDefault().createContainer(getServerContainerTypeName(),new Object[] {createServerID()});
- Properties props = new Properties();
- props.put(SERVICE_EXPORTED_CONFIGS, getServerContainerTypeName());
- props.put(SERVICE_EXPORTED_INTERFACES, new String[] {SERVICE_EXPORTED_INTERFACES_WILDCARD});
+ Properties props = getServiceProperties();
// Add intent that no one actually exposes
props.put(SERVICE_INTENTS, "foobar");
registerWaitAndUnregister(props, false);
@@ -132,9 +137,7 @@ public abstract class AbstractRemoteServiceRegisterTest extends
// Create server container
this.server = ContainerFactory.getDefault().createContainer(getServerContainerTypeName(),new Object[] {createServerID()});
- Properties props = new Properties();
- props.put(SERVICE_EXPORTED_CONFIGS, getServerContainerTypeName());
- props.put(SERVICE_EXPORTED_INTERFACES, new String[] {SERVICE_EXPORTED_INTERFACES_WILDCARD});
+ Properties props = getServiceProperties();
// Add intents
props.put(SERVICE_EXPORTED_INTENTS, "passByValue");
registerWaitAndUnregister(props, true);
@@ -144,9 +147,7 @@ public abstract class AbstractRemoteServiceRegisterTest extends
// Create server container
this.server = ContainerFactory.getDefault().createContainer(getServerContainerTypeName(),new Object[] {createServerID()});
- Properties props = new Properties();
- props.put(SERVICE_EXPORTED_CONFIGS, getServerContainerTypeName());
- props.put(SERVICE_EXPORTED_INTERFACES, new String[] {SERVICE_EXPORTED_INTERFACES_WILDCARD});
+ Properties props = getServiceProperties();
// Add intent that no one actually exposes
props.put(SERVICE_EXPORTED_INTENTS, "foobar");
registerWaitAndUnregister(props, false);
@@ -156,9 +157,7 @@ public abstract class AbstractRemoteServiceRegisterTest extends
// Create server container
this.server = ContainerFactory.getDefault().createContainer(getServerContainerTypeName(),new Object[] {createServerID()});
- Properties props = new Properties();
- props.put(SERVICE_EXPORTED_CONFIGS, getServerContainerTypeName());
- props.put(SERVICE_EXPORTED_INTERFACES, new String[] {SERVICE_EXPORTED_INTERFACES_WILDCARD});
+ Properties props = getServiceProperties();
// Add intents
props.put(SERVICE_EXPORTED_INTENTS_EXTRA, "passByValue");
registerWaitAndUnregister(props, true);
@@ -168,9 +167,7 @@ public abstract class AbstractRemoteServiceRegisterTest extends
// Create server container
this.server = ContainerFactory.getDefault().createContainer(getServerContainerTypeName(),new Object[] {createServerID()});
- Properties props = new Properties();
- props.put(SERVICE_EXPORTED_CONFIGS, getServerContainerTypeName());
- props.put(SERVICE_EXPORTED_INTERFACES, new String[] {SERVICE_EXPORTED_INTERFACES_WILDCARD});
+ Properties props = getServiceProperties();
// Add intent that no one actually exposes
props.put(SERVICE_EXPORTED_INTENTS_EXTRA, "foobar");
registerWaitAndUnregister(props, false);
@@ -180,8 +177,7 @@ public abstract class AbstractRemoteServiceRegisterTest extends
// Create server container
this.server = ContainerFactory.getDefault().createContainer(getServerContainerTypeName(),new Object[] {createServerID()});
- Properties props = new Properties();
- props.put(SERVICE_EXPORTED_INTERFACES, new String[] {SERVICE_EXPORTED_INTERFACES_WILDCARD});
+ final Properties props = getServiceProperties();
props.put(SERVICE_EXPORTED_CONTAINER_ID, this.server.getID());
registerWaitAndUnregister(props, true);
}
@@ -190,11 +186,7 @@ public abstract class AbstractRemoteServiceRegisterTest extends
// Create server container
this.server = ContainerFactory.getDefault().createContainer(getServerContainerTypeName(),getServerIdentity());
- Properties props = new Properties();
- // Set config to the server container name/provider config name (e.g. ecf.generic.server)
- props.put(SERVICE_EXPORTED_CONFIGS, getServerContainerTypeName());
- // Set the service exported interfaces to all
- props.put(SERVICE_EXPORTED_INTERFACES, new String[] {SERVICE_EXPORTED_INTERFACES_WILDCARD});
+ Properties props = getServiceProperties();
registerWaitAndUnregister(props, true);
}
diff --git a/tests/bundles/org.eclipse.ecf.tests.osgi.services.distribution/src/org/eclipse/ecf/tests/osgi/services/distribution/AbstractServicePublicationTest.java b/tests/bundles/org.eclipse.ecf.tests.osgi.services.distribution/src/org/eclipse/ecf/tests/osgi/services/distribution/AbstractServicePublicationTest.java
index 955b5f247..573cfb3cc 100644
--- a/tests/bundles/org.eclipse.ecf.tests.osgi.services.distribution/src/org/eclipse/ecf/tests/osgi/services/distribution/AbstractServicePublicationTest.java
+++ b/tests/bundles/org.eclipse.ecf.tests.osgi.services.distribution/src/org/eclipse/ecf/tests/osgi/services/distribution/AbstractServicePublicationTest.java
@@ -9,6 +9,7 @@
******************************************************************************/
package org.eclipse.ecf.tests.osgi.services.distribution;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Dictionary;
import java.util.Hashtable;
@@ -22,19 +23,13 @@ import org.eclipse.ecf.osgi.services.discovery.ServicePublication;
import org.eclipse.ecf.osgi.services.distribution.IDistributionConstants;
import org.eclipse.ecf.tests.internal.osgi.services.distribution.Activator;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
import org.osgi.util.tracker.ServiceTracker;
public abstract class AbstractServicePublicationTest extends TestCase implements IDistributionConstants, RemoteServicePublication {
- protected static void assertStringsEqual(final String[] s1, final String[] s2) {
- assertEquals(s1.length, s2.length);
- for (int i = 0; i < s1.length; i++) {
- assertEquals(s1[i], s2[i]);
- }
- }
-
// Member variables that should be set by subclasses
protected IContainer container;
protected String[] ifaces;
@@ -97,7 +92,7 @@ public abstract class AbstractServicePublicationTest extends TestCase implements
this.container = container;
}
- public void testServicePublication() throws InterruptedException {
+ public void testServicePublication() throws InterruptedException, InvalidSyntaxException {
final BundleContext context = Activator.getDefault().getContext();
// register a service with the marker property set
@@ -116,16 +111,23 @@ public abstract class AbstractServicePublicationTest extends TestCase implements
tracker.waitForService(10000);
// expected behavior: an endpoint is published
- final ServiceReference ref = context
- .getServiceReference(ServicePublication.class.getName());
- assertTrue(ref != null);
- // check the service publication properties
- final Object o = ref
+ final ServiceReference[] refs = context
+ .getServiceReferences(ServicePublication.class.getName(), null);
+ assertTrue(refs != null);
+
+ for (int i = 0; i < refs.length; i++) {
+ ServiceReference ref = refs[i];
+
+ // check the service publication properties
+ final Object o = ref
.getProperty(ServicePublication.SERVICE_INTERFACE_NAME);
- assertTrue(o instanceof Collection);
- final Collection refIfaces = (Collection) o;
- assertStringsEqual(getInterfaces(), (String []) refIfaces.toArray(new String[] {}));
- Thread.sleep(10000);
+ assertTrue(o instanceof Collection);
+ final Collection refIfaces = (Collection) o;
+ if(Arrays.equals(getInterfaces(), (String []) refIfaces.toArray(new String[] {}))) {
+ return;
+ }
+ }
+ fail("registered service not found.");
}
public void setInterfaces(String [] interfaces) {
this.ifaces = interfaces;

Back to the top