Fixes and enhancements to these tests.

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1039036 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/AbstractServiceDependencyTest.java b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/AbstractServiceDependencyTest.java
index c75c5a0..676e19e 100644
--- a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/AbstractServiceDependencyTest.java
+++ b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/AbstractServiceDependencyTest.java
@@ -23,8 +23,8 @@
 import static org.ops4j.pax.exam.CoreOptions.provision;
 import junit.framework.Assert;
 
-import org.apache.felix.dm.DependencyManager;
 import org.apache.felix.dm.Component;
+import org.apache.felix.dm.DependencyManager;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.Option;
@@ -50,8 +50,17 @@
        // helper class that ensures certain steps get executed in sequence
        Ensure e = new Ensure();
        // create a service provider and consumer
-       Component sp = m.createComponent().setImplementation(new ServiceProvider(e)).setInterface(ServiceAbstract.class.getName(), null);
-       Component sc = m.createComponent().setImplementation(new ServiceConsumer(e)).add(m.createServiceDependency().setService(ServiceAbstract.class).setRequired(true).setCallbacks("bind", "unbind"));
+       Component sp = m.createComponent()
+           .setInterface(ServiceAbstract.class.getName(), null)
+           .setImplementation(new ServiceProvider(e))
+           ;
+       Component sc = m.createComponent()
+           .setImplementation(new ServiceConsumer(e))
+           .add(m.createServiceDependency()
+               .setService(ServiceAbstract.class)
+               .setRequired(true)
+               .setCallbacks("bind", "unbind")
+               );
        m.add(sp);
        m.add(sc);
        m.remove(sp);
@@ -105,6 +114,7 @@
        }
 
        public void unbind(ServiceAbstract service) {
+           System.out.println("UNBINDDDDDDDDDDDDDDDDDDDDDDDDDDD");
            Assert.assertEquals(m_service, service);
            m_ensure.step(6);
        }
diff --git a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/DynamicProxyAspectTest.java b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/DynamicProxyAspectTest.java
index 3488462..bced730 100644
--- a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/DynamicProxyAspectTest.java
+++ b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/DynamicProxyAspectTest.java
@@ -28,8 +28,8 @@
 
 import junit.framework.Assert;
 
-import org.apache.felix.dm.DependencyManager;
 import org.apache.felix.dm.Component;
+import org.apache.felix.dm.DependencyManager;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.Option;
@@ -92,6 +92,14 @@
         
         // make sure the proxy has been called twice
         Assert.assertEquals("Proxy should have been invoked this many times.", 2, DynamicProxyHandler.getCounter());
+        
+        try {
+            Thread.sleep(2000);
+        }
+        catch (InterruptedException e1) {
+            // TODO Auto-generated catch block
+            e1.printStackTrace();
+        }
     }
     
     static interface ServiceInterface {
@@ -158,6 +166,7 @@
         }
 
         public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+            System.out.println("IIIIIIINVOKE--------------------------" + method.getName());
             if (m_service == null) {
                 Assert.fail("No service was injected into dynamic proxy handler " + m_label);
             }
@@ -165,7 +174,12 @@
             if (m == null) {
                 Assert.fail("No method " + method.getName() + " was found in instance " + m_service + " in dynamic proxy handler " + m_label);
             }
-            m_counter++;
+            if (method.getName().equals("invoke")) {
+                // only count methods called 'invoke' because those are actually the ones
+                // both interfaces implement (and the dynamic proxy might be invoked for
+                // other methods, such as toString() as well)
+                m_counter++;
+            }
             return m.invoke(m_service, args);
         }
         
diff --git a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/ServiceDependencyComponentLifeCycleTest.java b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/ServiceDependencyComponentLifeCycleTest.java
index b8c96e3..53bc3b1 100644
--- a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/ServiceDependencyComponentLifeCycleTest.java
+++ b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/ServiceDependencyComponentLifeCycleTest.java
@@ -102,7 +102,9 @@
         
         e.step(11);
         
-        // remove the service again
+        // remove the service again, the component still has an instance bound
+        // dependency on it, so stop() should be invoked, but the component
+        // should not be destroyed
         m.remove(component2);
         e.step(15);
         Assert.assertNull("service should no longer be available", st.getService());
@@ -116,8 +118,8 @@
         private final Ensure m_ensure;
         private final Ensure.Steps m_initSteps = new Ensure.Steps(1, 5);
         private final Ensure.Steps m_startSteps = new Ensure.Steps(2, 6, 8, 16);
-        private final Ensure.Steps m_stopSteps = new Ensure.Steps(3, 7, 17, 18);
-        private final Ensure.Steps m_destroySteps = new Ensure.Steps(4, 14);
+        private final Ensure.Steps m_stopSteps = new Ensure.Steps(3, 7, 12, 17);
+        private final Ensure.Steps m_destroySteps = new Ensure.Steps(4, 18);
 
         public MyComponent(Ensure e) {
             m_ensure = e;