felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clem...@apache.org
Subject svn commit: r701978 [2/5] - in /felix/trunk/ipojo/tests: ./ core/configadmin/ core/configadmin/src/main/java/org/apache/felix/ipojo/test/scenarios/configadmin/ core/configadmin/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/ core/con...
Date Mon, 06 Oct 2008 07:55:43 GMT
Modified: felix/trunk/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/DelayedProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/DelayedProvider.java?rev=701978&r1=701977&r2=701978&view=diff
==============================================================================
--- felix/trunk/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/DelayedProvider.java (original)
+++ felix/trunk/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/DelayedProvider.java Mon Oct  6 00:55:39 2008
@@ -1,63 +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.test.scenarios.temporal;
-
-import org.apache.felix.ipojo.ComponentInstance;
-
-public class DelayedProvider implements Runnable {
-    
-    ComponentInstance instance;
-    long delay = 400;
-    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);
-            try {
-                Thread.sleep(delay);
-            } catch (InterruptedException e) {
-                System.out.println("Interrupted ...");
-                return;
-            }
-            System.out.println("Wakeup");
-            thread = null;
-            instance.start();
-            System.out.println(instance.getInstanceName() + " started");
-    }
-
-}
+/* 
+ * 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.test.scenarios.temporal;
+
+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");
+    }
+
+}

Modified: felix/trunk/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/EmptyArrayTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/EmptyArrayTest.java?rev=701978&r1=701977&r2=701978&view=diff
==============================================================================
--- felix/trunk/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/EmptyArrayTest.java (original)
+++ felix/trunk/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/EmptyArrayTest.java Mon Oct  6 00:55:39 2008
@@ -1,116 +1,118 @@
-/* 
- * 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.test.scenarios.temporal;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.temporal.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.temporal.service.FooService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class EmptyArrayTest extends OSGiTestCase {
-   
-   public void testEmptyArrayTimeout() {
-       String prov = "provider";
-       ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
-       String un = "under-1";
-       ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-EmptyMultipleCheckServiceProviderTimeout", un);
-       
-       ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
-       assertNotNull("Check foo availability", ref_fs);
-       
-       ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
-       assertNotNull("Check cs availability", ref_cs);
-       
-       CheckService cs = (CheckService) context.getService(ref_cs);
-       assertTrue("Check invocation", cs.check());
-       
-       // Stop the provider.
-       provider.stop();
-       ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
-       assertNotNull("Check cs availability - 2", ref_cs);
-       DelayedProvider dp = new DelayedProvider(provider, 400);
-       dp.start();
-       cs = (CheckService) context.getService(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;
-   }
-   
-   public void testDelayOnMultipleDependency() {
-       String prov = "provider";
-       ComponentInstance provider1 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
-       String prov2 = "provider2";
-       ComponentInstance provider2 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov2);
-       String un = "under-1";
-       ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-EmptyMultipleCheckServiceProvider", un);
-       
-       ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
-       assertNotNull("Check foo availability", ref_fs);
-       
-       ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
-       assertNotNull("Check cs availability", ref_cs);
-       
-       CheckService cs = (CheckService) context.getService(ref_cs);
-       assertTrue("Check invocation", cs.check());
-       
-       // Stop the providers.
-       provider1.stop();
-       provider2.stop();
-       ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
-       assertNotNull("Check cs availability - 2", ref_cs);
-       long begin = System.currentTimeMillis();
-       DelayedProvider dp = new DelayedProvider(provider1, 250);
-       DelayedProvider dp2 = new DelayedProvider(provider2, 100);
-       dp.start();
-       dp2.start();
-       cs = (CheckService) context.getService(ref_cs);
-       assertTrue("Check invocation - 2", cs.check());
-       long end = System.currentTimeMillis();
-       assertTrue("Assert delay", (end - begin) >= 100  && (end - begin) <= 250);
-       dp.stop();
-       dp2.stop();
-       
-       provider1.stop();
-       provider2.stop();
-       
-       ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
-       assertNotNull("Check cs availability - 3", ref_cs);
-       cs = (CheckService) context.getService(ref_cs);
-       
-       assertTrue("Check invocation - 3", cs.check()); 
-       
-       provider1.dispose();
-       provider2.dispose();
-       under.stop();
-       under.dispose();
-   }
-}
+/* 
+ * 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.test.scenarios.temporal;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.temporal.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.temporal.service.FooService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.ServiceReference;
+
+public class EmptyArrayTest extends OSGiTestCase {
+   
+   public void testEmptyArrayTimeout() {
+       String prov = "provider";
+       ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
+       String un = "under-1";
+       ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-EmptyMultipleCheckServiceProviderTimeout", un);
+       
+       ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
+       assertNotNull("Check foo availability", ref_fs);
+       
+       ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
+       assertNotNull("Check cs availability", ref_cs);
+       
+       CheckService cs = (CheckService) context.getService(ref_cs);
+       assertTrue("Check invocation", cs.check());
+       
+       // Stop the provider.
+       provider.stop();
+       ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
+       assertNotNull("Check cs availability - 2", ref_cs);
+       DelayedProvider dp = new DelayedProvider(provider, 400);
+       dp.start();
+       cs = (CheckService) context.getService(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;
+   }
+   
+   public void testDelayOnMultipleDependency() {
+       String prov = "provider";
+       ComponentInstance provider1 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
+       String prov2 = "provider2";
+       ComponentInstance provider2 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov2);
+       String un = "under-1";
+       ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-EmptyMultipleCheckServiceProvider", un);
+       
+       ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
+       assertNotNull("Check foo availability", ref_fs);
+       
+       ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
+       assertNotNull("Check cs availability", ref_cs);
+       
+       CheckService cs = (CheckService) context.getService(ref_cs);
+       assertTrue("Check invocation", cs.check());
+       
+       // Stop the providers.
+       provider1.stop();
+       provider2.stop();
+       ref_cs = Utils.getServiceReferenceByName(context, 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) context.getService(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 = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
+       assertNotNull("Check cs availability - 3", ref_cs);
+       cs = (CheckService) context.getService(ref_cs);
+       
+       assertTrue("Check invocation - 3", cs.check()); 
+       
+       provider1.dispose();
+       provider2.dispose();
+       under.stop();
+       under.dispose();
+   }
+}

Modified: felix/trunk/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/NullTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/NullTest.java?rev=701978&r1=701977&r2=701978&view=diff
==============================================================================
--- felix/trunk/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/NullTest.java (original)
+++ felix/trunk/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/NullTest.java Mon Oct  6 00:55:39 2008
@@ -1,229 +1,231 @@
-/* 
- * 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.test.scenarios.temporal;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.temporal.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.temporal.service.FooService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class NullTest extends OSGiTestCase {
-    
-   public void testNullable() {
-       String prov = "provider";
-       ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
-       String un = "under-1";
-       ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullCheckServiceProvider", un);
-       
-       ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
-       assertNotNull("Check foo availability", ref_fs);
-       
-       ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
-       assertNotNull("Check cs availability", ref_cs);
-       
-       CheckService cs = (CheckService) context.getService(ref_cs);
-       assertTrue("Check invocation", cs.check());
-       
-       // Stop the provider.
-       provider.stop();
-       ref_cs = Utils.getServiceReferenceByName(context, 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) context.getService(ref_cs);
-       assertTrue("Check invocation - 2", cs.check());
-       long end = System.currentTimeMillis();
-       
-       assertTrue("Assert delay", (end - begin) >= 200);
-       
-       ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
-       assertNotNull("Check cs availability - 3", ref_cs);
-       cs = (CheckService) context.getService(ref_cs);
-       assertTrue("Check invocation - 3", cs.check());
-       
-       provider.stop();
-       provider.dispose();
-       under.stop();
-       under.dispose();
-   }
-   
-   public void testNullableTimeout() {
-       String prov = "provider";
-       ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
-       String un = "under-1";
-       ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullCheckServiceProvider", un);
-       
-       ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
-       assertNotNull("Check foo availability", ref_fs);
-       
-       ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
-       assertNotNull("Check cs availability", ref_cs);
-       
-       CheckService cs = (CheckService) context.getService(ref_cs);
-       assertTrue("Check invocation", cs.check());
-       
-       // Stop the provider.
-       provider.stop();
-       ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
-       assertNotNull("Check cs availability - 2", ref_cs);
-       cs = (CheckService) context.getService(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;
-   }
-   
-   public void testDelayTimeout() {
-       String prov = "provider";
-       ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
-       String un = "under-1";
-       ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullCheckServiceProviderTimeout", un);
-       
-       ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
-       assertNotNull("Check foo availability", ref_fs);
-       
-       ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
-       assertNotNull("Check cs availability", ref_cs);
-       
-       CheckService cs = (CheckService) context.getService(ref_cs);
-       assertTrue("Check invocation", cs.check());
-       
-       // Stop the provider.
-       provider.stop();
-       ref_cs = Utils.getServiceReferenceByName(context, 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) context.getService(ref_cs);
-       assertTrue("Check invocation - 2", cs.check());
-       long end = System.currentTimeMillis();
-       
-       assertTrue("Assert delay", (end - begin) >= 200);
-       
-       ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
-       assertNotNull("Check cs availability - 3", ref_cs);
-       cs = (CheckService) context.getService(ref_cs);
-       assertTrue("Check invocation - 3", cs.check());
-       
-       provider.stop();
-       provider.dispose();
-       under.stop();
-       under.dispose();
-   }
-   
-   public void testNullableMultipleTimeout() {
-       String prov = "provider";
-       ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
-       String un = "under-1";
-       ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullMultipleCheckServiceProviderTimeout", un);
-       
-       ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
-       assertNotNull("Check foo availability", ref_fs);
-       
-       ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
-       assertNotNull("Check cs availability", ref_cs);
-       
-       CheckService cs = (CheckService) context.getService(ref_cs);
-       assertTrue("Check invocation", cs.check());
-       
-       // Stop the provider.
-       provider.stop();
-       ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
-       assertNotNull("Check cs availability - 2", ref_cs);
-       DelayedProvider dp = new DelayedProvider(provider, 400);
-       dp.start();
-       cs = (CheckService) context.getService(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;
-   }
-   
-   public void testDelayOnMultipleDependency() {
-       String prov = "provider";
-       ComponentInstance provider1 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
-       String prov2 = "provider2";
-       ComponentInstance provider2 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov2);
-       String un = "under-1";
-       ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullableMultipleCheckServiceProviderTimeout", un);
-       
-       ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
-       assertNotNull("Check foo availability", ref_fs);
-       
-       ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
-       assertNotNull("Check cs availability", ref_cs);
-       
-       CheckService cs = (CheckService) context.getService(ref_cs);
-       assertTrue("Check invocation", cs.check());
-       
-       // Stop the providers.
-       provider1.stop();
-       provider2.stop();
-       ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
-       assertNotNull("Check cs availability - 2", ref_cs);
-       long begin = System.currentTimeMillis();
-       DelayedProvider dp = new DelayedProvider(provider1, 250);
-       DelayedProvider dp2 = new DelayedProvider(provider2, 100);
-       dp.start();
-       dp2.start();
-       cs = (CheckService) context.getService(ref_cs);
-       assertTrue("Check invocation - 2", cs.check());
-       long end = System.currentTimeMillis();
-       assertTrue("Assert delay", (end - begin) >= 100  && (end - begin) <= 250);
-       dp.stop();
-       dp2.stop();
-       
-       provider1.stop();
-       provider2.stop();
-       
-       ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
-       assertNotNull("Check cs availability - 3", ref_cs);
-       cs = (CheckService) context.getService(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();
-   }
-}
+/* 
+ * 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.test.scenarios.temporal;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.temporal.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.temporal.service.FooService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.ServiceReference;
+
+public class NullTest extends OSGiTestCase {
+    
+   public void testNullable() {
+       String prov = "provider";
+       ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
+       String un = "under-1";
+       ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullCheckServiceProvider", un);
+       
+       ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
+       assertNotNull("Check foo availability", ref_fs);
+       
+       ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
+       assertNotNull("Check cs availability", ref_cs);
+       
+       CheckService cs = (CheckService) context.getService(ref_cs);
+       assertTrue("Check invocation", cs.check());
+       
+       // Stop the provider.
+       provider.stop();
+       ref_cs = Utils.getServiceReferenceByName(context, 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) context.getService(ref_cs);
+       assertTrue("Check invocation - 2", cs.check());
+       long end = System.currentTimeMillis();
+       
+       assertTrue("Assert delay", (end - begin) >= 200);
+       
+       ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
+       assertNotNull("Check cs availability - 3", ref_cs);
+       cs = (CheckService) context.getService(ref_cs);
+       assertTrue("Check invocation - 3", cs.check());
+       
+       provider.stop();
+       provider.dispose();
+       under.stop();
+       under.dispose();
+   }
+   
+   public void testNullableTimeout() {
+       String prov = "provider";
+       ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
+       String un = "under-1";
+       ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullCheckServiceProvider", un);
+       
+       ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
+       assertNotNull("Check foo availability", ref_fs);
+       
+       ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
+       assertNotNull("Check cs availability", ref_cs);
+       
+       CheckService cs = (CheckService) context.getService(ref_cs);
+       assertTrue("Check invocation", cs.check());
+       
+       // Stop the provider.
+       provider.stop();
+       ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
+       assertNotNull("Check cs availability - 2", ref_cs);
+       cs = (CheckService) context.getService(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;
+   }
+   
+   public void testDelayTimeout() {
+       String prov = "provider";
+       ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
+       String un = "under-1";
+       ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullCheckServiceProviderTimeout", un);
+       
+       ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
+       assertNotNull("Check foo availability", ref_fs);
+       
+       ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
+       assertNotNull("Check cs availability", ref_cs);
+       
+       CheckService cs = (CheckService) context.getService(ref_cs);
+       assertTrue("Check invocation", cs.check());
+       
+       // Stop the provider.
+       provider.stop();
+       ref_cs = Utils.getServiceReferenceByName(context, 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) context.getService(ref_cs);
+       assertTrue("Check invocation - 2", cs.check());
+       long end = System.currentTimeMillis();
+       
+       assertTrue("Assert delay", (end - begin) >= 200);
+       
+       ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
+       assertNotNull("Check cs availability - 3", ref_cs);
+       cs = (CheckService) context.getService(ref_cs);
+       assertTrue("Check invocation - 3", cs.check());
+       
+       provider.stop();
+       provider.dispose();
+       under.stop();
+       under.dispose();
+   }
+   
+   public void testNullableMultipleTimeout() {
+       String prov = "provider";
+       ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
+       String un = "under-1";
+       ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullMultipleCheckServiceProviderTimeout", un);
+       
+       ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
+       assertNotNull("Check foo availability", ref_fs);
+       
+       ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
+       assertNotNull("Check cs availability", ref_cs);
+       
+       CheckService cs = (CheckService) context.getService(ref_cs);
+       assertTrue("Check invocation", cs.check());
+       
+       // Stop the provider.
+       provider.stop();
+       ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
+       assertNotNull("Check cs availability - 2", ref_cs);
+       DelayedProvider dp = new DelayedProvider(provider, 400);
+       dp.start();
+       cs = (CheckService) context.getService(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;
+   }
+   
+   public void testDelayOnMultipleDependency() {
+       String prov = "provider";
+       ComponentInstance provider1 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
+       String prov2 = "provider2";
+       ComponentInstance provider2 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov2);
+       String un = "under-1";
+       ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullableMultipleCheckServiceProviderTimeout", un);
+       
+       ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
+       assertNotNull("Check foo availability", ref_fs);
+       
+       ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
+       assertNotNull("Check cs availability", ref_cs);
+       
+       CheckService cs = (CheckService) context.getService(ref_cs);
+       assertTrue("Check invocation", cs.check());
+       
+       // Stop the providers.
+       provider1.stop();
+       provider2.stop();
+       ref_cs = Utils.getServiceReferenceByName(context, 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) context.getService(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 = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
+       assertNotNull("Check cs availability - 3", ref_cs);
+       cs = (CheckService) context.getService(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();
+   }
+}

Modified: felix/trunk/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/NullableTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/NullableTest.java?rev=701978&r1=701977&r2=701978&view=diff
==============================================================================
--- felix/trunk/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/NullableTest.java (original)
+++ felix/trunk/ipojo/tests/handler/temporal/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/NullableTest.java Mon Oct  6 00:55:39 2008
@@ -1,229 +1,231 @@
-/* 
- * 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.test.scenarios.temporal;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
-import org.apache.felix.ipojo.test.scenarios.temporal.service.CheckService;
-import org.apache.felix.ipojo.test.scenarios.temporal.service.FooService;
-import org.apache.felix.ipojo.test.scenarios.util.Utils;
-import org.osgi.framework.ServiceReference;
-
-public class NullableTest extends OSGiTestCase {
-    
-   public void testNullable() {
-       String prov = "provider";
-       ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
-       String un = "under-1";
-       ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullableCheckServiceProvider", un);
-       
-       ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
-       assertNotNull("Check foo availability", ref_fs);
-       
-       ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
-       assertNotNull("Check cs availability", ref_cs);
-       
-       CheckService cs = (CheckService) context.getService(ref_cs);
-       assertTrue("Check invocation", cs.check());
-       
-       // Stop the provider.
-       provider.stop();
-       ref_cs = Utils.getServiceReferenceByName(context, 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) context.getService(ref_cs);
-       assertTrue("Check invocation - 2", cs.check());
-       long end = System.currentTimeMillis();
-      
-       assertTrue("Assert delay", (end - begin) >= 200);
-       
-       ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
-       assertNotNull("Check cs availability - 3", ref_cs);
-       cs = (CheckService) context.getService(ref_cs);
-       assertTrue("Check invocation - 3", cs.check());
-       
-       provider.stop();
-       provider.dispose();
-       under.stop();
-       under.dispose();
-   }
-   
-   public void testNullableTimeout() {
-       String prov = "provider";
-       ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
-       String un = "under-1";
-       ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullableCheckServiceProvider", un);
-       
-       ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
-       assertNotNull("Check foo availability", ref_fs);
-       
-       ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
-       assertNotNull("Check cs availability", ref_cs);
-       
-       CheckService cs = (CheckService) context.getService(ref_cs);
-       assertTrue("Check invocation", cs.check());
-       
-       // Stop the provider.
-       provider.stop();
-       ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
-       assertNotNull("Check cs availability - 2", ref_cs);
-       cs = (CheckService) context.getService(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;
-   }
-   
-   public void testDelayTimeout() {
-       String prov = "provider";
-       ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
-       String un = "under-1";
-       ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullableCheckServiceProviderTimeout", un);
-       
-       ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
-       assertNotNull("Check foo availability", ref_fs);
-       
-       ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
-       assertNotNull("Check cs availability", ref_cs);
-       
-       CheckService cs = (CheckService) context.getService(ref_cs);
-       assertTrue("Check invocation", cs.check());
-       
-       // Stop the provider.
-       provider.stop();
-       ref_cs = Utils.getServiceReferenceByName(context, 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) context.getService(ref_cs);
-       assertTrue("Check invocation - 2", cs.check());
-       long end = System.currentTimeMillis();
-       
-       assertTrue("Assert delay", (end - begin) >= 200);
-       
-       ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
-       assertNotNull("Check cs availability - 3", ref_cs);
-       cs = (CheckService) context.getService(ref_cs);
-       assertTrue("Check invocation - 3", cs.check());
-       
-       provider.stop();
-       provider.dispose();
-       under.stop();
-       under.dispose();
-   }
-   
-   public void testNullableMultipleTimeout() {
-       String prov = "provider";
-       ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
-       String un = "under-1";
-       ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullableMultipleCheckServiceProviderTimeout", un);
-       
-       ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
-       assertNotNull("Check foo availability", ref_fs);
-       
-       ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
-       assertNotNull("Check cs availability", ref_cs);
-       
-       CheckService cs = (CheckService) context.getService(ref_cs);
-       assertTrue("Check invocation", cs.check());
-       
-       // Stop the provider.
-       provider.stop();
-       ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
-       assertNotNull("Check cs availability - 2", ref_cs);
-       DelayedProvider dp = new DelayedProvider(provider, 400);
-       dp.start();
-       cs = (CheckService) context.getService(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;
-   }
-   
-   public void testDelayOnMultipleDependency() {
-       String prov = "provider";
-       ComponentInstance provider1 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
-       String prov2 = "provider2";
-       ComponentInstance provider2 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov2);
-       String un = "under-1";
-       ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullableMultipleCheckServiceProviderTimeout", un);
-       
-       ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
-       assertNotNull("Check foo availability", ref_fs);
-       
-       ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
-       assertNotNull("Check cs availability", ref_cs);
-       
-       CheckService cs = (CheckService) context.getService(ref_cs);
-       assertTrue("Check invocation", cs.check());
-       
-       // Stop the providers.
-       provider1.stop();
-       provider2.stop();
-       ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
-       assertNotNull("Check cs availability - 2", ref_cs);
-       long begin = System.currentTimeMillis();
-       DelayedProvider dp = new DelayedProvider(provider1, 250);
-       DelayedProvider dp2 = new DelayedProvider(provider2, 100);
-       dp.start();
-       dp2.start();
-       cs = (CheckService) context.getService(ref_cs);
-       assertTrue("Check invocation - 2", cs.check());
-       long end = System.currentTimeMillis();
-       assertTrue("Assert delay", (end - begin) >= 100  && (end - begin) <= 250);
-       dp.stop();
-       dp2.stop();
-       
-       provider1.stop();
-       provider2.stop();
-      
-       ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
-       assertNotNull("Check cs availability - 3", ref_cs);
-       cs = (CheckService) context.getService(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();
-   }
-}
+/* 
+ * 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.test.scenarios.temporal;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.temporal.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.temporal.service.FooService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.ServiceReference;
+
+public class NullableTest extends OSGiTestCase {
+    
+   public void testNullable() {
+       String prov = "provider";
+       ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
+       String un = "under-1";
+       ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullableCheckServiceProvider", un);
+       
+       ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
+       assertNotNull("Check foo availability", ref_fs);
+       
+       ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
+       assertNotNull("Check cs availability", ref_cs);
+       
+       CheckService cs = (CheckService) context.getService(ref_cs);
+       assertTrue("Check invocation", cs.check());
+       
+       // Stop the provider.
+       provider.stop();
+       ref_cs = Utils.getServiceReferenceByName(context, 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) context.getService(ref_cs);
+       assertTrue("Check invocation - 2", cs.check());
+       long end = System.currentTimeMillis();
+      
+       assertTrue("Assert delay", (end - begin) >= 200);
+       
+       ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
+       assertNotNull("Check cs availability - 3", ref_cs);
+       cs = (CheckService) context.getService(ref_cs);
+       assertTrue("Check invocation - 3", cs.check());
+       
+       provider.stop();
+       provider.dispose();
+       under.stop();
+       under.dispose();
+   }
+   
+   public void testNullableTimeout() {
+       String prov = "provider";
+       ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
+       String un = "under-1";
+       ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullableCheckServiceProvider", un);
+       
+       ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
+       assertNotNull("Check foo availability", ref_fs);
+       
+       ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
+       assertNotNull("Check cs availability", ref_cs);
+       
+       CheckService cs = (CheckService) context.getService(ref_cs);
+       assertTrue("Check invocation", cs.check());
+       
+       // Stop the provider.
+       provider.stop();
+       ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
+       assertNotNull("Check cs availability - 2", ref_cs);
+       cs = (CheckService) context.getService(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;
+   }
+   
+   public void testDelayTimeout() {
+       String prov = "provider";
+       ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
+       String un = "under-1";
+       ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullableCheckServiceProviderTimeout", un);
+       
+       ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
+       assertNotNull("Check foo availability", ref_fs);
+       
+       ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
+       assertNotNull("Check cs availability", ref_cs);
+       
+       CheckService cs = (CheckService) context.getService(ref_cs);
+       assertTrue("Check invocation", cs.check());
+       
+       // Stop the provider.
+       provider.stop();
+       ref_cs = Utils.getServiceReferenceByName(context, 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) context.getService(ref_cs);
+       assertTrue("Check invocation - 2", cs.check());
+       long end = System.currentTimeMillis();
+       
+       assertTrue("Assert delay", (end - begin) >= 200);
+       
+       ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
+       assertNotNull("Check cs availability - 3", ref_cs);
+       cs = (CheckService) context.getService(ref_cs);
+       assertTrue("Check invocation - 3", cs.check());
+       
+       provider.stop();
+       provider.dispose();
+       under.stop();
+       under.dispose();
+   }
+   
+   public void testNullableMultipleTimeout() {
+       String prov = "provider";
+       ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
+       String un = "under-1";
+       ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullableMultipleCheckServiceProviderTimeout", un);
+       
+       ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
+       assertNotNull("Check foo availability", ref_fs);
+       
+       ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
+       assertNotNull("Check cs availability", ref_cs);
+       
+       CheckService cs = (CheckService) context.getService(ref_cs);
+       assertTrue("Check invocation", cs.check());
+       
+       // Stop the provider.
+       provider.stop();
+       ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
+       assertNotNull("Check cs availability - 2", ref_cs);
+       DelayedProvider dp = new DelayedProvider(provider, 400);
+       dp.start();
+       cs = (CheckService) context.getService(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;
+   }
+   
+   public void testDelayOnMultipleDependency() {
+       String prov = "provider";
+       ComponentInstance provider1 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
+       String prov2 = "provider2";
+       ComponentInstance provider2 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov2);
+       String un = "under-1";
+       ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-NullableMultipleCheckServiceProviderTimeout", un);
+       
+       ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
+       assertNotNull("Check foo availability", ref_fs);
+       
+       ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
+       assertNotNull("Check cs availability", ref_cs);
+       
+       CheckService cs = (CheckService) context.getService(ref_cs);
+       assertTrue("Check invocation", cs.check());
+       
+       // Stop the providers.
+       provider1.stop();
+       provider2.stop();
+       ref_cs = Utils.getServiceReferenceByName(context, 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) context.getService(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 = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
+       assertNotNull("Check cs availability - 3", ref_cs);
+       cs = (CheckService) context.getService(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();
+   }
+}

Propchange: felix/trunk/ipojo/tests/manipulator/creation/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Oct  6 00:55:39 2008
@@ -0,0 +1,5 @@
+.classpath
+.project
+.settings
+bin
+target

Added: felix/trunk/ipojo/tests/manipulator/creation/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/manipulator/creation/pom.xml?rev=701978&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/manipulator/creation/pom.xml (added)
+++ felix/trunk/ipojo/tests/manipulator/creation/pom.xml Mon Oct  6 00:55:39 2008
@@ -0,0 +1,102 @@
+<!--
+	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.
+-->
+<project>
+	<modelVersion>4.0.0</modelVersion>
+	<packaging>bundle</packaging>
+	<name>iPOJO Creation Manipulation Test Suite</name>
+	<artifactId>tests.manipulation.creation</artifactId>
+	<groupId>ipojo.tests</groupId>
+	<version>0.9.0-SNAPSHOT</version>
+	<dependencies>
+		<dependency>
+			<groupId>org.apache.felix</groupId>
+			<artifactId>org.apache.felix.ipojo</artifactId>
+			<version>0.9.0-SNAPSHOT</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.felix</groupId>
+			<artifactId>org.apache.felix.ipojo.metadata</artifactId>
+			<version>0.9.0-SNAPSHOT</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.felix</groupId>
+			<artifactId>org.osgi.core</artifactId>
+			<version>1.0.0</version>
+		</dependency>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>3.8.1</version>
+		</dependency>
+		<dependency>
+			<groupId>ipojo.examples</groupId>
+			<artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>
+			<version>0.9.0-SNAPSHOT</version>
+		</dependency>
+	</dependencies>
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.felix</groupId>
+				<artifactId>maven-bundle-plugin</artifactId>
+				<version>1.4.2</version>
+				<extensions>true</extensions>
+				<configuration>
+					<instructions>
+						<Export-Package>
+							org.apache.felix.ipojo.test.scenarios.manipulation.service
+						</Export-Package>
+						<Bundle-SymbolicName>
+							${pom.artifactId}
+						</Bundle-SymbolicName>
+						<Private-Package>
+							org.apache.felix.ipojo.test*
+						</Private-Package>
+						<Test-Suite>
+							org.apache.felix.ipojo.test.scenarios.manipulation.ManipulationTestSuite
+						</Test-Suite>
+					</instructions>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.felix</groupId>
+				<artifactId>maven-ipojo-plugin</artifactId>
+				<version>0.9.0-SNAPSHOT</version>
+				<executions>
+					<execution>
+						<goals>
+							<goal>ipojo-bundle</goal>
+						</goals>
+						<configuration>
+							<ignoreAnnotations>true</ignoreAnnotations>
+						</configuration>
+					</execution>
+				</executions>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<configuration>
+					<source>1.4</source>
+					<target>1.4</target>
+				</configuration>
+			</plugin>
+		</plugins>
+	</build>
+</project>

Added: felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CallSuperConstructor.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CallSuperConstructor.java?rev=701978&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CallSuperConstructor.java (added)
+++ felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CallSuperConstructor.java Mon Oct  6 00:55:39 2008
@@ -0,0 +1,10 @@
+package org.apache.felix.ipojo.test.scenarios.component;
+
+public class CallSuperConstructor extends ParentClass {
+    
+    public CallSuperConstructor() {
+        super("test");
+        System.out.println("plop");
+    } 
+
+}

Added: felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java?rev=701978&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java (added)
+++ felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java Mon Oct  6 00:55:39 2008
@@ -0,0 +1,117 @@
+/* 
+ * 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.test.scenarios.component;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.test.scenarios.manipulation.service.FooService;
+import org.osgi.framework.BundleContext;
+
+public class FooProviderType1 implements FooService {
+	
+	private int m_bar;
+	private String m_foo;
+    
+    private BundleContext m_context;
+    
+    private static FooProviderType1 singleton;
+    private static int count = 0;
+    
+    private static FooProviderType1 singleton(BundleContext bc) {
+        if (singleton == null) {
+            count++;
+            singleton = new FooProviderType1(bc);
+        }
+        return singleton;
+    }
+    
+    public static FooProviderType1 several(BundleContext bc) {
+        count++;
+        return new FooProviderType1(bc);
+    }
+        
+    public FooProviderType1(BundleContext bc) {
+        if (bc ==null) {
+            throw new RuntimeException("Injected bundle context null");
+        }
+            m_context = bc;
+    }
+
+	public boolean foo() {
+		return true;
+	}
+
+	public Properties fooProps() {
+		Properties p = new Properties();
+		p.put("bar", new Integer(m_bar));
+        if(m_foo != null) {
+            p.put("foo", m_foo);
+        }
+        p.put("context", m_context);
+        
+        p.put("count", new Integer(count));
+		return p;
+	}
+    
+	public void testException() throws Exception {
+        String a = "foobarbaz";
+	    throw new Exception("foo"+a);
+    }
+    
+    public void testTry() {
+            String a = "foo";
+            a.charAt(0);
+    }
+    
+    public void testTry2(String s) {
+            String a = "foo";
+            a.charAt(0);
+    }
+    
+    private void nexttry(String  s) {
+        try {
+            s += "foo";
+        } catch(RuntimeException e) {
+            
+        }
+    }
+    
+	public boolean getBoolean() { return true; }
+
+	public double getDouble() { return 1.0; }
+
+	public int getInt() { return 1; }
+
+	public long getLong() { return 1; }
+
+	public Boolean getObject() { return new Boolean(true); }
+	
+	/**
+	 * Custom constructor.
+	 * @param bar
+	 * @param foo
+	 * @param bc
+	 */
+	public FooProviderType1(int bar, String foo, BundleContext bc) {
+	    m_bar = bar;
+	    m_foo = foo;
+	    m_context = bc;
+	}
+
+}

Added: felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClass.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClass.java?rev=701978&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClass.java (added)
+++ felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClass.java Mon Oct  6 00:55:39 2008
@@ -0,0 +1,11 @@
+package org.apache.felix.ipojo.test.scenarios.component;
+
+public class ParentClass {
+    
+    private String name;
+
+    public ParentClass(final String n) {
+        name = n;
+    } 
+
+}

Added: felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java?rev=701978&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java (added)
+++ felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java Mon Oct  6 00:55:39 2008
@@ -0,0 +1,34 @@
+/* 
+ * 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.test.scenarios.manipulation;
+
+import junit.framework.Test;
+
+import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
+import org.osgi.framework.BundleContext;
+
+public class ManipulationTestSuite {
+
+	public static Test suite(BundleContext bc) {
+		OSGiTestSuite ots = new OSGiTestSuite("Manipulation Creation Test Suite", bc);
+        ots.addTestSuite(POJOCreation.class);
+		return ots;
+	}
+
+}

Added: felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/POJOCreation.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/POJOCreation.java?rev=701978&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/POJOCreation.java (added)
+++ felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/POJOCreation.java Mon Oct  6 00:55:39 2008
@@ -0,0 +1,308 @@
+/* 
+ * 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.test.scenarios.manipulation;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.Factory;
+import org.apache.felix.ipojo.architecture.Architecture;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.component.FooProviderType1;
+import org.apache.felix.ipojo.test.scenarios.manipulation.service.FooService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * Check the different method to create POJO object.
+ */
+public class POJOCreation extends OSGiTestCase {
+	
+	private ComponentInstance ci_lazzy;
+	private ComponentInstance ci_immediate;
+	private ComponentInstance ci_immediate_singleton;
+	
+	private Architecture lazzyArch;
+	private Architecture immeArch;
+	private Architecture immeArchSing;
+	
+	private ServiceReference lazzyRef;
+	private ServiceReference immRef;
+	private ServiceReference immRefSing;
+    private ComponentInstance ci_lazzy_sing;
+    private ComponentInstance ci_lazzy_sev;
+    private ServiceReference lazzyRefSing;
+    private ServiceReference lazzyRefSev;
+    private Architecture lazzyArchSing;
+    private Architecture lazzyArchSev;
+    private ComponentInstance ci_lazzy_singM;
+    private ComponentInstance ci_lazzy_sevM;
+    private ServiceReference lazzyRefSingM;
+    private ServiceReference lazzyRefSevM;
+    private Architecture lazzyArchSingM;
+    private Architecture lazzyArchSevM;
+	
+	public void setUp() {
+		String factName = "ManipulationCreation-FooProviderType-1";
+		String compName = "FooProvider-1";
+		Properties p = new Properties();
+		p.put("instance.name",compName);
+		ci_lazzy = Utils.getComponentInstance(context, factName ,p);
+		
+		String factName2 = "ManipulationCreation-ImmediateFooProviderType";
+		String compName2 = "FooProvider-2";
+		Properties p2 = new Properties();
+		p2.put("instance.name",compName2);
+		ci_immediate = Utils.getComponentInstance(context, factName2, p2);
+		
+		String factName3 = "ManipulationCreation-ImmediateFooProviderTypeSingleton";
+        String compName3 = "FooProvider-3";
+        Properties p3 = new Properties();
+        p3.put("instance.name",compName3);
+        ci_immediate_singleton = Utils.getComponentInstance(context, factName3, p3);
+        
+        String factName4 = "ManipulationCreation-FooProviderType-1-Sing";
+        String compName4 = "FooProvider-1-Sing";
+        Properties p4 = new Properties();
+        p4.put("instance.name",compName4);
+        ci_lazzy_sing = Utils.getComponentInstance(context, factName4 ,p4);
+        
+        String factName5 = "ManipulationCreation-FooProviderType-1-Sev";
+        String compName5 = "FooProvider-1-Sev";
+        Properties p5 = new Properties();
+        p5.put("instance.name",compName5);
+        ci_lazzy_sev = Utils.getComponentInstance(context, factName5 ,p5);
+        
+        String factName6 = "ManipulationCreation-FooProviderType-1-SingM";
+        String compName6 = "FooProvider-1-SingM";
+        Properties p6 = new Properties();
+        p6.put("instance.name",compName6);
+        ci_lazzy_singM = Utils.getComponentInstance(context, factName6 ,p6);
+        
+        String factName7 = "ManipulationCreation-FooProviderType-1-SevM";
+        String compName7 = "FooProvider-1-SevM";
+        Properties p7 = new Properties();
+        p7.put("instance.name",compName7);
+        ci_lazzy_sevM = Utils.getComponentInstance(context, factName7 ,p7);
+		
+		lazzyRef = Utils.getServiceReference(context, Architecture.class.getName(), "(architecture.instance="+compName+")");
+		immRef =   Utils.getServiceReference(context, Architecture.class.getName(), "(architecture.instance="+compName2+")");
+		immRefSing = Utils.getServiceReference(context, Architecture.class.getName(), "(architecture.instance="+compName3+")");
+		lazzyRefSing = Utils.getServiceReference(context, Architecture.class.getName(), "(architecture.instance="+compName4+")");
+		lazzyRefSev = Utils.getServiceReference(context, Architecture.class.getName(), "(architecture.instance="+compName5+")");
+		lazzyRefSingM = Utils.getServiceReference(context, Architecture.class.getName(), "(architecture.instance="+compName6+")");
+		lazzyRefSevM = Utils.getServiceReference(context, Architecture.class.getName(), "(architecture.instance="+compName7+")");
+		
+		lazzyArch = (Architecture) context.getService(lazzyRef);
+		immeArch = (Architecture) context.getService(immRef);
+		immeArchSing = (Architecture) context.getService(immRefSing);
+		lazzyArchSing = (Architecture) context.getService(lazzyRefSing);
+		lazzyArchSev = (Architecture) context.getService(lazzyRefSev);
+	    lazzyArchSingM = (Architecture) context.getService(lazzyRefSingM);
+	    lazzyArchSevM = (Architecture) context.getService(lazzyRefSevM);
+	}
+	
+	public void tearDown() {
+		context.ungetService(lazzyRef);
+		context.ungetService(immRef);
+		context.ungetService(immRefSing);
+		context.ungetService(lazzyRefSing);
+		context.ungetService(lazzyRefSev);
+		context.ungetService(lazzyRefSingM);
+        context.ungetService(lazzyRefSevM);
+		lazzyArch = null;
+		immeArch = null;
+		immeArchSing = null;
+		lazzyArchSing = null;
+		lazzyArchSev = null;
+		lazzyArchSingM = null;
+        lazzyArchSevM = null;
+		ci_lazzy.dispose();
+		ci_immediate.dispose();
+		ci_immediate_singleton.dispose();
+		ci_lazzy_sing.dispose();
+		ci_lazzy_sev.dispose();
+		ci_lazzy_singM.dispose();
+        ci_lazzy_sevM.dispose();
+	}
+	
+	/**
+	 * Check lazy creation.
+	 */
+	public void testLazyCreation() {
+		assertEquals("Check that no objects are created ", 0, lazzyArch.getInstanceDescription().getCreatedObjects().length);
+		ServiceReference[] refs = null;
+		try {
+			refs = context.getServiceReferences(FooService.class.getName(), "(instance.name="+ci_lazzy.getInstanceName()+")");
+		} catch (InvalidSyntaxException e) { e.printStackTrace(); }
+		assertNotNull("Check that a FooService from " + ci_lazzy.getInstanceName() + " is available",refs);
+		FooService fs = (FooService) context.getService(refs[0]);
+		assertTrue("Check the FooService invocation", fs.foo());
+		assertEquals("Check the creation of 1 object",1, lazzyArch.getInstanceDescription().getCreatedObjects().length);
+		context.ungetService(refs[0]);
+	}
+	
+	/**
+	 * Check lazy and singleton creation.
+	 */
+	public void testLazyCreationSingleton() {
+        assertEquals("Check that no objects are created ", 0, lazzyArchSing.getInstanceDescription().getCreatedObjects().length);
+        ServiceReference[] refs = null;
+        try {
+            refs = context.getServiceReferences(FooService.class.getName(), "(instance.name="+ci_lazzy_sing.getInstanceName()+")");
+        } catch (InvalidSyntaxException e) { e.printStackTrace(); }
+        assertNotNull("Check that a FooService from " + ci_lazzy_sing.getInstanceName() + " is available",refs);
+        FooService fs = (FooService) context.getService(refs[0]);
+        assertTrue("Check the FooService invocation", fs.foo());
+        assertEquals("Check the creation of 1 object",1, lazzyArchSing.getInstanceDescription().getCreatedObjects().length);
+        context.ungetService(refs[0]);
+    }
+	
+	/**
+	 * Check lazy and "several" creation.
+	 */
+	public void testLazyCreationSeveral() {
+        assertEquals("Check that no objects are created ", 0, lazzyArchSev.getInstanceDescription().getCreatedObjects().length);
+        ServiceReference[] refs = null;
+        try {
+            refs = context.getServiceReferences(FooService.class.getName(), "(instance.name="+ci_lazzy_sev.getInstanceName()+")");
+        } catch (InvalidSyntaxException e) { e.printStackTrace(); }
+        assertNotNull("Check that a FooService from " + ci_lazzy_sev.getInstanceName() + " is available",refs);
+        FooService fs = (FooService) context.getService(refs[0]);
+        FooService fs2 = (FooService) context.getService(refs[0]);
+        assertTrue("Check the FooService invocation", fs.foo());
+        assertTrue("Check the FooService invocation-2", fs2.foo());
+        assertEquals("Check the creation of 1 object",1, lazzyArchSev.getInstanceDescription().getCreatedObjects().length);
+        context.ungetService(refs[0]);
+    }
+	
+	/**
+	 * Check immediate creation.
+	 */
+	public void testImmediateCreation() {
+		assertEquals("Check that one object is created ", 1, immeArch.getInstanceDescription().getCreatedObjects().length);
+		ServiceReference[] refs = null;
+		try {
+			refs = context.getServiceReferences(FooService.class.getName(), "(instance.name="+ci_immediate.getInstanceName()+")");
+		} catch (InvalidSyntaxException e) { e.printStackTrace(); }
+		assertNotNull("Check that a FooService from " + ci_immediate.getInstanceName() + " is available",refs);
+		FooService fs = (FooService) context.getService(refs[0]);
+		assertTrue("Check the FooService invocation", fs.foo());
+		assertEquals("Check the creation of 1 object", 1, immeArch.getInstanceDescription().getCreatedObjects().length);
+		context.ungetService(refs[0]);
+	}
+    
+    /**
+     * Check bundle context injection.
+     */
+    public void testBundleContext() {
+        ServiceReference[] refs = null;
+        try {
+            refs = context.getServiceReferences(FooService.class.getName(), "(instance.name="+ci_lazzy.getInstanceName()+")");
+        } catch (InvalidSyntaxException e) { e.printStackTrace(); }
+        assertNotNull("Check that a FooService from " + ci_lazzy.getInstanceName() + " is available",refs);
+        FooService fs = (FooService) context.getService(refs[0]);
+        Properties p = fs.fooProps();
+        assertNotNull("Check the bundle context", p.get("context"));
+        assertEquals("Check the creation of 1 object",1, lazzyArch.getInstanceDescription().getCreatedObjects().length);
+        context.ungetService(refs[0]);
+    }
+
+    /**
+     * Test immediate singleton creation.
+     */
+    public void testImmediateSingletonCreation() {
+    	assertEquals("Check that one object is created ", 1, immeArchSing.getInstanceDescription().getCreatedObjects().length);
+    	ServiceReference[] refs = null;
+    	try {
+    		refs = context.getServiceReferences(FooService.class.getName(), "(instance.name="+ci_immediate_singleton.getInstanceName()+")");
+    	} catch (InvalidSyntaxException e) { e.printStackTrace(); }
+    	assertNotNull("Check that a FooService from " + ci_immediate_singleton.getInstanceName() + " is available",refs);
+    	FooService fs = (FooService) context.getService(refs[0]);
+    	assertTrue("Check the FooService invocation", fs.foo());
+    	assertEquals("Check the creation of 1 object", 1, immeArchSing.getInstanceDescription().getCreatedObjects().length);
+    	context.ungetService(refs[0]);
+    }
+
+    /**
+     * Check creation through a factory method.
+     * (lazy & singleton creation)
+     */
+    public void testLazyCreationSingletonM() {
+        assertEquals("Check that no objects are created ", 0, lazzyArchSingM.getInstanceDescription().getCreatedObjects().length);
+        ServiceReference[] refs = null;
+        try {
+            refs = context.getServiceReferences(FooService.class.getName(), "(instance.name="+ci_lazzy_singM.getInstanceName()+")");
+        } catch (InvalidSyntaxException e) { e.printStackTrace(); }
+        assertNotNull("Check that a FooService from " + ci_lazzy_singM.getInstanceName() + " is available",refs);
+        FooService fs = (FooService) context.getService(refs[0]);
+        FooService fs2 = (FooService) context.getService(refs[0]);
+        assertTrue("Check the FooService invocation", fs.foo());
+        assertTrue("Check the FooService invocation", fs2.foo());
+        assertEquals("Check the creation of 1 object",1, lazzyArchSingM.getInstanceDescription().getCreatedObjects().length);
+        context.ungetService(refs[0]);
+    }
+
+    /**
+     * Check creation through a factory method.
+     * (lazy & several creation)
+     */
+    public void testLazyCreationSeveralM() {
+        assertEquals("Check that no objects are created ", 0, lazzyArchSevM.getInstanceDescription().getCreatedObjects().length);
+        ServiceReference[] refs = null;
+        try {
+            refs = context.getServiceReferences(FooService.class.getName(), "(instance.name="+ci_lazzy_sevM.getInstanceName()+")");
+        } catch (InvalidSyntaxException e) { e.printStackTrace(); }
+        assertNotNull("Check that a FooService from " + ci_lazzy_sevM.getInstanceName() + " is available",refs);
+        FooService fs = (FooService) context.getService(refs[0]);
+        assertTrue("Check the FooService invocation", fs.foo());
+        assertEquals("Check the creation of 1 object",1, lazzyArchSevM.getInstanceDescription().getCreatedObjects().length);
+        FooService fs2 = (FooService) context.getService(refs[0]);
+        assertTrue("Check the FooService invocation-2", fs2.foo());
+        // Only one object as the getService method is called only once (service factory) despite the policy="method".
+        assertEquals("Check the creation of 1 object",1, lazzyArchSevM.getInstanceDescription().getCreatedObjects().length);
+        context.ungetService(refs[0]);
+    }
+    
+    /**
+     * Test a custom constructor.
+     * Not manipulated.
+     */
+    public void testCustomConstuctor() {
+        FooService fs = new FooProviderType1(0, "foo", context);
+        Properties props = fs.fooProps();
+        assertEquals("Check bar", 0, ((Integer) props.get("bar")).intValue());
+        assertEquals("Check foo", "foo", props.get("foo"));
+        assertEquals("Check context", context, props.get("context"));
+    }
+    
+    public void testSuperCall() {
+        try {
+            Factory fact = Utils.getFactoryByName(context, "org.apache.felix.ipojo.test.scenarios.component.CallSuperConstructor");
+            ComponentInstance ci = fact.createComponentInstance(null);
+            ci.dispose();
+        } catch (Throwable e) {
+            fail(e.getMessage());
+        }
+    }
+    
+    
+
+}
\ No newline at end of file

Added: felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/A123/CheckService2.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/A123/CheckService2.java?rev=701978&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/A123/CheckService2.java (added)
+++ felix/trunk/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/A123/CheckService2.java Mon Oct  6 00:55:39 2008
@@ -0,0 +1,25 @@
+/* 
+ * 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.test.scenarios.manipulation.service.A123;
+
+public interface CheckService2 {
+	
+	public boolean check();
+
+}



Mime
View raw message