cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject svn commit: r1403685 [2/2] - in /cxf/dosgi/trunk/dsw/cxf-topology-manager: ./ src/main/java/org/apache/cxf/dosgi/topologymanager/ src/test/java/org/apache/cxf/dosgi/topologymanager/
Date Tue, 30 Oct 2012 13:10:21 GMT
Modified: cxf/dosgi/trunk/dsw/cxf-topology-manager/src/test/java/org/apache/cxf/dosgi/topologymanager/EndpointListenerImplTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-topology-manager/src/test/java/org/apache/cxf/dosgi/topologymanager/EndpointListenerImplTest.java?rev=1403685&r1=1403684&r2=1403685&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-topology-manager/src/test/java/org/apache/cxf/dosgi/topologymanager/EndpointListenerImplTest.java
(original)
+++ cxf/dosgi/trunk/dsw/cxf-topology-manager/src/test/java/org/apache/cxf/dosgi/topologymanager/EndpointListenerImplTest.java
Tue Oct 30 13:10:20 2012
@@ -104,7 +104,7 @@ public class EndpointListenerImplTest {
         EasyMock.replay(tm);
         EasyMock.replay(sr);
         
-        EndpointListenerImpl endpointListener = new EndpointListenerImpl(bc, tm);
+        EndpointListenerManager endpointListener = new EndpointListenerManager(bc, tm);
                 
         endpointListener.start();
 

Copied: cxf/dosgi/trunk/dsw/cxf-topology-manager/src/test/java/org/apache/cxf/dosgi/topologymanager/EndpointListenerNotifierTest.java
(from r1401717, 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/EndpointListenerNotifierTest.java?p2=cxf/dosgi/trunk/dsw/cxf-topology-manager/src/test/java/org/apache/cxf/dosgi/topologymanager/EndpointListenerNotifierTest.java&p1=cxf/dosgi/trunk/dsw/cxf-topology-manager/src/test/java/org/apache/cxf/dosgi/topologymanager/TopologyManagerTest.java&r1=1401717&r2=1403685&rev=1403685&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/EndpointListenerNotifierTest.java
Tue Oct 30 13:10:20 2012
@@ -41,7 +41,7 @@ import org.osgi.service.remoteserviceadm
 
 import org.junit.Test;
 
-public class TopologyManagerTest {
+public class EndpointListenerNotifierTest {
 
     @Test
     public void testNotifyListenersOfRemovalIfAppropriate() throws InvalidSyntaxException
{
@@ -92,17 +92,20 @@ public class TopologyManagerTest {
         epl.endpointRemoved(EasyMock.eq(epd), EasyMock.eq("(objectClass=myClass)"));
         EasyMock.expectLastCall().once();
         
+        ExportRepository exportRepository = EasyMock.createMock(ExportRepository.class);
+        
         c.replay();
         EasyMock.replay(epl);
         
-        TopologyManager tm = new TopologyManager(bc, null);
+        
+        EndpointListenerNotifier tm = new EndpointListenerNotifier(bc, exportRepository);
 
 
         List<ExportRegistration> exRegs = new ArrayList<ExportRegistration>();
         exRegs.add(exReg);
         exRegs.add(exReg2);
 
-        tm.notifyListenersOfRemovalIfAppropriate(sref, exRegs);
+        tm.notifyListenersOfRemoval(sref, exRegs);
 
         c.verify();
         EasyMock.verify(epl);
@@ -125,7 +128,7 @@ public class TopologyManagerTest {
             EasyMock.replay(sr);
             EasyMock.replay(bc);
 
-            List<Filter> res = TopologyManager.getFiltersFromEndpointListenerScope(sr,
bc);
+            List<Filter> res = EndpointListenerNotifier.getFiltersFromEndpointListenerScope(sr,
bc);
 
             assertEquals(1, res.size());
             assertEquals(f, res.get(0));
@@ -158,7 +161,7 @@ public class TopologyManagerTest {
             EasyMock.replay(sr);
             EasyMock.replay(bc);
 
-            List<Filter> res = TopologyManager.getFiltersFromEndpointListenerScope(sr,
bc);
+            List<Filter> res = EndpointListenerNotifier.getFiltersFromEndpointListenerScope(sr,
bc);
 
             assertEquals(filterStrings.length, res.size());
             assertEquals(f, res.get(0));
@@ -194,7 +197,7 @@ public class TopologyManagerTest {
             EasyMock.replay(sr);
             EasyMock.replay(bc);
 
-            List<Filter> res = TopologyManager.getFiltersFromEndpointListenerScope(sr,
bc);
+            List<Filter> res = EndpointListenerNotifier.getFiltersFromEndpointListenerScope(sr,
bc);
 
             assertEquals(collection.size(), res.size());
             assertEquals(f, res.get(0));

Copied: cxf/dosgi/trunk/dsw/cxf-topology-manager/src/test/java/org/apache/cxf/dosgi/topologymanager/ListenerHookImplTest.java
(from r1401717, 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/ListenerHookImplTest.java?p2=cxf/dosgi/trunk/dsw/cxf-topology-manager/src/test/java/org/apache/cxf/dosgi/topologymanager/ListenerHookImplTest.java&p1=cxf/dosgi/trunk/dsw/cxf-topology-manager/src/test/java/org/apache/cxf/dosgi/topologymanager/UtilsTest.java&r1=1401717&r2=1403685&rev=1403685&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/ListenerHookImplTest.java
Tue Oct 30 13:10:20 2012
@@ -34,14 +34,14 @@ import org.osgi.framework.FrameworkUtil;
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.service.remoteserviceadmin.RemoteConstants;
 
-public class UtilsTest {
+public class ListenerHookImplTest {
     
     @Test
     public void testGetNewUUID(){
         BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
         EasyMock.expect(bc.getProperty(EasyMock.eq("org.osgi.framework.uuid"))).andReturn(null).atLeastOnce();
         EasyMock.replay(bc);
-        String uuid = Utils.getUUID(bc);
+        String uuid = ListenerHookImpl.getUUID(bc);
         assertNotNull(uuid);
         
         assertEquals(System.getProperty("org.osgi.framework.uuid"),uuid );
@@ -54,7 +54,7 @@ public class UtilsTest {
         BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
         EasyMock.expect(bc.getProperty(EasyMock.eq("org.osgi.framework.uuid"))).andReturn("MyUUID").atLeastOnce();
         EasyMock.replay(bc);
-        String uuid = Utils.getUUID(bc);
+        String uuid = ListenerHookImpl.getUUID(bc);
         
         assertEquals("MyUUID",uuid );
         
@@ -70,7 +70,7 @@ public class UtilsTest {
         EasyMock.expect(bc.getProperty(EasyMock.eq("org.osgi.framework.uuid"))).andReturn("MyUUID").atLeastOnce();
         EasyMock.replay(bc);
         
-        filter = Utils.extendFilter(filter, bc);
+        filter = ListenerHookImpl.extendFilter(filter, bc);
         
         Filter f = FrameworkUtil.createFilter(filter);
         

Modified: cxf/dosgi/trunk/dsw/cxf-topology-manager/src/test/java/org/apache/cxf/dosgi/topologymanager/TopologyManagerImportTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-topology-manager/src/test/java/org/apache/cxf/dosgi/topologymanager/TopologyManagerImportTest.java?rev=1403685&r1=1403684&r2=1403685&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-topology-manager/src/test/java/org/apache/cxf/dosgi/topologymanager/TopologyManagerImportTest.java
(original)
+++ cxf/dosgi/trunk/dsw/cxf-topology-manager/src/test/java/org/apache/cxf/dosgi/topologymanager/TopologyManagerImportTest.java
Tue Oct 30 13:10:20 2012
@@ -1,5 +1,8 @@
 package org.apache.cxf.dosgi.topologymanager;
 
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
 import java.util.Dictionary;
 import java.util.concurrent.Semaphore;
 import java.util.concurrent.TimeUnit;
@@ -7,6 +10,7 @@ import java.util.concurrent.TimeUnit;
 import org.easymock.IAnswer;
 import org.easymock.IMocksControl;
 import org.easymock.classextension.EasyMock;
+import org.junit.Test;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.remoteserviceadmin.EndpointDescription;
@@ -14,31 +18,33 @@ import org.osgi.service.remoteserviceadm
 import org.osgi.service.remoteserviceadmin.ImportRegistration;
 import org.osgi.service.remoteserviceadmin.RemoteServiceAdmin;
 
-import org.junit.Test;
-import static org.junit.Assert.*;
-
 public class TopologyManagerImportTest {
 
     
+    @SuppressWarnings("rawtypes")
     @Test
     public void testImportForNewlyAddedRSA() throws InterruptedException{
         
-        IMocksControl c = EasyMock.createNiceControl();
+        IMocksControl c = EasyMock.createControl();
 
         c.makeThreadSafe(true);
         
         final Semaphore sema = new Semaphore(0);
         
         BundleContext bc = c.createMock(BundleContext.class);
+        RemoteServiceAdminTracker rsaTracker = c.createMock(RemoteServiceAdminTracker.class);
         ServiceRegistration sreg = c.createMock(ServiceRegistration.class);
         EasyMock.expect(bc.registerService((String)EasyMock.anyObject(), EasyMock.anyObject(),
(Dictionary)EasyMock.anyObject())).andReturn(sreg).anyTimes();
-         
         
         EndpointDescription epd = c.createMock(EndpointDescription.class);
         RemoteServiceAdmin rsa  = c.createMock(RemoteServiceAdmin.class);
         final ImportRegistration ireg = c.createMock(ImportRegistration.class);
+        EasyMock.expect(ireg.getException()).andReturn(null);
         ImportReference iref = c.createMock(ImportReference.class);
         
+        rsaTracker.addListener(EasyMock.<RemoteServiceAdminLifeCycleListener>anyObject());
+        EasyMock.expect(rsaTracker.getList()).andReturn(Arrays.asList(rsa)).anyTimes();
+        
         EasyMock.expect(rsa.importService(EasyMock.eq(epd))).andAnswer(new IAnswer<ImportRegistration>(
) {
 
             public ImportRegistration answer() throws Throwable {
@@ -50,23 +56,13 @@ public class TopologyManagerImportTest {
         EasyMock.expect(iref.getImportedEndpoint()).andReturn(epd).anyTimes();
         c.replay();
         
-        
-        RemoteServiceAdminList rsaList = new RemoteServiceAdminList(bc);
-        
-        TopologyManagerImport tm = new TopologyManagerImport(bc, rsaList);
+        TopologyManagerImport tm = new TopologyManagerImport(bc, rsaTracker);
 
         tm.start();
-        
         // no RSa available yet so no import ...  
-        tm.addImportableService("myFilter", epd);
-        
-        rsaList.add(rsa);
-        
-        tm.triggerExportImportForRemoteServiceAdmin(rsa);
-        
-        assertTrue(sema.tryAcquire(10, TimeUnit.SECONDS));
-        
-        
+        tm.endpointAdded(epd, "myFilter");
+        tm.triggerImportsForRemoteServiceAdmin(rsa);
+        assertTrue("importService should have been called on RemoteServiceAdmin", sema.tryAcquire(100,
TimeUnit.SECONDS));
         tm.stop();
         
         c.verify();



Mime
View raw message