felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clem...@apache.org
Subject svn commit: r1451167 [2/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/main/resources/metadata.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/handler/temporal/temporal-dependency-handler-it/src/it/temporal-it/src/main/resources/metadata.xml?rev=1451167&view=auto
==============================================================================
--- felix/trunk/ipojo/handler/temporal/temporal-dependency-handler-it/src/it/temporal-it/src/main/resources/metadata.xml (added)
+++ felix/trunk/ipojo/handler/temporal/temporal-dependency-handler-it/src/it/temporal-it/src/main/resources/metadata.xml Thu Feb 28 10:27:21 2013
@@ -0,0 +1,243 @@
+<ipojo
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xmlns="org.apache.felix.ipojo"
+	xmlns:temp="org.apache.felix.ipojo.handler.temporal">
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.CheckServiceProvider" name="TEMPORAL-CheckServiceProvider">
+		<temp:requires field="fs"/>
+		<provides/>
+	</component>
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.CheckServiceProvider" name="TEMPORAL-CheckServiceProviderUsingTemporal">
+		<temp:temporal field="fs"/>
+		<provides/>
+	</component>
+
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.proxy.HelpedCheckServiceProvider" name="TEMPORAL-ProxiedCheckServiceProvider">
+		<temp:requires field="fs" proxy="true"/>
+		<provides/>
+	</component>
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.proxy.HelpedCheckServiceProvider" name="TEMPORAL-ProxiedCheckServiceProviderUsingTemporal">
+		<temp:temporal field="fs" proxy="true"/>
+		<provides/>
+	</component>
+
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.CheckServiceProvider" name="TEMPORAL-CheckServiceProviderTimeout">
+		<temp:requires field="fs" timeout="300"/>
+		<provides/>
+	</component>
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.CheckServiceProvider" name="TEMPORAL-CheckServiceProviderTimeoutUsingTemporal">
+		<temp:temporal field="fs" timeout="300"/>
+		<provides/>
+	</component>
+
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.proxy.HelpedCheckServiceProvider" name="TEMPORAL-ProxiedCheckServiceProviderTimeout">
+		<temp:requires field="fs" proxy="true" timeout="300"/>
+		<provides/>
+	</component>
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.proxy.HelpedCheckServiceProvider" name="TEMPORAL-ProxiedCheckServiceProviderTimeoutUsingTemporal">
+		<temp:temporal field="fs" proxy="true" timeout="300"/>
+		<provides/>
+	</component>
+
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.MultipleCheckServiceProvider" name="TEMPORAL-MultipleCheckServiceProvider">
+		<temp:requires field="fs" id="foo"/>
+		<provides/>
+	</component>
+
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.CollectionCheckServiceProvider" name="TEMPORAL-ColCheckServiceProvider">
+		<temp:requires field="fs" specification="org.apache.felix.ipojo.handler.temporal.services.FooService"/>
+		<provides/>
+	</component>
+
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.proxy.HelpedCollectionCheckServiceProvider" name="TEMPORAL-ProxiedColCheckServiceProvider">
+		<temp:requires field="fs" proxy="true" specification="org.apache.felix.ipojo.handler.temporal.services.FooService"/>
+		<provides/>
+	</component>
+
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.FooProvider" name="TEMPORAL-FooProvider">
+		<provides/>
+	</component>
+
+	<!-- Dependencies using nullables -->
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.MultipleCheckServiceProvider" name="TEMPORAL-NullableMultipleCheckServiceProvider">
+		<temp:requires field="fs" onTimeout="nullable"/>
+		<provides/>
+	</component>
+
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.CollectionCheckServiceProvider" name="TEMPORAL-NullableColCheckServiceProvider">
+		<temp:requires field="fs" onTimeout="nullable" specification="org.apache.felix.ipojo.handler.temporal.services.FooService"/>
+		<provides/>
+	</component>
+
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.proxy.HelpedCollectionCheckServiceProvider" name="TEMPORAL-NullableProxiedColCheckServiceProvider">
+		<temp:requires field="fs" proxy="true" onTimeout="nullable" specification="org.apache.felix.ipojo.handler.temporal.services.FooService"/>
+		<provides/>
+	</component>
+
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.CheckServiceProvider" name="TEMPORAL-NullableCheckServiceProvider">
+		<temp:requires field="fs" onTimeout="nullable"/>
+		<provides/>
+	</component>
+
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.proxy.HelpedCheckServiceProvider" name="TEMPORAL-NullableProxiedCheckServiceProvider">
+		<temp:requires field="fs" proxy="true" onTimeout="nullable"/>
+		<provides/>
+	</component>
+
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.CheckServiceProvider" name="TEMPORAL-NullableCheckServiceProviderTimeout">
+		<temp:requires field="fs" timeout="300" onTimeout="nullable"/>
+		<provides/>
+	</component>
+
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.proxy.HelpedCheckServiceProvider" name="TEMPORAL-NullableProxiedCheckServiceProviderTimeout">
+		<temp:requires field="fs" proxy="true" onTimeout="nullable" timeout="300"/>
+		<provides/>
+	</component>
+
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.MultipleCheckServiceProvider" name="TEMPORAL-NullableMultipleCheckServiceProviderTimeout">
+		<temp:requires field="fs" timeout="300" onTimeout="nullable"/>
+		<provides/>
+	</component>
+
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.CollectionCheckServiceProvider" name="TEMPORAL-NullableColCheckServiceProviderTimeout">
+		<temp:requires field="fs" onTimeout="nullable" timeout="300" specification="org.apache.felix.ipojo.handler.temporal.services.FooService"/>
+		<provides/>
+	</component>
+
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.proxy.HelpedCollectionCheckServiceProvider" name="TEMPORAL-NullableProxiedColCheckServiceProviderTimeout">
+		<temp:requires field="fs" proxy="true" onTimeout="nullable" timeout="300" specification="org.apache.felix.ipojo.handler.temporal.services.FooService"/>
+		<provides/>
+	</component>
+
+	<!-- Dependencies using default implementation -->
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.MultipleCheckServiceProvider" name="TEMPORAL-DIMultipleCheckServiceProvider">
+		<temp:requires field="fs" onTimeout="org.apache.felix.ipojo.handler.temporal.components.NullableFooProvider"/>
+		<provides/>
+	</component>
+
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.CollectionCheckServiceProvider" name="TEMPORAL-DIColCheckServiceProvider">
+		<temp:requires field="fs" onTimeout="org.apache.felix.ipojo.handler.temporal.components.NullableFooProvider" specification="org.apache.felix.ipojo.handler.temporal.services.FooService"/>
+		<provides/>
+	</component>
+
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.proxy.HelpedCollectionCheckServiceProvider" name="TEMPORAL-DIProxiedColCheckServiceProvider">
+		<temp:requires field="fs" proxy="true" onTimeout="org.apache.felix.ipojo.handler.temporal.components.NullableFooProvider" specification="org.apache.felix.ipojo.handler.temporal.services.FooService"/>
+		<provides/>
+	</component>
+
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.CheckServiceProvider" name="TEMPORAL-DICheckServiceProvider">
+		<temp:requires field="fs" onTimeout="org.apache.felix.ipojo.handler.temporal.components.NullableFooProvider"/>
+		<provides/>
+	</component>
+
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.proxy.HelpedCheckServiceProvider" name="TEMPORAL-DIProxiedCheckServiceProvider">
+		<temp:requires field="fs" proxy="true" onTimeout="org.apache.felix.ipojo.handler.temporal.components.NullableFooProvider"/>
+		<provides/>
+	</component>
+
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.CheckServiceProvider" name="TEMPORAL-DICheckServiceProviderTimeout">
+		<temp:requires field="fs" timeout="300" onTimeout="org.apache.felix.ipojo.handler.temporal.components.NullableFooProvider"/>
+		<provides/>
+	</component>
+
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.proxy.HelpedCheckServiceProvider" name="TEMPORAL-DIProxiedCheckServiceProviderTimeout">
+		<temp:requires field="fs" proxy="true" timeout="300" onTimeout="org.apache.felix.ipojo.handler.temporal.components.NullableFooProvider"/>
+		<provides/>
+	</component>
+
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.MultipleCheckServiceProvider" name="TEMPORAL-DIMultipleCheckServiceProviderTimeout">
+		<temp:requires field="fs" timeout="300" onTimeout="org.apache.felix.ipojo.handler.temporal.components.NullableFooProvider"/>
+		<provides/>
+	</component>
+
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.CollectionCheckServiceProvider" name="TEMPORAL-DIColCheckServiceProviderTimeout">
+		<temp:requires field="fs" timeout="300" onTimeout="org.apache.felix.ipojo.handler.temporal.components.NullableFooProvider" specification="org.apache.felix.ipojo.handler.temporal.services.FooService"/>
+		<provides/>
+	</component>
+
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.proxy.HelpedCollectionCheckServiceProvider" name="TEMPORAL-DIProxiedColCheckServiceProviderTimeout">
+		<temp:requires field="fs" proxy="true" timeout="300" onTimeout="org.apache.felix.ipojo.handler.temporal.components.NullableFooProvider" specification="org.apache.felix.ipojo.handler.temporal.services.FooService"/>
+		<provides/>
+	</component>
+
+	<!-- Dependencies using null -->
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.MultipleCheckServiceProvider" name="TEMPORAL-NullMultipleCheckServiceProvider">
+		<temp:requires field="fs" onTimeout="null"/>
+		<provides/>
+	</component>
+
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.CollectionCheckServiceProvider" name="TEMPORAL-NullColCheckServiceProvider">
+		<temp:requires field="fs" onTimeout="null" specification="org.apache.felix.ipojo.handler.temporal.services.FooService"/>
+		<provides/>
+	</component>
+
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.proxy.HelpedCollectionCheckServiceProvider" name="TEMPORAL-NullProxiedColCheckServiceProvider">
+		<temp:requires field="fs" proxy="true" onTimeout="null" specification="org.apache.felix.ipojo.handler.temporal.services.FooService"/>
+		<provides/>
+	</component>
+
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.CheckServiceProvider" name="TEMPORAL-NullCheckServiceProvider">
+		<temp:requires field="fs" onTimeout="null"/>
+		<provides/>
+	</component>
+
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.proxy.HelpedCheckServiceProvider" name="TEMPORAL-NullProxiedCheckServiceProvider">
+		<temp:requires field="fs" proxy="true" onTimeout="null"/>
+		<provides/>
+	</component>
+
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.CheckServiceProvider" name="TEMPORAL-NullCheckServiceProviderTimeout">
+		<temp:requires field="fs" timeout="300" onTimeout="null"/>
+		<provides/>
+	</component>
+
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.proxy.HelpedCheckServiceProvider" name="TEMPORAL-NullProxiedCheckServiceProviderTimeout">
+		<temp:requires field="fs" proxy="true" timeout="300" onTimeout="null"/>
+		<provides/>
+	</component>
+
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.MultipleCheckServiceProvider" name="TEMPORAL-NullMultipleCheckServiceProviderTimeout">
+		<temp:requires field="fs" timeout="300" onTimeout="null"/>
+		<provides/>
+	</component>
+
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.CollectionCheckServiceProvider" name="TEMPORAL-NullColCheckServiceProviderTimeout">
+		<temp:requires field="fs" timeout="300" onTimeout="null" specification="org.apache.felix.ipojo.handler.temporal.services.FooService"/>
+		<provides/>
+	</component>
+
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.proxy.HelpedCollectionCheckServiceProvider" name="TEMPORAL-NullProxiedColCheckServiceProviderTimeout">
+		<temp:requires field="fs" proxy="true" timeout="300" onTimeout="null" specification="org.apache.felix.ipojo.handler.temporal.services.FooService"/>
+		<provides/>
+	</component>
+
+	<!-- Dependencies using empty arrays -->
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.MultipleCheckServiceProvider" name="TEMPORAL-EmptyMultipleCheckServiceProvider">
+		<temp:requires field="fs" onTimeout="empty-array"/>
+		<provides/>
+	</component>
+
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.CollectionCheckServiceProvider" name="TEMPORAL-EmptyColCheckServiceProvider">
+		<temp:requires field="fs" onTimeout="empty" specification="org.apache.felix.ipojo.handler.temporal.services.FooService"/>
+		<provides/>
+	</component>
+
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.proxy.HelpedCollectionCheckServiceProvider" name="TEMPORAL-EmptyProxiedColCheckServiceProvider">
+		<temp:requires field="fs" proxy="true" onTimeout="empty" specification="org.apache.felix.ipojo.handler.temporal.services.FooService"/>
+		<provides/>
+	</component>
+
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.MultipleCheckServiceProvider" name="TEMPORAL-EmptyMultipleCheckServiceProviderTimeout">
+		<temp:requires field="fs" timeout="300" onTimeout="empty-array"/>
+		<provides/>
+	</component>
+
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.CollectionCheckServiceProvider" name="TEMPORAL-EmptyColCheckServiceProviderTimeout">
+		<temp:requires field="fs" timeout="300" onTimeout="empty" specification="org.apache.felix.ipojo.handler.temporal.services.FooService"/>
+		<provides/>
+	</component>
+
+	<component classname="org.apache.felix.ipojo.handler.temporal.components.proxy.HelpedCollectionCheckServiceProvider" name="TEMPORAL-EmptyProxiedColCheckServiceProviderTimeout">
+		<temp:requires field="fs" timeout="300" proxy="true" onTimeout="empty" specification="org.apache.felix.ipojo.handler.temporal.services.FooService"/>
+		<provides/>
+	</component>
+</ipojo>
\ No newline at end of file

Added: felix/trunk/ipojo/handler/temporal/temporal-dependency-handler-it/src/it/temporal-it/src/test/java/org/apache/felix/ipojo/handler/temporal/test/Common.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/Common.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/Common.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/Common.java Thu Feb 28 10:27:21 2013
@@ -0,0 +1,196 @@
+package org.apache.felix.ipojo.handler.temporal.test;
+
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.Logger;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.filefilter.TrueFileFilter;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.CoreOptions;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.options.CompositeOption;
+import org.ops4j.pax.exam.options.DefaultCompositeOption;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+import org.ops4j.pax.tinybundles.core.TinyBundle;
+import org.ops4j.pax.tinybundles.core.TinyBundles;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.ow2.chameleon.testing.helpers.IPOJOHelper;
+import org.ow2.chameleon.testing.helpers.OSGiHelper;
+import org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOStrategy;
+import org.slf4j.LoggerFactory;
+
+import javax.inject.Inject;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import static junit.framework.Assert.fail;
+import static org.ops4j.pax.exam.CoreOptions.*;
+
+/**
+ * Bootstrap the test from this project
+ */
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class Common {
+
+    @Inject
+    BundleContext bc;
+
+    OSGiHelper osgiHelper;
+    IPOJOHelper ipojoHelper;
+
+    Bundle testedBundle;
+
+    @Configuration
+    public Option[] config() throws IOException {
+        Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
+        root.setLevel(Level.DEBUG);
+
+        return options(
+                cleanCaches(),
+                ipojoBundles(),
+                junitBundles(),
+                testedBundle(),
+                systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("WARN")
+        );
+    }
+
+    public static Option junitAndMockitoBundles() {
+        return new DefaultCompositeOption(
+                // Repository required to load harmcrest (OSGi-fied version).
+                repository("http://repository.springsource.com/maven/bundles/external").id(
+                        "com.springsource.repository.bundles.external"),
+
+                // Hamcrest with a version matching the range expected by Mockito
+                mavenBundle("org.hamcrest", "com.springsource.org.hamcrest.core", "1.1.0"),
+
+                // Mockito core does not includes Hamcrest
+                mavenBundle("org.mockito", "mockito-core", "1.9.5"),
+
+                // Objenesis with a version matching the range expected by Mockito
+                wrappedBundle(mavenBundle("org.objenesis", "objenesis", "1.2"))
+                        .exports("*;version=1.2"),
+
+                // The default JUnit bundle also exports Hamcrest, but with an (incorrect) version of
+                // 4.9 which does not match the Mockito import. When deployed after the hamcrest bundles, it gets
+                // resolved correctly.
+                CoreOptions.junitBundles(),
+
+                /*
+                 * Felix has implicit boot delegation enabled by default. It conflicts with Mockito:
+                 * java.lang.LinkageError: loader constraint violation in interface itable initialization:
+                 * when resolving method "org.osgi.service.useradmin.User$$EnhancerByMockitoWithCGLIB$$dd2f81dc
+                 * .newInstance(Lorg/mockito/cglib/proxy/Callback;)Ljava/lang/Object;" the class loader
+                 * (instance of org/mockito/internal/creation/jmock/SearchingClassLoader) of the current class,
+                 * org/osgi/service/useradmin/User$$EnhancerByMockitoWithCGLIB$$dd2f81dc, and the class loader
+                 * (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) for interface
+                 * org/mockito/cglib/proxy/Factory have different Class objects for the type org/mockito/cglib/
+                 * proxy/Callback used in the signature
+                 *
+                 * So we disable the bootdelegation. this property has no effect on the other OSGi implementation.
+                 */
+                frameworkProperty("felix.bootdelegation.implicit").value("false")
+        );
+    }
+
+    @Before
+    public void commonSetUp() {
+        osgiHelper = new OSGiHelper(bc);
+        ipojoHelper = new IPOJOHelper(bc);
+
+        testedBundle = osgiHelper.getBundle("test.bundle");
+
+        // Dump OSGi Framework information
+        String vendor = (String) osgiHelper.getBundle(0).getHeaders().get(Constants.BUNDLE_VENDOR);
+        if (vendor == null) {
+            vendor = (String) osgiHelper.getBundle(0).getHeaders().get(Constants.BUNDLE_SYMBOLICNAME);
+        }
+        String version = (String) osgiHelper.getBundle(0).getHeaders().get(Constants.BUNDLE_VERSION);
+        System.out.println("OSGi Framework : " + vendor + " - " + version);
+    }
+
+    @After
+    public void commonTearDown() {
+        ipojoHelper.dispose();
+        osgiHelper.dispose();
+    }
+
+    public static CompositeOption ipojoBundles() {
+        return new DefaultCompositeOption(
+                mavenBundle("org.apache.felix", "org.apache.felix.ipojo").versionAsInProject(),
+                mavenBundle("org.ow2.chameleon.testing", "osgi-helpers").versionAsInProject(),
+                // The tested handler
+                mavenBundle("org.apache.felix", "org.apache.felix.ipojo.handler.temporal").versionAsInProject()
+        );
+    }
+
+    public Option testedBundle() throws MalformedURLException {
+        File out = new File("target/tested/bundle.jar");
+
+        TinyBundle tested = TinyBundles.bundle();
+
+        // We look inside target/classes to find the class and resources
+        File classes = new File("target/classes");
+        Collection<File> files = FileUtils.listFilesAndDirs(classes, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
+        List<File> services = new ArrayList<File>();
+        for (File file : files) {
+            if (file.isDirectory()) {
+                // By convention we export of .services and .service package
+                if (file.getName().endsWith("services")  || file.getName().endsWith("service")) {
+                    services.add(file);
+                }
+            } else {
+                // We need to compute the path
+                String path = file.getAbsolutePath().substring(classes.getAbsolutePath().length() +1);
+                tested.add(path, file.toURI().toURL());
+                System.out.println(file.getName() + " added to " + path);
+            }
+        }
+
+        String export = "";
+        for (File file : services) {
+            if (export.length() > 0) { export += ", "; }
+            String path = file.getAbsolutePath().substring(classes.getAbsolutePath().length() +1);
+            String packageName = path.replace('/', '.');
+            export += packageName;
+        }
+
+        System.out.println("Exported packages : " + export);
+
+        InputStream inputStream = tested
+                .set(Constants.BUNDLE_SYMBOLICNAME, "test.bundle")
+                .set(Constants.EXPORT_PACKAGE, export)
+                .build(IPOJOStrategy.withiPOJO(new File("src/main/resources")));
+
+        try {
+            FileUtils.copyInputStreamToFile(inputStream, out);
+            return bundle(out.toURI().toURL().toExternalForm());
+        } catch (MalformedURLException e) {
+            throw new RuntimeException("Cannot compute the url of the manipulated bundle");
+        } catch (IOException e) {
+            throw new RuntimeException("Cannot write of the manipulated bundle");
+        }
+    }
+
+    public void assertContains(String s, String[] arrays, String object) {
+        for (String suspect : arrays) {
+            if (object.equals(suspect)) {
+                return;
+            }
+        }
+        fail("Assertion failed : " + s);
+    }
+
+
+}

Added: felix/trunk/ipojo/handler/temporal/temporal-dependency-handler-it/src/it/temporal-it/src/test/java/org/apache/felix/ipojo/handler/temporal/test/DefaultImplementationTest.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/DefaultImplementationTest.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/DefaultImplementationTest.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/DefaultImplementationTest.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 DefaultImplementationTest extends Common {
+
+    @Test
+    public void testDefaultImplementation() {
+        String prov = "provider";
+        ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-DICheckServiceProvider", 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 testDefaultImplementationWithProxy() {
+        String prov = "provider";
+        ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-DIProxiedCheckServiceProvider", 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 testDefaultImplementationTimeout() {
+        String prov = "provider";
+        ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-DICheckServiceProvider", 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 testDefaultImplementationTimeoutWithProxy() {
+        String prov = "provider";
+        ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-DIProxiedCheckServiceProvider", 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-DICheckServiceProviderTimeout", 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-DIProxiedCheckServiceProviderTimeout", 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 testDefaultImplementationMultipleTimeout() {
+        String prov = "provider";
+        ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-DIMultipleCheckServiceProviderTimeout", 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 testDefaultImplementationCollectionTimeout() {
+        String prov = "provider";
+        ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-DIColCheckServiceProviderTimeout", 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 testDefaultImplementationProxiedCollectionTimeout() {
+        String prov = "provider";
+        ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-DIProxiedColCheckServiceProviderTimeout", 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 DI 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 DI 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 DI 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/DelayTest.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/DelayTest.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/DelayTest.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/DelayTest.java Thu Feb 28 10:27:21 2013
@@ -0,0 +1,494 @@
+/* 
+ * 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 DelayTest 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-CheckServiceProvider", 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-ProxiedCheckServiceProvider", 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-CheckServiceProvider", 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-ProxiedCheckServiceProvider", 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-CheckServiceProviderTimeout", 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-ProxiedCheckServiceProviderTimeout", 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-CheckServiceProviderTimeout", 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-ProxiedCheckServiceProviderTimeout", 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 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-MultipleCheckServiceProvider", 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();
+
+        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();
+    }
+
+    @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-ColCheckServiceProvider", 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();
+
+        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();
+    }
+
+    @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-ProxiedColCheckServiceProvider", 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();
+
+        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/DelayedProvider.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/DelayedProvider.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/DelayedProvider.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/DelayedProvider.java Thu Feb 28 10:27:21 2013
@@ -0,0 +1,71 @@
+/* 
+ * 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;
+
+public class DelayedProvider implements Runnable {
+    
+    
+    public static final long DELAY = 1000;
+    ComponentInstance instance;
+    long delay = DELAY;
+    Thread thread;
+    
+    public DelayedProvider(ComponentInstance ci) {
+        instance =ci;
+    }
+    
+    public DelayedProvider(ComponentInstance ci, long time) {
+        instance =ci;
+        delay = time;
+    }    
+    
+    public void start() {
+        thread = new Thread(this);
+        thread.start();
+    }
+    
+    public void stop() {
+        if (thread != null) {
+            thread.interrupt();
+        }
+    }
+
+    public void run() {
+            System.out.println("Start sleeping for " + delay);
+            long begin = System.currentTimeMillis();
+            try {
+                Thread.sleep(delay);
+                long end = System.currentTimeMillis();
+                if (end - begin < delay) {
+                	// Wait for the remaining time
+                	Thread.sleep(delay - (end - begin));
+                }
+            } catch (InterruptedException e) {
+                System.out.println("Interrupted ...");
+                return;
+            }
+            System.out.println("Wakeup");
+            thread = null;
+            instance.start();
+            System.out.println(instance.getInstanceName() + " started");
+    }
+
+}

Added: felix/trunk/ipojo/handler/temporal/temporal-dependency-handler-it/src/it/temporal-it/src/test/java/org/apache/felix/ipojo/handler/temporal/test/EmptyTest.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/EmptyTest.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/EmptyTest.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/EmptyTest.java Thu Feb 28 10:27:21 2013
@@ -0,0 +1,303 @@
+/* 
+ * 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 EmptyTest extends Common {
+
+    @Test
+    public void testEmptyArrayTimeout() {
+        String prov = "provider";
+        ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-EmptyMultipleCheckServiceProviderTimeout", 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("An empty array was expected ...");
+        }
+        assertTrue("Check empty array", res);
+
+        dp.stop();
+        provider.stop();
+        provider.dispose();
+        under.stop();
+        under.dispose();
+        return;
+    }
+
+    @Test
+    public void testEmptyCollectionTimeout() {
+        String prov = "provider";
+        ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-EmptyColCheckServiceProviderTimeout", 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("An empty array was expected ...");
+        }
+        assertTrue("Check empty array", res);
+
+        dp.stop();
+        provider.stop();
+        provider.dispose();
+        under.stop();
+        under.dispose();
+        return;
+    }
+
+    @Test
+    public void testEmptyProxiedCollectionTimeout() {
+        String prov = "provider";
+        ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
+        String un = "under-1";
+        ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-EmptyProxiedColCheckServiceProviderTimeout", 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("An empty array was expected ...");
+        }
+        assertTrue("Check empty array", 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-EmptyMultipleCheckServiceProvider", 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);
+
+        assertTrue("Check invocation - 3", cs.check());
+
+        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-EmptyColCheckServiceProvider", 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);
+
+        assertTrue("Check invocation - 3", cs.check());
+
+        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-EmptyProxiedColCheckServiceProvider", 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);
+
+        assertTrue("Check invocation - 3", cs.check());
+
+        provider1.dispose();
+        provider2.dispose();
+        under.stop();
+        under.dispose();
+    }
+}

Propchange: felix/trunk/ipojo/handler/temporal/temporal-dependency-handler-it/src/it/temporal-it/src/test/java/org/apache/felix/ipojo/handler/temporal/test/EmptyTest.java
------------------------------------------------------------------------------
    svn:executable = *



Mime
View raw message