cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From msch...@apache.org
Subject svn commit: r957925 - /cxf/dosgi/trunk/dsw/cxf-topology-manager/src/test/java/org/apache/cxf/dosgi/topologymanager/TopologyManagerImportTest.java
Date Fri, 25 Jun 2010 12:47:33 GMT
Author: mschaaf
Date: Fri Jun 25 12:47:32 2010
New Revision: 957925

URL: http://svn.apache.org/viewvc?rev=957925&view=rev
Log:
fixed the TopologyManagerImport test case

Modified:
    cxf/dosgi/trunk/dsw/cxf-topology-manager/src/test/java/org/apache/cxf/dosgi/topologymanager/TopologyManagerImportTest.java

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=957925&r1=957924&r2=957925&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
Fri Jun 25 12:47:32 2010
@@ -1,37 +1,53 @@
 package org.apache.cxf.dosgi.topologymanager;
 
 import java.util.Dictionary;
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
 
+import org.easymock.IAnswer;
 import org.easymock.IMocksControl;
 import org.easymock.classextension.EasyMock;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
 import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.remoteserviceadmin.EndpointDescription;
+import org.osgi.service.remoteserviceadmin.ImportReference;
 import org.osgi.service.remoteserviceadmin.ImportRegistration;
 import org.osgi.service.remoteserviceadmin.RemoteServiceAdmin;
 
 import org.junit.Test;
+import static org.junit.Assert.*;
 
 public class TopologyManagerImportTest {
 
     
     @Test
-    public void testImportForNewlyAddedRSA(){
+    public void testImportForNewlyAddedRSA() throws InterruptedException{
         
         IMocksControl c = EasyMock.createNiceControl();
 
+        c.makeThreadSafe(true);
+        
+        final Semaphore sema = new Semaphore(0);
+        
         BundleContext bc = c.createMock(BundleContext.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);
-        ImportRegistration ireg = c.createMock(ImportRegistration.class);
+        final ImportRegistration ireg = c.createMock(ImportRegistration.class);
+        ImportReference iref = c.createMock(ImportReference.class);
         
-        EasyMock.expect(rsa.importService(EasyMock.eq(epd))).andReturn(ireg).once();
+        EasyMock.expect(rsa.importService(EasyMock.eq(epd))).andAnswer(new IAnswer<ImportRegistration>(
) {
 
+            public ImportRegistration answer() throws Throwable {
+                sema.release();
+                return ireg;
+            }
+        }).once();
+        EasyMock.expect(ireg.getImportReference()).andReturn(iref).anyTimes();
+        EasyMock.expect(iref.getImportedEndpoint()).andReturn(epd).anyTimes();
         c.replay();
         
         
@@ -48,6 +64,9 @@ public class TopologyManagerImportTest {
         
         tm.triggerExportImportForRemoteSericeAdmin(rsa);
         
+        assertTrue(sema.tryAcquire(10, TimeUnit.SECONDS));
+        
+        
         tm.stop();
         
         c.verify();



Mime
View raw message