cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r779147 - in /cxf/dosgi/trunk/discovery/local/src: main/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryService.java test/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryServiceTest.java
Date Wed, 27 May 2009 12:37:18 GMT
Author: davidb
Date: Wed May 27 12:37:18 2009
New Revision: 779147

URL: http://svn.apache.org/viewvc?rev=779147&view=rev
Log:
Additional test for what was committed in r779136

Modified:
    cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryService.java
    cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryServiceTest.java

Modified: cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryService.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryService.java?rev=779147&r1=779146&r2=779147&view=diff
==============================================================================
--- cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryService.java
(original)
+++ cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryService.java
Wed May 27 12:37:18 2009
@@ -105,7 +105,7 @@
     }
 
     public void bundleChanged(BundleEvent be) {
-        LOG.info("bundle changed: " + be.getBundle().getSymbolicName());
+        LOG.fine("bundle changed: " + be.getBundle().getSymbolicName());
         switch (be.getType()) {
         case BundleEvent.STARTED:
             findDeclaredRemoteServices(be.getBundle());
@@ -320,12 +320,12 @@
         }
     }
 
-    private void triggerCallbacks(DiscoveredServiceTracker tracker,
-                                  String toMatch, 
-                                  boolean isFilter, 
-                                  ServiceEndpointDescription sd,
-                                  int type) {
-        LOG.info("check if string: " + toMatch + (isFilter ? " matches " : " contained by
") +  sd.getProvidedInterfaces());
+    void triggerCallbacks(DiscoveredServiceTracker tracker,
+                          String toMatch, 
+                          boolean isFilter, 
+                          ServiceEndpointDescription sd,
+                          int type) {
+        LOG.fine("check if string: " + toMatch + (isFilter ? " matches " : " contained by
") +  sd.getProvidedInterfaces());
 
         TrackerNotification notification = 
             isFilter

Modified: cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryServiceTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryServiceTest.java?rev=779147&r1=779146&r2=779147&view=diff
==============================================================================
--- cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryServiceTest.java
(original)
+++ cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryServiceTest.java
Wed May 27 12:37:18 2009
@@ -538,6 +538,35 @@
         
         assertNull(LocalDiscoveryService.removeTracker(dst, forwardMap, reverseMap));
     }
+    
+    public void testTriggerCallbacksWithFilter() throws Exception {
+        String filter = "(|(osgi.remote.service.interfaces=org.acme.A)(osgi.remote.service.interfaces=org.acme.B))";
+
+        Filter mockFilter = EasyMock.createMock(Filter.class);
+        Dictionary<String, Object> map = new Hashtable<String, Object>();
+        map.put("osgi.remote.service.interfaces", Arrays.asList("org.acme.B"));
+        EasyMock.expect(mockFilter.match(map)).andReturn(true).anyTimes();
+        EasyMock.replay(mockFilter);
+
+        BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
+        EasyMock.expect(bc.createFilter(filter)).andReturn(mockFilter).anyTimes();
+        EasyMock.replay(bc);
+        
+        final List<DiscoveredServiceNotification> notifications = 
+            new ArrayList<DiscoveredServiceNotification>();
+        DiscoveredServiceTracker dst = new DiscoveredServiceTracker(){        
+            public void serviceChanged(DiscoveredServiceNotification notification) {
+                notifications.add(notification);
+            }
+        };
+        
+        LocalDiscoveryService lds = new LocalDiscoveryService(bc);
+        ServiceEndpointDescription sd = new ServiceEndpointDescriptionImpl("org.acme.B");
+        
+        assertEquals("Precondition failed", 0, notifications.size());
+        lds.triggerCallbacks(dst, filter, true, sd, DiscoveredServiceNotification.AVAILABLE);
+        assertEquals(1, notifications.size());
+    }
  
     private void verifyNotification(DiscoveredServiceNotification dsn,
                                int filterCount,



Mime
View raw message