You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by da...@apache.org on 2010/06/04 14:25:22 UTC

svn commit: r951390 - in /cxf/dosgi/trunk/dsw/cxf-dsw/src: main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractConfigurationHandler.java test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java

Author: davidb
Date: Fri Jun  4 12:25:21 2010
New Revision: 951390

URL: http://svn.apache.org/viewvc?rev=951390&view=rev
Log:
Fix for the endpoint properties and a test for it.

Modified:
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractConfigurationHandler.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractConfigurationHandler.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractConfigurationHandler.java?rev=951390&r1=951389&r2=951390&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractConfigurationHandler.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractConfigurationHandler.java Fri Jun  4 12:25:21 2010
@@ -96,21 +96,16 @@ public abstract class AbstractConfigurat
 
         copyEndpointProperties(sd, props);
 
-        String[] sa = new String[1];
-        sa[0] = iClass.getName();
-
+        String[] sa = new String[] {iClass.getName()};
+        String pkg = iClass.getPackage().getName();
+        
+        props.remove(org.osgi.framework.Constants.SERVICE_ID);
         props.put(org.osgi.framework.Constants.OBJECTCLASS, sa);
-        // endpointProps.put(RemoteConstants.SERVICE_IMPORTED, "someValue;-)"); // should be done when the
-        // service is imported
-        // endpointProps.put(RemoteConstants.SERVICE_REMOTE_ID, "TODO");
-
-        // FIXME: This key is not defined in the spec but is required by the EndpointDescription !!!!!
-        props.put(RemoteConstants.ENDPOINT_SERVICE_ID, 123L);
-
+        props.put(RemoteConstants.ENDPOINT_SERVICE_ID, sd.get(org.osgi.framework.Constants.SERVICE_ID));        
         props.put(RemoteConstants.ENDPOINT_FRAMEWORK_UUID, OsgiUtils.getUUID(getBundleContext()));
         props.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, importedConfigs);
-        props.put(RemoteConstants.ENDPOINT_PACKAGE_VERSION_ + sa[0], OsgiUtils.getVersion(iClass,
-                                                                                         getBundleContext()));
+        props.put(RemoteConstants.ENDPOINT_PACKAGE_VERSION_ + pkg, 
+                OsgiUtils.getVersion(iClass, getBundleContext()));
 
         for (String configurationType : importedConfigs) {
             if(Constants.WS_CONFIG_TYPE.equals(configurationType))

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java?rev=951390&r1=951389&r2=951390&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java Fri Jun  4 12:25:21 2010
@@ -699,6 +699,28 @@ public class PojoConfigurationTypeHandle
         Set<String> expectedIntents = new HashSet<String>(Arrays.asList(new String [] {"A", "B"}));
         assertEquals(expectedIntents, effectiveIntents);
     }
+    
+    public void testCreateEndpointProps() {
+        BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
+        EasyMock.expect(bc.getProperty("org.osgi.framework.uuid")).andReturn("some_uuid1");
+        EasyMock.replay(bc);
+        
+        PojoConfigurationTypeHandler pch = new PojoConfigurationTypeHandler(bc, null);
+        
+        Map<String, Object> sd = new HashMap<String, Object>();
+        sd.put(org.osgi.framework.Constants.SERVICE_ID, 42);
+        Map<String, Object> props = pch.createEndpointProps(sd, String.class, new String [] {"org.apache.cxf.ws"}, 
+                "http://localhost:12345", new String [] {"my_intent", "your_intent"});
+        
+        assertFalse(props.containsKey(org.osgi.framework.Constants.SERVICE_ID));
+        assertEquals(42, props.get(RemoteConstants.ENDPOINT_SERVICE_ID));
+        assertEquals("some_uuid1", props.get(RemoteConstants.ENDPOINT_FRAMEWORK_UUID));
+        assertEquals("http://localhost:12345", props.get(RemoteConstants.ENDPOINT_ID));
+        assertEquals(Arrays.asList("java.lang.String"), Arrays.asList((Object []) props.get(org.osgi.framework.Constants.OBJECTCLASS)));
+        assertEquals(Arrays.asList("org.apache.cxf.ws"), Arrays.asList((Object []) props.get(RemoteConstants.SERVICE_IMPORTED_CONFIGS)));
+        assertEquals(Arrays.asList("my_intent", "your_intent"), Arrays.asList((Object []) props.get(RemoteConstants.SERVICE_INTENTS)));
+        assertEquals("0.0.0", props.get("endpoint.package.version.java.lang"));
+    }
 //    
 //    public void testServiceExposedAdminEvent() throws Exception {
 //        EventAdmin ea = EasyMock.createMock(EventAdmin.class);