cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject svn commit: r1401715 - in /cxf/dosgi/trunk/dsw/cxf-topology-manager/src: main/java/org/apache/cxf/dosgi/topologymanager/ test/java/org/apache/cxf/dosgi/topologymanager/
Date Wed, 24 Oct 2012 14:49:21 GMT
Author: cschneider
Date: Wed Oct 24 14:49:20 2012
New Revision: 1401715

URL: http://svn.apache.org/viewvc?rev=1401715&view=rev
Log:
DOSGI-129 Fixing NPE, better handling of exceptions

Modified:
    cxf/dosgi/trunk/dsw/cxf-topology-manager/src/main/java/org/apache/cxf/dosgi/topologymanager/TopologyManager.java
    cxf/dosgi/trunk/dsw/cxf-topology-manager/src/main/java/org/apache/cxf/dosgi/topologymanager/Utils.java
    cxf/dosgi/trunk/dsw/cxf-topology-manager/src/test/java/org/apache/cxf/dosgi/topologymanager/TopologyManagerTest.java
    cxf/dosgi/trunk/dsw/cxf-topology-manager/src/test/java/org/apache/cxf/dosgi/topologymanager/UtilsTest.java

Modified: cxf/dosgi/trunk/dsw/cxf-topology-manager/src/main/java/org/apache/cxf/dosgi/topologymanager/TopologyManager.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-topology-manager/src/main/java/org/apache/cxf/dosgi/topologymanager/TopologyManager.java?rev=1401715&r1=1401714&r2=1401715&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-topology-manager/src/main/java/org/apache/cxf/dosgi/topologymanager/TopologyManager.java
(original)
+++ cxf/dosgi/trunk/dsw/cxf-topology-manager/src/main/java/org/apache/cxf/dosgi/topologymanager/TopologyManager.java
Wed Oct 24 14:49:20 2012
@@ -18,6 +18,7 @@
  */
 package org.apache.cxf.dosgi.topologymanager;
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Dictionary;
@@ -131,15 +132,9 @@ public class TopologyManager {
                     Collection<ExportRegistration> endpoints = exports.getValue().get(rsa);
                     // TODO for each notify discovery......
 
-                    try {
-                        ServiceReference[] refs = Utils.getEndpointListeners(bctx);
-                        if (refs != null) {
-                            for (ServiceReference sref : refs) {
-                                notifyListenersOfRemovalIfAppropriate(sref, endpoints);
-                            }
-                        }
-                    } catch (InvalidSyntaxException e) {
-                        LOG.log(Level.SEVERE, e.getMessage(), e);
+                    ServiceReference[] refs = getEndpointListeners(bctx);
+                    for (ServiceReference sref : refs) {
+                        notifyListenersOfRemovalIfAppropriate(sref, endpoints);
                     }
 
                     // remove all management information for the RemoteServiceAdmin
@@ -227,14 +222,12 @@ public class TopologyManager {
                                  new LinkedHashMap<RemoteServiceAdmin, Collection<ExportRegistration>>());
         }
 
-        // trigger the export
         triggerExport(sref);
 
     }
 
     private void triggerExport(final ServiceReference sref) {
         execService.execute(new Runnable() {
-            @SuppressWarnings("unchecked")
             public void run() {
                 LOG.finer("TopologyManager: exporting service ...");
 
@@ -273,8 +266,7 @@ public class TopologyManager {
                                     // enqueue in local list of endpoints
                                     exports.put(remoteServiceAdmin, endpoints);
 
-                                    // publish to endpoint listeners
-                                    nofifyListeners(endpoints);
+                                    nofifyEndpointListenersOfAdding(endpoints);
                                 }
                             }
                         }
@@ -285,21 +277,28 @@ public class TopologyManager {
         });
     }
 
-    protected void nofifyListeners(Collection<ExportRegistration> exportRegistrations)
{
-        try {
-            // Find all EndpointListeners; They must have the Scope property otherwise they
have to be ignored
-            ServiceReference[] refs = Utils.getEndpointListeners(bctx);
-
-            if (refs != null) {
-                for (ServiceReference sref : refs) {
-                    notifyListenerOfAddingIfAppropriate(sref, exportRegistrations);
-                }
-            }
+    protected void nofifyEndpointListenersOfAdding(Collection<ExportRegistration> exportRegistrations)
{
+        ServiceReference[] epListeners = getEndpointListeners(bctx);
+        for (ServiceReference sref : epListeners) {
+            notifyListenerOfAddingIfAppropriate(sref, exportRegistrations);
+        }
+    }
 
+     /** 
+      * Find all EndpointListeners; They must have the Scope property otherwise they have
to be ignored
+      * @param bctx
+      * @return
+      * @throws InvalidSyntaxException
+      */
+    protected static ServiceReference[] getEndpointListeners(BundleContext bctx) {
+        ServiceReference[] result = null;
+        try {
+            String filter = "(" + EndpointListener.ENDPOINT_LISTENER_SCOPE + "=*)";
+            result = bctx.getServiceReferences(EndpointListener.class.getName(), filter);
         } catch (InvalidSyntaxException e) {
             LOG.log(Level.SEVERE, e.getMessage(), e);
         }
-
+        return (result == null) ? new ServiceReference[]{} : result;
     }
 
     /**
@@ -311,91 +310,84 @@ public class TopologyManager {
     protected void notifyListenerOfAddingIfAppropriate(ServiceReference sref,
                                                        Collection<ExportRegistration>
exportRegistrations) {
 
-        // if (sref.getBundle().equals(bctx.getBundle())) {
-        // LOG
-        // .info("TopologyManager: notifyListenerOfAddingIfAppropriate() called for own listener
-> skipping ");
-        // return;
-        // }
-
         EndpointListener epl = (EndpointListener)bctx.getService(sref);
-
         LOG.finer("TopologyManager: notifyListenerOfAddingIfAppropriate() ");
+        List<Filter> filters = getFiltersFromEndpointListenerScope(sref, bctx);
 
-        try {
-
-            List<Filter> filters = Utils.normalizeScope(sref, bctx);
-
-            for (ExportRegistration exReg : exportRegistrations) {
-
-                // FIXME!!!!!!!!!!!!! There needs to be a better way ?!?!?!
-                Map props = exReg.getExportReference().getExportedEndpoint().getProperties();
-                Dictionary d = new Hashtable(props);
-
-                if (LOG.isLoggable(Level.FINE)) {
-                    for (Filter filter : filters) {
-                        LOG.fine("Matching: " + filter + "  against " + d);
-                    }
-                }
-
-                for (Filter filter : filters) {
-                    if (filter.match(d)) {
-                        LOG.fine("Listener mached one of the Endpoints !!!!: " + epl);
-
-                        epl.endpointAdded(exReg.getExportReference().getExportedEndpoint(),
filter
-                                .toString());
-                    }
-                }
+        for (ExportRegistration exReg : exportRegistrations) {
+            EndpointDescription endpoint = getExportedEndpoint(exReg);
+            List<Filter> matchingFilters = getMatchingFilters(filters, endpoint);
+            for (Filter filter : matchingFilters) {
+                epl.endpointAdded(endpoint, filter.toString());
             }
-
-        } catch (InvalidSyntaxException e) {
-            LOG.log(Level.SEVERE, e.getMessage(), e);
         }
+
     }
 
     protected void notifyListenersOfRemovalIfAppropriate(ServiceReference sref,
-                                                         Collection<ExportRegistration>
exportRegistrations) {
-
-        EndpointListener epl = (EndpointListener)bctx.getService(sref);
+            Collection<ExportRegistration> exportRegistrations) {
 
+        EndpointListener epl = (EndpointListener) bctx.getService(sref);
         LOG.finer("TopologyManager: notifyListenerOfREMOVALIfAppropriate() ");
+        List<Filter> filters = getFiltersFromEndpointListenerScope(sref, bctx);
 
-        List<Filter> filters;
+        for (ExportRegistration exReg : exportRegistrations) {
+            EndpointDescription endpoint = getExportedEndpoint(exReg);
+            List<Filter> matchingFilters = getMatchingFilters(filters, endpoint);
+            for (Filter filter : matchingFilters) {
+                epl.endpointRemoved(endpoint, filter.toString());
+            }
+        }
+    }
+    
+    static List<Filter> getFiltersFromEndpointListenerScope(ServiceReference sref,BundleContext
bctx) {
+        List<Filter> filters = new ArrayList<Filter>();
         try {
-            filters = Utils.normalizeScope(sref, bctx);
-
-            for (ExportRegistration exReg : exportRegistrations) {
-
-                // FIXME!!!!!!!!!!!!! There needs to be a better way ?!?!?!
-            	ExportReference ref = exReg.getExportReference(); 
-            	EndpointDescription endpoint = ref.getExportedEndpoint(); 
-                Map props = endpoint.getProperties();
-                Dictionary d = new Hashtable(props);
-
-                if (LOG.isLoggable(Level.FINE)) {
-                    for (Filter filter : filters) {
-                        LOG.fine("Matching: " + filter + "  against " + d);
-                    }
-                }
-
-                for (Filter filter : filters) {
-                    if (filter.match(d)) {
-                        LOG.fine("Listener matched one of the Endpoints !!!! --> calling
removed() ...");
-
-                        epl.endpointRemoved(exReg.getExportReference().getExportedEndpoint(),
filter
-                            .toString());
+            Object fo = sref.getProperty(EndpointListener.ENDPOINT_LISTENER_SCOPE);
+            if (fo instanceof String) {
+                filters.add(bctx.createFilter((String) fo));
+            } else if (fo instanceof String[]) {
+                String[] foArray = (String[]) fo;
+                for (String f : foArray) {
+                    filters.add(bctx.createFilter(f));
+                }
+            } else if (fo instanceof Collection) {
+                @SuppressWarnings("rawtypes")
+                Collection c = (Collection) fo;
+                for (Object o : c) {
+                    if (o instanceof String) {
+                        filters.add(bctx.createFilter((String) o));
+                    } else {
+                        LOG.warning("Component of a filter is not a string -> skipped
!");
                     }
                 }
             }
         } catch (InvalidSyntaxException e) {
             LOG.log(Level.SEVERE, e.getMessage(), e);
         }
+        return filters;
+    }
+
+    private List<Filter> getMatchingFilters(List<Filter> filters,
+            EndpointDescription endpoint) {
+        List<Filter> matchingFilters = new ArrayList<Filter>();
+        Dictionary<String, Object> d = getEndpointProperties(endpoint);
 
+        for (Filter filter : filters) {
+            if (LOG.isLoggable(Level.FINE)) {
+                LOG.fine("Matching: " + filter + "  against " + d);
+            }
+            if (filter.match(d)) {
+                LOG.fine("Listener matched one of the Endpoints !!!! --> calling removed()
...");
+                matchingFilters.add(filter);
+            }
+        }
+        return matchingFilters;
     }
 
     private void checkExistingServices() throws InvalidSyntaxException {
-        ServiceReference[] references = bctx
-            .getServiceReferences(null, "(" + RemoteConstants.SERVICE_EXPORTED_INTERFACES
+ "=*)");
-        // + "("+org.apache.cxf.dosgi.dsw.Constants.EXPORTED_INTERFACES_OLD + "=*))");
+        String filter = "(" + RemoteConstants.SERVICE_EXPORTED_INTERFACES + "=*)";
+        ServiceReference[] references = bctx.getServiceReferences(null, filter);
 
         if (references != null) {
             for (ServiceReference sref : references) {
@@ -411,7 +403,6 @@ public class TopologyManager {
 
                 Map<RemoteServiceAdmin, Collection<ExportRegistration>> ex =
exportedServices.get(sref);
                 if (ex != null) {
-                    EndpointDescription ep = exportRegistration.getExportReference().getExportedEndpoint();
                     for (Map.Entry<RemoteServiceAdmin, Collection<ExportRegistration>>
export : ex.entrySet()) {
                         export.getValue().contains(exportRegistration);
                     }
@@ -432,4 +423,27 @@ public class TopologyManager {
         // LOG.severe("NOT implemented !!!");
     }
 
+    /**
+     * Retrieve exported Endpoint while handling null
+     * @param exReg
+     * @return exported Endpoint or null if not present
+     */
+    private EndpointDescription getExportedEndpoint(ExportRegistration exReg) {
+        ExportReference ref = (exReg == null) ? null : exReg.getExportReference();
+        return (ref == null) ? null : ref.getExportedEndpoint(); 
+    }
+    
+    /**
+     * Retrieve endpoint properties as Dictionary
+     * 
+     * @param ep
+     * @return endpoint properties (will never return null) 
+     */
+    private Dictionary<String, Object> getEndpointProperties(EndpointDescription ep)
{
+        if (ep == null || ep.getProperties() == null) {
+            return new Hashtable<String, Object>();
+        } else {
+            return new Hashtable<String, Object>(ep.getProperties());
+        }
+    }
 }

Modified: cxf/dosgi/trunk/dsw/cxf-topology-manager/src/main/java/org/apache/cxf/dosgi/topologymanager/Utils.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-topology-manager/src/main/java/org/apache/cxf/dosgi/topologymanager/Utils.java?rev=1401715&r1=1401714&r2=1401715&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-topology-manager/src/main/java/org/apache/cxf/dosgi/topologymanager/Utils.java
(original)
+++ cxf/dosgi/trunk/dsw/cxf-topology-manager/src/main/java/org/apache/cxf/dosgi/topologymanager/Utils.java
Wed Oct 24 14:49:20 2012
@@ -18,57 +18,14 @@
   */
 package org.apache.cxf.dosgi.topologymanager;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
 import java.util.UUID;
-import java.util.logging.Logger;
 
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.Filter;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.remoteserviceadmin.EndpointListener;
 import org.osgi.service.remoteserviceadmin.RemoteConstants;
 
 
 public class Utils {
 
-    private static final Logger LOG = Logger.getLogger(Utils.class.getName());
-    
-    protected static ServiceReference[] getEndpointListeners(BundleContext bctx) throws InvalidSyntaxException
{
-        ServiceReference[] refs = bctx
-            .getServiceReferences(EndpointListener.class.getName(),
-                                  "(" + EndpointListener.ENDPOINT_LISTENER_SCOPE + "=*)");
-        return refs;
-    }
-
-    public static List<Filter> normalizeScope(ServiceReference sref,BundleContext bctx)
throws InvalidSyntaxException {
-        List<Filter> filters = new ArrayList<Filter>();
-    
-        Object fo = sref.getProperty(EndpointListener.ENDPOINT_LISTENER_SCOPE);
-        if (fo instanceof String) {
-            filters.add(bctx.createFilter((String)fo));
-        } else if (fo instanceof String[]) {
-            String[] foArray = (String[])fo;
-            for (String f : foArray) {
-                filters.add(bctx.createFilter(f));
-            }
-        } else if (fo instanceof Collection) {
-            Collection c = (Collection)fo;
-            for (Object o : c) {
-                if (o instanceof String) {
-                    filters.add(bctx.createFilter((String)o));
-                } else {
-                    LOG.info("Component of a filter is not a string -> skipped !");
-                }
-            }
-        }
-    
-        return filters;
-    }
-
-    
     public static String getUUID(BundleContext bctx) {
         synchronized ("org.osgi.framework.uuid") {
             String uuid = bctx.getProperty("org.osgi.framework.uuid");

Modified: cxf/dosgi/trunk/dsw/cxf-topology-manager/src/test/java/org/apache/cxf/dosgi/topologymanager/TopologyManagerTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-topology-manager/src/test/java/org/apache/cxf/dosgi/topologymanager/TopologyManagerTest.java?rev=1401715&r1=1401714&r2=1401715&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-topology-manager/src/test/java/org/apache/cxf/dosgi/topologymanager/TopologyManagerTest.java
(original)
+++ cxf/dosgi/trunk/dsw/cxf-topology-manager/src/test/java/org/apache/cxf/dosgi/topologymanager/TopologyManagerTest.java
Wed Oct 24 14:49:20 2012
@@ -18,7 +18,10 @@
   */
 package org.apache.cxf.dosgi.topologymanager;
 
+import static org.junit.Assert.assertEquals;
+
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -56,12 +59,12 @@ public class TopologyManagerTest {
         ExportReference exRef2 = c.createMock(ExportReference.class);
         
         
-        Map props = new HashMap();
+        Map<String, Object> props = new HashMap<String, Object>();
         String[] oc = new String[1];
         oc[0] = "myClass";
         props.put("objectClass", oc);
         
-        Map props2 = new HashMap();
+        Map<String, Object> props2 = new HashMap<String, Object>();
         oc = new String[1];
         oc[0] = "notMyClass";
         props2.put("objectClass", oc);
@@ -106,4 +109,100 @@ public class TopologyManagerTest {
 
     }
 
+    @Test
+    public void testNomalizeScopeForSingleString() {
+
+        try {
+            ServiceReference sr = EasyMock.createMock(ServiceReference.class);
+            EasyMock.expect(sr.getProperty(EndpointListener.ENDPOINT_LISTENER_SCOPE))
+                .andReturn("Filterstring");
+
+            Filter f = EasyMock.createNiceMock(Filter.class);
+            
+            BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
+            EasyMock.expect(bc.createFilter((String)EasyMock.anyObject())).andReturn(f);
+
+            EasyMock.replay(sr);
+            EasyMock.replay(bc);
+
+            List<Filter> res = TopologyManager.getFiltersFromEndpointListenerScope(sr,
bc);
+
+            assertEquals(1, res.size());
+            assertEquals(f, res.get(0));
+
+            EasyMock.verify(sr);
+            EasyMock.verify(bc);
+        } catch (InvalidSyntaxException e) {
+            e.printStackTrace();
+        }
+    }
+    
+    
+    @Test
+    public void testNomalizeScopeForStringArray() {
+
+        try {
+            
+            String[] filterStrings = {"f1","f2","f3"};
+            
+            ServiceReference sr = EasyMock.createMock(ServiceReference.class);
+            EasyMock.expect(sr.getProperty(EndpointListener.ENDPOINT_LISTENER_SCOPE))
+                .andReturn(filterStrings);
+
+            Filter f = EasyMock.createNiceMock(Filter.class);
+            
+            
+            BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
+            EasyMock.expect(bc.createFilter((String)EasyMock.anyObject())).andReturn(f).times(filterStrings.length);
+
+            EasyMock.replay(sr);
+            EasyMock.replay(bc);
+
+            List<Filter> res = TopologyManager.getFiltersFromEndpointListenerScope(sr,
bc);
+
+            assertEquals(filterStrings.length, res.size());
+            assertEquals(f, res.get(0));
+
+            EasyMock.verify(sr);
+            EasyMock.verify(bc);
+        } catch (InvalidSyntaxException e) {
+            e.printStackTrace();
+        }
+    }
+    
+    @Test
+    public void testNomalizeScopeForCollection() {
+
+        try {
+            
+            
+            Collection<String> collection = new ArrayList<String>();
+            collection.add("f1");
+            collection.add("f2");
+            collection.add("f3");
+            
+            ServiceReference sr = EasyMock.createMock(ServiceReference.class);
+            EasyMock.expect(sr.getProperty(EndpointListener.ENDPOINT_LISTENER_SCOPE))
+                .andReturn(collection);
+
+            Filter f = EasyMock.createNiceMock(Filter.class);
+            
+            
+            BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
+            EasyMock.expect(bc.createFilter((String)EasyMock.anyObject())).andReturn(f).times(collection.size());
+
+            EasyMock.replay(sr);
+            EasyMock.replay(bc);
+
+            List<Filter> res = TopologyManager.getFiltersFromEndpointListenerScope(sr,
bc);
+
+            assertEquals(collection.size(), res.size());
+            assertEquals(f, res.get(0));
+
+            EasyMock.verify(sr);
+            EasyMock.verify(bc);
+        } catch (InvalidSyntaxException e) {
+            e.printStackTrace();
+        }
+    }
 }

Modified: cxf/dosgi/trunk/dsw/cxf-topology-manager/src/test/java/org/apache/cxf/dosgi/topologymanager/UtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-topology-manager/src/test/java/org/apache/cxf/dosgi/topologymanager/UtilsTest.java?rev=1401715&r1=1401714&r2=1401715&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-topology-manager/src/test/java/org/apache/cxf/dosgi/topologymanager/UtilsTest.java
(original)
+++ cxf/dosgi/trunk/dsw/cxf-topology-manager/src/test/java/org/apache/cxf/dosgi/topologymanager/UtilsTest.java
Wed Oct 24 14:49:20 2012
@@ -18,130 +18,23 @@
   */
 package org.apache.cxf.dosgi.topologymanager;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
 import java.util.Dictionary;
-import java.util.HashMap;
 import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-
 
 import org.easymock.classextension.EasyMock;
+import org.junit.Test;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Filter;
 import org.osgi.framework.FrameworkUtil;
 import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.remoteserviceadmin.EndpointListener;
 import org.osgi.service.remoteserviceadmin.RemoteConstants;
 
-import org.junit.Test;
-
 public class UtilsTest {
-
-    @Test
-    public void testNomalizeScopeForSingleString() {
-
-        try {
-            ServiceReference sr = EasyMock.createMock(ServiceReference.class);
-            EasyMock.expect(sr.getProperty(EndpointListener.ENDPOINT_LISTENER_SCOPE))
-                .andReturn("Filterstring");
-
-            Filter f = EasyMock.createNiceMock(Filter.class);
-            
-            BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
-            EasyMock.expect(bc.createFilter((String)EasyMock.anyObject())).andReturn(f);
-
-            EasyMock.replay(sr);
-            EasyMock.replay(bc);
-
-            List<Filter> res = Utils.normalizeScope(sr, bc);
-
-            assertEquals(1, res.size());
-            assertEquals(f, res.get(0));
-
-            EasyMock.verify(sr);
-            EasyMock.verify(bc);
-        } catch (InvalidSyntaxException e) {
-            e.printStackTrace();
-        }
-    }
-    
-    
-    @Test
-    public void testNomalizeScopeForStringArray() {
-
-        try {
-            
-            String[] filterStrings = {"f1","f2","f3"};
-            
-            ServiceReference sr = EasyMock.createMock(ServiceReference.class);
-            EasyMock.expect(sr.getProperty(EndpointListener.ENDPOINT_LISTENER_SCOPE))
-                .andReturn(filterStrings);
-
-            Filter f = EasyMock.createNiceMock(Filter.class);
-            
-            
-            BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
-            EasyMock.expect(bc.createFilter((String)EasyMock.anyObject())).andReturn(f).times(filterStrings.length);
-
-            EasyMock.replay(sr);
-            EasyMock.replay(bc);
-
-            List<Filter> res = Utils.normalizeScope(sr, bc);
-
-            assertEquals(filterStrings.length, res.size());
-            assertEquals(f, res.get(0));
-
-            EasyMock.verify(sr);
-            EasyMock.verify(bc);
-        } catch (InvalidSyntaxException e) {
-            e.printStackTrace();
-        }
-    }
-    
-    
-    
-    @Test
-    public void testNomalizeScopeForCollection() {
-
-        try {
-            
-            
-            Collection<String> collection = new ArrayList<String>();
-            collection.add("f1");
-            collection.add("f2");
-            collection.add("f3");
-            
-            ServiceReference sr = EasyMock.createMock(ServiceReference.class);
-            EasyMock.expect(sr.getProperty(EndpointListener.ENDPOINT_LISTENER_SCOPE))
-                .andReturn(collection);
-
-            Filter f = EasyMock.createNiceMock(Filter.class);
-            
-            
-            BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
-            EasyMock.expect(bc.createFilter((String)EasyMock.anyObject())).andReturn(f).times(collection.size());
-
-            EasyMock.replay(sr);
-            EasyMock.replay(bc);
-
-            List<Filter> res = Utils.normalizeScope(sr, bc);
-
-            assertEquals(collection.size(), res.size());
-            assertEquals(f, res.get(0));
-
-            EasyMock.verify(sr);
-            EasyMock.verify(bc);
-        } catch (InvalidSyntaxException e) {
-            e.printStackTrace();
-        }
-    }
-    
     
     @Test
     public void testGetNewUUID(){
@@ -155,9 +48,7 @@ public class UtilsTest {
         
         EasyMock.verify(bc);
     }
-     
-    
-    
+
     @Test
     public void testGetExistingUUID(){
         BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
@@ -170,7 +61,6 @@ public class UtilsTest {
         EasyMock.verify(bc);
     }
 
-    
     @Test
     public void testUUIDFilterExtension() throws InvalidSyntaxException{
         String filter = "(a=b)";
@@ -184,7 +74,7 @@ public class UtilsTest {
         
         Filter f = FrameworkUtil.createFilter(filter);
         
-        Dictionary m = new Hashtable();
+        Dictionary<String, String> m = new Hashtable<String, String>();
         m.put("a", "b");
         
         assertTrue(filter+" filter must match as uuid is missing",f.match(m));      



Mime
View raw message