You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2012/12/11 20:51:59 UTC

svn commit: r1420365 - in /cxf/dosgi/trunk/discovery/local/src: main/java/org/apache/cxf/dosgi/discovery/local/ main/java/org/apache/cxf/dosgi/discovery/local/internal/ test/java/org/apache/cxf/dosgi/discovery/local/ test/java/org/apache/cxf/dosgi/disc...

Author: dkulp
Date: Tue Dec 11 19:51:57 2012
New Revision: 1420365

URL: http://svn.apache.org/viewvc?rev=1420365&view=rev
Log:
Cleanup of discovery/local

Modified:
    cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryUtils.java
    cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/internal/Activator.java
    cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/internal/LocalDiscovery.java
    cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryUtilsTest.java
    cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/internal/ActivatorTest.java
    cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/internal/LocalDiscoveryTest.java

Modified: cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryUtils.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryUtils.java?rev=1420365&r1=1420364&r2=1420365&view=diff
==============================================================================
--- cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryUtils.java (original)
+++ cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryUtils.java Tue Dec 11 19:51:57 2012
@@ -1,21 +1,21 @@
 /**
-  * 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.
-  */
+ * 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;
 
 import java.io.IOException;
@@ -77,9 +77,8 @@ public final class LocalDiscoveryUtils {
 
     private static final String INTERFACE_SEPARATOR = ":";
 
-    static boolean addEndpointID = true; // for testing
-
-    private LocalDiscoveryUtils() {}
+    private LocalDiscoveryUtils() {
+    }
 
     public static List<EndpointDescription> getAllEndpointDescriptions(Bundle b) {
         List<Element> elements = getAllDescriptionElements(b);
@@ -153,7 +152,7 @@ public final class LocalDiscoveryUtils {
         }
         remoteProps.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, exportedConfigs);
 
-        for(Iterator<String> it = remoteProps.keySet().iterator(); it.hasNext(); ) {
+        for (Iterator<String> it = remoteProps.keySet().iterator(); it.hasNext();) {
             if (it.next().startsWith("service.exported.")) {
                 it.remove();
             }
@@ -203,7 +202,7 @@ public final class LocalDiscoveryUtils {
             }
             Object array = Array.newInstance(cls, values.size());
 
-            for (int i=0; i < values.size(); i++) {
+            for (int i = 0; i < values.size(); i++) {
                 Element vEl = values.get(i);
                 Object val = handleValue(vEl, type);
                 Array.set(array, i, val);
@@ -322,7 +321,7 @@ public final class LocalDiscoveryUtils {
         String javaType = "java.lang." + boxedType;
 
         try {
-            if (boxedType.equals("Character")) {
+            if ("Character".equals(boxedType)) {
                 return new Character(value.charAt(0));
             } else {
                 Class<?> cls = ClassLoader.getSystemClassLoader().loadClass(javaType);
@@ -335,11 +334,10 @@ public final class LocalDiscoveryUtils {
         }
     }
 
-    @SuppressWarnings("unchecked")
     static List<Element> getAllDescriptionElements(Bundle b) {
         Object header = null;
 
-        Dictionary headers = b.getHeaders();
+        Dictionary<?, ?> headers = b.getHeaders();
         if (headers != null) {
             header = headers.get(REMOTE_SERVICES_HEADER_NAME);
         }
@@ -351,7 +349,7 @@ public final class LocalDiscoveryUtils {
         String dir = header.toString();
         String filePattern = "*.xml";
         if (dir.endsWith("/")) {
-            dir = dir.substring(0, dir.length()-1);
+            dir = dir.substring(0, dir.length() - 1);
         } else {
             int idx = dir.lastIndexOf('/');
             if (idx >= 0 & dir.length() > idx) {
@@ -363,7 +361,7 @@ public final class LocalDiscoveryUtils {
             }
         }
 
-        Enumeration urls = b.findEntries(dir, filePattern, false);
+        Enumeration<?> urls = b.findEntries(dir, filePattern, false);
         if (urls == null) {
             return Collections.emptyList();
         }
@@ -451,8 +449,7 @@ public final class LocalDiscoveryUtils {
         return Collections.emptyList();
     }
 
-    @SuppressWarnings("unchecked")
-    public static String getEndpointDescriptionXML(Map m) {
+    public static String getEndpointDescriptionXML(Map<String, Object> m) {
         Document d = new Document();
         Namespace ns = Namespace.getNamespace("http://www.osgi.org/xmlns/rsa/v1.0.0");
         Element rootEl = new Element("endpoint-descriptions", ns);
@@ -460,7 +457,7 @@ public final class LocalDiscoveryUtils {
         Element contentEl = new Element("endpoint-description", ns);
         rootEl.addContent(contentEl);
 
-        for (Map.Entry entry : (Set<Map.Entry>) m.entrySet()) {
+        for (Map.Entry<String, Object> entry : m.entrySet()) {
             String key = entry.getKey().toString();
             Object val = entry.getValue();
 
@@ -478,20 +475,23 @@ public final class LocalDiscoveryUtils {
             } else if (val instanceof List) {
                 Element listEl = new Element("list", ns);
                 propEl.addContent(listEl);
-                handleCollectionValue(ns, (Collection) val, propEl, listEl);
+                handleCollectionValue(ns, (Collection<?>) val, propEl, listEl);
             } else if (val instanceof Set) {
                 Element setEl = new Element("set", ns);
                 propEl.addContent(setEl);
-                handleCollectionValue(ns, (Collection) val, propEl, setEl);
+                handleCollectionValue(ns, (Collection<?>) val, propEl, setEl);
             } else if (val instanceof String
-                    || val instanceof Long
+                    || val instanceof Character
+                    || val instanceof Boolean
+                    || val instanceof Byte) {
+                setValueType(propEl, val);
+                propEl.setAttribute("value", val.toString());
+            } else if (val instanceof Long
                     || val instanceof Double
                     || val instanceof Float
                     || val instanceof Integer
-                    || val instanceof Byte
-                    || val instanceof Character
-                    || val instanceof Boolean
                     || val instanceof Short) {
+                //various numbers..   maybe "val instanceof Number"?
                 setValueType(propEl, val);
                 propEl.setAttribute("value", val.toString());
             } else {
@@ -504,9 +504,8 @@ public final class LocalDiscoveryUtils {
         return new XMLOutputter(Format.getPrettyFormat()).outputString(d);
     }
 
-    @SuppressWarnings("unchecked")
     private static Object [] normalizeArray(Object val) {
-        List l = new ArrayList();
+        List<Object> l = new ArrayList<Object>();
         if (val instanceof int[]) {
             int[] ia = (int []) val;
             for (int i : ia) {
@@ -548,8 +547,7 @@ public final class LocalDiscoveryUtils {
         return l.toArray();
     }
 
-    @SuppressWarnings("unchecked")
-    private static void handleCollectionValue(Namespace ns, Collection val, Element propEl, Element listEl) {
+    private static void handleCollectionValue(Namespace ns, Collection<?> val, Element propEl, Element listEl) {
         for (Object o : val) {
             setValueType(propEl, o);
             Element valueEl = new Element("value", ns);
@@ -570,6 +568,7 @@ public final class LocalDiscoveryUtils {
         propEl.setAttribute("value-type", dataType);
     }
 
+    @SuppressWarnings("unchecked")
     public static List<Element> getElements(InputStream in) throws JDOMException, IOException {
 
         List<Element> elements = new ArrayList<Element>();
@@ -577,7 +576,7 @@ public final class LocalDiscoveryUtils {
         Document d = new SAXBuilder().build(in);
         if (d.getRootElement().getNamespaceURI().equals(REMOTE_SERVICES_ADMIN_NS)) {
             elements.addAll(d.getRootElement().getChildren(ENDPOINT_DESCRIPTION_ELEMENT,
-                    Namespace.getNamespace(REMOTE_SERVICES_ADMIN_NS)));
+                                                           Namespace.getNamespace(REMOTE_SERVICES_ADMIN_NS)));
         }
 
         Namespace nsOld = Namespace.getNamespace(REMOTE_SERVICES_NS);

Modified: cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/internal/Activator.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/internal/Activator.java?rev=1420365&r1=1420364&r2=1420365&view=diff
==============================================================================
--- cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/internal/Activator.java (original)
+++ cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/internal/Activator.java Tue Dec 11 19:51:57 2012
@@ -1,21 +1,21 @@
-/** 
-  * 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. 
-  */
+/**
+ * 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 org.osgi.framework.BundleActivator;

Modified: cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/internal/LocalDiscovery.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/internal/LocalDiscovery.java?rev=1420365&r1=1420364&r2=1420365&view=diff
==============================================================================
--- cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/internal/LocalDiscovery.java (original)
+++ cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/internal/LocalDiscovery.java Tue Dec 11 19:51:57 2012
@@ -1,21 +1,21 @@
-/** 
-  * 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. 
-  */
+/**
+ * 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.util.ArrayList;
@@ -175,6 +175,7 @@ public class LocalDiscovery implements B
         case BundleEvent.STOPPED:
             removeServicesDeclaredInBundle(be.getBundle());
             break;
+        default:
         }
     }
 
@@ -187,7 +188,8 @@ public class LocalDiscovery implements B
     }
 
     private void removeServicesDeclaredInBundle(Bundle bundle) {
-        for (Iterator<Entry<EndpointDescription, Bundle>> i = endpointDescriptions.entrySet().iterator(); i.hasNext(); ) {
+        for (Iterator<Entry<EndpointDescription, Bundle>> i = endpointDescriptions.entrySet().iterator();
+            i.hasNext();) {
             Entry<EndpointDescription, Bundle> entry = i.next();
             if (bundle.equals(entry.getValue())) {
                 removedEndpointDescription(entry.getKey());

Modified: cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryUtilsTest.java?rev=1420365&r1=1420364&r2=1420365&view=diff
==============================================================================
--- cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryUtilsTest.java (original)
+++ cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryUtilsTest.java Tue Dec 11 19:51:57 2012
@@ -105,7 +105,6 @@ public class LocalDiscoveryUtilsTest ext
         assertEquals(Arrays.asList("SomeOtherService", "WithSomeSecondInterface"), ed3.getInterfaces());
     }
 
-    @SuppressWarnings("unchecked")
     public void testAllEndpoints2() throws Exception {
         URL ed2URL = getClass().getResource("/ed2.xml");
 
@@ -132,7 +131,8 @@ public class LocalDiscoveryUtilsTest ext
         // exports should have been removed
         assertNull(props.get("service.exported.configs"));
 
-        assertEquals(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></other:t1>"),
+        assertEquals(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></other:t1>"),
             normXML((String) props.get("someXML")));
 
         assertEquals(Long.MAX_VALUE, props.get("long"));
@@ -145,8 +145,8 @@ public class LocalDiscoveryUtilsTest ext
         assertEquals(new Integer(42), props.get("Integer2"));
         assertEquals(new Byte((byte) 127), props.get("byte"));
         assertEquals(new Byte((byte) -128), props.get("Byte2"));
-        assertEquals(new Boolean(true), props.get("boolean"));
-        assertEquals(new Boolean(true), props.get("Boolean2"));
+        assertEquals(Boolean.TRUE, props.get("boolean"));
+        assertEquals(Boolean.TRUE, props.get("Boolean2"));
         assertEquals(new Short((short) 99), props.get("short"));
         assertEquals(new Short((short) -99), props.get("Short2"));
         assertEquals(new Character('@'), props.get("char"));
@@ -166,7 +166,7 @@ public class LocalDiscoveryUtilsTest ext
         assertEquals(stringSet, props.get("string-set"));
         assertEquals("Hello", props.get("other1").toString().trim());
 
-        List l = (List) props.get("other2");
+        List<?> l = (List<?>) props.get("other2");
         assertEquals(1, l.size());
         assertEquals(normXML("<other:t2 xmlns:other='http://www.acme.org/xmlns/other/v1.0.0'/>"),
             normXML((String) l.get(0)));
@@ -218,9 +218,8 @@ public class LocalDiscoveryUtilsTest ext
         assertEquals("5", ed1.getProperties().get("blah"));
     }
 
-    @SuppressWarnings("unchecked")
     public void testCreateXML() throws Exception {
-        Map m = new LinkedHashMap();
+        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"});
@@ -246,9 +245,9 @@ public class LocalDiscoveryUtilsTest ext
         boolList.add(true);
         boolList.add(false);
         m.put("bool-list", boolList);
-        m.put("empty-set", new HashSet());
+        m.put("empty-set", new HashSet<Object>());
 
-        Set<String> stringSet= new LinkedHashSet<String>();
+        Set<String> stringSet = new LinkedHashSet<String>();
         stringSet.add("Hello there");
         stringSet.add("How are you?");
         m.put("string-set", stringSet);
@@ -256,11 +255,11 @@ public class LocalDiscoveryUtilsTest ext
         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>";
+        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);
 
         String actual = LocalDiscoveryUtils.getEndpointDescriptionXML(m);

Modified: cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/internal/ActivatorTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/internal/ActivatorTest.java?rev=1420365&r1=1420364&r2=1420365&view=diff
==============================================================================
--- cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/internal/ActivatorTest.java (original)
+++ cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/internal/ActivatorTest.java Tue Dec 11 19:51:57 2012
@@ -1,27 +1,25 @@
-/** 
-  * 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. 
-  */
+/**
+ * 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.apache.cxf.dosgi.discovery.local.internal.Activator;
-import org.apache.cxf.dosgi.discovery.local.internal.LocalDiscovery;
 import org.easymock.IAnswer;
 import org.easymock.classextension.EasyMock;
 import org.osgi.framework.BundleContext;

Modified: cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/internal/LocalDiscoveryTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/internal/LocalDiscoveryTest.java?rev=1420365&r1=1420364&r2=1420365&view=diff
==============================================================================
--- cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/internal/LocalDiscoveryTest.java (original)
+++ cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/internal/LocalDiscoveryTest.java Tue Dec 11 19:51:57 2012
@@ -1,21 +1,21 @@
-/** 
-  * 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. 
-  */
+/**
+ * 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;
@@ -33,7 +33,6 @@ import java.util.Set;
 
 import junit.framework.TestCase;
 
-import org.apache.cxf.dosgi.discovery.local.internal.LocalDiscovery;
 import org.easymock.EasyMock;
 import org.easymock.IAnswer;
 import org.osgi.framework.Bundle;
@@ -54,11 +53,13 @@ public class LocalDiscoveryTest extends 
         EasyMock.replay(filter);
         
         BundleContext bc = EasyMock.createMock(BundleContext.class);
-        EasyMock.expect(bc.createFilter("(objectClass=org.osgi.service.remoteserviceadmin.EndpointListener)")).andReturn(filter);
+        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);
+        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 {
@@ -91,11 +92,13 @@ public class LocalDiscoveryTest extends 
         EasyMock.replay(filter);
         
         BundleContext bc = EasyMock.createMock(BundleContext.class);
-        EasyMock.expect(bc.createFilter("(objectClass=org.osgi.service.remoteserviceadmin.EndpointListener)")).andReturn(filter);
+        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);
+        EasyMock.expect(bc.getServiceReferences("org.osgi.service.remoteserviceadmin.EndpointListener", null))
+            .andReturn(null);
         bc.addBundleListener((BundleListener) EasyMock.anyObject());
         EasyMock.expectLastCall();
         
@@ -150,7 +153,7 @@ public class LocalDiscoveryTest extends 
         assertEquals(0, ld.endpointDescriptions.size());
         
         // Create an EndpointListener
-        final Hashtable<String, Object> props = new Hashtable<String, Object>();
+        final Map<String, Object> props = new Hashtable<String, Object>();
         props.put(EndpointListener.ENDPOINT_LISTENER_SCOPE, "(objectClass=*)");
         ServiceReference sr = EasyMock.createMock(ServiceReference.class);
         EasyMock.expect(sr.getPropertyKeys()).andReturn(props.keySet().toArray(new String [] {})).anyTimes();
@@ -207,7 +210,7 @@ public class LocalDiscoveryTest extends 
         ld.bundleChanged(be);
         assertEquals(2, ld.endpointDescriptions.size());        
 
-        final Hashtable<String, Object> props = new Hashtable<String, Object>();
+        final Map<String, Object> props = new Hashtable<String, Object>();
         props.put(EndpointListener.ENDPOINT_LISTENER_SCOPE, new String [] {"(objectClass=org.example.ClassA)"});
         ServiceReference sr = EasyMock.createMock(ServiceReference.class);
         EasyMock.expect(sr.getPropertyKeys()).andReturn(props.keySet().toArray(new String [] {})).anyTimes();
@@ -249,7 +252,8 @@ public class LocalDiscoveryTest extends 
         
         // 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))");
+        props.put(EndpointListener.ENDPOINT_LISTENER_SCOPE,
+                  "(|(objectClass=org.example.ClassA)(objectClass=org.example.ClassB))");
         
         EasyMock.reset(el);
         final Set<String> actualEndpoints = new HashSet<String>();
@@ -289,7 +293,7 @@ public class LocalDiscoveryTest extends 
     public void testRegisterTracker() throws Exception {
         LocalDiscovery ld = getLocalDiscovery();
 
-        final Hashtable<String, Object> props = new Hashtable<String, Object>();
+        final Map<String, Object> props = new Hashtable<String, Object>();
         props.put(EndpointListener.ENDPOINT_LISTENER_SCOPE, "(objectClass=Aaaa)");
         ServiceReference sr = EasyMock.createMock(ServiceReference.class);
         EasyMock.expect(sr.getPropertyKeys()).andReturn(props.keySet().toArray(new String [] {})).anyTimes();
@@ -334,8 +338,8 @@ public class LocalDiscoveryTest extends 
         assertEquals(Arrays.asList(el, el2), ld.filterToListeners.get("(objectClass=Aaaa)"));
         
         // Add another listener with a multi-value scope
-        final Hashtable<String, Object> props2 = new Hashtable<String, Object>();
-        props2.put(EndpointListener.ENDPOINT_LISTENER_SCOPE, Arrays.asList("(objectClass=X)","(objectClass=Y)"));
+        final Map<String, Object> props2 = new Hashtable<String, Object>();
+        props2.put(EndpointListener.ENDPOINT_LISTENER_SCOPE, Arrays.asList("(objectClass=X)", "(objectClass=Y)"));
         ServiceReference 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>() {
@@ -352,7 +356,7 @@ public class LocalDiscoveryTest extends 
         assertEquals(3, ld.listenerToFilters.size());
         assertEquals(Collections.singletonList("(objectClass=Aaaa)"), ld.listenerToFilters.get(el));
         assertEquals(Collections.singletonList("(objectClass=Aaaa)"), ld.listenerToFilters.get(el2));
-        assertEquals(Arrays.asList("(objectClass=X)","(objectClass=Y)"), ld.listenerToFilters.get(el3));
+        assertEquals(Arrays.asList("(objectClass=X)", "(objectClass=Y)"), ld.listenerToFilters.get(el3));
 
         assertEquals(3, ld.filterToListeners.size());
         assertEquals(Arrays.asList(el, el2), ld.filterToListeners.get("(objectClass=Aaaa)"));
@@ -393,13 +397,13 @@ public class LocalDiscoveryTest extends 
         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);
+        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);
                 
-        LocalDiscovery ld = new LocalDiscovery(bc);
-        return ld;
+        return new LocalDiscovery(bc);
     }    
 }