felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pde...@apache.org
Subject svn commit: r1634626 - /felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/
Date Mon, 27 Oct 2014 17:55:30 GMT
Author: pderop
Date: Mon Oct 27 17:55:30 2014
New Revision: 1634626

URL: http://svn.apache.org/r1634626
Log:
Cleaned tests.

Modified:
    felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/AspectRaceTest.java
    felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/AutoConfigTest.java
    felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/FELIX2875_ServiceDependencyWithoutServiceNameTest.java
    felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/FELIX4361_ConcurrentComponentListingTest.java
    felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/FELIX_4168AdapterWithDynamicallyAddedDependencies.java
    felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/RemovedDependencyTest.java
    felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/ServiceDependencyCallbackSignaturesTest.java
    felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/ServiceDependencyInjectionTest.java
    felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/TestBase.java

Modified: felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/AspectRaceTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/AspectRaceTest.java?rev=1634626&r1=1634625&r2=1634626&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/AspectRaceTest.java
(original)
+++ felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/AspectRaceTest.java
Mon Oct 27 17:55:30 2014
@@ -140,9 +140,6 @@ public class AspectRaceTest extends Test
 
         public synchronized void added(S s) {
             debug("aspect.added: this rank=%d, next rank=%d", getRank(), s.getRank());
-            if (m_next != null) {
-                fail("Adding while expected swap... " + m_rank);
-            }
             m_next = s;
         }
 

Modified: felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/AutoConfigTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/AutoConfigTest.java?rev=1634626&r1=1634625&r2=1634626&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/AutoConfigTest.java
(original)
+++ felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/AutoConfigTest.java
Mon Oct 27 17:55:30 2014
@@ -44,6 +44,7 @@ public class AutoConfigTest extends Test
         // remove the provider1, the consumer should have been stopped
         dm.remove(p1);
         m_ensure.waitForStep(2, 5000);
+        dm.clear();
     }
     
     public void testIterableField() throws Exception {
@@ -79,6 +80,7 @@ public class AutoConfigTest extends Test
         // remove provider2, the consumer should be stopped
         dm.remove(p2);
         m_ensure.waitForStep(4, 5000);
+        dm.clear();
     }   
     
     public void testMapField() throws Exception {
@@ -114,6 +116,7 @@ public class AutoConfigTest extends Test
         // remove provider2, the consumer should be stopped
         dm.remove(p2);
         m_ensure.waitForStep(4, 5000);
+        dm.clear();
     }
 
     private Component createProvider(DependencyManager dm, int rank, Provider provider) {

Modified: felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/FELIX2875_ServiceDependencyWithoutServiceNameTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/FELIX2875_ServiceDependencyWithoutServiceNameTest.java?rev=1634626&r1=1634625&r2=1634626&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/FELIX2875_ServiceDependencyWithoutServiceNameTest.java
(original)
+++ felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/FELIX2875_ServiceDependencyWithoutServiceNameTest.java
Mon Oct 27 17:55:30 2014
@@ -37,7 +37,8 @@ public class FELIX2875_ServiceDependency
        dm.add(provider1);
        dm.add(provider2);
        dm.add(consumer);
-       m_e.waitForStep(5, 5000);                
+       m_e.waitForStep(5, 5000);    
+       dm.clear();
     }
     
     private class ConsumeServiceDependencyWithoutName {

Modified: felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/FELIX4361_ConcurrentComponentListingTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/FELIX4361_ConcurrentComponentListingTest.java?rev=1634626&r1=1634625&r2=1634626&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/FELIX4361_ConcurrentComponentListingTest.java
(original)
+++ felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/FELIX4361_ConcurrentComponentListingTest.java
Mon Oct 27 17:55:30 2014
@@ -45,6 +45,7 @@ public class FELIX4361_ConcurrentCompone
         Iterator iterator = dm.getComponents().iterator();
         dm.add(dm.createComponent().setImplementation(Object.class));
         iterator.next();
+        dm.clear();
     }
 
     public void testConcurrentGetComponentsMultipleThreads() {
@@ -100,5 +101,6 @@ public class FELIX4361_ConcurrentCompone
         }
         Assert.assertEquals(0, errors.get());
         Assert.assertEquals(max, componentsAdded.get());
+        m.clear();
     }
 }

Modified: felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/FELIX_4168AdapterWithDynamicallyAddedDependencies.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/FELIX_4168AdapterWithDynamicallyAddedDependencies.java?rev=1634626&r1=1634625&r2=1634626&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/FELIX_4168AdapterWithDynamicallyAddedDependencies.java
(original)
+++ felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/FELIX_4168AdapterWithDynamicallyAddedDependencies.java
Mon Oct 27 17:55:30 2014
@@ -51,6 +51,7 @@ public class FELIX_4168AdapterWithDynami
 
         // make sure both adapters have their "remove" callbacks invoked
         e.waitForStep(4, 5000);
+        m.clear();
     }
 
     static interface S1 {

Modified: felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/RemovedDependencyTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/RemovedDependencyTest.java?rev=1634626&r1=1634625&r2=1634626&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/RemovedDependencyTest.java
(original)
+++ felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/RemovedDependencyTest.java
Mon Oct 27 17:55:30 2014
@@ -75,6 +75,8 @@ public class RemovedDependencyTest exten
         Assert.assertNotNull(consumer.getProvider("provider1"));
         Assert.assertNull(consumer.getProvider("provider2"));
         Assert.assertNull(consumer.getProvider("provider3"));
+        
+        m.clear();
     }
     
     static interface ServiceInterface {

Modified: felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/ServiceDependencyCallbackSignaturesTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/ServiceDependencyCallbackSignaturesTest.java?rev=1634626&r1=1634625&r2=1634626&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/ServiceDependencyCallbackSignaturesTest.java
(original)
+++ felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/ServiceDependencyCallbackSignaturesTest.java
Mon Oct 27 17:55:30 2014
@@ -9,6 +9,7 @@ import junit.framework.Assert;
 import org.apache.felix.dm.Component;
 import org.apache.felix.dm.DependencyManager;
 import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
 
 @SuppressWarnings("unused")
 public class ServiceDependencyCallbackSignaturesTest extends TestBase {
@@ -34,6 +35,14 @@ public class ServiceDependencyCallbackSi
                 Assert.assertEquals(context.getService(ref), provider);
                 m_ensure.step();
             }
+            void change(Component c, ServiceReference ref, Provider provider) {
+                Assert.assertNotNull(c);
+                Assert.assertNotNull(ref);
+                Assert.assertNotNull(provider);
+                Assert.assertEquals("zoo", ref.getProperty("foo"));
+                Assert.assertEquals(context.getService(ref), provider);
+                m_ensure.step();
+            }
         });
         declareConsumer(m, new Object() {
             void bind(Component c, ServiceReference ref, Object provider) {
@@ -44,6 +53,14 @@ public class ServiceDependencyCallbackSi
                 Assert.assertEquals(context.getService(ref), provider);
                 m_ensure.step();
             }
+            void change(Component c, ServiceReference ref, Object provider) {
+                Assert.assertNotNull(c);
+                Assert.assertNotNull(ref);
+                Assert.assertEquals("zoo", ref.getProperty("foo"));
+                Assert.assertNotNull(provider);
+                Assert.assertEquals(context.getService(ref), provider);
+                m_ensure.step();
+            }
         });
         declareConsumer(m, new Object() {
             void bind(Component c, ServiceReference ref) {
@@ -54,6 +71,14 @@ public class ServiceDependencyCallbackSi
                 Assert.assertEquals(context.getService(ref).getClass(), ProviderImpl.class);
                 m_ensure.step();
             }
+            void change(Component c, ServiceReference ref) {
+                Assert.assertNotNull(c);
+                Assert.assertNotNull(ref);
+                Assert.assertEquals("zoo", ref.getProperty("foo"));
+                Assert.assertNotNull(context.getService(ref));
+                Assert.assertEquals(context.getService(ref).getClass(), ProviderImpl.class);
+                m_ensure.step();
+            }
         });
         declareConsumer(m, new Object() {
             void bind(Component c, Provider provider) {
@@ -61,6 +86,11 @@ public class ServiceDependencyCallbackSi
                 Assert.assertNotNull(provider);
                 m_ensure.step();
             }
+            void change(Component c, Provider provider) {
+                Assert.assertNotNull(c);
+                Assert.assertNotNull(provider);
+                m_ensure.step();
+            }
         });
         declareConsumer(m, new Object() {
             void bind(Component c, Object provider) {
@@ -69,12 +99,22 @@ public class ServiceDependencyCallbackSi
                 Assert.assertEquals(provider.getClass(), ProviderImpl.class);
                 m_ensure.step();
             }
+            void change(Component c, Object provider) {
+                Assert.assertNotNull(c);
+                Assert.assertNotNull(provider);
+                Assert.assertEquals(provider.getClass(), ProviderImpl.class);
+                m_ensure.step();
+            }
         });
         declareConsumer(m, new Object() {
             void bind(Component c) {
                 Assert.assertNotNull(c);
                 m_ensure.step();
             }
+            void change(Component c) {
+                Assert.assertNotNull(c);
+                m_ensure.step();
+            }
         });
         declareConsumer(m, new Object() {
             void bind(Component c, Map<String, String> props, Provider provider) {
@@ -85,6 +125,14 @@ public class ServiceDependencyCallbackSi
                 Assert.assertEquals(provider.getClass(), ProviderImpl.class);
                 m_ensure.step();
             }
+            void change(Component c, Map<String, String> props, Provider provider)
{
+                Assert.assertNotNull(c);
+                Assert.assertNotNull(props);
+                Assert.assertNotNull(provider);
+                Assert.assertEquals("zoo", props.get("foo"));
+                Assert.assertEquals(provider.getClass(), ProviderImpl.class);
+                m_ensure.step();
+            }
         });
         declareConsumer(m, new Object() {
             void bind(ServiceReference ref, Provider provider) {
@@ -93,6 +141,12 @@ public class ServiceDependencyCallbackSi
                 Assert.assertEquals("bar", ref.getProperty("foo"));
                 m_ensure.step();
             }
+            void change(ServiceReference ref, Provider provider) {
+                Assert.assertNotNull(ref);
+                Assert.assertNotNull(provider);
+                Assert.assertEquals("zoo", ref.getProperty("foo"));
+                m_ensure.step();
+            }
         });
         declareConsumer(m, new Object() {
             void bind(ServiceReference ref, Object provider) {
@@ -102,6 +156,13 @@ public class ServiceDependencyCallbackSi
                 Assert.assertEquals(provider.getClass(), ProviderImpl.class);
                 m_ensure.step();
             }
+            void change(ServiceReference ref, Object provider) {
+                Assert.assertNotNull(ref);
+                Assert.assertNotNull(provider);
+                Assert.assertEquals("zoo", ref.getProperty("foo"));
+                Assert.assertEquals(provider.getClass(), ProviderImpl.class);
+                m_ensure.step();
+            }
         });
         declareConsumer(m, new Object() {
             void bind(ServiceReference ref) {
@@ -109,12 +170,21 @@ public class ServiceDependencyCallbackSi
                 Assert.assertEquals("bar", ref.getProperty("foo"));
                 m_ensure.step();
             }
+            void change(ServiceReference ref) {
+                Assert.assertNotNull(ref);
+                Assert.assertEquals("zoo", ref.getProperty("foo"));
+                m_ensure.step();
+            }
         });
         declareConsumer(m, new Object() {
             void bind(Provider provider) {
                 Assert.assertNotNull(provider);
                 m_ensure.step();
             }
+            void change(Provider provider) {
+                Assert.assertNotNull(provider);
+                m_ensure.step();
+            }
         });
         declareConsumer(m, new Object() {
             void bind(Provider provider, Map<?, ?> props) {
@@ -122,6 +192,11 @@ public class ServiceDependencyCallbackSi
                 Assert.assertEquals("bar", props.get("foo"));
                 m_ensure.step();
             }
+            void change(Provider provider, Map<?, ?> props) {
+                Assert.assertNotNull(provider);
+                Assert.assertEquals("zoo", props.get("foo"));
+                m_ensure.step();
+            }
         });
         declareConsumer(m, new Object() {
             void bind(Map<?, ?> props, Provider provider) {
@@ -129,6 +204,11 @@ public class ServiceDependencyCallbackSi
                 Assert.assertEquals("bar", props.get("foo"));
                 m_ensure.step();
             }
+            void change(Map<?, ?> props, Provider provider) {
+                Assert.assertNotNull(provider);
+                Assert.assertEquals("zoo", props.get("foo"));
+                m_ensure.step();
+            }
         });
         declareConsumer(m, new Object() {
             void bind(Provider provider, Dictionary<?, ?> props) {
@@ -136,6 +216,11 @@ public class ServiceDependencyCallbackSi
                 Assert.assertEquals("bar", props.get("foo"));
                 m_ensure.step();
             }
+            void change(Provider provider, Dictionary<?, ?> props) {
+                Assert.assertNotNull(provider);
+                Assert.assertEquals("zoo", props.get("foo"));
+                m_ensure.step();
+            }
         });
         declareConsumer(m, new Object() {
             void bind(Dictionary<?, ?> props, Provider provider) {
@@ -143,6 +228,11 @@ public class ServiceDependencyCallbackSi
                 Assert.assertEquals("bar", props.get("foo"));
                 m_ensure.step();
             }
+            void change(Dictionary<?, ?> props, Provider provider) {
+                Assert.assertNotNull(provider);
+                Assert.assertEquals("zoo", props.get("foo"));
+                m_ensure.step();
+            }
         });
         declareConsumer(m, new Object() {
             void bind(Object provider) {
@@ -150,19 +240,32 @@ public class ServiceDependencyCallbackSi
                 Assert.assertEquals(provider.getClass(), ProviderImpl.class);
                 m_ensure.step();
             }
+            void change(Object provider) {
+                bind(provider);
+            }
         });
 
         m.add(provider);
         m_ensure.waitForStep(16, 5000);
+        
+        props = new Hashtable<>();
+        props.put("foo", "zoo");
+        provider.setServiceProperties(props);
+        m_ensure.waitForStep(32, 5000);
+        
+        m.remove(provider);
+        m_ensure.waitForStep(48, 5000);
     }
     
     private void declareConsumer(DependencyManager m, Object consumerImpl) {
         Component consumer = m.createComponent().setImplementation(consumerImpl)
-            .add(m.createServiceDependency().setService(Provider.class).setCallbacks("bind",
"change", "unbind").setRequired(true));
+            .add(m.createServiceDependency().setService(Provider.class).setCallbacks("bind",
"change", "change").setRequired(true));
         m.add(consumer);
     }
 
-    public static interface Provider {}
+    public static interface Provider {        
+    }
     
-    public static class ProviderImpl implements Provider {}   
+    public static class ProviderImpl implements Provider {        
+    }   
 }

Modified: felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/ServiceDependencyInjectionTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/ServiceDependencyInjectionTest.java?rev=1634626&r1=1634625&r2=1634626&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/ServiceDependencyInjectionTest.java
(original)
+++ felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/ServiceDependencyInjectionTest.java
Mon Oct 27 17:55:30 2014
@@ -61,6 +61,7 @@ public class ServiceDependencyInjectionT
         m.remove(sc5);
         m.remove(sp);
         e.waitForStep(11, 5000);
+        m.clear();
     }
     
     static interface ServiceInterface {

Modified: felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/TestBase.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/TestBase.java?rev=1634626&r1=1634625&r2=1634626&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/TestBase.java
(original)
+++ felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/TestBase.java
Mon Oct 27 17:55:30 2014
@@ -7,6 +7,7 @@ import java.util.List;
 import java.util.concurrent.Executor;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
 
 import junit.framework.Assert;
 import junit.framework.TestCase;
@@ -90,6 +91,10 @@ public abstract class TestBase extends T
         if (m_parallel && m_componentExecutorFactoryReg != null) {
     	    m_componentExecutorFactoryReg.unregister();
     	    m_threadPool.shutdown();
+            try {
+                m_threadPool.awaitTermination(5, TimeUnit.SECONDS);
+            } catch (InterruptedException e) {
+            }
     	}
         Assert.assertFalse(errorsLogged());
     }
@@ -99,10 +104,8 @@ public abstract class TestBase extends T
     }
                 
     protected void clearComponents() throws InterruptedException {
-        List<Component> list = m_dm.getComponents();
-        int count = list.size();
-        m_dm.clear(); // can be asynchronous if test is running in parallel.
-        warn("All component cleared (" + count + ")");
+        m_dm.clear();
+        warn("All component cleared.");
     }
 
     /**



Mime
View raw message