Search in sources :

Example 11 with ServiceURL

use of ch.ethz.iks.slp.ServiceURL in project ecf by eclipse.

the class JSLPServiceIDTest method testCreateByjSLPAndRemoveServicePrefixWithServiceService.

/* (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.eclipse:foo:bar";
    final ServiceURL sUrl = new ServiceURL(internalRep + "://localhost:1234/a/path/to/something", ServiceURL.LIFETIME_PERMANENT);
    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(serviceInfo.getServiceName(), DiscoveryTestHelper.SERVICENAME);
    final IServiceTypeID stid = sid.getServiceTypeID();
    assertEquals(internalRep, stid.getInternal());
    assertEquals("_service._foo._bar._" + IServiceTypeID.DEFAULT_PROTO[0] + "." + IServiceTypeID.DEFAULT_SCOPE[0] + "._eclipse", stid.getName());
    assertEquals("eclipse", stid.getNamingAuthority());
    assertTrue(Arrays.equals(new String[] { "service", "foo", "bar" }, stid.getServices()));
    assertTrue(Arrays.equals(IServiceTypeID.DEFAULT_SCOPE, stid.getScopes()));
    assertTrue(Arrays.equals(IServiceTypeID.DEFAULT_PROTO, stid.getProtocols()));
}
Also used : IServiceTypeID(org.eclipse.ecf.discovery.identity.IServiceTypeID) ServiceURLAdapter(org.eclipse.ecf.internal.provider.jslp.ServiceURLAdapter) JSLPServiceInfo(org.eclipse.ecf.provider.jslp.container.JSLPServiceInfo) ServicePropertiesAdapter(org.eclipse.ecf.internal.provider.jslp.ServicePropertiesAdapter) IServiceInfo(org.eclipse.ecf.discovery.IServiceInfo) IServiceID(org.eclipse.ecf.discovery.identity.IServiceID) ArrayList(java.util.ArrayList) ServiceURL(ch.ethz.iks.slp.ServiceURL)

Example 12 with ServiceURL

use of ch.ethz.iks.slp.ServiceURL in project ecf by eclipse.

the class ServiceURLTest method testServiceURLNamingAuthorityIana.

public void testServiceURLNamingAuthorityIana() throws Exception {
    String urlString = "service:test.iana://http://localhost";
    ServiceURL url = new ServiceURL(urlString, 0);
    assertEquals(url.getServiceType().toString(), "service:test");
    assertEquals(url.getHost(), "localhost");
    assertEquals(url.getPort(), 0);
    assertEquals(url.getURLPath(), "");
    assertEquals(url.getUserInfo(), "");
    assertEquals(url.getProtocol(), "http");
    assertEquals(url.toString(), "service:test://http://localhost");
    assertTrue("".equals(url.getServiceType().getNamingAuthority()));
}
Also used : ServiceURL(ch.ethz.iks.slp.ServiceURL)

Example 13 with ServiceURL

use of ch.ethz.iks.slp.ServiceURL in project ecf by eclipse.

the class ServiceURLTest method testServiceURL258252a.

// https://bugs.eclipse.org/258252
public void testServiceURL258252a() throws Exception {
    String urlString = "service:test:myservice://localhost:80/my:path";
    ServiceURL url = new ServiceURL(urlString, 0);
    assertEquals(url.getServiceType().toString(), "service:test:myservice");
    assertEquals(url.getHost(), "localhost");
    assertEquals(url.getPort(), 80);
    assertEquals(url.getURLPath(), "/my:path");
    assertEquals(url.getUserInfo(), "");
    assertEquals(url.getProtocol(), null);
    assertEquals(url.toString(), urlString);
}
Also used : ServiceURL(ch.ethz.iks.slp.ServiceURL)

Example 14 with ServiceURL

use of ch.ethz.iks.slp.ServiceURL in project ecf by eclipse.

the class ServiceURLTest method testServiceURL5.

public void testServiceURL5() throws Exception {
    String urlString = "service:test:myservice://http://localhost:8080/my/path";
    ServiceURL url = new ServiceURL(urlString, 0);
    assertEquals(url.getServiceType().toString(), "service:test:myservice");
    assertEquals(url.getHost(), "localhost");
    assertEquals(url.getPort(), 8080);
    assertEquals(url.getURLPath(), "/my/path");
    assertEquals(url.getUserInfo(), "");
    assertEquals(url.getProtocol(), "http");
    assertEquals(url.toString(), urlString);
}
Also used : ServiceURL(ch.ethz.iks.slp.ServiceURL)

Example 15 with ServiceURL

use of ch.ethz.iks.slp.ServiceURL in project ecf by eclipse.

the class ServiceURLTest method testServiceURL6.

public void testServiceURL6() throws Exception {
    String urlString = "service:test://http://localhost";
    ServiceURL url = new ServiceURL(urlString, 0);
    assertEquals(url.getServiceType().toString(), "service:test");
    assertEquals(url.getHost(), "localhost");
    assertEquals(url.getPort(), 0);
    assertEquals(url.getURLPath(), "");
    assertEquals(url.getUserInfo(), "");
    assertEquals(url.getProtocol(), "http");
    assertEquals(url.toString(), urlString);
}
Also used : ServiceURL(ch.ethz.iks.slp.ServiceURL)

Aggregations

ServiceURL (ch.ethz.iks.slp.ServiceURL)23 ServiceLocationException (ch.ethz.iks.slp.ServiceLocationException)4 ArrayList (java.util.ArrayList)4 IServiceInfo (org.eclipse.ecf.discovery.IServiceInfo)3 IServiceTypeID (org.eclipse.ecf.discovery.identity.IServiceTypeID)3 JSLPServiceInfo (org.eclipse.ecf.provider.jslp.container.JSLPServiceInfo)3 ServiceType (ch.ethz.iks.slp.ServiceType)2 URI (java.net.URI)2 Iterator (java.util.Iterator)2 List (java.util.List)2 IServiceID (org.eclipse.ecf.discovery.identity.IServiceID)2 ServicePropertiesAdapter (org.eclipse.ecf.internal.provider.jslp.ServicePropertiesAdapter)2 ServiceURLAdapter (org.eclipse.ecf.internal.provider.jslp.ServiceURLAdapter)2 Hashtable (java.util.Hashtable)1 Entry (java.util.Map.Entry)1