Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkuppe2009-03-10 12:04:48 -0400
committermkuppe2009-03-10 12:04:48 -0400
commitfb5f83480e1e2e7efe8fa3190df85eb4492f6028 (patch)
tree547cd846b977ecd9198c9e25f1772db2c1abb63f /tests/bundles/org.eclipse.ecf.tests.provider.jslp
parentd7b34eccaa723bfcee63ba5b6a46baba7ead64ea (diff)
downloadorg.eclipse.ecf-fb5f83480e1e2e7efe8fa3190df85eb4492f6028.tar.gz
org.eclipse.ecf-fb5f83480e1e2e7efe8fa3190df85eb4492f6028.tar.xz
org.eclipse.ecf-fb5f83480e1e2e7efe8fa3190df85eb4492f6028.zip
NEW - bug 266723: [Discovery] specify how clients can determine service uniqueness
https://bugs.eclipse.org/bugs/show_bug.cgi?id=266723
Diffstat (limited to 'tests/bundles/org.eclipse.ecf.tests.provider.jslp')
-rwxr-xr-xtests/bundles/org.eclipse.ecf.tests.provider.jslp/src/org/eclipse/ecf/tests/provider/jslp/JSLPServiceInfoTest.java28
-rwxr-xr-xtests/bundles/org.eclipse.ecf.tests.provider.jslp/src/org/eclipse/ecf/tests/provider/jslp/identity/JSLPServiceIDTest.java48
2 files changed, 18 insertions, 58 deletions
diff --git a/tests/bundles/org.eclipse.ecf.tests.provider.jslp/src/org/eclipse/ecf/tests/provider/jslp/JSLPServiceInfoTest.java b/tests/bundles/org.eclipse.ecf.tests.provider.jslp/src/org/eclipse/ecf/tests/provider/jslp/JSLPServiceInfoTest.java
index 93b234e31..d0ec2a629 100755
--- a/tests/bundles/org.eclipse.ecf.tests.provider.jslp/src/org/eclipse/ecf/tests/provider/jslp/JSLPServiceInfoTest.java
+++ b/tests/bundles/org.eclipse.ecf.tests.provider.jslp/src/org/eclipse/ecf/tests/provider/jslp/JSLPServiceInfoTest.java
@@ -10,39 +10,13 @@
******************************************************************************/
package org.eclipse.ecf.tests.provider.jslp;
-import org.eclipse.ecf.core.identity.IDCreateException;
import org.eclipse.ecf.core.identity.IDFactory;
-import org.eclipse.ecf.core.identity.Namespace;
-import org.eclipse.ecf.discovery.IServiceInfo;
-import org.eclipse.ecf.discovery.ServiceProperties;
-import org.eclipse.ecf.discovery.identity.IServiceID;
-import org.eclipse.ecf.provider.jslp.container.JSLPServiceInfo;
import org.eclipse.ecf.provider.jslp.identity.JSLPNamespace;
-import org.eclipse.ecf.tests.discovery.DiscoveryTestHelper;
import org.eclipse.ecf.tests.discovery.ServiceInfoTest;
public class JSLPServiceInfoTest extends ServiceInfoTest {
public JSLPServiceInfoTest() {
- super();
- uri = DiscoveryTestHelper.createDefaultURI();
- priority = DiscoveryTestHelper.PRIORITY;
- weight = DiscoveryTestHelper.WEIGHT;
- serviceProperties = new ServiceProperties();
- serviceProperties.setProperty("foobar", new String("foobar"));
- Namespace namespace = IDFactory.getDefault().getNamespaceByName(
- JSLPNamespace.NAME);
- try {
- serviceID = (IServiceID) IDFactory.getDefault().createID(namespace,
- new Object[] {DiscoveryTestHelper.SERVICE_TYPE, DiscoveryTestHelper.getHost()});
- } catch (IDCreateException e) {
- fail(e.getMessage());
- }
- serviceInfo = new JSLPServiceInfo(uri, serviceID, priority, weight,
- serviceProperties);
- }
-
- protected IServiceInfo getServiceInfo(IServiceInfo aServiceInfo) {
- return new JSLPServiceInfo(aServiceInfo);
+ super(IDFactory.getDefault().getNamespaceByName(JSLPNamespace.NAME));
}
}
diff --git a/tests/bundles/org.eclipse.ecf.tests.provider.jslp/src/org/eclipse/ecf/tests/provider/jslp/identity/JSLPServiceIDTest.java b/tests/bundles/org.eclipse.ecf.tests.provider.jslp/src/org/eclipse/ecf/tests/provider/jslp/identity/JSLPServiceIDTest.java
index fa41347f5..a2260b5b4 100755
--- a/tests/bundles/org.eclipse.ecf.tests.provider.jslp/src/org/eclipse/ecf/tests/provider/jslp/identity/JSLPServiceIDTest.java
+++ b/tests/bundles/org.eclipse.ecf.tests.provider.jslp/src/org/eclipse/ecf/tests/provider/jslp/identity/JSLPServiceIDTest.java
@@ -23,7 +23,6 @@ import org.eclipse.ecf.internal.provider.jslp.ServicePropertiesAdapter;
import org.eclipse.ecf.internal.provider.jslp.ServiceURLAdapter;
import org.eclipse.ecf.provider.jslp.container.JSLPServiceInfo;
import org.eclipse.ecf.provider.jslp.identity.JSLPNamespace;
-import org.eclipse.ecf.provider.jslp.identity.JSLPServiceTypeID;
import org.eclipse.ecf.tests.discovery.DiscoveryTestHelper;
import org.eclipse.ecf.tests.discovery.identity.ServiceIDTest;
@@ -41,8 +40,7 @@ public class JSLPServiceIDTest extends ServiceIDTest {
*/
public void testCreateServiceTypeIDWithProviderSpecificString() {
final String internalRep = "service:foo.eclipse:bar";
- final IServiceID sid = (IServiceID) createIDFromString(internalRep);
- final IServiceTypeID stid = sid.getServiceTypeID();
+ IServiceTypeID stid = (IServiceTypeID) new JSLPNamespace().createInstance(new Object[]{internalRep});
assertEquals(internalRep, stid.getInternal());
assertTrue(stid.getName().startsWith("_foo._bar"));
@@ -60,10 +58,9 @@ public class JSLPServiceIDTest extends ServiceIDTest {
* test from ECF discovery -> jSLP
*/
public void testRemoveServicePrefixECFtojSLP() throws ServiceLocationException {
- final IServiceID sid = (IServiceID) createIDFromString(DiscoveryTestHelper.SERVICE_TYPE);
- final JSLPServiceTypeID stid = (JSLPServiceTypeID) sid.getServiceTypeID();
+ final IServiceTypeID stid = (IServiceTypeID) createIDFromString(DiscoveryTestHelper.SERVICE_TYPE);
- assertEquals("service:" + DiscoveryTestHelper.SERVICES[0] + ":" + DiscoveryTestHelper.SERVICES[1] + "." + DiscoveryTestHelper.NAMINGAUTHORITY + ":" + DiscoveryTestHelper.SERVICES[2], stid.getInternal());
+ assertEquals("service:" + DiscoveryTestHelper.SERVICES[0] + "." + DiscoveryTestHelper.NAMINGAUTHORITY + ":" + DiscoveryTestHelper.SERVICES[1] + ":" + DiscoveryTestHelper.SERVICES[2], stid.getInternal());
assertEquals(DiscoveryTestHelper.SERVICE_TYPE, stid.getName());
assertEquals(DiscoveryTestHelper.NAMINGAUTHORITY, stid.getNamingAuthority());
@@ -81,11 +78,11 @@ public class JSLPServiceIDTest extends ServiceIDTest {
final String internalRep = "service:foo.eclipse:bar";
final ServiceURL sUrl = new ServiceURL(internalRep + "://localhost:1234/a/path/to/something", ServiceURL.LIFETIME_PERMANENT);
- final IServiceInfo serviceInfo = new JSLPServiceInfo(new ServiceURLAdapter(sUrl, DiscoveryTestHelper.SERVICENAME), DiscoveryTestHelper.PRIORITY, DiscoveryTestHelper.WEIGHT, new ServicePropertiesAdapter(new ArrayList()));
+ final IServiceInfo serviceInfo = new JSLPServiceInfo(DiscoveryTestHelper.SERVICENAME, new ServiceURLAdapter(sUrl), DiscoveryTestHelper.PRIORITY, DiscoveryTestHelper.WEIGHT, new ServicePropertiesAdapter(new ArrayList()));
assertEquals(serviceInfo.getPriority(), DiscoveryTestHelper.PRIORITY);
assertEquals(serviceInfo.getWeight(), DiscoveryTestHelper.WEIGHT);
final IServiceID sid = serviceInfo.getServiceID();
- assertEquals(sid.getServiceName(), DiscoveryTestHelper.SERVICENAME);
+ assertEquals(serviceInfo.getServiceName(), DiscoveryTestHelper.SERVICENAME);
final IServiceTypeID stid = sid.getServiceTypeID();
String internal = stid.getInternal();
@@ -104,14 +101,14 @@ public class JSLPServiceIDTest extends ServiceIDTest {
* test from jSLP -> ECF discovery which needs to remove the first occurrence of "service:"
*/
public void testCreateByjSLPAndRemoveServicePrefixWithServiceService() throws ServiceLocationException {
- final String internalRep = "service:service:foo.eclipse:bar";
+ final String internalRep = "service:service.eclipse:foo:bar";
final ServiceURL sUrl = new ServiceURL(internalRep + "://localhost:1234/a/path/to/something", ServiceURL.LIFETIME_PERMANENT);
- final IServiceInfo serviceInfo = new JSLPServiceInfo(new ServiceURLAdapter(sUrl, DiscoveryTestHelper.SERVICENAME), DiscoveryTestHelper.PRIORITY, DiscoveryTestHelper.WEIGHT, new ServicePropertiesAdapter(new ArrayList()));
+ final IServiceInfo serviceInfo = new JSLPServiceInfo(DiscoveryTestHelper.SERVICENAME, new ServiceURLAdapter(sUrl), DiscoveryTestHelper.PRIORITY, DiscoveryTestHelper.WEIGHT, new ServicePropertiesAdapter(new ArrayList()));
assertEquals(serviceInfo.getPriority(), DiscoveryTestHelper.PRIORITY);
assertEquals(serviceInfo.getWeight(), DiscoveryTestHelper.WEIGHT);
final IServiceID sid = serviceInfo.getServiceID();
- assertEquals(sid.getServiceName(), DiscoveryTestHelper.SERVICENAME);
+ assertEquals(serviceInfo.getServiceName(), DiscoveryTestHelper.SERVICENAME);
final IServiceTypeID stid = sid.getServiceTypeID();
assertEquals(internalRep, stid.getInternal());
@@ -128,8 +125,7 @@ public class JSLPServiceIDTest extends ServiceIDTest {
*/
public void testCreateServiceTypeIDFromSLPStringWithDefaultNamingAuthority() {
final String internalRep = "service:foo.iana:bar";
- final IServiceID sid = (IServiceID) createIDFromString(internalRep);
- final IServiceTypeID stid = sid.getServiceTypeID();
+ final IServiceTypeID stid = (IServiceTypeID) new JSLPNamespace().createInstance(new Object[]{internalRep});
// the internalRep contains "iana" but getInternal may not!
final int indexOf = stid.getInternal().toLowerCase().indexOf("iana");
@@ -139,13 +135,9 @@ public class JSLPServiceIDTest extends ServiceIDTest {
}
public void testECFDefaultsTojSLP() {
- String expected = "some Name";
-
Namespace namespaceByName = IDFactory.getDefault().getNamespaceByName(namespace);
- IServiceID aServiceID = ServiceIDFactory.getDefault().createServiceID(namespaceByName, DiscoveryTestHelper.SERVICES, DiscoveryTestHelper.PROTOCOLS, expected);
- assertNotNull(aServiceID);
-
- IServiceTypeID stid = aServiceID.getServiceTypeID();
+ IServiceTypeID stid = ServiceIDFactory.getDefault().createServiceTypeID(namespaceByName, DiscoveryTestHelper.SERVICES, DiscoveryTestHelper.PROTOCOLS);
+ assertNotNull(stid);
assertTrue(Arrays.equals(DiscoveryTestHelper.SERVICES, stid.getServices()));
assertTrue(Arrays.equals(IServiceTypeID.DEFAULT_SCOPE, stid.getScopes()));
assertTrue(Arrays.equals(DiscoveryTestHelper.PROTOCOLS, stid.getProtocols()));
@@ -155,24 +147,18 @@ public class JSLPServiceIDTest extends ServiceIDTest {
}
public void testjSLPDefaultsToECF() {
- String expected = "some Name";
Namespace namespaceByName = IDFactory.getDefault().getNamespaceByName(namespace);
- IServiceID aServiceID = ServiceIDFactory.getDefault().createServiceID(namespaceByName, DiscoveryTestHelper.SERVICES, new String[]{DiscoveryTestHelper.SCOPE}, DiscoveryTestHelper.PROTOCOLS, DiscoveryTestHelper.NAMINGAUTHORITY, expected);
- assertNotNull(aServiceID);
-
- IServiceTypeID stid = aServiceID.getServiceTypeID();
+ IServiceTypeID stid = ServiceIDFactory.getDefault().createServiceTypeID(namespaceByName, DiscoveryTestHelper.SERVICES, new String[]{DiscoveryTestHelper.SCOPE}, DiscoveryTestHelper.PROTOCOLS, DiscoveryTestHelper.NAMINGAUTHORITY);
+ assertNotNull(stid);
assertEquals(DiscoveryTestHelper.NAMINGAUTHORITY, stid.getNamingAuthority());
- assertEquals("_ecf._junit._tests._someProtocol." + DiscoveryTestHelper.SCOPE + "._" + DiscoveryTestHelper.NAMINGAUTHORITY + "@" + expected, aServiceID.getName());
+ assertEquals("_ecf._junit._tests._someProtocol." + DiscoveryTestHelper.SCOPE + "._" + DiscoveryTestHelper.NAMINGAUTHORITY, stid.getName());
}
public void testjSLPDefaultsToECF2() {
- String expected = "some Name";
Namespace namespaceByName = IDFactory.getDefault().getNamespaceByName(namespace);
- IServiceID aServiceID = ServiceIDFactory.getDefault().createServiceID(namespaceByName, DiscoveryTestHelper.SERVICES, DiscoveryTestHelper.PROTOCOLS, expected);
- assertNotNull(aServiceID);
-
- IServiceTypeID stid = aServiceID.getServiceTypeID();
+ IServiceTypeID stid = ServiceIDFactory.getDefault().createServiceTypeID(namespaceByName, DiscoveryTestHelper.SERVICES, DiscoveryTestHelper.PROTOCOLS);
+ assertNotNull(stid);
assertEquals(IServiceTypeID.DEFAULT_NA, stid.getNamingAuthority());
- assertEquals("_ecf._junit._tests._someProtocol." + IServiceTypeID.DEFAULT_SCOPE[0] + "._" + IServiceTypeID.DEFAULT_NA + "@" + expected, aServiceID.getName());
+ assertEquals("_ecf._junit._tests._someProtocol." + IServiceTypeID.DEFAULT_SCOPE[0] + "._" + IServiceTypeID.DEFAULT_NA, stid.getName());
}
}

Back to the top