cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r1442924 - in /cxf/dosgi/trunk/dsw/cxf-dsw/src: main/java/org/apache/cxf/dosgi/dsw/ main/java/org/apache/cxf/dosgi/dsw/handlers/ main/java/org/apache/cxf/dosgi/dsw/qos/ main/java/org/apache/cxf/dosgi/dsw/service/ main/java/org/apache/cxf/do...
Date Wed, 06 Feb 2013 12:20:44 GMT
Author: davidb
Date: Wed Feb  6 12:20:44 2013
New Revision: 1442924

URL: http://svn.apache.org/viewvc?rev=1442924&view=rev
Log:
DOSGI-156 Fix for failures when run with OSGi CTs

This commit provides fixes for most, possibly all of the failures experienced with the OSGi Remote Services and Remote Service Admin CTs. 
There is a small number of CT failures that relate to the arrival of events, but it looks like there might be an error in the CT logic around this. I have raised an issue against the CT for this. 
I added unit tests for most of the behaviour that I changed, but am planning to add more unit tests in subsequent commits.


Added:
    cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/EventProducerTest.java
Modified:
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactory.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentUtils.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/EventProducer.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ExportRegistrationImpl.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminInstance.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/util/OsgiUtils.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentUtilsTest.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/UtilsTest.java

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java?rev=1442924&r1=1442923&r2=1442924&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java Wed Feb  6 12:20:44 2013
@@ -18,10 +18,12 @@
  */
 package org.apache.cxf.dosgi.dsw;
 
+import java.util.ArrayList;
 import java.util.Dictionary;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Hashtable;
+import java.util.List;
 import java.util.Map;
 
 import org.apache.cxf.Bus;
@@ -35,7 +37,6 @@ import org.apache.cxf.dosgi.dsw.qos.Inte
 import org.apache.cxf.dosgi.dsw.qos.IntentManagerImpl;
 import org.apache.cxf.dosgi.dsw.qos.IntentMap;
 import org.apache.cxf.dosgi.dsw.qos.IntentTracker;
-import org.apache.cxf.dosgi.dsw.qos.IntentUtils;
 import org.apache.cxf.dosgi.dsw.service.RemoteServiceAdminCore;
 import org.apache.cxf.dosgi.dsw.service.RemoteServiceadminFactory;
 import org.osgi.framework.BundleActivator;
@@ -48,7 +49,7 @@ import org.osgi.service.remoteserviceadm
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-// registered as spring bean -> start / stop called accordingly 
+// registered as spring bean -> start / stop called accordingly
 public class Activator implements ManagedService, BundleActivator {
     private static final int DEFAULT_INTENT_TIMEOUT = 30000;
     private static final Logger LOG = LoggerFactory.getLogger(Activator.class);
@@ -76,20 +77,31 @@ public class Activator implements Manage
         intentTracker.open();
         IntentManager intentManager = new IntentManagerImpl(intentMap, DEFAULT_INTENT_TIMEOUT);
         HttpServiceManager httpServiceManager = new HttpServiceManager(bc, httpBase, cxfServletAlisas);
-        ConfigTypeHandlerFactory configTypeHandlerFactory 
+        ConfigTypeHandlerFactory configTypeHandlerFactory
             = new ConfigTypeHandlerFactory(bc, intentManager, httpServiceManager);
         RemoteServiceAdminCore rsaCore = new RemoteServiceAdminCore(bc, configTypeHandlerFactory);
         RemoteServiceadminFactory rsaf = new RemoteServiceadminFactory(rsaCore);
         Dictionary<String, Object> props = new Hashtable<String, Object>();
         String[] supportedIntents = intentMap.keySet().toArray(new String[] {});
-        String siString = IntentUtils.formatIntents(supportedIntents);
-        props.put("remote.intents.supported", siString);
-        props.put("remote.configs.supported", configTypeHandlerFactory.getSupportedConfigurationTypes());
+        props.put("remote.intents.supported", supportedIntents);
+        props.put("remote.configs.supported", obtainSupportedConfigTypes(configTypeHandlerFactory.getSupportedConfigurationTypes()));
         LOG.info("Registering RemoteServiceAdminFactory...");
         rsaFactoryReg = bc.registerService(RemoteServiceAdmin.class.getName(), rsaf, props);
         decoratorReg = bc.registerService(ServiceDecorator.class.getName(), new ServiceDecoratorImpl(bc), null);
     }
 
+    // The CT sometimes uses the first element returned to register a service, but does not provide any additional configuration
+    // Return the configuration type that works without additional configuration as the first in the list.
+    private String[] obtainSupportedConfigTypes(List<String> types) {
+        List<String> l = new ArrayList<String>(types);
+        if (l.contains(org.apache.cxf.dosgi.dsw.Constants.WS_CONFIG_TYPE)) {
+            // make sure its the first element...
+            l.remove(org.apache.cxf.dosgi.dsw.Constants.WS_CONFIG_TYPE);
+            l.add(0, org.apache.cxf.dosgi.dsw.Constants.WS_CONFIG_TYPE);
+        }
+        return l.toArray(new String[] {});
+    }
+
     private void registerManagedService(BundleContext bundlecontext) {
         Dictionary<String, String> props = new Hashtable<String, String>();
         props.put(Constants.SERVICE_PID, CONFIG_SERVICE_PID);
@@ -137,7 +149,7 @@ public class Activator implements Manage
         }
         Enumeration<String> keys = config.keys();
         while (keys.hasMoreElements()) {
-            String key = (String) keys.nextElement();
+            String key = keys.nextElement();
             configMap.put(key, config.get(key));
         }
         return configMap;

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java?rev=1442924&r1=1442923&r2=1442924&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java Wed Feb  6 12:20:44 2013
@@ -93,7 +93,7 @@ public abstract class AbstractPojoConfig
             }
         }
 
-        String[] allIntents = IntentUtils.mergeArrays(intents, IntentUtils.getInetntsImplementedByTheService(sd));
+        String[] allIntents = IntentUtils.mergeArrays(intents, IntentUtils.getIntentsImplementedByTheService(sd));
         props.put(RemoteConstants.SERVICE_INTENTS, allIntents);
         props.put(RemoteConstants.ENDPOINT_ID, address);
         return props;

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactory.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactory.java?rev=1442924&r1=1442923&r2=1442924&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactory.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactory.java Wed Feb  6 12:20:44 2013
@@ -26,7 +26,6 @@ import java.util.Map;
 
 import org.apache.cxf.dosgi.dsw.Constants;
 import org.apache.cxf.dosgi.dsw.qos.IntentManager;
-import org.apache.cxf.dosgi.dsw.qos.IntentUtils;
 import org.apache.cxf.dosgi.dsw.util.OsgiUtils;
 import org.apache.cxf.dosgi.dsw.util.Utils;
 import org.osgi.framework.BundleContext;
@@ -38,7 +37,7 @@ import org.slf4j.LoggerFactory;
 public class ConfigTypeHandlerFactory {
     protected static final String DEFAULT_CONFIGURATION_TYPE = Constants.WS_CONFIG_TYPE;
     private static final Logger LOG = LoggerFactory.getLogger(ConfigTypeHandlerFactory.class);
-    
+
     // protected because of tests
     protected final List<String> supportedConfigurationTypes;
 
@@ -51,8 +50,8 @@ public class ConfigTypeHandlerFactory {
                                     HttpServiceManager httpServiceManager) {
         this.intentManager = intentManager;
         this.pojoConfigurationTypeHandler = new PojoConfigurationTypeHandler(bc, intentManager, httpServiceManager);
-        this.jaxRsPojoConfigurationTypeHandler = new JaxRSPojoConfigurationTypeHandler(bc, 
-                                                                                       intentManager, 
+        this.jaxRsPojoConfigurationTypeHandler = new JaxRSPojoConfigurationTypeHandler(bc,
+                                                                                       intentManager,
                                                                                        httpServiceManager);
         this.wsdlConfigurationTypeHandler = new WsdlConfigurationTypeHandler(bc, intentManager, httpServiceManager);
         supportedConfigurationTypes = new ArrayList<String>();
@@ -61,13 +60,13 @@ public class ConfigTypeHandlerFactory {
         supportedConfigurationTypes.add(Constants.WS_CONFIG_TYPE);
         supportedConfigurationTypes.add(Constants.WS_CONFIG_TYPE_OLD);
     }
-    
+
     public ConfigurationTypeHandler getHandler(BundleContext dswBC,
             Map<String, Object> serviceProperties) {
         List<String> configurationTypes = determineConfigurationTypes(serviceProperties);
         return getHandler(dswBC, configurationTypes, serviceProperties);
     }
-    
+
     public ConfigurationTypeHandler getHandler(BundleContext dswBC, EndpointDescription endpoint) {
         List<String> configurationTypes = determineConfigTypesForImport(endpoint);
         return getHandler(dswBC, configurationTypes, endpoint.getProperties());
@@ -97,28 +96,28 @@ public class ConfigTypeHandlerFactory {
         }
 
         if (types.contains(Constants.RS_CONFIG_TYPE)) {
-            String intentsProperty = OsgiUtils.getProperty(serviceProperties, RemoteConstants.SERVICE_EXPORTED_INTENTS);
+            Collection<String> intentsProperty = OsgiUtils.getMultiValueProperty(serviceProperties.get(RemoteConstants.SERVICE_EXPORTED_INTENTS));
             boolean hasHttpIntent = false;
             boolean hasSoapIntent = false;
             if (intentsProperty != null) {
-                String[] intents = IntentUtils.parseIntents(intentsProperty);
-                for (int i = 0; i < intents.length; i++) {
-                    if (intents[i].indexOf("SOAP") > -1) {
+                for (String intent : intentsProperty) {
+                    if (intent.indexOf("SOAP") > -1) {
                         hasSoapIntent = true;
                         break;
                     }
-                    if ("HTTP".equals(intents[i])) {
+
+                    if (intent.indexOf("HTTP") > -1) {
                         hasHttpIntent = true;
                     }
                 }
             }
-            if (intentsProperty != null && hasHttpIntent && !hasSoapIntent || intentsProperty == null) {
+            if ((hasHttpIntent && !hasSoapIntent) || intentsProperty == null) {
                 return true;
             }
         }
         return false;
     }
-    
+
     /**
      * determine which configuration types should be used / if the requested are
      * supported
@@ -142,7 +141,7 @@ public class ConfigTypeHandlerFactory {
         }
         return configurationTypes;
     }
-    
+
     private List<String> determineConfigTypesForImport(EndpointDescription endpoint) {
         List<String> remoteConfigurationTypes = endpoint.getConfigurationTypes();
 

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java?rev=1442924&r1=1442923&r2=1442924&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java Wed Feb  6 12:20:44 2013
@@ -47,7 +47,7 @@ public class PojoConfigurationTypeHandle
                                         HttpServiceManager httpServiceManager) {
         super(dswBC, intentManager, httpServiceManager);
     }
-    
+
     public String[] getSupportedTypes() {
         return new String[] {Constants.WS_CONFIG_TYPE, Constants.WS_CONFIG_TYPE_OLD};
     }
@@ -84,37 +84,57 @@ public class PojoConfigurationTypeHandle
         }
         return null;
     }
-    
+
     public ExportResult createServer(ServiceReference sref,
                                      BundleContext dswContext,
-                                     BundleContext callingContext, 
+                                     BundleContext callingContext,
                                      Map<String, Object> sd,
-                                     Class<?> iClass, 
+                                     Class<?> iClass,
                                      Object serviceBean) throws IntentUnsatifiedException {
-        String address = getServerAddress(sd, iClass);
-        String contextRoot = httpServiceManager.getServletContextRoot(sd, iClass);
-        
-        ServerFactoryBean factory = createServerFactoryBean(sd, iClass);
-        factory.setDataBinding(getDataBinding(sd, iClass));
-        if (contextRoot != null) {
-            Bus bus = httpServiceManager.registerServletAndGetBus(contextRoot, callingContext, sref);
-            factory.setBus(bus);
+        try {
+            String address = getPojoAddress(sd, iClass);
+            String contextRoot = httpServiceManager.getServletContextRoot(sd, iClass);
+
+            ServerFactoryBean factory = createServerFactoryBean(sd, iClass);
+            factory.setDataBinding(getDataBinding(sd, iClass));
+            if (contextRoot != null) {
+                Bus bus = httpServiceManager.registerServletAndGetBus(contextRoot, callingContext, sref);
+                factory.setBus(bus);
+            }
+            factory.setServiceClass(iClass);
+            factory.setAddress(address);
+            factory.setServiceBean(serviceBean);
+            addWsInterceptorsFeaturesProps(factory, callingContext, sd);
+            setWsdlProperties(factory, callingContext, sd, false);
+            String[] intents = intentManager.applyIntents(factory.getFeatures(), factory, sd);
+
+            String completeEndpointAddress = httpServiceManager.getAbsoluteAddress(dswContext, contextRoot, address);
+
+            // The properties for the EndpointDescription
+            Map<String, Object> endpointProps = createEndpointProps(sd, iClass,
+                                                                    new String[]{Constants.WS_CONFIG_TYPE},
+                                                                    completeEndpointAddress, intents);
+
+            return createServerFromFactory(factory, endpointProps);
+        } catch (RuntimeException re) {
+            return new ExportResult(sd, re);
         }
-        factory.setServiceClass(iClass);
-        factory.setAddress(address);
-        factory.setServiceBean(serviceBean);
-        addWsInterceptorsFeaturesProps(factory, callingContext, sd);
-        setWsdlProperties(factory, callingContext, sd, false);
-        String[] intents = intentManager.applyIntents(factory.getFeatures(), factory, sd);
-        
-        String completeEndpointAddress = httpServiceManager.getAbsoluteAddress(dswContext, contextRoot, address);
-
-        // The properties for the EndpointDescription
-        Map<String, Object> endpointProps = createEndpointProps(sd, iClass,
-                                                                new String[]{Constants.WS_CONFIG_TYPE},
-                                                                completeEndpointAddress, intents);
+    }
+
+    private String getPojoAddress(Map<String, Object> sd, Class<?> iClass) {
+        String address = getClientAddress(sd, iClass);
+        if (address != null)
+            return address;
 
-        return createServerFromFactory(factory, endpointProps);
+        // If the property is not of type string this will cause an ClassCastException which
+        // will be propagated to the ExportRegistration exception property.
+        String port = (String) sd.get(Constants.WS_PORT_PROPERTY);
+        if (port == null)
+            port = "9000";
+
+        address = "http://localhost:" + port + "/" + iClass.getName().replace('.', '/');
+        LOG.info("Using a default address : " + address);
+        return address;
     }
 
     private DataBinding getDataBinding(Map<String, Object> sd, Class<?> iClass) {
@@ -123,8 +143,8 @@ public class PojoConfigurationTypeHandle
 
     private boolean isJAXB(Map<String, Object> sd, Class<?> iClass) {
         String dataBindingName = (String)sd.get(Constants.WS_DATABINDING_PROP_KEY);
-        return (iClass.getAnnotation(WebService.class) != null 
-            || Constants.WS_DATA_BINDING_JAXB.equals(dataBindingName)) 
+        return (iClass.getAnnotation(WebService.class) != null
+            || Constants.WS_DATA_BINDING_JAXB.equals(dataBindingName))
             && !Constants.WS_DATA_BINDING_AEGIS.equals(dataBindingName);
     }
 
@@ -137,11 +157,11 @@ public class PojoConfigurationTypeHandle
     protected ServerFactoryBean createServerFactoryBean(Map<String, Object> sd, Class<?> iClass) {
         return isJAXWS(sd, iClass) ? new JaxWsServerFactoryBean() : new ServerFactoryBean();
     }
-    
+
     private boolean isJAXWS(Map<String, Object> sd, Class<?> iClass) {
         String frontEnd = (String)sd.get(Constants.WS_FRONTEND_PROP_KEY);
         return (iClass.getAnnotation(WebService.class) != null
-            || Constants.WS_FRONTEND_JAXWS.equals(frontEnd)) 
+            || Constants.WS_FRONTEND_JAXWS.equals(frontEnd))
             && !Constants.WS_FRONTEND_SIMPLE.equals(frontEnd);
     }
 

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentUtils.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentUtils.java?rev=1442924&r1=1442923&r2=1442924&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentUtils.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentUtils.java Wed Feb  6 12:20:44 2013
@@ -35,27 +35,9 @@ public final class IntentUtils {
     private IntentUtils() {
         //never constructed
     }
-    
-    public static String formatIntents(String[] intents) {
-        StringBuilder sb = new StringBuilder();
-        boolean first = true;
-        for (String intent : intents) {
-            if (first) {
-                first = false;
-            } else {
-                sb.append(' ');
-            }
-            sb.append(intent);
-        }
-        return sb.toString();
-    }
-
-    public static String[] parseIntents(String intentsSequence) {
-        return intentsSequence == null ? new String[] {} : intentsSequence.split(" ");
-    }
 
     @SuppressWarnings("rawtypes")
-    public static String[] getInetntsImplementedByTheService(Map serviceProperties) {
+    public static String[] getIntentsImplementedByTheService(Map serviceProperties) {
         // Get the Intents that are implemented by the service
         String[] serviceIntents = Utils.normalizeStringPlus(serviceProperties.get(RemoteConstants.SERVICE_INTENTS));
 
@@ -84,18 +66,28 @@ public final class IntentUtils {
 
         return list.toArray(new String[list.size()]);
     }
-    
+
     public static Set<String> getRequestedIntents(Map<?, ?> sd) {
-        Collection<String> intents = Arrays.asList(
-            IntentUtils.parseIntents(OsgiUtils.getProperty(sd, RemoteConstants.SERVICE_EXPORTED_INTENTS)));        
+        Collection<String> intents = OsgiUtils.getMultiValueProperty(sd.get(RemoteConstants.SERVICE_EXPORTED_INTENTS));
+        Collection<String> intents2 = OsgiUtils.getMultiValueProperty(sd.get(RemoteConstants.SERVICE_EXPORTED_INTENTS_EXTRA));
         @SuppressWarnings("deprecation")
-        Collection<String> oldIntents = Arrays.asList(
-            IntentUtils.parseIntents(OsgiUtils.getProperty(sd, Constants.EXPORTED_INTENTS_OLD))); 
-        
-        Set<String> allIntents = new HashSet<String>(intents.size() + oldIntents.size());
-        allIntents.addAll(intents);
-        allIntents.addAll(oldIntents);
+        Collection<String> oldIntents = OsgiUtils.getMultiValueProperty(sd.get(Constants.EXPORTED_INTENTS_OLD));
+        Set<String> allIntents = new HashSet<String>();
+        if (intents != null)
+            allIntents.addAll(parseIntents(intents));
+        if (intents2 != null)
+            allIntents.addAll(parseIntents(intents2));
+        if (oldIntents != null)
+            allIntents.addAll(parseIntents(oldIntents));
+
         return allIntents;
     }
 
+    private static Collection<String> parseIntents(Collection<String> intents) {
+        List<String> parsed = new ArrayList<String>();
+        for (String intent : intents) {
+            parsed.addAll(Arrays.asList(intent.split("[ ]")));
+        }
+        return parsed;
+    }
 }

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/EventProducer.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/EventProducer.java?rev=1442924&r1=1442923&r2=1442924&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/EventProducer.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/EventProducer.java Wed Feb  6 12:20:44 2013
@@ -23,7 +23,6 @@ import java.util.List;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceReference;
-import org.osgi.service.remoteserviceadmin.ExportReference;
 import org.osgi.service.remoteserviceadmin.ExportRegistration;
 import org.osgi.service.remoteserviceadmin.ImportRegistration;
 import org.osgi.service.remoteserviceadmin.RemoteServiceAdminEvent;
@@ -49,14 +48,9 @@ public class EventProducer {
     }
 
     protected void publishNotifcation(ExportRegistration er) {
-        RemoteServiceAdminEvent rsae = null;
-        if (er.getException() != null) {
-            rsae = new RemoteServiceAdminEvent(RemoteServiceAdminEvent.EXPORT_ERROR, bctx.getBundle(), 
-                                               (ExportReference)null, er.getException());
-        } else {
-            rsae = new RemoteServiceAdminEvent(RemoteServiceAdminEvent.EXPORT_REGISTRATION, bctx.getBundle(),
-                                               er.getExportReference(), er.getException());
-        }
+        int type = er.getException() == null ? RemoteServiceAdminEvent.EXPORT_REGISTRATION : RemoteServiceAdminEvent.EXPORT_ERROR;
+        RemoteServiceAdminEvent rsae = new RemoteServiceAdminEvent(type, bctx.getBundle(), er.getExportReference(),
+                er.getException());
 
         notifyListeners(rsae);
         eaHelper.notifyEventAdmin(rsae);
@@ -100,19 +94,19 @@ public class EventProducer {
         RemoteServiceAdminEvent rsae = null;
         rsae = new RemoteServiceAdminEvent(RemoteServiceAdminEvent.EXPORT_UNREGISTRATION, bctx.getBundle(),
                                            eri.getExportReference(), eri.getException());
-        
+
         notifyListeners(rsae);
         eaHelper.notifyEventAdmin(rsae);
     }
-     
-    
+
+
     public void notifyRemoval(ImportRegistration eri) {
         RemoteServiceAdminEvent rsae = null;
         rsae = new RemoteServiceAdminEvent(RemoteServiceAdminEvent.IMPORT_UNREGISTRATION, bctx.getBundle(),
                                            eri.getImportReference(), eri.getException());
-        
+
         notifyListeners(rsae);
         eaHelper.notifyEventAdmin(rsae);
     }
-    
+
 }

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ExportRegistrationImpl.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ExportRegistrationImpl.java?rev=1442924&r1=1442923&r2=1442924&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ExportRegistrationImpl.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ExportRegistrationImpl.java Wed Feb  6 12:20:44 2013
@@ -129,7 +129,7 @@ public class ExportRegistrationImpl impl
             Set<Map.Entry<String, Object>> props = endpointDescription.getProperties().entrySet();
             for (Map.Entry<String, Object> entry : props) {
                 Object value = entry.getValue();
-                r += entry.getKey() + "  => " 
+                r += entry.getKey() + "  => "
                     + (value instanceof Object[] ? Arrays.toString((Object []) value) : value) + "\n";
             }
         }

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java?rev=1442924&r1=1442923&r2=1442924&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java Wed Feb  6 12:20:44 2013
@@ -29,7 +29,6 @@ import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
-import java.util.Properties;
 
 import org.apache.cxf.dosgi.dsw.handlers.ConfigTypeHandlerFactory;
 import org.apache.cxf.dosgi.dsw.handlers.ConfigurationTypeHandler;
@@ -55,8 +54,8 @@ public class RemoteServiceAdminCore impl
 
     private static final Logger LOG = LoggerFactory.getLogger(RemoteServiceAdminCore.class);
 
-    private final Map<ServiceReference, Collection<ExportRegistration>> exportedServices 
-        = new LinkedHashMap<ServiceReference, Collection<ExportRegistration>>();
+    private final Map<Map<String, Object>, Collection<ExportRegistration>> exportedServices
+        = new LinkedHashMap<Map<String, Object>, Collection<ExportRegistration>>();
     private final Map<EndpointDescription, Collection<ImportRegistrationImpl>> importedServices
         = new LinkedHashMap<EndpointDescription, Collection<ImportRegistrationImpl>>();
 
@@ -75,7 +74,7 @@ public class RemoteServiceAdminCore impl
     public List<ExportRegistration> exportService(ServiceReference serviceReference, Map additionalProperties)
         throws IllegalArgumentException, UnsupportedOperationException {
 
-        Properties serviceProperties = getProperties(serviceReference);
+        Map<String, Object> serviceProperties = getProperties(serviceReference);
         if (additionalProperties != null) {
             OsgiUtils.overlayProperties(serviceProperties, additionalProperties);
         }
@@ -86,7 +85,7 @@ public class RemoteServiceAdminCore impl
             // TODO: publish error event ? not sure
             return Collections.emptyList();
         }
-        
+
         if (isCreatedByThisRSA(serviceReference)) {
             LOG.debug("Skipping export of this service as we created it ourself as a proxy {}", interfaces);
             // TODO: publish error event ? Not sure
@@ -95,9 +94,9 @@ public class RemoteServiceAdminCore impl
 
         synchronized (exportedServices) {
             // check if it is already exported ....
-            if (exportedServices.containsKey(serviceReference)) {
+            if (exportedServices.containsKey(serviceProperties)) {
                 LOG.debug("already exported this service. Returning existing exportRegs {} ", interfaces);
-                return copyExportRegistration(serviceReference);
+                return copyExportRegistration(serviceProperties);
             }
             LOG.info("interfaces selected for export: " + interfaces);
             Map<String, ExportRegistrationImpl> exportRegs = new LinkedHashMap<String, ExportRegistrationImpl>(1);
@@ -105,7 +104,7 @@ public class RemoteServiceAdminCore impl
             BundleContext callingContext = serviceReference.getBundle().getBundleContext();
             ConfigurationTypeHandler handler = null;
             try {
-                handler = configTypeHandlerFactory.getHandler(bctx, (Map)serviceProperties);
+                handler = configTypeHandlerFactory.getHandler(bctx, serviceProperties);
             } catch (RuntimeException e) {
                 LOG.error(e.getMessage(), e);
                 return Collections.emptyList();
@@ -118,7 +117,7 @@ public class RemoteServiceAdminCore impl
                 Class<?> interfaceClass = ClassUtils.getInterfaceClass(serviceObject, iface);
                 if (interfaceClass != null) {
                     ExportResult exportResult = handler.createServer(serviceReference, bctx, callingContext,
-                            (Map)serviceProperties, interfaceClass, serviceObject);
+                            serviceProperties, interfaceClass, serviceObject);
                     LOG.info("created server for interface " + iface);
                     EndpointDescription epd = new EndpointDescription(exportResult.getEndpointProps());
                     ExportRegistrationImpl exportRegistration = new ExportRegistrationImpl(serviceReference, epd, this);
@@ -126,13 +125,14 @@ public class RemoteServiceAdminCore impl
                         exportRegistration.startServiceTracker(bctx);
                     } else {
                         LOG.error(exportResult.getException().getMessage(), exportResult.getException());
+                        exportRegistration.setException(exportResult.getException());
                     }
                     exportRegs.put(iface, exportRegistration);
                 }
             }
 
             // enlist initial export Registrations in global list of exportRegistrations
-            exportedServices.put(serviceReference, new ArrayList<ExportRegistration>(exportRegs.values()));
+            exportedServices.put(serviceProperties, new ArrayList<ExportRegistration>(exportRegs.values()));
 
             List<ExportRegistration> lExpReg = new ArrayList<ExportRegistration>(exportRegs.values());
             eventProducer.publishNotifcation(lExpReg);
@@ -143,15 +143,18 @@ public class RemoteServiceAdminCore impl
 
     /**
      * Determine which interfaces should be exported
-     * 
-     * @param serviceProperties 
+     *
+     * @param serviceProperties
      * @return interfaces to be exported
      */
-    private List<String> getInterfaces(Properties serviceProperties) {
+    private List<String> getInterfaces(Map<String, Object> serviceProperties) {
         List<String> interfaces = new ArrayList<String>(1);
-        
-        String[] providedInterfaces = (String[]) serviceProperties.get(org.osgi.framework.Constants.OBJECTCLASS);
-        String[] allowedInterfaces 
+
+        // Earlier in this class we have converted objectClass from String[] to List<String>...
+        @SuppressWarnings("unchecked")
+        List<String> providedInterfaces = (List<String>) serviceProperties.get(org.osgi.framework.Constants.OBJECTCLASS);
+
+        String[] allowedInterfaces
             = Utils.normalizeStringPlus(serviceProperties.get(RemoteConstants.SERVICE_EXPORTED_INTERFACES));
         if (providedInterfaces == null || allowedInterfaces == null) {
             return Collections.emptyList();
@@ -173,16 +176,27 @@ public class RemoteServiceAdminCore impl
         return interfaces;
     }
 
-    private Properties getProperties(ServiceReference serviceReference) {
-        Properties serviceProperties = new Properties();
+    private Map<String, Object> getProperties(ServiceReference serviceReference) {
+        Map<String, Object> serviceProperties = new HashMap<String, Object>();
         for (String key : serviceReference.getPropertyKeys()) {
-            serviceProperties.put(key, serviceReference.getProperty(key));
+            Object val = serviceReference.getProperty(key);
+            if (val instanceof Object[]) {
+                // If we are dealing with an array, turn it into a list because otherwise the equals method on the map key won't work
+                Object[] arr = (Object[]) val;
+                List<Object> l = new ArrayList<Object>();
+                for (Object o : arr)
+                    l.add(o);
+
+                serviceProperties.put(key, l);
+            } else {
+                serviceProperties.put(key, val);
+            }
         }
         return serviceProperties;
     }
 
-    private List<ExportRegistration> copyExportRegistration(ServiceReference serviceReference) {
-        Collection<ExportRegistration> regs = exportedServices.get(serviceReference);
+    private List<ExportRegistration> copyExportRegistration(Map<String, Object> serviceProperties) {
+        Collection<ExportRegistration> regs = exportedServices.get(serviceProperties);
 
         List<EndpointDescription> copiedEndpoints = new ArrayList<EndpointDescription>();
 
@@ -299,7 +313,7 @@ public class RemoteServiceAdminCore impl
             if (iClass == null) {
                 throw new ClassNotFoundException("Cannot load interface class");
             }
-            
+
             BundleContext actualContext = bctx;
             Class<?> actualClass = requestingContext.getBundle().loadClass(interfaceName);
             if (actualClass != iClass) {
@@ -315,7 +329,7 @@ public class RemoteServiceAdminCore impl
             Dictionary<String, Object> serviceProps = new Hashtable<String, Object>(ed.getProperties());
             serviceProps.put(RemoteConstants.SERVICE_IMPORTED, true);
             serviceProps.remove(RemoteConstants.SERVICE_EXPORTED_INTERFACES);
-                
+
             // synchronized (discoveredServices) {
             ClientServiceFactory csf = new ClientServiceFactory(actualContext, iClass, ed, handler, imReg);
             imReg.setClientServiceFactory(csf);
@@ -336,17 +350,19 @@ public class RemoteServiceAdminCore impl
      */
     protected void removeExportRegistration(ExportRegistrationImpl eri) {
         synchronized (exportedServices) {
-            ServiceReference sref = eri.getExportReference().getExportedService();
-            Collection<ExportRegistration> exRegs = exportedServices.get(sref);
-            if (exRegs != null && exRegs.contains(eri)) {
-                eventProducer.notifyRemoval(eri);
-                exRegs.remove(eri);
-            } else {
-                LOG.error("An exportRegistartion was intended to be removed form internal "
-                          + "management structure but couldn't be found in it !! ");
-            }
-            if (exRegs == null || exRegs.size() == 0) {
-                exportedServices.remove(sref);
+            for (Iterator<Collection<ExportRegistration>> it = exportedServices.values().iterator(); it.hasNext(); ) {
+                Collection<ExportRegistration> value = it.next();
+                for (Iterator<ExportRegistration> it2 = value.iterator(); it2.hasNext(); ) {
+                    ExportRegistration er = it2.next();
+                    if (er.equals(eri)) {
+                        eventProducer.notifyRemoval(eri);
+                        it2.remove();
+                        if (value.size() == 0)
+                            it.remove();
+
+                        return;
+                    }
+                }
             }
         }
     }
@@ -356,14 +372,18 @@ public class RemoteServiceAdminCore impl
         Bundle exportingBundle = exportingBundleCtx.getBundle();
 
         // Work on a copy as the map gets modified as part of the behaviour by underlying methods
-        Map<ServiceReference, Collection<ExportRegistration>> exportCopy 
-            = new HashMap<ServiceReference, Collection<ExportRegistration>>(exportedServices);
+        Map<Map<String, Object>, Collection<ExportRegistration>> exportCopy
+            = new HashMap<Map<String, Object>, Collection<ExportRegistration>>(exportedServices);
 
-        for (Iterator<Map.Entry<ServiceReference, Collection<ExportRegistration>>> it
+        for (Iterator<Map.Entry<Map<String, Object>, Collection<ExportRegistration>>> it
                 = exportCopy.entrySet().iterator(); it.hasNext();) {
-            
-            Entry<ServiceReference, Collection<ExportRegistration>> entry = it.next();
-            Bundle regBundle = entry.getKey().getBundle();
+
+            Entry<Map<String, Object>, Collection<ExportRegistration>> entry = it.next();
+            Bundle regBundle = null;
+            Iterator<ExportRegistration> it2 = entry.getValue().iterator();
+            if (it2.hasNext())
+                regBundle = it2.next().getExportReference().getExportedService().getBundle();
+
             if (exportingBundle.equals(regBundle)) {
                 // Again work on a copy, as the value gets modified by the behaviour inside export.close()
                 for (ExportRegistration export : new ArrayList<ExportRegistration>(entry.getValue())) {
@@ -382,7 +402,7 @@ public class RemoteServiceAdminCore impl
             if (imRegs != null && imRegs.contains(iri)) {
                 imRegs.remove(iri);
             } else {
-                LOG.error("An importRegistartion was intended to be removed form internal management " 
+                LOG.error("An importRegistartion was intended to be removed form internal management "
                     + "structure but couldn't be found in it !! ");
             }
             if (imRegs == null || imRegs.size() == 0) {

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminInstance.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminInstance.java?rev=1442924&r1=1442923&r2=1442924&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminInstance.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminInstance.java Wed Feb  6 12:20:44 2013
@@ -46,29 +46,22 @@ public class RemoteServiceAdminInstance 
     }
 
     @SuppressWarnings({ "rawtypes", "unchecked" })
-    public List /* ExportRegistration */exportService(ServiceReference ref, Map properties)
+    public List /* ExportRegistration */exportService(final ServiceReference ref, final Map properties)
         throws IllegalArgumentException, UnsupportedOperationException {
 
         SecurityManager sm = System.getSecurityManager();
-        EndpointPermission epp = new EndpointPermission("*", EndpointPermission.EXPORT);
-
-
         if (sm != null) {
+            EndpointPermission epp = new EndpointPermission("*", EndpointPermission.EXPORT);
             sm.checkPermission(epp);
         }
 
-
-        final ServiceReference refFinal = ref;
-        final Map propertiesFinal = properties;
-
         return AccessController.doPrivileged(new PrivilegedAction<List>() {
             public List<ExportRegistration> run() {
-
                 if (closed) {
                     return Collections.emptyList();
                 }
 
-                return rsaCore.exportService(refFinal, propertiesFinal);
+                return rsaCore.exportService(ref, properties);
             }
         });
     }

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/util/OsgiUtils.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/util/OsgiUtils.java?rev=1442924&r1=1442923&r2=1442924&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/util/OsgiUtils.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/util/OsgiUtils.java Wed Feb  6 12:20:44 2013
@@ -21,11 +21,8 @@ package org.apache.cxf.dosgi.dsw.util;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
 import java.util.UUID;
 
 import org.osgi.framework.Bundle;
@@ -38,7 +35,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public final class OsgiUtils {
-    
+
     public static final Logger LOG = LoggerFactory.getLogger(OsgiUtils.class);
 
     private OsgiUtils() {
@@ -92,7 +89,7 @@ public final class OsgiUtils {
         }
         return null;
     }
-    
+
     public static String getFirstNonEmptyStringProperty(@SuppressWarnings("rawtypes") Map dict, String ... keys) {
         for (String key : keys) {
             String value = getStringProperty(dict, key);
@@ -102,7 +99,7 @@ public final class OsgiUtils {
         }
         return null;
     }
-    
+
     @SuppressWarnings("rawtypes")
     private static String getStringProperty(Map dict, String name) {
         Object o = dict.get(name);
@@ -110,8 +107,6 @@ public final class OsgiUtils {
         if (o != null) {
             if (o instanceof String) {
                 return (String)o;
-            } else {
-                throw new RuntimeException("Could not use property " + name + " as the value is not a String");
             }
         }
         return null;
@@ -119,7 +114,7 @@ public final class OsgiUtils {
 
     /**
      * Tries to retrieve the version of iClass via the PackageAdmin
-     * 
+     *
      * @param iClass - The interface for which the version should be found
      * @param bc - any valid BundleContext
      * @return the version of the interface or "0.0.0" if no version information could be found or an error
@@ -175,42 +170,28 @@ public final class OsgiUtils {
         }
     }
 
-    @SuppressWarnings({ "rawtypes", "unchecked" })
-    public static void overlayProperties(Properties serviceProperties, Map additionalProperties) {
-        Enumeration<Object> keys = serviceProperties.keys();
-        // Maps lower case key to original key
+    public static void overlayProperties(Map<String, Object> serviceProperties, Map<String, Object> additionalProperties) {
         Map<String, String> keysLowerCase = new HashMap<String, String>();
-        while (keys.hasMoreElements()) {
-            Object o = keys.nextElement(); 
-            if (o instanceof String) {
-                String ks = (String)o;
-                keysLowerCase.put(ks.toLowerCase(), ks);
-            }
+        for (String key : serviceProperties.keySet()) {
+            keysLowerCase.put(key.toLowerCase(), key);
         }
-        
-        Set<Map.Entry> adProps = additionalProperties.entrySet();
-        for (Map.Entry e : adProps) {
-            // objectClass and service.id must not be overwritten
-            Object keyObj = e.getKey();
-            if (keyObj instanceof String) {
-                String key = ((String)keyObj).toLowerCase();
-                if (org.osgi.framework.Constants.SERVICE_ID.toLowerCase().equals(key)
-                    || org.osgi.framework.Constants.OBJECTCLASS.toLowerCase().equals(key)) {
-                    LOG.info("exportService called with additional properties map that contained illegal key: "
-                              + key + "   The key is ignored");
-                    continue;
-                } else if (keysLowerCase.containsKey(key)) {
-                    String origKey = keysLowerCase.get(key);
-                    serviceProperties.put(origKey, e.getValue());
-                    LOG.debug("Overwriting property [{}]  with value [{}]", origKey, e.getValue());
-                } else {
-                    serviceProperties.put(e.getKey(), e.getValue());
-                    keysLowerCase.put(e.getKey().toString().toLowerCase(), e.getKey().toString());
-                }
+
+        for (Map.Entry<String, Object> e : additionalProperties.entrySet()) {
+            String key = e.getKey().toLowerCase();
+            if (org.osgi.framework.Constants.SERVICE_ID.toLowerCase().equals(key)
+                || org.osgi.framework.Constants.OBJECTCLASS.toLowerCase().equals(key)) {
+                // objectClass and service.id must not be overwritten
+                LOG.info("exportService called with additional properties map that contained illegal key: "
+                          + key + "   The key is ignored");
+                continue;
+            } else if (keysLowerCase.containsKey(key)) {
+                String origKey = keysLowerCase.get(key);
+                serviceProperties.put(origKey, e.getValue());
+                LOG.debug("Overwriting property [{}]  with value [{}]", origKey, e.getValue());
+            } else {
+                serviceProperties.put(e.getKey(), e.getValue());
+                keysLowerCase.put(e.getKey().toString().toLowerCase(), e.getKey().toString());
             }
-            
-            
         }
     }
-    
 }

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=1442924&r1=1442923&r2=1442924&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 Wed Feb  6 12:20:44 2013
@@ -60,15 +60,15 @@ import org.osgi.service.remoteserviceadm
 public class PojoConfigurationTypeHandlerTest extends TestCase {
     public void testGetPojoAddressEndpointURI() {
         IntentManager intentManager = new IntentManagerImpl(new IntentMap());
-        PojoConfigurationTypeHandler handler = new PojoConfigurationTypeHandler(null, 
-                                                                                intentManager, 
+        PojoConfigurationTypeHandler handler = new PojoConfigurationTypeHandler(null,
+                                                                                intentManager,
                                                                                 dummyHttpServiceManager());
         Map<String, Object> sd = new HashMap<String, Object>();
         String url = "http://somewhere:1234/blah";
         sd.put(RemoteConstants.ENDPOINT_ID, url);
         assertEquals(url, handler.getServerAddress(sd, String.class));
     }
-    
+
     private HttpServiceManager dummyHttpServiceManager() {
         return new HttpServiceManager(null, null, null, null);
     }
@@ -86,7 +86,7 @@ public class PojoConfigurationTypeHandle
 
     public void testGetPojoAddressEndpointPojo() {
         IntentManager intentManager = new IntentManagerImpl(new IntentMap());
-        PojoConfigurationTypeHandler handler = new PojoConfigurationTypeHandler(null, 
+        PojoConfigurationTypeHandler handler = new PojoConfigurationTypeHandler(null,
                                                                                 intentManager,
                                                                                 dummyHttpServiceManager());
         Map<String, Object> sd = new HashMap<String, Object>();
@@ -94,13 +94,13 @@ public class PojoConfigurationTypeHandle
         sd.put("osgi.remote.configuration.pojo.address", url);
         assertEquals(url, handler.getServerAddress(sd, String.class));
     }
-    
+
     public void testGetDefaultPojoAddress() {
         IntentManager intentManager = new IntentManagerImpl(new IntentMap());
-        PojoConfigurationTypeHandler handler = new PojoConfigurationTypeHandler(null, 
-                                                                                intentManager , 
+        PojoConfigurationTypeHandler handler = new PojoConfigurationTypeHandler(null,
+                                                                                intentManager ,
                                                                                 dummyHttpServiceManager());
-        Map<String, Object> sd = new HashMap<String, Object>(); 
+        Map<String, Object> sd = new HashMap<String, Object>();
         assertEquals("/java/lang/String", handler.getServerAddress(sd, String.class));
     }
 
@@ -109,16 +109,16 @@ public class PojoConfigurationTypeHandle
         IMocksControl c = EasyMock.createNiceControl();
         BundleContext bc1 = c.createMock(BundleContext.class);
         BundleContext bc2 = c.createMock(BundleContext.class);
-        
+
         ServiceReference sref = c.createMock(ServiceReference.class);
-        
+
         final ClientProxyFactoryBean cpfb = c.createMock(ClientProxyFactoryBean.class);
         ReflectionServiceFactoryBean sf = c.createMock(ReflectionServiceFactoryBean.class);
         EasyMock.expect(cpfb.getServiceFactory()).andReturn(sf).anyTimes();
         IntentManager intentManager = new IntentManagerImpl(new IntentMap()) {
             @Override
-            public String[] applyIntents(List<Feature> features, 
-                                         AbstractEndpointFactory factory, 
+            public String[] applyIntents(List<Feature> features,
+                                         AbstractEndpointFactory factory,
                                          Map<String, Object> sd) {
                 return new String[0];
             }
@@ -131,21 +131,21 @@ public class PojoConfigurationTypeHandle
                 return cpfb;
             }
         };
-        
+
         Map<String, Object> props = new HashMap<String, Object>();
-        
+
         props.put(RemoteConstants.ENDPOINT_ID, "http://google.de/");
         props.put(org.osgi.framework.Constants.OBJECTCLASS, new String[]{"my.class"});
         props.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, new String[]{"my.config"});
         EndpointDescription endpoint = new EndpointDescription(props);
-        
-        
+
+
         cpfb.setAddress((String)EasyMock.eq(props.get(RemoteConstants.ENDPOINT_ID)));
         EasyMock.expectLastCall().atLeastOnce();
-        
+
         cpfb.setServiceClass(EasyMock.eq(CharSequence.class));
         EasyMock.expectLastCall().atLeastOnce();
-        
+
         c.replay();
         Object proxy = p.createProxy(sref, bc1, bc2, CharSequence.class, endpoint);
         assertNotNull(proxy);
@@ -157,54 +157,54 @@ public class PojoConfigurationTypeHandle
         BundleContext dswContext = EasyMock.createNiceMock(BundleContext.class);
         EasyMock.replay(dswContext);
 
-        String myService = "Hi";                
+        String myService = "Hi";
         final ServerFactoryBean sfb = createMockServerFactoryBean();
-        
+
         IntentMap intentMap = new IntentMap();
         IntentManager intentManager = new IntentManagerImpl(intentMap) {
             @Override
-            public String[] applyIntents(List<Feature> features, AbstractEndpointFactory factory, 
+            public String[] applyIntents(List<Feature> features, AbstractEndpointFactory factory,
                                          Map<String, Object> sd) {
                 return new String []{};
             }
         };
-        PojoConfigurationTypeHandler p = new PojoConfigurationTypeHandler(dswContext, intentManager, 
+        PojoConfigurationTypeHandler p = new PojoConfigurationTypeHandler(dswContext, intentManager,
                                                                           dummyHttpServiceManager()) {
             @Override
             protected ServerFactoryBean createServerFactoryBean(Map<String, Object> sd, Class<?> iClass) {
                 return sfb;
             }
         };
-        
+
         ServiceReference sr = EasyMock.createNiceMock(ServiceReference.class);
         BundleContext callingContext = EasyMock.createNiceMock(BundleContext.class);
         EasyMock.replay(sr);
         EasyMock.replay(callingContext);
-        
+
         Map<String, Object> props = new HashMap<String, Object>();
         props.put(Constants.WS_ADDRESS_PROPERTY, "http://alternate_host:80/myString");
 
         ExportResult exportResult = p.createServer(sr, dswContext, callingContext, props, String.class, myService);
-        
-        
+
+
         Map<String, Object> edProps = exportResult.getEndpointProps();
 
         assertNotNull(edProps.get(RemoteConstants.SERVICE_IMPORTED_CONFIGS));
         assertEquals(1, ((String[])edProps.get(RemoteConstants.SERVICE_IMPORTED_CONFIGS)).length);
         assertEquals(Constants.WS_CONFIG_TYPE, ((String[])edProps.get(RemoteConstants.SERVICE_IMPORTED_CONFIGS))[0]);
         assertEquals("http://alternate_host:80/myString", edProps.get(RemoteConstants.ENDPOINT_ID));
-        
-    }    
+
+    }
 
     private ServerFactoryBean createMockServerFactoryBean() {
         ReflectionServiceFactoryBean sf = EasyMock.createNiceMock(ReflectionServiceFactoryBean.class);
         EasyMock.replay(sf);
-        
+
         final StringBuilder serverURI = new StringBuilder();
-        
+
         ServerFactoryBean sfb = EasyMock.createNiceMock(ServerFactoryBean.class);
-        Server server = createMockServer(sfb);    
-        
+        Server server = createMockServer(sfb);
+
         EasyMock.expect(sfb.getServiceFactory()).andReturn(sf).anyTimes();
         EasyMock.expect(sfb.create()).andReturn(server);
         sfb.setAddress((String) EasyMock.anyObject());
@@ -213,12 +213,12 @@ public class PojoConfigurationTypeHandle
                 serverURI.setLength(0);
                 serverURI.append(EasyMock.getCurrentArguments()[0]);
                 return null;
-            }            
+            }
         });
         EasyMock.expect(sfb.getAddress()).andAnswer(new IAnswer<String>() {
             public String answer() throws Throwable {
                 return serverURI.toString();
-            }            
+            }
         });
         EasyMock.replay(sfb);
         return sfb;
@@ -229,44 +229,44 @@ public class PojoConfigurationTypeHandle
         EasyMock.expect(addr.getValue()).andAnswer(new IAnswer<String>() {
             public String answer() throws Throwable {
                 return sfb.getAddress();
-            }            
+            }
         });
         EasyMock.replay(addr);
 
         EndpointReferenceType er = EasyMock.createMock(EndpointReferenceType.class);
         EasyMock.expect(er.getAddress()).andReturn(addr);
         EasyMock.replay(er);
-        
+
         Destination destination = EasyMock.createMock(Destination.class);
         EasyMock.expect(destination.getAddress()).andReturn(er);
-        EasyMock.replay(destination);        
-                
+        EasyMock.replay(destination);
+
         Server server = EasyMock.createNiceMock(Server.class);
         EasyMock.expect(server.getDestination()).andReturn(destination);
         EasyMock.replay(server);
         return server;
     }
-    
+
     public void testCreateEndpointProps() {
         BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
         EasyMock.expect(bc.getProperty("org.osgi.framework.uuid")).andReturn("some_uuid1");
         EasyMock.replay(bc);
-        
+
         IntentManager intentManager = new IntentManagerImpl(new IntentMap());
-        PojoConfigurationTypeHandler pch = new PojoConfigurationTypeHandler(bc, 
+        PojoConfigurationTypeHandler pch = new PojoConfigurationTypeHandler(bc,
                                                                             intentManager,
                                                                             dummyHttpServiceManager());
-        
+
         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"}, 
+        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"), 
+        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)));
@@ -274,18 +274,21 @@ public class PojoConfigurationTypeHandle
                      Arrays.asList((Object []) props.get(RemoteConstants.SERVICE_INTENTS)));
         assertEquals("0.0.0", props.get("endpoint.package.version.java.lang"));
     }
-    
+
     public void testCreateJaxWsEndpointWithoutIntents() {
         IMocksControl c = EasyMock.createNiceControl();
         BundleContext dswBC = c.createMock(BundleContext.class);
         IntentManager intentManager = new DummyIntentManager();
-        PojoConfigurationTypeHandler handler = new PojoConfigurationTypeHandler(dswBC, 
-                                                                                intentManager, 
+        PojoConfigurationTypeHandler handler = new PojoConfigurationTypeHandler(dswBC,
+                                                                                intentManager,
                                                                                 dummyHttpServiceManager());
+
+
         Object serviceBean = new MyJaxWsEchoServiceImpl();
         ServiceReference sref = c.createMock(ServiceReference.class);
 
         Map<String, Object> sd = new HashMap<String, Object>();
+        sd.put(Constants.WS_ADDRESS_PROPERTY, "/somewhere");
 
         c.replay();
         ExportResult exportResult = handler.createServer(sref, dswBC, null, sd, MyJaxWsEchoService.class, serviceBean);
@@ -298,24 +301,25 @@ public class PojoConfigurationTypeHandle
         Assert.assertEquals(new QName("http://jaxws.handlers.dsw.dosgi.cxf.apache.org/",
                                       "MyJaxWsEchoServiceServiceSoapBinding"),
                             bindingName);
-        
+
     }
-    
+
     public void testCreateSimpleEndpointWithoutIntents() {
         IMocksControl c = EasyMock.createNiceControl();
         BundleContext dswBC = c.createMock(BundleContext.class);
         IntentManager intentManager = new DummyIntentManager();
-        PojoConfigurationTypeHandler handler 
+        PojoConfigurationTypeHandler handler
             = new PojoConfigurationTypeHandler(dswBC, intentManager, dummyHttpServiceManager());
         Object serviceBean = new MySimpleEchoServiceImpl();
         ServiceReference sref = c.createMock(ServiceReference.class);
         Map<String, Object> sd = new HashMap<String, Object>();
+        sd.put(Constants.WS_ADDRESS_PROPERTY, "/somewhere_else");
 
         c.replay();
         ExportResult exportResult = handler.createServer(sref, dswBC, null, sd, MySimpleEchoService.class, serviceBean);
         Server server = exportResult.getServer();
         c.verify();
-        
+
         Endpoint ep = server.getEndpoint();
         QName bindingName = ep.getEndpointInfo().getBinding().getName();
         Assert.assertEquals(EndpointImpl.class, ep.getClass());
@@ -323,11 +327,11 @@ public class PojoConfigurationTypeHandle
                                       "MySimpleEchoServiceSoapBinding"),
                             bindingName);
     }
-    
+
     public static class DummyIntentManager implements IntentManager {
 
         @Override
-        public String[] applyIntents(List<Feature> features, 
+        public String[] applyIntents(List<Feature> features,
                                      AbstractEndpointFactory factory,
                                      Map<String, Object> props) {
             return new String[]{};
@@ -335,8 +339,8 @@ public class PojoConfigurationTypeHandle
 
         @Override
         public void assertAllIntentsSupported(Map<String, Object> serviceProperties) {
-            
+
         }
-        
+
     }
 }

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentUtilsTest.java?rev=1442924&r1=1442923&r2=1442924&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentUtilsTest.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentUtilsTest.java Wed Feb  6 12:20:44 2013
@@ -19,19 +19,51 @@
 package org.apache.cxf.dosgi.dsw.qos;
 
 import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.cxf.dosgi.dsw.Constants;
+import org.junit.Assert;
+import org.junit.Test;
+import org.osgi.service.remoteserviceadmin.RemoteConstants;
 
-import junit.framework.Assert;
 
 public class IntentUtilsTest {
-    
-    public void testIntentsParsingAndFormatting() {
-        String initial = "A SOAP_1.1 integrity";
-
-        String[] expected = {"A", "SOAP_1.1", "integrity"};
-        String[] actual = IntentUtils.parseIntents(initial);
-        Assert.assertTrue(Arrays.equals(expected, actual));
-        
-        Assert.assertEquals(initial, IntentUtils.formatIntents(actual));
+    @Test
+    public void testMergeArrays() {
+        Assert.assertNull(IntentUtils.mergeArrays(null, null));
+
+        String[] sa1 = {};
+        Assert.assertEquals(0, IntentUtils.mergeArrays(sa1, null).length);
+
+        String[] sa2 = {"X"};
+        Assert.assertEquals(1, IntentUtils.mergeArrays(null, sa2).length);
+        Assert.assertEquals("X", IntentUtils.mergeArrays(null, sa2)[0]);
+
+        String[] sa3 = {"Y", "Z"};
+        String[] sa4 = {"A", "Z"};
+        Assert.assertEquals(3, IntentUtils.mergeArrays(sa3, sa4).length);
+        Assert.assertEquals(new HashSet<String>(Arrays.asList("A", "Y", "Z")),
+                new HashSet<String>(Arrays.asList(IntentUtils.mergeArrays(sa3, sa4))));
     }
 
+    @Test
+    public void testRequestedIntents() {
+        Map<String, Object> props = new HashMap<String, Object>();
+        Assert.assertEquals(0, IntentUtils.getRequestedIntents(props).size());
+
+        props.put(RemoteConstants.SERVICE_EXPORTED_INTENTS, "one");
+        Assert.assertEquals(Collections.singleton("one"), IntentUtils.getRequestedIntents(props));
+
+        props.put(RemoteConstants.SERVICE_EXPORTED_INTENTS_EXTRA, new String[] {"two", "three"});
+        Set<String> expected1 = new HashSet<String>(Arrays.asList("one", "two", "three"));
+        Assert.assertEquals(expected1, IntentUtils.getRequestedIntents(props));
+
+        props.put(Constants.EXPORTED_INTENTS_OLD, "A B C");
+        Set<String> expected2 = new HashSet<String>(Arrays.asList("one", "two", "three", "A", "B", "C"));
+        Assert.assertEquals(expected2, IntentUtils.getRequestedIntents(props));
+    }
 }

Added: cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/EventProducerTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/EventProducerTest.java?rev=1442924&view=auto
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/EventProducerTest.java (added)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/EventProducerTest.java Wed Feb  6 12:20:44 2013
@@ -0,0 +1,180 @@
+/**
+ * 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.dsw.service;
+
+import java.util.Arrays;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.UUID;
+
+import org.easymock.IAnswer;
+import org.easymock.classextension.EasyMock;
+import org.junit.Assert;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.Version;
+import org.osgi.service.event.Event;
+import org.osgi.service.event.EventAdmin;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
+import org.osgi.service.remoteserviceadmin.ExportReference;
+import org.osgi.service.remoteserviceadmin.ExportRegistration;
+import org.osgi.service.remoteserviceadmin.RemoteServiceAdminEvent;
+
+public class EventProducerTest {
+    @Test
+    public void testPublishNotification() throws Exception {
+        RemoteServiceAdminCore remoteServiceAdminCore = EasyMock.createNiceMock(RemoteServiceAdminCore.class);
+        EasyMock.replay(remoteServiceAdminCore);
+
+        final EndpointDescription endpoint = EasyMock.createNiceMock(EndpointDescription.class);
+        EasyMock.expect(endpoint.getServiceId()).andReturn(Long.MAX_VALUE).anyTimes();
+        final String uuid = UUID.randomUUID().toString();
+        EasyMock.expect(endpoint.getFrameworkUUID()).andReturn(uuid).anyTimes();
+        EasyMock.expect(endpoint.getId()).andReturn("foo://bar").anyTimes();
+        final List<String> interfaces = Arrays.asList("org.foo.Bar", "org.boo.Far");
+        EasyMock.expect(endpoint.getInterfaces()).andReturn(interfaces).anyTimes();
+        EasyMock.expect(endpoint.getConfigurationTypes()).andReturn(Arrays.asList("org.apache.cxf.ws")).anyTimes();
+        EasyMock.replay(endpoint);
+        final ServiceReference sref = EasyMock.createNiceMock(ServiceReference.class);
+        EasyMock.replay(sref);
+
+        final Bundle bundle = EasyMock.createNiceMock(Bundle.class);
+        EasyMock.expect(bundle.getBundleId()).andReturn(42L).anyTimes();
+        EasyMock.expect(bundle.getSymbolicName()).andReturn("test.bundle").anyTimes();
+        Hashtable<String, Object> headers = new Hashtable<String, Object>();
+        headers.put("Bundle-Version", "1.2.3.test");
+        EasyMock.expect(bundle.getHeaders()).andReturn(headers).anyTimes();
+        EasyMock.replay(bundle);
+
+        EventAdmin ea = EasyMock.createNiceMock(EventAdmin.class);
+        ea.postEvent((Event) EasyMock.anyObject());
+        EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
+            @Override
+            public Object answer() throws Throwable {
+                Event event = (Event) EasyMock.getCurrentArguments()[0];
+
+                Assert.assertEquals("org/osgi/service/remoteserviceadmin/EXPORT_REGISTRATION", event.getTopic());
+                Assert.assertSame(bundle, event.getProperty("bundle"));
+                Assert.assertEquals(new Long(42), event.getProperty("bundle.id"));
+                Assert.assertEquals("test.bundle", event.getProperty("bundle.symbolicname"));
+                Assert.assertEquals(new Version(1,2,3,"test"), event.getProperty("bundle.version"));
+                Assert.assertNull(event.getProperty("cause"));
+                Assert.assertEquals(endpoint, event.getProperty("export.registration"));
+
+                Assert.assertEquals(new Long(Long.MAX_VALUE), event.getProperty("service.remote.id"));
+                Assert.assertEquals(uuid, event.getProperty("service.remote.uuid"));
+                Assert.assertEquals("foo://bar", event.getProperty("service.remote.uri"));
+                Assert.assertTrue(Arrays.equals(interfaces.toArray(new String[] {}), (String[]) event.getProperty("objectClass")));
+
+                Assert.assertNotNull(event.getProperty("timestamp"));
+
+                RemoteServiceAdminEvent rsae = (RemoteServiceAdminEvent) event.getProperty("event");
+                Assert.assertNull(rsae.getException());
+                Assert.assertEquals(RemoteServiceAdminEvent.EXPORT_REGISTRATION, rsae.getType());
+                Assert.assertSame(bundle, rsae.getSource());
+                ExportReference er = rsae.getExportReference();
+                Assert.assertSame(endpoint, er.getExportedEndpoint());
+                Assert.assertSame(sref, er.getExportedService());
+
+                return null;
+            }
+        });
+        EasyMock.replay(ea);
+
+        ServiceReference eaSref = EasyMock.createNiceMock(ServiceReference.class);
+        EasyMock.replay(eaSref);
+
+        BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
+        EasyMock.expect(bc.getBundle()).andReturn(bundle).anyTimes();
+        EasyMock.expect(bc.getAllServiceReferences(EventAdmin.class.getName(), null)).
+            andReturn(new ServiceReference[] {eaSref}).anyTimes();
+        EasyMock.expect(bc.getService(eaSref)).andReturn(ea).anyTimes();
+        EasyMock.replay(bc);
+        EventProducer eventProducer = new EventProducer(bc);
+
+        ExportRegistrationImpl ereg = new ExportRegistrationImpl(sref, endpoint, remoteServiceAdminCore);
+        eventProducer.publishNotifcation(ereg);
+    }
+
+    @Test
+    public void testPublishErrorNotification() throws Exception {
+        RemoteServiceAdminCore remoteServiceAdminCore = EasyMock.createNiceMock(RemoteServiceAdminCore.class);
+        EasyMock.replay(remoteServiceAdminCore);
+
+        final EndpointDescription endpoint = EasyMock.createNiceMock(EndpointDescription.class);
+        EasyMock.expect(endpoint.getInterfaces()).andReturn(Arrays.asList("org.foo.Bar")).anyTimes();
+        EasyMock.replay(endpoint);
+        final ServiceReference sref = EasyMock.createNiceMock(ServiceReference.class);
+        EasyMock.replay(sref);
+
+        final Bundle bundle = EasyMock.createNiceMock(Bundle.class);
+        EasyMock.expect(bundle.getBundleId()).andReturn(42L).anyTimes();
+        EasyMock.expect(bundle.getSymbolicName()).andReturn("test.bundle").anyTimes();
+        EasyMock.expect(bundle.getHeaders()).andReturn(new Hashtable<String, Object>()).anyTimes();
+        EasyMock.replay(bundle);
+
+        final Exception exportException = new Exception();
+
+        EventAdmin ea = EasyMock.createNiceMock(EventAdmin.class);
+        ea.postEvent((Event) EasyMock.anyObject());
+        EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
+            @Override
+            public Object answer() throws Throwable {
+                Event event = (Event) EasyMock.getCurrentArguments()[0];
+
+                Assert.assertEquals("org/osgi/service/remoteserviceadmin/EXPORT_ERROR", event.getTopic());
+                Assert.assertSame(bundle, event.getProperty("bundle"));
+                Assert.assertEquals(new Long(42), event.getProperty("bundle.id"));
+                Assert.assertEquals("test.bundle", event.getProperty("bundle.symbolicname"));
+                Assert.assertEquals(new Version("0"), event.getProperty("bundle.version"));
+                Assert.assertSame(exportException, event.getProperty("cause"));
+                Assert.assertEquals(endpoint, event.getProperty("export.registration"));
+                Assert.assertTrue(Arrays.equals(new String[] {"org.foo.Bar"}, (String[]) event.getProperty("objectClass")));
+
+                RemoteServiceAdminEvent rsae = (RemoteServiceAdminEvent) event.getProperty("event");
+                Assert.assertSame(exportException, rsae.getException());
+                Assert.assertEquals(RemoteServiceAdminEvent.EXPORT_ERROR, rsae.getType());
+                Assert.assertSame(bundle, rsae.getSource());
+                ExportReference er = rsae.getExportReference();
+                Assert.assertSame(endpoint, er.getExportedEndpoint());
+                Assert.assertSame(sref, er.getExportedService());
+
+                return null;
+            }
+        });
+        EasyMock.replay(ea);
+
+        ServiceReference eaSref = EasyMock.createNiceMock(ServiceReference.class);
+        EasyMock.replay(eaSref);
+
+        BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
+        EasyMock.expect(bc.getBundle()).andReturn(bundle).anyTimes();
+        EasyMock.expect(bc.getAllServiceReferences(EventAdmin.class.getName(), null)).
+            andReturn(new ServiceReference[] {eaSref}).anyTimes();
+        EasyMock.expect(bc.getService(eaSref)).andReturn(ea).anyTimes();
+        EasyMock.replay(bc);
+        EventProducer eventProducer = new EventProducer(bc);
+
+        ExportRegistrationImpl ereg = new ExportRegistrationImpl(sref, endpoint, remoteServiceAdminCore);
+        ereg.setException(exportException);
+        eventProducer.publishNotifcation(Arrays.<ExportRegistration>asList(ereg));
+    }
+}

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/UtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/UtilsTest.java?rev=1442924&r1=1442923&r2=1442924&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/UtilsTest.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/UtilsTest.java Wed Feb  6 12:20:44 2013
@@ -18,20 +18,20 @@
  */
 package org.apache.cxf.dosgi.dsw.service;
 
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
-import java.util.Properties;
+import java.util.HashMap;
+import java.util.Map;
 
 import org.apache.cxf.dosgi.dsw.util.OsgiUtils;
 import org.apache.cxf.dosgi.dsw.util.Utils;
 import org.junit.Test;
 import org.osgi.framework.Constants;
 
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
 
 public class UtilsTest {
 
@@ -72,34 +72,34 @@ public class UtilsTest {
     @Test
     public void testOverlayProperties() {
 
-        Properties original = new Properties();
+        Map<String, Object> original = new HashMap<String, Object>();
 
         original.put("MyProp", "my value");
         original.put(Constants.OBJECTCLASS, "myClass");
 
-        Properties copy = new Properties();
+        Map<String, Object> copy = new HashMap<String, Object>();
         copy.putAll(original);
 
         // nothing should change here
-        Properties overload = new Properties();
+        Map<String, Object> overload = new HashMap<String, Object>();
         OsgiUtils.overlayProperties(copy, overload);
 
         assertEquals(original.size(), copy.size());
-        for (Object key : Collections.list(original.keys())) {
+        for (Object key : original.keySet()) {
             assertEquals(original.get(key), copy.get(key));
         }
-        
+
         copy.clear();
         copy.putAll(original);
-        
+
         // a property should be added
-        overload = new Properties();
+        overload = new HashMap<String, Object>();
         overload.put("new", "prop");
-            
+
         OsgiUtils.overlayProperties(copy, overload);
 
         assertEquals(original.size() + 1, copy.size());
-        for (Object key : Collections.list(original.keys())) {
+        for (Object key : original.keySet()) {
             assertEquals(original.get(key), copy.get(key));
         }
         assertNotNull(overload.get("new"));
@@ -107,61 +107,61 @@ public class UtilsTest {
 
         copy.clear();
         copy.putAll(original);
-        
+
         // only one property should be added
-        overload = new Properties();
+        overload = new HashMap<String, Object>();
         overload.put("new", "prop");
         overload.put("NEW", "prop");
-            
+
         OsgiUtils.overlayProperties(copy, overload);
 
         assertEquals(original.size() + 1, copy.size());
-        for (Object key : Collections.list(original.keys())) {
+        for (Object key : original.keySet()) {
             assertEquals(original.get(key), copy.get(key));
         }
         assertNotNull(overload.get("new"));
         assertEquals("prop", overload.get("new"));
-        
+
         copy.clear();
         copy.putAll(original);
-        
+
         // nothing should change here
-        overload = new Properties();
+        overload = new HashMap<String, Object>();
         overload.put(Constants.OBJECTCLASS, "assd");
         overload.put(Constants.SERVICE_ID, "asasdasd");
         OsgiUtils.overlayProperties(copy, overload);
 
         assertEquals(original.size(), copy.size());
-        for (Object key : Collections.list(original.keys())) {
+        for (Object key : original.keySet()) {
             assertEquals(original.get(key), copy.get(key));
         }
-        
+
         copy.clear();
         copy.putAll(original);
-        
+
         // overwrite own prop
-        overload = new Properties();
+        overload = new HashMap<String, Object>();
         overload.put("MyProp", "newValue");
         OsgiUtils.overlayProperties(copy, overload);
 
         assertEquals(original.size(), copy.size());
-        for (Object key : Collections.list(original.keys())) {
+        for (Object key : original.keySet()) {
             if (!"MyProp".equals(key)) {
                 assertEquals(original.get(key), copy.get(key));
             }
         }
         assertEquals("newValue", copy.get("MyProp"));
-        
+
         copy.clear();
         copy.putAll(original);
-        
+
         // overwrite own prop in different case
-        overload = new Properties();
+        overload = new HashMap<String, Object>();
         overload.put("MYPROP", "newValue");
         OsgiUtils.overlayProperties(copy, overload);
 
         assertEquals(original.size(), copy.size());
-        for (Object key : Collections.list(original.keys())) {
+        for (Object key : original.keySet()) {
             if (!"MyProp".equals(key)) {
                 assertEquals(original.get(key), copy.get(key));
             }



Mime
View raw message