felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clem...@apache.org
Subject svn commit: r1451167 [3/7] - in /felix/trunk/ipojo/handler/temporal: ./ doc/ src/ temporal-dependency-handler-it/ temporal-dependency-handler-it/src/ temporal-dependency-handler-it/src/it/ temporal-dependency-handler-it/src/it/temporal-it/ temporal-dep...
Date Thu, 28 Feb 2013 10:27:24 GMT
Added: felix/trunk/ipojo/handler/temporal/temporal-dependency-handler-it/src/it/temporal-it/src/test/java/org/apache/felix/ipojo/handler/temporal/test/FilterTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/handler/temporal/temporal-dependency-handler-it/src/it/temporal-it/src/test/java/org/apache/felix/ipojo/handler/temporal/test/FilterTest.java?rev=1451167&view=auto
==============================================================================
--- felix/trunk/ipojo/handler/temporal/temporal-dependency-handler-it/src/it/temporal-it/src/test/java/org/apache/felix/ipojo/handler/temporal/test/FilterTest.java (added)
+++ felix/trunk/ipojo/handler/temporal/temporal-dependency-handler-it/src/it/temporal-it/src/test/java/org/apache/felix/ipojo/handler/temporal/test/FilterTest.java Thu Feb 28 10:27:21 2013
@@ -0,0 +1,263 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.handler.temporal.test;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.handler.temporal.services.CheckService;
+import org.apache.felix.ipojo.handler.temporal.services.FooService;
+import org.junit.Test;
+import org.osgi.framework.ServiceReference;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Checks <tt>requires.filter</tt>, <tt>temporal.filter</tt>, <tt>temporal.from</tt> and
+ * <tt>requires.from</tt> attributes.
+ */
+public class FilterTest extends Common {
+
+    /**
+     * Checks <tt>temporal.filter</tt> with dependency id.
+     * The filter is made to get only one provider.
+     */
+    @Test
+    public void testWithTemporalFilters() {
+        String prov = "provider";
+        ComponentInstance provider1 = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String prov2 = "provider2";
+        ComponentInstance provider2 = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov2);
+
+        Dictionary configuration = new Hashtable();
+        String un = "under-1";
+        configuration.put("instance.name", un);
+        Dictionary filter = new Hashtable();
+        filter.put("foo", "(instance.name=provider2)");
+        configuration.put("temporal.filters", filter);
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-MultipleCheckServiceProvider",
+                configuration);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        // Stop the provider.
+        provider2.stop();
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 2", ref_cs);
+        long begin = System.currentTimeMillis();
+        DelayedProvider dp2 = new DelayedProvider(provider2, 100);
+        dp2.start();
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation - 2", cs.check());
+        long end = System.currentTimeMillis();
+        System.out.println("delay = " + (end - begin));
+        assertTrue("Assert min delay", (end - begin) >= 100);
+        assertTrue("Assert max delay", (end - begin) <= 1000);
+        dp2.stop();
+
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 3", ref_cs);
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation - 3", cs.check());
+
+        provider1.stop();
+        provider2.stop();
+        provider1.dispose();
+        provider2.dispose();
+        under.stop();
+        under.dispose();
+    }
+
+    /**
+     * Checks <tt>requires.filter</tt> with dependency id.
+     * The filter is made to get only one provider.
+     */
+    @Test
+    public void testWithRequireFilters() {
+        String prov = "provider";
+        ComponentInstance provider1 = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String prov2 = "provider2";
+        ComponentInstance provider2 = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov2);
+
+        Dictionary configuration = new Hashtable();
+        String un = "under-1";
+        configuration.put("instance.name", un);
+        Dictionary filter = new Hashtable();
+        filter.put("foo", "(instance.name=provider2)");
+        configuration.put("requires.filters", filter);
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-MultipleCheckServiceProvider", configuration);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        // Stop the provider.
+        provider2.stop();
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 2", ref_cs);
+        long begin = System.currentTimeMillis();
+        DelayedProvider dp2 = new DelayedProvider(provider2, 100);
+        dp2.start();
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation - 2", cs.check());
+        long end = System.currentTimeMillis();
+        System.out.println("delay = " + (end - begin));
+        assertTrue("Assert min delay", (end - begin) >= 100);
+        assertTrue("Assert max delay", (end - begin) <= 1000);
+        dp2.stop();
+
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 3", ref_cs);
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation - 3", cs.check());
+
+        provider1.stop();
+        provider2.stop();
+        provider1.dispose();
+        provider2.dispose();
+        under.stop();
+        under.dispose();
+    }
+
+    /**
+     * Checks <tt>temporal.from</tt> with dependency id.
+     * The filter is made to get only one specific provider.
+     */
+    @Test
+    public void testWithTemporalFrom() {
+        String prov = "provider";
+        ComponentInstance provider1 = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String prov2 = "provider2";
+        ComponentInstance provider2 = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov2);
+
+        Dictionary configuration = new Hashtable();
+        String un = "under-1";
+        configuration.put("instance.name", un);
+        Dictionary filter = new Hashtable();
+        filter.put("foo", "provider2");
+        configuration.put("temporal.from", filter);
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-MultipleCheckServiceProvider", configuration);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        // Stop the provider.
+        provider2.stop();
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 2", ref_cs);
+        long begin = System.currentTimeMillis();
+        DelayedProvider dp2 = new DelayedProvider(provider2, 100);
+        dp2.start();
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation - 2", cs.check());
+        long end = System.currentTimeMillis();
+        System.out.println("delay = " + (end - begin));
+        assertTrue("Assert min delay", (end - begin) >= 100);
+        assertTrue("Assert max delay", (end - begin) <= 1000);
+        dp2.stop();
+
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 3", ref_cs);
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation - 3", cs.check());
+
+        provider1.stop();
+        provider2.stop();
+        provider1.dispose();
+        provider2.dispose();
+        under.stop();
+        under.dispose();
+    }
+
+    /**
+     * Checks <tt>requires.from</tt> with dependency id.
+     * The filter is made to get only one specific provider.
+     */
+    @Test
+    public void testWithRequiresFrom() {
+        String prov = "provider";
+        ComponentInstance provider1 = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String prov2 = "provider2";
+        ComponentInstance provider2 = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov2);
+
+        Dictionary configuration = new Hashtable();
+        String un = "under-1";
+        configuration.put("instance.name", un);
+        Dictionary filter = new Hashtable();
+        filter.put("foo", "provider2");
+        configuration.put("requires.from", filter);
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-MultipleCheckServiceProvider", configuration);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        // Stop the provider.
+        provider2.stop();
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 2", ref_cs);
+        long begin = System.currentTimeMillis();
+        DelayedProvider dp2 = new DelayedProvider(provider2, 100);
+        dp2.start();
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation - 2", cs.check());
+        long end = System.currentTimeMillis();
+        System.out.println("delay = " + (end - begin));
+        assertTrue("Assert min delay", (end - begin) >= 100);
+        assertTrue("Assert max delay", (end - begin) <= 1000);
+        dp2.stop();
+
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 3", ref_cs);
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation - 3", cs.check());
+
+        provider1.stop();
+        provider2.stop();
+        provider1.dispose();
+        provider2.dispose();
+        under.stop();
+        under.dispose();
+    }
+}

Added: felix/trunk/ipojo/handler/temporal/temporal-dependency-handler-it/src/it/temporal-it/src/test/java/org/apache/felix/ipojo/handler/temporal/test/NoDelayTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/handler/temporal/temporal-dependency-handler-it/src/it/temporal-it/src/test/java/org/apache/felix/ipojo/handler/temporal/test/NoDelayTest.java?rev=1451167&view=auto
==============================================================================
--- felix/trunk/ipojo/handler/temporal/temporal-dependency-handler-it/src/it/temporal-it/src/test/java/org/apache/felix/ipojo/handler/temporal/test/NoDelayTest.java (added)
+++ felix/trunk/ipojo/handler/temporal/temporal-dependency-handler-it/src/it/temporal-it/src/test/java/org/apache/felix/ipojo/handler/temporal/test/NoDelayTest.java Thu Feb 28 10:27:21 2013
@@ -0,0 +1,146 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.handler.temporal.test;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.handler.temporal.services.CheckService;
+import org.apache.felix.ipojo.handler.temporal.services.FooService;
+import org.junit.Test;
+import org.osgi.framework.ServiceReference;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class NoDelayTest extends Common {
+
+    @Test
+    public void testNoDelay() {
+        String prov = "provider";
+        ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-CheckServiceProvider", un);
+        assertNotNull("Check creation", under);
+        assertNotNull("Check provider creation", prov);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        provider.stop();
+        provider.dispose();
+        under.stop();
+        under.dispose();
+    }
+
+    @Test
+    public void testNoDelayWithProxy() {
+        String prov = "provider";
+        ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-ProxiedCheckServiceProvider", un);
+        assertNotNull("Check creation", under);
+        assertNotNull("Check provider creation", prov);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        provider.stop();
+        provider.dispose();
+        under.stop();
+        under.dispose();
+    }
+
+    @Test
+    public void testMultipleNoDelay() {
+        String prov1 = "provider-1";
+        ComponentInstance provider1 = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov1);
+        String un = "under-2";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-MultipleCheckServiceProvider", un);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov1);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        provider1.stop();
+        provider1.dispose();
+        under.stop();
+        under.dispose();
+    }
+
+    @Test
+    public void testCollectionNoDelay() {
+        String prov1 = "provider-1";
+        ComponentInstance provider1 = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov1);
+        String un = "under-2";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-ColCheckServiceProvider", un);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov1);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        provider1.stop();
+        provider1.dispose();
+        under.stop();
+        under.dispose();
+    }
+
+    @Test
+    public void testProxiedCollectionNoDelay() {
+        String prov1 = "provider-1";
+        ComponentInstance provider1 = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov1);
+        String un = "under-2";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-ProxiedColCheckServiceProvider", un);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov1);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        provider1.stop();
+        provider1.dispose();
+        under.stop();
+        under.dispose();
+    }
+
+}

Added: felix/trunk/ipojo/handler/temporal/temporal-dependency-handler-it/src/it/temporal-it/src/test/java/org/apache/felix/ipojo/handler/temporal/test/NullTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/handler/temporal/temporal-dependency-handler-it/src/it/temporal-it/src/test/java/org/apache/felix/ipojo/handler/temporal/test/NullTest.java?rev=1451167&view=auto
==============================================================================
--- felix/trunk/ipojo/handler/temporal/temporal-dependency-handler-it/src/it/temporal-it/src/test/java/org/apache/felix/ipojo/handler/temporal/test/NullTest.java (added)
+++ felix/trunk/ipojo/handler/temporal/temporal-dependency-handler-it/src/it/temporal-it/src/test/java/org/apache/felix/ipojo/handler/temporal/test/NullTest.java Thu Feb 28 10:27:21 2013
@@ -0,0 +1,536 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.handler.temporal.test;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.handler.temporal.services.CheckService;
+import org.apache.felix.ipojo.handler.temporal.services.FooService;
+import org.junit.Test;
+import org.osgi.framework.ServiceReference;
+
+import static org.junit.Assert.*;
+
+public class NullTest extends Common {
+
+    @Test
+    public void testNull() {
+        String prov = "provider";
+        ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-NullCheckServiceProvider", un);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        // Stop the provider.
+        provider.stop();
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 2", ref_cs);
+        long begin = System.currentTimeMillis();
+        DelayedProvider dp = new DelayedProvider(provider, 200);
+        dp.start();
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation - 2", cs.check());
+        long end = System.currentTimeMillis();
+
+        assertTrue("Assert delay", (end - begin) >= 200);
+
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 3", ref_cs);
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation - 3", cs.check());
+
+        provider.stop();
+        provider.dispose();
+        under.stop();
+        under.dispose();
+    }
+
+    @Test
+    public void testNullTimeout() {
+        String prov = "provider";
+        ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-NullCheckServiceProvider", un);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        // Stop the provider.
+        provider.stop();
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 2", ref_cs);
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        boolean res = false;
+        try {
+            res = cs.check();
+        } catch (RuntimeException e) {
+            fail("A null was expected ...");
+        }
+        assertFalse("Check null", res); // Return false when the foo service is null.
+
+        provider.stop();
+        provider.dispose();
+        under.stop();
+        under.dispose();
+        return;
+    }
+
+    @Test
+    public void testDelayTimeout() {
+        String prov = "provider";
+        ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-NullCheckServiceProviderTimeout", un);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        // Stop the provider.
+        provider.stop();
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 2", ref_cs);
+        long begin = System.currentTimeMillis();
+        DelayedProvider dp = new DelayedProvider(provider, 200);
+        dp.start();
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation - 2", cs.check());
+        long end = System.currentTimeMillis();
+
+        assertTrue("Assert delay", (end - begin) >= 200);
+
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 3", ref_cs);
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation - 3", cs.check());
+
+        provider.stop();
+        provider.dispose();
+        under.stop();
+        under.dispose();
+    }
+
+    @Test
+    public void testNullWithProxy() {
+        String prov = "provider";
+        ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-NullProxiedCheckServiceProvider", un);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        // Stop the provider.
+        provider.stop();
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 2", ref_cs);
+        long begin = System.currentTimeMillis();
+        DelayedProvider dp = new DelayedProvider(provider, 200);
+        dp.start();
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation - 2", cs.check());
+        long end = System.currentTimeMillis();
+
+        assertTrue("Assert delay", (end - begin) >= 200);
+
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 3", ref_cs);
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation - 3", cs.check());
+
+        provider.stop();
+        provider.dispose();
+        under.stop();
+        under.dispose();
+    }
+
+    @Test
+    public void testNullTimeoutWithProxy() {
+        String prov = "provider";
+        ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-NullProxiedCheckServiceProvider", un);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        // Stop the provider.
+        provider.stop();
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 2", ref_cs);
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        boolean res = false;
+        try {
+            res = cs.check();
+        } catch (RuntimeException e) {
+            fail("A null was expected ...");
+        }
+        assertFalse("Check null", res); // Return false when the foo service is null.
+
+        provider.stop();
+        provider.dispose();
+        under.stop();
+        under.dispose();
+        return;
+    }
+
+    @Test
+    public void testDelayTimeoutWithProxy() {
+        String prov = "provider";
+        ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-NullProxiedCheckServiceProviderTimeout", un);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        // Stop the provider.
+        provider.stop();
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 2", ref_cs);
+        long begin = System.currentTimeMillis();
+        DelayedProvider dp = new DelayedProvider(provider, 200);
+        dp.start();
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation - 2", cs.check());
+        long end = System.currentTimeMillis();
+
+        assertTrue("Assert delay", (end - begin) >= 200);
+
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 3", ref_cs);
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation - 3", cs.check());
+
+        provider.stop();
+        provider.dispose();
+        under.stop();
+        under.dispose();
+    }
+
+    @Test
+    public void testNullMultipleTimeout() {
+        String prov = "provider";
+        ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-NullMultipleCheckServiceProviderTimeout", un);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        // Stop the provider.
+        provider.stop();
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 2", ref_cs);
+        DelayedProvider dp = new DelayedProvider(provider, 400);
+        dp.start();
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        boolean res = false;
+        try {
+            res = cs.check();
+        } catch (RuntimeException e) {
+            fail("A null was expected ...");
+        }
+        assertTrue("Check nullable", res);
+
+        dp.stop();
+        provider.stop();
+        provider.dispose();
+        under.stop();
+        under.dispose();
+        return;
+    }
+
+    @Test
+    public void testNullCollectionTimeout() {
+        String prov = "provider";
+        ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-NullColCheckServiceProviderTimeout", un);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        // Stop the provider.
+        provider.stop();
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 2", ref_cs);
+        DelayedProvider dp = new DelayedProvider(provider, 400);
+        dp.start();
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        boolean res = false;
+        try {
+            res = cs.check();
+        } catch (RuntimeException e) {
+            fail("A null was expected ...");
+        }
+        assertTrue("Check nullable", res);
+
+        dp.stop();
+        provider.stop();
+        provider.dispose();
+        under.stop();
+        under.dispose();
+        return;
+    }
+
+    @Test
+    public void testNullProxiedCollectionTimeout() {
+        String prov = "provider";
+        ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-NullProxiedColCheckServiceProviderTimeout", un);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        // Stop the provider.
+        provider.stop();
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 2", ref_cs);
+        DelayedProvider dp = new DelayedProvider(provider, 400);
+        dp.start();
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        boolean res = false;
+        try {
+            res = cs.check();
+        } catch (RuntimeException e) {
+            fail("A null was expected ... : " + e.getMessage());
+            e.printStackTrace();
+        }
+        assertTrue("Check nullable", res);
+
+        dp.stop();
+        provider.stop();
+        provider.dispose();
+        under.stop();
+        under.dispose();
+        return;
+    }
+
+    @Test
+    public void testDelayOnMultipleDependency() {
+        String prov = "provider";
+        ComponentInstance provider1 = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String prov2 = "provider2";
+        ComponentInstance provider2 = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov2);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-NullableMultipleCheckServiceProviderTimeout", un);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        // Stop the providers.
+        provider1.stop();
+        provider2.stop();
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 2", ref_cs);
+        long begin = System.currentTimeMillis();
+        DelayedProvider dp = new DelayedProvider(provider1, 1500);
+        DelayedProvider dp2 = new DelayedProvider(provider2, 100);
+        dp.start();
+        dp2.start();
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation - 2", cs.check());
+        long end = System.currentTimeMillis();
+        System.out.println("delay = " + (end - begin));
+        assertTrue("Assert min delay", (end - begin) >= 100);
+        assertTrue("Assert max delay", (end - begin) <= 1000);
+        dp.stop();
+        dp2.stop();
+
+        provider1.stop();
+        provider2.stop();
+
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 3", ref_cs);
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+
+        assertFalse("Check invocation - 3", cs.check()); // Will return false as the contained nullable will return false to the foo method.
+
+        provider1.dispose();
+        provider2.dispose();
+        under.stop();
+        under.dispose();
+    }
+
+    @Test
+    public void testDelayOnCollectionDependency() {
+        String prov = "provider";
+        ComponentInstance provider1 = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String prov2 = "provider2";
+        ComponentInstance provider2 = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov2);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-NullableColCheckServiceProviderTimeout", un);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        // Stop the providers.
+        provider1.stop();
+        provider2.stop();
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 2", ref_cs);
+        long begin = System.currentTimeMillis();
+        DelayedProvider dp = new DelayedProvider(provider1, 1500);
+        DelayedProvider dp2 = new DelayedProvider(provider2, 100);
+        dp.start();
+        dp2.start();
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation - 2", cs.check());
+        long end = System.currentTimeMillis();
+        System.out.println("delay = " + (end - begin));
+        assertTrue("Assert min delay", (end - begin) >= 100);
+        assertTrue("Assert max delay", (end - begin) <= 1000);
+        dp.stop();
+        dp2.stop();
+
+        provider1.stop();
+        provider2.stop();
+
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 3", ref_cs);
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+
+        assertFalse("Check invocation - 3", cs.check()); // Will return false as the contained nullable will return false to the foo method.
+
+        provider1.dispose();
+        provider2.dispose();
+        under.stop();
+        under.dispose();
+    }
+
+    @Test
+    public void testDelayOnProxiedCollectionDependency() {
+        String prov = "provider";
+        ComponentInstance provider1 = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String prov2 = "provider2";
+        ComponentInstance provider2 = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov2);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-NullableProxiedColCheckServiceProviderTimeout", un);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        // Stop the providers.
+        provider1.stop();
+        provider2.stop();
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 2", ref_cs);
+        long begin = System.currentTimeMillis();
+        DelayedProvider dp = new DelayedProvider(provider1, 1500);
+        DelayedProvider dp2 = new DelayedProvider(provider2, 100);
+        dp.start();
+        dp2.start();
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation - 2", cs.check());
+        long end = System.currentTimeMillis();
+        System.out.println("delay = " + (end - begin));
+        assertTrue("Assert min delay", (end - begin) >= 100);
+        assertTrue("Assert max delay", (end - begin) <= 1000);
+        dp.stop();
+        dp2.stop();
+
+        provider1.stop();
+        provider2.stop();
+
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 3", ref_cs);
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+
+        assertFalse("Check invocation - 3", cs.check()); // Will return false as the contained nullable will return false to the foo method.
+
+        provider1.dispose();
+        provider2.dispose();
+        under.stop();
+        under.dispose();
+    }
+}

Added: felix/trunk/ipojo/handler/temporal/temporal-dependency-handler-it/src/it/temporal-it/src/test/java/org/apache/felix/ipojo/handler/temporal/test/NullableTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/handler/temporal/temporal-dependency-handler-it/src/it/temporal-it/src/test/java/org/apache/felix/ipojo/handler/temporal/test/NullableTest.java?rev=1451167&view=auto
==============================================================================
--- felix/trunk/ipojo/handler/temporal/temporal-dependency-handler-it/src/it/temporal-it/src/test/java/org/apache/felix/ipojo/handler/temporal/test/NullableTest.java (added)
+++ felix/trunk/ipojo/handler/temporal/temporal-dependency-handler-it/src/it/temporal-it/src/test/java/org/apache/felix/ipojo/handler/temporal/test/NullableTest.java Thu Feb 28 10:27:21 2013
@@ -0,0 +1,535 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.handler.temporal.test;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.handler.temporal.services.CheckService;
+import org.apache.felix.ipojo.handler.temporal.services.FooService;
+import org.junit.Test;
+import org.osgi.framework.ServiceReference;
+
+import static org.junit.Assert.*;
+
+public class NullableTest extends Common {
+
+    @Test
+    public void testNullable() {
+        String prov = "provider";
+        ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-NullableCheckServiceProvider", un);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        // Stop the provider.
+        provider.stop();
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 2", ref_cs);
+        long begin = System.currentTimeMillis();
+        DelayedProvider dp = new DelayedProvider(provider, 200);
+        dp.start();
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation - 2", cs.check());
+        long end = System.currentTimeMillis();
+
+        assertTrue("Assert delay", (end - begin) >= 200);
+
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 3", ref_cs);
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation - 3", cs.check());
+
+        provider.stop();
+        provider.dispose();
+        under.stop();
+        under.dispose();
+    }
+
+    @Test
+    public void testNullableTimeout() {
+        String prov = "provider";
+        ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-NullableCheckServiceProvider", un);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        // Stop the provider.
+        provider.stop();
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 2", ref_cs);
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        boolean res = false;
+        try {
+            res = cs.check();
+        } catch (RuntimeException e) {
+            fail("A nullable was expected ...");
+        }
+        assertFalse("Check nullable", res);
+
+        provider.stop();
+        provider.dispose();
+        under.stop();
+        under.dispose();
+        return;
+    }
+
+    @Test
+    public void testDelayTimeout() {
+        String prov = "provider";
+        ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-NullableCheckServiceProviderTimeout", un);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        // Stop the provider.
+        provider.stop();
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 2", ref_cs);
+        long begin = System.currentTimeMillis();
+        DelayedProvider dp = new DelayedProvider(provider, 200);
+        dp.start();
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation - 2", cs.check());
+        long end = System.currentTimeMillis();
+
+        assertTrue("Assert delay", (end - begin) >= 200);
+
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 3", ref_cs);
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation - 3", cs.check());
+
+        provider.stop();
+        provider.dispose();
+        under.stop();
+        under.dispose();
+    }
+
+    @Test
+    public void testNullableWithProxy() {
+        String prov = "provider";
+        ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-NullableProxiedCheckServiceProvider", un);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        // Stop the provider.
+        provider.stop();
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 2", ref_cs);
+        long begin = System.currentTimeMillis();
+        DelayedProvider dp = new DelayedProvider(provider, 200);
+        dp.start();
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation - 2", cs.check());
+        long end = System.currentTimeMillis();
+
+        assertTrue("Assert delay", (end - begin) >= 200);
+
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 3", ref_cs);
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation - 3", cs.check());
+
+        provider.stop();
+        provider.dispose();
+        under.stop();
+        under.dispose();
+    }
+
+    @Test
+    public void testNullableTimeoutWithProxy() {
+        String prov = "provider";
+        ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-NullableProxiedCheckServiceProvider", un);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        // Stop the provider.
+        provider.stop();
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 2", ref_cs);
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        boolean res = false;
+        try {
+            res = cs.check();
+        } catch (RuntimeException e) {
+            fail("A nullable was expected ...");
+        }
+        assertFalse("Check nullable", res);
+
+        provider.stop();
+        provider.dispose();
+        under.stop();
+        under.dispose();
+        return;
+    }
+
+    @Test
+    public void testDelayTimeoutWithProxy() {
+        String prov = "provider";
+        ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-NullableProxiedCheckServiceProviderTimeout", un);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        // Stop the provider.
+        provider.stop();
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 2", ref_cs);
+        long begin = System.currentTimeMillis();
+        DelayedProvider dp = new DelayedProvider(provider, 200);
+        dp.start();
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation - 2", cs.check());
+        long end = System.currentTimeMillis();
+
+        assertTrue("Assert delay", (end - begin) >= 200);
+
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 3", ref_cs);
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation - 3", cs.check());
+
+        provider.stop();
+        provider.dispose();
+        under.stop();
+        under.dispose();
+    }
+
+    @Test
+    public void testNullableMultipleTimeout() {
+        String prov = "provider";
+        ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-NullableMultipleCheckServiceProviderTimeout", un);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        // Stop the provider.
+        provider.stop();
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 2", ref_cs);
+        DelayedProvider dp = new DelayedProvider(provider, 400);
+        dp.start();
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        boolean res = false;
+        try {
+            res = cs.check();
+        } catch (RuntimeException e) {
+            fail("A nullable was expected ...");
+        }
+        assertFalse("Check nullable", res);
+
+        dp.stop();
+        provider.stop();
+        provider.dispose();
+        under.stop();
+        under.dispose();
+        return;
+    }
+
+    @Test
+    public void testNullableCollectionTimeout() {
+        String prov = "provider";
+        ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-NullableColCheckServiceProviderTimeout", un);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        // Stop the provider.
+        provider.stop();
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 2", ref_cs);
+        DelayedProvider dp = new DelayedProvider(provider, 400);
+        dp.start();
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        boolean res = false;
+        try {
+            res = cs.check();
+        } catch (RuntimeException e) {
+            fail("A nullable was expected ...");
+        }
+        assertFalse("Check nullable", res);
+
+        dp.stop();
+        provider.stop();
+        provider.dispose();
+        under.stop();
+        under.dispose();
+        return;
+    }
+
+    @Test
+    public void testNullableProxiedCollectionTimeout() {
+        String prov = "provider";
+        ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-NullableProxiedColCheckServiceProviderTimeout", un);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        // Stop the provider.
+        provider.stop();
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 2", ref_cs);
+        DelayedProvider dp = new DelayedProvider(provider, 400);
+        dp.start();
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        boolean res = false;
+        try {
+            res = cs.check();
+        } catch (RuntimeException e) {
+            fail("A nullable was expected ...");
+        }
+        assertFalse("Check nullable", res);
+
+        dp.stop();
+        provider.stop();
+        provider.dispose();
+        under.stop();
+        under.dispose();
+        return;
+    }
+
+    @Test
+    public void testDelayOnMultipleDependency() {
+        String prov = "provider";
+        ComponentInstance provider1 = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String prov2 = "provider2";
+        ComponentInstance provider2 = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov2);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-NullableMultipleCheckServiceProviderTimeout", un);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        // Stop the providers.
+        provider1.stop();
+        provider2.stop();
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 2", ref_cs);
+        long begin = System.currentTimeMillis();
+        DelayedProvider dp = new DelayedProvider(provider1, 1500);
+        DelayedProvider dp2 = new DelayedProvider(provider2, 100);
+        dp.start();
+        dp2.start();
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation - 2", cs.check());
+        long end = System.currentTimeMillis();
+        System.out.println("delay = " + (end - begin));
+        assertTrue("Assert min delay", (end - begin) >= 100);
+        assertTrue("Assert max delay", (end - begin) <= 1000);
+        dp.stop();
+        dp2.stop();
+
+        provider1.stop();
+        provider2.stop();
+
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 3", ref_cs);
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+
+        assertFalse("Check invocation - 3", cs.check()); // Will return false as the contained nullable will return false to the foo method.
+
+        provider1.dispose();
+        provider2.dispose();
+        under.stop();
+        under.dispose();
+    }
+
+    @Test
+    public void testDelayOnCollectionDependency() {
+        String prov = "provider";
+        ComponentInstance provider1 = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String prov2 = "provider2";
+        ComponentInstance provider2 = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov2);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-NullableColCheckServiceProviderTimeout", un);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        // Stop the providers.
+        provider1.stop();
+        provider2.stop();
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 2", ref_cs);
+        long begin = System.currentTimeMillis();
+        DelayedProvider dp = new DelayedProvider(provider1, 1500);
+        DelayedProvider dp2 = new DelayedProvider(provider2, 100);
+        dp.start();
+        dp2.start();
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation - 2", cs.check());
+        long end = System.currentTimeMillis();
+        System.out.println("delay = " + (end - begin));
+        assertTrue("Assert min delay", (end - begin) >= 100);
+        assertTrue("Assert max delay", (end - begin) <= 1000);
+        dp.stop();
+        dp2.stop();
+
+        provider1.stop();
+        provider2.stop();
+
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 3", ref_cs);
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+
+        assertFalse("Check invocation - 3", cs.check()); // Will return false as the contained nullable will return false to the foo method.
+
+        provider1.dispose();
+        provider2.dispose();
+        under.stop();
+        under.dispose();
+    }
+
+    @Test
+    public void testDelayOnProxiedCollectionDependency() {
+        String prov = "provider";
+        ComponentInstance provider1 = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String prov2 = "provider2";
+        ComponentInstance provider2 = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov2);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-NullableProxiedColCheckServiceProviderTimeout", un);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        // Stop the providers.
+        provider1.stop();
+        provider2.stop();
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 2", ref_cs);
+        long begin = System.currentTimeMillis();
+        DelayedProvider dp = new DelayedProvider(provider1, 1500);
+        DelayedProvider dp2 = new DelayedProvider(provider2, 100);
+        dp.start();
+        dp2.start();
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation - 2", cs.check());
+        long end = System.currentTimeMillis();
+        System.out.println("delay = " + (end - begin));
+        assertTrue("Assert min delay", (end - begin) >= 100);
+        assertTrue("Assert max delay", (end - begin) <= 1000);
+        dp.stop();
+        dp2.stop();
+
+        provider1.stop();
+        provider2.stop();
+
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 3", ref_cs);
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+
+        assertFalse("Check invocation - 3", cs.check()); // Will return false as the contained nullable will return false to the foo method.
+
+        provider1.dispose();
+        provider2.dispose();
+        under.stop();
+        under.dispose();
+    }
+}

Added: felix/trunk/ipojo/handler/temporal/temporal-dependency-handler-it/src/it/temporal-it/src/test/java/org/apache/felix/ipojo/handler/temporal/test/TemporalTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/handler/temporal/temporal-dependency-handler-it/src/it/temporal-it/src/test/java/org/apache/felix/ipojo/handler/temporal/test/TemporalTest.java?rev=1451167&view=auto
==============================================================================
--- felix/trunk/ipojo/handler/temporal/temporal-dependency-handler-it/src/it/temporal-it/src/test/java/org/apache/felix/ipojo/handler/temporal/test/TemporalTest.java (added)
+++ felix/trunk/ipojo/handler/temporal/temporal-dependency-handler-it/src/it/temporal-it/src/test/java/org/apache/felix/ipojo/handler/temporal/test/TemporalTest.java Thu Feb 28 10:27:21 2013
@@ -0,0 +1,344 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.handler.temporal.test;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.handler.temporal.services.CheckService;
+import org.apache.felix.ipojo.handler.temporal.services.FooService;
+import org.junit.Test;
+import org.osgi.framework.ServiceReference;
+
+import static org.junit.Assert.*;
+
+public class TemporalTest extends Common {
+
+    @Test
+    public void testDelay() {
+        String prov = "provider";
+        ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-CheckServiceProviderUsingTemporal", un);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        // Stop the provider.
+        provider.stop();
+        assertNull("No FooService", osgiHelper.getServiceReference(FooService.class.getName(), null));
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 2", ref_cs);
+        long begin = System.currentTimeMillis();
+        DelayedProvider dp = new DelayedProvider(provider, 200);
+        dp.start();
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+
+        assertTrue("Check invocation - 2", cs.check());
+        long end = System.currentTimeMillis();
+
+        assertTrue("Assert delay (" + (end - begin) + ")", (end - begin) >= 200);
+
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 3", ref_cs);
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation - 3", cs.check());
+
+        provider.stop();
+        provider.dispose();
+        under.stop();
+        under.dispose();
+    }
+
+    @Test
+    public void testDelayWithProxy() {
+        String prov = "provider";
+        ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-ProxiedCheckServiceProviderUsingTemporal", un);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        // Stop the provider.
+        provider.stop();
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 2", ref_cs);
+        long begin = System.currentTimeMillis();
+        DelayedProvider dp = new DelayedProvider(provider, 200);
+        dp.start();
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation - 2", cs.check());
+        long end = System.currentTimeMillis();
+
+        assertTrue("Assert delay", (end - begin) >= 200);
+
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 3", ref_cs);
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation - 3", cs.check());
+
+        provider.stop();
+        provider.dispose();
+        under.stop();
+        under.dispose();
+    }
+
+    @Test
+    public void testTimeout() {
+        String prov = "provider";
+        ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-CheckServiceProviderUsingTemporal", un);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        // Stop the provider.
+        provider.stop();
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 2", ref_cs);
+        DelayedProvider dp = new DelayedProvider(provider, 4000);
+        dp.start();
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        try {
+            cs.check();
+        } catch (RuntimeException e) {
+            // OK
+            dp.stop();
+            provider.stop();
+            provider.dispose();
+            under.stop();
+            under.dispose();
+            return;
+        }
+
+        fail("Timeout expected");
+    }
+
+    @Test
+    public void testTimeoutWithProxy() {
+        String prov = "provider";
+        ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-ProxiedCheckServiceProviderUsingTemporal", un);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        // Stop the provider.
+        provider.stop();
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 2", ref_cs);
+        DelayedProvider dp = new DelayedProvider(provider, 4000);
+        dp.start();
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        try {
+            cs.check();
+        } catch (RuntimeException e) {
+            // OK
+            dp.stop();
+            provider.stop();
+            provider.dispose();
+            under.stop();
+            under.dispose();
+            return;
+        }
+
+        fail("Timeout expected");
+    }
+
+    @Test
+    public void testDelayTimeout() {
+        String prov = "provider";
+        ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-CheckServiceProviderTimeoutUsingTemporal", un);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        // Stop the provider.
+        provider.stop();
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 2", ref_cs);
+        long begin = System.currentTimeMillis();
+        DelayedProvider dp = new DelayedProvider(provider, 200);
+        dp.start();
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation - 2", cs.check());
+        long end = System.currentTimeMillis();
+
+        assertTrue("Assert delay", (end - begin) >= 200);
+
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 3", ref_cs);
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation - 3", cs.check());
+
+        provider.stop();
+        provider.dispose();
+        under.stop();
+        under.dispose();
+    }
+
+    @Test
+    public void testDelayTimeoutWithProxy() {
+        String prov = "provider";
+        ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-ProxiedCheckServiceProviderTimeoutUsingTemporal", un);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        // Stop the provider.
+        provider.stop();
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 2", ref_cs);
+        long begin = System.currentTimeMillis();
+        DelayedProvider dp = new DelayedProvider(provider, 200);
+        dp.start();
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation - 2", cs.check());
+        long end = System.currentTimeMillis();
+
+        assertTrue("Assert delay", (end - begin) >= 200);
+
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 3", ref_cs);
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation - 3", cs.check());
+
+        provider.stop();
+        provider.dispose();
+        under.stop();
+        under.dispose();
+    }
+
+    @Test
+    public void testSetTimeout() {
+        String prov = "provider";
+        ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-CheckServiceProviderTimeoutUsingTemporal", un);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        // Stop the provider.
+        provider.stop();
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 2", ref_cs);
+        DelayedProvider dp = new DelayedProvider(provider, 400);
+        dp.start();
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        try {
+            cs.check();
+        } catch (RuntimeException e) {
+            // OK
+            dp.stop();
+            provider.stop();
+            provider.dispose();
+            under.stop();
+            under.dispose();
+            return;
+        }
+
+        fail("Timeout expected");
+    }
+
+    @Test
+    public void testSetTimeoutWithProxy() {
+        String prov = "provider";
+        ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-ProxiedCheckServiceProviderTimeoutUsingTemporal", un);
+
+        ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
+        assertNotNull("Check foo availability", ref_fs);
+
+        ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability", ref_cs);
+
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        assertTrue("Check invocation", cs.check());
+
+        // Stop the provider.
+        provider.stop();
+        ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
+        assertNotNull("Check cs availability - 2", ref_cs);
+        DelayedProvider dp = new DelayedProvider(provider, 400);
+        dp.start();
+        cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
+        try {
+            cs.check();
+        } catch (RuntimeException e) {
+            // OK
+            dp.stop();
+            provider.stop();
+            provider.dispose();
+            under.stop();
+            under.dispose();
+            return;
+        }
+
+        fail("Timeout expected");
+    }
+}

Added: felix/trunk/ipojo/handler/temporal/temporal-dependency-handler/DEPENDENCIES
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/handler/temporal/temporal-dependency-handler/DEPENDENCIES?rev=1451167&view=auto
==============================================================================
--- felix/trunk/ipojo/handler/temporal/temporal-dependency-handler/DEPENDENCIES (added)
+++ felix/trunk/ipojo/handler/temporal/temporal-dependency-handler/DEPENDENCIES Thu Feb 28 10:27:21 2013
@@ -0,0 +1,24 @@
+Apache Felix iPOJO Temporal Dependency Handler
+Copyright 2008-2011 The Apache Software Foundation
+
+This software was developed at the Apache Software Foundation
+(http://www.apache.org) and may have dependencies on other
+Apache software licensed under Apache License 2.0.
+
+I. Included Third-Party Software
+
+This product includes software developed at
+Copyright (c) 2000-2005 INRIA, France Telecom
+Licensed under BSD License.
+
+II. Used Third-Party Software
+
+This product uses software developed at
+The OSGi Alliance (http://www.osgi.org/).
+Copyright (c) OSGi Alliance (2000, 2009).
+Licensed under the Apache License 2.0.
+
+III. Overall License Summary
+- Apache License 2.0
+- BSD License
+



Mime
View raw message