FELIX-3186 Fixed the test case, which required a patch after the code changes that were done.

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1226522 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/AdapterWithAspectTest.java b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/AdapterWithAspectTest.java
index 70011c9..39ce6d4 100644
--- a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/AdapterWithAspectTest.java
+++ b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/AdapterWithAspectTest.java
@@ -24,7 +24,6 @@
 
 import org.apache.felix.dm.Component;
 import org.apache.felix.dm.DependencyManager;
-import org.apache.felix.dm.ServiceUtil;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.Option;
@@ -41,7 +40,9 @@
             provision(
                 mavenBundle().groupId("org.osgi").artifactId("org.osgi.compendium").version(Base.OSGI_SPEC_VERSION),
                 mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.dependencymanager").versionAsInProject()
-            )
+            ) // ,
+//          new VMOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"),
+//          new TimeoutOption(0)
         );
     }
     
@@ -64,15 +65,15 @@
             .setImplementation(new ServiceConsumer(e))
             .add(m.createServiceDependency()
                 .setService(AdaptedService.class)
-                .setCallbacks("add", "remove")
+                .setCallbacks("add", null, "remove", "swap")
             );
-        Component adapter = m.createAdapterService(OriginalService.class, null)
+        Component adapter = m.createAdapterService(OriginalService.class, null, "add", null, "remove", "swap")
             .setInterface(AdaptedService.class.getName(), null)
-            .setImplementation(ServiceAdapter.class);
+            .setImplementation(new ServiceAdapter(e,1));
         
-        Component adapter2 = m.createAdapterService(OriginalService.class, null)
+        Component adapter2 = m.createAdapterService(OriginalService.class, null, "add", null, "remove", "swap")
             .setInterface(AdaptedService.class.getName(), null)
-            .setImplementation(ServiceAdapter.class);
+            .setImplementation(new ServiceAdapter(e,2));
         
         Component aspect = m.createAspectService(OriginalService.class, null, 10, null)
             .setImplementation(ServiceAspect.class);
@@ -84,16 +85,20 @@
         for (int loop = 0; loop < loops; loop++) {
             int offset = stepsInLoop * loop;
             
+            System.out.println("add adapter");
             m.add(adapter);
+            System.out.println("add consumer");
             m.add(consumer);
             e.waitForStep(1 + offset, 5000);
+            System.out.println("add aspect");
             m.add(aspect);
-            // the aspect adapter will appear
-            // the original adapter will disappear
-            e.waitForStep(3 + offset, 5000);
+            // a swap is expected on the adapter
+            e.waitForStep(2 + offset, 5000);
+            System.out.println("add adapter2");
             m.add(adapter2);
             // another aspect adapter will appear
             e.waitForStep(4 + offset, 5000);
+            System.out.println("remove provider");
             m.remove(provider);
             // two times:
             // the aspect adapter will disappear
@@ -103,16 +108,18 @@
             // TODO the test will fail somewhere here most of the time
             
             e.waitForStep(8 + offset, 5000);
+            System.out.println("remove consumer");
             m.remove(consumer);
             
             // nothing should happen, all consumed services were already gone
-            e.step(9 + offset);
-            
+            System.out.println("add provider");
             m.add(provider);
             // still nothing should happen
-            e.step(10 + offset);
+            System.out.println("remove adapter");
             m.remove(adapter);
+            System.out.println("remove adapter2");
             m.remove(adapter2);
+            System.out.println("remove aspect");
             m.remove(aspect);
         }
         m.remove(provider);
@@ -142,8 +149,12 @@
     
     public static class ServiceAdapter implements AdaptedService {
         private volatile OriginalService m_originalService;
+		private final Ensure m_ensure;
+		private final int m_nr;
         
-        public ServiceAdapter() {
+        public ServiceAdapter(Ensure e, int nr) {
+			this.m_ensure = e;
+			this.m_nr = nr;
         }
         public void init() {
         }
@@ -155,6 +166,24 @@
         }
         public void stop() {
         }
+        
+        void add(ServiceReference ref, OriginalService originalService) {
+        	m_originalService = originalService;
+        	m_ensure.step();
+        	System.out.println("adapter" + m_nr + " add: " + originalService);
+        }
+        
+        void remove(ServiceReference ref, OriginalService originalService) {
+        	System.out.println("adapter" + m_nr + " rem: " + originalService);
+        	m_originalService = null;
+        }
+        
+        void swap(ServiceReference oldRef, OriginalService oldService, ServiceReference newRef, OriginalService newService) {
+        	m_originalService = newService;
+        	m_ensure.step();
+        	System.out.println("adapter" + m_nr + " swp: " + newService);
+        }
+        
         @Override
         public String toString() {
             return "Adapter on " + m_originalService;
@@ -196,14 +225,18 @@
         int counter = 0;
         public void add(ServiceReference ref, AdaptedService service) {
             counter++;
-            System.out.println("add: " + counter + " " + service + " " + ServiceUtil.toString(ref));
+            System.out.println("consumer add: " + counter + " " + service);
             m_ensure.step();
         }
         public void remove(ServiceReference ref, AdaptedService service) {
             counter--;
-            System.out.println("rem: " + counter + " " + service + " " + ServiceUtil.toString(ref));
+            System.out.println("consumer rem: " + counter + " " + service);
             m_ensure.step();
         }
+        public void swap(ServiceReference oldRef, AdaptedService oldService, ServiceReference newRef, AdaptedService newService) {
+        	System.out.println("consumer swp: " + counter + " " + newService);
+        	m_ensure.step();
+        }
         
 //        public void run() {
 //            m_service.invoke();