Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkuppe2008-02-06 12:02:30 -0500
committermkuppe2008-02-06 12:02:30 -0500
commitc36e37c55163c2500ffea93f7d67fac6b7fba265 (patch)
tree8e82cec5e7d86fce8a80db908e10a6012a7c2b08 /tests/bundles/org.eclipse.ecf.tests.provider.jslp
parent406cf5138cd2cb2ff409f65e19413180ea3f8e79 (diff)
downloadorg.eclipse.ecf-c36e37c55163c2500ffea93f7d67fac6b7fba265.tar.gz
org.eclipse.ecf-c36e37c55163c2500ffea93f7d67fac6b7fba265.tar.xz
org.eclipse.ecf-c36e37c55163c2500ffea93f7d67fac6b7fba265.zip
NEW - bug 218027: [Discovery][jSLP] Provider doesn't handle scope correctly
https://bugs.eclipse.org/bugs/show_bug.cgi?id=218027
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/JSLPDiscoveryTest.java31
-rwxr-xr-xtests/bundles/org.eclipse.ecf.tests.provider.jslp/src/org/eclipse/ecf/tests/provider/jslp/JSLPTestComparator.java34
2 files changed, 56 insertions, 9 deletions
diff --git a/tests/bundles/org.eclipse.ecf.tests.provider.jslp/src/org/eclipse/ecf/tests/provider/jslp/JSLPDiscoveryTest.java b/tests/bundles/org.eclipse.ecf.tests.provider.jslp/src/org/eclipse/ecf/tests/provider/jslp/JSLPDiscoveryTest.java
index 6c21c3dbc..b770245d1 100755
--- a/tests/bundles/org.eclipse.ecf.tests.provider.jslp/src/org/eclipse/ecf/tests/provider/jslp/JSLPDiscoveryTest.java
+++ b/tests/bundles/org.eclipse.ecf.tests.provider.jslp/src/org/eclipse/ecf/tests/provider/jslp/JSLPDiscoveryTest.java
@@ -10,6 +10,7 @@
******************************************************************************/
package org.eclipse.ecf.tests.provider.jslp;
+import org.eclipse.ecf.discovery.IServiceInfo;
import org.eclipse.ecf.provider.jslp.container.JSLPDiscoveryContainer;
import org.eclipse.ecf.tests.discovery.DiscoveryTest;
@@ -35,6 +36,36 @@ public class JSLPDiscoveryTest extends DiscoveryTest {
}
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.tests.discovery.DiscoveryTest#testRegisterService()
+ */
+ public void testRegisterService() {
+ testConnect();
+ registerService();
+ // SLP discovery doesn't search in all scopes and it is not possible to query for all reachable scopes, thus we need to pass the "local" scope
+ final IServiceInfo[] services = discoveryContainer.getServices(serviceInfo.getServiceID().getServiceTypeID());
+ assertTrue(services.length >= 1);
+ for (int i = 0; i < services.length; i++) {
+ final IServiceInfo service = services[i];
+ if (comparator.compare(service, serviceInfo) == 0) {
+ return;
+ }
+ }
+ fail("Self registered service not found");
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.tests.discovery.DiscoveryTest#testGetServices()
+ */
+ public void testGetServices() {
+ testConnect();
+ registerService();
+ // SLP discovery doesn't search in all scopes and it is not possible to query for all reachable scopes, thus we need to pass the "local" scope
+ final IServiceInfo[] services = discoveryContainer.getServices(serviceInfo.getServiceID().getServiceTypeID());
+ assertTrue(services.length >= 1);
+ }
+
+
public void testJSLPLocatorNull() {
//Activator.getDefault().getLocator() == null always
fail("not yet implemented");
diff --git a/tests/bundles/org.eclipse.ecf.tests.provider.jslp/src/org/eclipse/ecf/tests/provider/jslp/JSLPTestComparator.java b/tests/bundles/org.eclipse.ecf.tests.provider.jslp/src/org/eclipse/ecf/tests/provider/jslp/JSLPTestComparator.java
index d86bc42d7..d315ac5b5 100755
--- a/tests/bundles/org.eclipse.ecf.tests.provider.jslp/src/org/eclipse/ecf/tests/provider/jslp/JSLPTestComparator.java
+++ b/tests/bundles/org.eclipse.ecf.tests.provider.jslp/src/org/eclipse/ecf/tests/provider/jslp/JSLPTestComparator.java
@@ -10,9 +10,13 @@
******************************************************************************/
package org.eclipse.ecf.tests.provider.jslp;
+import java.net.InetAddress;
+import java.net.URI;
import java.util.Arrays;
import java.util.Comparator;
+import java.util.Properties;
+import org.eclipse.ecf.core.identity.Namespace;
import org.eclipse.ecf.discovery.IServiceInfo;
import org.eclipse.ecf.discovery.identity.IServiceTypeID;
import org.eclipse.ecf.provider.jslp.identity.JSLPServiceID;
@@ -31,24 +35,36 @@ public class JSLPTestComparator implements Comparator {
IServiceInfo first = (IServiceInfo) arg0;
IServiceInfo second = (IServiceInfo) arg1;
- //TODO-mkuppe No prio, weight, scope and protocol atm in the JSLP testcase
+ //TODO-mkuppe No prio, weight and protocol atm in the JSLP testcase
JSLPServiceID firstID = (JSLPServiceID) first.getServiceID();
JSLPServiceID secondID = (JSLPServiceID) second.getServiceID();
IServiceTypeID firstTypeID = firstID.getServiceTypeID();
IServiceTypeID secondTypeID = secondID.getServiceTypeID();
boolean protocolsSame = Arrays.equals(firstTypeID.getProtocols(), secondTypeID.getProtocols());
- boolean scopesSame = Arrays.equals(firstTypeID.getScopes(), secondTypeID.getScopes());
boolean weightSame = first.getWeight() == second.getWeight();
boolean prioSame = first.getPriority() == second.getPriority();
- boolean namesSame = firstID.getAddress().equals(secondID.getAddress());
- boolean servicesSame = Arrays.equals(firstTypeID.getServices(), secondTypeID.getServices());
- boolean namespacesSame = firstID.getNamespace().equals(secondID.getNamespace());
- boolean naSame = firstTypeID.getNamingAuthority().equals(secondTypeID.getNamingAuthority());
- boolean addressesSame = first.getLocation().equals(second.getLocation());
- boolean propertiesSame = first.getServiceProperties().asProperties().equals(second.getServiceProperties().asProperties());
- boolean result = namesSame && namespacesSame && servicesSame && naSame && addressesSame && propertiesSame;
+ InetAddress firstAddress = firstID.getAddress();
+ InetAddress secondAddress = secondID.getAddress();
+ boolean addressSame = firstAddress.equals(secondAddress);
+ String[] firstServices = firstTypeID.getServices();
+ String[] secondServices = secondTypeID.getServices();
+ boolean serviceSame = Arrays.equals(firstServices, secondServices);
+ Namespace firstNamespace = firstID.getNamespace();
+ Namespace secondNamespace = secondID.getNamespace();
+ boolean namespaceSame = firstNamespace.equals(secondNamespace);
+ String firstNA = firstTypeID.getNamingAuthority();
+ String secondsSA = secondTypeID.getNamingAuthority();
+ boolean naSame = firstNA.equals(secondsSA);
+ URI firstLocation = first.getLocation();
+ URI secondLocation = second.getLocation();
+ boolean locationSame = firstLocation.equals(secondLocation);
+ Properties firstProperties = first.getServiceProperties().asProperties();
+ Properties secondProperties = second.getServiceProperties().asProperties();
+ boolean scopesSame = Arrays.equals(firstTypeID.getScopes(), secondTypeID.getScopes());
+ boolean propertySame = firstProperties.equals(secondProperties);
+ boolean result = addressSame && namespaceSame && serviceSame && naSame && locationSame && scopesSame && propertySame;
if(result == true) {
return 0;
}

Back to the top