Added: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestUpdatedNoArgMethodAndManagedService.java URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestUpdatedNoArgMethodAndManagedService.java?rev=1445708&view=auto ============================================================================== --- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestUpdatedNoArgMethodAndManagedService.java (added) +++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestUpdatedNoArgMethodAndManagedService.java Wed Feb 13 16:26:18 2013 @@ -0,0 +1,327 @@ +/* + * 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.FooService; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.osgi.framework.ServiceReference; +import org.osgi.service.cm.ConfigurationException; +import org.osgi.service.cm.ManagedService; +import org.ow2.chameleon.testing.helpers.IPOJOHelper; +import org.ow2.chameleon.testing.helpers.OSGiHelper; + +import java.util.Hashtable; +import java.util.Properties; + +import static junit.framework.Assert.*; + + +public class TestUpdatedNoArgMethodAndManagedService extends Common { + + + + /** + * Instance where the ManagedServicePID is provided by the component type. + */ + ComponentInstance instance1; + /** + * Instance where the ManagedServicePID is provided by the instance. + */ + ComponentInstance instance2; + + /** + * Instance without configuration. + */ + ComponentInstance instance3; + + + + @Before + public void setUp() { + osgiHelper = new OSGiHelper(bc); + ipojoHelper = new IPOJOHelper(bc); + String type = "CONFIG-FooProviderType-4Updated2"; + Hashtable<String, String> p = new Hashtable<String, String>(); + p.put("instance.name", "instance"); + p.put("foo", "foo"); + p.put("bar", "2"); + p.put("baz", "baz"); + instance1 = ipojoHelper.createComponentInstance(type, p); + assertEquals("instance1 created", ComponentInstance.VALID, instance1.getState()); + + type = "CONFIG-FooProviderType-3Updated2"; + Hashtable<String, String> p1 = new Hashtable<String, String>(); + p1.put("instance.name", "instance-2"); + p1.put("foo", "foo"); + p1.put("bar", "2"); + p1.put("baz", "baz"); + p1.put("managed.service.pid", "instance"); + instance2 = ipojoHelper.createComponentInstance(type, p1); + + type = "CONFIG-FooProviderType-3Updated2"; + Hashtable<String, String> p2 = new Hashtable<String, String>(); + p2.put("instance.name", "instance-3"); + p2.put("managed.service.pid", "instance-3"); + instance3 = ipojoHelper.createComponentInstance(type, p2); + } + + @After + public void tearDown() { + instance1.dispose(); + instance2.dispose(); + instance3.dispose(); + instance1 = null; + instance2 = null; + instance3 = null; + } + + @Test + public void testStaticInstance1() { + ServiceReference fooRef = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance1.getInstanceName()); + assertNotNull("Check FS availability", fooRef); + String fooP = (String) fooRef.getProperty("foo"); + Integer barP = (Integer) fooRef.getProperty("bar"); + String bazP = (String) fooRef.getProperty("baz"); + assertEquals("Check foo equality -1", fooP, "foo"); + assertEquals("Check bar equality -1", barP, new Integer(2)); + assertEquals("Check baz equality -1", bazP, "baz"); + + ServiceReference msRef = osgiHelper.getServiceReferenceByPID(ManagedService.class.getName(), "FooProvider-3"); + assertNotNull("Check ManagedServiceFactory availability", msRef); + + // Configuration of baz + Properties conf = new Properties(); + conf.put("baz", "zab"); + conf.put("bar", new Integer(2)); + conf.put("foo", "foo"); + ManagedService ms = (ManagedService) osgiHelper.getServiceObject(msRef); + try { + ms.updated(conf); + } catch (ConfigurationException e) { + fail("Configuration Exception : " + e); + } + + // Re-check props + fooRef = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance1.getInstanceName()); + fooP = (String) fooRef.getProperty("foo"); + barP = (Integer) fooRef.getProperty("bar"); + bazP = (String) fooRef.getProperty("baz"); + assertEquals("Check foo equality -2", fooP, "foo"); + assertEquals("Check bar equality -2", barP, new Integer(2)); + assertEquals("Check baz equality -2", bazP, "zab"); + + // Get Service + FooService fs = (FooService) osgiHelper.getServiceObject(fooRef); + Integer updated = (Integer) fs.fooProps().get("updated"); + assertEquals("Check updated", 1, updated.intValue()); + } + + @Test + public void testStaticInstance2() { + ServiceReference fooRef = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance2.getInstanceName()); + assertNotNull("Check FS availability", fooRef); + String fooP = (String) fooRef.getProperty("foo"); + Integer barP = (Integer) fooRef.getProperty("bar"); + String bazP = (String) fooRef.getProperty("baz"); + assertEquals("Check foo equality -1", fooP, "foo"); + assertEquals("Check bar equality -1", barP, new Integer(2)); + assertEquals("Check baz equality -1", bazP, "baz"); + + ServiceReference msRef = osgiHelper.getServiceReferenceByPID(ManagedService.class.getName(), "instance"); + assertNotNull("Check ManagedService availability", msRef); + + + // Configuration of baz + Properties conf = new Properties(); + conf.put("baz", "zab"); + conf.put("bar", new Integer(2)); + conf.put("foo", "foo"); + ManagedService ms = (ManagedService) osgiHelper.getServiceObject(msRef); + try { + ms.updated(conf); + } catch (ConfigurationException e) { + fail("Configuration Exception : " + e); + } + + // Recheck props + fooRef = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance2.getInstanceName()); + fooP = (String) fooRef.getProperty("foo"); + barP = (Integer) fooRef.getProperty("bar"); + bazP = (String) fooRef.getProperty("baz"); + assertEquals("Check foo equality -2", fooP, "foo"); + assertEquals("Check bar equality -2", barP, new Integer(2)); + assertEquals("Check baz equality -2", bazP, "zab"); + + // Get Service + FooService fs = (FooService) osgiHelper.getServiceObject(fooRef); + Integer updated = (Integer) fs.fooProps().get("updated"); + + assertEquals("Check updated", 1, updated.intValue()); + + conf.put("baz", "zab2"); + conf.put("foo", "oof2"); + conf.put("bar", new Integer(0)); + ms = (ManagedService) osgiHelper.getServiceObject(msRef); + try { + ms.updated(conf); + } catch (ConfigurationException e) { + fail("Configuration Exception : " + e); + } + + updated = (Integer) fs.fooProps().get("updated"); + + assertEquals("Check updated -2", 2, updated.intValue()); + } + + @Test + public void testDynamicInstance1() { + ServiceReference fooRef = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance1.getInstanceName()); + assertNotNull("Check FS availability", fooRef); + + String fooP = (String) fooRef.getProperty("foo"); + Integer barP = (Integer) fooRef.getProperty("bar"); + String bazP = (String) fooRef.getProperty("baz"); + + assertEquals("Check foo equality", fooP, "foo"); + assertEquals("Check bar equality", barP, new Integer(2)); + assertEquals("Check baz equality", bazP, "baz"); + + ServiceReference msRef = osgiHelper.getServiceReferenceByPID(ManagedService.class.getName(), "FooProvider-3"); + assertNotNull("Check ManagedServiceFactory availability", msRef); + + // Configuration of baz + Properties conf = new Properties(); + conf.put("baz", "zab"); + conf.put("foo", "oof"); + conf.put("bar", new Integer(0)); + ManagedService ms = (ManagedService) osgiHelper.getServiceObject(msRef); + try { + ms.updated(conf); + } catch (ConfigurationException e) { + fail("Configuration Exception : " + e); + } + + // Re-check props + fooRef = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance1.getInstanceName()); + fooP = (String) fooRef.getProperty("foo"); + barP = (Integer) fooRef.getProperty("bar"); + bazP = (String) fooRef.getProperty("baz"); + + assertEquals("Check foo equality", fooP, "oof"); + assertEquals("Check bar equality", barP, new Integer(0)); + assertEquals("Check baz equality", bazP, "zab"); + + // Check field value + FooService fs = (FooService) osgiHelper.getServiceObject(fooRef); + Properties p = fs.fooProps(); + fooP = (String) p.get("foo"); + barP = (Integer) p.get("bar"); + + assertEquals("Check foo field equality", fooP, "oof"); + assertEquals("Check bar field equality", barP, new Integer(0)); + + Integer updated = (Integer) fs.fooProps().get("updated"); + + assertEquals("Check updated -1", 1, updated.intValue()); + + conf.put("baz", "zab2"); + conf.put("foo", "oof2"); + conf.put("bar", new Integer(0)); + ms = (ManagedService) osgiHelper.getServiceObject(msRef); + try { + ms.updated(conf); + } catch (ConfigurationException e) { + fail("Configuration Exception : " + e); + } + + updated = (Integer) fs.fooProps().get("updated"); + + assertEquals("Check updated -2", 2, updated.intValue()); + + } + + @Test + public void testDynamicInstance2() { + ServiceReference fooRef = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance2.getInstanceName()); + assertNotNull("Check FS availability", fooRef); + + String fooP = (String) fooRef.getProperty("foo"); + Integer barP = (Integer) fooRef.getProperty("bar"); + String bazP = (String) fooRef.getProperty("baz"); + + assertEquals("Check foo equality", fooP, "foo"); + assertEquals("Check bar equality", barP, new Integer(2)); + assertEquals("Check baz equality", bazP, "baz"); + + ServiceReference msRef = osgiHelper.getServiceReferenceByPID(ManagedService.class.getName(), "instance"); + assertNotNull("Check ManagedServiceFactory availability", msRef); + + // Configuration of baz + Properties conf = new Properties(); + conf.put("baz", "zab"); + conf.put("foo", "oof"); + conf.put("bar", new Integer(0)); + ManagedService ms = (ManagedService) osgiHelper.getServiceObject(msRef); + try { + ms.updated(conf); + } catch (ConfigurationException e) { + fail("Configuration Exception : " + e); + } + + // Recheck props + fooRef = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance2.getInstanceName()); + fooP = (String) fooRef.getProperty("foo"); + barP = (Integer) fooRef.getProperty("bar"); + bazP = (String) fooRef.getProperty("baz"); + + assertEquals("Check foo equality", fooP, "oof"); + assertEquals("Check bar equality", barP, new Integer(0)); + assertEquals("Check baz equality", bazP, "zab"); + + // Check field value + FooService fs = (FooService) osgiHelper.getServiceObject(fooRef); + Properties p = fs.fooProps(); + fooP = (String) p.get("foo"); + barP = (Integer) p.get("bar"); + + assertEquals("Check foo field equality", fooP, "oof"); + assertEquals("Check bar field equality", barP, new Integer(0)); + + Integer updated = (Integer) fs.fooProps().get("updated"); + + assertEquals("Check updated", 1, updated.intValue()); + + conf.put("baz", "zab2"); + conf.put("foo", "oof2"); + conf.put("bar", new Integer(0)); + ms = (ManagedService) osgiHelper.getServiceObject(msRef); + try { + ms.updated(conf); + } catch (ConfigurationException e) { + fail("Configuration Exception : " + e); + } + + updated = (Integer) fs.fooProps().get("updated"); + + assertEquals("Check updated -2", 2, updated.intValue()); + } +}
Added: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestUpdatedNoArgMethodAndManagedServiceFactory.java URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestUpdatedNoArgMethodAndManagedServiceFactory.java?rev=1445708&view=auto ============================================================================== --- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestUpdatedNoArgMethodAndManagedServiceFactory.java (added) +++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestUpdatedNoArgMethodAndManagedServiceFactory.java Wed Feb 13 16:26:18 2013 @@ -0,0 +1,317 @@ +/* + * 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.FooService; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.osgi.framework.ServiceReference; +import org.osgi.service.cm.ConfigurationException; +import org.osgi.service.cm.ManagedServiceFactory; +import org.ow2.chameleon.testing.helpers.IPOJOHelper; +import org.ow2.chameleon.testing.helpers.OSGiHelper; + +import java.util.Hashtable; +import java.util.Properties; + +import static org.junit.Assert.*; + + +public class TestUpdatedNoArgMethodAndManagedServiceFactory extends Common { + + + + ComponentInstance instance, instance2; + + + + @Before + public void setUp() { + osgiHelper = new OSGiHelper(bc); + ipojoHelper = new IPOJOHelper(bc); + String type = "CONFIG-FooProviderType-3Updated2"; + + Hashtable<String, String> p1 = new Hashtable<String, String>(); + p1.put("instance.name", "instance"); + p1.put("foo", "foo"); + p1.put("bar", "2"); + p1.put("baz", "baz"); + instance = ipojoHelper.createComponentInstance(type, p1); + + Hashtable<String, String> p2 = new Hashtable<String, String>(); + p2.put("instance.name", "instance2"); + + instance2 = ipojoHelper.createComponentInstance(type, p2); + } + + @After + public void tearDown() { + instance.dispose(); + instance2.dispose(); + instance2 = null; + instance = null; + } + + @Test + public void testStatic() { + + ServiceReference fooRef = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance.getInstanceName()); + assertNotNull("Check FS availability", fooRef); + String fooP = (String) fooRef.getProperty("foo"); + Integer barP = (Integer) fooRef.getProperty("bar"); + String bazP = (String) fooRef.getProperty("baz"); + assertEquals("Check foo equality -1", fooP, "foo"); + assertEquals("Check bar equality -1", barP, new Integer(2)); + assertEquals("Check baz equality -1", bazP, "baz"); + + ServiceReference msRef = ipojoHelper.getServiceReferenceByName(ManagedServiceFactory.class.getName(), instance.getFactory().getName()); + assertNotNull("Check ManagedServiceFactory availability", msRef); + + + // Configuration of baz + Properties conf = new Properties(); + conf.put("baz", "zab"); + conf.put("bar", new Integer(2)); + conf.put("foo", "foo"); + ManagedServiceFactory ms = (ManagedServiceFactory) osgiHelper.getServiceObject(msRef); + try { + ms.updated(instance.getInstanceName(), conf); + } catch (ConfigurationException e) { + fail("Configuration Exception : " + e); + } + + // Recheck props + fooRef = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance.getInstanceName()); + fooP = (String) fooRef.getProperty("foo"); + barP = (Integer) fooRef.getProperty("bar"); + bazP = (String) fooRef.getProperty("baz"); + assertEquals("Check foo equality -2", fooP, "foo"); + assertEquals("Check bar equality -2", barP, new Integer(2)); + assertEquals("Check baz equality -2", bazP, "zab"); + + // Get Service + FooService fs = (FooService) osgiHelper.getServiceObject(fooRef); + Integer updated = (Integer) fs.fooProps().get("updated"); + + assertEquals("Check updated", 1, updated.intValue()); + + } + + @Test + public void testStaticNoValue() { + ServiceReference fooRef = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance2.getInstanceName()); + assertNotNull("Check FS availability", fooRef); + Object fooP = fooRef.getProperty("foo"); + Object barP = fooRef.getProperty("bar"); + Object bazP = fooRef.getProperty("baz"); + assertEquals("Check foo equality -1", fooP, null); + assertEquals("Check bar equality -1", barP, null); + assertEquals("Check baz equality -1", bazP, null); + + ServiceReference msRef = ipojoHelper.getServiceReferenceByName(ManagedServiceFactory.class.getName(), instance2.getFactory().getName()); + assertNotNull("Check ManagedServiceFactory availability", msRef); + + + // Configuration of baz + Properties conf = new Properties(); + conf.put("baz", "zab"); + conf.put("bar", new Integer(2)); + conf.put("foo", "foo"); + ManagedServiceFactory ms = (ManagedServiceFactory) osgiHelper.getServiceObject(msRef); + try { + ms.updated(instance2.getInstanceName(), conf); + } catch (ConfigurationException e) { + fail("Configuration Exception : " + e); + } + + // Recheck props + fooRef = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance2.getInstanceName()); + fooP = (String) fooRef.getProperty("foo"); + barP = (Integer) fooRef.getProperty("bar"); + bazP = (String) fooRef.getProperty("baz"); + assertEquals("Check foo equality -2", fooP, "foo"); + assertEquals("Check bar equality -2", barP, new Integer(2)); + assertEquals("Check baz equality -2", bazP, "zab"); + + // Get Service + FooService fs = (FooService) osgiHelper.getServiceObject(fooRef); + Integer updated = (Integer) fs.fooProps().get("updated"); + + assertEquals("Check updated", 1, updated.intValue()); + } + + @Test + public void testDynamic() { + ServiceReference fooRef = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance.getInstanceName()); + assertNotNull("Check FS availability", fooRef); + + String fooP = (String) fooRef.getProperty("foo"); + Integer barP = (Integer) fooRef.getProperty("bar"); + String bazP = (String) fooRef.getProperty("baz"); + + assertEquals("Check foo equality", fooP, "foo"); + assertEquals("Check bar equality", barP, new Integer(2)); + assertEquals("Check baz equality", bazP, "baz"); + + ServiceReference msRef = ipojoHelper.getServiceReferenceByName(ManagedServiceFactory.class.getName(), instance.getFactory().getName()); + assertNotNull("Check ManagedServiceFactory availability", msRef); + + // Configuration of baz + Properties conf = new Properties(); + conf.put("baz", "zab"); + conf.put("foo", "oof"); + conf.put("bar", new Integer(0)); + ManagedServiceFactory ms = (ManagedServiceFactory) osgiHelper.getServiceObject(msRef); + try { + ms.updated(instance.getInstanceName(), conf); + } catch (ConfigurationException e) { + fail("Configuration Exception : " + e); + } + + // Recheck props + fooRef = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance.getInstanceName()); + fooP = (String) fooRef.getProperty("foo"); + barP = (Integer) fooRef.getProperty("bar"); + bazP = (String) fooRef.getProperty("baz"); + + assertEquals("Check foo equality", fooP, "oof"); + assertEquals("Check bar equality", barP, new Integer(0)); + assertEquals("Check baz equality", bazP, "zab"); + + // Check field value + FooService fs = (FooService) osgiHelper.getServiceObject(fooRef); + Properties p = fs.fooProps(); + fooP = (String) p.get("foo"); + barP = (Integer) p.get("bar"); + + assertEquals("Check foo field equality", fooP, "oof"); + assertEquals("Check bar field equality", barP, new Integer(0)); + + Integer updated = (Integer) fs.fooProps().get("updated"); + + assertEquals("Check updated", 1, updated.intValue()); + } + + @Test + public void testDynamicNoValue() { + ServiceReference fooRef = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance2.getInstanceName()); + assertNotNull("Check FS availability", fooRef); + + Object fooP = fooRef.getProperty("foo"); + Object barP = fooRef.getProperty("bar"); + Object bazP = fooRef.getProperty("baz"); + assertEquals("Check foo equality -1", fooP, null); + assertEquals("Check bar equality -1", barP, null); + assertEquals("Check baz equality -1", bazP, null); + + ServiceReference msRef = ipojoHelper.getServiceReferenceByName(ManagedServiceFactory.class.getName(), instance2.getFactory().getName()); + assertNotNull("Check ManagedServiceFactory availability", msRef); + + // Configuration of baz + Properties conf = new Properties(); + conf.put("baz", "zab"); + conf.put("foo", "oof"); + conf.put("bar", new Integer(0)); + ManagedServiceFactory ms = (ManagedServiceFactory) osgiHelper.getServiceObject(msRef); + try { + ms.updated(instance2.getInstanceName(), conf); + } catch (ConfigurationException e) { + fail("Configuration Exception : " + e); + } + + // Recheck props + fooRef = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance2.getInstanceName()); + fooP = (String) fooRef.getProperty("foo"); + barP = (Integer) fooRef.getProperty("bar"); + bazP = (String) fooRef.getProperty("baz"); + + assertEquals("Check foo equality", fooP, "oof"); + assertEquals("Check bar equality", barP, new Integer(0)); + assertEquals("Check baz equality", bazP, "zab"); + + // Check field value + FooService fs = (FooService) osgiHelper.getServiceObject(fooRef); + Properties p = fs.fooProps(); + fooP = (String) p.get("foo"); + barP = (Integer) p.get("bar"); + + assertEquals("Check foo field equality", fooP, "oof"); + assertEquals("Check bar field equality", barP, new Integer(0)); + + Integer updated = (Integer) fs.fooProps().get("updated"); + + assertEquals("Check updated", 1, updated.intValue()); + } + + + @Test + public void testDynamicString() { + ServiceReference fooRef = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance.getInstanceName()); + assertNotNull("Check FS availability", fooRef); + + String fooP = (String) fooRef.getProperty("foo"); + Integer barP = (Integer) fooRef.getProperty("bar"); + String bazP = (String) fooRef.getProperty("baz"); + + assertEquals("Check foo equality", fooP, "foo"); + assertEquals("Check bar equality", barP, new Integer(2)); + assertEquals("Check baz equality", bazP, "baz"); + + ServiceReference msRef = ipojoHelper.getServiceReferenceByName(ManagedServiceFactory.class.getName(), instance.getFactory().getName()); + assertNotNull("Check ManagedServiceFactory availability", msRef); + + // Configuration of baz + Properties conf = new Properties(); + conf.put("baz", "zab"); + conf.put("foo", "oof"); + conf.put("bar", "0"); + ManagedServiceFactory ms = (ManagedServiceFactory) osgiHelper.getServiceObject(msRef); + try { + ms.updated(instance.getInstanceName(), conf); + } catch (ConfigurationException e) { + fail("Configuration Exception : " + e); + } + + // Recheck props + fooRef = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance.getInstanceName()); + fooP = (String) fooRef.getProperty("foo"); + barP = (Integer) fooRef.getProperty("bar"); + bazP = (String) fooRef.getProperty("baz"); + + assertEquals("Check foo equality", fooP, "oof"); + assertEquals("Check bar equality", barP, new Integer(0)); + assertEquals("Check baz equality", bazP, "zab"); + + // Check field value + FooService fs = (FooService) osgiHelper.getServiceObject(fooRef); + Properties p = fs.fooProps(); + fooP = (String) p.get("foo"); + barP = (Integer) p.get("bar"); + + assertEquals("Check foo field equality", fooP, "oof"); + assertEquals("Check bar field equality", barP, new Integer(0)); + + Integer updated = (Integer) fs.fooProps().get("updated"); + + assertEquals("Check updated", 1, updated.intValue()); + } + +} Added: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/resources/exam.properties URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/resources/exam.properties?rev=1445708&view=auto ============================================================================== (empty) Added: felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/untitled.iml URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/untitled.iml?rev=1445708&view=auto ============================================================================== --- felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/untitled.iml (added) +++ felix/trunk/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/untitled.iml Wed Feb 13 16:26:18 2013 @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> + <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6" inherit-compiler-output="false"> + <output url="file://$MODULE_DIR$/target/classes" /> + <output-test url="file://$MODULE_DIR$/target/test-classes" /> + <content url="file://$MODULE_DIR$"> + <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/src/main/resources" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" /> + <sourceFolder url="file://$MODULE_DIR$/src/test/resources" isTestSource="true" /> + <excludeFolder url="file://$MODULE_DIR$/target" /> + </content> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + <orderEntry type="library" scope="TEST" name="Maven: org.ops4j.pax.exam:pax-exam-container-native:3.0.0" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.ops4j.pax.exam:pax-exam:3.0.0" level="project" /> + <orderEntry type="library" name="Maven: org.ops4j.base:ops4j-base-lang:1.4.0" level="project" /> + <orderEntry type="library" name="Maven: org.ops4j.base:ops4j-base-store:1.2.3" level="project" /> + <orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.5.11" level="project" /> + <orderEntry type="library" name="Maven: org.ops4j.base:ops4j-base-io:1.2.3" level="project" /> + <orderEntry type="library" name="Maven: org.ops4j.base:ops4j-base-monitors:1.4.0" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.ops4j.base:ops4j-base-util-property:1.4.0" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.ops4j.pax.exam:pax-exam-spi:3.0.0" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.ops4j.base:ops4j-base-spi:1.4.0" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: com.google.guava:guava:12.0" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: com.google.code.findbugs:jsr305:1.3.9" level="project" /> + <orderEntry type="library" name="Maven: org.ops4j.pax.tinybundles:tinybundles:1.0.0" level="project" /> + <orderEntry type="library" name="Maven: biz.aQute:bndlib:1.43.0" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.glassfish.main.common:scattered-archive-api:3.1.2.2" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.ops4j.pax.swissbox:pax-swissbox-core:1.6.0" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.ops4j.pax.swissbox:pax-swissbox-lifecycle:1.6.0" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.ops4j.pax.swissbox:pax-swissbox-tracker:1.6.0" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.ops4j.base:ops4j-base-net:1.4.0" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.ops4j.pax.url:pax-url-link:1.5.0" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.ops4j.pax.url:pax-url-commons:1.5.1" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.ops4j.pax.swissbox:pax-swissbox-property:1.5.0" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.ops4j.pax.url:pax-url-classpath:1.5.0" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.ops4j.pax.swissbox:pax-swissbox-optional-jcl:1.5.0" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.ops4j.pax.exam:pax-exam-junit4:3.0.0" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.9" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.ops4j.pax.exam:pax-exam-link-mvn:3.0.0" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.ops4j.pax.url:pax-url-aether:1.5.1" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.ops4j.pax.url:pax-url-maven-commons:1.5.1" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.ops4j.base:ops4j-base-util-xml:1.3.0" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.ops4j.base:ops4j-base-util-collections:1.3.0" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.sonatype.aether:aether-api:1.13.1" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.sonatype.aether:aether-spi:1.13.1" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.sonatype.aether:aether-util:1.13.1" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.sonatype.aether:aether-impl:1.13.1" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.sonatype.aether:aether-connector-wagon:1.13.1" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.apache.maven.wagon:wagon-provider-api:1.0-beta-7" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.codehaus.plexus:plexus-utils:3.0" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.codehaus.plexus:plexus-classworlds:2.4" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.sonatype.sisu:sisu-inject-plexus:2.2.3" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.codehaus.plexus:plexus-component-annotations:1.5.5" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.sonatype.sisu:sisu-inject-bean:2.2.3" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.sonatype.sisu:sisu-guice:no_aop:3.0.3" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.apache.maven:maven-aether-provider:3.0.4" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.apache.maven:maven-model:3.0.4" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.apache.maven:maven-model-builder:3.0.4" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.codehaus.plexus:plexus-interpolation:1.14" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.apache.maven:maven-repository-metadata:3.0.4" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.apache.maven.wagon:wagon-file:1.0-beta-7" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.apache.maven.wagon:wagon-http-lightweight:1.0-beta-7" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.apache.maven.wagon:wagon-http-shared:1.0-beta-7" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.codehaus.plexus:plexus-container-default:1.5.5" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.apache.xbean:xbean-reflect:3.4" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: com.google.collections:google-collections:1.0" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: commons-httpclient:commons-httpclient:3.1" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: commons-codec:commons-codec:1.2" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: commons-logging:commons-logging:1.0.4" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.apache.felix:org.apache.felix.framework:3.2.2" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: ch.qos.logback:logback-core:0.9.20" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: ch.qos.logback:logback-classic:0.9.20" level="project" /> + <orderEntry type="library" name="Maven: org.apache.felix:org.apache.felix.ipojo:1.9.0-SNAPSHOT" level="project" /> + <orderEntry type="library" name="Maven: org.osgi:org.osgi.core:4.3.1" level="project" /> + <orderEntry type="library" name="Maven: org.osgi:org.osgi.compendium:4.0.0" level="project" /> + <orderEntry type="library" name="Maven: org.apache.felix:org.apache.felix.ipojo.metadata:1.6.0" level="project" /> + <orderEntry type="library" name="Maven: org.apache.felix:org.apache.felix.ipojo.manipulator:1.9.0-SNAPSHOT" level="project" /> + <orderEntry type="library" name="Maven: asm:asm-all:3.3.1" level="project" /> + <orderEntry type="library" name="Maven: org.apache.felix:org.apache.felix.ipojo.annotations:1.8.0" level="project" /> + <orderEntry type="library" name="Maven: commons-io:commons-io:2.4" level="project" /> + <orderEntry type="module" module-name="osgi-helpers" scope="TEST" /> + <orderEntry type="module" module-name="tinybundles-ipojo" /> + <orderEntry type="library" name="Maven: xerces:xercesImpl:2.4.0" level="project" /> + </component> +</module> +
