Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Alexander Kuppe2013-12-18 12:18:48 +0000
committerMarkus Alexander Kuppe2013-12-18 12:29:53 +0000
commit4a7dfbda7c9b87ef684ab16a7d0e6b490d643b40 (patch)
tree57d9d1fd2a2c6299c67af7dc889739d8aa398507 /tests/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin
parent695a5cee6021806d7d8a05b106ee7baec3073bf8 (diff)
downloadorg.eclipse.ecf-4a7dfbda7c9b87ef684ab16a7d0e6b490d643b40.tar.gz
org.eclipse.ecf-4a7dfbda7c9b87ef684ab16a7d0e6b490d643b40.tar.xz
org.eclipse.ecf-4a7dfbda7c9b87ef684ab16a7d0e6b490d643b40.zip
Bug 424059: RSA not dynamic aware with regards to discovery providers
https://bugs.eclipse.org/bugs/show_bug.cgi?id=424059 Refactor .remoteserviceadmin bundle to interact with ECF discovery via whiteboard pattern only. Besides code simplifications a major advantage is removal of startup ordering in that Discovery providers can now be started but still advertise the endpoint after RSA has published the service. Part #1 removes the coupling with IDiscoveryAdvertiser Signed-off-by: Markus Alexander Kuppe <bugs.eclipse.org@lemmster.de>
Diffstat (limited to 'tests/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin')
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractEndpointDescriptionEDEFBundleGeneratorTest.java98
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractEndpointDescriptionWriterTest.java133
2 files changed, 79 insertions, 152 deletions
diff --git a/tests/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractEndpointDescriptionEDEFBundleGeneratorTest.java b/tests/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractEndpointDescriptionEDEFBundleGeneratorTest.java
deleted file mode 100644
index d179ed3a0..000000000
--- a/tests/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractEndpointDescriptionEDEFBundleGeneratorTest.java
+++ /dev/null
@@ -1,98 +0,0 @@
-package org.eclipse.ecf.tests.osgi.services.remoteserviceadmin;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Properties;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.ecf.osgi.services.remoteserviceadmin.EndpointDescription;
-import org.eclipse.ecf.osgi.services.remoteserviceadmin.IEndpointDescriptionAdvertiser;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.remoteserviceadmin.RemoteConstants;
-
-public abstract class AbstractEndpointDescriptionEDEFBundleGeneratorTest extends
- AbstractDistributionTest {
-
- protected static final int REGISTER_WAIT = 2000;
- private ServiceRegistration registration;
-
- private ServiceRegistration writerEndpointDescriptionAdvertiser;
-
- protected void setUp() throws Exception {
- super.setUp();
- writerEndpointDescriptionAdvertiser = getContext().registerService(IEndpointDescriptionAdvertiser.class.getName(), createStandardOutputWriterServiceInfoFactory(), null);
- }
-
- private IEndpointDescriptionAdvertiser createStandardOutputWriterServiceInfoFactory() {
- return new IEndpointDescriptionAdvertiser() {
-
- @Override
- public IStatus advertise(EndpointDescription endpointDescription) {
- try {
- EDEFBundleGenerator edefBundleGenerator = new EDEFBundleGenerator(new File("c:\\temp\\"),"org.eclipse.ecf.edefbundlegenerator","1.0.0",null);
- edefBundleGenerator.generateEDEFBundle(new EndpointDescription[] { endpointDescription });
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- return Status.OK_STATUS;
- }
-
- @Override
- public IStatus unadvertise(EndpointDescription endpointDescription) {
- // TODO Auto-generated method stub
- return Status.OK_STATUS;
- }
-
- @Override
- public IStatus advertise(
- org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription) {
- // TODO Auto-generated method stub
- return Status.OK_STATUS;
- }
-
- @Override
- public IStatus unadvertise(
- org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription) {
- // TODO Auto-generated method stub
- return Status.OK_STATUS;
- }
- };
- }
-
- protected void tearDown() throws Exception {
- if (registration != null) {
- registration.unregister();
- registration = null;
- }
- if (writerEndpointDescriptionAdvertiser != null) {
- writerEndpointDescriptionAdvertiser.unregister();
- writerEndpointDescriptionAdvertiser = null;
- }
- super.tearDown();
- }
-
- public void testRegisterOnCreatedServer() throws Exception {
- Properties props = getServiceProperties();
- // Actually register with default service (IConcatService)
- registration = registerDefaultService(props);
- // Wait a while
- Thread.sleep(REGISTER_WAIT);
- }
-
- protected abstract String getServerContainerTypeName();
-
- private Properties getServiceProperties() {
- Properties props = new Properties();
- // Set config to the server container name/provider config name (e.g.
- // ecf.generic.server)
- props.put(RemoteConstants.SERVICE_EXPORTED_CONFIGS,
- getServerContainerTypeName());
- // Set the service exported interfaces to all
- props.put(RemoteConstants.SERVICE_EXPORTED_INTERFACES, "*");
- return props;
- }
-
-}
diff --git a/tests/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractEndpointDescriptionWriterTest.java b/tests/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractEndpointDescriptionWriterTest.java
index 33c72a976..471705511 100644
--- a/tests/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractEndpointDescriptionWriterTest.java
+++ b/tests/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractEndpointDescriptionWriterTest.java
@@ -1,14 +1,19 @@
package org.eclipse.ecf.tests.osgi.services.remoteserviceadmin;
+import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
+import java.util.Dictionary;
+import java.util.Hashtable;
import java.util.Properties;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
+import org.eclipse.ecf.discovery.IDiscoveryAdvertiser;
+import org.eclipse.ecf.discovery.IServiceInfo;
import org.eclipse.ecf.osgi.services.remoteserviceadmin.EndpointDescription;
import org.eclipse.ecf.osgi.services.remoteserviceadmin.EndpointDescriptionWriter;
-import org.eclipse.ecf.osgi.services.remoteserviceadmin.IEndpointDescriptionAdvertiser;
+import org.eclipse.ecf.osgi.services.remoteserviceadmin.IServiceInfoFactory;
+import org.eclipse.ecf.osgi.services.remoteserviceadmin.ServiceInfoFactory;
+import org.osgi.framework.Constants;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.remoteserviceadmin.RemoteConstants;
@@ -18,74 +23,94 @@ public abstract class AbstractEndpointDescriptionWriterTest extends
protected static final int REGISTER_WAIT = 2000;
private ServiceRegistration registration;
- private ServiceRegistration writerEndpointDescriptionAdvertiser;
- private EndpointDescriptionWriter writer;
+ private ServiceRegistration serviceInfoFactory;
- protected void setUp() throws Exception {
- super.setUp();
- writer = new EndpointDescriptionWriter();
- writerEndpointDescriptionAdvertiser = getContext().registerService(IEndpointDescriptionAdvertiser.class.getName(), createStandardOutputWriterServiceInfoFactory(), null);
+ protected void tearDown() throws Exception {
+ if (registration != null) {
+ registration.unregister();
+ registration = null;
+ }
+ if (serviceInfoFactory != null) {
+ serviceInfoFactory.unregister();
+ serviceInfoFactory = null;
+ }
+ super.tearDown();
}
- private IEndpointDescriptionAdvertiser createStandardOutputWriterServiceInfoFactory() {
- return new IEndpointDescriptionAdvertiser() {
-
- @Override
- public IStatus advertise(EndpointDescription endpointDescription) {
- // TODO Auto-generated method stub
- try {
- StringWriter sr = new StringWriter();
- sr.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>").append("\n");
- writer.writeEndpointDescriptions(sr, new EndpointDescription[] { (EndpointDescription) endpointDescription });
- System.out.print(sr.toString());
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- return Status.OK_STATUS;
- }
+
+ private static class EDEFServiceInfoFactory extends ServiceInfoFactory {
- @Override
- public IStatus unadvertise(EndpointDescription endpointDescription) {
- // TODO Auto-generated method stub
- return Status.OK_STATUS;
+ @Override
+ public IServiceInfo createServiceInfo(
+ IDiscoveryAdvertiser advertiser,
+ org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription) {
+ try {
+ EDEFBundleGenerator edefBundleGenerator = new EDEFBundleGenerator(new File(System.getProperty("java.io.tmpdir")),"org.eclipse.ecf.edefbundlegenerator","1.0.0",null);
+ edefBundleGenerator.generateEDEFBundle(new EndpointDescription[] { (EndpointDescription) endpointDescription });
+ } catch (IOException e) {
+ e.printStackTrace();
}
+ return super.createServiceInfo(advertiser, endpointDescription);
+ }
+ }
+
+ public void testRegisterOnCreatedServerEDEF() throws Exception {
+
+ // Make sure we take precedence over default ISIF
+ final Dictionary<String, String> props = new Hashtable<String, String>();
+ props.put(Constants.SERVICE_RANKING, "9999");
- @Override
- public IStatus advertise(
- org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription) {
- // TODO Auto-generated method stub
- return Status.OK_STATUS;
- }
+ serviceInfoFactory = getContext().registerService(
+ IServiceInfoFactory.class,
+ new EDEFServiceInfoFactory(), props);
+
+ // Actually register with default service (IConcatService)
+ registration = registerDefaultService(getServiceProperties());
+ // Wait a while
+ Thread.sleep(REGISTER_WAIT);
- @Override
- public IStatus unadvertise(
- org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription) {
- // TODO Auto-generated method stub
- return null;
- }
- };
}
- protected void tearDown() throws Exception {
- if (registration != null) {
- registration.unregister();
- registration = null;
+ private static class XMLServiceInfoFactory extends ServiceInfoFactory {
+
+ private EndpointDescriptionWriter writer;
+
+ public XMLServiceInfoFactory(EndpointDescriptionWriter writer) {
+ this.writer = writer;
}
- if (writerEndpointDescriptionAdvertiser != null) {
- writerEndpointDescriptionAdvertiser.unregister();
- writerEndpointDescriptionAdvertiser = null;
+
+ @Override
+ public IServiceInfo createServiceInfo(
+ IDiscoveryAdvertiser advertiser,
+ org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription) {
+ try {
+ StringWriter sr = new StringWriter();
+ sr.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>").append("\n");
+ writer.writeEndpointDescriptions(sr, new EndpointDescription[] { (EndpointDescription) endpointDescription });
+ System.out.print(sr.toString());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return super.createServiceInfo(advertiser, endpointDescription);
}
- super.tearDown();
}
public void testRegisterOnCreatedServer() throws Exception {
- Properties props = getServiceProperties();
+
+ // Make sure we take precedence over default ISIF
+ final Dictionary<String, String> props = new Hashtable<String, String>();
+ props.put(Constants.SERVICE_RANKING, "9999");
+
+ serviceInfoFactory = getContext().registerService(
+ IServiceInfoFactory.class,
+ new XMLServiceInfoFactory(new EndpointDescriptionWriter()), props);
+
// Actually register with default service (IConcatService)
- registration = registerDefaultService(props);
+ registration = registerDefaultService(getServiceProperties());
// Wait a while
Thread.sleep(REGISTER_WAIT);
+
+ //TODO really test something here
}
protected abstract String getServerContainerTypeName();

Back to the top