Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkuppe2009-11-15 15:14:03 +0000
committermkuppe2009-11-15 15:14:03 +0000
commit990c722bf02794020f3158209cb32d568c3929ce (patch)
tree5bed9ae1c0071adef1a598f2ec3fe738f6409a28 /protocols
parent13aa57b2e27b41868bc959284f6c775b5e0ceed9 (diff)
downloadorg.eclipse.ecf-990c722bf02794020f3158209cb32d568c3929ce.tar.gz
org.eclipse.ecf-990c722bf02794020f3158209cb32d568c3929ce.tar.xz
org.eclipse.ecf-990c722bf02794020f3158209cb32d568c3929ce.zip
NEW - bug 295184: [Discovery][jSLP] Maven bundle build fails due to split package
https://bugs.eclipse.org/bugs/show_bug.cgi?id=295184
Diffstat (limited to 'protocols')
-rw-r--r--protocols/bundles/ch.ethz.iks.slp/runtimeTests/src/main/java/ch/ethz/iks/slp/impl/SelfDiscoveryTest.java172
-rw-r--r--protocols/bundles/ch.ethz.iks.slp/runtimeTests/src/main/java/ch/ethz/iks/slp/impl/TestActivator.java77
2 files changed, 0 insertions, 249 deletions
diff --git a/protocols/bundles/ch.ethz.iks.slp/runtimeTests/src/main/java/ch/ethz/iks/slp/impl/SelfDiscoveryTest.java b/protocols/bundles/ch.ethz.iks.slp/runtimeTests/src/main/java/ch/ethz/iks/slp/impl/SelfDiscoveryTest.java
deleted file mode 100644
index e1ff0e6f6..000000000
--- a/protocols/bundles/ch.ethz.iks.slp/runtimeTests/src/main/java/ch/ethz/iks/slp/impl/SelfDiscoveryTest.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Versant Corp.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Markus Kuppe (mkuppe <at> versant <dot> com) - initial API and implementation
- ******************************************************************************/
-package ch.ethz.iks.slp.impl;
-
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.Hashtable;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-import ch.ethz.iks.slp.ServiceLocationEnumeration;
-import ch.ethz.iks.slp.ServiceLocationException;
-import ch.ethz.iks.slp.ServiceType;
-import ch.ethz.iks.slp.ServiceURL;
-
-public class SelfDiscoveryTest extends TestCase {
-
- private final String HOST_AND_PORT = System.getProperty("net.slp.tests.hostAndPort", "gantenbein:123");
- private ServiceURL service;
- private Dictionary properties;
-
- public SelfDiscoveryTest() {
- super("runTests");
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
- public void setUp() throws InterruptedException {
- try {
- service = new ServiceURL("service:osgi://" + HOST_AND_PORT, 10800);
- int i = 0;
- properties = new Hashtable();
- properties.put("attr", Boolean.FALSE);
- properties.put("attr" + i++, "value");
- properties.put("attr" + i++, "foo,bar");
- properties.put("attr" + i++, "foo:bar");
- properties.put("attr" + i++, "foo bar");
- TestActivator.advertiser.register(service, properties);
- } catch (ServiceLocationException e) {
- Assert.fail(e.getMessage());
- e.printStackTrace();
- }
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
- public void tearDown() throws InterruptedException {
- try {
- TestActivator.advertiser.deregister(service);
- } catch (ServiceLocationException e) {
- Assert.fail(e.getMessage());
- e.printStackTrace();
- }
- }
-
- public void runTests() throws Exception {
- testService();
- testAttributes();
- testFilter();
- testFilterWithWildcard();
- testFilterWithBrokenParenthesis();
- }
-
- /**
- * Test method for
- * {@link ch.ethz.iks.slp.Locator}.
- */
- public void testService() throws Exception {
- int count = 0;
- for (ServiceLocationEnumeration services = TestActivator.locator
- .findServices(new ServiceType("service:osgi"), null, null); services
- .hasMoreElements();) {
- assertEquals(services.next().toString(),
- "service:osgi://" + HOST_AND_PORT);
- count++;
- }
- assertEquals(1, count);
- }
-
- /**
- * Test method for
- * {@link ch.ethz.iks.slp.Locator}.
- */
- public void testAttributes() throws Exception {
- int count = 0;
-
- // not fast but DRY
- outter:
- for (ServiceLocationEnumeration attributes = TestActivator.locator
- .findAttributes(new ServiceType("service:osgi"), null, null); attributes
- .hasMoreElements();) {
- final String attribute = attributes.next().toString();
-
- // inner loop over the dict
- Enumeration elements = properties.keys();
- for(;elements.hasMoreElements();) {
- String key= elements.nextElement().toString();
- String value = properties.get(key).toString();
- if(attribute.equals(("(" + key + "=" + value + ")"))) {
- count++;
- continue outter;
- }
- }
- fail(attribute + " not found in reference " + properties.toString());
- }
- assertEquals(properties.size(), count);
- }
-
- /**
- * Test method for
- * {@link ch.ethz.iks.slp.Locator}.
- */
- public void testFilter() throws Exception {
- int count = 0;
- for (ServiceLocationEnumeration services = TestActivator.locator
- .findServices(new ServiceType("service:osgi"), null,
- "(attr=false)"); services.hasMoreElements();) {
- assertEquals(services.next().toString(),
- "service:osgi://" + HOST_AND_PORT);
- count++;
- }
- assertEquals(1, count);
- }
-
- /**
- * Test method for
- * {@link ch.ethz.iks.slp.Locator}.
- */
- public void testFilterWithWildcard() throws Exception {
- int count = 0;
- for (ServiceLocationEnumeration services = TestActivator.locator
- .findServices(new ServiceType("service:osgi"), null, "(attr=*)"); services
- .hasMoreElements();) {
- assertEquals(services.next().toString(),
- "service:osgi://" + HOST_AND_PORT);
- count++;
- }
- assertEquals(1, count);
- }
-
-
- /**
- * Test method for
- * {@link ch.ethz.iks.slp.Locator}.
- *
- * [1] http://www.faqs.org/rfcs/rfc1960.html
- * Cite: If a <value> must contain one of the characters '*' or '(' or ')', these
- * characters should be escaped by preceding them with the backslash '\' character.
- */
- public void testFilterWithBrokenParenthesis() throws Exception {
- try {
- // correct filter is (service-type=\(service:osgi\))
- TestActivator.locator.findServices(new ServiceType("service:osgi"), null,
- "(service-type=(service:osgi))");
- } catch (ServiceLocationException e) {
- if(e.getErrorCode() == 20) {
- return;
- }
- }
- fail();
- }
-}
diff --git a/protocols/bundles/ch.ethz.iks.slp/runtimeTests/src/main/java/ch/ethz/iks/slp/impl/TestActivator.java b/protocols/bundles/ch.ethz.iks.slp/runtimeTests/src/main/java/ch/ethz/iks/slp/impl/TestActivator.java
deleted file mode 100644
index 2b11f6fe5..000000000
--- a/protocols/bundles/ch.ethz.iks.slp/runtimeTests/src/main/java/ch/ethz/iks/slp/impl/TestActivator.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package ch.ethz.iks.slp.impl;
-
-import java.util.Enumeration;
-
-import junit.framework.TestFailure;
-import junit.framework.TestResult;
-import junit.textui.TestRunner;
-
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-
-import ch.ethz.iks.slp.Advertiser;
-import ch.ethz.iks.slp.Locator;
-
-public class TestActivator implements BundleActivator {
-
- static Advertiser advertiser;
- static Locator locator;
-
- public void start(BundleContext context) throws Exception {
- ServiceReference advertiserRef = null;
- try {
- ServiceReference[] aSrefs = context
- .getServiceReferences(Advertiser.class.getName(), null);
- for (int i = 0; i < aSrefs.length; i++) {
- ServiceReference serviceReference = aSrefs[i];
- String version = (String) serviceReference.getBundle().getHeaders().get("Bundle-Version");
- if(version.equals(System.getProperty("net.slp.versionUnderTest"))) {
- advertiserRef = serviceReference;
- } else {
- context.getService(serviceReference);
- }
- }
-
- advertiser = (Advertiser) context.getService(advertiserRef);
- locator = (Locator) context.getService(context
- .getServiceReference(Locator.class.getName()));
- } catch (Exception e) {
- System.exit(1);
- }
-
- startTests();
- }
-
- private void startTests() {
- TestResult result = TestRunner.run(new SelfDiscoveryTest());
- if (result.wasSuccessful()) {
- System.exit(0);
- } else {
- if (result.errorCount() > 0) {
- System.err.println("Errors:");
- for (Enumeration errors = result.errors(); errors
- .hasMoreElements();) {
- TestFailure error = (TestFailure) errors.nextElement();
- System.err.println(error.trace());
- }
- }
- if (result.failureCount() > 0) {
- System.err.println("Failures:");
- for (Enumeration failures = result.failures(); failures
- .hasMoreElements();) {
- TestFailure failure = (TestFailure) failures.nextElement();
- System.err.println(failure.trace());
- }
- }
- System.exit(1);
- }
-
- }
-
- public void stop(BundleContext context) throws Exception {
- advertiser = null;
- locator = null;
- }
-
-}

Back to the top