felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clem...@apache.org
Subject svn commit: r602115 [1/2] - in /felix/sandbox/clement/Tests/Suite: ./ src/main/java/org/apache/felix/ipojo/test/log/ src/main/java/org/apache/felix/ipojo/test/scenarios/component/ src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/ src/m...
Date Fri, 07 Dec 2007 15:00:35 GMT
Author: clement
Date: Fri Dec  7 07:00:34 2007
New Revision: 602115

URL: http://svn.apache.org/viewvc?rev=602115&view=rev
Log:
Commit the test suite integrating tests on default-implementation.

Added:
    felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/log/DefaultLogImpl.java
    felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooServiceDefaultImpl.java
    felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/dependency/di/
    felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/dependency/di/DefaultImplementationTestSuite.java
    felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/dependency/di/DelayedOptionalDependencies.java
    felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/dependency/di/MethodDelayedOptionalDependencies.java
    felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/dependency/di/MethodOptionalDependencies.java
    felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/dependency/di/OptionalDependencies.java
Modified:
    felix/sandbox/clement/Tests/Suite/pom.xml
    felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/TestMethodProperties.java
    felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/dependency/DependencyTestSuite.java
    felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/dependency/OptionalDependencies.java
    felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/service/Tota.java
    felix/sandbox/clement/Tests/Suite/src/main/resources/metadata.xml

Modified: felix/sandbox/clement/Tests/Suite/pom.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/Tests/Suite/pom.xml?rev=602115&r1=602114&r2=602115&view=diff
==============================================================================
--- felix/sandbox/clement/Tests/Suite/pom.xml (original)
+++ felix/sandbox/clement/Tests/Suite/pom.xml Fri Dec  7 07:00:34 2007
@@ -45,11 +45,15 @@
       <plugin>
 	      <groupId>org.apache.felix</groupId>
 	      <artifactId>maven-ipojo-plugin</artifactId>
+	      <version>0.7.5-SNAPSHOT</version>
 		  <executions>
           	<execution>
             	<goals>
 	              <goal>ipojo-bundle</goal>
                </goals>
+                <configuration>
+   					<ignoreAnnotations>true</ignoreAnnotations>
+            	</configuration>
           </execution>
         </executions>
       </plugin>

Added: felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/log/DefaultLogImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/log/DefaultLogImpl.java?rev=602115&view=auto
==============================================================================
--- felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/log/DefaultLogImpl.java (added)
+++ felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/log/DefaultLogImpl.java Fri Dec  7 07:00:34 2007
@@ -0,0 +1,47 @@
+package org.apache.felix.ipojo.test.log;
+
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.log.LogService;
+
+public class DefaultLogImpl implements LogService {
+    
+
+    public void log(int arg0, String arg1) {
+        dispatch(arg0, arg1);
+    }
+
+    public void log(int arg0, String arg1, Throwable arg2) {
+        dispatch(arg0, arg1 + " (" + arg2.getMessage() + ")");
+    }
+
+    public void log(ServiceReference arg0, int arg1, String arg2) {
+        dispatch(arg1, arg2 + " (" + arg0.toString() + ")");
+    }
+
+    public void log(ServiceReference arg0, int arg1, String arg2, Throwable arg3) {
+        dispatch(arg1, arg2 + " (" + arg0.toString() + ")" + " (" + arg3.getMessage() + ")");
+    }
+    
+    
+    private void dispatch(int level, String message) {
+        switch (level) {
+            case LogService.LOG_DEBUG:
+                System.out.println("[DEBUG] " + message);
+                break;
+            case LogService.LOG_INFO:
+                System.out.println("[INFO] " + message);
+                break;
+            case LogService.LOG_WARNING:
+                System.out.println("[WARNING] " + message);
+                break; 
+            case LogService.LOG_ERROR:
+                System.out.println("[ERROR] " + message);
+                break;
+            default:
+                System.out.println("[" + level + "] " + message);
+                break;
+        }
+    }
+
+
+}

Added: felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooServiceDefaultImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooServiceDefaultImpl.java?rev=602115&view=auto
==============================================================================
--- felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooServiceDefaultImpl.java (added)
+++ felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooServiceDefaultImpl.java Fri Dec  7 07:00:34 2007
@@ -0,0 +1,37 @@
+package org.apache.felix.ipojo.test.scenarios.component;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.test.scenarios.service.FooService;
+
+public class FooServiceDefaultImpl implements FooService {
+
+    public boolean foo() {
+        return false;
+    }
+
+    public Properties fooProps() {
+        return null;
+    }
+
+    public boolean getBoolean() {
+        return false;
+    }
+
+    public double getDouble() {
+        return 5;
+    }
+
+    public int getInt() {
+        return 5;
+    }
+
+    public long getLong() {
+        return 5;
+    }
+
+    public Boolean getObject() {
+        return null;
+    }
+
+}

Modified: felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/TestMethodProperties.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/TestMethodProperties.java?rev=602115&r1=602114&r2=602115&view=diff
==============================================================================
--- felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/TestMethodProperties.java (original)
+++ felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/TestMethodProperties.java Fri Dec  7 07:00:34 2007
@@ -14,6 +14,8 @@
 public class TestMethodProperties extends TestCase {
     
     ComponentInstance instance;
+    
+    ComponentInstance instance2;
 
     public TestMethodProperties(BundleContext arg0) {
         super(arg0);
@@ -48,12 +50,42 @@
            fail("Cannot create the under-test instance : " + e.getMessage());
         }
         
+        Properties props2 = new Properties();
+        props2.put("name", "under-test-2");
+        props2.put("b", new Byte("1"));
+        props2.put("s", new Short("1"));
+        props2.put("i", new Integer("1"));
+        props2.put("l", new Long("1"));
+        props2.put("d", new Double("1"));
+        props2.put("f", new Float("1"));
+        props2.put("c", new Character('a'));
+        props2.put("bool", new Boolean(true));
+        props2.put("bs", new byte[] {1,2,3});
+        props2.put("ss", new short[] {1,2,3});
+        props2.put("is", new int[] {1,2,3});
+        props2.put("ls", new long[] {1,2,3});
+        props2.put("ds", new double[] {1,2,3});
+        props2.put("fs", new float[] {1,2,3});
+        props2.put("cs", new char[] {'a','b','c'});
+        props2.put("bools", new boolean[] {true,true,true});
+        props2.put("string", "foo");
+        props2.put("strings", new String[] {"foo", "bar", "baz"});
+        
+        try {
+            instance2 = fact.createComponentInstance(props2);
+        } catch(Exception e) {
+           e.printStackTrace();
+           fail("Cannot create the under-test instance 2 : " + e.getMessage());
+        }
+        
         
     }
     
     public void tearDown() {
         instance.dispose();
+        instance2.dispose();
         instance = null;
+        instance2 = null;
     }
     
     public void testConfigurationPrimitive() {
@@ -98,7 +130,7 @@
         assertEquals("Check upc", upc, new Integer(1));
         assertEquals("Check upbool", upbool, new Integer(1));
         
-        reconfigure();
+        reconfigure(instance);
         
         ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
         assertNotNull("Test check service availability", ref);
@@ -201,7 +233,7 @@
         assertEquals("Check upc", upc, new Integer(1));
         assertEquals("Check upbool", upbool, new Integer(1));
         
-        reconfigure();
+        reconfigure(instance);
         
         ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
         assertNotNull("Test check service availability", ref);
@@ -282,7 +314,7 @@
         assertEquals("Check upString", upString, new Integer(1));
         assertEquals("Check upStrings", upStrings, new Integer(1));
         
-        reconfigure();
+        reconfigure(instance);
         
         ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
         assertNotNull("Test check service availability", ref);
@@ -304,7 +336,255 @@
         assertEquals("2) Check upStrings", upStrings, new Integer(2));
     }
     
-    private void reconfigure() {
+    public void testConfigurationPrimitive2() {
+        ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance2.getInstanceName());
+        assertNotNull("Test check service availability", ref);
+        CheckService check = (CheckService) context.getService(ref);
+        Properties props = check.getProps();
+        
+        Byte b = (Byte) props.get("b");
+        Short s = (Short) props.get("s");
+        Integer i = (Integer) props.get("i");
+        Long l = (Long) props.get("l");
+        Double d = (Double) props.get("d");
+        Float f = (Float) props.get("f");
+        Character c = (Character) props.get("c");
+        Boolean bool = (Boolean) props.get("bool");
+                
+        assertEquals("Check b", b, new Byte("1"));
+        assertEquals("Check s", s, new Short("1"));
+        assertEquals("Check i", i, new Integer("1"));
+        assertEquals("Check l", l, new Long("1"));
+        assertEquals("Check d", d, new Double("1"));
+        assertEquals("Check f", f, new Float("1"));
+        assertEquals("Check c", c, new Character('a'));
+        assertEquals("Check bool", bool, new Boolean("true"));
+        
+        Integer upb = (Integer) props.get("upb");
+        Integer ups = (Integer) props.get("ups");
+        Integer upi = (Integer) props.get("upi");
+        Integer upl = (Integer) props.get("upl");
+        Integer upd = (Integer) props.get("upd");
+        Integer upf = (Integer) props.get("upf");
+        Integer upc = (Integer) props.get("upc");
+        Integer upbool = (Integer) props.get("upbool");
+        
+        assertEquals("Check upb", upb, new Integer(1));
+        assertEquals("Check ups", ups, new Integer(1));
+        assertEquals("Check upi", upi, new Integer(1));
+        assertEquals("Check upl", upl, new Integer(1));
+        assertEquals("Check upd", upd, new Integer(1));
+        assertEquals("Check upf", upf, new Integer(1));
+        assertEquals("Check upc", upc, new Integer(1));
+        assertEquals("Check upbool", upbool, new Integer(1));
+        
+        reconfigure(instance2);
+        
+        ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance2.getInstanceName());
+        assertNotNull("Test check service availability", ref);
+        check = (CheckService) context.getService(ref);
+        props = check.getProps();
+        
+        b = (Byte) props.get("b");
+        s = (Short) props.get("s");
+        i = (Integer) props.get("i");
+        l = (Long) props.get("l");
+        d = (Double) props.get("d");
+        f = (Float) props.get("f");
+        c = (Character) props.get("c");
+        bool = (Boolean) props.get("bool");
+        
+        assertEquals("2) Check b ("+b+")", b, new Byte("2"));
+        assertEquals("2) Check s", s, new Short("2"));
+        assertEquals("2) Check i", i, new Integer("2"));
+        assertEquals("2) Check l", l, new Long("2"));
+        assertEquals("2) Check d", d, new Double("2"));
+        assertEquals("2) Check f", f, new Float("2"));
+        assertEquals("2) Check c", c, new Character('b'));
+        assertEquals("2) Check bool", bool, new Boolean("false"));
+        
+        upb = (Integer) props.get("upb");
+        ups = (Integer) props.get("ups");
+        upi = (Integer) props.get("upi");
+        upl = (Integer) props.get("upl");
+        upd = (Integer) props.get("upd");
+        upf = (Integer) props.get("upf");
+        upc = (Integer) props.get("upc");
+        upbool = (Integer) props.get("upbool");
+        
+        assertEquals("2) Check upb", upb, new Integer(2));
+        assertEquals("2) Check ups", ups, new Integer(2));
+        assertEquals("2) Check upi", upi, new Integer(2));
+        assertEquals("2) Check upl", upl, new Integer(2));
+        assertEquals("2) Check upd", upd, new Integer(2));
+        assertEquals("2) Check upf", upf, new Integer(2));
+        assertEquals("2) Check upc", upc, new Integer(2));
+        assertEquals("2) Check upbool", upbool, new Integer(2));
+        
+    }
+    
+    public void testConfigurationPrimitiveArrays2() {
+        ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance2.getInstanceName());
+        assertNotNull("Test check service availability", ref);
+        CheckService check = (CheckService) context.getService(ref);
+        Properties props = check.getProps();
+        
+        byte[] b = (byte[]) props.get("bs");
+        short[] s = (short[]) props.get("ss");
+        int[] i = (int[]) props.get("is");
+        long[] l = (long[]) props.get("ls");
+        double[] d = (double[]) props.get("ds");
+        float[] f = (float[]) props.get("fs");
+        char[] c = (char[]) props.get("cs");
+        boolean[] bool = (boolean[]) props.get("bools");
+                
+        assertEquals("Check b 0", b[0], 1);
+        assertEquals("Check b 1", b[1], 2);
+        assertEquals("Check b 2", b[2], 3);
+        assertEquals("Check s 0", s[0], 1);
+        assertEquals("Check s 1", s[1], 2);
+        assertEquals("Check s 2", s[2], 3);
+        assertEquals("Check i 0", i[0], 1);
+        assertEquals("Check i 1", i[1], 2);
+        assertEquals("Check i 2", i[2], 3);
+        assertEquals("Check l 0", l[0], 1);
+        assertEquals("Check l 1", l[1], 2);
+        assertEquals("Check l 2", l[2], 3);
+        assertEquals("Check d 0", d[0], 1);
+        assertEquals("Check d 1", d[1], 2);
+        assertEquals("Check d 2", d[2], 3);
+        assertEquals("Check f 0", f[0], 1);
+        assertEquals("Check f 1", f[1], 2);
+        assertEquals("Check f 2", f[2], 3);
+        assertEquals("Check c 0", c[0], 'a');
+        assertEquals("Check c 1", c[1], 'b');
+        assertEquals("Check c 2", c[2], 'c');
+        assertTrue("Check bool 0", bool[0]);
+        assertTrue("Check bool 1", bool[0]);
+        assertTrue("Check bool 2", bool[0]);
+        
+        Integer upb = (Integer) props.get("upbs");
+        Integer ups = (Integer) props.get("upss");
+        Integer upi = (Integer) props.get("upis");
+        Integer upl = (Integer) props.get("upls");
+        Integer upd = (Integer) props.get("upds");
+        Integer upf = (Integer) props.get("upfs");
+        Integer upc = (Integer) props.get("upcs");
+        Integer upbool = (Integer) props.get("upbools");
+        
+        assertEquals("Check upb", upb, new Integer(1));
+        assertEquals("Check ups", ups, new Integer(1));
+        assertEquals("Check upi", upi, new Integer(1));
+        assertEquals("Check upl", upl, new Integer(1));
+        assertEquals("Check upd", upd, new Integer(1));
+        assertEquals("Check upf", upf, new Integer(1));
+        assertEquals("Check upc", upc, new Integer(1));
+        assertEquals("Check upbool", upbool, new Integer(1));
+        
+        reconfigure(instance2);
+        
+        ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance2.getInstanceName());
+        assertNotNull("Test check service availability", ref);
+        check = (CheckService) context.getService(ref);
+        props = check.getProps();
+        
+        b = (byte[]) props.get("bs");
+        s = (short[]) props.get("ss");
+        i = (int[]) props.get("is");
+        l = (long[]) props.get("ls");
+        d = (double[]) props.get("ds");
+        f = (float[]) props.get("fs");
+        c = (char[]) props.get("cs");
+        bool = (boolean[]) props.get("bools");
+        
+        assertEquals("2) Check b 0", b[0], 3);
+        assertEquals("2) Check b 1", b[1], 2);
+        assertEquals("2) Check b 2", b[2], 1);
+        assertEquals("2) Check s 0", s[0], 3);
+        assertEquals("2) Check s 1", s[1], 2);
+        assertEquals("2) Check s 2", s[2], 1);
+        assertEquals("2) Check i 0", i[0], 3);
+        assertEquals("2) Check i 1", i[1], 2);
+        assertEquals("2) Check i 2", i[2], 1);
+        assertEquals("2) Check l 0", l[0], 3);
+        assertEquals("2) Check l 1", l[1], 2);
+        assertEquals("2) Check l 2", l[2], 1);
+        assertEquals("2) Check d 0", d[0], 3);
+        assertEquals("2) Check d 1", d[1], 2);
+        assertEquals("2) Check d 2", d[2], 1);
+        assertEquals("2) Check f 0", f[0], 3);
+        assertEquals("2) Check f 1", f[1], 2);
+        assertEquals("2) Check f 2", f[2], 1);
+        assertEquals("2) Check c 0", c[0], 'c');
+        assertEquals("2) Check c 1", c[1], 'b');
+        assertEquals("2) Check c 2", c[2], 'a');
+        assertFalse("2) Check bool 0", bool[0]);
+        assertFalse("2) Check bool 1", bool[0]);
+        assertFalse("2) Check bool 2", bool[0]);
+        
+        upb = (Integer) props.get("upbs");
+        ups = (Integer) props.get("upss");
+        upi = (Integer) props.get("upis");
+        upl = (Integer) props.get("upls");
+        upd = (Integer) props.get("upds");
+        upf = (Integer) props.get("upfs");
+        upc = (Integer) props.get("upcs");
+        upbool = (Integer) props.get("upbools");
+        
+        assertEquals("2) Check upb", upb, new Integer(2));
+        assertEquals("2) Check ups", ups, new Integer(2));
+        assertEquals("2) Check upi", upi, new Integer(2));
+        assertEquals("2) Check upl", upl, new Integer(2));
+        assertEquals("2) Check upd", upd, new Integer(2));
+        assertEquals("2) Check upf", upf, new Integer(2));
+        assertEquals("2) Check upc", upc, new Integer(2));
+        assertEquals("2) Check upbool", upbool, new Integer(2));
+        
+    }
+    
+    public void testConfigurationObj2() {
+        ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance2.getInstanceName());
+        assertNotNull("Test check service availability", ref);
+        CheckService check = (CheckService) context.getService(ref);
+        Properties props = check.getProps();
+        
+        String s = (String) props.get("string");
+        String[] ss = (String[]) props.get("strings");
+                
+        assertEquals("Check string", s, "foo");
+        assertEquals("Check strings 0", ss[0], "foo");
+        assertEquals("Check strings 1", ss[1], "bar");
+        assertEquals("Check strings 2", ss[2], "baz");
+        
+        Integer upString = (Integer) props.get("upstring");
+        Integer upStrings = (Integer) props.get("upstrings");
+        
+        assertEquals("Check upString", upString, new Integer(1));
+        assertEquals("Check upStrings", upStrings, new Integer(1));
+        
+        reconfigure(instance2);
+        
+        ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance2.getInstanceName());
+        assertNotNull("Test check service availability", ref);
+        check = (CheckService) context.getService(ref);
+        props = check.getProps();
+        
+        s = (String) props.get("string");
+        ss = (String[]) props.get("strings");
+                
+        assertEquals("2) Check string", s, "bar");
+        assertEquals("2) Check strings 0", ss[0], "baz");
+        assertEquals("2) Check strings 1", ss[1], "bar");
+        assertEquals("2) Check strings 2", ss[2], "foo");
+        
+        upString = (Integer) props.get("upstring");
+        upStrings = (Integer) props.get("upstrings");
+        
+        assertEquals("2) Check upString", upString, new Integer(2));
+        assertEquals("2) Check upStrings", upStrings, new Integer(2));
+    }
+    
+    private void reconfigure(ComponentInstance ci) {
         Properties props2 = new Properties();
         props2.put("name", "under-test");
         props2.put("b", new Byte("2"));
@@ -326,7 +606,7 @@
         props2.put("string", "bar");
         props2.put("strings", new String[]{"baz", "bar", "foo"});
         
-        instance.reconfigure(props2);
+        ci.reconfigure(props2);
     }
 
 }

Modified: felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/dependency/DependencyTestSuite.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/dependency/DependencyTestSuite.java?rev=602115&r1=602114&r2=602115&view=diff
==============================================================================
--- felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/dependency/DependencyTestSuite.java (original)
+++ felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/dependency/DependencyTestSuite.java Fri Dec  7 07:00:34 2007
@@ -3,6 +3,7 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.felix.ipojo.test.scenarios.dependency.di.DefaultImplementationTestSuite;
 import org.apache.felix.ipojo.test.scenarios.dependency.statics.StaticDependencyTestSuite;
 import org.osgi.framework.BundleContext;
 
@@ -35,6 +36,7 @@
         list.add(new MultipleFilterDependencies(context));
         list.add(new OptionalMultipleFilterDependencies(context));
         list.add(new StaticDependencyTestSuite(context));
+        list.add(new DefaultImplementationTestSuite(context));
 		return list;
 	}
 

Modified: felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/dependency/OptionalDependencies.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/dependency/OptionalDependencies.java?rev=602115&r1=602114&r2=602115&view=diff
==============================================================================
--- felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/dependency/OptionalDependencies.java (original)
+++ felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/dependency/OptionalDependencies.java Fri Dec  7 07:00:34 2007
@@ -82,7 +82,7 @@
 		assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
 		assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
 		assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
-		assertNull("Check FS invocation (object) - 1", props.get("object"));
+		assertNull("Check FS invocation (object) - 1 ("+props.get("object")+")", props.get("object"));
 		assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 0);
 		assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 0);
 		assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 0.0);

Added: felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/dependency/di/DefaultImplementationTestSuite.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/dependency/di/DefaultImplementationTestSuite.java?rev=602115&view=auto
==============================================================================
--- felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/dependency/di/DefaultImplementationTestSuite.java (added)
+++ felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/dependency/di/DefaultImplementationTestSuite.java Fri Dec  7 07:00:34 2007
@@ -0,0 +1,23 @@
+package org.apache.felix.ipojo.test.scenarios.dependency.di;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.osgi.framework.BundleContext;
+
+import fr.imag.adele.escoffier.utf.framework.TestSuite;
+
+public class DefaultImplementationTestSuite extends TestSuite {
+	
+	public DefaultImplementationTestSuite(BundleContext bc) { super(bc); }
+
+	public List suite() {
+		List list = new ArrayList();
+		list.add(new OptionalDependencies(context));
+        list.add(new MethodOptionalDependencies(context));
+        list.add(new DelayedOptionalDependencies(context));
+        list.add(new MethodDelayedOptionalDependencies(context));
+		return list;
+	}
+
+}

Added: felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/dependency/di/DelayedOptionalDependencies.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/dependency/di/DelayedOptionalDependencies.java?rev=602115&view=auto
==============================================================================
--- felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/dependency/di/DelayedOptionalDependencies.java (added)
+++ felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/dependency/di/DelayedOptionalDependencies.java Fri Dec  7 07:00:34 2007
@@ -0,0 +1,341 @@
+package org.apache.felix.ipojo.test.scenarios.dependency.di;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.architecture.Architecture;
+import org.apache.felix.ipojo.architecture.InstanceDescription;
+import org.apache.felix.ipojo.test.scenarios.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+import fr.imag.adele.escoffier.utf.framework.TestCase;
+
+public class DelayedOptionalDependencies extends TestCase {
+
+    ComponentInstance instance1, instance2, instance3, instance4, instance5;
+
+    ComponentInstance fooProvider;
+
+    public DelayedOptionalDependencies(BundleContext bc) {
+        super(bc);
+    }
+
+    public void setUp() {
+        try {
+            Properties prov = new Properties();
+            prov.put("name", "FooProvider");
+            fooProvider = Utils.getFactoryByName(context, "FooProviderType-1").createComponentInstance(prov);
+
+            Properties i1 = new Properties();
+            i1.put("name", "Simple");
+            instance1 = Utils.getFactoryByName(context, "DISimpleOptionalCheckServiceProvider").createComponentInstance(i1);
+            instance1.stop();
+
+            Properties i2 = new Properties();
+            i2.put("name", "Void");
+            instance2 = Utils.getFactoryByName(context, "DIVoidOptionalCheckServiceProvider").createComponentInstance(i2);
+            instance2.stop();
+
+            Properties i3 = new Properties();
+            i3.put("name", "Object");
+            instance3 = Utils.getFactoryByName(context, "DIObjectOptionalCheckServiceProvider").createComponentInstance(i3);
+            instance3.stop();
+
+            Properties i4 = new Properties();
+            i4.put("name", "Ref");
+            instance4 = Utils.getFactoryByName(context, "DIRefOptionalCheckServiceProvider").createComponentInstance(i4);
+            instance4.stop();
+
+            Properties i5 = new Properties();
+            i5.put("name", "Both");
+            instance5 = Utils.getFactoryByName(context, "DIBothOptionalCheckServiceProvider").createComponentInstance(i5);
+            instance5.stop();
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+
+    }
+
+    public void tearDown() {
+        instance1.dispose();
+        instance2.dispose();
+        instance3.dispose();
+        instance4.dispose();
+        instance5.dispose();
+        fooProvider.dispose();
+        instance1 = null;
+        instance2 = null;
+        instance3 = null;
+        instance4 = null;
+        instance5 = null;
+        fooProvider = null;
+    }
+
+    public void testSimple() {
+        instance1.start();
+
+        ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance1.getInstanceName());
+        assertNotNull("Check architecture availability", arch_ref);
+        InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
+
+        ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());
+        assertNotNull("Check CheckService availability", cs_ref);
+        CheckService cs = (CheckService) context.getService(cs_ref);
+        Properties props = cs.getProps();
+
+        // Check properties
+        assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue());
+        assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 0);
+        assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
+        assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
+        assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
+        assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
+        assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
+        assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
+        assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
+        assertNotNull("Check FS invocation (object) - 1", props.get("object"));
+        assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 1);
+        assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 1);
+        assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 1.0);
+
+        fooProvider.stop();
+
+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
+
+        assertNotNull("Check CheckService availability", cs_ref);
+        cs = (CheckService) context.getService(cs_ref);
+        props = cs.getProps();
+        // Check properties
+        assertFalse("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, a provider is here
+        assertEquals("check void bind invocation - 2", ((Integer) props.get("voidB")).intValue(), 0);
+        assertEquals("check void unbind callback invocation - 2", ((Integer) props.get("voidU")).intValue(), 0);
+        assertEquals("check object bind callback invocation - 2", ((Integer) props.get("objectB")).intValue(), 0);
+        assertEquals("check object unbind callback invocation - 2", ((Integer) props.get("objectU")).intValue(), 0);
+        assertEquals("check ref bind callback invocation - 2", ((Integer) props.get("refB")).intValue(), 0);
+        assertEquals("check ref unbind callback invocation - 2", ((Integer) props.get("refU")).intValue(), 0);
+        assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);
+        assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 0);
+        assertNull("Check FS invocation (object) - 2", props.get("object"));
+        assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 5);
+        assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 5);
+        assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 5.0);
+
+        id = null;
+        cs = null;
+        context.ungetService(arch_ref);
+        context.ungetService(cs_ref);
+
+        instance1.stop();
+    }
+
+    public void testVoid() {
+        instance2.start();
+        ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance2.getInstanceName());
+        assertNotNull("Check architecture availability", arch_ref);
+        InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
+
+        ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance2.getInstanceName());
+        assertNotNull("Check CheckService availability", cs_ref);
+        CheckService cs = (CheckService) context.getService(cs_ref);
+        Properties props = cs.getProps();
+        // Check properties
+        assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue());
+        assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 1);
+        assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
+        assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
+        assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
+        assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
+        assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
+        assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
+        assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
+        assertNotNull("Check FS invocation (object) - 1", props.get("object"));
+        assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 1);
+        assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 1);
+        assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 1.0);
+
+        fooProvider.stop();
+
+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
+
+        assertNotNull("Check CheckService availability", cs_ref);
+        cs = (CheckService) context.getService(cs_ref);
+        props = cs.getProps();
+        // Check properties
+        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
+        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 1);
+        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 1);
+        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
+        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
+        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
+        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
+        assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);
+        assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 0);
+        assertNull("Check FS invocation (object) - 2", props.get("object"));
+        assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 5);
+        assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 5);
+        assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 5.0);
+
+        id = null;
+        cs = null;
+        context.ungetService(arch_ref);
+        context.ungetService(cs_ref);
+
+        instance2.stop();
+    }
+
+    public void testObject() {
+        instance3.start();
+        ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance3.getInstanceName());
+        assertNotNull("Check architecture availability", arch_ref);
+        InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
+
+        ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance3.getInstanceName());
+        assertNotNull("Check CheckService availability", cs_ref);
+        CheckService cs = (CheckService) context.getService(cs_ref);
+        Properties props = cs.getProps();
+        // Check properties
+        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
+        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
+        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
+        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 1);
+        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
+        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
+        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
+        assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
+        assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
+
+        fooProvider.stop();
+
+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
+
+        assertNotNull("Check CheckService availability", cs_ref);
+        cs = (CheckService) context.getService(cs_ref);
+        props = cs.getProps();
+        // Check properties
+        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
+        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
+        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
+        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 1);
+        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 1);
+        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
+        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
+        assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);
+        assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 0);
+
+        id = null;
+        cs = null;
+        context.ungetService(arch_ref);
+        context.ungetService(cs_ref);
+
+        instance3.stop();
+    }
+
+    public void testRef() {
+        instance4.start();
+
+        ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance4.getInstanceName());
+        assertNotNull("Check architecture availability", arch_ref);
+        InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
+
+        ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance4.getInstanceName());
+        assertNotNull("Check CheckService availability", cs_ref);
+        CheckService cs = (CheckService) context.getService(cs_ref);
+        Properties props = cs.getProps();
+        // Check properties
+        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
+        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
+        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
+        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
+        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
+        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 1);
+        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
+        assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
+        assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
+
+        fooProvider.stop();
+
+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
+
+        assertNotNull("Check CheckService availability", cs_ref);
+        cs = (CheckService) context.getService(cs_ref);
+        props = cs.getProps();
+        // Check properties
+        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
+        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
+        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
+        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
+        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
+        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 1);
+        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 1);
+        assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);
+        assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 0);
+
+        id = null;
+        cs = null;
+        context.ungetService(arch_ref);
+        context.ungetService(cs_ref);
+
+        instance4.stop();
+    }
+
+    public void testBoth() {
+        instance5.start();
+
+        ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance5.getInstanceName());
+        assertNotNull("Check architecture availability", arch_ref);
+        InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
+
+        ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance5.getInstanceName());
+        assertNotNull("Check CheckService availability", cs_ref);
+        CheckService cs = (CheckService) context.getService(cs_ref);
+        Properties props = cs.getProps();
+        // Check properties
+        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
+        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
+        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
+        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
+        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
+        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
+        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
+        assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 1);
+        assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
+
+        fooProvider.stop();
+
+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
+
+        assertNotNull("Check CheckService availability", cs_ref);
+        cs = (CheckService) context.getService(cs_ref);
+        props = cs.getProps();
+        //Check properties
+        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
+        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
+        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
+        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
+        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
+        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
+        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
+        assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 1);
+        assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 1);
+
+        id = null;
+        cs = null;
+        context.ungetService(arch_ref);
+        context.ungetService(cs_ref);
+
+        instance4.stop();
+    }
+
+}

Added: felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/dependency/di/MethodDelayedOptionalDependencies.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/dependency/di/MethodDelayedOptionalDependencies.java?rev=602115&view=auto
==============================================================================
--- felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/dependency/di/MethodDelayedOptionalDependencies.java (added)
+++ felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/dependency/di/MethodDelayedOptionalDependencies.java Fri Dec  7 07:00:34 2007
@@ -0,0 +1,213 @@
+package org.apache.felix.ipojo.test.scenarios.dependency.di;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.architecture.Architecture;
+import org.apache.felix.ipojo.architecture.InstanceDescription;
+import org.apache.felix.ipojo.test.scenarios.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+import fr.imag.adele.escoffier.utf.framework.TestCase;
+
+public class MethodDelayedOptionalDependencies extends TestCase {
+
+    ComponentInstance instance3, instance4, instance5;
+
+    ComponentInstance fooProvider;
+
+    public MethodDelayedOptionalDependencies(BundleContext bc) {
+        super(bc);
+    }
+
+    public void setUp() {
+        try {
+            Properties prov = new Properties();
+            prov.put("name", "FooProvider");
+            fooProvider = Utils.getFactoryByName(context, "FooProviderType-1").createComponentInstance(prov);
+
+            Properties i3 = new Properties();
+            i3.put("name", "Object");
+            instance3 = Utils.getFactoryByName(context, "DIMObjectOptionalCheckServiceProvider").createComponentInstance(i3);
+            instance3.stop();
+
+            Properties i4 = new Properties();
+            i4.put("name", "Ref");
+            instance4 = Utils.getFactoryByName(context, "DIMRefOptionalCheckServiceProvider").createComponentInstance(i4);
+            instance4.stop();
+
+            Properties i5 = new Properties();
+            i5.put("name", "Both");
+            instance5 = Utils.getFactoryByName(context, "DIMBothOptionalCheckServiceProvider").createComponentInstance(i5);
+            instance5.stop();
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+
+    }
+
+    public void tearDown() {
+        instance3.dispose();
+        instance4.dispose();
+        instance5.dispose();
+        fooProvider.dispose();
+        instance3 = null;
+        instance4 = null;
+        instance5 = null;
+        fooProvider = null;
+    }
+
+    public void testObject() {
+        instance3.start();
+        ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance3.getInstanceName());
+        assertNotNull("Check architecture availability", arch_ref);
+        InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
+
+        ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance3.getInstanceName());
+        assertNotNull("Check CheckService availability", cs_ref);
+        CheckService cs = (CheckService) context.getService(cs_ref);
+        Properties props = cs.getProps();
+        // Check properties
+        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
+        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
+        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
+        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 1);
+        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
+        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
+        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
+        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
+        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
+        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
+        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
+
+        fooProvider.stop();
+
+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
+
+        assertNotNull("Check CheckService availability", cs_ref);
+        cs = (CheckService) context.getService(cs_ref);
+        props = cs.getProps();
+        // Check properties
+        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
+        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
+        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
+        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 1);
+        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 1);
+        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
+        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
+        assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
+        assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
+
+        id = null;
+        cs = null;
+        context.ungetService(arch_ref);
+        context.ungetService(cs_ref);
+
+        instance3.stop();
+    }
+
+    public void testRef() {
+        instance4.start();
+
+        ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance4.getInstanceName());
+        assertNotNull("Check architecture availability", arch_ref);
+        InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
+
+        ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance4.getInstanceName());
+        assertNotNull("Check CheckService availability", cs_ref);
+        CheckService cs = (CheckService) context.getService(cs_ref);
+        Properties props = cs.getProps();
+        // Check properties
+        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
+        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
+        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
+        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
+        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
+        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 1);
+        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
+        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
+        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
+
+        fooProvider.stop();
+
+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
+
+        assertNotNull("Check CheckService availability", cs_ref);
+        cs = (CheckService) context.getService(cs_ref);
+        props = cs.getProps();
+        // Check properties
+        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
+        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
+        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
+        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
+        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
+        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 1);
+        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 1);
+        assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
+        assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
+
+        id = null;
+        cs = null;
+        context.ungetService(arch_ref);
+        context.ungetService(cs_ref);
+
+        instance4.stop();
+    }
+
+    public void testBoth() {
+        instance5.start();
+
+        ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance5.getInstanceName());
+        assertNotNull("Check architecture availability", arch_ref);
+        InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
+
+        ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance5.getInstanceName());
+        assertNotNull("Check CheckService availability", cs_ref);
+        CheckService cs = (CheckService) context.getService(cs_ref);
+        Properties props = cs.getProps();
+        // Check properties
+        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
+        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
+        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
+        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
+        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
+        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
+        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
+        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 1);
+        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
+
+        fooProvider.stop();
+
+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
+
+        assertNotNull("Check CheckService availability", cs_ref);
+        cs = (CheckService) context.getService(cs_ref);
+        props = cs.getProps();
+        // Check properties
+        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
+        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
+        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
+        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
+        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
+        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
+        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
+        assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 1);
+        assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 1);
+
+        id = null;
+        cs = null;
+        context.ungetService(arch_ref);
+        context.ungetService(cs_ref);
+
+        instance4.stop();
+    }
+
+}

Added: felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/dependency/di/MethodOptionalDependencies.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/dependency/di/MethodOptionalDependencies.java?rev=602115&view=auto
==============================================================================
--- felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/dependency/di/MethodOptionalDependencies.java (added)
+++ felix/sandbox/clement/Tests/Suite/src/main/java/org/apache/felix/ipojo/test/scenarios/dependency/di/MethodOptionalDependencies.java Fri Dec  7 07:00:34 2007
@@ -0,0 +1,254 @@
+package org.apache.felix.ipojo.test.scenarios.dependency.di;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.architecture.Architecture;
+import org.apache.felix.ipojo.architecture.InstanceDescription;
+import org.apache.felix.ipojo.test.scenarios.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+import fr.imag.adele.escoffier.utf.framework.TestCase;
+
+public class MethodOptionalDependencies extends TestCase {
+
+    ComponentInstance instance3, instance4, instance5;
+
+    ComponentInstance fooProvider;
+
+    public MethodOptionalDependencies(BundleContext bc) {
+        super(bc);
+    }
+
+    public void setUp() {
+        try {
+            Properties prov = new Properties();
+            prov.put("name", "FooProvider");
+            fooProvider = Utils.getFactoryByName(context, "FooProviderType-1").createComponentInstance(prov);
+            fooProvider.stop();
+
+            Properties i3 = new Properties();
+            i3.put("name", "Object");
+            instance3 = Utils.getFactoryByName(context, "DIMObjectOptionalCheckServiceProvider").createComponentInstance(i3);
+
+            Properties i4 = new Properties();
+            i4.put("name", "Ref");
+            instance4 = Utils.getFactoryByName(context, "DIMRefOptionalCheckServiceProvider").createComponentInstance(i4);
+
+            Properties i5 = new Properties();
+            i5.put("name", "Both");
+            instance5 = Utils.getFactoryByName(context, "DIMBothOptionalCheckServiceProvider").createComponentInstance(i5);
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+    }
+
+    public void tearDown() {
+        instance3.dispose();
+        instance4.dispose();
+        instance5.dispose();
+        fooProvider.dispose();
+        instance3 = null;
+        instance4 = null;
+        instance5 = null;
+        fooProvider = null;
+    }
+
+    public void testObject() {
+
+        ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance3.getInstanceName());
+        assertNotNull("Check architecture availability", arch_ref);
+        InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
+
+        ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance3.getInstanceName());
+        assertNotNull("Check CheckService availability", cs_ref);
+        CheckService cs = (CheckService) context.getService(cs_ref);
+
+        Properties props = cs.getProps();
+
+        // Check properties
+        assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
+        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
+        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
+        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
+        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
+        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
+        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
+        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
+        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
+
+        fooProvider.start();
+
+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
+
+        assertNotNull("Check CheckService availability", cs_ref);
+        cs = (CheckService) context.getService(cs_ref);
+        props = cs.getProps();
+        // Check properties
+        assertTrue("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
+        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
+        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
+        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 1);
+        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
+        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
+        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
+        assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
+        assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
+
+        fooProvider.stop();
+
+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
+
+        cs = (CheckService) context.getService(cs_ref);
+        props = cs.getProps();
+        // Check properties
+        assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
+        assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
+        assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
+        assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 1);
+        assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 1);
+        assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
+        assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
+        assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 0);
+        assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 0);
+
+        id = null;
+        cs = null;
+        context.ungetService(arch_ref);
+        context.ungetService(cs_ref);
+    }
+
+    public void testRef() {
+        ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance4.getInstanceName());
+        assertNotNull("Check architecture availability", arch_ref);
+        InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
+
+        ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance4.getInstanceName());
+        assertNotNull("Check CheckService availability", cs_ref);
+        CheckService cs = (CheckService) context.getService(cs_ref);
+        Properties props = cs.getProps();
+        // Check properties
+        assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
+        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
+        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
+        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
+        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
+        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
+        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
+        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
+        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
+
+        fooProvider.start();
+
+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
+
+        assertNotNull("Check CheckService availability", cs_ref);
+        cs = (CheckService) context.getService(cs_ref);
+        props = cs.getProps();
+        // Check properties
+        assertTrue("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
+        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
+        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
+        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
+        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
+        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 1);
+        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
+        assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
+        assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
+
+        fooProvider.stop();
+
+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
+
+        cs = (CheckService) context.getService(cs_ref);
+        props = cs.getProps();
+        // Check properties
+        assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
+        assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
+        assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
+        assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
+        assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
+        assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 1);
+        assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 1);
+        assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 0);
+        assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 0);
+
+        id = null;
+        cs = null;
+        context.ungetService(arch_ref);
+        context.ungetService(cs_ref);
+    }
+    
+    public void testBoth() {
+        ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance5.getInstanceName());
+        assertNotNull("Check architecture availability", arch_ref);
+        InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
+
+        ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance5.getInstanceName());
+        assertNotNull("Check CheckService availability", cs_ref);
+        CheckService cs = (CheckService) context.getService(cs_ref);
+        Properties props = cs.getProps();
+        // Check properties
+        assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
+        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
+        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
+        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
+        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
+        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
+        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
+        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
+        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
+
+        fooProvider.start();
+
+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
+
+        assertNotNull("Check CheckService availability", cs_ref);
+        cs = (CheckService) context.getService(cs_ref);
+        props = cs.getProps();
+        // Check properties
+        assertTrue("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
+        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
+        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
+        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
+        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
+        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
+        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
+        assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 1);
+        assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
+
+        fooProvider.stop();
+
+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
+
+        cs = (CheckService) context.getService(cs_ref);
+        props = cs.getProps();
+        // Check properties
+        assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
+        assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
+        assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
+        assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
+        assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
+        assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
+        assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
+        assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 1);
+        assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 1);
+
+        id = null;
+        cs = null;
+        context.ungetService(arch_ref);
+        context.ungetService(cs_ref);
+    }
+
+}



Mime
View raw message