Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis@composent.com2010-10-29 18:37:30 -0400
committerslewis@composent.com2010-10-29 18:37:30 -0400
commitd48405bbcc2b6b3bdeb01913e7fc8d79e5b87ae6 (patch)
tree06136775912ca80b1d4b80b678ab720e725421d9
parent1c68b8fc5c5d426e7cfbaa312070364a6975751f (diff)
downloadorg.eclipse.ecf-d48405bbcc2b6b3bdeb01913e7fc8d79e5b87ae6.tar.gz
org.eclipse.ecf-d48405bbcc2b6b3bdeb01913e7fc8d79e5b87ae6.tar.xz
org.eclipse.ecf-d48405bbcc2b6b3bdeb01913e7fc8d79e5b87ae6.zip
Additions and tests for rsa
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractMetadataFactory.java67
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescription.java7
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteConstants.java7
-rw-r--r--incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractMetadataFactoryTest.java115
-rw-r--r--incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/EndpointDescriptionFactoryTest.java43
-rw-r--r--incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/ServiceInfoFactoryTest.java31
6 files changed, 224 insertions, 46 deletions
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractMetadataFactory.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractMetadataFactory.java
index 4825b3009..91f05a56d 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractMetadataFactory.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractMetadataFactory.java
@@ -44,7 +44,9 @@ public abstract class AbstractMetadataFactory {
RemoteConstants.ENDPOINT_TARGET_ID,
RemoteConstants.ENDPOINT_TARGET_ID_NAMESPACE,
RemoteConstants.ENDPOINT_IDFILTER_IDS,
- RemoteConstants.ENDPOINT_IDFILTER_NAMESPACES,
+ RemoteConstants.ENDPOINT_IDFILTER_ID_COUNT,
+ RemoteConstants.ENDPOINT_IDFILTER_ID_NAME_,
+ RemoteConstants.ENDPOINT_IDFILTER_NAMESPACE_,
RemoteConstants.ENDPOINT_REMOTESERVICE_ID,
RemoteConstants.ENDPOINT_REMOTESERVICEFILTER
});
@@ -122,33 +124,31 @@ public abstract class AbstractMetadataFactory {
return result;
}
- protected void encodeIDArray(IServiceProperties result, String idsname,
- String idnamespaces, ID[] idFilter) {
- List<String> idef = new ArrayList<String>();
- List<String> idns = new ArrayList<String>();
- for (int i = 0; i < idFilter.length; i++) {
- idef.add(idFilter[i].toExternalForm());
- idns.add(idFilter[i].getNamespace().getName());
+ protected void encodeIDArray(IServiceProperties result, ID[] idFilter) {
+ // First, for every id, setup prop name with index suffix
+ for(int i=0; i < idFilter.length; i++) {
+ encodeString(result, RemoteConstants.ENDPOINT_IDFILTER_ID_NAME_+i, idFilter[i].toExternalForm());
+ result.setPropertyString(RemoteConstants.ENDPOINT_IDFILTER_NAMESPACE_+i, idFilter[i].getNamespace().getName());
}
- encodeList(result, idsname, idef);
- encodeList(result, idnamespaces, idns);
+ // Now add count
+ result.setPropertyString(RemoteConstants.ENDPOINT_IDFILTER_ID_COUNT, new Integer(idFilter.length).toString());
}
- protected ID[] decodeIDArray(IServiceProperties props, String idsname,
- String idnamespaces) {
- String idef = props.getPropertyString(idsname);
- if (idef == null)
- return null;
- String idns = props.getPropertyString(idnamespaces);
- if (idns == null)
- return null;
- List<String> idsl = decodeList(props, idef);
- List<String> idnsl = decodeList(props, idns);
+ protected ID[] decodeIDArray(IServiceProperties props) {
+ // First, get the count
+ String countValue = props.getPropertyString(RemoteConstants.ENDPOINT_IDFILTER_ID_COUNT);
+ if (countValue == null) return null;
+ int count = new Integer(countValue).intValue();
+ if (count <= 0) return null;
List result = new ArrayList();
- for (int i = 0; i < idsl.size(); i++) {
- ID id = createID(idnsl.get(i), idsl.get(i));
- if (id != null)
- result.add(id);
+ for(int i=0; i < count; i++) {
+ // decode string as name
+ String name = decodeString(props,RemoteConstants.ENDPOINT_IDFILTER_ID_NAME_+i);
+ String ns = props.getPropertyString(RemoteConstants.ENDPOINT_IDFILTER_NAMESPACE_+i);
+ if (name != null && ns != null) {
+ ID id = createID(ns,name);
+ if (id != null) result.add(id);
+ }
}
return (ID[]) result.toArray(new ID[] {});
}
@@ -174,15 +174,15 @@ public abstract class AbstractMetadataFactory {
result.put(org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_FRAMEWORK_UUID, fwkuuid);
// configuration types
List<String> configTypes = decodeList(props,org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_IMPORTED_CONFIGS);
- if (configTypes != null) result.put(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_IMPORTED_CONFIGS, (String[]) configTypes.toArray(new String[] {}));
+ if (configTypes != null && configTypes.size() > 0) result.put(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_IMPORTED_CONFIGS, (String[]) configTypes.toArray(new String[] {}));
// service intents
List<String> intents = decodeList(props,org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_INTENTS);
- if (configTypes != null) result.put(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_INTENTS, (String[]) intents.toArray(new String[] {}));
+ if (intents != null && intents.size() > 0) result.put(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_INTENTS, (String[]) intents.toArray(new String[] {}));
// endpoint ID
String endpointName = decodeString(props,RemoteConstants.ENDPOINT_ID);
String endpointNamespace = decodeString(props,RemoteConstants.ENDPOINT_ID_NAMESPACE);
- ID endpointID = createID(endpointName,endpointNamespace);
+ ID endpointID = createID(endpointNamespace,endpointName);
if (endpointID != null) {
result.put(RemoteConstants.ENDPOINT_ID,endpointID);
}
@@ -192,12 +192,14 @@ public abstract class AbstractMetadataFactory {
// target ID
String targetName = decodeString(props,RemoteConstants.ENDPOINT_TARGET_ID);
String targetNamespace = decodeString(props,RemoteConstants.ENDPOINT_ID_NAMESPACE);
- ID targetID = createID(targetName,targetNamespace);
- if (targetID != null) {
- result.put(RemoteConstants.ENDPOINT_TARGET_ID,targetID);
+ if (targetName != null && targetNamespace != null) {
+ ID targetID = createID(targetNamespace,targetName);
+ if (targetID != null) {
+ result.put(RemoteConstants.ENDPOINT_TARGET_ID,targetID);
+ }
}
// ID filter
- ID[] idFilter = decodeIDArray(props, RemoteConstants.ENDPOINT_IDFILTER_IDS, RemoteConstants.ENDPOINT_IDFILTER_NAMESPACES);
+ ID[] idFilter = decodeIDArray(props);
if (idFilter != null) {
result.put(RemoteConstants.ENDPOINT_IDFILTER_IDS, idFilter);
}
@@ -285,8 +287,7 @@ public abstract class AbstractMetadataFactory {
// ECF idFilter = endpointDescription.getIDFilter();
ID[] idFilter = endpointDescription.getIDFilter();
if (idFilter != null && idFilter.length > 0) {
- encodeIDArray(result, RemoteConstants.ENDPOINT_IDFILTER_IDS,
- RemoteConstants.ENDPOINT_IDFILTER_NAMESPACES, idFilter);
+ encodeIDArray(result, idFilter);
}
// ECF remote service filter =
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescription.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescription.java
index e0e3cd1fa..17350da37 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescription.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescription.java
@@ -45,12 +45,13 @@ public class EndpointDescription extends
containerID = (ID) properties.get(RemoteConstants.ENDPOINT_ID);
if (containerID == null)
throw new NullPointerException(
- "ECF EndpointDescription must include non-null containerID");
+ "ECF EndpointDescription must include non-null value for 'ecf.endpoint.id' of type ID");
Object rsid = properties.get(RemoteConstants.ENDPOINT_REMOTESERVICE_ID);
if (rsid != null)
remoteServiceId = ((Long) rsid).longValue();
-
+ else throw new NullPointerException("ECF EndpointDescription must include value of 'ecf.endpoint.rs.id' of type Long");
+
Object ctid = properties.get(RemoteConstants.ENDPOINT_TARGET_ID);
if (ctid != null)
connectTargetID = (ID) ctid;
@@ -61,7 +62,7 @@ public class EndpointDescription extends
Object rsf = properties.get(RemoteConstants.ENDPOINT_REMOTESERVICEFILTER);
if (rsf != null)
- rsFilter = (String) rsFilter;
+ rsFilter = (String) rsf;
}
public EndpointDescription(Map osgiProperties) {
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteConstants.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteConstants.java
index 381b018d3..52dcc20b5 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteConstants.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteConstants.java
@@ -30,10 +30,13 @@ public class RemoteConstants {
public static final String ENDPOINT_TARGET_ID = "ecf.endpoint.target.id";
public static final String ENDPOINT_TARGET_ID_NAMESPACE = "ecf.endpoint.target.id.ns";
-// id filter external form
public static final String ENDPOINT_IDFILTER_IDS = "ecf.endpoint.idfilter.ids";
+
+ public static final String ENDPOINT_IDFILTER_ID_COUNT = "ecf.endpoint.idfilter.id.n";
+ // id filter external form
+ public static final String ENDPOINT_IDFILTER_ID_NAME_ = "ecf.endpoint.idfilter.id.name.";
// id filter namespaces
- public static final String ENDPOINT_IDFILTER_NAMESPACES = "ecf.endpoint.idfilter.ids.ns";
+ public static final String ENDPOINT_IDFILTER_NAMESPACE_ = "ecf.endpoint.idfilter.id.ns.";
// remote service filter
public static final String ENDPOINT_REMOTESERVICEFILTER = "ecf.endpoint.rsfilter";
diff --git a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractMetadataFactoryTest.java b/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractMetadataFactoryTest.java
index 9948476a0..3b3d93678 100644
--- a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractMetadataFactoryTest.java
+++ b/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractMetadataFactoryTest.java
@@ -16,7 +16,11 @@ import java.util.UUID;
import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.discovery.IDiscoveryAdvertiser;
import org.eclipse.ecf.discovery.IDiscoveryLocator;
+import org.eclipse.ecf.discovery.IServiceInfo;
+import org.eclipse.ecf.osgi.services.remoteserviceadmin.DiscoveredEndpointDescription;
import org.eclipse.ecf.osgi.services.remoteserviceadmin.EndpointDescription;
+import org.eclipse.ecf.osgi.services.remoteserviceadmin.IEndpointDescriptionFactory;
+import org.eclipse.ecf.osgi.services.remoteserviceadmin.IServiceInfoFactory;
import org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteConstants;
import org.eclipse.ecf.tests.ECFAbstractTestCase;
import org.osgi.framework.Constants;
@@ -24,8 +28,22 @@ import org.osgi.util.tracker.ServiceTracker;
public abstract class AbstractMetadataFactoryTest extends ECFAbstractTestCase {
- private static final String DEFAULT_ENDPOINT_ID = "ecftcp://localhost:3282/server";
- private static final String DEFAULT_SERVICE_IMPORTED_CONFIG = "ecf.generic.server";
+ protected static final String DEFAULT_SERVICE_INTF_PACKAGE = "com.foo";
+ protected static final String DEFAULT_SERVICE_INTF_VERSION = "3.0.0";
+ protected static final String DEFAULT_SERVICE_INTF = DEFAULT_SERVICE_INTF_PACKAGE + "." + "Foo";
+
+ protected static final String DEFAULT_ENDPOINT_ID = "ecftcp://localhost:3282/server";
+ protected static final String DEFAULT_SERVICE_IMPORTED_CONFIG = "ecf.generic.server";
+ protected static final String DEFAULT_SERVICE_INTENT1 = "test.intent.1";
+ protected static final String DEFAULT_SERVICE_INTENT2 = "test.intent.2";
+ protected static final String DEFAULT_ECF_TARGET_ID = "ecftcp://localhost:3333/server";
+ protected static final Object DEFAULT_IDFILTER = "(&(key1=foo)(key2=foo2))";
+ protected static final String EXTRA_PROPERTY1 = "test.extra.prop.value.1";
+ protected static final String EXTRA_PROPERTY2 = "test.extra.prop.value.2";
+
+ protected IServiceInfoFactory serviceInfoFactory;
+ protected IEndpointDescriptionFactory endpointDescriptionFactory;
+
protected IDiscoveryAdvertiser discoveryAdvertiser;
protected IDiscoveryLocator discoveryLocator;
@@ -50,13 +68,15 @@ public abstract class AbstractMetadataFactoryTest extends ECFAbstractTestCase {
}
protected void tearDown() throws Exception {
+ serviceInfoFactory = null;
+ endpointDescriptionFactory = null;
discoveryAdvertiser = null;
discoveryLocator = null;
super.tearDown();
}
- protected String[] createOSGiObjectClass() {
- return new String[] { "com.foo.IFoo" };
+ protected Object createOSGiObjectClass() {
+ return new String[] { DEFAULT_SERVICE_INTF };
}
protected String createOSGiEndpointFrameworkUUID() {
@@ -77,17 +97,66 @@ public abstract class AbstractMetadataFactoryTest extends ECFAbstractTestCase {
addRequiredOSGiProperties(props);
// Add required ECF properties
addRequiredECFProperties(props);
+ // Add extra properties
+ addExtraProperties(props);
+ return new EndpointDescription(props);
+ }
+
+ protected EndpointDescription createFullEndpointDescription() {
+ Map<String,Object> props = new HashMap<String,Object>();
+ // Add required OSGi properties
+ addRequiredOSGiProperties(props);
+ // Add full OSGi properties
+ addOptionalOSGiProperties(props);
+ // Add required ECF properties
+ addRequiredECFProperties(props);
+ // Add optional ECF properties
+ addOptionalECFProperties(props);
+ // Add extra properties
+ addExtraProperties(props);
+ return new EndpointDescription(props);
+ }
+
+ protected void addExtraProperties(Map<String, Object> props) {
+ props.put(EXTRA_PROPERTY1, "com.foo.bar.propertyvalue1");
+ props.put(EXTRA_PROPERTY2, "com.foo.bar.propertyvalue2");
+ }
+
+ protected EndpointDescription createBadOSGiEndpointDescrption() throws Exception {
+ Map<String,Object> props = new HashMap<String,Object>();
+ // Add only ECF properties
+ // no OSGi properties
+ // Add required ECF properties
+ addRequiredECFProperties(props);
+ // This should throw a runtime exception
return new EndpointDescription(props);
}
+ protected EndpointDescription createBadECFEndpointDescrption() throws Exception {
+ Map<String,Object> props = new HashMap<String,Object>();
+ // Add required OSGi properties
+ addRequiredOSGiProperties(props);
+ // Add full OSGi properties
+ addOptionalOSGiProperties(props);
+
+ // No ECF required properties
+ // This should throw a runtime exception
+ return new EndpointDescription(props);
+ }
+
protected String createOSGiServiceImportedConfig() {
return DEFAULT_SERVICE_IMPORTED_CONFIG;
}
protected ID createECFContainerID(Map<String,Object> props) {
- return getIDFactory().createStringID(createOSGiEndpointId());
+ String osgiEndpointId = (String) props.get(org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_ID);
+ return getIDFactory().createStringID(osgiEndpointId);
}
+ protected ID createECFTargetID(Map<String,Object> props) {
+ return getIDFactory().createStringID(DEFAULT_ECF_TARGET_ID);
+ }
+
protected Long createECFRemoteServiceId(Map<String,Object> props) {
return new Long(101);
}
@@ -105,7 +174,16 @@ public abstract class AbstractMetadataFactoryTest extends ECFAbstractTestCase {
props.put(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_IMPORTED_CONFIGS,createOSGiServiceImportedConfig());
}
+ protected void addOptionalOSGiProperties(Map<String,Object> props) {
+ props.put(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_INTENTS, createOSGiServiceIntents());
+ props.put(org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_PACKAGE_VERSION_+DEFAULT_SERVICE_INTF_PACKAGE,DEFAULT_SERVICE_INTF_VERSION);
+ }
+
+ protected Object createOSGiServiceIntents() {
+ return new String[] { DEFAULT_SERVICE_INTENT1, DEFAULT_SERVICE_INTENT2 };
+ }
+
protected void addRequiredECFProperties(Map<String,Object> props) {
// ecf.endpoint.id
props.put(RemoteConstants.ENDPOINT_ID,createECFContainerID(props));
@@ -113,5 +191,32 @@ public abstract class AbstractMetadataFactoryTest extends ECFAbstractTestCase {
props.put(RemoteConstants.ENDPOINT_REMOTESERVICE_ID, createECFRemoteServiceId(props));
}
+ protected void addOptionalECFProperties(Map<String,Object> props) {
+ // ecf.endpoint.target.id
+ props.put(RemoteConstants.ENDPOINT_TARGET_ID,createECFTargetID(props));
+ // ecf.endpoint.idfilter.ids
+ props.put(RemoteConstants.ENDPOINT_IDFILTER_IDS, createECFIDFilterIDs(props));
+ // ecf.endpoint.idfilter
+ props.put(RemoteConstants.ENDPOINT_REMOTESERVICEFILTER, createECFIDFilter(props));
+ }
+
+ protected Object createECFIDFilter(Map<String, Object> props) {
+ return DEFAULT_IDFILTER;
+ }
+
+ protected Object createECFIDFilterIDs(Map<String, Object> props) {
+ return new ID[] { getIDFactory().createGUID(), getIDFactory().createGUID() };
+ }
+
+ protected IServiceInfo createServiceInfoForDiscovery(EndpointDescription endpointDescription) {
+ return serviceInfoFactory.createServiceInfoForDiscovery(discoveryAdvertiser, endpointDescription);
+ }
+
+ protected EndpointDescription createEndpointDescriptionFromDiscovery(
+ IServiceInfo discoveredServiceInfo) {
+ DiscoveredEndpointDescription ded = endpointDescriptionFactory.createDiscoveredEndpointDescription(discoveryLocator, discoveredServiceInfo);
+ assertNotNull(ded);
+ return ded.getEndpointDescription();
+ }
}
diff --git a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/EndpointDescriptionFactoryTest.java b/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/EndpointDescriptionFactoryTest.java
new file mode 100644
index 000000000..438d7e97f
--- /dev/null
+++ b/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/EndpointDescriptionFactoryTest.java
@@ -0,0 +1,43 @@
+package org.eclipse.ecf.tests.osgi.services.remoteserviceadmin;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.ecf.discovery.IServiceInfo;
+import org.eclipse.ecf.osgi.services.remoteserviceadmin.DefaultEndpointDescriptionFactory;
+import org.eclipse.ecf.osgi.services.remoteserviceadmin.DefaultServiceInfoFactory;
+import org.eclipse.ecf.osgi.services.remoteserviceadmin.EndpointDescription;
+
+public class EndpointDescriptionFactoryTest extends AbstractMetadataFactoryTest {
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ discoveryAdvertiser = getDiscoveryAdvertiser();
+ Assert.isNotNull(discoveryAdvertiser);
+ serviceInfoFactory = new DefaultServiceInfoFactory();
+ Assert.isNotNull(serviceInfoFactory);
+ discoveryLocator = getDiscoveryLocator();
+ Assert.isNotNull(discoveryLocator);
+ endpointDescriptionFactory = new DefaultEndpointDescriptionFactory();
+ Assert.isNotNull(endpointDescriptionFactory);
+ }
+
+ public void testCreateRequiredEndpointDescriptionFromServiceInfo() throws Exception {
+ EndpointDescription published = createRequiredEndpointDescription();
+ assertNotNull(published);
+ IServiceInfo serviceInfo = createServiceInfoForDiscovery(published);
+ assertNotNull(serviceInfo);
+ EndpointDescription received = createEndpointDescriptionFromDiscovery(serviceInfo);
+ assertNotNull(received);
+ assertTrue(published.equals(received));
+ }
+
+ public void testCreateFullEndpointDescriptionFromServiceInfo() throws Exception {
+ EndpointDescription published = createFullEndpointDescription();
+ assertNotNull(published);
+ IServiceInfo serviceInfo = createServiceInfoForDiscovery(published);
+ assertNotNull(serviceInfo);
+ EndpointDescription received = createEndpointDescriptionFromDiscovery(serviceInfo);
+ assertNotNull(received);
+ assertTrue(published.equals(received));
+ }
+
+}
diff --git a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/ServiceInfoFactoryTest.java b/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/ServiceInfoFactoryTest.java
index b8e850c4e..25c7084e0 100644
--- a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/ServiceInfoFactoryTest.java
+++ b/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/ServiceInfoFactoryTest.java
@@ -12,7 +12,6 @@ package org.eclipse.ecf.tests.osgi.services.remoteserviceadmin;
import org.eclipse.core.runtime.Assert;
import org.eclipse.ecf.discovery.IServiceInfo;
import org.eclipse.ecf.osgi.services.remoteserviceadmin.DefaultServiceInfoFactory;
-import org.eclipse.ecf.osgi.services.remoteserviceadmin.IServiceInfoFactory;
public class ServiceInfoFactoryTest extends AbstractMetadataFactoryTest {
@@ -20,11 +19,37 @@ public class ServiceInfoFactoryTest extends AbstractMetadataFactoryTest {
super.setUp();
discoveryAdvertiser = getDiscoveryAdvertiser();
Assert.isNotNull(discoveryAdvertiser);
+ serviceInfoFactory = new DefaultServiceInfoFactory();
}
public void testCreateServiceInfoFromMinimalEndpointDescription() throws Exception {
- IServiceInfoFactory serviceInfoFactory = new DefaultServiceInfoFactory();
- IServiceInfo serviceInfo = serviceInfoFactory.createServiceInfoForDiscovery(discoveryAdvertiser, createRequiredEndpointDescription());
+ IServiceInfo serviceInfo = createServiceInfoForDiscovery(createRequiredEndpointDescription());
assertNotNull(serviceInfo);
}
+
+ public void testCreateServiceInfoFromFullEndpointDescription() throws Exception {
+ IServiceInfo serviceInfo = createServiceInfoForDiscovery(createFullEndpointDescription());
+ assertNotNull(serviceInfo);
+ }
+
+ public void testCreateBadOSGiEndpointDescription() throws Exception {
+ try{
+ createBadOSGiEndpointDescrption();
+ fail();
+ } catch (Exception e) {
+ e.printStackTrace();
+ // this is test success
+ }
+ }
+
+ public void testCreateBadECFEndpointDescription() throws Exception {
+ try{
+ createBadECFEndpointDescrption();
+ fail();
+ } catch (Exception e) {
+ // this is test success
+ e.printStackTrace();
+ }
+ }
+
}

Back to the top