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 2008/04/25 18:50:22 UTC
svn commit: r651646 [8/22] - in /felix/trunk/ipojo/tests: ./
tests.composite/ tests.composite/src/ tests.composite/src/main/
tests.composite/src/main/java/ tests.composite/src/main/java/org/
tests.composite/src/main/java/org/apache/ tests.composite/src...
Added: felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/CallbackTestCase.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/CallbackTestCase.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/CallbackTestCase.java (added)
+++ felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/CallbackTestCase.java Fri Apr 25 09:49:43 2008
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.test.scenarios.lifecycle.callback;
+
+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.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.lifecycle.callback.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.ServiceReference;
+
+public class CallbackTestCase extends OSGiTestCase {
+
+ ComponentInstance instance; // Instance under test
+ ComponentInstance fooProvider;
+
+ public void setUp() {
+ Properties p2 = new Properties();
+ p2.put("name", "fooProvider");
+ fooProvider = Utils.getComponentInstance(context, "LFCB-FooProviderType-1", p2);
+ fooProvider.stop();
+
+ Properties p1 = new Properties();
+ p1.put("name", "callback");
+ instance = Utils.getComponentInstance(context, "LFCB-CallbackCheckService", p1);
+
+ }
+
+ public void tearDown() {
+ instance.dispose();
+ fooProvider.dispose();
+ instance= null;
+ fooProvider = null;
+ }
+
+ public void testCallback() {
+ // Check instance is invalid
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ref);
+ InstanceDescription id_dep = ((Architecture) context.getService(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) context.getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 1", id_dep.getState() == ComponentInstance.VALID);
+
+ // Check service providing
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Check CheckService availability", cs_ref);
+ CheckService cs = (CheckService) context.getService(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) context.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) context.getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 2", id_dep.getState() == ComponentInstance.VALID);
+
+ // Check service providing
+ cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Check CheckService availability", cs_ref);
+ cs = (CheckService) context.getService(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);
+
+ // Clean up
+ context.ungetService(arch_ref);
+ context.ungetService(cs_ref);
+ cs = null;
+ id_dep = null;
+ }
+
+
+}
Added: felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/ImmediateCallbackSeveralFactoryTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/ImmediateCallbackSeveralFactoryTest.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/ImmediateCallbackSeveralFactoryTest.java (added)
+++ felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/ImmediateCallbackSeveralFactoryTest.java Fri Apr 25 09:49:43 2008
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.test.scenarios.lifecycle.callback;
+
+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.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.component.CallbackCheckService;
+import org.apache.felix.ipojo.test.scenarios.lifecycle.callback.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.ServiceReference;
+
+public class ImmediateCallbackSeveralFactoryTest extends OSGiTestCase {
+
+ ComponentInstance instance; // Instance under test
+ ComponentInstance fooProvider;
+
+ public void setUp() {
+ Properties p2 = new Properties();
+ p2.put("name", "fooProvider");
+ fooProvider = Utils.getComponentInstance(context, "LFCB-FooProviderType-1", p2);
+ fooProvider.stop();
+
+ Properties p1 = new Properties();
+ p1.put("name", "callback");
+ instance = Utils.getComponentInstance(context, "LFCB-ImmediateCallbackCheckServiceSeveral", p1);
+
+ }
+
+ public void tearDown() {
+ instance.dispose();
+ fooProvider.dispose();
+ instance= null;
+ fooProvider = null;
+ CallbackCheckService.count = 0;
+ }
+
+ public void testCallback() {
+ // Check instance is invalid
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ref);
+ InstanceDescription id_dep = ((Architecture) context.getService(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) context.getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 1", id_dep.getState() == ComponentInstance.VALID);
+
+ // Check service providing
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Check CheckService availability", cs_ref);
+ CheckService cs = (CheckService) context.getService(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.intValue() +")", index.intValue(), 1);
+ assertEquals("Check count property - 1 (" + count.intValue() +")", count.intValue(), 1);
+
+ fooProvider.stop();
+
+ id_dep = ((Architecture) context.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) context.getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 2", id_dep.getState() == ComponentInstance.VALID);
+
+ // Check service providing
+ cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Check CheckService availability", cs_ref);
+ cs = (CheckService) context.getService(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.intValue()+")", index.intValue(), 3);
+ assertEquals("Check count property - 2 ("+count.intValue()+")", count.intValue(), 1);
+
+ assertEquals("Check pojo count - 4 ", id_dep.getCreatedObjects().length, 1);
+
+ // Clean up
+ context.ungetService(arch_ref);
+ context.ungetService(cs_ref);
+ cs = null;
+ id_dep = null;
+ }
+
+
+}
Added: felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/ImmediateCallbackSingletonFactoryTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/ImmediateCallbackSingletonFactoryTest.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/ImmediateCallbackSingletonFactoryTest.java (added)
+++ felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/ImmediateCallbackSingletonFactoryTest.java Fri Apr 25 09:49:43 2008
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.test.scenarios.lifecycle.callback;
+
+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.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.component.CallbackCheckService;
+import org.apache.felix.ipojo.test.scenarios.lifecycle.callback.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.ServiceReference;
+
+public class ImmediateCallbackSingletonFactoryTest extends OSGiTestCase {
+
+ ComponentInstance instance; // Instance under test
+ ComponentInstance fooProvider;
+
+ public void setUp() {
+ Properties p2 = new Properties();
+ p2.put("name", "fooProvider");
+ fooProvider = Utils.getComponentInstance(context, "LFCB-FooProviderType-1", p2);
+ fooProvider.stop();
+
+ Properties p1 = new Properties();
+ p1.put("name", "callback");
+ instance = Utils.getComponentInstance(context, "LFCB-ImmediateCallbackCheckServiceSingleton", p1);
+
+ }
+
+ public void tearDown() {
+ instance.dispose();
+ fooProvider.dispose();
+ instance= null;
+ fooProvider = null;
+ CallbackCheckService.count = 0;
+ CallbackCheckService.singleton = null;
+ }
+
+ public void testCallback() {
+ // Check instance is invalid
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ref);
+ InstanceDescription id_dep = ((Architecture) context.getService(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) context.getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 1", id_dep.getState() == ComponentInstance.VALID);
+
+ // Check service providing
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Check CheckService availability", cs_ref);
+ CheckService cs = (CheckService) context.getService(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.intValue() +")", index.intValue(), 1);
+
+ fooProvider.stop();
+
+ id_dep = ((Architecture) context.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) context.getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 2", id_dep.getState() == ComponentInstance.VALID);
+
+ // Check service providing
+ cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Check CheckService availability", cs_ref);
+ cs = (CheckService) context.getService(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);
+
+ // Clean up
+ context.ungetService(arch_ref);
+ context.ungetService(cs_ref);
+ cs = null;
+ id_dep = null;
+ }
+
+
+}
Added: felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/ImmediateCallbackTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/ImmediateCallbackTest.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/ImmediateCallbackTest.java (added)
+++ felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/ImmediateCallbackTest.java Fri Apr 25 09:49:43 2008
@@ -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.test.scenarios.lifecycle.callback;
+
+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.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.lifecycle.callback.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.ServiceReference;
+
+public class ImmediateCallbackTest extends OSGiTestCase {
+
+ ComponentInstance instance; // Instance under test
+ ComponentInstance fooProvider;
+
+ public void setUp() {
+ Properties p2 = new Properties();
+ p2.put("name", "fooProvider");
+ fooProvider = Utils.getComponentInstance(context, "LFCB-FooProviderType-1", p2);
+ fooProvider.stop();
+
+ Properties p1 = new Properties();
+ p1.put("name", "callback");
+ instance = Utils.getComponentInstance(context, "LFCB-ImmediateCallbackCheckService", p1);
+
+ }
+
+ public void tearDown() {
+ instance.dispose();
+ fooProvider.dispose();
+ instance= null;
+ fooProvider = null;
+ }
+
+ public void testCallback() {
+ // Check instance is invalid
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ref);
+ InstanceDescription id_dep = ((Architecture) context.getService(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) context.getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 1", id_dep.getState() == ComponentInstance.VALID);
+
+ // Check service providing
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Check CheckService availability", cs_ref);
+ CheckService cs = (CheckService) context.getService(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.intValue() +")", index.intValue(), 1);
+
+ fooProvider.stop();
+
+ id_dep = ((Architecture) context.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) context.getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 2", id_dep.getState() == ComponentInstance.VALID);
+
+ // Check service providing
+ cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Check CheckService availability", cs_ref);
+ cs = (CheckService) context.getService(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);
+
+ // Clean up
+ context.ungetService(arch_ref);
+ context.ungetService(cs_ref);
+ cs = null;
+ id_dep = null;
+ }
+
+
+}
Added: felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/ImmediateLifeCycleControllerTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/ImmediateLifeCycleControllerTest.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/ImmediateLifeCycleControllerTest.java (added)
+++ felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/ImmediateLifeCycleControllerTest.java Fri Apr 25 09:49:43 2008
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.test.scenarios.lifecycle.callback;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.Factory;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.lifecycle.callback.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.ServiceReference;
+
+public class ImmediateLifeCycleControllerTest extends OSGiTestCase {
+
+ private ComponentInstance under;
+ private Factory factory;
+
+ public void setUp() {
+ factory = Utils.getFactoryByName(context, "LFC-Test-Immediate");
+ }
+
+ public void testOne() {
+ Properties props = new Properties();
+ props.put("conf", "foo");
+ props.put("name", "under");
+ under = Utils.getComponentInstance(context, "LFC-Test-Immediate", props);
+
+ // The conf is correct, the PS must be provided
+ ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), "under");
+ assertNotNull("Check service availability -1", ref);
+ CheckService cs = (CheckService) context.getService(ref);
+ assertTrue("Check state 1", cs.check());
+ context.ungetService(ref);
+ cs = null;
+
+ // 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 = Utils.getServiceReferenceByName(context, 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 = Utils.getServiceReferenceByName(context, CheckService.class.getName(), "under");
+ assertNotNull("Check service availability -3", ref);
+ cs = (CheckService) context.getService(ref);
+ assertTrue("Check state 2", cs.check());
+ context.ungetService(ref);
+ cs = null;
+
+ under.dispose();
+ }
+
+ public void testTwo() {
+ Properties props = new Properties();
+ props.put("conf", "bar");
+ props.put("name", "under");
+ under = Utils.getComponentInstance(context, "LFC-Test-Immediate", props);
+
+ assertEquals("check under state", under.getState(), ComponentInstance.INVALID);
+
+ // The conf is incorrect, the PS must not be provided
+ ServiceReference ref = Utils.getServiceReferenceByName(context, 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 = Utils.getServiceReferenceByName(context, CheckService.class.getName(), "under");
+ assertNotNull("Check service availability -2", ref);
+ CheckService cs = (CheckService) context.getService(ref);
+ assertTrue("Check state ", cs.check());
+ context.ungetService(ref);
+ cs = null;
+
+ under.dispose();
+ }
+
+
+
+}
Added: felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/LifeCycleCallbackTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/LifeCycleCallbackTest.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/LifeCycleCallbackTest.java (added)
+++ felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/LifeCycleCallbackTest.java Fri Apr 25 09:49:43 2008
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.test.scenarios.lifecycle.callback;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
+import org.osgi.framework.BundleContext;
+
+public class LifeCycleCallbackTest extends TestSuite {
+
+
+ public static Test suite(BundleContext bc) {
+ OSGiTestSuite ots = new OSGiTestSuite("Lifecycle callbacks Test Suite", bc);
+ ots.addTestSuite(CallbackTestCase.class);
+ ots.addTestSuite(ParentCallbackTestCase.class);
+ ots.addTestSuite(ImmediateCallbackTest.class);
+ ots.addTestSuite(ImmediateCallbackSingletonFactoryTest.class);
+ ots.addTestSuite(ImmediateCallbackSeveralFactoryTest.class);
+ return ots;
+ }
+
+}
+
Added: felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/ParentCallbackTestCase.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/ParentCallbackTestCase.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/ParentCallbackTestCase.java (added)
+++ felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/ParentCallbackTestCase.java Fri Apr 25 09:49:43 2008
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.test.scenarios.lifecycle.callback;
+
+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.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.lifecycle.callback.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.ServiceReference;
+
+public class ParentCallbackTestCase extends OSGiTestCase {
+
+ ComponentInstance instance; // Instance under test
+ ComponentInstance fooProvider;
+
+ public void setUp() {
+ Properties p2 = new Properties();
+ p2.put("name", "fooProvider");
+ fooProvider = Utils.getComponentInstance(context, "LFCB-FooProviderType-1", p2);
+ fooProvider.stop();
+
+ Properties p1 = new Properties();
+ p1.put("name", "callback");
+ instance = Utils.getComponentInstance(context, "LFCB-ParentCallbackCheckService", p1);
+
+ }
+
+ public void tearDown() {
+ instance.dispose();
+ fooProvider.dispose();
+ instance= null;
+ fooProvider = null;
+ }
+
+ public void testCallback() {
+ // Check instance is invalid
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ref);
+ InstanceDescription id_dep = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 1", id_dep.getState() == ComponentInstance.INVALID);
+
+ // Start fooprovider
+ fooProvider.start();
+
+ // Check instance validity
+ id_dep = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 1", id_dep.getState() == ComponentInstance.VALID);
+
+ // Check service providing
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Check CheckService availability", cs_ref);
+ CheckService cs = (CheckService) context.getService(cs_ref);
+
+ // Check int property
+ assertEquals("Check pojo count - 2", id_dep.getCreatedObjects().length, 1);
+
+ fooProvider.stop();
+
+ id_dep = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.INVALID);
+
+ fooProvider.start();
+
+ // Check instance validity
+ id_dep = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 2", id_dep.getState() == ComponentInstance.VALID);
+
+ // Check service providing
+ cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Check CheckService availability", cs_ref);
+ cs = (CheckService) context.getService(cs_ref);
+ assertTrue("check CheckService invocation", cs.check());
+
+ // Clean up
+ context.ungetService(arch_ref);
+ context.ungetService(cs_ref);
+ cs = null;
+ id_dep = null;
+ }
+
+
+}
Added: felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/service/CheckService.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/service/CheckService.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/service/CheckService.java (added)
+++ felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/service/CheckService.java Fri Apr 25 09:49:43 2008
@@ -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.test.scenarios.lifecycle.callback.service;
+
+import java.util.Properties;
+
+public interface CheckService {
+
+ public static final String foo = "foo";
+
+ public boolean check();
+
+ public Properties getProps();
+
+}
Added: felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/service/FooService.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/service/FooService.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/service/FooService.java (added)
+++ felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/callback/service/FooService.java Fri Apr 25 09:49:43 2008
@@ -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.test.scenarios.lifecycle.callback.service;
+
+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/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java (added)
+++ felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java Fri Apr 25 09:49:43 2008
@@ -0,0 +1,325 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.test.scenarios.util;
+
+import java.util.Dictionary;
+import java.util.Properties;
+
+import junit.framework.Assert;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.Factory;
+import org.apache.felix.ipojo.Handler;
+import org.apache.felix.ipojo.HandlerFactory;
+import org.apache.felix.ipojo.ServiceContext;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.cm.ManagedServiceFactory;
+
+public class Utils {
+
+ public static Factory getFactoryByName(BundleContext bc, String factoryName) {
+ ServiceReference[] refs;
+ try {
+ refs = bc.getServiceReferences(Factory.class.getName(), "(factory.name=" + factoryName + ")");
+ if (refs == null) {
+ System.err.println("Cannot get the factory " + factoryName);
+ return null;
+ }
+ return ((Factory) bc.getService(refs[0]));
+ } catch (InvalidSyntaxException e) {
+ System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
+ return null;
+ }
+ }
+
+ public static HandlerFactory getHandlerFactoryByName(BundleContext bc, String factoryName) {
+ ServiceReference[] refs;
+ try {
+ refs = bc.getServiceReferences(Factory.class.getName(), "(" + Handler.HANDLER_NAME_PROPERTY + "=" + factoryName + ")");
+ if (refs == null) {
+ System.err.println("Cannot get the factory " + factoryName);
+ return null;
+ }
+ return (HandlerFactory) bc.getService(refs[0]);
+ } catch (InvalidSyntaxException e) {
+ System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
+ return null;
+ }
+ }
+
+ public static ComponentInstance getComponentInstance(BundleContext bc, String factoryName, Dictionary configuration) {
+ Factory fact = getFactoryByName(bc, factoryName);
+
+ if (fact == null) {
+ System.err.println("Factory " + factoryName + " not found");
+ return null;
+ }
+
+ // if(fact.isAcceptable(configuration)) {
+ try {
+ return fact.createComponentInstance(configuration);
+ } catch (Exception e) {
+ e.printStackTrace();
+ Assert.fail("Cannot create the instance from " + factoryName + " : " + e.getMessage());
+ return null;
+ }
+ // }
+ // else {
+ // System.err.println("Configuration not accepted by : " + factoryName);
+ // return null;
+ // }
+ }
+
+ public static ComponentInstance getComponentInstanceByName(BundleContext bc, String factoryName, String name) {
+ Factory fact = getFactoryByName(bc, factoryName);
+
+ if (fact == null) {
+ System.err.println("Factory " + factoryName + " not found");
+ return null;
+ }
+
+ try {
+ Properties props = new Properties();
+ props.put("name", name);
+ return fact.createComponentInstance(props);
+ } catch (Exception e) {
+ System.err.println("Cannot create the instance from " + factoryName + " : " + e.getMessage());
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ public static ServiceReference[] getServiceReferences(BundleContext bc, String itf, String filter) {
+ ServiceReference[] refs = null;
+ try {
+ refs = bc.getServiceReferences(itf, filter);
+ } catch (InvalidSyntaxException e) {
+ System.err.println("Invalid Filter : " + filter);
+ }
+ if (refs == null) {
+ return new ServiceReference[0];
+ } else {
+ return refs;
+ }
+ }
+
+ public static ServiceReference getServiceReference(BundleContext bc, String itf, String filter) {
+ ServiceReference[] refs = null;
+ try {
+ refs = bc.getServiceReferences(itf, filter);
+ } catch (InvalidSyntaxException e) {
+ System.err.println("Invalid Filter : " + filter);
+ }
+ if (refs == null) {
+ return null;
+ } else {
+ return refs[0];
+ }
+ }
+
+ public static ServiceReference getServiceReferenceByName(BundleContext bc, String itf, String name) {
+ ServiceReference[] refs = null;
+ String filter = null;
+ if (itf.equals(Factory.class.getName()) || itf.equals(ManagedServiceFactory.class.getName())) {
+ filter = "(" + "factory.name" + "=" + name + ")";
+ } else {
+ filter = "(" + "instance.name" + "=" + name + ")";
+ }
+ try {
+ refs = bc.getServiceReferences(itf, filter);
+ } catch (InvalidSyntaxException e) {
+ System.err.println("Invalid Filter : " + filter);
+ }
+ if (refs == null) {
+ return null;
+ } else {
+ return refs[0];
+ }
+ }
+
+ public static ServiceReference getServiceReferenceByPID(BundleContext bc, String itf, String pid) {
+ ServiceReference[] refs = null;
+ String filter = "(" + "service.pid" + "=" + pid + ")";
+ try {
+ refs = bc.getServiceReferences(itf, filter);
+ } catch (InvalidSyntaxException e) {
+ System.err.println("Invalid Filter : " + filter);
+ }
+ if (refs == null) {
+ return null;
+ } else if (refs.length == 1) {
+ return refs[0];
+ } else {
+ Assert.fail("A service lookup by PID returned several providers (" + refs.length + ")" + " for " + itf + " with " + pid);
+ return null;
+ }
+ }
+
+ public static Object getServiceObject(BundleContext bc, String itf, String filter) {
+ ServiceReference ref = getServiceReference(bc, itf, filter);
+ if (ref != null) {
+ return bc.getService(ref);
+ } else {
+ return null;
+ }
+ }
+
+ public static Object[] getServiceObjects(BundleContext bc, String itf, String filter) {
+ ServiceReference[] refs = getServiceReferences(bc, itf, filter);
+ if (refs != null) {
+ Object[] list = new Object[refs.length];
+ for (int i = 0; i < refs.length; i++) {
+ list[i] = bc.getService(refs[i]);
+ }
+ return list;
+ } else {
+ return new Object[0];
+ }
+ }
+
+// public static ServiceContext getServiceContext(ComponentInstance ci) {
+// if (ci instanceof CompositeManager) {
+// return ((CompositeManager) ci).getServiceContext();
+// } else {
+// throw new RuntimeException("Cannot get the service context form an non composite instance");
+// }
+// }
+
+ public static Factory getFactoryByName(ServiceContext bc, String factoryName) {
+ ServiceReference[] refs;
+ try {
+ refs = bc.getServiceReferences(Factory.class.getName(), "(factory.name=" + factoryName + ")");
+ if (refs == null) { return null; }
+ return ((Factory) bc.getService(refs[0]));
+ } catch (InvalidSyntaxException e) {
+ System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
+ return null;
+ }
+ }
+
+ public static ComponentInstance getComponentInstance(ServiceContext bc, String factoryName, Dictionary configuration) {
+ Factory fact = getFactoryByName(bc, factoryName);
+
+ if (fact == null) { return null; }
+
+ if (fact.isAcceptable(configuration)) {
+ try {
+ return fact.createComponentInstance(configuration);
+ } catch (Exception e) {
+ System.err.println(e.getMessage());
+ e.printStackTrace();
+ return null;
+ }
+ } else {
+ System.err.println("Configuration not accepted by : " + factoryName);
+ return null;
+ }
+ }
+
+ public static ServiceReference[] getServiceReferences(ServiceContext bc, String itf, String filter) {
+ ServiceReference[] refs = null;
+ try {
+ refs = bc.getServiceReferences(itf, filter);
+ } catch (InvalidSyntaxException e) {
+ System.err.println("Invalid Filter : " + filter);
+ }
+ if (refs == null) {
+ return new ServiceReference[0];
+ } else {
+ return refs;
+ }
+ }
+
+ public static ServiceReference getServiceReference(ServiceContext bc, String itf, String filter) {
+ ServiceReference[] refs = null;
+ try {
+ refs = bc.getServiceReferences(itf, filter);
+ } catch (InvalidSyntaxException e) {
+ System.err.println("Invalid Filter : " + filter);
+ }
+ if (refs == null) {
+ return null;
+ } else {
+ return refs[0];
+ }
+ }
+
+ public static ServiceReference getServiceReferenceByName(ServiceContext bc, String itf, String name) {
+ ServiceReference[] refs = null;
+ String filter = null;
+ if (itf.equals(Factory.class.getName()) || itf.equals(ManagedServiceFactory.class.getName())) {
+ filter = "(" + "factory.name" + "=" + name + ")";
+ } else {
+ filter = "(" + "instance.name" + "=" + name + ")";
+ }
+ try {
+ refs = bc.getServiceReferences(itf, filter);
+ } catch (InvalidSyntaxException e) {
+ System.err.println("Invalid Filter : " + filter);
+ }
+ if (refs == null) {
+ return null;
+ } else {
+ return refs[0];
+ }
+ }
+
+ public static Object getServiceObject(ServiceContext bc, String itf, String filter) {
+ ServiceReference ref = getServiceReference(bc, itf, filter);
+ if (ref != null) {
+ return bc.getService(ref);
+ } else {
+ return null;
+ }
+ }
+
+ public static Object[] getServiceObjects(ServiceContext bc, String itf, String filter) {
+ ServiceReference[] refs = getServiceReferences(bc, itf, filter);
+ if (refs != null) {
+ Object[] list = new Object[refs.length];
+ for (int i = 0; i < refs.length; i++) {
+ list[i] = bc.getService(refs[i]);
+ }
+ return list;
+ } else {
+ return new Object[0];
+ }
+ }
+
+ public static boolean contains(String string, String[] array) {
+ for (int i = 0; array != null && i < array.length; i++) {
+ if (array[i] != null && array[i].equals(string)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static boolean contains(int value, int[] array) {
+ for (int i = 0; array != null && i < array.length; i++) {
+ if (array[i] == value) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
Added: felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/resources/metadata.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/resources/metadata.xml?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/resources/metadata.xml (added)
+++ felix/trunk/ipojo/tests/tests.core.lifecycle.callback/src/main/resources/metadata.xml Fri Apr 25 09:49:43 2008
@@ -0,0 +1,52 @@
+<ipojo>
+ <component
+ className="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"
+ factory="LFCB-FooProviderType-1" architecture="true">
+ <provides />
+ </component>
+
+ <!-- Lifecycle Callback -->
+ <component
+ className="org.apache.felix.ipojo.test.scenarios.component.CallbackCheckService"
+ factory="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.test.scenarios.component.CallbackCheckService"
+ factory="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.test.scenarios.component.CallbackCheckService"
+ immediate="true" factory="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.test.scenarios.component.CallbackCheckService"
+ immediate="true" factory="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.test.scenarios.component.CallbackCheckService"
+ immediate="true" factory="LFCB-ImmediateCallbackCheckServiceSeveral"
+ factory-method="several" architecture="true">
+ <requires field="fs" />
+ <provides />
+ <callback transition="validate" method="start" />
+ <callback transition="invalidate" method="stop" />
+ </component>
+</ipojo>
Propchange: felix/trunk/ipojo/tests/tests.core.lifecycle.controller/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr 25 09:49:43 2008
@@ -0,0 +1,9 @@
+target*
+bin*
+.settings*
+.classpath
+.project
+.checkstyle
+maven-eclipse.xml
+.externalToolBuilders
+
Added: felix/trunk/ipojo/tests/tests.core.lifecycle.controller/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.lifecycle.controller/pom.xml?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.lifecycle.controller/pom.xml (added)
+++ felix/trunk/ipojo/tests/tests.core.lifecycle.controller/pom.xml Fri Apr 25 09:49:43 2008
@@ -0,0 +1,102 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <packaging>bundle</packaging>
+ <name>iPOJO Lifecycle controller Test Suite</name>
+ <artifactId>tests.core.lifecycle.controller</artifactId>
+ <groupId>ipojo.tests</groupId>
+ <version>0.7.6-SNAPSHOT</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.ipojo</artifactId>
+ <version>0.7.6-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.ipojo.metadata</artifactId>
+ <version>0.7.6-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ </dependency>
+ <dependency>
+ <groupId>ipojo.examples</groupId>
+ <artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>
+ <version>0.7.6-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>1.4.0</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Export-Package>
+ org.apache.felix.ipojo.test.scenarios.lfc.service
+ </Export-Package>
+ <Bundle-SymbolicName>
+ ${pom.artifactId}
+ </Bundle-SymbolicName>
+ <Private-Package>
+ org.apache.felix.ipojo.test*
+ </Private-Package>
+ <Test-Suite>
+ org.apache.felix.ipojo.test.scenarios.lfc.LifeCycleControllerTestSuite
+ </Test-Suite>
+ </instructions>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-ipojo-plugin</artifactId>
+ <version>0.7.6-SNAPSHOT</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>ipojo-bundle</goal>
+ </goals>
+ <configuration>
+ <ignoreAnnotations>true</ignoreAnnotations>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.4</source>
+ <target>1.4</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added: felix/trunk/ipojo/tests/tests.core.lifecycle.controller/src/main/java/org/apache/felix/ipojo/test/scenarios/component/LifecycleControllerTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.lifecycle.controller/src/main/java/org/apache/felix/ipojo/test/scenarios/component/LifecycleControllerTest.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.lifecycle.controller/src/main/java/org/apache/felix/ipojo/test/scenarios/component/LifecycleControllerTest.java (added)
+++ felix/trunk/ipojo/tests/tests.core.lifecycle.controller/src/main/java/org/apache/felix/ipojo/test/scenarios/component/LifecycleControllerTest.java Fri Apr 25 09:49:43 2008
@@ -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.test.scenarios.component;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.test.scenarios.lfc.service.CheckService;
+
+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/tests/tests.core.lifecycle.controller/src/main/java/org/apache/felix/ipojo/test/scenarios/lfc/ImmediateLifeCycleControllerTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.lifecycle.controller/src/main/java/org/apache/felix/ipojo/test/scenarios/lfc/ImmediateLifeCycleControllerTest.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.lifecycle.controller/src/main/java/org/apache/felix/ipojo/test/scenarios/lfc/ImmediateLifeCycleControllerTest.java (added)
+++ felix/trunk/ipojo/tests/tests.core.lifecycle.controller/src/main/java/org/apache/felix/ipojo/test/scenarios/lfc/ImmediateLifeCycleControllerTest.java Fri Apr 25 09:49:43 2008
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.test.scenarios.lfc;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.Factory;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.lfc.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.ServiceReference;
+
+public class ImmediateLifeCycleControllerTest extends OSGiTestCase {
+
+ private ComponentInstance under;
+ private Factory factory;
+
+ public void setUp() {
+ factory = Utils.getFactoryByName(context, "LFC-Test-Immediate");
+ }
+
+ public void testOne() {
+ Properties props = new Properties();
+ props.put("conf", "foo");
+ props.put("name", "under");
+ under = Utils.getComponentInstance(context, "LFC-Test-Immediate", props);
+
+ // The conf is correct, the PS must be provided
+ ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), "under");
+ assertNotNull("Check service availability -1", ref);
+ CheckService cs = (CheckService) context.getService(ref);
+ assertTrue("Check state 1", cs.check());
+ context.ungetService(ref);
+ cs = null;
+
+ // 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 = Utils.getServiceReferenceByName(context, 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 = Utils.getServiceReferenceByName(context, CheckService.class.getName(), "under");
+ assertNotNull("Check service availability -3", ref);
+ cs = (CheckService) context.getService(ref);
+ assertTrue("Check state 2", cs.check());
+ context.ungetService(ref);
+ cs = null;
+
+ under.dispose();
+ }
+
+ public void testTwo() {
+ Properties props = new Properties();
+ props.put("conf", "bar");
+ props.put("name", "under");
+ under = Utils.getComponentInstance(context, "LFC-Test-Immediate", props);
+
+ assertEquals("check under state", under.getState(), ComponentInstance.INVALID);
+
+ // The conf is incorrect, the PS must not be provided
+ ServiceReference ref = Utils.getServiceReferenceByName(context, 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 = Utils.getServiceReferenceByName(context, CheckService.class.getName(), "under");
+ assertNotNull("Check service availability -2", ref);
+ CheckService cs = (CheckService) context.getService(ref);
+ assertTrue("Check state ", cs.check());
+ context.ungetService(ref);
+ cs = null;
+
+ under.dispose();
+ }
+
+
+
+}
Added: felix/trunk/ipojo/tests/tests.core.lifecycle.controller/src/main/java/org/apache/felix/ipojo/test/scenarios/lfc/LifeCycleControllerTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.lifecycle.controller/src/main/java/org/apache/felix/ipojo/test/scenarios/lfc/LifeCycleControllerTest.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.lifecycle.controller/src/main/java/org/apache/felix/ipojo/test/scenarios/lfc/LifeCycleControllerTest.java (added)
+++ felix/trunk/ipojo/tests/tests.core.lifecycle.controller/src/main/java/org/apache/felix/ipojo/test/scenarios/lfc/LifeCycleControllerTest.java Fri Apr 25 09:49:43 2008
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.test.scenarios.lfc;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.Factory;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.lfc.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * @author clement
+ *
+ */
+public class LifeCycleControllerTest extends OSGiTestCase {
+
+ private ComponentInstance under;
+
+ private Factory factory;
+
+ public void setUp() {
+ factory = Utils.getFactoryByName(context, "LFC-Test");
+ }
+
+ public void testOne() {
+ Properties props = new Properties();
+ props.put("conf", "foo");
+ props.put("name", "under");
+ under = Utils.getComponentInstance(context, "LFC-Test", props);
+
+ // The conf is correct, the PS must be provided
+ ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), "under");
+ assertNotNull("Check service availability -1", ref);
+ CheckService cs = (CheckService) context.getService(ref);
+ assertTrue("Check state 1", cs.check());
+ context.ungetService(ref);
+ cs = null;
+
+ // 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 = Utils.getServiceReferenceByName(context, 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 = Utils.getServiceReferenceByName(context, CheckService.class.getName(), "under");
+ assertNotNull("Check service availability -3", ref);
+ cs = (CheckService) context.getService(ref);
+ assertTrue("Check state 2", cs.check());
+ context.ungetService(ref);
+ cs = null;
+
+ under.dispose();
+ }
+
+ /**
+ * This test must be removed as it is not compliant with OSGi. It unregisters a service during the creation of the
+ * service instance, so the returned object is null.
+ */
+ public void notestTwo() {
+ Properties props = new Properties();
+ props.put("conf", "bar");
+ props.put("name", "under");
+ under = Utils.getComponentInstance(context, "LFC-Test", props);
+
+ // The conf is incorrect, but the test can appears only when the object is created : the PS must be provided
+ ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), "under");
+ assertNotNull("Check service availability -1", ref);
+
+ System.out.println("CS received : " + context.getService(ref));
+ CheckService cs = (CheckService) context.getService(ref);
+ assertNotNull("Assert CS not null", cs);
+ try {
+ assertFalse("Check state (false)", cs.check());
+ } catch (Throwable e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+
+ // As soon as the instance is created, the service has to disappear :
+ ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), "under");
+ assertNull("Check service availability -2", 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 = Utils.getServiceReferenceByName(context, CheckService.class.getName(), "under");
+ assertNotNull("Check service availability -3", ref);
+ cs = (CheckService) context.getService(ref);
+ assertTrue("Check state ", cs.check());
+ context.ungetService(ref);
+ cs = null;
+
+ under.dispose();
+ }
+
+}
Added: felix/trunk/ipojo/tests/tests.core.lifecycle.controller/src/main/java/org/apache/felix/ipojo/test/scenarios/lfc/LifeCycleControllerTestSuite.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.lifecycle.controller/src/main/java/org/apache/felix/ipojo/test/scenarios/lfc/LifeCycleControllerTestSuite.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.lifecycle.controller/src/main/java/org/apache/felix/ipojo/test/scenarios/lfc/LifeCycleControllerTestSuite.java (added)
+++ felix/trunk/ipojo/tests/tests.core.lifecycle.controller/src/main/java/org/apache/felix/ipojo/test/scenarios/lfc/LifeCycleControllerTestSuite.java Fri Apr 25 09:49:43 2008
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.test.scenarios.lfc;
+
+import junit.framework.Test;
+
+import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
+import org.osgi.framework.BundleContext;
+
+public class LifeCycleControllerTestSuite {
+
+
+ public static Test suite(BundleContext bc) {
+ OSGiTestSuite ots = new OSGiTestSuite("Lifecycle Controller Test Suite", bc);
+ ots.addTestSuite( LifeCycleControllerTest.class);
+ ots.addTestSuite( ImmediateLifeCycleControllerTest.class);
+ return ots;
+ }
+
+}
Added: felix/trunk/ipojo/tests/tests.core.lifecycle.controller/src/main/java/org/apache/felix/ipojo/test/scenarios/lfc/service/CheckService.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.lifecycle.controller/src/main/java/org/apache/felix/ipojo/test/scenarios/lfc/service/CheckService.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.lifecycle.controller/src/main/java/org/apache/felix/ipojo/test/scenarios/lfc/service/CheckService.java (added)
+++ felix/trunk/ipojo/tests/tests.core.lifecycle.controller/src/main/java/org/apache/felix/ipojo/test/scenarios/lfc/service/CheckService.java Fri Apr 25 09:49:43 2008
@@ -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.test.scenarios.lfc.service;
+
+import java.util.Properties;
+
+public interface CheckService {
+
+ public static final String foo = "foo";
+
+ public boolean check();
+
+ public Properties getProps();
+
+}