cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r1358632 - in /cxf/dosgi/trunk/discovery/local/src: main/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryUtils.java test/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryUtilsTest.java
Date Sat, 07 Jul 2012 19:40:30 GMT
Author: davidb
Date: Sat Jul  7 19:40:30 2012
New Revision: 1358632

URL: http://svn.apache.org/viewvc?rev=1358632&view=rev
Log:
Avoid the publication of service properties which are not part of the 
supported set of properties as listed in the OSGi Remote Service Admin
spec section 122.8.1

Also updated unit test to reflect this.

Modified:
    cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryUtils.java
    cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryUtilsTest.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=1358632&r1=1358631&r2=1358632&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
Sat Jul  7 19:40:30 2012
@@ -1,20 +1,20 @@
-/** 
-  * 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;
 
@@ -52,21 +52,21 @@ import org.osgi.service.remoteserviceadm
 
 
 public final class LocalDiscoveryUtils {
-    private static final Logger LOG = 
-        Logger.getLogger(LocalDiscoveryUtils.class.getName());        
-    
+    private static final Logger LOG =
+        Logger.getLogger(LocalDiscoveryUtils.class.getName());
+
     private static final String REMOTE_SERVICES_HEADER_NAME = "Remote-Service";
     private static final String REMOTE_SERVICES_DIRECTORY =
         "OSGI-INF/remote-service/";
     private static final String REMOTE_SERVICES_NS =
         "http://www.osgi.org/xmlns/sd/v1.0.0"; // this one was replaced by the RSA one in
the spec
-    private static final String REMOTE_SERVICES_ADMIN_NS = 
+    private static final String REMOTE_SERVICES_ADMIN_NS =
         "http://www.osgi.org/xmlns/rsa/v1.0.0";
-    
-    
+
+
     private static final String SERVICE_DESCRIPTION_ELEMENT = "service-description";
     private static final String ENDPOINT_DESCRIPTION_ELEMENT = "endpoint-description";
-    
+
     private static final String PROVIDE_INTERFACE_ELEMENT = "provide";
     private static final String PROVIDE_INTERFACE_NAME_ATTRIBUTE = "interface";
 
@@ -77,14 +77,14 @@ public final class LocalDiscoveryUtils {
     private static final String PROPERTY_INTERFACE_ATTRIBUTE = "interface";
 
     private static final String INTERFACE_SEPARATOR = ":";
-    
+
     static boolean addEndpointID = true; // for testing
-    
+
     private LocalDiscoveryUtils() {}
-    
+
     public static List<EndpointDescription> getAllEndpointDescriptions(Bundle b) {
         List<Element> elements = getAllDescriptionElements(b);
-        
+
         List<EndpointDescription> eds = new ArrayList<EndpointDescription>(elements.size());
         for (Element el : elements) {
             if (ENDPOINT_DESCRIPTION_ELEMENT.equals(el.getName())) {
@@ -99,7 +99,7 @@ public final class LocalDiscoveryUtils {
     @SuppressWarnings("unchecked")
     public static EndpointDescription getEndpointDescription(Element endpointDescriptionElement)
{
         Map<String, Object> map = new HashMap<String, Object>();
-        
+
         List<Element> properties = endpointDescriptionElement.getChildren(PROPERTY_ELEMENT,
                 Namespace.getNamespace(REMOTE_SERVICES_ADMIN_NS));
         for (Element prop : properties) {
@@ -115,7 +115,7 @@ public final class LocalDiscoveryUtils {
             if (handled) {
                 continue;
             }
-            
+
             String name = prop.getAttributeValue(PROPERTY_NAME_ATTRIBUTE);
             String value = prop.getAttributeValue(PROPERTY_VALUE_ATTRIBUTE);
             if (value == null) {
@@ -133,11 +133,11 @@ public final class LocalDiscoveryUtils {
 
         List<String> iNames = getProvidedInterfaces(el.getChildren(PROVIDE_INTERFACE_ELEMENT,
ns));
         Map<String, Object> remoteProps = getProperties(el.getChildren(PROPERTY_ELEMENT,
ns));
-        
+
         if (remoteProps.get(Constants.OBJECTCLASS) == null) {
             remoteProps.put(Constants.OBJECTCLASS, iNames.toArray(new String[] {}));
         }
-        
+
         Object uri = remoteProps.get("org.apache.cxf.ws.address");
         if (uri == null) {
             uri = remoteProps.get("osgi.remote.configuration.pojo.address");
@@ -147,21 +147,21 @@ public final class LocalDiscoveryUtils {
             uri = "http://localhost:9000/" + firstIntf.replace('.', '/');
         }
         remoteProps.put(RemoteConstants.ENDPOINT_ID, uri.toString());
-        
+
         Object exportedConfigs = remoteProps.get(RemoteConstants.SERVICE_EXPORTED_CONFIGS);
         if (exportedConfigs == null) {
             exportedConfigs = "org.apache.cxf.ws";
         }
         remoteProps.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, exportedConfigs);
-        
+
         for(Iterator<String> it = remoteProps.keySet().iterator(); it.hasNext(); )
{
             if (it.next().startsWith("service.exported.")) {
                 it.remove();
             }
         }
-        
+
         return new EndpointDescription(remoteProps);
-    } 
+    }
 
     private static String getTypeName(Element prop) {
         String type = prop.getAttributeValue(PROPERTY_VALUE_TYPE_ATTRIBUTE);
@@ -177,8 +177,8 @@ public final class LocalDiscoveryUtils {
         if (arrayEl == null) {
             return false;
         }
-        
-        List<Element> values = arrayEl.getChildren(PROPERTY_VALUE_ATTRIBUTE, 
+
+        List<Element> values = arrayEl.getChildren(PROPERTY_VALUE_ATTRIBUTE,
                 Namespace.getNamespace(REMOTE_SERVICES_ADMIN_NS));
         String type = getTypeName(prop);
         Class<?> cls = null;
@@ -196,20 +196,20 @@ public final class LocalDiscoveryUtils {
             cls = boolean.class;
         } else if ("short".equals(type)) {
             cls = short.class;
-        }            
+        }
 
         try {
             if (cls == null) {
                 cls = ClassLoader.getSystemClassLoader().loadClass("java.lang." + type);
             }
             Object array = Array.newInstance(cls, values.size());
-            
+
             for (int i=0; i < values.size(); i++) {
                 Element vEl = values.get(i);
                 Object val = handleValue(vEl, type);
                 Array.set(array, i, val);
             }
-            
+
             String name = prop.getAttributeValue(PROPERTY_NAME_ATTRIBUTE);
             map.put(name, array);
             return true;
@@ -221,7 +221,7 @@ public final class LocalDiscoveryUtils {
 
     @SuppressWarnings("unchecked")
     private static boolean handleCollection(Element prop, Map<String, Object> map)
{
-        Collection<Object> col = null;        
+        Collection<Object> col = null;
         Element el = prop.getChild("list",
                 Namespace.getNamespace(REMOTE_SERVICES_ADMIN_NS));
         if (el != null) {
@@ -232,19 +232,19 @@ public final class LocalDiscoveryUtils {
                 col = new HashSet<Object>();
             }
         }
-                
+
         if (el == null) {
             return false;
         }
-        
+
         String type = getTypeName(prop);
-        List<Element> values = el.getChildren(PROPERTY_VALUE_ATTRIBUTE, 
+        List<Element> values = el.getChildren(PROPERTY_VALUE_ATTRIBUTE,
                 Namespace.getNamespace(REMOTE_SERVICES_ADMIN_NS));
         for (Element val : values) {
             Object obj = handleValue(val, type);
             col.add(obj);
         }
-        
+
         String name = prop.getAttributeValue(PROPERTY_NAME_ATTRIBUTE);
         map.put(name, col);
         return true;
@@ -267,15 +267,15 @@ public final class LocalDiscoveryUtils {
         if (el == null) {
             return null;
         }
-        
+
         String type = getTypeName(prop);
         if (!"String".equals(type)) {
             LOG.warning("Embedded XML must be of type String, found: " + type);
             return null;
         }
-        
+
         XMLOutputter outputter = new XMLOutputter(Format.getCompactFormat());
-        StringBuilder sb = new StringBuilder();    
+        StringBuilder sb = new StringBuilder();
         List<Element> children = el.getChildren();
         for (Element child : children) {
             sb.append(outputter.outputString(child));
@@ -296,7 +296,7 @@ public final class LocalDiscoveryUtils {
         if ("String".equals(type)) {
             return value;
         }
-        
+
         value = value.trim();
         String boxedType = null;
         if ("long".equals(type)) {
@@ -316,12 +316,12 @@ public final class LocalDiscoveryUtils {
         } else if ("short".equals(type)) {
             boxedType = "Short";
         }
-        
+
         if (boxedType == null) {
             boxedType = type;
         }
         String javaType = "java.lang." + boxedType;
-        
+
         try {
             if (boxedType.equals("Character")) {
                 return new Character(value.charAt(0));
@@ -339,16 +339,16 @@ public final class LocalDiscoveryUtils {
     @SuppressWarnings("unchecked")
     static List<Element> getAllDescriptionElements(Bundle b) {
         Object header = null;
-        
+
         Dictionary headers = b.getHeaders();
         if (headers != null) {
             header = headers.get(REMOTE_SERVICES_HEADER_NAME);
         }
-        
+
         if (header == null) {
             header = REMOTE_SERVICES_DIRECTORY;
         }
-        
+
         String dir = header.toString();
         String filePattern = "*.xml";
         if (dir.endsWith("/")) {
@@ -363,7 +363,7 @@ public final class LocalDiscoveryUtils {
                 dir = "";
             }
         }
-        
+
         Enumeration urls = b.findEntries(dir, filePattern, false);
         if (urls == null) {
             return Collections.emptyList();
@@ -376,21 +376,21 @@ public final class LocalDiscoveryUtils {
                 elements.addAll(getElements(resourceURL.openStream()));
             } catch (Exception ex) {
                 LOG.log(Level.WARNING, "Problem parsing: " + resourceURL, ex);
-            }            
+            }
         }
-        return elements; 
+        return elements;
     }
-    
-    private static Map<String, Object> getProperties(List<Element> elements)
{       
+
+    private static Map<String, Object> getProperties(List<Element> elements)
{
         Map<String, Object> props = new HashMap<String, Object>();
-        
+
         for (Element p : elements) {
             String key = p.getAttributeValue(PROPERTY_NAME_ATTRIBUTE);
             String value = p.getAttributeValue(PROPERTY_VALUE_ATTRIBUTE);
             if (value == null) {
                 value = p.getTextTrim();
             }
-            
+
             String iface = p.getAttributeValue(PROPERTY_INTERFACE_ATTRIBUTE);
             if (key != null) {
                 props.put(iface == null || iface.length() == 0
@@ -399,23 +399,23 @@ public final class LocalDiscoveryUtils {
                           value);
             }
         }
-        
+
         return props;
     }
-    
-    private static List<String> getProvidedInterfaces(List<Element> elements)
{        
+
+    private static List<String> getProvidedInterfaces(List<Element> elements)
{
         List<String> names = new ArrayList<String>();
-        
+
         for (Element p : elements) {
             String name = p.getAttributeValue(PROVIDE_INTERFACE_NAME_ATTRIBUTE);
             if (name != null) {
                 names.add(name);
             }
         }
-        
+
         return names;
     }
-    
+
     public static List<String> getStringPlusProperty(ServiceReference sr, String key)
{
         Object value = sr.getProperty(key);
         if (value == null) {
@@ -464,7 +464,7 @@ public final class LocalDiscoveryUtils {
         for (Map.Entry entry : (Set<Map.Entry>) m.entrySet()) {
             String key = entry.getKey().toString();
             Object val = entry.getValue();
-            
+
             Element propEl = new Element("property", ns);
             propEl.setAttribute("name", key);
             if (val.getClass().isArray()) {
@@ -483,14 +483,25 @@ public final class LocalDiscoveryUtils {
             } else if (val instanceof Set) {
                 Element setEl = new Element("set", ns);
                 propEl.addContent(setEl);
-                handleCollectionValue(ns, (Collection) val, propEl, setEl);             
  
-            } else {
+                handleCollectionValue(ns, (Collection) val, propEl, setEl);
+            } else if (val instanceof String
+                    || val instanceof Long
+                    || val instanceof Double
+                    || val instanceof Float
+                    || val instanceof Integer
+                    || val instanceof Byte
+                    || val instanceof Character
+                    || val instanceof Boolean
+                    || val instanceof Short) {
                 setValueType(propEl, val);
                 propEl.setAttribute("value", val.toString());
+            } else {
+                // Don't add this property as the value type is not supported
+                continue;
             }
             contentEl.addContent(propEl);
         }
-        
+
         return new XMLOutputter(Format.getPrettyFormat()).outputString(d);
     }
 
@@ -552,7 +563,7 @@ public final class LocalDiscoveryUtils {
         if (val instanceof String) {
             return;
         }
-        
+
         String dataType = val.getClass().getName();
         if (dataType.startsWith("java.lang.")) {
             dataType = dataType.substring("java.lang.".length());
@@ -563,16 +574,16 @@ public final class LocalDiscoveryUtils {
     public static List<Element> getElements(InputStream in) throws JDOMException, IOException
{
 
         List<Element> elements = new ArrayList<Element>();
-        
+
         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 nsOld = Namespace.getNamespace(REMOTE_SERVICES_NS);
         elements.addAll(d.getRootElement().getChildren(SERVICE_DESCRIPTION_ELEMENT, nsOld));
-        
+
         return elements;
-    }    
+    }
 }

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=1358632&r1=1358631&r2=1358632&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
Sat Jul  7 19:40:30 2012
@@ -1,20 +1,20 @@
-/** 
- * 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;
 
@@ -54,48 +54,48 @@ public class LocalDiscoveryUtilsTest ext
     public void testNoRemoteServicesXMLFiles() {
         Bundle b = EasyMock.createNiceMock(Bundle.class);
         EasyMock.replay(b);
-        
+
         List<Element> rsElements = LocalDiscoveryUtils.getAllDescriptionElements(b);
-        assertEquals(0, rsElements.size());        
+        assertEquals(0, rsElements.size());
     }
-    
+
     public void testEndpointDescriptionXMLFiles() {
         URL ed1URL = getClass().getResource("/ed1.xml");
-        
+
         Bundle b = EasyMock.createNiceMock(Bundle.class);
         EasyMock.expect(b.findEntries(
-            EasyMock.eq("OSGI-INF/remote-service"), 
+            EasyMock.eq("OSGI-INF/remote-service"),
             EasyMock.eq("*.xml"), EasyMock.anyBoolean())).andReturn(
                 Collections.enumeration(Arrays.asList(ed1URL))).anyTimes();
         EasyMock.replay(b);
-        
+
         List<Element> edElements = LocalDiscoveryUtils.getAllDescriptionElements(b);
         assertEquals(4, edElements.size());
     }
-    
+
     public void testAllEndpoints1() {
         URL ed1URL = getClass().getResource("/ed1.xml");
-        
+
         Bundle b = EasyMock.createNiceMock(Bundle.class);
         EasyMock.expect(b.findEntries(
-            EasyMock.eq("OSGI-INF/remote-service"), 
+            EasyMock.eq("OSGI-INF/remote-service"),
             EasyMock.eq("*.xml"), EasyMock.anyBoolean())).andReturn(
                 Collections.enumeration(Arrays.asList(ed1URL))).anyTimes();
         EasyMock.replay(b);
-        
+
         List<EndpointDescription> eds = LocalDiscoveryUtils.getAllEndpointDescriptions(b);
         assertEquals(4, eds.size());
         EndpointDescription ed0 = eds.get(0);
         assertEquals("http://somewhere:12345", ed0.getId());
         assertEquals(Arrays.asList("SomeService"), ed0.getInterfaces());
-        assertEquals(Arrays.asList("confidentiality"), 
+        assertEquals(Arrays.asList("confidentiality"),
             ed0.getProperties().get("osgi.remote.requires.intents"));
         assertEquals("testValue", ed0.getProperties().get("testKey"));
-        
+
         EndpointDescription ed1 = eds.get(1);
         assertEquals("myScheme://somewhere:12345", ed1.getId());
         assertEquals(Arrays.asList("SomeOtherService", "WithSomeSecondInterface"), ed1.getInterfaces());
-        
+
         EndpointDescription ed2 = eds.get(2);
         assertEquals("http://somewhere", ed2.getId());
         assertEquals(Arrays.asList("SomeOtherService", "WithSomeSecondInterface"), ed2.getInterfaces());
@@ -104,37 +104,37 @@ public class LocalDiscoveryUtilsTest ext
         assertEquals("http://somewhere:1/2/3/4?5", ed3.getId());
         assertEquals(Arrays.asList("SomeOtherService", "WithSomeSecondInterface"), ed3.getInterfaces());
     }
-    
+
     @SuppressWarnings("unchecked")
     public void testAllEndpoints2() throws Exception {
         URL ed2URL = getClass().getResource("/ed2.xml");
-        
+
         Bundle b = EasyMock.createNiceMock(Bundle.class);
         EasyMock.expect(b.findEntries(
-            EasyMock.eq("OSGI-INF/remote-service"), 
+            EasyMock.eq("OSGI-INF/remote-service"),
             EasyMock.eq("*.xml"), EasyMock.anyBoolean())).andReturn(
                 Collections.enumeration(Arrays.asList(ed2URL))).anyTimes();
         EasyMock.replay(b);
-        
+
         List<EndpointDescription> eds = LocalDiscoveryUtils.getAllEndpointDescriptions(b);
         assertEquals(2, eds.size());
         EndpointDescription ed0 = eds.get(0);
         assertEquals("foo:bar", ed0.getId());
         assertEquals(Arrays.asList("com.acme.HelloService"), ed0.getInterfaces());
         assertEquals(Arrays.asList("SOAP"), ed0.getIntents());
-        // changed from exported to imported 
+        // changed from exported to imported
         assertEquals("org.apache.cxf.ws", ed0.getProperties().get("service.imported.configs"));
-        
+
         EndpointDescription ed1 = eds.get(1);
         Map<String, Object> props = ed1.getProperties();
         assertEquals(Arrays.asList("com.acme.HelloService", "some.other.Service"), ed1.getInterfaces());
         assertEquals("org.apache.cxf.ws", props.get("service.imported.configs"));
         // 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"));
         assertEquals(new Long(-1), props.get("long2"));
         assertEquals(Double.MAX_VALUE, props.get("double"));
@@ -151,13 +151,13 @@ public class LocalDiscoveryUtilsTest ext
         assertEquals(new Short((short) -99), props.get("Short2"));
         assertEquals(new Character('@'), props.get("char"));
         assertEquals(new Character('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>();
@@ -165,54 +165,54 @@ public class LocalDiscoveryUtilsTest ext
         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(normXML("<other:t2 xmlns:other='http://www.acme.org/xmlns/other/v1.0.0'/>"),
             normXML((String) l.get(0)));
     }
-    
+
     public void testLegacyServiceDescriptionFormat() {
         URL sdURL = getClass().getResource("/sd.xml");
-        
+
         Bundle b = EasyMock.createNiceMock(Bundle.class);
         EasyMock.expect(b.findEntries(
-            EasyMock.eq("OSGI-INF/remote-service"), 
+            EasyMock.eq("OSGI-INF/remote-service"),
             EasyMock.eq("*.xml"), EasyMock.anyBoolean())).andReturn(
                 Collections.enumeration(Arrays.asList(sdURL))).anyTimes();
         EasyMock.replay(b);
-        
+
         List<EndpointDescription> eds = LocalDiscoveryUtils.getAllEndpointDescriptions(b);
         assertEquals(1, eds.size());
         EndpointDescription ed = eds.get(0);
         assertEquals("http://localhost:9090/greeter", ed.getId());
         assertEquals(Arrays.asList("org.apache.cxf.ws"), ed.getConfigurationTypes());
         assertEquals(Arrays.asList("org.apache.cxf.dosgi.samples.greeter.GreeterService"),
ed.getInterfaces());
-        assertNull("Should not contain service.exported.*", 
+        assertNull("Should not contain service.exported.*",
                 ed.getProperties().get(RemoteConstants.SERVICE_EXPORTED_INTERFACES));
-        assertNull("Should not contain service.exported.*", 
+        assertNull("Should not contain service.exported.*",
                 ed.getProperties().get(RemoteConstants.SERVICE_EXPORTED_CONFIGS));
     }
-    
+
     public void testLegacyServiceDescriptionFormat2() {
         URL sdURL = getClass().getResource("/sd2.xml");
-        
+
         Bundle b = EasyMock.createNiceMock(Bundle.class);
         EasyMock.expect(b.findEntries(
-            EasyMock.eq("OSGI-INF/remote-service"), 
+            EasyMock.eq("OSGI-INF/remote-service"),
             EasyMock.eq("*.xml"), EasyMock.anyBoolean())).andReturn(
                 Collections.enumeration(Arrays.asList(sdURL))).anyTimes();
         EasyMock.replay(b);
-        
+
         List<EndpointDescription> eds = LocalDiscoveryUtils.getAllEndpointDescriptions(b);
         assertEquals(2, eds.size());
-        
+
         EndpointDescription ed0 = eds.get(0);
         assertEquals("http://localhost:9000/org/example/SomeService", ed0.getId());
         assertEquals(Arrays.asList("org.apache.cxf.ws"), ed0.getConfigurationTypes());
         assertEquals(Arrays.asList("org.example.SomeService"), ed0.getInterfaces());
         assertEquals(Arrays.asList("confidentiality"), ed0.getIntents());
-        
+
         EndpointDescription ed1 = eds.get(1);
         assertEquals(Arrays.asList("SomeOtherService", "WithSomeSecondInterface"), ed1.getInterfaces());
         assertEquals("5", ed1.getProperties().get("blah"));
@@ -224,6 +224,7 @@ public class LocalDiscoveryUtilsTest ext
         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);
@@ -240,35 +241,35 @@ public class LocalDiscoveryUtilsTest ext
         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()); 
-        
+        m.put("empty-set", new HashSet());
+
         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 + 
+        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);        
-        
+        m.put("someXML", xml);
+
         String actual = LocalDiscoveryUtils.getEndpointDescriptionXML(m);
-        
+
         URL edURL = getClass().getResource("/ed2-generated.xml");
         String expected = new String(drainStream(edURL.openStream()));
         assertEquals(normXML(expected), normXML(actual));
     }
-    
+
     private static String normXML(String s) throws JDOMException, IOException {
         String s2 = stripComment(s);
         String s3 = stripProlog(s2);
@@ -276,16 +277,16 @@ public class LocalDiscoveryUtilsTest ext
         XMLOutputter outputter  = new XMLOutputter(Format.getPrettyFormat());
         return outputter.outputString(d);
     }
-    
-    private static String stripComment(String s) { 
-        return Pattern.compile("<!--(.*?)-->", Pattern.DOTALL).matcher(s).replaceAll("");
       
+
+    private static String stripComment(String s) {
+        return Pattern.compile("<!--(.*?)-->", Pattern.DOTALL).matcher(s).replaceAll("");
     }
-    
+
     private static String stripProlog(String s) {
         return s.replaceAll("<\\?(.*?)\\?>", "");
-    }         
-    
-    public static void drainStream(InputStream is, OutputStream os) throws IOException {
       
+    }
+
+    public static void drainStream(InputStream is, OutputStream os) throws IOException {
         byte[] bytes = new byte[8192];
 
         int length = 0;
@@ -303,7 +304,7 @@ public class LocalDiscoveryUtilsTest ext
             os.write(bytes, 0, offset);
         }
     }
-    
+
     public static byte [] drainStream(InputStream is) throws IOException {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         try {
@@ -313,5 +314,5 @@ public class LocalDiscoveryUtilsTest ext
             is.close();
         }
     }
-    
+
 }



Mime
View raw message