Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkuppe2008-06-02 07:40:03 -0400
committermkuppe2008-06-02 07:40:03 -0400
commit01a2e8d4c47eb631416ae72c5d91a2d5917b83b1 (patch)
treeb50499609baee3e160eeb997dd0019c8b22f801a /tests/bundles/org.eclipse.ecf.tests.provider.jslp
parenteeedbe377b91f8e235d28456e752999b094a227a (diff)
downloadorg.eclipse.ecf-01a2e8d4c47eb631416ae72c5d91a2d5917b83b1.tar.gz
org.eclipse.ecf-01a2e8d4c47eb631416ae72c5d91a2d5917b83b1.tar.xz
org.eclipse.ecf-01a2e8d4c47eb631416ae72c5d91a2d5917b83b1.zip
RESOLVED - bug 218310: [Discovery][jSLP] ServiceType in jSLP always starts with "_service."
https://bugs.eclipse.org/bugs/show_bug.cgi?id=218310 FORWARD PORT from Revision_2_0
Diffstat (limited to 'tests/bundles/org.eclipse.ecf.tests.provider.jslp')
-rwxr-xr-xtests/bundles/org.eclipse.ecf.tests.provider.jslp/META-INF/MANIFEST.MF3
-rwxr-xr-xtests/bundles/org.eclipse.ecf.tests.provider.jslp/src/org/eclipse/ecf/tests/provider/jslp/identity/JSLPServiceIDTest.java79
2 files changed, 78 insertions, 4 deletions
diff --git a/tests/bundles/org.eclipse.ecf.tests.provider.jslp/META-INF/MANIFEST.MF b/tests/bundles/org.eclipse.ecf.tests.provider.jslp/META-INF/MANIFEST.MF
index 0d7d8c77a..35d7b4726 100755
--- a/tests/bundles/org.eclipse.ecf.tests.provider.jslp/META-INF/MANIFEST.MF
+++ b/tests/bundles/org.eclipse.ecf.tests.provider.jslp/META-INF/MANIFEST.MF
@@ -10,7 +10,8 @@ Require-Bundle: org.junit,
org.eclipse.ecf.discovery,
org.eclipse.equinox.common,
org.eclipse.ecf.tests.discovery,
- org.eclipse.ecf.provider.jslp
+ org.eclipse.ecf.provider.jslp,
+ ch.ethz.iks.slp;bundle-version="1.0.0"
Bundle-Vendor: %plugin.provider
Bundle-RequiredExecutionEnvironment: CDC-1.1/Foundation-1.1,
J2SE-1.4
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 c7d808662..59839a8b9 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
@@ -10,13 +10,22 @@
******************************************************************************/
package org.eclipse.ecf.tests.provider.jslp.identity;
+import java.util.ArrayList;
import java.util.Arrays;
+import org.eclipse.ecf.discovery.IServiceInfo;
import org.eclipse.ecf.discovery.identity.IServiceID;
import org.eclipse.ecf.discovery.identity.IServiceTypeID;
+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.identity.ServiceIDTest;
+import ch.ethz.iks.slp.ServiceLocationException;
+import ch.ethz.iks.slp.ServiceURL;
+
public class JSLPServiceIDTest extends ServiceIDTest {
private static final String IANA = "iana";
@@ -28,13 +37,77 @@ public class JSLPServiceIDTest extends ServiceIDTest {
/* (non-Javadoc)
* @see org.eclipse.ecf.tests.discovery.identity.ServiceIDTest#testCreateServiceTypeIDFromInternalString()
*/
- public void testCreateServiceTypeIDFromInternalString() {
+ public void testCreateServiceTypeIDWithProviderSpecificString() {
final String internalRep = "service:foo.eclipse:bar";
final IServiceID sid = (IServiceID) createIDFromString(internalRep);
final IServiceTypeID stid = sid.getServiceTypeID();
assertEquals(internalRep, stid.getInternal());
- assertNotSame(internalRep, stid.getName());
+ assertTrue(stid.getName().startsWith("_foo._bar"));
+ assertTrue(stid.getName().endsWith("._eclipse"));
+
+ assertEquals("eclipse", stid.getNamingAuthority());
+ assertTrue(Arrays.equals(new String[] {"foo", "bar"}, stid.getServices()));
+ assertTrue(Arrays.equals(new String[] {"default"}, stid.getScopes()));
+ assertTrue(Arrays.equals(new String[] {"unknown"}, stid.getProtocols()));
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.tests.discovery.identity.ServiceIDTest#testCreateServiceTypeIDFromInternalString()
+ *
+ * test from ECF discovery -> jSLP
+ */
+ public void testRemoveServicePrefixECFtojSLP() throws ServiceLocationException {
+ final IServiceID sid = (IServiceID) createIDFromString(SERVICE_TYPE);
+ final JSLPServiceTypeID stid = (JSLPServiceTypeID) sid.getServiceTypeID();
+
+ assertEquals("service:" + SERVICES[0] + ":" + SERVICES[1] + ":" + SERVICES[2], stid.getInternal());
+ assertEquals(SERVICE_TYPE, stid.getName());
+
+ assertEquals(NAMINGAUTHORITY, stid.getNamingAuthority());
+ assertTrue(Arrays.equals(SERVICES, stid.getServices()));
+ assertTrue(Arrays.equals(new String[] {SCOPE}, stid.getScopes()));
+ assertTrue(Arrays.equals(new String[] {PROTOCOL}, stid.getProtocols()));
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.tests.discovery.identity.ServiceIDTest#testCreateServiceTypeIDFromInternalString()
+ *
+ * test from jSLP -> ECF discovery which needs to remove the first occurrence of "service:"
+ */
+ public void testCreateByjSLPAndRemoveServicePrefix() throws ServiceLocationException {
+ 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), -1, -1, new ServicePropertiesAdapter(new ArrayList()));
+ final IServiceID sid = serviceInfo.getServiceID();
+ final IServiceTypeID stid = sid.getServiceTypeID();
+
+ String internal = stid.getInternal();
+ assertEquals(internalRep, internal);
+ assertEquals("_foo._bar._unknown.default._eclipse", stid.getName());
+
+ assertEquals("eclipse", stid.getNamingAuthority());
+ assertTrue(Arrays.equals(new String[] {"foo", "bar"}, stid.getServices()));
+ assertTrue(Arrays.equals(new String[] {"default"}, stid.getScopes()));
+ assertTrue(Arrays.equals(new String[] {"unknown"}, stid.getProtocols()));
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.tests.discovery.identity.ServiceIDTest#testRemoveServicePrefixWithServiceService()
+ *
+ * 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 ServiceURL sUrl = new ServiceURL(internalRep + "://localhost:1234/a/path/to/something", ServiceURL.LIFETIME_PERMANENT);
+
+ final IServiceInfo serviceInfo = new JSLPServiceInfo(new ServiceURLAdapter(sUrl), -1, -1, new ServicePropertiesAdapter(new ArrayList()));
+ final IServiceID sid = serviceInfo.getServiceID();
+ final IServiceTypeID stid = sid.getServiceTypeID();
+
+ assertEquals(internalRep, stid.getInternal());
+ assertEquals("_service._foo._bar._unknown.default._eclipse", stid.getName());
assertEquals("eclipse", stid.getNamingAuthority());
assertTrue(Arrays.equals(new String[] {"service", "foo", "bar"}, stid.getServices()));
@@ -45,7 +118,7 @@ public class JSLPServiceIDTest extends ServiceIDTest {
/* (non-Javadoc)
* @see org.eclipse.ecf.tests.discovery.identity.ServiceIDTest#testCreateServiceTypeIDFromInternalString()
*/
- public void testCreateServiceTypeIDFromInternalStringWithDefaultNamingAuthority() {
+ public void testCreateServiceTypeIDFromSLPStringWithDefaultNamingAuthority() {
final String internalRep = "service:foo." + IANA + ":bar";
final IServiceID sid = (IServiceID) createIDFromString(internalRep);
final IServiceTypeID stid = sid.getServiceTypeID();

Back to the top