You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by cs...@apache.org on 2016/03/11 20:43:48 UTC

[49/50] [abbrv] aries-rsa git commit: Switching to aries package names

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/5f4c6604/discovery/local/src/test/java/org/apache/aries/rsa/discovery/endpoint/EndpointDescriptionBundleParserTest.java
----------------------------------------------------------------------
diff --git a/discovery/local/src/test/java/org/apache/aries/rsa/discovery/endpoint/EndpointDescriptionBundleParserTest.java b/discovery/local/src/test/java/org/apache/aries/rsa/discovery/endpoint/EndpointDescriptionBundleParserTest.java
new file mode 100644
index 0000000..06afb0a
--- /dev/null
+++ b/discovery/local/src/test/java/org/apache/aries/rsa/discovery/endpoint/EndpointDescriptionBundleParserTest.java
@@ -0,0 +1,171 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.rsa.discovery.endpoint;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Pattern;
+
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import junit.framework.TestCase;
+
+import org.apache.aries.rsa.discovery.endpoint.EndpointDescriptionBundleParser;
+import org.easymock.EasyMock;
+import org.osgi.framework.Bundle;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
+
+public class EndpointDescriptionBundleParserTest extends TestCase {
+
+    private Bundle createBundleContaining(URL ed1URL) {
+        Bundle b = EasyMock.createNiceMock(Bundle.class);
+        EasyMock.expect(b.findEntries(
+            EasyMock.eq("OSGI-INF/remote-service"),
+            EasyMock.eq("*.xml"), EasyMock.anyBoolean())).andReturn(
+                Collections.enumeration(Arrays.asList(ed1URL))).anyTimes();
+        EasyMock.replay(b);
+        return b;
+    }
+
+    public void testAllEndpoints1() {
+        URL ed1URL = getClass().getResource("/ed1.xml");
+
+        Bundle b = createBundleContaining(ed1URL);
+
+        List<EndpointDescription> endpoints = new EndpointDescriptionBundleParser().getAllEndpointDescriptions(b);
+        assertEquals(4, endpoints.size());
+        EndpointDescription endpoint0 = endpoints.get(0);
+        assertEquals("http://somewhere:12345", endpoint0.getId());
+        assertEquals(Arrays.asList("SomeService"), endpoint0.getInterfaces());
+        assertEquals(Arrays.asList("confidentiality"),
+            endpoint0.getProperties().get("osgi.remote.requires.intents"));
+        assertEquals("testValue", endpoint0.getProperties().get("testKey"));
+
+        EndpointDescription endpoint1 = endpoints.get(1);
+        assertEquals("myScheme://somewhere:12345", endpoint1.getId());
+        assertEquals(Arrays.asList("SomeOtherService", "WithSomeSecondInterface"), endpoint1.getInterfaces());
+
+        EndpointDescription endpoint2 = endpoints.get(2);
+        assertEquals("http://somewhere", endpoint2.getId());
+        assertEquals(Arrays.asList("SomeOtherService", "WithSomeSecondInterface"), endpoint2.getInterfaces());
+
+        EndpointDescription endpoint3 = endpoints.get(3);
+        assertEquals("http://somewhere:1/2/3/4?5", endpoint3.getId());
+        assertEquals(Arrays.asList("SomeOtherService", "WithSomeSecondInterface"), endpoint3.getInterfaces());
+    }
+
+    public void testAllEndpoints2() throws Exception {
+        URL ed2URL = getClass().getResource("/ed2.xml");
+
+        Bundle b = createBundleContaining(ed2URL);
+
+        List<EndpointDescription> endpoints = new EndpointDescriptionBundleParser().getAllEndpointDescriptions(b);
+        assertEquals(2, endpoints.size());
+        EndpointDescription endpoint0 = endpoints.get(0);
+        assertEquals("foo:bar", endpoint0.getId());
+        assertEquals(Arrays.asList("com.acme.HelloService"), endpoint0.getInterfaces());
+        assertEquals(Arrays.asList("SOAP"), endpoint0.getIntents());
+        // changed from exported to imported
+        assertEquals("org.apache.cxf.ws", endpoint0.getProperties().get("service.imported.configs"));
+
+        EndpointDescription endpoint1 = endpoints.get(1);
+        Map<String, Object> props = endpoint1.getProperties();
+        assertEquals(Arrays.asList("com.acme.HelloService", "some.other.Service"), endpoint1.getInterfaces());
+        assertEquals("org.apache.cxf.ws", props.get("service.imported.configs"));
+        // exports should have been removed
+        assertNull(props.get("service.exported.configs"));
+
+        assertEquals(EndpointDescriptionBundleParserTest.normXML("<other:t1 xmlns:other='http://www.acme.org/xmlns/other/v1.0.0' "
+            + "xmlns='http://www.acme.org/xmlns/other/v1.0.0'><foo type='bar'>haha</foo>\n"
+            + "        </other:t1>"),
+            EndpointDescriptionBundleParserTest.normXML((String) props.get("someXML")));
+        assertEquals(Long.MAX_VALUE, props.get("long"));
+        assertEquals(-1L, props.get("long2"));
+        assertEquals(Double.MAX_VALUE, props.get("double"));
+        assertEquals(1.0d, props.get("Double2"));
+        assertEquals(42.24f, props.get("float"));
+        assertEquals(1.0f, props.get("Float2"));
+        assertEquals(17, props.get("int"));
+        assertEquals(42, props.get("Integer2"));
+        assertEquals((byte) 127, props.get("byte"));
+        assertEquals((byte) -128, props.get("Byte2"));
+        assertEquals(Boolean.TRUE, props.get("boolean"));
+        assertEquals(Boolean.TRUE, props.get("Boolean2"));
+        assertEquals((short) 99, props.get("short"));
+        assertEquals((short) -99, props.get("Short2"));
+        assertEquals('@', props.get("char"));
+        assertEquals('X', props.get("Character2"));
+
+        int[] intArray = (int[]) props.get("int-array");
+        assertTrue(Arrays.equals(new int[] {1, 2}, intArray));
+
+        Integer[] integerArray = (Integer[]) props.get("Integer-array");
+        assertTrue(Arrays.equals(new Integer[] {2, 1}, integerArray));
+
+        assertEquals(Arrays.asList(true, false), props.get("bool-list"));
+        assertEquals(new HashSet<Object>(), props.get("long-set"));
+        Set<String> stringSet = new HashSet<String>();
+        stringSet.add("Hello there");
+        stringSet.add("How are you?");
+        assertEquals(stringSet, props.get("string-set"));
+        assertEquals("Hello", props.get("other1").toString().trim());
+
+        List<?> l = (List<?>) props.get("other2");
+        assertEquals(1, l.size());
+        assertEquals(EndpointDescriptionBundleParserTest.normXML("<other:t2 xmlns:other='http://www.acme.org/xmlns/other/v1.0.0' " 
+                                   + "xmlns='http://www.osgi.org/xmlns/rsa/v1.0.0'/>"),
+                                   EndpointDescriptionBundleParserTest.normXML((String) l.get(0)));
+    }
+
+    public static String stripProlog(String s) {
+        return s.replaceAll("<\\?(.*?)\\?>", "");
+    }
+
+    public static String stripComment(String s) {
+        return Pattern.compile("<!--(.*?)-->", Pattern.DOTALL).matcher(s).replaceAll("");
+    }
+
+    public static String normXML(String s) {
+        String s2 = stripComment(s);
+        String s3 = stripProlog(s2);
+        try {
+            TransformerFactory transFactory = TransformerFactory.newInstance();
+            Transformer transformer = transFactory.newTransformer();
+            StringWriter buffer = new StringWriter();
+            transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+            transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+            transformer.transform(new StreamSource(new StringReader(s3)), new StreamResult(buffer));
+            return buffer.toString();
+        } catch (Exception e) {
+            return "";
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/5f4c6604/discovery/local/src/test/java/org/apache/aries/rsa/discovery/endpoint/EndpointDescriptionParserTest.java
----------------------------------------------------------------------
diff --git a/discovery/local/src/test/java/org/apache/aries/rsa/discovery/endpoint/EndpointDescriptionParserTest.java b/discovery/local/src/test/java/org/apache/aries/rsa/discovery/endpoint/EndpointDescriptionParserTest.java
new file mode 100644
index 0000000..dea3c19
--- /dev/null
+++ b/discovery/local/src/test/java/org/apache/aries/rsa/discovery/endpoint/EndpointDescriptionParserTest.java
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.rsa.discovery.endpoint;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.List;
+
+import org.apache.aries.rsa.discovery.endpoint.EndpointDescriptionBundleParser;
+import org.apache.aries.rsa.discovery.endpoint.EndpointDescriptionParser;
+import org.easymock.EasyMock;
+import org.junit.Assert;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.xmlns.rsa.v1_0.EndpointDescriptionType;
+
+public class EndpointDescriptionParserTest {
+
+    @Test
+    public void testNoRemoteServicesXMLFiles() {
+        Bundle b = EasyMock.createNiceMock(Bundle.class);
+        EasyMock.replay(b);
+
+        List<EndpointDescriptionType> rsElements = new EndpointDescriptionBundleParser().getAllDescriptionElements(b);
+        Assert.assertEquals(0, rsElements.size());
+    }
+
+    @Test
+    public void testEndpointDescriptionsFromURL() throws IOException {
+        URL ed1URL = getClass().getResource("/ed1.xml");
+        List<EndpointDescriptionType> edElements = new EndpointDescriptionParser().
+            getEndpointDescriptions(ed1URL.openStream());
+        Assert.assertEquals(4, edElements.size());
+    }
+}

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/5f4c6604/discovery/local/src/test/java/org/apache/aries/rsa/discovery/endpoint/PropertiesMapperTest.java
----------------------------------------------------------------------
diff --git a/discovery/local/src/test/java/org/apache/aries/rsa/discovery/endpoint/PropertiesMapperTest.java b/discovery/local/src/test/java/org/apache/aries/rsa/discovery/endpoint/PropertiesMapperTest.java
new file mode 100644
index 0000000..3ba0451
--- /dev/null
+++ b/discovery/local/src/test/java/org/apache/aries/rsa/discovery/endpoint/PropertiesMapperTest.java
@@ -0,0 +1,98 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.rsa.discovery.endpoint;
+
+import java.io.ByteArrayInputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.xml.sax.InputSource;
+import org.apache.aries.rsa.discovery.endpoint.EndpointDescriptionParser;
+import org.apache.aries.rsa.discovery.endpoint.PropertiesMapper;
+import org.custommonkey.xmlunit.XMLAssert;
+import org.junit.Test;
+import org.osgi.xmlns.rsa.v1_0.EndpointDescriptionType;
+import org.osgi.xmlns.rsa.v1_0.PropertyType;
+
+public class PropertiesMapperTest {
+    private static final String LF = "\n";
+
+    @Test
+    public void testCreateXML() throws Exception {
+        Map<String, Object> m = new LinkedHashMap<String, Object>();
+        m.put("service.imported.configs", "org.apache.cxf.ws");
+        m.put("endpoint.id", "foo:bar");
+        m.put("objectClass", new String[] {"com.acme.HelloService", "some.other.Service"});
+        m.put("SomeObject", new Object());
+        m.put("long", 9223372036854775807L);
+        m.put("Long2", -1L);
+        m.put("double", 1.7976931348623157E308);
+        m.put("Double2", 1.0d);
+        m.put("float", 42.24f);
+        m.put("Float2", 1.0f);
+        m.put("int", 17);
+        m.put("Integer2", 42);
+        m.put("byte", (byte) 127);
+        m.put("Byte2", (byte) -128);
+        m.put("boolean", true);
+        m.put("Boolean2", false);
+        m.put("short", (short) 99);
+        m.put("Short2", (short) -99);
+        m.put("char", '@');
+        m.put("Character2", 'X');
+
+        List<Boolean> boolList = new ArrayList<Boolean>();
+        boolList.add(true);
+        boolList.add(false);
+        m.put("bool-list", boolList);
+        m.put("empty-set", new HashSet<Object>());
+
+        Set<String> stringSet = new LinkedHashSet<String>();
+        stringSet.add("Hello there");
+        stringSet.add("How are you?");
+        m.put("string-set", stringSet);
+
+        int[] intArray = new int[] {1, 2};
+        m.put("int-array", intArray);
+
+        String xml = "<xml>" + LF
+            + "<t1 xmlns=\"http://www.acme.org/xmlns/other/v1.0.0\">" + LF
+            + "<foo type='bar'>haha</foo>" + LF
+            + "</t1>" + LF
+            + "</xml>";
+        m.put("someXML", xml);
+
+        List<PropertyType> props = new PropertiesMapper().fromProps(m);
+        EndpointDescriptionType epd = new EndpointDescriptionType();
+        epd.getProperty().addAll(props);
+        byte[] epData = new EndpointDescriptionParser().getData(epd);
+
+        URL edURL = getClass().getResource("/ed2-generated.xml");
+        InputSource expectedXml = new InputSource(edURL.openStream());
+        InputSource actualXml = new InputSource(new ByteArrayInputStream(epData)); 
+        XMLAssert.assertXMLEqual(expectedXml, actualXml);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/5f4c6604/discovery/local/src/test/java/org/apache/aries/rsa/discovery/local/ActivatorTest.java
----------------------------------------------------------------------
diff --git a/discovery/local/src/test/java/org/apache/aries/rsa/discovery/local/ActivatorTest.java b/discovery/local/src/test/java/org/apache/aries/rsa/discovery/local/ActivatorTest.java
new file mode 100644
index 0000000..a69e7e6
--- /dev/null
+++ b/discovery/local/src/test/java/org/apache/aries/rsa/discovery/local/ActivatorTest.java
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.rsa.discovery.local;
+
+import junit.framework.TestCase;
+
+import org.apache.aries.rsa.discovery.local.Activator;
+import org.apache.aries.rsa.discovery.local.LocalDiscovery;
+import org.easymock.EasyMock;
+import org.easymock.IAnswer;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkUtil;
+
+public class ActivatorTest extends TestCase {
+
+    public void testActivator() throws Exception {
+        BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
+        EasyMock.expect(bc.createFilter((String) EasyMock.anyObject())).andAnswer(new IAnswer<Filter>() {
+            public Filter answer() throws Throwable {
+                return FrameworkUtil.createFilter((String) EasyMock.getCurrentArguments()[0]);
+            }
+        }).anyTimes();
+        EasyMock.replay(bc);
+
+        Activator a = new Activator();
+        a.start(bc);
+        assertNotNull(a.localDiscovery);
+
+        a.localDiscovery = EasyMock.createMock(LocalDiscovery.class);
+        a.localDiscovery.shutDown();
+        EasyMock.expectLastCall();
+        EasyMock.replay(a.localDiscovery);
+        a.stop(bc);
+
+        EasyMock.verify(a.localDiscovery);
+    }
+}

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/5f4c6604/discovery/local/src/test/java/org/apache/aries/rsa/discovery/local/LocalDiscoveryTest.java
----------------------------------------------------------------------
diff --git a/discovery/local/src/test/java/org/apache/aries/rsa/discovery/local/LocalDiscoveryTest.java b/discovery/local/src/test/java/org/apache/aries/rsa/discovery/local/LocalDiscoveryTest.java
new file mode 100644
index 0000000..c33c23f
--- /dev/null
+++ b/discovery/local/src/test/java/org/apache/aries/rsa/discovery/local/LocalDiscoveryTest.java
@@ -0,0 +1,410 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.rsa.discovery.local;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Dictionary;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.apache.aries.rsa.discovery.local.LocalDiscovery;
+import org.easymock.EasyMock;
+import org.easymock.IAnswer;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.BundleListener;
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
+import org.osgi.service.remoteserviceadmin.EndpointListener;
+
+public class LocalDiscoveryTest extends TestCase {
+
+    public void testLocalDiscovery() throws Exception {
+        Filter filter = EasyMock.createMock(Filter.class);
+        EasyMock.replay(filter);
+
+        BundleContext bc = EasyMock.createMock(BundleContext.class);
+        EasyMock.expect(bc.createFilter("(objectClass=org.osgi.service.remoteserviceadmin.EndpointListener)"))
+            .andReturn(filter);
+        bc.addServiceListener((ServiceListener) EasyMock.anyObject(),
+            EasyMock.eq("(objectClass=org.osgi.service.remoteserviceadmin.EndpointListener)"));
+        EasyMock.expectLastCall();
+        EasyMock.expect(bc.getServiceReferences("org.osgi.service.remoteserviceadmin.EndpointListener", null))
+            .andReturn(null);
+        bc.addBundleListener((BundleListener) EasyMock.anyObject());
+        EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
+            public Object answer() throws Throwable {
+                assertEquals(LocalDiscovery.class, EasyMock.getCurrentArguments()[0].getClass());
+                return null;
+            }
+        });
+        EasyMock.expect(bc.getBundles()).andReturn(null);
+        EasyMock.replay(bc);
+
+        LocalDiscovery ld = new LocalDiscovery(bc);
+        assertSame(bc, ld.bundleContext);
+        assertNotNull(ld.listenerTracker);
+
+        EasyMock.verify(bc);
+
+        EasyMock.reset(bc);
+        bc.removeBundleListener(ld);
+        EasyMock.expectLastCall();
+        bc.removeServiceListener((ServiceListener) EasyMock.anyObject());
+        EasyMock.expectLastCall();
+        EasyMock.replay(bc);
+
+        ld.shutDown();
+        EasyMock.verify(bc);
+    }
+
+    public void testPreExistingBundles() throws Exception {
+        Filter filter = EasyMock.createMock(Filter.class);
+        EasyMock.replay(filter);
+
+        BundleContext bc = EasyMock.createMock(BundleContext.class);
+        EasyMock.expect(bc.createFilter("(objectClass=org.osgi.service.remoteserviceadmin.EndpointListener)"))
+            .andReturn(filter);
+        bc.addServiceListener((ServiceListener) EasyMock.anyObject(),
+            EasyMock.eq("(objectClass=org.osgi.service.remoteserviceadmin.EndpointListener)"));
+        EasyMock.expectLastCall();
+        EasyMock.expect(bc.getServiceReferences("org.osgi.service.remoteserviceadmin.EndpointListener", null))
+            .andReturn(null);
+        bc.addBundleListener((BundleListener) EasyMock.anyObject());
+        EasyMock.expectLastCall();
+
+        Bundle b1 = EasyMock.createMock(Bundle.class);
+        EasyMock.expect(b1.getState()).andReturn(Bundle.RESOLVED);
+        EasyMock.replay(b1);
+        Bundle b2 = EasyMock.createMock(Bundle.class);
+        EasyMock.expect(b2.getState()).andReturn(Bundle.ACTIVE);
+        Dictionary<String, String> headers = new Hashtable<String, String>();
+        headers.put("Remote-Service", "OSGI-INF/remote-service/");
+        EasyMock.expect(b2.getHeaders()).andReturn(headers);
+
+        URL rs3URL = getClass().getResource("/ed3.xml");
+        URL rs4URL = getClass().getResource("/ed4.xml");
+        List<URL> urls = Arrays.asList(rs3URL, rs4URL);
+        EasyMock.expect(b2.findEntries("OSGI-INF/remote-service", "*.xml", false))
+            .andReturn(Collections.enumeration(urls));
+        EasyMock.replay(b2);
+
+        EasyMock.expect(bc.getBundles()).andReturn(new Bundle[] {b1, b2});
+        EasyMock.replay(bc);
+
+        LocalDiscovery ld = new LocalDiscovery(bc);
+
+        assertEquals(3, ld.endpointDescriptions.size());
+        Set<String> expected = new HashSet<String>(
+                Arrays.asList("http://somewhere:12345", "http://somewhere:1", "http://somewhere"));
+        Set<String> actual = new HashSet<String>();
+        for (Map.Entry<EndpointDescription, Bundle> entry : ld.endpointDescriptions.entrySet()) {
+            assertSame(b2, entry.getValue());
+            actual.add(entry.getKey().getId());
+        }
+        assertEquals(expected, actual);
+    }
+
+    public void testBundleChanged() throws Exception {
+        LocalDiscovery ld = getLocalDiscovery();
+
+        Bundle bundle = EasyMock.createMock(Bundle.class);
+        EasyMock.expect(bundle.getSymbolicName()).andReturn("testing.bundle").anyTimes();
+        EasyMock.expect(bundle.getState()).andReturn(Bundle.ACTIVE);
+        Dictionary<String, String> headers = new Hashtable<String, String>();
+        headers.put("Remote-Service", "OSGI-INF/rsa/");
+        EasyMock.expect(bundle.getHeaders()).andReturn(headers);
+        EasyMock.expect(bundle.findEntries("OSGI-INF/rsa", "*.xml", false))
+            .andReturn(Collections.enumeration(
+                Collections.singleton(getClass().getResource("/ed3.xml"))));
+        EasyMock.replay(bundle);
+
+        BundleEvent be0 = new BundleEvent(BundleEvent.INSTALLED, bundle);
+        ld.bundleChanged(be0);
+        assertEquals(0, ld.endpointDescriptions.size());
+
+        // Create an EndpointListener
+        final Map<String, Object> props = new Hashtable<String, Object>();
+        props.put(EndpointListener.ENDPOINT_LISTENER_SCOPE, "(objectClass=*)");
+        @SuppressWarnings("unchecked")
+        ServiceReference<EndpointListener> sr = EasyMock.createMock(ServiceReference.class);
+        EasyMock.expect(sr.getPropertyKeys()).andReturn(props.keySet().toArray(new String[] {})).anyTimes();
+        EasyMock.expect(sr.getProperty((String) EasyMock.anyObject())).andAnswer(new IAnswer<Object>() {
+            public Object answer() throws Throwable {
+                return props.get(EasyMock.getCurrentArguments()[0]);
+            }
+        }).anyTimes();
+        EasyMock.replay(sr);
+
+        EndpointListener endpointListener = EasyMock.createMock(EndpointListener.class);
+        endpointListener.endpointAdded((EndpointDescription) EasyMock.anyObject(), EasyMock.eq("(objectClass=*)"));
+        EasyMock.expectLastCall();
+        EasyMock.replay(endpointListener);
+        ld.addListener(sr, endpointListener);
+
+        // Start the bundle
+        BundleEvent be = new BundleEvent(BundleEvent.STARTED, bundle);
+        ld.bundleChanged(be);
+        assertEquals(1, ld.endpointDescriptions.size());
+        EndpointDescription endpoint = ld.endpointDescriptions.keySet().iterator().next();
+        assertEquals("http://somewhere:12345", endpoint.getId());
+        assertSame(bundle, ld.endpointDescriptions.get(endpoint));
+
+        EasyMock.verify(endpointListener);
+
+        // Stop the bundle
+        EasyMock.reset(endpointListener);
+        endpointListener.endpointRemoved((EndpointDescription) EasyMock.anyObject(), EasyMock.eq("(objectClass=*)"));
+        EasyMock.expectLastCall();
+        EasyMock.replay(endpointListener);
+
+        BundleEvent be1 = new BundleEvent(BundleEvent.STOPPED, bundle);
+        ld.bundleChanged(be1);
+        assertEquals(0, ld.endpointDescriptions.size());
+
+        EasyMock.verify(endpointListener);
+    }
+
+    public void testEndpointListenerService() throws Exception {
+        LocalDiscovery ld = getLocalDiscovery();
+
+        Bundle bundle = EasyMock.createMock(Bundle.class);
+        EasyMock.expect(bundle.getState()).andReturn(Bundle.ACTIVE);
+        Dictionary<String, String> headers = new Hashtable<String, String>();
+        headers.put("Remote-Service", "OSGI-INF/rsa/ed4.xml");
+        EasyMock.expect(bundle.getHeaders()).andReturn(headers);
+        EasyMock.expect(bundle.findEntries("OSGI-INF/rsa", "ed4.xml", false))
+            .andReturn(Collections.enumeration(
+                Collections.singleton(getClass().getResource("/ed4.xml"))));
+        EasyMock.replay(bundle);
+
+        BundleEvent be = new BundleEvent(BundleEvent.STARTED, bundle);
+        ld.bundleChanged(be);
+        assertEquals(2, ld.endpointDescriptions.size());
+
+        final Map<String, Object> props = new Hashtable<String, Object>();
+        props.put(EndpointListener.ENDPOINT_LISTENER_SCOPE, new String[] {"(objectClass=org.example.ClassA)"});
+        @SuppressWarnings("unchecked")
+        ServiceReference<EndpointListener> sr = EasyMock.createMock(ServiceReference.class);
+        EasyMock.expect(sr.getPropertyKeys()).andReturn(props.keySet().toArray(new String[] {})).anyTimes();
+        EasyMock.expect(sr.getProperty((String) EasyMock.anyObject())).andAnswer(new IAnswer<Object>() {
+            public Object answer() throws Throwable {
+                return props.get(EasyMock.getCurrentArguments()[0]);
+            }
+        }).anyTimes();
+
+        EasyMock.replay(sr);
+
+        EasyMock.reset(ld.bundleContext);
+        EndpointListener el = EasyMock.createMock(EndpointListener.class);
+        EasyMock.expect(ld.bundleContext.getService(sr)).andReturn(el);
+        EasyMock.expect(ld.bundleContext.ungetService(sr)).andReturn(true);
+        EasyMock.expect(ld.bundleContext.createFilter((String) EasyMock.anyObject())).andAnswer(new IAnswer<Filter>() {
+            public Filter answer() throws Throwable {
+                return FrameworkUtil.createFilter((String) EasyMock.getCurrentArguments()[0]);
+            }
+        }).anyTimes();
+        EasyMock.replay(ld.bundleContext);
+
+        el.endpointAdded((EndpointDescription) EasyMock.anyObject(),
+                EasyMock.eq("(objectClass=org.example.ClassA)"));
+        EasyMock.expectLastCall();
+        EasyMock.replay(el);
+
+        // Add the EndpointListener Service
+        assertEquals("Precondition failed", 0, ld.listenerToFilters.size());
+        assertEquals("Precondition failed", 0, ld.filterToListeners.size());
+        assertSame(el, ld.listenerTracker.addingService(sr));
+
+        assertEquals(1, ld.listenerToFilters.size());
+        assertEquals(Collections.singletonList("(objectClass=org.example.ClassA)"), ld.listenerToFilters.get(el));
+        assertEquals(1, ld.filterToListeners.size());
+        assertEquals(Collections.singletonList(el), ld.filterToListeners.get("(objectClass=org.example.ClassA)"));
+
+        EasyMock.verify(el);
+
+        // Modify the EndpointListener Service
+        // no need to reset the mock for this...
+        props.put(EndpointListener.ENDPOINT_LISTENER_SCOPE,
+                  "(|(objectClass=org.example.ClassA)(objectClass=org.example.ClassB))");
+
+        EasyMock.reset(el);
+        final Set<String> actualEndpoints = new HashSet<String>();
+        el.endpointAdded((EndpointDescription) EasyMock.anyObject(),
+                EasyMock.eq("(|(objectClass=org.example.ClassA)(objectClass=org.example.ClassB))"));
+        EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
+            public Object answer() throws Throwable {
+                EndpointDescription endpoint = (EndpointDescription) EasyMock.getCurrentArguments()[0];
+                actualEndpoints.addAll(endpoint.getInterfaces());
+                return null;
+            }
+        }).times(2);
+        EasyMock.replay(el);
+
+        ld.listenerTracker.modifiedService(sr, el);
+        assertEquals(1, ld.listenerToFilters.size());
+        assertEquals(Arrays.asList("(|(objectClass=org.example.ClassA)(objectClass=org.example.ClassB))"),
+            ld.listenerToFilters.get(el));
+        assertEquals(1, ld.filterToListeners.size());
+        assertEquals(Collections.singletonList(el),
+            ld.filterToListeners.get("(|(objectClass=org.example.ClassA)(objectClass=org.example.ClassB))"));
+
+        EasyMock.verify(el);
+        Set<String> expectedEndpoints = new HashSet<String>(Arrays.asList("org.example.ClassA", "org.example.ClassB"));
+        assertEquals(expectedEndpoints, actualEndpoints);
+
+        // Remove the EndpointListener Service
+        ld.listenerTracker.removedService(sr, el);
+        assertEquals(0, ld.listenerToFilters.size());
+        assertEquals(0, ld.filterToListeners.size());
+    }
+
+    public void testRegisterTracker() throws Exception {
+        LocalDiscovery ld = getLocalDiscovery();
+
+        final Map<String, Object> props = new Hashtable<String, Object>();
+        props.put(EndpointListener.ENDPOINT_LISTENER_SCOPE, "(objectClass=Aaaa)");
+        @SuppressWarnings("unchecked")
+        ServiceReference<EndpointListener> sr = EasyMock.createMock(ServiceReference.class);
+        EasyMock.expect(sr.getPropertyKeys()).andReturn(props.keySet().toArray(new String[] {})).anyTimes();
+        EasyMock.expect(sr.getProperty((String) EasyMock.anyObject())).andAnswer(new IAnswer<Object>() {
+            public Object answer() throws Throwable {
+                return props.get(EasyMock.getCurrentArguments()[0]);
+            }
+        }).anyTimes();
+        EasyMock.replay(sr);
+
+        EndpointListener endpointListener = EasyMock.createMock(EndpointListener.class);
+        EasyMock.replay(endpointListener);
+
+        assertEquals("Precondition failed", 0, ld.listenerToFilters.size());
+        assertEquals("Precondition failed", 0, ld.filterToListeners.size());
+        ld.addListener(sr, endpointListener);
+
+        assertEquals(1, ld.listenerToFilters.size());
+        assertEquals(Collections.singletonList("(objectClass=Aaaa)"), ld.listenerToFilters.get(endpointListener));
+        assertEquals(1, ld.filterToListeners.size());
+        assertEquals(Collections.singletonList(endpointListener), ld.filterToListeners.get("(objectClass=Aaaa)"));
+
+        // Add another one with the same scope filter
+        @SuppressWarnings("unchecked")
+        ServiceReference<EndpointListener> sr2 = EasyMock.createMock(ServiceReference.class);
+        EasyMock.expect(sr2.getPropertyKeys()).andReturn(props.keySet().toArray(new String[] {})).anyTimes();
+        EasyMock.expect(sr2.getProperty((String) EasyMock.anyObject())).andAnswer(new IAnswer<Object>() {
+            public Object answer() throws Throwable {
+                return props.get(EasyMock.getCurrentArguments()[0]);
+            }
+        }).anyTimes();
+        EasyMock.replay(sr2);
+
+        EndpointListener endpointListener2 = EasyMock.createMock(EndpointListener.class);
+        EasyMock.replay(endpointListener2);
+        ld.addListener(sr2, endpointListener2);
+
+        assertEquals(2, ld.listenerToFilters.size());
+        assertEquals(Collections.singletonList("(objectClass=Aaaa)"), ld.listenerToFilters.get(endpointListener));
+        assertEquals(Collections.singletonList("(objectClass=Aaaa)"), ld.listenerToFilters.get(endpointListener2));
+
+        assertEquals(1, ld.filterToListeners.size());
+        List<EndpointListener> endpointListeners12 = Arrays.asList(endpointListener, endpointListener2);
+        assertEquals(endpointListeners12, ld.filterToListeners.get("(objectClass=Aaaa)"));
+
+        // Add another listener with a multi-value scope
+        final Map<String, Object> props2 = new Hashtable<String, Object>();
+        props2.put(EndpointListener.ENDPOINT_LISTENER_SCOPE, Arrays.asList("(objectClass=X)", "(objectClass=Y)"));
+        @SuppressWarnings("unchecked")
+        ServiceReference<EndpointListener> sr3 = EasyMock.createMock(ServiceReference.class);
+        EasyMock.expect(sr3.getPropertyKeys()).andReturn(props2.keySet().toArray(new String[] {})).anyTimes();
+        EasyMock.expect(sr3.getProperty((String) EasyMock.anyObject())).andAnswer(new IAnswer<Object>() {
+            public Object answer() throws Throwable {
+                return props2.get(EasyMock.getCurrentArguments()[0]);
+            }
+        }).anyTimes();
+        EasyMock.replay(sr3);
+
+        EndpointListener endpointListener3 = EasyMock.createMock(EndpointListener.class);
+        EasyMock.replay(endpointListener3);
+        ld.addListener(sr3, endpointListener3);
+
+        assertEquals(3, ld.listenerToFilters.size());
+        assertEquals(Collections.singletonList("(objectClass=Aaaa)"), ld.listenerToFilters.get(endpointListener));
+        assertEquals(Collections.singletonList("(objectClass=Aaaa)"), ld.listenerToFilters.get(endpointListener2));
+        assertEquals(Arrays.asList("(objectClass=X)", "(objectClass=Y)"), ld.listenerToFilters.get(endpointListener3));
+
+        assertEquals(3, ld.filterToListeners.size());
+        assertEquals(endpointListeners12, ld.filterToListeners.get("(objectClass=Aaaa)"));
+        assertEquals(Collections.singletonList(endpointListener3), ld.filterToListeners.get("(objectClass=X)"));
+        assertEquals(Collections.singletonList(endpointListener3), ld.filterToListeners.get("(objectClass=Y)"));
+    }
+
+    public void testClearTracker() throws Exception {
+        LocalDiscovery ld = getLocalDiscovery();
+
+        EndpointListener endpointListener = EasyMock.createMock(EndpointListener.class);
+        ld.listenerToFilters.put(endpointListener,
+                new ArrayList<String>(Arrays.asList("(a=b)", "(objectClass=foo.bar.Bheuaark)")));
+        ld.filterToListeners.put("(a=b)", new ArrayList<EndpointListener>(Arrays.asList(endpointListener)));
+        ld.filterToListeners.put("(objectClass=foo.bar.Bheuaark)",
+                new ArrayList<EndpointListener>(Arrays.asList(endpointListener)));
+
+        assertEquals(1, ld.listenerToFilters.size());
+        assertEquals(2, ld.filterToListeners.size());
+        assertEquals(1, ld.filterToListeners.values().iterator().next().size());
+        ld.removeListener(EasyMock.createMock(EndpointListener.class));
+        assertEquals(1, ld.listenerToFilters.size());
+        assertEquals(2, ld.filterToListeners.size());
+        assertEquals(1, ld.filterToListeners.values().iterator().next().size());
+        ld.removeListener(endpointListener);
+        assertEquals(0, ld.listenerToFilters.size());
+        assertEquals(0, ld.filterToListeners.size());
+    }
+
+    private LocalDiscovery getLocalDiscovery() throws InvalidSyntaxException {
+        BundleContext bc = EasyMock.createMock(BundleContext.class);
+        EasyMock.expect(bc.createFilter((String) EasyMock.anyObject())).andAnswer(new IAnswer<Filter>() {
+            public Filter answer() throws Throwable {
+                return FrameworkUtil.createFilter((String) EasyMock.getCurrentArguments()[0]);
+            }
+        }).anyTimes();
+        bc.addServiceListener((ServiceListener) EasyMock.anyObject(),
+            EasyMock.eq("(objectClass=org.osgi.service.remoteserviceadmin.EndpointListener)"));
+        EasyMock.expectLastCall();
+        EasyMock.expect(bc.getServiceReferences("org.osgi.service.remoteserviceadmin.EndpointListener", null))
+            .andReturn(null);
+        bc.addBundleListener((BundleListener) EasyMock.anyObject());
+        EasyMock.expectLastCall();
+        EasyMock.expect(bc.getBundles()).andReturn(null);
+        EasyMock.replay(bc);
+
+        return new LocalDiscovery(bc);
+    }
+}

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/5f4c6604/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/internal/ActivatorTest.java
----------------------------------------------------------------------
diff --git a/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/internal/ActivatorTest.java b/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/internal/ActivatorTest.java
deleted file mode 100644
index a0bdc87..0000000
--- a/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/internal/ActivatorTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cxf.dosgi.discovery.local.internal;
-
-import junit.framework.TestCase;
-
-import org.easymock.IAnswer;
-import org.easymock.classextension.EasyMock;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Filter;
-import org.osgi.framework.FrameworkUtil;
-
-public class ActivatorTest extends TestCase {
-
-    public void testActivator() throws Exception {
-        BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
-        EasyMock.expect(bc.createFilter((String) EasyMock.anyObject())).andAnswer(new IAnswer<Filter>() {
-            public Filter answer() throws Throwable {
-                return FrameworkUtil.createFilter((String) EasyMock.getCurrentArguments()[0]);
-            }
-        }).anyTimes();
-        EasyMock.replay(bc);
-
-        Activator a = new Activator();
-        a.start(bc);
-        assertNotNull(a.localDiscovery);
-
-        a.localDiscovery = EasyMock.createMock(LocalDiscovery.class);
-        a.localDiscovery.shutDown();
-        EasyMock.expectLastCall();
-        EasyMock.replay(a.localDiscovery);
-        a.stop(bc);
-
-        EasyMock.verify(a.localDiscovery);
-    }
-}

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/5f4c6604/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/internal/LocalDiscoveryTest.java
----------------------------------------------------------------------
diff --git a/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/internal/LocalDiscoveryTest.java b/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/internal/LocalDiscoveryTest.java
deleted file mode 100644
index ccbaca7..0000000
--- a/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/internal/LocalDiscoveryTest.java
+++ /dev/null
@@ -1,409 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cxf.dosgi.discovery.local.internal;
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Dictionary;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import junit.framework.TestCase;
-
-import org.easymock.EasyMock;
-import org.easymock.IAnswer;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleEvent;
-import org.osgi.framework.BundleListener;
-import org.osgi.framework.Filter;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceListener;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.remoteserviceadmin.EndpointDescription;
-import org.osgi.service.remoteserviceadmin.EndpointListener;
-
-public class LocalDiscoveryTest extends TestCase {
-
-    public void testLocalDiscovery() throws Exception {
-        Filter filter = EasyMock.createMock(Filter.class);
-        EasyMock.replay(filter);
-
-        BundleContext bc = EasyMock.createMock(BundleContext.class);
-        EasyMock.expect(bc.createFilter("(objectClass=org.osgi.service.remoteserviceadmin.EndpointListener)"))
-            .andReturn(filter);
-        bc.addServiceListener((ServiceListener) EasyMock.anyObject(),
-            EasyMock.eq("(objectClass=org.osgi.service.remoteserviceadmin.EndpointListener)"));
-        EasyMock.expectLastCall();
-        EasyMock.expect(bc.getServiceReferences("org.osgi.service.remoteserviceadmin.EndpointListener", null))
-            .andReturn(null);
-        bc.addBundleListener((BundleListener) EasyMock.anyObject());
-        EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
-            public Object answer() throws Throwable {
-                assertEquals(LocalDiscovery.class, EasyMock.getCurrentArguments()[0].getClass());
-                return null;
-            }
-        });
-        EasyMock.expect(bc.getBundles()).andReturn(null);
-        EasyMock.replay(bc);
-
-        LocalDiscovery ld = new LocalDiscovery(bc);
-        assertSame(bc, ld.bundleContext);
-        assertNotNull(ld.listenerTracker);
-
-        EasyMock.verify(bc);
-
-        EasyMock.reset(bc);
-        bc.removeBundleListener(ld);
-        EasyMock.expectLastCall();
-        bc.removeServiceListener((ServiceListener) EasyMock.anyObject());
-        EasyMock.expectLastCall();
-        EasyMock.replay(bc);
-
-        ld.shutDown();
-        EasyMock.verify(bc);
-    }
-
-    public void testPreExistingBundles() throws Exception {
-        Filter filter = EasyMock.createMock(Filter.class);
-        EasyMock.replay(filter);
-
-        BundleContext bc = EasyMock.createMock(BundleContext.class);
-        EasyMock.expect(bc.createFilter("(objectClass=org.osgi.service.remoteserviceadmin.EndpointListener)"))
-            .andReturn(filter);
-        bc.addServiceListener((ServiceListener) EasyMock.anyObject(),
-            EasyMock.eq("(objectClass=org.osgi.service.remoteserviceadmin.EndpointListener)"));
-        EasyMock.expectLastCall();
-        EasyMock.expect(bc.getServiceReferences("org.osgi.service.remoteserviceadmin.EndpointListener", null))
-            .andReturn(null);
-        bc.addBundleListener((BundleListener) EasyMock.anyObject());
-        EasyMock.expectLastCall();
-
-        Bundle b1 = EasyMock.createMock(Bundle.class);
-        EasyMock.expect(b1.getState()).andReturn(Bundle.RESOLVED);
-        EasyMock.replay(b1);
-        Bundle b2 = EasyMock.createMock(Bundle.class);
-        EasyMock.expect(b2.getState()).andReturn(Bundle.ACTIVE);
-        Dictionary<String, String> headers = new Hashtable<String, String>();
-        headers.put("Remote-Service", "OSGI-INF/remote-service/");
-        EasyMock.expect(b2.getHeaders()).andReturn(headers);
-
-        URL rs3URL = getClass().getResource("/ed3.xml");
-        URL rs4URL = getClass().getResource("/ed4.xml");
-        List<URL> urls = Arrays.asList(rs3URL, rs4URL);
-        EasyMock.expect(b2.findEntries("OSGI-INF/remote-service", "*.xml", false))
-            .andReturn(Collections.enumeration(urls));
-        EasyMock.replay(b2);
-
-        EasyMock.expect(bc.getBundles()).andReturn(new Bundle[] {b1, b2});
-        EasyMock.replay(bc);
-
-        LocalDiscovery ld = new LocalDiscovery(bc);
-
-        assertEquals(3, ld.endpointDescriptions.size());
-        Set<String> expected = new HashSet<String>(
-                Arrays.asList("http://somewhere:12345", "http://somewhere:1", "http://somewhere"));
-        Set<String> actual = new HashSet<String>();
-        for (Map.Entry<EndpointDescription, Bundle> entry : ld.endpointDescriptions.entrySet()) {
-            assertSame(b2, entry.getValue());
-            actual.add(entry.getKey().getId());
-        }
-        assertEquals(expected, actual);
-    }
-
-    public void testBundleChanged() throws Exception {
-        LocalDiscovery ld = getLocalDiscovery();
-
-        Bundle bundle = EasyMock.createMock(Bundle.class);
-        EasyMock.expect(bundle.getSymbolicName()).andReturn("testing.bundle").anyTimes();
-        EasyMock.expect(bundle.getState()).andReturn(Bundle.ACTIVE);
-        Dictionary<String, String> headers = new Hashtable<String, String>();
-        headers.put("Remote-Service", "OSGI-INF/rsa/");
-        EasyMock.expect(bundle.getHeaders()).andReturn(headers);
-        EasyMock.expect(bundle.findEntries("OSGI-INF/rsa", "*.xml", false))
-            .andReturn(Collections.enumeration(
-                Collections.singleton(getClass().getResource("/ed3.xml"))));
-        EasyMock.replay(bundle);
-
-        BundleEvent be0 = new BundleEvent(BundleEvent.INSTALLED, bundle);
-        ld.bundleChanged(be0);
-        assertEquals(0, ld.endpointDescriptions.size());
-
-        // Create an EndpointListener
-        final Map<String, Object> props = new Hashtable<String, Object>();
-        props.put(EndpointListener.ENDPOINT_LISTENER_SCOPE, "(objectClass=*)");
-        @SuppressWarnings("unchecked")
-        ServiceReference<EndpointListener> sr = EasyMock.createMock(ServiceReference.class);
-        EasyMock.expect(sr.getPropertyKeys()).andReturn(props.keySet().toArray(new String[] {})).anyTimes();
-        EasyMock.expect(sr.getProperty((String) EasyMock.anyObject())).andAnswer(new IAnswer<Object>() {
-            public Object answer() throws Throwable {
-                return props.get(EasyMock.getCurrentArguments()[0]);
-            }
-        }).anyTimes();
-        EasyMock.replay(sr);
-
-        EndpointListener endpointListener = EasyMock.createMock(EndpointListener.class);
-        endpointListener.endpointAdded((EndpointDescription) EasyMock.anyObject(), EasyMock.eq("(objectClass=*)"));
-        EasyMock.expectLastCall();
-        EasyMock.replay(endpointListener);
-        ld.addListener(sr, endpointListener);
-
-        // Start the bundle
-        BundleEvent be = new BundleEvent(BundleEvent.STARTED, bundle);
-        ld.bundleChanged(be);
-        assertEquals(1, ld.endpointDescriptions.size());
-        EndpointDescription endpoint = ld.endpointDescriptions.keySet().iterator().next();
-        assertEquals("http://somewhere:12345", endpoint.getId());
-        assertSame(bundle, ld.endpointDescriptions.get(endpoint));
-
-        EasyMock.verify(endpointListener);
-
-        // Stop the bundle
-        EasyMock.reset(endpointListener);
-        endpointListener.endpointRemoved((EndpointDescription) EasyMock.anyObject(), EasyMock.eq("(objectClass=*)"));
-        EasyMock.expectLastCall();
-        EasyMock.replay(endpointListener);
-
-        BundleEvent be1 = new BundleEvent(BundleEvent.STOPPED, bundle);
-        ld.bundleChanged(be1);
-        assertEquals(0, ld.endpointDescriptions.size());
-
-        EasyMock.verify(endpointListener);
-    }
-
-    public void testEndpointListenerService() throws Exception {
-        LocalDiscovery ld = getLocalDiscovery();
-
-        Bundle bundle = EasyMock.createMock(Bundle.class);
-        EasyMock.expect(bundle.getState()).andReturn(Bundle.ACTIVE);
-        Dictionary<String, String> headers = new Hashtable<String, String>();
-        headers.put("Remote-Service", "OSGI-INF/rsa/ed4.xml");
-        EasyMock.expect(bundle.getHeaders()).andReturn(headers);
-        EasyMock.expect(bundle.findEntries("OSGI-INF/rsa", "ed4.xml", false))
-            .andReturn(Collections.enumeration(
-                Collections.singleton(getClass().getResource("/ed4.xml"))));
-        EasyMock.replay(bundle);
-
-        BundleEvent be = new BundleEvent(BundleEvent.STARTED, bundle);
-        ld.bundleChanged(be);
-        assertEquals(2, ld.endpointDescriptions.size());
-
-        final Map<String, Object> props = new Hashtable<String, Object>();
-        props.put(EndpointListener.ENDPOINT_LISTENER_SCOPE, new String[] {"(objectClass=org.example.ClassA)"});
-        @SuppressWarnings("unchecked")
-        ServiceReference<EndpointListener> sr = EasyMock.createMock(ServiceReference.class);
-        EasyMock.expect(sr.getPropertyKeys()).andReturn(props.keySet().toArray(new String[] {})).anyTimes();
-        EasyMock.expect(sr.getProperty((String) EasyMock.anyObject())).andAnswer(new IAnswer<Object>() {
-            public Object answer() throws Throwable {
-                return props.get(EasyMock.getCurrentArguments()[0]);
-            }
-        }).anyTimes();
-
-        EasyMock.replay(sr);
-
-        EasyMock.reset(ld.bundleContext);
-        EndpointListener el = EasyMock.createMock(EndpointListener.class);
-        EasyMock.expect(ld.bundleContext.getService(sr)).andReturn(el);
-        EasyMock.expect(ld.bundleContext.ungetService(sr)).andReturn(true);
-        EasyMock.expect(ld.bundleContext.createFilter((String) EasyMock.anyObject())).andAnswer(new IAnswer<Filter>() {
-            public Filter answer() throws Throwable {
-                return FrameworkUtil.createFilter((String) EasyMock.getCurrentArguments()[0]);
-            }
-        }).anyTimes();
-        EasyMock.replay(ld.bundleContext);
-
-        el.endpointAdded((EndpointDescription) EasyMock.anyObject(),
-                EasyMock.eq("(objectClass=org.example.ClassA)"));
-        EasyMock.expectLastCall();
-        EasyMock.replay(el);
-
-        // Add the EndpointListener Service
-        assertEquals("Precondition failed", 0, ld.listenerToFilters.size());
-        assertEquals("Precondition failed", 0, ld.filterToListeners.size());
-        assertSame(el, ld.listenerTracker.addingService(sr));
-
-        assertEquals(1, ld.listenerToFilters.size());
-        assertEquals(Collections.singletonList("(objectClass=org.example.ClassA)"), ld.listenerToFilters.get(el));
-        assertEquals(1, ld.filterToListeners.size());
-        assertEquals(Collections.singletonList(el), ld.filterToListeners.get("(objectClass=org.example.ClassA)"));
-
-        EasyMock.verify(el);
-
-        // Modify the EndpointListener Service
-        // no need to reset the mock for this...
-        props.put(EndpointListener.ENDPOINT_LISTENER_SCOPE,
-                  "(|(objectClass=org.example.ClassA)(objectClass=org.example.ClassB))");
-
-        EasyMock.reset(el);
-        final Set<String> actualEndpoints = new HashSet<String>();
-        el.endpointAdded((EndpointDescription) EasyMock.anyObject(),
-                EasyMock.eq("(|(objectClass=org.example.ClassA)(objectClass=org.example.ClassB))"));
-        EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
-            public Object answer() throws Throwable {
-                EndpointDescription endpoint = (EndpointDescription) EasyMock.getCurrentArguments()[0];
-                actualEndpoints.addAll(endpoint.getInterfaces());
-                return null;
-            }
-        }).times(2);
-        EasyMock.replay(el);
-
-        ld.listenerTracker.modifiedService(sr, el);
-        assertEquals(1, ld.listenerToFilters.size());
-        assertEquals(Arrays.asList("(|(objectClass=org.example.ClassA)(objectClass=org.example.ClassB))"),
-            ld.listenerToFilters.get(el));
-        assertEquals(1, ld.filterToListeners.size());
-        assertEquals(Collections.singletonList(el),
-            ld.filterToListeners.get("(|(objectClass=org.example.ClassA)(objectClass=org.example.ClassB))"));
-
-        EasyMock.verify(el);
-        Set<String> expectedEndpoints = new HashSet<String>(Arrays.asList("org.example.ClassA", "org.example.ClassB"));
-        assertEquals(expectedEndpoints, actualEndpoints);
-
-        // Remove the EndpointListener Service
-        ld.listenerTracker.removedService(sr, el);
-        assertEquals(0, ld.listenerToFilters.size());
-        assertEquals(0, ld.filterToListeners.size());
-    }
-
-    public void testRegisterTracker() throws Exception {
-        LocalDiscovery ld = getLocalDiscovery();
-
-        final Map<String, Object> props = new Hashtable<String, Object>();
-        props.put(EndpointListener.ENDPOINT_LISTENER_SCOPE, "(objectClass=Aaaa)");
-        @SuppressWarnings("unchecked")
-        ServiceReference<EndpointListener> sr = EasyMock.createMock(ServiceReference.class);
-        EasyMock.expect(sr.getPropertyKeys()).andReturn(props.keySet().toArray(new String[] {})).anyTimes();
-        EasyMock.expect(sr.getProperty((String) EasyMock.anyObject())).andAnswer(new IAnswer<Object>() {
-            public Object answer() throws Throwable {
-                return props.get(EasyMock.getCurrentArguments()[0]);
-            }
-        }).anyTimes();
-        EasyMock.replay(sr);
-
-        EndpointListener endpointListener = EasyMock.createMock(EndpointListener.class);
-        EasyMock.replay(endpointListener);
-
-        assertEquals("Precondition failed", 0, ld.listenerToFilters.size());
-        assertEquals("Precondition failed", 0, ld.filterToListeners.size());
-        ld.addListener(sr, endpointListener);
-
-        assertEquals(1, ld.listenerToFilters.size());
-        assertEquals(Collections.singletonList("(objectClass=Aaaa)"), ld.listenerToFilters.get(endpointListener));
-        assertEquals(1, ld.filterToListeners.size());
-        assertEquals(Collections.singletonList(endpointListener), ld.filterToListeners.get("(objectClass=Aaaa)"));
-
-        // Add another one with the same scope filter
-        @SuppressWarnings("unchecked")
-        ServiceReference<EndpointListener> sr2 = EasyMock.createMock(ServiceReference.class);
-        EasyMock.expect(sr2.getPropertyKeys()).andReturn(props.keySet().toArray(new String[] {})).anyTimes();
-        EasyMock.expect(sr2.getProperty((String) EasyMock.anyObject())).andAnswer(new IAnswer<Object>() {
-            public Object answer() throws Throwable {
-                return props.get(EasyMock.getCurrentArguments()[0]);
-            }
-        }).anyTimes();
-        EasyMock.replay(sr2);
-
-        EndpointListener endpointListener2 = EasyMock.createMock(EndpointListener.class);
-        EasyMock.replay(endpointListener2);
-        ld.addListener(sr2, endpointListener2);
-
-        assertEquals(2, ld.listenerToFilters.size());
-        assertEquals(Collections.singletonList("(objectClass=Aaaa)"), ld.listenerToFilters.get(endpointListener));
-        assertEquals(Collections.singletonList("(objectClass=Aaaa)"), ld.listenerToFilters.get(endpointListener2));
-
-        assertEquals(1, ld.filterToListeners.size());
-        List<EndpointListener> endpointListeners12 = Arrays.asList(endpointListener, endpointListener2);
-        assertEquals(endpointListeners12, ld.filterToListeners.get("(objectClass=Aaaa)"));
-
-        // Add another listener with a multi-value scope
-        final Map<String, Object> props2 = new Hashtable<String, Object>();
-        props2.put(EndpointListener.ENDPOINT_LISTENER_SCOPE, Arrays.asList("(objectClass=X)", "(objectClass=Y)"));
-        @SuppressWarnings("unchecked")
-        ServiceReference<EndpointListener> sr3 = EasyMock.createMock(ServiceReference.class);
-        EasyMock.expect(sr3.getPropertyKeys()).andReturn(props2.keySet().toArray(new String[] {})).anyTimes();
-        EasyMock.expect(sr3.getProperty((String) EasyMock.anyObject())).andAnswer(new IAnswer<Object>() {
-            public Object answer() throws Throwable {
-                return props2.get(EasyMock.getCurrentArguments()[0]);
-            }
-        }).anyTimes();
-        EasyMock.replay(sr3);
-
-        EndpointListener endpointListener3 = EasyMock.createMock(EndpointListener.class);
-        EasyMock.replay(endpointListener3);
-        ld.addListener(sr3, endpointListener3);
-
-        assertEquals(3, ld.listenerToFilters.size());
-        assertEquals(Collections.singletonList("(objectClass=Aaaa)"), ld.listenerToFilters.get(endpointListener));
-        assertEquals(Collections.singletonList("(objectClass=Aaaa)"), ld.listenerToFilters.get(endpointListener2));
-        assertEquals(Arrays.asList("(objectClass=X)", "(objectClass=Y)"), ld.listenerToFilters.get(endpointListener3));
-
-        assertEquals(3, ld.filterToListeners.size());
-        assertEquals(endpointListeners12, ld.filterToListeners.get("(objectClass=Aaaa)"));
-        assertEquals(Collections.singletonList(endpointListener3), ld.filterToListeners.get("(objectClass=X)"));
-        assertEquals(Collections.singletonList(endpointListener3), ld.filterToListeners.get("(objectClass=Y)"));
-    }
-
-    public void testClearTracker() throws Exception {
-        LocalDiscovery ld = getLocalDiscovery();
-
-        EndpointListener endpointListener = EasyMock.createMock(EndpointListener.class);
-        ld.listenerToFilters.put(endpointListener,
-                new ArrayList<String>(Arrays.asList("(a=b)", "(objectClass=foo.bar.Bheuaark)")));
-        ld.filterToListeners.put("(a=b)", new ArrayList<EndpointListener>(Arrays.asList(endpointListener)));
-        ld.filterToListeners.put("(objectClass=foo.bar.Bheuaark)",
-                new ArrayList<EndpointListener>(Arrays.asList(endpointListener)));
-
-        assertEquals(1, ld.listenerToFilters.size());
-        assertEquals(2, ld.filterToListeners.size());
-        assertEquals(1, ld.filterToListeners.values().iterator().next().size());
-        ld.removeListener(EasyMock.createMock(EndpointListener.class));
-        assertEquals(1, ld.listenerToFilters.size());
-        assertEquals(2, ld.filterToListeners.size());
-        assertEquals(1, ld.filterToListeners.values().iterator().next().size());
-        ld.removeListener(endpointListener);
-        assertEquals(0, ld.listenerToFilters.size());
-        assertEquals(0, ld.filterToListeners.size());
-    }
-
-    private LocalDiscovery getLocalDiscovery() throws InvalidSyntaxException {
-        BundleContext bc = EasyMock.createMock(BundleContext.class);
-        EasyMock.expect(bc.createFilter((String) EasyMock.anyObject())).andAnswer(new IAnswer<Filter>() {
-            public Filter answer() throws Throwable {
-                return FrameworkUtil.createFilter((String) EasyMock.getCurrentArguments()[0]);
-            }
-        }).anyTimes();
-        bc.addServiceListener((ServiceListener) EasyMock.anyObject(),
-            EasyMock.eq("(objectClass=org.osgi.service.remoteserviceadmin.EndpointListener)"));
-        EasyMock.expectLastCall();
-        EasyMock.expect(bc.getServiceReferences("org.osgi.service.remoteserviceadmin.EndpointListener", null))
-            .andReturn(null);
-        bc.addBundleListener((BundleListener) EasyMock.anyObject());
-        EasyMock.expectLastCall();
-        EasyMock.expect(bc.getBundles()).andReturn(null);
-        EasyMock.replay(bc);
-
-        return new LocalDiscovery(bc);
-    }
-}

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/5f4c6604/discovery/local/src/test/java/org/apache/cxf/dosgi/endpointdesc/EndpointDescriptionBundleParserTest.java
----------------------------------------------------------------------
diff --git a/discovery/local/src/test/java/org/apache/cxf/dosgi/endpointdesc/EndpointDescriptionBundleParserTest.java b/discovery/local/src/test/java/org/apache/cxf/dosgi/endpointdesc/EndpointDescriptionBundleParserTest.java
deleted file mode 100644
index 4884c50..0000000
--- a/discovery/local/src/test/java/org/apache/cxf/dosgi/endpointdesc/EndpointDescriptionBundleParserTest.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cxf.dosgi.endpointdesc;
-
-import java.net.URL;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import junit.framework.TestCase;
-
-import org.apache.cxf.dosgi.discovery.local.util.Utils;
-import org.easymock.EasyMock;
-import org.osgi.framework.Bundle;
-import org.osgi.service.remoteserviceadmin.EndpointDescription;
-
-public class EndpointDescriptionBundleParserTest extends TestCase {
-
-    private Bundle createBundleContaining(URL ed1URL) {
-        Bundle b = EasyMock.createNiceMock(Bundle.class);
-        EasyMock.expect(b.findEntries(
-            EasyMock.eq("OSGI-INF/remote-service"),
-            EasyMock.eq("*.xml"), EasyMock.anyBoolean())).andReturn(
-                Collections.enumeration(Arrays.asList(ed1URL))).anyTimes();
-        EasyMock.replay(b);
-        return b;
-    }
-
-    public void testAllEndpoints1() {
-        URL ed1URL = getClass().getResource("/ed1.xml");
-
-        Bundle b = createBundleContaining(ed1URL);
-
-        List<EndpointDescription> endpoints = new EndpointDescriptionBundleParser().getAllEndpointDescriptions(b);
-        assertEquals(4, endpoints.size());
-        EndpointDescription endpoint0 = endpoints.get(0);
-        assertEquals("http://somewhere:12345", endpoint0.getId());
-        assertEquals(Arrays.asList("SomeService"), endpoint0.getInterfaces());
-        assertEquals(Arrays.asList("confidentiality"),
-            endpoint0.getProperties().get("osgi.remote.requires.intents"));
-        assertEquals("testValue", endpoint0.getProperties().get("testKey"));
-
-        EndpointDescription endpoint1 = endpoints.get(1);
-        assertEquals("myScheme://somewhere:12345", endpoint1.getId());
-        assertEquals(Arrays.asList("SomeOtherService", "WithSomeSecondInterface"), endpoint1.getInterfaces());
-
-        EndpointDescription endpoint2 = endpoints.get(2);
-        assertEquals("http://somewhere", endpoint2.getId());
-        assertEquals(Arrays.asList("SomeOtherService", "WithSomeSecondInterface"), endpoint2.getInterfaces());
-
-        EndpointDescription endpoint3 = endpoints.get(3);
-        assertEquals("http://somewhere:1/2/3/4?5", endpoint3.getId());
-        assertEquals(Arrays.asList("SomeOtherService", "WithSomeSecondInterface"), endpoint3.getInterfaces());
-    }
-
-    public void testAllEndpoints2() throws Exception {
-        URL ed2URL = getClass().getResource("/ed2.xml");
-
-        Bundle b = createBundleContaining(ed2URL);
-
-        List<EndpointDescription> endpoints = new EndpointDescriptionBundleParser().getAllEndpointDescriptions(b);
-        assertEquals(2, endpoints.size());
-        EndpointDescription endpoint0 = endpoints.get(0);
-        assertEquals("foo:bar", endpoint0.getId());
-        assertEquals(Arrays.asList("com.acme.HelloService"), endpoint0.getInterfaces());
-        assertEquals(Arrays.asList("SOAP"), endpoint0.getIntents());
-        // changed from exported to imported
-        assertEquals("org.apache.cxf.ws", endpoint0.getProperties().get("service.imported.configs"));
-
-        EndpointDescription endpoint1 = endpoints.get(1);
-        Map<String, Object> props = endpoint1.getProperties();
-        assertEquals(Arrays.asList("com.acme.HelloService", "some.other.Service"), endpoint1.getInterfaces());
-        assertEquals("org.apache.cxf.ws", props.get("service.imported.configs"));
-        // exports should have been removed
-        assertNull(props.get("service.exported.configs"));
-
-        assertEquals(Utils.normXML("<other:t1 xmlns:other='http://www.acme.org/xmlns/other/v1.0.0' "
-            + "xmlns='http://www.acme.org/xmlns/other/v1.0.0'><foo type='bar'>haha</foo>\n"
-            + "        </other:t1>"),
-            Utils.normXML((String) props.get("someXML")));
-        assertEquals(Long.MAX_VALUE, props.get("long"));
-        assertEquals(-1L, props.get("long2"));
-        assertEquals(Double.MAX_VALUE, props.get("double"));
-        assertEquals(1.0d, props.get("Double2"));
-        assertEquals(42.24f, props.get("float"));
-        assertEquals(1.0f, props.get("Float2"));
-        assertEquals(17, props.get("int"));
-        assertEquals(42, props.get("Integer2"));
-        assertEquals((byte) 127, props.get("byte"));
-        assertEquals((byte) -128, props.get("Byte2"));
-        assertEquals(Boolean.TRUE, props.get("boolean"));
-        assertEquals(Boolean.TRUE, props.get("Boolean2"));
-        assertEquals((short) 99, props.get("short"));
-        assertEquals((short) -99, props.get("Short2"));
-        assertEquals('@', props.get("char"));
-        assertEquals('X', props.get("Character2"));
-
-        int[] intArray = (int[]) props.get("int-array");
-        assertTrue(Arrays.equals(new int[] {1, 2}, intArray));
-
-        Integer[] integerArray = (Integer[]) props.get("Integer-array");
-        assertTrue(Arrays.equals(new Integer[] {2, 1}, integerArray));
-
-        assertEquals(Arrays.asList(true, false), props.get("bool-list"));
-        assertEquals(new HashSet<Object>(), props.get("long-set"));
-        Set<String> stringSet = new HashSet<String>();
-        stringSet.add("Hello there");
-        stringSet.add("How are you?");
-        assertEquals(stringSet, props.get("string-set"));
-        assertEquals("Hello", props.get("other1").toString().trim());
-
-        List<?> l = (List<?>) props.get("other2");
-        assertEquals(1, l.size());
-        assertEquals(Utils.normXML("<other:t2 xmlns:other='http://www.acme.org/xmlns/other/v1.0.0' " 
-                                   + "xmlns='http://www.osgi.org/xmlns/rsa/v1.0.0'/>"),
-                                   Utils.normXML((String) l.get(0)));
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/5f4c6604/discovery/local/src/test/java/org/apache/cxf/dosgi/endpointdesc/EndpointDescriptionParserTest.java
----------------------------------------------------------------------
diff --git a/discovery/local/src/test/java/org/apache/cxf/dosgi/endpointdesc/EndpointDescriptionParserTest.java b/discovery/local/src/test/java/org/apache/cxf/dosgi/endpointdesc/EndpointDescriptionParserTest.java
deleted file mode 100644
index 97e4b45..0000000
--- a/discovery/local/src/test/java/org/apache/cxf/dosgi/endpointdesc/EndpointDescriptionParserTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cxf.dosgi.endpointdesc;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.List;
-
-import org.easymock.EasyMock;
-import org.junit.Assert;
-import org.junit.Test;
-import org.osgi.framework.Bundle;
-import org.osgi.xmlns.rsa.v1_0.EndpointDescriptionType;
-
-public class EndpointDescriptionParserTest {
-
-    @Test
-    public void testNoRemoteServicesXMLFiles() {
-        Bundle b = EasyMock.createNiceMock(Bundle.class);
-        EasyMock.replay(b);
-
-        List<EndpointDescriptionType> rsElements = new EndpointDescriptionBundleParser().getAllDescriptionElements(b);
-        Assert.assertEquals(0, rsElements.size());
-    }
-
-    @Test
-    public void testEndpointDescriptionsFromURL() throws IOException {
-        URL ed1URL = getClass().getResource("/ed1.xml");
-        List<EndpointDescriptionType> edElements = new EndpointDescriptionParser().
-            getEndpointDescriptions(ed1URL.openStream());
-        Assert.assertEquals(4, edElements.size());
-    }
-}

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/5f4c6604/discovery/local/src/test/java/org/apache/cxf/dosgi/endpointdesc/PropertiesMapperTest.java
----------------------------------------------------------------------
diff --git a/discovery/local/src/test/java/org/apache/cxf/dosgi/endpointdesc/PropertiesMapperTest.java b/discovery/local/src/test/java/org/apache/cxf/dosgi/endpointdesc/PropertiesMapperTest.java
deleted file mode 100644
index bc21198..0000000
--- a/discovery/local/src/test/java/org/apache/cxf/dosgi/endpointdesc/PropertiesMapperTest.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cxf.dosgi.endpointdesc;
-
-import java.io.ByteArrayInputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.xml.sax.InputSource;
-
-import org.custommonkey.xmlunit.XMLAssert;
-import org.junit.Test;
-import org.osgi.xmlns.rsa.v1_0.EndpointDescriptionType;
-import org.osgi.xmlns.rsa.v1_0.PropertyType;
-
-public class PropertiesMapperTest {
-    private static final String LF = "\n";
-
-    @Test
-    public void testCreateXML() throws Exception {
-        Map<String, Object> m = new LinkedHashMap<String, Object>();
-        m.put("service.imported.configs", "org.apache.cxf.ws");
-        m.put("endpoint.id", "foo:bar");
-        m.put("objectClass", new String[] {"com.acme.HelloService", "some.other.Service"});
-        m.put("SomeObject", new Object());
-        m.put("long", 9223372036854775807L);
-        m.put("Long2", -1L);
-        m.put("double", 1.7976931348623157E308);
-        m.put("Double2", 1.0d);
-        m.put("float", 42.24f);
-        m.put("Float2", 1.0f);
-        m.put("int", 17);
-        m.put("Integer2", 42);
-        m.put("byte", (byte) 127);
-        m.put("Byte2", (byte) -128);
-        m.put("boolean", true);
-        m.put("Boolean2", false);
-        m.put("short", (short) 99);
-        m.put("Short2", (short) -99);
-        m.put("char", '@');
-        m.put("Character2", 'X');
-
-        List<Boolean> boolList = new ArrayList<Boolean>();
-        boolList.add(true);
-        boolList.add(false);
-        m.put("bool-list", boolList);
-        m.put("empty-set", new HashSet<Object>());
-
-        Set<String> stringSet = new LinkedHashSet<String>();
-        stringSet.add("Hello there");
-        stringSet.add("How are you?");
-        m.put("string-set", stringSet);
-
-        int[] intArray = new int[] {1, 2};
-        m.put("int-array", intArray);
-
-        String xml = "<xml>" + LF
-            + "<t1 xmlns=\"http://www.acme.org/xmlns/other/v1.0.0\">" + LF
-            + "<foo type='bar'>haha</foo>" + LF
-            + "</t1>" + LF
-            + "</xml>";
-        m.put("someXML", xml);
-
-        List<PropertyType> props = new PropertiesMapper().fromProps(m);
-        EndpointDescriptionType epd = new EndpointDescriptionType();
-        epd.getProperty().addAll(props);
-        byte[] epData = new EndpointDescriptionParser().getData(epd);
-
-        URL edURL = getClass().getResource("/ed2-generated.xml");
-        InputSource expectedXml = new InputSource(edURL.openStream());
-        InputSource actualXml = new InputSource(new ByteArrayInputStream(epData)); 
-        XMLAssert.assertXMLEqual(expectedXml, actualXml);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/5f4c6604/discovery/zookeeper-server-config/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/config/Activator.java
----------------------------------------------------------------------
diff --git a/discovery/zookeeper-server-config/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/config/Activator.java b/discovery/zookeeper-server-config/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/config/Activator.java
index a00c7b0..1243818 100644
--- a/discovery/zookeeper-server-config/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/config/Activator.java
+++ b/discovery/zookeeper-server-config/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/config/Activator.java
@@ -70,7 +70,7 @@ public class Activator implements BundleActivator {
         st.open();
 
         // The following section is done synchronously otherwise it doesn't happen in time for the CT
-        ServiceReference[] refs = context.getServiceReferences(ManagedService.class.getName(),
+        ServiceReference<?>[] refs = context.getServiceReferences(ManagedService.class.getName(),
                 "(service.pid=org.apache.cxf.dosgi.discovery.zookeeper)");
         if (refs == null || refs.length == 0) {
             throw new RuntimeException("This bundle must be started after the bundle with the ZooKeeper "

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/5f4c6604/discovery/zookeeper/pom.xml
----------------------------------------------------------------------
diff --git a/discovery/zookeeper/pom.xml b/discovery/zookeeper/pom.xml
index 576031a..e0c9db7 100644
--- a/discovery/zookeeper/pom.xml
+++ b/discovery/zookeeper/pom.xml
@@ -38,6 +38,11 @@
 
     <dependencies>
         <dependency>
+            <groupId>org.apache.aries.rsa</groupId>
+            <artifactId>spi</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
             <groupId>org.apache.zookeeper</groupId>
             <artifactId>zookeeper</artifactId>
             <version>${zookeeper.version}</version>

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/5f4c6604/discovery/zookeeper/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListener.java
----------------------------------------------------------------------
diff --git a/discovery/zookeeper/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListener.java b/discovery/zookeeper/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListener.java
index c703b9f..d90e355 100644
--- a/discovery/zookeeper/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListener.java
+++ b/discovery/zookeeper/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListener.java
@@ -23,14 +23,15 @@ import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.UnknownHostException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.aries.rsa.discovery.endpoint.EndpointDescriptionParser;
+import org.apache.aries.rsa.discovery.endpoint.PropertiesMapper;
 import org.apache.cxf.dosgi.discovery.zookeeper.util.Utils;
-import org.apache.cxf.dosgi.endpointdesc.EndpointDescriptionParser;
-import org.apache.cxf.dosgi.endpointdesc.PropertiesMapper;
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.KeeperException.NoNodeException;
@@ -174,7 +175,7 @@ public class PublishingEndpointListener implements EndpointListener {
 
     private static void ensurePath(String path, ZooKeeper zk) throws KeeperException, InterruptedException {
         StringBuilder current = new StringBuilder();
-        String[] parts = Utils.removeEmpty(path.split("/"));
+        List<String> parts = Utils.removeEmpty(Arrays.asList(path.split("/")));
         for (String part : parts) {
             current.append('/');
             current.append(part);

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/5f4c6604/discovery/zookeeper/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerFactory.java
----------------------------------------------------------------------
diff --git a/discovery/zookeeper/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerFactory.java b/discovery/zookeeper/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerFactory.java
index c505bb4..76d79eb 100644
--- a/discovery/zookeeper/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerFactory.java
+++ b/discovery/zookeeper/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerFactory.java
@@ -46,7 +46,7 @@ public class PublishingEndpointListenerFactory implements ServiceFactory<Publish
     private final BundleContext bctx;
     private final ZooKeeper zk;
     private final List<PublishingEndpointListener> listeners = new ArrayList<PublishingEndpointListener>();
-    private ServiceRegistration serviceRegistration;
+    private ServiceRegistration<?> serviceRegistration;
 
     public PublishingEndpointListenerFactory(ZooKeeper zk, BundleContext bctx) {
         this.bctx = bctx;

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/5f4c6604/discovery/zookeeper/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitor.java
----------------------------------------------------------------------
diff --git a/discovery/zookeeper/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitor.java b/discovery/zookeeper/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitor.java
index 95277d3..3822b6e 100644
--- a/discovery/zookeeper/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitor.java
+++ b/discovery/zookeeper/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitor.java
@@ -24,9 +24,9 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.aries.rsa.discovery.endpoint.EndpointDescriptionParser;
+import org.apache.aries.rsa.discovery.endpoint.PropertiesMapper;
 import org.apache.cxf.dosgi.discovery.zookeeper.util.Utils;
-import org.apache.cxf.dosgi.endpointdesc.EndpointDescriptionParser;
-import org.apache.cxf.dosgi.endpointdesc.PropertiesMapper;
 import org.apache.zookeeper.AsyncCallback.StatCallback;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.KeeperException.Code;

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/5f4c6604/discovery/zookeeper/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorManager.java
----------------------------------------------------------------------
diff --git a/discovery/zookeeper/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorManager.java b/discovery/zookeeper/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorManager.java
index 240e5ea..7da98de 100644
--- a/discovery/zookeeper/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorManager.java
+++ b/discovery/zookeeper/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorManager.java
@@ -20,24 +20,26 @@ package org.apache.cxf.dosgi.discovery.zookeeper.subscribe;
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Dictionary;
 import java.util.HashMap;
+import java.util.Hashtable;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.CopyOnWriteArrayList;
 
+
 import org.apache.cxf.dosgi.discovery.zookeeper.ZooKeeperDiscovery;
 import org.apache.cxf.dosgi.discovery.zookeeper.util.Utils;
 import org.apache.zookeeper.ZooKeeper;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.remoteserviceadmin.EndpointDescription;
 import org.osgi.service.remoteserviceadmin.EndpointListener;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static org.apache.cxf.dosgi.discovery.local.util.Utils.matchFilter;
-
 /**
  * Manages the EndpointListeners and the scopes they are interested in.
  * For each scope with interested EndpointListeners an InterfaceMonitor is created.
@@ -89,7 +91,6 @@ public class InterfaceMonitorManager {
                 endpointListener.getProperty(ZooKeeperDiscovery.DISCOVERY_ZOOKEEPER_ID)));
     }
 
-    @SuppressWarnings("unchecked")
     public synchronized void addInterest(ServiceReference<EndpointListener> endpointListener, 
                                          String scope, String objClass) {
         // get or create interest for given scope and add listener to it
@@ -178,6 +179,21 @@ public class InterfaceMonitorManager {
             }
         }
     }
+    
+    private static boolean matchFilter(BundleContext bctx, String filter, EndpointDescription endpoint) {
+        if (filter == null) {
+            return false;
+        }
+    
+        try {
+            Filter f = bctx.createFilter(filter);
+            Dictionary<String, Object> dict = new Hashtable<String, Object>(endpoint.getProperties());
+            return f.match(dict);
+        } catch (Exception e) {
+            return false;
+        }
+    }
+
 
     private void notifyListener(EndpointDescription endpoint, String currentScope, boolean isAdded,
                                 Bundle endpointListenerBundle, EndpointListener endpointListener) {