You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cl...@apache.org on 2013/02/18 22:05:36 UTC

svn commit: r1447493 - in /felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/felix/ src/main/java/org/apache/felix/ipojo/ ...

Author: clement
Date: Mon Feb 18 21:05:35 2013
New Revision: 1447493

URL: http://svn.apache.org/r1447493
Log:
FELIX-3903

Migrate the core lifecycle callback tests to pax exam 3

Added:
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/   (with props)
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CallbackWithErrorCheckService.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderType1.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderTypeDyn2.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/LifecycleControllerTest.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ParentClass.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/CallbackCheckService.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/CheckService.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/FooService.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/resources/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/resources/metadata.xml
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/runtime/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/runtime/core/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestCallback.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestErrorCallback.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestImmediateCallback.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestImmediateCallbackSeveralFactories.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestImmediateCallbackSingletonFactory.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestImmediateLifeCycleController.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestParentCallback.java
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/resources/
    felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/resources/exam.properties

Propchange: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Feb 18 21:05:35 2013
@@ -0,0 +1,3 @@
+target*
+.idea*
+*.iml

Added: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CallbackWithErrorCheckService.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CallbackWithErrorCheckService.java?rev=1447493&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CallbackWithErrorCheckService.java (added)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CallbackWithErrorCheckService.java Mon Feb 18 21:05:35 2013
@@ -0,0 +1,44 @@
+/* 
+ * 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.runtime.core.components;
+
+import org.apache.felix.ipojo.runtime.core.services.CheckService;
+
+import java.util.Properties;
+
+public class CallbackWithErrorCheckService extends ParentClass implements CheckService {
+
+
+    public void start() {
+        throw new NullPointerException();
+    }
+
+    public void stop() {
+    }
+
+    public boolean check() {
+        return true;
+    }
+
+    public Properties getProps() {
+        Properties p = new Properties();
+        return p;
+    }
+
+}

Added: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderType1.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderType1.java?rev=1447493&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderType1.java (added)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderType1.java Mon Feb 18 21:05:35 2013
@@ -0,0 +1,109 @@
+/* 
+ * 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.runtime.core.components;
+
+import org.apache.felix.ipojo.runtime.core.services.FooService;
+import org.osgi.framework.BundleContext;
+
+import java.util.Properties;
+
+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);
+    }
+    
+	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/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderTypeDyn2.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderTypeDyn2.java?rev=1447493&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderTypeDyn2.java (added)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderTypeDyn2.java Mon Feb 18 21:05:35 2013
@@ -0,0 +1,58 @@
+/* 
+ * 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.runtime.core.components;
+
+import org.apache.felix.ipojo.runtime.core.services.FooService;
+
+import java.util.Properties;
+
+public class FooProviderTypeDyn2 implements FooService {
+	
+	private int intProp = 2;
+	private boolean boolProp = true;
+	private String strProp = "foo";
+	private String[] strAProp = new String[] {"foo", "bar"};
+	private int[] intAProp = new int[] {1, 2, 3};
+
+	public boolean foo() {
+		intAProp = null;
+		return true;
+	}
+
+	public Properties fooProps() {
+		Properties p = new Properties();
+		p.put("intProp", new Integer(intProp));
+		p.put("boolProp", new Boolean(boolProp));
+		p.put("strProp", strProp);
+		p.put("strAProp", strAProp);
+		p.put("intAProp", intAProp);
+		return p;
+	}
+	
+	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); }
+
+}

Added: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/LifecycleControllerTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/LifecycleControllerTest.java?rev=1447493&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/LifecycleControllerTest.java (added)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/LifecycleControllerTest.java Mon Feb 18 21:05:35 2013
@@ -0,0 +1,49 @@
+/* 
+ * 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.runtime.core.components;
+
+import org.apache.felix.ipojo.runtime.core.services.CheckService;
+
+import java.util.Properties;
+
+public class LifecycleControllerTest implements CheckService {
+    
+    private boolean m_state = true;
+    private String m_conf;
+    
+    public void setConf(String newConf) {
+        if (newConf.equals("foo")) {
+            m_state = true;
+        } else {
+            m_state = false;
+        }
+    }
+
+    public boolean check() {
+        return m_state;
+    }
+
+    public Properties getProps() {
+       Properties props = new Properties();
+       props.put("conf", m_conf);
+       props.put("state", new Boolean(m_state));
+       return props;
+    }
+}
+

Added: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ParentClass.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ParentClass.java?rev=1447493&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ParentClass.java (added)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ParentClass.java Mon Feb 18 21:05:35 2013
@@ -0,0 +1,51 @@
+/* 
+ * 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.runtime.core.components;
+
+public class ParentClass {
+    
+    public void parentStart() {
+        
+    }
+    
+    public void parentStop() {
+        
+    }
+	
+	protected String[] strings;
+	
+	protected String string;
+	
+	protected int upStrings;
+	
+	protected int upString;
+	
+	public void updateStrings(String[] bb) {
+        strings = bb;
+        upStrings++;
+    }
+    
+    public void updateString(String bb) {
+        string = bb;
+        upString++;
+    }
+	
+	
+
+}

Added: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/CallbackCheckService.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/CallbackCheckService.java?rev=1447493&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/CallbackCheckService.java (added)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/CallbackCheckService.java Mon Feb 18 21:05:35 2013
@@ -0,0 +1,67 @@
+/* 
+ * 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.runtime.core.services;
+
+import org.apache.felix.ipojo.runtime.core.components.ParentClass;
+
+import java.util.Properties;
+
+public class CallbackCheckService extends ParentClass implements CheckService {
+
+    int i = 0;
+
+    FooService fs;
+
+    public static CallbackCheckService singleton;
+
+    public static int count = 0;
+
+    private static CallbackCheckService singleton() {
+        if (singleton == null) {
+            count++;
+            singleton = new CallbackCheckService();
+        }
+        return singleton;
+    }
+
+    public static CallbackCheckService several() {
+        count++;
+        return new CallbackCheckService();
+    }
+
+    private void start() {
+        i++;
+    }
+
+    protected void stop() {
+        i++;
+    }
+
+    public boolean check() {
+        return fs.foo();
+    }
+
+    public Properties getProps() {
+        Properties p = new Properties();
+        p.put("int", new Integer(i));
+        p.put("count", new Integer(count));
+        return p;
+    }
+
+}

Added: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/CheckService.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/CheckService.java?rev=1447493&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/CheckService.java (added)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/CheckService.java Mon Feb 18 21:05:35 2013
@@ -0,0 +1,31 @@
+/* 
+ * 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.runtime.core.services;
+
+import java.util.Properties;
+
+public interface CheckService {
+    
+    public static final String foo = "foo";
+	
+	public boolean check();
+	
+	public Properties getProps();
+
+}

Added: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/FooService.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/FooService.java?rev=1447493&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/FooService.java (added)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/FooService.java Mon Feb 18 21:05:35 2013
@@ -0,0 +1,39 @@
+/* 
+ * 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.runtime.core.services;
+
+import java.util.Properties;
+
+public interface FooService {
+
+	boolean foo();
+	
+	Properties fooProps();
+	
+	Boolean getObject();
+	
+	boolean getBoolean();
+	
+	int getInt();
+	
+	long getLong();
+	
+	double getDouble();
+	
+}

Added: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/resources/metadata.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/resources/metadata.xml?rev=1447493&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/resources/metadata.xml (added)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/main/resources/metadata.xml Mon Feb 18 21:05:35 2013
@@ -0,0 +1,89 @@
+<ipojo
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd"
+        xmlns="org.apache.felix.ipojo"
+        >
+    <component
+            classname="org.apache.felix.ipojo.runtime.core.components.FooProviderType1"
+            name="LFCB-FooProviderType-1" architecture="true">
+        <provides/>
+    </component>
+
+    <!-- Lifecycle Callback -->
+    <component
+            classname="org.apache.felix.ipojo.runtime.core.services.CallbackCheckService"
+            name="LFCB-CallbackCheckService" architecture="true">
+        <requires field="fs"/>
+        <provides/>
+        <callback transition="validate" method="start"/>
+        <callback transition="invalidate" method="stop"/>
+    </component>
+    <component
+            classname="org.apache.felix.ipojo.runtime.core.services.CallbackCheckService"
+            name="LFCB-ParentCallbackCheckService" architecture="true">
+        <requires field="fs"/>
+        <provides/>
+        <callback transition="validate" method="parentStart"/>
+        <callback transition="invalidate" method="parentStop"/>
+    </component>
+    <component
+            classname="org.apache.felix.ipojo.runtime.core.services.CallbackCheckService"
+            immediate="true" name="LFCB-ImmediateCallbackCheckService"
+            architecture="true">
+        <requires field="fs"/>
+        <provides/>
+        <callback transition="validate" method="start"/>
+        <callback transition="invalidate" method="stop"/>
+    </component>
+    <component
+            classname="org.apache.felix.ipojo.runtime.core.services.CallbackCheckService"
+            immediate="true" name="LFCB-ImmediateCallbackCheckServiceSingleton"
+            factory-method="singleton" architecture="true">
+        <requires field="fs"/>
+        <provides/>
+        <callback transition="validate" method="start"/>
+        <callback transition="invalidate" method="stop"/>
+    </component>
+    <component
+            classname="org.apache.felix.ipojo.runtime.core.services.CallbackCheckService"
+            immediate="true" name="LFCB-ImmediateCallbackCheckServiceSeveral"
+            factory-method="several" architecture="true">
+        <requires field="fs"/>
+        <provides/>
+        <callback transition="validate" method="start"/>
+        <callback transition="invalidate" method="stop"/>
+    </component>
+
+    <!--  Test initialization error -->
+    <component
+            classname="org.apache.felix.ipojo.runtime.core.components.CallbackWithErrorCheckService"
+            name="LFCB-CallbackWithError">
+        <provides/>
+        <callback transition="validate" method="start"/>
+        <callback transition="invalidate" method="stop"/>
+    </component>
+
+    <!-- Component type initially defined in another project, moved here after pax exam 3 -->
+    <component
+            classname="org.apache.felix.ipojo.runtime.core.components.FooProviderTypeDyn2"
+            name="Factories-FooProviderType-Dyn2" architecture="true">
+        <provides>
+            <property name="int" field="intProp" value="4" mandatory="true"/>
+            <property name="boolean" field="boolProp" mandatory="true"/>
+            <property name="string" field="strProp" mandatory="true"/>
+            <property name="strAProp" field="strAProp" mandatory="true"/>
+            <property name="intAProp" field="intAProp"
+                      value="{1, 2,3 }" mandatory="true"/>
+        </provides>
+    </component>
+
+    <component
+            classname="org.apache.felix.ipojo.runtime.core.components.LifecycleControllerTest"
+            name="LFC-Test-Immediate" immediate="true" architecture="true">
+        <provides />
+        <controller field="m_state" />
+        <properties>
+            <property name="conf" field="m_conf" method="setConf" />
+        </properties>
+    </component>
+</ipojo>

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

Added: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestCallback.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestCallback.java?rev=1447493&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestCallback.java (added)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestCallback.java Mon Feb 18 21:05:35 2013
@@ -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.runtime.core;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.PrimitiveInstanceDescription;
+import org.apache.felix.ipojo.architecture.Architecture;
+import org.apache.felix.ipojo.runtime.core.services.CheckService;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.ServiceReference;
+
+import java.util.Properties;
+
+import static junit.framework.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class TestCallback extends Common {
+
+    ComponentInstance instance; // Instance under test
+    ComponentInstance fooProvider;
+
+    @Before
+    public void setUp() {
+        Properties p2 = new Properties();
+        p2.put("instance.name", "fooProvider");
+        fooProvider = ipojoHelper.createComponentInstance("LFCB-FooProviderType-1", p2);
+        fooProvider.stop();
+
+        Properties p1 = new Properties();
+        p1.put("instance.name", "callback");
+        instance = ipojoHelper.createComponentInstance("LFCB-CallbackCheckService", p1);
+
+    }
+
+    @After
+    public void tearDown() {
+        instance.dispose();
+        fooProvider.dispose();
+        instance = null;
+        fooProvider = null;
+    }
+
+    @Test
+    public void testCallback() {
+        // Check instance is invalid
+        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance.getInstanceName());
+        assertNotNull("Check architecture availability", arch_ref);
+        PrimitiveInstanceDescription id_dep = (PrimitiveInstanceDescription) ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance invalidity - 1", id_dep.getState() == ComponentInstance.INVALID);
+        assertEquals("Check pojo count - 1", id_dep.getCreatedObjects().length, 0);
+
+        // Start fooprovider
+        fooProvider.start();
+
+        // Check instance validity
+        //id_dep = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 1", id_dep.getState() == ComponentInstance.VALID);
+
+        // Check service providing
+        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance.getInstanceName());
+        assertNotNull("Check CheckService availability", cs_ref);
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
+        assertTrue("check CheckService invocation", cs.check());
+
+        // Check int property
+        Integer index = (Integer) (cs.getProps().get("int"));
+        assertEquals("Check int property - 1", index.intValue(), 1);
+
+        assertEquals("Check pojo count - 2", id_dep.getCreatedObjects().length, 1);
+
+        fooProvider.stop();
+
+        //id_dep = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.INVALID);
+
+        assertEquals("Check pojo count - 3", id_dep.getCreatedObjects().length, 1);
+
+        fooProvider.start();
+
+        // Check instance validity
+        //id_dep = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 2", id_dep.getState() == ComponentInstance.VALID);
+
+        // Check service providing
+        cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance.getInstanceName());
+        assertNotNull("Check CheckService availability", cs_ref);
+        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
+        assertTrue("check CheckService invocation", cs.check());
+
+        // Check int property
+        index = (Integer) (cs.getProps().get("int"));
+        assertEquals("Check int property - 2 (" + index.intValue() + ")", index.intValue(), 3);
+
+        assertEquals("Check pojo count - 4 ", id_dep.getCreatedObjects().length, 1);
+    }
+
+
+}

Added: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestErrorCallback.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestErrorCallback.java?rev=1447493&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestErrorCallback.java (added)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestErrorCallback.java Mon Feb 18 21:05:35 2013
@@ -0,0 +1,60 @@
+/* 
+ * 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.runtime.core;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.runtime.core.services.CheckService;
+import org.junit.After;
+import org.junit.Test;
+import org.osgi.framework.ServiceReference;
+
+import java.util.Properties;
+
+import static org.junit.Assert.assertNull;
+
+/**
+ * Test the fix for FELIX-1965.
+ * When a validate callback throws an exception, the service is still provided.
+ */
+public class TestErrorCallback extends Common {
+    
+    ComponentInstance instance; // Instance under test
+
+    @After
+    public void tearDown() {
+        if (instance != null) {
+            instance.dispose();
+            instance= null;
+        }
+    }
+    
+    @Test
+    public void testErrorInValidateCallback() {
+        Properties p2 = new Properties();
+        p2.put("instance.name","error");
+        instance = ipojoHelper.createComponentInstance("LFCB-CallbackWithError", p2);
+        
+        // The service should not be provided as the start method has thrown an exception
+        ServiceReference ref = osgiHelper.getServiceReference(CheckService.class.getName(),
+                "(instance.name=" + instance.getInstanceName() + ")");
+        assertNull(ref);
+    }
+        
+
+}

Added: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestImmediateCallback.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestImmediateCallback.java?rev=1447493&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestImmediateCallback.java (added)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestImmediateCallback.java Mon Feb 18 21:05:35 2013
@@ -0,0 +1,116 @@
+/* 
+ * 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.runtime.core;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.PrimitiveInstanceDescription;
+import org.apache.felix.ipojo.architecture.Architecture;
+import org.apache.felix.ipojo.runtime.core.services.CheckService;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.ServiceReference;
+
+import java.util.Properties;
+
+import static junit.framework.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class TestImmediateCallback extends Common {
+
+    ComponentInstance instance; // Instance under test
+    ComponentInstance fooProvider;
+
+    @Before
+    public void setUp() {
+        Properties p2 = new Properties();
+        p2.put("instance.name", "fooProvider");
+        fooProvider = ipojoHelper.createComponentInstance("LFCB-FooProviderType-1", p2);
+        fooProvider.stop();
+
+        Properties p1 = new Properties();
+        p1.put("instance.name", "callback");
+        instance = ipojoHelper.createComponentInstance("LFCB-ImmediateCallbackCheckService", p1);
+
+    }
+
+    @After
+    public void tearDown() {
+        instance.dispose();
+        fooProvider.dispose();
+        instance = null;
+        fooProvider = null;
+    }
+
+    @Test
+    public void testCallback() {
+        // Check instance is invalid
+        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance.getInstanceName());
+        assertNotNull("Check architecture availability", arch_ref);
+        PrimitiveInstanceDescription id_dep = (PrimitiveInstanceDescription) ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance invalidity - 1", id_dep.getState() == ComponentInstance.INVALID);
+        assertEquals("Check pojo count - 1", id_dep.getCreatedObjects().length, 0);
+
+        // Start fooprovider
+        fooProvider.start();
+
+        // Check instance validity
+        //id_dep = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 1", id_dep.getState() == ComponentInstance.VALID);
+
+        // Check service providing
+        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance.getInstanceName());
+        assertNotNull("Check CheckService availability", cs_ref);
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
+        assertTrue("check CheckService invocation", cs.check());
+
+        assertEquals("Check pojo count - 2", id_dep.getCreatedObjects().length, 1);
+        // Check int property
+        Integer index = (Integer) (cs.getProps().get("int"));
+        assertEquals("Check int property - 1 (" + index + ")", index.intValue(), 1);
+
+        fooProvider.stop();
+
+        //id_dep = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.INVALID);
+
+        assertEquals("Check pojo count - 3", id_dep.getCreatedObjects().length, 1);
+
+        fooProvider.start();
+
+        // Check instance validity
+        //id_dep = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 2", id_dep.getState() == ComponentInstance.VALID);
+
+        // Check service providing
+        cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance.getInstanceName());
+        assertNotNull("Check CheckService availability", cs_ref);
+        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
+        assertTrue("check CheckService invocation", cs.check());
+
+        // Check int property
+        index = (Integer) (cs.getProps().get("int"));
+        assertEquals("Check int property - 2 (" + index + ")", index.intValue(), 3);
+
+        assertEquals("Check pojo count - 4 ", id_dep.getCreatedObjects().length, 1);
+    }
+
+
+}

Added: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestImmediateCallbackSeveralFactories.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestImmediateCallbackSeveralFactories.java?rev=1447493&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestImmediateCallbackSeveralFactories.java (added)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestImmediateCallbackSeveralFactories.java Mon Feb 18 21:05:35 2013
@@ -0,0 +1,124 @@
+/* 
+ * 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.runtime.core;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.PrimitiveInstanceDescription;
+import org.apache.felix.ipojo.architecture.Architecture;
+import org.apache.felix.ipojo.runtime.core.services.CallbackCheckService;
+import org.apache.felix.ipojo.runtime.core.services.CheckService;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.ServiceReference;
+
+import java.util.Properties;
+
+import static junit.framework.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class TestImmediateCallbackSeveralFactories extends Common {
+
+    ComponentInstance instance; // Instance under test
+    ComponentInstance fooProvider;
+
+    @Before
+    public void setUp() {
+        Properties p2 = new Properties();
+        p2.put("instance.name", "fooProvider");
+        fooProvider = ipojoHelper.createComponentInstance("LFCB-FooProviderType-1", p2);
+        fooProvider.stop();
+
+        Properties p1 = new Properties();
+        p1.put("instance.name", "callback");
+        instance = ipojoHelper.createComponentInstance("LFCB-ImmediateCallbackCheckServiceSeveral", p1);
+
+    }
+
+    @After
+    public void tearDown() {
+        instance.dispose();
+        fooProvider.dispose();
+        instance = null;
+        fooProvider = null;
+        CallbackCheckService.count = 0;
+    }
+
+    @Test
+    public void testCallback() {
+        // Check instance is invalid
+        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(),
+                instance.getInstanceName());
+        assertNotNull("Check architecture availability", arch_ref);
+        PrimitiveInstanceDescription id_dep = (PrimitiveInstanceDescription) ((Architecture) osgiHelper.getServiceObject
+                (arch_ref)).getInstanceDescription();
+        assertTrue("Check instance invalidity - 1", id_dep.getState() == ComponentInstance.INVALID);
+        assertEquals("Check pojo count - 1", id_dep.getCreatedObjects().length, 0);
+
+        // Start fooprovider
+        fooProvider.start();
+
+        // Check instance validity
+        //id_dep = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 1", id_dep.getState() == ComponentInstance.VALID);
+
+        // Check service providing
+        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance.getInstanceName());
+        assertNotNull("Check CheckService availability", cs_ref);
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
+        assertTrue("check CheckService invocation", cs.check());
+
+        assertEquals("Check pojo count - 2", id_dep.getCreatedObjects().length, 1);
+        // Check int property
+        Integer index = (Integer) (cs.getProps().get("int"));
+        Integer count = (Integer) (cs.getProps().get("count"));
+        assertEquals("Check int property - 1 (" + index + ")", index.intValue(), 1);
+        assertEquals("Check count property - 1 (" + count + ")", count.intValue(), 1);
+
+        fooProvider.stop();
+
+        //id_dep = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.INVALID);
+
+        assertEquals("Check pojo count - 3", id_dep.getCreatedObjects().length, 1);
+
+        fooProvider.start();
+
+        // Check instance validity
+        //id_dep = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 2", id_dep.getState() == ComponentInstance.VALID);
+
+        // Check service providing
+        cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance.getInstanceName());
+        assertNotNull("Check CheckService availability", cs_ref);
+        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
+        assertTrue("check CheckService invocation", cs.check());
+
+        // Check int property
+        index = (Integer) (cs.getProps().get("int"));
+        count = (Integer) (cs.getProps().get("count"));
+        assertEquals("Check int property - 2 (" + index + ")", index.intValue(), 3);
+        assertEquals("Check count property - 2 (" + count + ")", count.intValue(), 1);
+
+        assertEquals("Check pojo count - 4 ", id_dep.getCreatedObjects().length, 1);
+    }
+
+
+}

Added: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestImmediateCallbackSingletonFactory.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestImmediateCallbackSingletonFactory.java?rev=1447493&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestImmediateCallbackSingletonFactory.java (added)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestImmediateCallbackSingletonFactory.java Mon Feb 18 21:05:35 2013
@@ -0,0 +1,119 @@
+/* 
+ * 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.runtime.core;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.PrimitiveInstanceDescription;
+import org.apache.felix.ipojo.architecture.Architecture;
+import org.apache.felix.ipojo.runtime.core.services.CallbackCheckService;
+import org.apache.felix.ipojo.runtime.core.services.CheckService;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.ServiceReference;
+
+import java.util.Properties;
+
+import static junit.framework.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class TestImmediateCallbackSingletonFactory extends Common {
+
+    ComponentInstance instance; // Instance under test
+    ComponentInstance fooProvider;
+
+    @Before
+    public void setUp() {
+        Properties p2 = new Properties();
+        p2.put("instance.name", "fooProvider");
+        fooProvider = ipojoHelper.createComponentInstance("LFCB-FooProviderType-1", p2);
+        fooProvider.stop();
+
+        Properties p1 = new Properties();
+        p1.put("instance.name", "callback");
+        instance = ipojoHelper.createComponentInstance("LFCB-ImmediateCallbackCheckServiceSingleton", p1);
+
+    }
+
+    @After
+    public void tearDown() {
+        instance.dispose();
+        fooProvider.dispose();
+        instance = null;
+        fooProvider = null;
+        CallbackCheckService.count = 0;
+        CallbackCheckService.singleton = null;
+    }
+
+    @Test
+    public void testCallback() {
+        // Check instance is invalid
+        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance.getInstanceName());
+        assertNotNull("Check architecture availability", arch_ref);
+        PrimitiveInstanceDescription id_dep = (PrimitiveInstanceDescription) ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance invalidity - 1", id_dep.getState() == ComponentInstance.INVALID);
+        assertEquals("Check pojo count - 1", id_dep.getCreatedObjects().length, 0);
+
+        // Start fooprovider
+        fooProvider.start();
+
+        // Check instance validity
+        // id_dep = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 1", id_dep.getState() == ComponentInstance.VALID);
+
+        // Check service providing
+        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance.getInstanceName());
+        assertNotNull("Check CheckService availability", cs_ref);
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
+        assertTrue("check CheckService invocation", cs.check());
+
+        assertEquals("Check pojo count - 2", id_dep.getCreatedObjects().length, 1);
+        // Check int property
+        Integer index = (Integer) (cs.getProps().get("int"));
+        assertEquals("Check int property - 1 (" + index + ")", index.intValue(), 1);
+
+        fooProvider.stop();
+
+        //id_dep = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.INVALID);
+
+        assertEquals("Check pojo count - 3", id_dep.getCreatedObjects().length, 1);
+
+        fooProvider.start();
+
+        // Check instance validity
+        // id_dep = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 2", id_dep.getState() == ComponentInstance.VALID);
+
+        // Check service providing
+        cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance.getInstanceName());
+        assertNotNull("Check CheckService availability", cs_ref);
+        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
+        assertTrue("check CheckService invocation", cs.check());
+
+        // Check int property
+        index = (Integer) (cs.getProps().get("int"));
+        assertEquals("Check int property - 2 (" + index + ")", index.intValue(), 3);
+
+        assertEquals("Check pojo count - 4 ", id_dep.getCreatedObjects().length, 1);
+    }
+
+
+}

Added: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestImmediateLifeCycleController.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestImmediateLifeCycleController.java?rev=1447493&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestImmediateLifeCycleController.java (added)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestImmediateLifeCycleController.java Mon Feb 18 21:05:35 2013
@@ -0,0 +1,114 @@
+/* 
+ * 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.runtime.core;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.Factory;
+import org.apache.felix.ipojo.runtime.core.services.CheckService;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.ServiceReference;
+
+import java.util.Properties;
+
+import static org.junit.Assert.*;
+
+public class TestImmediateLifeCycleController extends Common {
+
+    private ComponentInstance under;
+    private Factory factory;
+
+    @Before
+    public void setUp() {
+        factory = ipojoHelper.getFactory("LFC-Test-Immediate");
+    }
+
+    @Test
+    public void testOne() {
+        Properties props = new Properties();
+        props.put("conf", "foo");
+        props.put("instance.name", "under");
+        under = ipojoHelper.createComponentInstance("LFC-Test-Immediate", props);
+
+        // The conf is correct, the PS must be provided
+        ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), "under");
+        assertNotNull("Check service availability -1", ref);
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref);
+        assertTrue("Check state 1", cs.check());
+        bc.ungetService(ref);
+
+        // Reconfigure the instance with a bad configuration
+        props.put("conf", "bar"); // Bar is a bad conf
+        try {
+            factory.reconfigure(props);
+        } catch (Exception e) {
+            fail("The reconfiguration is not unacceptable and seems unacceptable : " + props);
+        }
+
+        // The instance should now be invalid 
+        ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), "under");
+        assertNull("Check service availability -2", ref);
+
+        // Reconfigure the instance with a valid configuration
+        props.put("conf", "foo"); // Bar is a bad conf
+        try {
+            factory.reconfigure(props);
+        } catch (Exception e) {
+            fail("The reconfiguration is not unacceptable and seems unacceptable (2) : " + props);
+        }
+
+        ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), "under");
+        assertNotNull("Check service availability -3", ref);
+        cs = (CheckService) osgiHelper.getServiceObject(ref);
+        assertTrue("Check state 2", cs.check());
+        bc.ungetService(ref);
+        under.dispose();
+    }
+
+    @Test
+    public void testTwo() {
+        Properties props = new Properties();
+        props.put("conf", "bar");
+        props.put("instance.name", "under");
+        under = ipojoHelper.createComponentInstance("LFC-Test-Immediate", props);
+
+        assertEquals("check under state", under.getState(), ComponentInstance.INVALID);
+
+        // The conf is incorrect, the PS must not be provided
+        ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), "under");
+        assertNull("Check service availability -1", ref);
+
+        // Reconfigure the instance with a correct configuration
+        props.put("conf", "foo");
+        try {
+            factory.reconfigure(props);
+        } catch (Exception e) {
+            fail("The reconfiguration is not unacceptable and seems unacceptable : " + props);
+        }
+
+        ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), "under");
+        assertNotNull("Check service availability -2", ref);
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref);
+        assertTrue("Check state ", cs.check());
+        bc.ungetService(ref);
+        under.dispose();
+    }
+
+
+}

Added: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestParentCallback.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestParentCallback.java?rev=1447493&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestParentCallback.java (added)
+++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestParentCallback.java Mon Feb 18 21:05:35 2013
@@ -0,0 +1,108 @@
+/* 
+ * 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.runtime.core;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.PrimitiveInstanceDescription;
+import org.apache.felix.ipojo.architecture.Architecture;
+import org.apache.felix.ipojo.runtime.core.services.CheckService;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.ServiceReference;
+
+import java.util.Properties;
+
+import static junit.framework.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class TestParentCallback extends Common {
+
+    ComponentInstance instance; // Instance under test
+    ComponentInstance fooProvider;
+
+    @Before
+    public void setUp() {
+        Properties p2 = new Properties();
+        p2.put("instance.name", "fooProvider");
+        fooProvider = ipojoHelper.createComponentInstance("LFCB-FooProviderType-1", p2);
+        fooProvider.stop();
+
+        Properties p1 = new Properties();
+        p1.put("instance.name", "callback");
+        instance = ipojoHelper.createComponentInstance("LFCB-ParentCallbackCheckService", p1);
+
+    }
+
+    @After
+    public void tearDown() {
+        instance.dispose();
+        fooProvider.dispose();
+        instance = null;
+        fooProvider = null;
+    }
+
+    @Test
+    public void testCallback() {
+        // Check instance is invalid
+        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance.getInstanceName());
+        assertNotNull("Check architecture availability", arch_ref);
+        PrimitiveInstanceDescription id_dep = (PrimitiveInstanceDescription) ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance invalidity - 1", id_dep.getState() == ComponentInstance.INVALID);
+
+        // Start fooprovider
+        fooProvider.start();
+
+        // Check instance validity
+        //id_dep = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 1", id_dep.getState() == ComponentInstance.VALID);
+
+        // Check service providing
+        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance.getInstanceName());
+        assertNotNull("Check CheckService availability", cs_ref);
+        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
+
+        // Check int property
+        assertEquals("Check pojo count - 2", id_dep.getCreatedObjects().length, 1);
+
+        fooProvider.stop();
+
+        //id_dep = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.INVALID);
+
+        fooProvider.start();
+
+        // Check instance validity
+        //id_dep = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 2", id_dep.getState() == ComponentInstance.VALID);
+
+        // Check service providing
+        cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance.getInstanceName());
+        assertNotNull("Check CheckService availability", cs_ref);
+        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
+        assertTrue("check CheckService invocation", cs.check());
+
+        // Clean up
+        bc.ungetService(arch_ref);
+        bc.ungetService(cs_ref);
+    }
+
+
+}

Added: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/resources/exam.properties
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-lifecycle-callback-test/src/test/resources/exam.properties?rev=1447493&view=auto
==============================================================================
    (empty)