Split the iPOJO test suite in several bundles.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@651646 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/tests/tests.core.configuration/pom.xml b/ipojo/tests/tests.core.configuration/pom.xml
new file mode 100644
index 0000000..d308dfc
--- /dev/null
+++ b/ipojo/tests/tests.core.configuration/pom.xml
@@ -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 Configuration Management Test Suite</name>
+ <artifactId>tests.core.configuration</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.configuration.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.configuration.ConfigurationTestSuite
+ </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>
diff --git a/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckProviderParentClass.java b/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckProviderParentClass.java
new file mode 100644
index 0000000..11bf266
--- /dev/null
+++ b/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckProviderParentClass.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.test.scenarios.component;
+
+import org.apache.felix.ipojo.test.scenarios.configuration.service.FooService;
+import org.osgi.framework.ServiceReference;
+
+public abstract class CheckProviderParentClass {
+
+ int simpleU = 0;
+ int objectU = 0;
+ int refU = 0;
+ int bothU = 0;
+
+
+ public void bothUnbind(FooService o, ServiceReference sr) {
+ if(sr != null && o != null && o instanceof FooService) { bothU++; }
+ }
+
+ public void refUnbind(ServiceReference sr) {
+ if(sr != null) { refU++; }
+ }
+
+ public void objectUnbind(FooService o) {
+ if(o != null && o instanceof FooService) { objectU++; }
+ else {
+ System.err.println("Unbind null : " + o);
+ }
+ }
+
+ public void voidUnbind() {
+ simpleU++;
+ }
+
+}
diff --git a/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java b/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java
new file mode 100644
index 0000000..5b2494e
--- /dev/null
+++ b/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java
@@ -0,0 +1,83 @@
+/*
+ * 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.configuration.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.configuration.service.FooService;
+import org.osgi.framework.ServiceReference;
+
+public class CheckServiceProvider extends CheckProviderParentClass implements CheckService {
+
+ FooService fs;
+
+ int simpleB = 0;
+ int objectB = 0;
+ int refB = 0;
+ int bothB = 0;
+
+ public boolean check() {
+ return fs.foo();
+ }
+
+ public Properties getProps() {
+ Properties props = new Properties();
+ props.put("voidB", new Integer(simpleB));
+ props.put("objectB", new Integer(objectB));
+ props.put("refB", new Integer(refB));
+ props.put("bothB", new Integer(bothB));
+ props.put("voidU", new Integer(simpleU));
+ props.put("objectU", new Integer(objectU));
+ props.put("refU", new Integer(refU));
+ props.put("bothU", new Integer(bothU));
+ if (fs != null) {
+ props.put("result", new Boolean(fs.foo()));
+ props.put("boolean", new Boolean(fs.getBoolean()));
+ props.put("int", new Integer(fs.getInt()));
+ props.put("long", new Long(fs.getLong()));
+ props.put("double", new Double(fs.getDouble()));
+ if(fs.getObject() != null) { props.put("object", fs.getObject()); }
+ }
+ props.put("static", CheckService.foo);
+ props.put("class", CheckService.class.getName());
+ return props;
+ }
+
+ private void voidBind() {
+ simpleB++;
+ }
+
+ protected void objectBind(FooService o) {
+ if (o == null) {
+ System.err.println("Bind receive null !!! ");
+ return;
+ }
+ if(o != null && o instanceof FooService) { objectB++; }
+ }
+
+ public void refBind(ServiceReference sr) {
+ if(sr != null) { refB++; }
+ }
+
+ public void bothBind(FooService o, ServiceReference sr) {
+ if(sr != null && o != null && o instanceof FooService) { bothB++; }
+ }
+
+}
diff --git a/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ConfigurableCheckServiceProvider.java b/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ConfigurableCheckServiceProvider.java
new file mode 100644
index 0000000..c018a54
--- /dev/null
+++ b/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ConfigurableCheckServiceProvider.java
@@ -0,0 +1,202 @@
+/*
+ * 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.configuration.service.CheckService;
+
+public class ConfigurableCheckServiceProvider implements CheckService {
+
+ // Integer types
+ byte b;
+ short s;
+ int i;
+ long l;
+
+ // Floatting types
+ double d;
+ float f;
+
+ // Character
+ char c;
+
+ // Boolean
+ boolean bool;
+
+ // Integer arrays
+ byte[] bs;
+ short[] ss;
+ int[] is;
+ long[] ls;
+
+ double[] ds;
+ float[] fs;
+
+ char[] cs;
+
+ boolean[] bools;
+
+ String string;
+ String[] strings;
+
+ int upB, upS, upI, upL, upD, upF, upC, upBool, upBs, upSs, upIs, upLs, upDs, upFs, upCs, upBools, upString, upStrings;
+
+
+ public boolean check() {
+ return true;
+ }
+
+ public Properties getProps() {
+ Properties props = new Properties();
+ props.put("b", new Byte(b));
+ props.put("s", new Short(s));
+ props.put("i", new Integer(i));
+ props.put("l", new Long(l));
+ props.put("d", new Double(d));
+ props.put("f", new Float(f));
+ props.put("c", new Character(c));
+ props.put("bool", new Boolean(bool));
+
+ props.put("bs", bs);
+ props.put("ss", ss);
+ props.put("is", is);
+ props.put("ls", ls);
+ props.put("ds", ds);
+ props.put("fs", fs);
+ props.put("cs", cs);
+ props.put("bools", bools);
+
+ props.put("upb", new Integer(upB));
+ props.put("ups", new Integer(upS));
+ props.put("upi", new Integer(upI));
+ props.put("upl", new Integer(upL));
+ props.put("upd", new Integer(upD));
+ props.put("upf", new Integer(upF));
+ props.put("upc", new Integer(upC));
+ props.put("upbool", new Integer(upBool));
+
+ props.put("upbs", new Integer(upBs));
+ props.put("upss", new Integer(upSs));
+ props.put("upis", new Integer(upIs));
+ props.put("upls", new Integer(upLs));
+ props.put("upds", new Integer(upDs));
+ props.put("upfs", new Integer(upFs));
+ props.put("upcs", new Integer(upCs));
+ props.put("upbools", new Integer(upBools));
+
+ props.put("string", string);
+ props.put("strings", strings);
+ props.put("upstring", new Integer(upString));
+ props.put("upstrings", new Integer(upStrings));
+
+ return props;
+ }
+
+ public void updateB(byte bb) {
+ b = bb;
+ upB++;
+ }
+
+ public void updateS(short bb) {
+ s = bb;
+ upS++;
+ }
+
+ public void updateI(int bb) {
+ i = bb;
+ upI++;
+ }
+
+ public void updateL(long bb) {
+ l = bb;
+ upL++;
+ }
+
+ public void updateD(double bb) {
+ d = bb;
+ upD++;
+ }
+
+ public void updateF(float bb) {
+ f = bb;
+ upF++;
+ }
+
+ public void updateC(char bb) {
+ c = bb;
+ upC++;
+ }
+
+ public void updateBool(boolean bb) {
+ bool = bb;
+ upBool++;
+ }
+
+ public void updateBs(byte[] bb) {
+ bs = bb;
+ upBs++;
+ }
+
+ public void updateSs(short[] bb) {
+ ss = bb;
+ upSs++;
+ }
+
+ public void updateIs(int[] bb) {
+ is = bb;
+ upIs++;
+ }
+
+ public void updateLs(long[] bb) {
+ ls = bb;
+ upLs++;
+ }
+
+ public void updateDs(double[] bb) {
+ ds = bb;
+ upDs++;
+ }
+
+ public void updateFs(float[] bb) {
+ fs = bb;
+ upFs++;
+ }
+
+ public void updateCs(char[] bb) {
+ cs = bb;
+ upCs++;
+ }
+
+ public void updateBools(boolean[] bb) {
+ bools = bb;
+ upBools++;
+ }
+
+ public void updateStrings(String[] bb) {
+ strings = bb;
+ upStrings++;
+ }
+
+ public void updateString(String bb) {
+ string = bb;
+ upString++;
+ }
+
+}
diff --git a/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java b/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java
new file mode 100644
index 0000000..32d2fd9
--- /dev/null
+++ b/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.test.scenarios.component;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.test.scenarios.configuration.service.FooService;
+import org.osgi.framework.BundleContext;
+
+public class FooProviderType1 implements FooService {
+
+ private int m_bar;
+ private String m_foo;
+
+ private BundleContext m_context;
+
+ private static FooProviderType1 singleton;
+ private static int count = 0;
+
+ private static FooProviderType1 singleton(BundleContext bc) {
+ if (singleton == null) {
+ count++;
+ singleton = new FooProviderType1(bc);
+ }
+ return singleton;
+ }
+
+ public static FooProviderType1 several(BundleContext bc) {
+ count++;
+ return new FooProviderType1(bc);
+ }
+
+ public FooProviderType1(BundleContext bc) {
+ if (bc ==null) {
+ throw new RuntimeException("Injected bundle context null");
+ }
+ m_context = bc;
+ }
+
+ public boolean foo() {
+ return true;
+ }
+
+ public Properties fooProps() {
+ Properties p = new Properties();
+ p.put("bar", new Integer(m_bar));
+ if(m_foo != null) {
+ p.put("foo", m_foo);
+ }
+ p.put("context", m_context);
+
+ p.put("count", new Integer(count));
+ return p;
+ }
+
+ public void testException() throws Exception {
+ String a = "foobarbaz";
+ throw new Exception("foo"+a);
+ }
+
+ public void testTry() {
+ String a = "foo";
+ a.charAt(0);
+ }
+
+ public void testTry2(String s) {
+ String a = "foo";
+ a.charAt(0);
+ }
+
+ private void nexttry(String s) {
+ try {
+ s += "foo";
+ } catch(RuntimeException e) {
+
+ }
+ }
+
+ public boolean getBoolean() { return true; }
+
+ public double getDouble() { return 1.0; }
+
+ public int getInt() { return 1; }
+
+ public long getLong() { return 1; }
+
+ public Boolean getObject() { return new Boolean(true); }
+
+ /**
+ * Custom constructor.
+ * @param bar
+ * @param foo
+ * @param bc
+ */
+ public FooProviderType1(int bar, String foo, BundleContext bc) {
+ m_bar = bar;
+ m_foo = foo;
+ m_context = bc;
+ }
+
+}
diff --git a/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderTypeDyn.java b/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderTypeDyn.java
new file mode 100644
index 0000000..6266e30
--- /dev/null
+++ b/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderTypeDyn.java
@@ -0,0 +1,63 @@
+/*
+ * 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.configuration.service.FooService;
+
+public class FooProviderTypeDyn implements FooService {
+
+ private int intProp;
+ private String strProp;
+ private String[] strAProp;
+ private int[] intAProp;
+ private boolean boolProp;
+
+ public boolean foo() {
+ intProp = 3;
+ boolProp = true;
+ if(strProp.equals("foo")) { strProp = "bar"; }
+ else { strProp = "foo"; }
+ strAProp = new String[] {"foo", "bar", "baz"};
+ intAProp = new int[] {3, 2, 1};
+ return true;
+ }
+
+ public Properties fooProps() {
+ Properties p = new Properties();
+ p.put("intProp", new Integer(intProp));
+ p.put("boolProp", new Boolean(boolProp));
+ p.put("strProp", strProp);
+ p.put("strAProp", strAProp);
+ p.put("intAProp", intAProp);
+ return p;
+ }
+
+ public boolean getBoolean() { return true; }
+
+ public double getDouble() { return 1.0; }
+
+ public int getInt() { return 1; }
+
+ public long getLong() { return 1; }
+
+ public Boolean getObject() { return new Boolean(true); }
+
+}
diff --git a/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClass.java b/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClass.java
new file mode 100644
index 0000000..f7fb580
--- /dev/null
+++ b/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentClass.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.test.scenarios.component;
+
+public class ParentClass {
+
+ public void parentStart() {
+
+ }
+
+ public void parentStop() {
+
+ }
+
+ protected String[] strings;
+
+ protected String string;
+
+ protected int upStrings;
+
+ protected int upString;
+
+ public void updateStrings(String[] bb) {
+ strings = bb;
+ upStrings++;
+ }
+
+ public void updateString(String bb) {
+ string = bb;
+ upString++;
+ }
+
+
+
+}
diff --git a/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentConfigurableCheckServiceProvider.java b/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentConfigurableCheckServiceProvider.java
new file mode 100644
index 0000000..1dc7212
--- /dev/null
+++ b/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ParentConfigurableCheckServiceProvider.java
@@ -0,0 +1,194 @@
+/*
+ * 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.configuration.service.CheckService;
+
+public class ParentConfigurableCheckServiceProvider extends ParentClass implements CheckService {
+
+ // Integer types
+ byte b;
+ short s;
+ int i;
+ long l;
+
+ // Floatting types
+ double d;
+ float f;
+
+ // Character
+ char c;
+
+ // Boolean
+ boolean bool;
+
+ // Integer arrays
+ byte[] bs;
+ short[] ss;
+ int[] is;
+ long[] ls;
+
+ double[] ds;
+ float[] fs;
+
+ char[] cs;
+
+ boolean[] bools;
+
+ //String string;
+ //String[] strings;
+
+ int upB, upS, upI, upL, upD, upF, upC, upBool, upBs, upSs, upIs, upLs, upDs, upFs, upCs, upBools/*, upString, upStrings*/;
+
+
+ public boolean check() {
+ return true;
+ }
+
+ public Properties getProps() {
+ Properties props = new Properties();
+ props.put("b", new Byte(b));
+ props.put("s", new Short(s));
+ props.put("i", new Integer(i));
+ props.put("l", new Long(l));
+ props.put("d", new Double(d));
+ props.put("f", new Float(f));
+ props.put("c", new Character(c));
+ props.put("bool", new Boolean(bool));
+
+ props.put("bs", bs);
+ props.put("ss", ss);
+ props.put("is", is);
+ props.put("ls", ls);
+ props.put("ds", ds);
+ props.put("fs", fs);
+ props.put("cs", cs);
+ props.put("bools", bools);
+
+ props.put("upb", new Integer(upB));
+ props.put("ups", new Integer(upS));
+ props.put("upi", new Integer(upI));
+ props.put("upl", new Integer(upL));
+ props.put("upd", new Integer(upD));
+ props.put("upf", new Integer(upF));
+ props.put("upc", new Integer(upC));
+ props.put("upbool", new Integer(upBool));
+
+ props.put("upbs", new Integer(upBs));
+ props.put("upss", new Integer(upSs));
+ props.put("upis", new Integer(upIs));
+ props.put("upls", new Integer(upLs));
+ props.put("upds", new Integer(upDs));
+ props.put("upfs", new Integer(upFs));
+ props.put("upcs", new Integer(upCs));
+ props.put("upbools", new Integer(upBools));
+
+ props.put("string", string);
+ props.put("strings", strings);
+ props.put("upstring", new Integer(upString));
+ props.put("upstrings", new Integer(upStrings));
+
+ return props;
+ }
+
+ public void updateB(byte bb) {
+ b = bb;
+ upB++;
+ }
+
+ public void updateS(short bb) {
+ s = bb;
+ upS++;
+ }
+
+ public void updateI(int bb) {
+ i = bb;
+ upI++;
+ }
+
+ public void updateL(long bb) {
+ l = bb;
+ upL++;
+ }
+
+ public void updateD(double bb) {
+ d = bb;
+ upD++;
+ }
+
+ public void updateF(float bb) {
+ f = bb;
+ upF++;
+ }
+
+ public void updateC(char bb) {
+ c = bb;
+ upC++;
+ }
+
+ public void updateBool(boolean bb) {
+ bool = bb;
+ upBool++;
+ }
+
+ public void updateBs(byte[] bb) {
+ bs = bb;
+ upBs++;
+ }
+
+ public void updateSs(short[] bb) {
+ ss = bb;
+ upSs++;
+ }
+
+ public void updateIs(int[] bb) {
+ is = bb;
+ upIs++;
+ }
+
+ public void updateLs(long[] bb) {
+ ls = bb;
+ upLs++;
+ }
+
+ public void updateDs(double[] bb) {
+ ds = bb;
+ upDs++;
+ }
+
+ public void updateFs(float[] bb) {
+ fs = bb;
+ upFs++;
+ }
+
+ public void updateCs(char[] bb) {
+ cs = bb;
+ upCs++;
+ }
+
+ public void updateBools(boolean[] bb) {
+ bools = bb;
+ upBools++;
+ }
+
+
+
+}
diff --git a/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/ConfigurationTestSuite.java b/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/ConfigurationTestSuite.java
new file mode 100644
index 0000000..60796bc
--- /dev/null
+++ b/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/ConfigurationTestSuite.java
@@ -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.configuration;
+
+import junit.framework.Test;
+
+import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
+import org.osgi.framework.BundleContext;
+
+public class ConfigurationTestSuite {
+
+ public static Test suite(BundleContext bc) {
+ OSGiTestSuite ots = new OSGiTestSuite("Configuration Test Suite", bc);
+ ots.addTestSuite(SimpleProperties.class);
+ ots.addTestSuite(DynamicallyConfigurableProperties.class);
+ ots.addTestSuite(TestFieldProperties.class);
+ ots.addTestSuite(TestMethodProperties.class);
+ ots.addTestSuite(TestBothProperties.class);
+ ots.addTestSuite(TestSuperMethodProperties.class);
+ ots.addTestSuite(ManagedServiceConfigurableProperties.class);
+
+ return ots;
+ }
+
+}
diff --git a/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/DynamicallyConfigurableProperties.java b/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/DynamicallyConfigurableProperties.java
new file mode 100644
index 0000000..b7fbb6c
--- /dev/null
+++ b/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/DynamicallyConfigurableProperties.java
@@ -0,0 +1,228 @@
+/*
+ * 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.configuration;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.configuration.service.FooService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.cm.ManagedServiceFactory;
+
+public class DynamicallyConfigurableProperties extends OSGiTestCase {
+
+ ComponentInstance instance;
+
+ public void setUp() {
+ String type = "CONFIG-FooProviderType-3";
+
+ Properties p1 = new Properties();
+ p1.put("name", "instance");
+ p1.put("foo", "foo");
+ p1.put("bar", "2");
+ p1.put("baz", "baz");
+ instance = Utils.getComponentInstance(context, type, p1);
+ }
+
+ public void tearDown() {
+ instance.dispose();
+ instance = null;
+ }
+
+ public void testStatic() {
+ ServiceReference fooRef = Utils.getServiceReferenceByName(context, 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 = Utils.getServiceReferenceByName(context, 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) context.getService(msRef);
+ try {
+ ms.updated(instance.getInstanceName(), conf);
+ } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
+
+ // Recheck props
+ fooRef = Utils.getServiceReferenceByName(context, 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");
+ context.ungetService(msRef);
+ }
+
+ public void testDynamic() {
+ ServiceReference fooRef = Utils.getServiceReferenceByName(context, 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 = Utils.getServiceReferenceByName(context, 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) context.getService(msRef);
+ try {
+ ms.updated(instance.getInstanceName(), conf);
+ } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
+
+ // Recheck props
+ fooRef = Utils.getServiceReferenceByName(context, 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) context.getService(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));
+
+ context.ungetService(fooRef);
+ context.ungetService(msRef);
+ }
+
+ public void testDynamicString() {
+ ServiceReference fooRef = Utils.getServiceReferenceByName(context, 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 = Utils.getServiceReferenceByName(context, 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) context.getService(msRef);
+ try {
+ ms.updated(instance.getInstanceName(), conf);
+ } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
+
+ // Recheck props
+ fooRef = Utils.getServiceReferenceByName(context, 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) context.getService(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));
+
+ context.ungetService(fooRef);
+ context.ungetService(msRef);
+ }
+
+ public void testPropagation() {
+ ServiceReference fooRef = Utils.getServiceReferenceByName(context, 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 = Utils.getServiceReferenceByName(context, 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", "foo");
+ conf.put("bar", new Integer(2));
+ conf.put("propagated1", "propagated");
+ conf.put("propagated2", new Integer(1));
+ ManagedServiceFactory ms = (ManagedServiceFactory) context.getService(msRef);
+ try {
+ ms.updated(instance.getInstanceName(), conf);
+ } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
+
+ // Recheck props
+ fooRef = Utils.getServiceReferenceByName(context, FooService.class.getName(), instance.getInstanceName());
+ fooP = (String) fooRef.getProperty("foo");
+ barP = (Integer) fooRef.getProperty("bar");
+ bazP = (String) fooRef.getProperty("baz");
+ assertNotNull("Check the propagated1 existency", fooRef.getProperty("propagated1"));
+ String prop1 = (String) fooRef.getProperty("propagated1");
+ assertNotNull("Check the propagated2 existency", fooRef.getProperty("propagated2"));
+ Integer prop2 = (Integer) fooRef.getProperty("propagated2");
+
+ assertEquals("Check foo equality", fooP, "foo");
+ assertEquals("Check bar equality", barP, new Integer(2));
+ assertEquals("Check baz equality", bazP, "zab");
+ assertEquals("Check propagated1 equality", prop1, "propagated");
+ assertEquals("Check propagated2 equality", prop2, new Integer(1));
+
+ context.ungetService(msRef);
+ }
+
+}
diff --git a/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/ManagedServiceConfigurableProperties.java b/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/ManagedServiceConfigurableProperties.java
new file mode 100644
index 0000000..0859ac1
--- /dev/null
+++ b/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/ManagedServiceConfigurableProperties.java
@@ -0,0 +1,431 @@
+/*
+ * 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.configuration;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.PrimitiveHandler;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.configuration.service.FooService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.cm.ManagedService;
+
+public class ManagedServiceConfigurableProperties extends OSGiTestCase {
+
+ /**
+ * Instance where the ManagedServicePID is provided by the component type.
+ */
+ ComponentInstance instance1;
+ /**
+ * Instance where the ManagedServicePID is provided by the instance.
+ */
+ ComponentInstance instance2;
+
+ public void setUp() {
+ String type = "CONFIG-FooProviderType-4";
+ Properties p = new Properties();
+ p.put("name", "instance");
+ p.put("foo", "foo");
+ p.put("bar", "2");
+ p.put("baz", "baz");
+ instance1 = Utils.getComponentInstance(context, type, p);
+ assertEquals("instance1 created", ComponentInstance.VALID,instance1.getState());
+
+ type = "CONFIG-FooProviderType-3";
+ Properties p1 = new Properties();
+ p1.put("name", "instance-2");
+ p1.put("foo", "foo");
+ p1.put("bar", "2");
+ p1.put("baz", "baz");
+ p1.put("managed.service.pid", "instance");
+ instance2 = Utils.getComponentInstance(context, type, p1);
+ }
+
+ public void tearDown() {
+ instance1.dispose();
+ instance2.dispose();
+ instance1 = null;
+ instance2 = null;
+ }
+
+ public void testStaticInstance1() {
+ ServiceReference fooRef = Utils.getServiceReferenceByName(context, 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 = Utils.getServiceReferenceByPID(context, 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) context.getService(msRef);
+ try {
+ ms.updated(conf);
+ } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
+
+ // Re-check props
+ fooRef = Utils.getServiceReferenceByName(context, 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");
+ context.ungetService(msRef);
+ }
+
+ public void testStaticInstance2() {
+ ServiceReference fooRef = Utils.getServiceReferenceByName(context, 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 = Utils.getServiceReferenceByPID(context, 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) context.getService(msRef);
+ try {
+ ms.updated(conf);
+ } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
+
+ // Recheck props
+ fooRef = Utils.getServiceReferenceByName(context, 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");
+ context.ungetService(fooRef);
+ context.ungetService(msRef);
+ }
+
+ public void testDynamicInstance1() {
+ ServiceReference fooRef = Utils.getServiceReferenceByName(context, 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 = Utils.getServiceReferenceByPID(context, 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) context.getService(msRef);
+ try {
+ ms.updated(conf);
+ } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
+
+ // Re-check props
+ fooRef = Utils.getServiceReferenceByName(context, 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) context.getService(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));
+
+ context.ungetService(fooRef);
+ context.ungetService(msRef);
+ }
+
+ public void testDynamicInstance2() {
+ ServiceReference fooRef = Utils.getServiceReferenceByName(context, 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 = Utils.getServiceReferenceByPID(context, 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) context.getService(msRef);
+ try {
+ ms.updated(conf);
+ } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
+
+ // Recheck props
+ fooRef = Utils.getServiceReferenceByName(context, 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) context.getService(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));
+
+ context.ungetService(fooRef);
+ context.ungetService(msRef);
+ }
+
+ public void testDynamicStringInstance1() {
+ assertEquals("Check instance1 state", ComponentInstance.VALID,instance1.getState());
+ ServiceReference fooRef = Utils.getServiceReferenceByName(context, 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 = Utils.getServiceReferenceByPID(context, ManagedService.class.getName(), "FooProvider-3");
+ assertNotNull("Check ManagedService availability", msRef);
+
+ // Configuration of baz
+ Properties conf = new Properties();
+ conf.put("baz", "zab");
+ conf.put("foo", "oof");
+ conf.put("bar", "0");
+ assertEquals("Check instance1 state (2)", ComponentInstance.VALID,instance1.getState());
+ ManagedService ms = (ManagedService) context.getService(msRef);
+
+ PrimitiveHandler ph = (PrimitiveHandler) ms;
+ assertSame("Check the correct instance", ph.getInstanceManager(), instance1);
+
+ try {
+ ms.updated(conf);
+ } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
+ assertEquals("Check instance1 state (3)", ComponentInstance.VALID,instance1.getState());
+
+ // Recheck props
+ fooRef = Utils.getServiceReferenceByName(context, 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, "oof");
+ assertEquals("Check bar equality - 2", barP, new Integer(0));
+ assertEquals("Check baz equality - 2", bazP, "zab");
+
+ // Check field value
+ FooService fs = (FooService) context.getService(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));
+
+ context.ungetService(fooRef);
+ context.ungetService(msRef);
+ }
+
+ public void testDynamicStringInstance2() {
+ ServiceReference fooRef = Utils.getServiceReferenceByName(context, 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 = Utils.getServiceReferenceByPID(context, ManagedService.class.getName(), "instance");
+ assertNotNull("Check ManagedService availability", msRef);
+
+ // Configuration of baz
+ Properties conf = new Properties();
+ conf.put("baz", "zab");
+ conf.put("foo", "oof");
+ conf.put("bar", "0");
+ ManagedService ms = (ManagedService) context.getService(msRef);
+ try {
+ ms.updated(conf);
+ } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
+
+ // Recheck props
+ fooRef = Utils.getServiceReferenceByName(context, 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) context.getService(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));
+
+ context.ungetService(fooRef);
+ context.ungetService(msRef);
+ }
+
+ public void testPropagationInstance1() {
+ ServiceReference fooRef = Utils.getServiceReferenceByName(context, 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 = Utils.getServiceReferenceByPID(context, ManagedService.class.getName(), "FooProvider-3");
+ assertNotNull("Check ManagedService availability", msRef);
+
+ // Configuration of baz
+ Properties conf = new Properties();
+ conf.put("baz", "zab");
+ conf.put("foo", "foo");
+ conf.put("bar", new Integer(2));
+ conf.put("propagated1", "propagated");
+ conf.put("propagated2", new Integer(1));
+ ManagedService ms = (ManagedService) context.getService(msRef);
+ try {
+ ms.updated(conf);
+ } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
+
+ // Recheck props
+ fooRef = Utils.getServiceReferenceByName(context, FooService.class.getName(), instance1.getInstanceName());
+ fooP = (String) fooRef.getProperty("foo");
+ barP = (Integer) fooRef.getProperty("bar");
+ bazP = (String) fooRef.getProperty("baz");
+ assertNotNull("Check the propagated1 existency", fooRef.getProperty("propagated1"));
+ String prop1 = (String) fooRef.getProperty("propagated1");
+ assertNotNull("Check the propagated2 existency", fooRef.getProperty("propagated2"));
+ Integer prop2 = (Integer) fooRef.getProperty("propagated2");
+
+ assertEquals("Check foo equality", fooP, "foo");
+ assertEquals("Check bar equality", barP, new Integer(2));
+ assertEquals("Check baz equality", bazP, "zab");
+ assertEquals("Check propagated1 equality", prop1, "propagated");
+ assertEquals("Check propagated2 equality", prop2, new Integer(1));
+
+ context.ungetService(msRef);
+ }
+
+ public void testPropagationInstance2() {
+ ServiceReference fooRef = Utils.getServiceReferenceByName(context, 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 = Utils.getServiceReferenceByPID(context, ManagedService.class.getName(), "instance");
+ assertNotNull("Check ManagedService availability", msRef);
+
+ // Configuration of baz
+ Properties conf = new Properties();
+ conf.put("baz", "zab");
+ conf.put("foo", "foo");
+ conf.put("bar", new Integer(2));
+ conf.put("propagated1", "propagated");
+ conf.put("propagated2", new Integer(1));
+ ManagedService ms = (ManagedService) context.getService(msRef);
+ try {
+ ms.updated(conf);
+ } catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
+
+ // Recheck props
+ fooRef = Utils.getServiceReferenceByName(context, FooService.class.getName(), instance2.getInstanceName());
+ fooP = (String) fooRef.getProperty("foo");
+ barP = (Integer) fooRef.getProperty("bar");
+ bazP = (String) fooRef.getProperty("baz");
+ assertNotNull("Check the propagated1 existency", fooRef.getProperty("propagated1"));
+ String prop1 = (String) fooRef.getProperty("propagated1");
+ assertNotNull("Check the propagated2 existency", fooRef.getProperty("propagated2"));
+ Integer prop2 = (Integer) fooRef.getProperty("propagated2");
+
+ assertEquals("Check foo equality", fooP, "foo");
+ assertEquals("Check bar equality", barP, new Integer(2));
+ assertEquals("Check baz equality", bazP, "zab");
+ assertEquals("Check propagated1 equality", prop1, "propagated");
+ assertEquals("Check propagated2 equality", prop2, new Integer(1));
+
+ context.ungetService(msRef);
+ }
+
+}
diff --git a/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/SimpleProperties.java b/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/SimpleProperties.java
new file mode 100644
index 0000000..33f47a7
--- /dev/null
+++ b/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/SimpleProperties.java
@@ -0,0 +1,171 @@
+/*
+ * 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.configuration;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.configuration.service.FooService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.ServiceReference;
+
+public class SimpleProperties extends OSGiTestCase {
+
+ ComponentInstance fooProvider1;
+ ComponentInstance fooProvider2;
+
+ public void setUp() {
+ String type = "CONFIG-FooProviderType-Conf";
+
+ Properties p1 = new Properties();
+ p1.put("name", "FooProvider-1");
+ fooProvider1 = Utils.getComponentInstance(context, type, p1);
+
+ Properties p2 = new Properties();
+ p2.put("name", "FooProvider-2");
+ p2.put("int", new Integer(4));
+ p2.put("boolean", new Boolean(false));
+ p2.put("string", new String("bar"));
+ p2.put("strAProp", new String[] {"bar", "foo"});
+ p2.put("intAProp", new int[] {1, 2, 3});
+ fooProvider2 = Utils.getComponentInstance(context, type, p2);
+ }
+
+ public void tearDown() {
+ fooProvider1.dispose();
+ fooProvider2.dispose();
+ fooProvider1 = null;
+ fooProvider2 = null;
+ }
+
+ public void testComponentTypeConfiguration() {
+ ServiceReference ref = Utils.getServiceReferenceByName(context, FooService.class.getName(), fooProvider1.getInstanceName());
+ assertNotNull("Check FooService availability", ref);
+ FooService fs = (FooService) context.getService(ref);
+ Properties toCheck = fs.fooProps();
+
+ Integer intProp = (Integer) toCheck.get("intProp");
+ Boolean boolProp = (Boolean) toCheck.get("boolProp");
+ String strProp = (String) toCheck.get("strProp");
+ String[] strAProp = (String[]) toCheck.get("strAProp");
+ int[] intAProp = (int[]) toCheck.get("intAProp");
+
+ assertEquals("Check intProp equality (1)", intProp, new Integer(2));
+ assertEquals("Check longProp equality (1)", boolProp, new Boolean(false));
+ assertEquals("Check strProp equality (1)", strProp, new String("foo"));
+ assertNotNull("Check strAProp not nullity (1)", strAProp);
+ String[] v = new String[] {"foo", "bar"};
+ for (int i = 0; i < strAProp.length; i++) {
+ if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality (1) : " + strAProp[i] + " != " + v[i]); }
+ }
+ assertNotNull("Check intAProp not nullity", intAProp);
+ int[] v2 = new int[] {1, 2, 3};
+ for (int i = 0; i < intAProp.length; i++) {
+ if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality (1) : " + intAProp[i] + " != " + v2[i]); }
+ }
+
+ // change the field value
+ assertTrue("Invoke the fs service", fs.foo());
+ toCheck = fs.fooProps();
+
+
+ // Re-check the property (change)
+ intProp = (Integer) toCheck.get("intProp");
+ boolProp = (Boolean) toCheck.get("boolProp");
+ strProp = (String) toCheck.get("strProp");
+ strAProp = (String[]) toCheck.get("strAProp");
+ intAProp = (int[]) toCheck.get("intAProp");
+
+ assertEquals("Check intProp equality (2) ("+intProp+")", intProp, new Integer(3));
+ assertEquals("Check longProp equality (2)", boolProp, new Boolean(true));
+ assertEquals("Check strProp equality (2)", strProp, new String("bar"));
+ assertNotNull("Check strAProp not nullity (2)", strAProp);
+ v = new String[] {"foo", "bar", "baz"};
+ for (int i = 0; i < strAProp.length; i++) {
+ if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality (2)"); }
+ }
+ assertNotNull("Check intAProp not nullity (2)", intAProp);
+ v2 = new int[] {3, 2, 1};
+ for (int i = 0; i < intAProp.length; i++) {
+ if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality (2) : " + intAProp[i] + " != " + v2[i]); }
+ }
+
+ fs = null;
+ context.ungetService(ref);
+ }
+
+ public void testInstanceConfiguration() {
+ ServiceReference sr = Utils.getServiceReferenceByName(context, FooService.class.getName(), "FooProvider-2");
+ assertNotNull("Check the availability of the FS service", sr);
+
+ FooService fs = (FooService) context.getService(sr);
+ Properties toCheck = fs.fooProps();
+
+ // Check service properties
+ Integer intProp = (Integer) toCheck.get("intProp");
+ Boolean boolProp = (Boolean) toCheck.get("boolProp");
+ String strProp = (String) toCheck.get("strProp");
+ String[] strAProp = (String[]) toCheck.get("strAProp");
+ int[] intAProp = (int[]) toCheck.get("intAProp");
+
+ assertEquals("Check intProp equality", intProp, new Integer(4));
+ assertEquals("Check longProp equality", boolProp, new Boolean(false));
+ assertEquals("Check strProp equality", strProp, new String("bar"));
+ assertNotNull("Check strAProp not nullity", strAProp);
+ String[] v = new String[] {"bar", "foo"};
+ for (int i = 0; i < strAProp.length; i++) {
+ if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality"); }
+ }
+ assertNotNull("Check intAProp not nullity", intAProp);
+ int[] v2 = new int[] {1, 2, 3};
+ for (int i = 0; i < intAProp.length; i++) {
+ if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality"); }
+ }
+
+
+ assertTrue("invoke fs", fs.foo());
+ toCheck = fs.fooProps();
+
+ // Re-check the property (change)
+ intProp = (Integer) toCheck.get("intProp");
+ boolProp = (Boolean) toCheck.get("boolProp");
+ strProp = (String) toCheck.get("strProp");
+ strAProp = (String[]) toCheck.get("strAProp");
+ intAProp = (int[]) toCheck.get("intAProp");
+
+ assertEquals("Check intProp equality", intProp, new Integer(3));
+ assertEquals("Check longProp equality", boolProp, new Boolean(true));
+ assertEquals("Check strProp equality", strProp, new String("foo"));
+ assertNotNull("Check strAProp not nullity", strAProp);
+ v = new String[] {"foo", "bar", "baz"};
+ for (int i = 0; i < strAProp.length; i++) {
+ if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality"); }
+ }
+ assertNotNull("Check intAProp not nullity", intAProp);
+ v2 = new int[] {3, 2, 1};
+ for (int i = 0; i < intAProp.length; i++) {
+ if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality"); }
+ }
+
+ fs = null;
+ context.ungetService(sr);
+ }
+
+}
diff --git a/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/TestBothProperties.java b/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/TestBothProperties.java
new file mode 100644
index 0000000..7cfce8a
--- /dev/null
+++ b/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/TestBothProperties.java
@@ -0,0 +1,618 @@
+/*
+ * 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.configuration;
+
+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.configuration.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.ServiceReference;
+
+public class TestBothProperties extends OSGiTestCase {
+
+ ComponentInstance instance;
+
+
+ public void setUp() {
+ Factory fact = Utils.getFactoryByName(context, "CONFIG-BothConfigurableCheckService");
+ Properties props = new Properties();
+ props.put("name", "under-test");
+ props.put("b", "1");
+ props.put("s", "1");
+ props.put("i", "1");
+ props.put("l", "1");
+ props.put("d", "1");
+ props.put("f", "1");
+ props.put("c", "a");
+ props.put("bool", "true");
+ props.put("bs", "{1,2,3}");
+ props.put("ss", "{1,2,3}");
+ props.put("is", "{1,2,3}");
+ props.put("ls", "{1,2,3}");
+ props.put("ds", "{1,2,3}");
+ props.put("fs", "{1,2,3}");
+ props.put("cs", "{a,b,c}");
+ props.put("bools", "{true,true,true}");
+ props.put("string", "foo");
+ props.put("strings", "{foo, bar, baz}");
+
+ try {
+ instance = fact.createComponentInstance(props);
+ } catch(Exception e) {
+ fail("Cannot create the under-test instance : " + e.getMessage());
+ }
+
+
+ }
+
+ public void tearDown() {
+ instance.dispose();
+ instance = null;
+ }
+
+ public void testConfigurationPrimitive() {
+ ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ CheckService check = (CheckService) context.getService(ref);
+ Properties props = check.getProps();
+
+ Byte b = (Byte) props.get("b");
+ Short s = (Short) props.get("s");
+ Integer i = (Integer) props.get("i");
+ Long l = (Long) props.get("l");
+ Double d = (Double) props.get("d");
+ Float f = (Float) props.get("f");
+ Character c = (Character) props.get("c");
+ Boolean bool = (Boolean) props.get("bool");
+
+ assertEquals("Check b", b, new Byte("1"));
+ assertEquals("Check s", s, new Short("1"));
+ assertEquals("Check i", i, new Integer("1"));
+ assertEquals("Check l", l, new Long("1"));
+ assertEquals("Check d", d, new Double("1"));
+ assertEquals("Check f", f, new Float("1"));
+ assertEquals("Check c", c, new Character('a'));
+ assertEquals("Check bool", bool, new Boolean("true"));
+
+ Integer upb = (Integer) props.get("upb");
+ Integer ups = (Integer) props.get("ups");
+ Integer upi = (Integer) props.get("upi");
+ Integer upl = (Integer) props.get("upl");
+ Integer upd = (Integer) props.get("upd");
+ Integer upf = (Integer) props.get("upf");
+ Integer upc = (Integer) props.get("upc");
+ Integer upbool = (Integer) props.get("upbool");
+
+ assertEquals("Check upb", upb, new Integer(1));
+ assertEquals("Check ups", ups, new Integer(1));
+ assertEquals("Check upi", upi, new Integer(1));
+ assertEquals("Check upl", upl, new Integer(1));
+ assertEquals("Check upd", upd, new Integer(1));
+ assertEquals("Check upf", upf, new Integer(1));
+ assertEquals("Check upc", upc, new Integer(1));
+ assertEquals("Check upbool", upbool, new Integer(1));
+
+ reconfigure();
+
+ ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ check = (CheckService) context.getService(ref);
+ props = check.getProps();
+
+ b = (Byte) props.get("b");
+ s = (Short) props.get("s");
+ i = (Integer) props.get("i");
+ l = (Long) props.get("l");
+ d = (Double) props.get("d");
+ f = (Float) props.get("f");
+ c = (Character) props.get("c");
+ bool = (Boolean) props.get("bool");
+
+ assertEquals("2) Check b ("+b+")", b, new Byte("2"));
+ assertEquals("2) Check s", s, new Short("2"));
+ assertEquals("2) Check i", i, new Integer("2"));
+ assertEquals("2) Check l", l, new Long("2"));
+ assertEquals("2) Check d", d, new Double("2"));
+ assertEquals("2) Check f", f, new Float("2"));
+ assertEquals("2) Check c", c, new Character('b'));
+ assertEquals("2) Check bool", bool, new Boolean("false"));
+
+ upb = (Integer) props.get("upb");
+ ups = (Integer) props.get("ups");
+ upi = (Integer) props.get("upi");
+ upl = (Integer) props.get("upl");
+ upd = (Integer) props.get("upd");
+ upf = (Integer) props.get("upf");
+ upc = (Integer) props.get("upc");
+ upbool = (Integer) props.get("upbool");
+
+ assertEquals("2) Check upb", upb, new Integer(2));
+ assertEquals("2) Check ups", ups, new Integer(2));
+ assertEquals("2) Check upi", upi, new Integer(2));
+ assertEquals("2) Check upl", upl, new Integer(2));
+ assertEquals("2) Check upd", upd, new Integer(2));
+ assertEquals("2) Check upf", upf, new Integer(2));
+ assertEquals("2) Check upc", upc, new Integer(2));
+ assertEquals("2) Check upbool", upbool, new Integer(2));
+
+ }
+
+ public void testConfigurationPrimitiveString() {
+ ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ CheckService check = (CheckService) context.getService(ref);
+ Properties props = check.getProps();
+
+ Byte b = (Byte) props.get("b");
+ Short s = (Short) props.get("s");
+ Integer i = (Integer) props.get("i");
+ Long l = (Long) props.get("l");
+ Double d = (Double) props.get("d");
+ Float f = (Float) props.get("f");
+ Character c = (Character) props.get("c");
+ Boolean bool = (Boolean) props.get("bool");
+
+ assertEquals("Check b", b, new Byte("1"));
+ assertEquals("Check s", s, new Short("1"));
+ assertEquals("Check i", i, new Integer("1"));
+ assertEquals("Check l", l, new Long("1"));
+ assertEquals("Check d", d, new Double("1"));
+ assertEquals("Check f", f, new Float("1"));
+ assertEquals("Check c", c, new Character('a'));
+ assertEquals("Check bool", bool, new Boolean("true"));
+
+ Integer upb = (Integer) props.get("upb");
+ Integer ups = (Integer) props.get("ups");
+ Integer upi = (Integer) props.get("upi");
+ Integer upl = (Integer) props.get("upl");
+ Integer upd = (Integer) props.get("upd");
+ Integer upf = (Integer) props.get("upf");
+ Integer upc = (Integer) props.get("upc");
+ Integer upbool = (Integer) props.get("upbool");
+
+ assertEquals("Check upb", upb, new Integer(1));
+ assertEquals("Check ups", ups, new Integer(1));
+ assertEquals("Check upi", upi, new Integer(1));
+ assertEquals("Check upl", upl, new Integer(1));
+ assertEquals("Check upd", upd, new Integer(1));
+ assertEquals("Check upf", upf, new Integer(1));
+ assertEquals("Check upc", upc, new Integer(1));
+ assertEquals("Check upbool", upbool, new Integer(1));
+
+ reconfigureString();
+
+ ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ check = (CheckService) context.getService(ref);
+ props = check.getProps();
+
+ b = (Byte) props.get("b");
+ s = (Short) props.get("s");
+ i = (Integer) props.get("i");
+ l = (Long) props.get("l");
+ d = (Double) props.get("d");
+ f = (Float) props.get("f");
+ c = (Character) props.get("c");
+ bool = (Boolean) props.get("bool");
+
+ assertEquals("2) Check b ("+b+")", b, new Byte("2"));
+ assertEquals("2) Check s", s, new Short("2"));
+ assertEquals("2) Check i", i, new Integer("2"));
+ assertEquals("2) Check l", l, new Long("2"));
+ assertEquals("2) Check d", d, new Double("2"));
+ assertEquals("2) Check f", f, new Float("2"));
+ assertEquals("2) Check c", c, new Character('b'));
+ assertEquals("2) Check bool", bool, new Boolean("false"));
+
+ upb = (Integer) props.get("upb");
+ ups = (Integer) props.get("ups");
+ upi = (Integer) props.get("upi");
+ upl = (Integer) props.get("upl");
+ upd = (Integer) props.get("upd");
+ upf = (Integer) props.get("upf");
+ upc = (Integer) props.get("upc");
+ upbool = (Integer) props.get("upbool");
+
+ assertEquals("2) Check upb", upb, new Integer(2));
+ assertEquals("2) Check ups", ups, new Integer(2));
+ assertEquals("2) Check upi", upi, new Integer(2));
+ assertEquals("2) Check upl", upl, new Integer(2));
+ assertEquals("2) Check upd", upd, new Integer(2));
+ assertEquals("2) Check upf", upf, new Integer(2));
+ assertEquals("2) Check upc", upc, new Integer(2));
+ assertEquals("2) Check upbool", upbool, new Integer(2));
+
+ }
+
+ public void testConfigurationPrimitiveArrays() {
+ ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ CheckService check = (CheckService) context.getService(ref);
+ Properties props = check.getProps();
+
+ byte[] b = (byte[]) props.get("bs");
+ short[] s = (short[]) props.get("ss");
+ int[] i = (int[]) props.get("is");
+ long[] l = (long[]) props.get("ls");
+ double[] d = (double[]) props.get("ds");
+ float[] f = (float[]) props.get("fs");
+ char[] c = (char[]) props.get("cs");
+ boolean[] bool = (boolean[]) props.get("bools");
+
+ assertEquals("Check b 0", b[0], 1);
+ assertEquals("Check b 1", b[1], 2);
+ assertEquals("Check b 2", b[2], 3);
+ assertEquals("Check s 0", s[0], 1);
+ assertEquals("Check s 1", s[1], 2);
+ assertEquals("Check s 2", s[2], 3);
+ assertEquals("Check i 0", i[0], 1);
+ assertEquals("Check i 1", i[1], 2);
+ assertEquals("Check i 2", i[2], 3);
+ assertEquals("Check l 0", l[0], 1);
+ assertEquals("Check l 1", l[1], 2);
+ assertEquals("Check l 2", l[2], 3);
+ assertEquals("Check d 0", d[0], 1);
+ assertEquals("Check d 1", d[1], 2);
+ assertEquals("Check d 2", d[2], 3);
+ assertEquals("Check f 0", f[0], 1);
+ assertEquals("Check f 1", f[1], 2);
+ assertEquals("Check f 2", f[2], 3);
+ assertEquals("Check c 0", c[0], 'a');
+ assertEquals("Check c 1", c[1], 'b');
+ assertEquals("Check c 2", c[2], 'c');
+ assertTrue("Check bool 0", bool[0]);
+ assertTrue("Check bool 1", bool[0]);
+ assertTrue("Check bool 2", bool[0]);
+
+ Integer upb = (Integer) props.get("upbs");
+ Integer ups = (Integer) props.get("upss");
+ Integer upi = (Integer) props.get("upis");
+ Integer upl = (Integer) props.get("upls");
+ Integer upd = (Integer) props.get("upds");
+ Integer upf = (Integer) props.get("upfs");
+ Integer upc = (Integer) props.get("upcs");
+ Integer upbool = (Integer) props.get("upbools");
+
+ assertEquals("Check upb", upb, new Integer(1));
+ assertEquals("Check ups", ups, new Integer(1));
+ assertEquals("Check upi", upi, new Integer(1));
+ assertEquals("Check upl", upl, new Integer(1));
+ assertEquals("Check upd", upd, new Integer(1));
+ assertEquals("Check upf", upf, new Integer(1));
+ assertEquals("Check upc", upc, new Integer(1));
+ assertEquals("Check upbool", upbool, new Integer(1));
+
+ reconfigure();
+
+ ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ check = (CheckService) context.getService(ref);
+ props = check.getProps();
+
+ b = (byte[]) props.get("bs");
+ s = (short[]) props.get("ss");
+ i = (int[]) props.get("is");
+ l = (long[]) props.get("ls");
+ d = (double[]) props.get("ds");
+ f = (float[]) props.get("fs");
+ c = (char[]) props.get("cs");
+ bool = (boolean[]) props.get("bools");
+
+ assertEquals("2) Check b 0", b[0], 3);
+ assertEquals("2) Check b 1", b[1], 2);
+ assertEquals("2) Check b 2", b[2], 1);
+ assertEquals("2) Check s 0", s[0], 3);
+ assertEquals("2) Check s 1", s[1], 2);
+ assertEquals("2) Check s 2", s[2], 1);
+ assertEquals("2) Check i 0", i[0], 3);
+ assertEquals("2) Check i 1", i[1], 2);
+ assertEquals("2) Check i 2", i[2], 1);
+ assertEquals("2) Check l 0", l[0], 3);
+ assertEquals("2) Check l 1", l[1], 2);
+ assertEquals("2) Check l 2", l[2], 1);
+ assertEquals("2) Check d 0", d[0], 3);
+ assertEquals("2) Check d 1", d[1], 2);
+ assertEquals("2) Check d 2", d[2], 1);
+ assertEquals("2) Check f 0", f[0], 3);
+ assertEquals("2) Check f 1", f[1], 2);
+ assertEquals("2) Check f 2", f[2], 1);
+ assertEquals("2) Check c 0", c[0], 'c');
+ assertEquals("2) Check c 1", c[1], 'b');
+ assertEquals("2) Check c 2", c[2], 'a');
+ assertFalse("2) Check bool 0", bool[0]);
+ assertFalse("2) Check bool 1", bool[0]);
+ assertFalse("2) Check bool 2", bool[0]);
+
+ upb = (Integer) props.get("upbs");
+ ups = (Integer) props.get("upss");
+ upi = (Integer) props.get("upis");
+ upl = (Integer) props.get("upls");
+ upd = (Integer) props.get("upds");
+ upf = (Integer) props.get("upfs");
+ upc = (Integer) props.get("upcs");
+ upbool = (Integer) props.get("upbools");
+
+ assertEquals("2) Check upb", upb, new Integer(2));
+ assertEquals("2) Check ups", ups, new Integer(2));
+ assertEquals("2) Check upi", upi, new Integer(2));
+ assertEquals("2) Check upl", upl, new Integer(2));
+ assertEquals("2) Check upd", upd, new Integer(2));
+ assertEquals("2) Check upf", upf, new Integer(2));
+ assertEquals("2) Check upc", upc, new Integer(2));
+ assertEquals("2) Check upbool", upbool, new Integer(2));
+
+ }
+
+ public void testConfigurationPrimitiveArraysString() {
+ ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ CheckService check = (CheckService) context.getService(ref);
+ Properties props = check.getProps();
+
+ byte[] b = (byte[]) props.get("bs");
+ short[] s = (short[]) props.get("ss");
+ int[] i = (int[]) props.get("is");
+ long[] l = (long[]) props.get("ls");
+ double[] d = (double[]) props.get("ds");
+ float[] f = (float[]) props.get("fs");
+ char[] c = (char[]) props.get("cs");
+ boolean[] bool = (boolean[]) props.get("bools");
+
+ assertEquals("Check b 0", b[0], 1);
+ assertEquals("Check b 1", b[1], 2);
+ assertEquals("Check b 2", b[2], 3);
+ assertEquals("Check s 0", s[0], 1);
+ assertEquals("Check s 1", s[1], 2);
+ assertEquals("Check s 2", s[2], 3);
+ assertEquals("Check i 0", i[0], 1);
+ assertEquals("Check i 1", i[1], 2);
+ assertEquals("Check i 2", i[2], 3);
+ assertEquals("Check l 0", l[0], 1);
+ assertEquals("Check l 1", l[1], 2);
+ assertEquals("Check l 2", l[2], 3);
+ assertEquals("Check d 0", d[0], 1);
+ assertEquals("Check d 1", d[1], 2);
+ assertEquals("Check d 2", d[2], 3);
+ assertEquals("Check f 0", f[0], 1);
+ assertEquals("Check f 1", f[1], 2);
+ assertEquals("Check f 2", f[2], 3);
+ assertEquals("Check c 0", c[0], 'a');
+ assertEquals("Check c 1", c[1], 'b');
+ assertEquals("Check c 2", c[2], 'c');
+ assertTrue("Check bool 0", bool[0]);
+ assertTrue("Check bool 1", bool[0]);
+ assertTrue("Check bool 2", bool[0]);
+
+ Integer upb = (Integer) props.get("upbs");
+ Integer ups = (Integer) props.get("upss");
+ Integer upi = (Integer) props.get("upis");
+ Integer upl = (Integer) props.get("upls");
+ Integer upd = (Integer) props.get("upds");
+ Integer upf = (Integer) props.get("upfs");
+ Integer upc = (Integer) props.get("upcs");
+ Integer upbool = (Integer) props.get("upbools");
+
+ assertEquals("Check upb", upb, new Integer(1));
+ assertEquals("Check ups", ups, new Integer(1));
+ assertEquals("Check upi", upi, new Integer(1));
+ assertEquals("Check upl", upl, new Integer(1));
+ assertEquals("Check upd", upd, new Integer(1));
+ assertEquals("Check upf", upf, new Integer(1));
+ assertEquals("Check upc", upc, new Integer(1));
+ assertEquals("Check upbool", upbool, new Integer(1));
+
+ reconfigureString();
+
+ ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ check = (CheckService) context.getService(ref);
+ props = check.getProps();
+
+ b = (byte[]) props.get("bs");
+ s = (short[]) props.get("ss");
+ i = (int[]) props.get("is");
+ l = (long[]) props.get("ls");
+ d = (double[]) props.get("ds");
+ f = (float[]) props.get("fs");
+ c = (char[]) props.get("cs");
+ bool = (boolean[]) props.get("bools");
+
+ assertEquals("2) Check b 0", b[0], 3);
+ assertEquals("2) Check b 1", b[1], 2);
+ assertEquals("2) Check b 2", b[2], 1);
+ assertEquals("2) Check s 0", s[0], 3);
+ assertEquals("2) Check s 1", s[1], 2);
+ assertEquals("2) Check s 2", s[2], 1);
+ assertEquals("2) Check i 0", i[0], 3);
+ assertEquals("2) Check i 1", i[1], 2);
+ assertEquals("2) Check i 2", i[2], 1);
+ assertEquals("2) Check l 0", l[0], 3);
+ assertEquals("2) Check l 1", l[1], 2);
+ assertEquals("2) Check l 2", l[2], 1);
+ assertEquals("2) Check d 0", d[0], 3);
+ assertEquals("2) Check d 1", d[1], 2);
+ assertEquals("2) Check d 2", d[2], 1);
+ assertEquals("2) Check f 0", f[0], 3);
+ assertEquals("2) Check f 1", f[1], 2);
+ assertEquals("2) Check f 2", f[2], 1);
+ assertEquals("2) Check c 0", c[0], 'c');
+ assertEquals("2) Check c 1", c[1], 'b');
+ assertEquals("2) Check c 2", c[2], 'a');
+ assertFalse("2) Check bool 0", bool[0]);
+ assertFalse("2) Check bool 1", bool[0]);
+ assertFalse("2) Check bool 2", bool[0]);
+
+ upb = (Integer) props.get("upbs");
+ ups = (Integer) props.get("upss");
+ upi = (Integer) props.get("upis");
+ upl = (Integer) props.get("upls");
+ upd = (Integer) props.get("upds");
+ upf = (Integer) props.get("upfs");
+ upc = (Integer) props.get("upcs");
+ upbool = (Integer) props.get("upbools");
+
+ assertEquals("2) Check upb", upb, new Integer(2));
+ assertEquals("2) Check ups", ups, new Integer(2));
+ assertEquals("2) Check upi", upi, new Integer(2));
+ assertEquals("2) Check upl", upl, new Integer(2));
+ assertEquals("2) Check upd", upd, new Integer(2));
+ assertEquals("2) Check upf", upf, new Integer(2));
+ assertEquals("2) Check upc", upc, new Integer(2));
+ assertEquals("2) Check upbool", upbool, new Integer(2));
+
+ }
+
+ public void testConfigurationObj() {
+ ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ CheckService check = (CheckService) context.getService(ref);
+ Properties props = check.getProps();
+
+ String s = (String) props.get("string");
+ String[] ss = (String[]) props.get("strings");
+
+ assertEquals("Check string", s, "foo");
+ assertEquals("Check strings 0", ss[0], "foo");
+ assertEquals("Check strings 1", ss[1], "bar");
+ assertEquals("Check strings 2", ss[2], "baz");
+
+ Integer upString = (Integer) props.get("upstring");
+ Integer upStrings = (Integer) props.get("upstrings");
+
+ assertEquals("Check upString", upString, new Integer(1));
+ assertEquals("Check upStrings", upStrings, new Integer(1));
+
+ reconfigure();
+
+ ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ check = (CheckService) context.getService(ref);
+ props = check.getProps();
+
+ s = (String) props.get("string");
+ ss = (String[]) props.get("strings");
+
+ assertEquals("2) Check string", s, "bar");
+ assertEquals("2) Check strings 0", ss[0], "baz");
+ assertEquals("2) Check strings 1", ss[1], "bar");
+ assertEquals("2) Check strings 2", ss[2], "foo");
+
+ upString = (Integer) props.get("upstring");
+ upStrings = (Integer) props.get("upstrings");
+
+ assertEquals("2) Check upstring", upString, new Integer(2));
+ assertEquals("2) Check upstrings", upStrings, new Integer(2));
+ }
+
+ public void testConfigurationObjString() {
+ ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ CheckService check = (CheckService) context.getService(ref);
+ Properties props = check.getProps();
+
+ String s = (String) props.get("string");
+ String[] ss = (String[]) props.get("strings");
+
+ assertEquals("Check string", s, "foo");
+ assertEquals("Check strings 0", ss[0], "foo");
+ assertEquals("Check strings 1", ss[1], "bar");
+ assertEquals("Check strings 2", ss[2], "baz");
+
+ Integer upString = (Integer) props.get("upstring");
+ Integer upStrings = (Integer) props.get("upstrings");
+
+ assertEquals("Check upString", upString, new Integer(1));
+ assertEquals("Check upStrings", upStrings, new Integer(1));
+
+ reconfigureString();
+
+ ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ check = (CheckService) context.getService(ref);
+ props = check.getProps();
+
+ s = (String) props.get("string");
+ ss = (String[]) props.get("strings");
+
+ assertEquals("2) Check string", s, "bar");
+ assertEquals("2) Check strings 0", ss[0], "baz");
+ assertEquals("2) Check strings 1", ss[1], "bar");
+ assertEquals("2) Check strings 2", ss[2], "foo");
+
+ upString = (Integer) props.get("upstring");
+ upStrings = (Integer) props.get("upstrings");
+
+ assertEquals("2) Check upstring", upString, new Integer(2));
+ assertEquals("2) Check upstrings", upStrings, new Integer(2));
+ }
+
+ private void reconfigure() {
+ Properties props2 = new Properties();
+ props2.put("name", "under-test");
+ props2.put("b", new Byte("2"));
+ props2.put("s", new Short("2"));
+ props2.put("i", new Integer("2"));
+ props2.put("l", new Long("2"));
+ props2.put("d", new Double("2"));
+ props2.put("f", new Float("2"));
+ props2.put("c", new Character('b'));
+ props2.put("bool", new Boolean(false));
+ props2.put("bs", new byte[]{(byte)3,(byte)2,(byte)1});
+ props2.put("ss", new short[]{(short)3,(short)2,(short)1});
+ props2.put("is", new int[]{3,2,1});
+ props2.put("ls", new long[]{3,2,1});
+ props2.put("ds", new double[]{3,2,1});
+ props2.put("fs", new float[]{3,2,1});
+ props2.put("cs", new char[]{'c','b','a'});
+ props2.put("bools", new boolean[]{false,false,false});
+ props2.put("string", "bar");
+ props2.put("strings", new String[]{"baz", "bar", "foo"});
+
+ instance.reconfigure(props2);
+ }
+
+ private void reconfigureString() {
+ Properties props2 = new Properties();
+ props2.put("name", "under-test");
+ props2.put("b", "2");
+ props2.put("s", "2");
+ props2.put("i", "2");
+ props2.put("l", "2");
+ props2.put("d", "2");
+ props2.put("f", "2");
+ props2.put("c", "b");
+ props2.put("bool", "false");
+ props2.put("bs", "{3, 2,1}");
+ props2.put("ss", "{3, 2,1}");
+ props2.put("is", "{3, 2,1}");
+ props2.put("ls", "{3, 2,1}");
+ props2.put("ds", "{3, 2,1}");
+ props2.put("fs", "{3, 2,1}");
+ props2.put("cs", "{c, b , a}");
+ props2.put("bools", "{false,false,false}");
+ props2.put("string", "bar");
+ props2.put("strings", "{baz, bar, foo}");
+
+ instance.reconfigure(props2);
+ }
+
+}
diff --git a/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/TestFieldProperties.java b/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/TestFieldProperties.java
new file mode 100644
index 0000000..a34051a
--- /dev/null
+++ b/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/TestFieldProperties.java
@@ -0,0 +1,449 @@
+/*
+ * 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.configuration;
+
+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.configuration.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.ServiceReference;
+
+public class TestFieldProperties extends OSGiTestCase {
+
+ ComponentInstance instance;
+
+ public void setUp() {
+ Factory fact = Utils.getFactoryByName(context, "CONFIG-FieldConfigurableCheckService");
+ Properties props = new Properties();
+ props.put("name", "under-test");
+ props.put("b", "1");
+ props.put("s", "1");
+ props.put("i", "1");
+ props.put("l", "1");
+ props.put("d", "1");
+ props.put("f", "1");
+ props.put("c", "a");
+ props.put("bool", "true");
+ props.put("bs", "{1,2,3}");
+ props.put("ss", "{1,2,3}");
+ props.put("is", "{1,2,3}");
+ props.put("ls", "{1,2,3}");
+ props.put("ds", "{1,2,3}");
+ props.put("fs", "{1,2,3}");
+ props.put("cs", "{a,b,c}");
+ props.put("bools", "{true,true,true}");
+ props.put("string", "foo");
+ props.put("strings", "{foo, bar, baz}");
+
+ try {
+ instance = fact.createComponentInstance(props);
+ } catch(Exception e) {
+ fail("Cannot create the under-test instance : " + e.getMessage());
+ }
+
+
+ }
+
+ public void tearDown() {
+ instance.dispose();
+ instance = null;
+ }
+
+ public void testConfigurationPrimitive() {
+ ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ CheckService check = (CheckService) context.getService(ref);
+ Properties props = check.getProps();
+
+ Byte b = (Byte) props.get("b");
+ Short s = (Short) props.get("s");
+ Integer i = (Integer) props.get("i");
+ Long l = (Long) props.get("l");
+ Double d = (Double) props.get("d");
+ Float f = (Float) props.get("f");
+ Character c = (Character) props.get("c");
+ Boolean bool = (Boolean) props.get("bool");
+
+ assertEquals("Check b", b, new Byte("1"));
+ assertEquals("Check s", s, new Short("1"));
+ assertEquals("Check i", i, new Integer("1"));
+ assertEquals("Check l", l, new Long("1"));
+ assertEquals("Check d", d, new Double("1"));
+ assertEquals("Check f", f, new Float("1"));
+ assertEquals("Check c", c, new Character('a'));
+ assertEquals("Check bool", bool, new Boolean("true"));
+
+ reconfigure();
+
+ ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ check = (CheckService) context.getService(ref);
+ props = check.getProps();
+
+ b = (Byte) props.get("b");
+ s = (Short) props.get("s");
+ i = (Integer) props.get("i");
+ l = (Long) props.get("l");
+ d = (Double) props.get("d");
+ f = (Float) props.get("f");
+ c = (Character) props.get("c");
+ bool = (Boolean) props.get("bool");
+
+ assertEquals("2) Check b", b, new Byte("2"));
+ assertEquals("2) Check s", s, new Short("2"));
+ assertEquals("2) Check i", i, new Integer("2"));
+ assertEquals("2) Check l", l, new Long("2"));
+ assertEquals("2) Check d", d, new Double("2"));
+ assertEquals("2) Check f", f, new Float("2"));
+ assertEquals("2) Check c", c, new Character('b'));
+ assertEquals("2) Check bool", bool, new Boolean("false"));
+
+ }
+
+ public void testConfigurationPrimitiveString() {
+ ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ CheckService check = (CheckService) context.getService(ref);
+ Properties props = check.getProps();
+
+ Byte b = (Byte) props.get("b");
+ Short s = (Short) props.get("s");
+ Integer i = (Integer) props.get("i");
+ Long l = (Long) props.get("l");
+ Double d = (Double) props.get("d");
+ Float f = (Float) props.get("f");
+ Character c = (Character) props.get("c");
+ Boolean bool = (Boolean) props.get("bool");
+
+ assertEquals("Check b", b, new Byte("1"));
+ assertEquals("Check s", s, new Short("1"));
+ assertEquals("Check i", i, new Integer("1"));
+ assertEquals("Check l", l, new Long("1"));
+ assertEquals("Check d", d, new Double("1"));
+ assertEquals("Check f", f, new Float("1"));
+ assertEquals("Check c", c, new Character('a'));
+ assertEquals("Check bool", bool, new Boolean("true"));
+
+ reconfigureString();
+
+ ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ check = (CheckService) context.getService(ref);
+ props = check.getProps();
+
+ b = (Byte) props.get("b");
+ s = (Short) props.get("s");
+ i = (Integer) props.get("i");
+ l = (Long) props.get("l");
+ d = (Double) props.get("d");
+ f = (Float) props.get("f");
+ c = (Character) props.get("c");
+ bool = (Boolean) props.get("bool");
+
+ assertEquals("2) Check b", b, new Byte("2"));
+ assertEquals("2) Check s", s, new Short("2"));
+ assertEquals("2) Check i", i, new Integer("2"));
+ assertEquals("2) Check l", l, new Long("2"));
+ assertEquals("2) Check d", d, new Double("2"));
+ assertEquals("2) Check f", f, new Float("2"));
+ assertEquals("2) Check c", c, new Character('b'));
+ assertEquals("2) Check bool", bool, new Boolean("false"));
+
+ }
+
+ public void testConfigurationPrimitiveArrays() {
+ ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ CheckService check = (CheckService) context.getService(ref);
+ Properties props = check.getProps();
+
+ byte[] b = (byte[]) props.get("bs");
+ short[] s = (short[]) props.get("ss");
+ int[] i = (int[]) props.get("is");
+ long[] l = (long[]) props.get("ls");
+ double[] d = (double[]) props.get("ds");
+ float[] f = (float[]) props.get("fs");
+ char[] c = (char[]) props.get("cs");
+ boolean[] bool = (boolean[]) props.get("bools");
+
+ assertEquals("Check b 0", b[0], 1);
+ assertEquals("Check b 1", b[1], 2);
+ assertEquals("Check b 2", b[2], 3);
+ assertEquals("Check s 0", s[0], 1);
+ assertEquals("Check s 1", s[1], 2);
+ assertEquals("Check s 2", s[2], 3);
+ assertEquals("Check i 0", i[0], 1);
+ assertEquals("Check i 1", i[1], 2);
+ assertEquals("Check i 2", i[2], 3);
+ assertEquals("Check l 0", l[0], 1);
+ assertEquals("Check l 1", l[1], 2);
+ assertEquals("Check l 2", l[2], 3);
+ assertEquals("Check d 0", d[0], 1);
+ assertEquals("Check d 1", d[1], 2);
+ assertEquals("Check d 2", d[2], 3);
+ assertEquals("Check f 0", f[0], 1);
+ assertEquals("Check f 1", f[1], 2);
+ assertEquals("Check f 2", f[2], 3);
+ assertEquals("Check c 0", c[0], 'a');
+ assertEquals("Check c 1", c[1], 'b');
+ assertEquals("Check c 2", c[2], 'c');
+ assertTrue("Check bool 0", bool[0]);
+ assertTrue("Check bool 1", bool[0]);
+ assertTrue("Check bool 2", bool[0]);
+
+ reconfigure();
+
+ ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ check = (CheckService) context.getService(ref);
+ props = check.getProps();
+
+ b = (byte[]) props.get("bs");
+ s = (short[]) props.get("ss");
+ i = (int[]) props.get("is");
+ l = (long[]) props.get("ls");
+ d = (double[]) props.get("ds");
+ f = (float[]) props.get("fs");
+ c = (char[]) props.get("cs");
+ bool = (boolean[]) props.get("bools");
+
+ assertEquals("2) Check b 0", b[0], 3);
+ assertEquals("2) Check b 1", b[1], 2);
+ assertEquals("2) Check b 2", b[2], 1);
+ assertEquals("2) Check s 0", s[0], 3);
+ assertEquals("2) Check s 1", s[1], 2);
+ assertEquals("2) Check s 2", s[2], 1);
+ assertEquals("2) Check i 0", i[0], 3);
+ assertEquals("2) Check i 1", i[1], 2);
+ assertEquals("2) Check i 2", i[2], 1);
+ assertEquals("2) Check l 0", l[0], 3);
+ assertEquals("2) Check l 1", l[1], 2);
+ assertEquals("2) Check l 2", l[2], 1);
+ assertEquals("2) Check d 0", d[0], 3);
+ assertEquals("2) Check d 1", d[1], 2);
+ assertEquals("2) Check d 2", d[2], 1);
+ assertEquals("2) Check f 0", f[0], 3);
+ assertEquals("2) Check f 1", f[1], 2);
+ assertEquals("2) Check f 2", f[2], 1);
+ assertEquals("2) Check c 0", c[0], 'c');
+ assertEquals("2) Check c 1", c[1], 'b');
+ assertEquals("2) Check c 2", c[2], 'a');
+ assertFalse("2) Check bool 0", bool[0]);
+ assertFalse("2) Check bool 1", bool[0]);
+ assertFalse("2) Check bool 2", bool[0]);
+
+ }
+
+ public void testConfigurationPrimitiveArraysString() {
+ ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ CheckService check = (CheckService) context.getService(ref);
+ Properties props = check.getProps();
+
+ byte[] b = (byte[]) props.get("bs");
+ short[] s = (short[]) props.get("ss");
+ int[] i = (int[]) props.get("is");
+ long[] l = (long[]) props.get("ls");
+ double[] d = (double[]) props.get("ds");
+ float[] f = (float[]) props.get("fs");
+ char[] c = (char[]) props.get("cs");
+ boolean[] bool = (boolean[]) props.get("bools");
+
+ assertEquals("Check b 0", b[0], 1);
+ assertEquals("Check b 1", b[1], 2);
+ assertEquals("Check b 2", b[2], 3);
+ assertEquals("Check s 0", s[0], 1);
+ assertEquals("Check s 1", s[1], 2);
+ assertEquals("Check s 2", s[2], 3);
+ assertEquals("Check i 0", i[0], 1);
+ assertEquals("Check i 1", i[1], 2);
+ assertEquals("Check i 2", i[2], 3);
+ assertEquals("Check l 0", l[0], 1);
+ assertEquals("Check l 1", l[1], 2);
+ assertEquals("Check l 2", l[2], 3);
+ assertEquals("Check d 0", d[0], 1);
+ assertEquals("Check d 1", d[1], 2);
+ assertEquals("Check d 2", d[2], 3);
+ assertEquals("Check f 0", f[0], 1);
+ assertEquals("Check f 1", f[1], 2);
+ assertEquals("Check f 2", f[2], 3);
+ assertEquals("Check c 0", c[0], 'a');
+ assertEquals("Check c 1", c[1], 'b');
+ assertEquals("Check c 2", c[2], 'c');
+ assertTrue("Check bool 0", bool[0]);
+ assertTrue("Check bool 1", bool[0]);
+ assertTrue("Check bool 2", bool[0]);
+
+ reconfigureString();
+
+ ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ check = (CheckService) context.getService(ref);
+ props = check.getProps();
+
+ b = (byte[]) props.get("bs");
+ s = (short[]) props.get("ss");
+ i = (int[]) props.get("is");
+ l = (long[]) props.get("ls");
+ d = (double[]) props.get("ds");
+ f = (float[]) props.get("fs");
+ c = (char[]) props.get("cs");
+ bool = (boolean[]) props.get("bools");
+
+ assertEquals("2) Check b 0", b[0], 3);
+ assertEquals("2) Check b 1", b[1], 2);
+ assertEquals("2) Check b 2", b[2], 1);
+ assertEquals("2) Check s 0", s[0], 3);
+ assertEquals("2) Check s 1", s[1], 2);
+ assertEquals("2) Check s 2", s[2], 1);
+ assertEquals("2) Check i 0", i[0], 3);
+ assertEquals("2) Check i 1", i[1], 2);
+ assertEquals("2) Check i 2", i[2], 1);
+ assertEquals("2) Check l 0", l[0], 3);
+ assertEquals("2) Check l 1", l[1], 2);
+ assertEquals("2) Check l 2", l[2], 1);
+ assertEquals("2) Check d 0", d[0], 3);
+ assertEquals("2) Check d 1", d[1], 2);
+ assertEquals("2) Check d 2", d[2], 1);
+ assertEquals("2) Check f 0", f[0], 3);
+ assertEquals("2) Check f 1", f[1], 2);
+ assertEquals("2) Check f 2", f[2], 1);
+ assertEquals("2) Check c 0", c[0], 'c');
+ assertEquals("2) Check c 1", c[1], 'b');
+ assertEquals("2) Check c 2", c[2], 'a');
+ assertFalse("2) Check bool 0", bool[0]);
+ assertFalse("2) Check bool 1", bool[0]);
+ assertFalse("2) Check bool 2", bool[0]);
+
+ }
+
+ public void testConfigurationObj() {
+ ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ CheckService check = (CheckService) context.getService(ref);
+ Properties props = check.getProps();
+
+ String s = (String) props.get("string");
+ String[] ss = (String[]) props.get("strings");
+
+ assertEquals("Check string", s, "foo");
+ assertEquals("Check strings 0", ss[0], "foo");
+ assertEquals("Check strings 1", ss[1], "bar");
+ assertEquals("Check strings 2", ss[2], "baz");
+
+ reconfigure();
+
+ ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ check = (CheckService) context.getService(ref);
+ props = check.getProps();
+
+ s = (String) props.get("string");
+ ss = (String[]) props.get("strings");
+
+ assertEquals("2) Check string", s, "bar");
+ assertEquals("2) Check strings 0", ss[0], "baz");
+ assertEquals("2) Check strings 1", ss[1], "bar");
+ assertEquals("2) Check strings 2", ss[2], "foo");
+ }
+
+ public void testConfigurationObjString() {
+ ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ CheckService check = (CheckService) context.getService(ref);
+ Properties props = check.getProps();
+
+ String s = (String) props.get("string");
+ String[] ss = (String[]) props.get("strings");
+
+ assertEquals("Check string", s, "foo");
+ assertEquals("Check strings 0", ss[0], "foo");
+ assertEquals("Check strings 1", ss[1], "bar");
+ assertEquals("Check strings 2", ss[2], "baz");
+
+ reconfigureString();
+
+ ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ check = (CheckService) context.getService(ref);
+ props = check.getProps();
+
+ s = (String) props.get("string");
+ ss = (String[]) props.get("strings");
+
+ assertEquals("2) Check string", s, "bar");
+ assertEquals("2) Check strings 0", ss[0], "baz");
+ assertEquals("2) Check strings 1", ss[1], "bar");
+ assertEquals("2) Check strings 2", ss[2], "foo");
+ }
+
+ private void reconfigure() {
+ Properties props2 = new Properties();
+ props2.put("name", "under-test");
+ props2.put("b", new Byte("2"));
+ props2.put("s", new Short("2"));
+ props2.put("i", new Integer("2"));
+ props2.put("l", new Long("2"));
+ props2.put("d", new Double("2"));
+ props2.put("f", new Float("2"));
+ props2.put("c", new Character('b'));
+ props2.put("bool", new Boolean(false));
+ props2.put("bs", new byte[]{(byte)3,(byte)2,(byte)1});
+ props2.put("ss", new short[]{(short)3,(short)2,(short)1});
+ props2.put("is", new int[]{3,2,1});
+ props2.put("ls", new long[]{3,2,1});
+ props2.put("ds", new double[]{3,2,1});
+ props2.put("fs", new float[]{3,2,1});
+ props2.put("cs", new char[]{'c','b','a'});
+ props2.put("bools", new boolean[]{false,false,false});
+ props2.put("string", "bar");
+ props2.put("strings", new String[]{"baz", "bar", "foo"});
+
+ instance.reconfigure(props2);
+ }
+
+ private void reconfigureString() {
+ Properties props2 = new Properties();
+ props2.put("name", "under-test");
+ props2.put("b", "2");
+ props2.put("s", "2");
+ props2.put("i", "2");
+ props2.put("l", "2");
+ props2.put("d", "2");
+ props2.put("f", "2");
+ props2.put("c", "b");
+ props2.put("bool", "false");
+ props2.put("bs", "{3, 2,1}");
+ props2.put("ss", "{3, 2,1}");
+ props2.put("is", "{3, 2,1}");
+ props2.put("ls", "{3, 2,1}");
+ props2.put("ds", "{3, 2,1}");
+ props2.put("fs", "{3, 2,1}");
+ props2.put("cs", "{c, b , a}");
+ props2.put("bools", "{false,false,false}");
+ props2.put("string", "bar");
+ props2.put("strings", "{baz, bar, foo}");
+
+ instance.reconfigure(props2);
+ }
+
+}
diff --git a/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/TestMethodProperties.java b/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/TestMethodProperties.java
new file mode 100644
index 0000000..b4e9afc
--- /dev/null
+++ b/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/TestMethodProperties.java
@@ -0,0 +1,1145 @@
+/*
+ * 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.configuration;
+
+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.configuration.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.ServiceReference;
+
+public class TestMethodProperties extends OSGiTestCase {
+
+ ComponentInstance instance;
+
+ ComponentInstance instance2;
+
+ public void setUp() {
+ Factory fact = Utils.getFactoryByName(context, "CONFIG-MethodConfigurableCheckService");
+ Properties props = new Properties();
+ props.put("name", "under-test");
+ props.put("b", "1");
+ props.put("s", "1");
+ props.put("i", "1");
+ props.put("l", "1");
+ props.put("d", "1");
+ props.put("f", "1");
+ props.put("c", "a");
+ props.put("bool", "true");
+ props.put("bs", "{1,2,3}");
+ props.put("ss", "{1,2,3}");
+ props.put("is", "{1,2,3}");
+ props.put("ls", "{1,2,3}");
+ props.put("ds", "{1,2,3}");
+ props.put("fs", "{1,2,3}");
+ props.put("cs", "{a,b,c}");
+ props.put("bools", "{true,true,true}");
+ props.put("string", "foo");
+ props.put("strings", "{foo, bar, baz}");
+
+ try {
+ instance = fact.createComponentInstance(props);
+ } catch(Exception e) {
+ fail("Cannot create the under-test instance : " + e.getMessage());
+ }
+
+ Properties props2 = new Properties();
+ props2.put("name", "under-test-2");
+ props2.put("b", new Byte("1"));
+ props2.put("s", new Short("1"));
+ props2.put("i", new Integer("1"));
+ props2.put("l", new Long("1"));
+ props2.put("d", new Double("1"));
+ props2.put("f", new Float("1"));
+ props2.put("c", new Character('a'));
+ props2.put("bool", new Boolean(true));
+ props2.put("bs", new byte[] {1,2,3});
+ props2.put("ss", new short[] {1,2,3});
+ props2.put("is", new int[] {1,2,3});
+ props2.put("ls", new long[] {1,2,3});
+ props2.put("ds", new double[] {1,2,3});
+ props2.put("fs", new float[] {1,2,3});
+ props2.put("cs", new char[] {'a','b','c'});
+ props2.put("bools", new boolean[] {true,true,true});
+ props2.put("string", "foo");
+ props2.put("strings", new String[] {"foo", "bar", "baz"});
+
+ try {
+ instance2 = fact.createComponentInstance(props2);
+ } catch(Exception e) {
+ e.printStackTrace();
+ fail("Cannot create the under-test instance 2 : " + e.getMessage());
+ }
+
+
+ }
+
+ public void tearDown() {
+ instance.dispose();
+ instance2.dispose();
+ instance = null;
+ instance2 = null;
+ }
+
+ public void testConfigurationPrimitive() {
+ ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ CheckService check = (CheckService) context.getService(ref);
+ Properties props = check.getProps();
+
+ Byte b = (Byte) props.get("b");
+ Short s = (Short) props.get("s");
+ Integer i = (Integer) props.get("i");
+ Long l = (Long) props.get("l");
+ Double d = (Double) props.get("d");
+ Float f = (Float) props.get("f");
+ Character c = (Character) props.get("c");
+ Boolean bool = (Boolean) props.get("bool");
+
+ assertEquals("Check b", b, new Byte("1"));
+ assertEquals("Check s", s, new Short("1"));
+ assertEquals("Check i", i, new Integer("1"));
+ assertEquals("Check l", l, new Long("1"));
+ assertEquals("Check d", d, new Double("1"));
+ assertEquals("Check f", f, new Float("1"));
+ assertEquals("Check c", c, new Character('a'));
+ assertEquals("Check bool", bool, new Boolean("true"));
+
+// Integer upb = (Integer) props.get("upb");
+// Integer ups = (Integer) props.get("ups");
+// Integer upi = (Integer) props.get("upi");
+// Integer upl = (Integer) props.get("upl");
+// Integer upd = (Integer) props.get("upd");
+// Integer upf = (Integer) props.get("upf");
+// Integer upc = (Integer) props.get("upc");
+// Integer upbool = (Integer) props.get("upbool");
+//
+// assertEquals("Check upb", upb, new Integer(1));
+// assertEquals("Check ups", ups, new Integer(1));
+// assertEquals("Check upi", upi, new Integer(1));
+// assertEquals("Check upl", upl, new Integer(1));
+// assertEquals("Check upd", upd, new Integer(1));
+// assertEquals("Check upf", upf, new Integer(1));
+// assertEquals("Check upc", upc, new Integer(1));
+// assertEquals("Check upbool", upbool, new Integer(1));
+
+ reconfigure(instance);
+
+ ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ check = (CheckService) context.getService(ref);
+ props = check.getProps();
+
+ b = (Byte) props.get("b");
+ s = (Short) props.get("s");
+ i = (Integer) props.get("i");
+ l = (Long) props.get("l");
+ d = (Double) props.get("d");
+ f = (Float) props.get("f");
+ c = (Character) props.get("c");
+ bool = (Boolean) props.get("bool");
+
+ assertEquals("2) Check b ("+b+")", b, new Byte("2"));
+ assertEquals("2) Check s", s, new Short("2"));
+ assertEquals("2) Check i", i, new Integer("2"));
+ assertEquals("2) Check l", l, new Long("2"));
+ assertEquals("2) Check d", d, new Double("2"));
+ assertEquals("2) Check f", f, new Float("2"));
+ assertEquals("2) Check c", c, new Character('b'));
+ assertEquals("2) Check bool", bool, new Boolean("false"));
+
+// upb = (Integer) props.get("upb");
+// ups = (Integer) props.get("ups");
+// upi = (Integer) props.get("upi");
+// upl = (Integer) props.get("upl");
+// upd = (Integer) props.get("upd");
+// upf = (Integer) props.get("upf");
+// upc = (Integer) props.get("upc");
+// upbool = (Integer) props.get("upbool");
+//
+// assertEquals("2) Check upb", upb, new Integer(2));
+// assertEquals("2) Check ups", ups, new Integer(2));
+// assertEquals("2) Check upi", upi, new Integer(2));
+// assertEquals("2) Check upl", upl, new Integer(2));
+// assertEquals("2) Check upd", upd, new Integer(2));
+// assertEquals("2) Check upf", upf, new Integer(2));
+// assertEquals("2) Check upc", upc, new Integer(2));
+// assertEquals("2) Check upbool", upbool, new Integer(2));
+
+ }
+
+ public void testConfigurationPrimitiveString() {
+ ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ CheckService check = (CheckService) context.getService(ref);
+ Properties props = check.getProps();
+
+ Byte b = (Byte) props.get("b");
+ Short s = (Short) props.get("s");
+ Integer i = (Integer) props.get("i");
+ Long l = (Long) props.get("l");
+ Double d = (Double) props.get("d");
+ Float f = (Float) props.get("f");
+ Character c = (Character) props.get("c");
+ Boolean bool = (Boolean) props.get("bool");
+
+ assertEquals("Check b", b, new Byte("1"));
+ assertEquals("Check s", s, new Short("1"));
+ assertEquals("Check i", i, new Integer("1"));
+ assertEquals("Check l", l, new Long("1"));
+ assertEquals("Check d", d, new Double("1"));
+ assertEquals("Check f", f, new Float("1"));
+ assertEquals("Check c", c, new Character('a'));
+ assertEquals("Check bool", bool, new Boolean("true"));
+
+// Integer upb = (Integer) props.get("upb");
+// Integer ups = (Integer) props.get("ups");
+// Integer upi = (Integer) props.get("upi");
+// Integer upl = (Integer) props.get("upl");
+// Integer upd = (Integer) props.get("upd");
+// Integer upf = (Integer) props.get("upf");
+// Integer upc = (Integer) props.get("upc");
+// Integer upbool = (Integer) props.get("upbool");
+//
+// assertEquals("Check upb", upb, new Integer(1));
+// assertEquals("Check ups", ups, new Integer(1));
+// assertEquals("Check upi", upi, new Integer(1));
+// assertEquals("Check upl", upl, new Integer(1));
+// assertEquals("Check upd", upd, new Integer(1));
+// assertEquals("Check upf", upf, new Integer(1));
+// assertEquals("Check upc", upc, new Integer(1));
+// assertEquals("Check upbool", upbool, new Integer(1));
+//
+ reconfigureString(instance);
+
+ ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ check = (CheckService) context.getService(ref);
+ props = check.getProps();
+
+ b = (Byte) props.get("b");
+ s = (Short) props.get("s");
+ i = (Integer) props.get("i");
+ l = (Long) props.get("l");
+ d = (Double) props.get("d");
+ f = (Float) props.get("f");
+ c = (Character) props.get("c");
+ bool = (Boolean) props.get("bool");
+
+ assertEquals("2) Check b ("+b+")", b, new Byte("2"));
+ assertEquals("2) Check s", s, new Short("2"));
+ assertEquals("2) Check i", i, new Integer("2"));
+ assertEquals("2) Check l", l, new Long("2"));
+ assertEquals("2) Check d", d, new Double("2"));
+ assertEquals("2) Check f", f, new Float("2"));
+ assertEquals("2) Check c", c, new Character('b'));
+ assertEquals("2) Check bool", bool, new Boolean("false"));
+
+// upb = (Integer) props.get("upb");
+// ups = (Integer) props.get("ups");
+// upi = (Integer) props.get("upi");
+// upl = (Integer) props.get("upl");
+// upd = (Integer) props.get("upd");
+// upf = (Integer) props.get("upf");
+// upc = (Integer) props.get("upc");
+// upbool = (Integer) props.get("upbool");
+//
+// assertEquals("2) Check upb", upb, new Integer(2));
+// assertEquals("2) Check ups", ups, new Integer(2));
+// assertEquals("2) Check upi", upi, new Integer(2));
+// assertEquals("2) Check upl", upl, new Integer(2));
+// assertEquals("2) Check upd", upd, new Integer(2));
+// assertEquals("2) Check upf", upf, new Integer(2));
+// assertEquals("2) Check upc", upc, new Integer(2));
+// assertEquals("2) Check upbool", upbool, new Integer(2));
+
+ }
+
+ public void testConfigurationPrimitiveArrays() {
+ ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ CheckService check = (CheckService) context.getService(ref);
+ Properties props = check.getProps();
+
+ byte[] b = (byte[]) props.get("bs");
+ short[] s = (short[]) props.get("ss");
+ int[] i = (int[]) props.get("is");
+ long[] l = (long[]) props.get("ls");
+ double[] d = (double[]) props.get("ds");
+ float[] f = (float[]) props.get("fs");
+ char[] c = (char[]) props.get("cs");
+ boolean[] bool = (boolean[]) props.get("bools");
+
+ assertEquals("Check b 0", b[0], 1);
+ assertEquals("Check b 1", b[1], 2);
+ assertEquals("Check b 2", b[2], 3);
+ assertEquals("Check s 0", s[0], 1);
+ assertEquals("Check s 1", s[1], 2);
+ assertEquals("Check s 2", s[2], 3);
+ assertEquals("Check i 0", i[0], 1);
+ assertEquals("Check i 1", i[1], 2);
+ assertEquals("Check i 2", i[2], 3);
+ assertEquals("Check l 0", l[0], 1);
+ assertEquals("Check l 1", l[1], 2);
+ assertEquals("Check l 2", l[2], 3);
+ assertEquals("Check d 0", d[0], 1);
+ assertEquals("Check d 1", d[1], 2);
+ assertEquals("Check d 2", d[2], 3);
+ assertEquals("Check f 0", f[0], 1);
+ assertEquals("Check f 1", f[1], 2);
+ assertEquals("Check f 2", f[2], 3);
+ assertEquals("Check c 0", c[0], 'a');
+ assertEquals("Check c 1", c[1], 'b');
+ assertEquals("Check c 2", c[2], 'c');
+ assertTrue("Check bool 0", bool[0]);
+ assertTrue("Check bool 1", bool[0]);
+ assertTrue("Check bool 2", bool[0]);
+
+// Integer upb = (Integer) props.get("upbs");
+// Integer ups = (Integer) props.get("upss");
+// Integer upi = (Integer) props.get("upis");
+// Integer upl = (Integer) props.get("upls");
+// Integer upd = (Integer) props.get("upds");
+// Integer upf = (Integer) props.get("upfs");
+// Integer upc = (Integer) props.get("upcs");
+// Integer upbool = (Integer) props.get("upbools");
+//
+// assertEquals("Check upb", upb, new Integer(1));
+// assertEquals("Check ups", ups, new Integer(1));
+// assertEquals("Check upi", upi, new Integer(1));
+// assertEquals("Check upl", upl, new Integer(1));
+// assertEquals("Check upd", upd, new Integer(1));
+// assertEquals("Check upf", upf, new Integer(1));
+// assertEquals("Check upc", upc, new Integer(1));
+// assertEquals("Check upbool", upbool, new Integer(1));
+
+ reconfigure(instance);
+
+ ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ check = (CheckService) context.getService(ref);
+ props = check.getProps();
+
+ b = (byte[]) props.get("bs");
+ s = (short[]) props.get("ss");
+ i = (int[]) props.get("is");
+ l = (long[]) props.get("ls");
+ d = (double[]) props.get("ds");
+ f = (float[]) props.get("fs");
+ c = (char[]) props.get("cs");
+ bool = (boolean[]) props.get("bools");
+
+ assertEquals("2) Check b 0", b[0], 3);
+ assertEquals("2) Check b 1", b[1], 2);
+ assertEquals("2) Check b 2", b[2], 1);
+ assertEquals("2) Check s 0", s[0], 3);
+ assertEquals("2) Check s 1", s[1], 2);
+ assertEquals("2) Check s 2", s[2], 1);
+ assertEquals("2) Check i 0", i[0], 3);
+ assertEquals("2) Check i 1", i[1], 2);
+ assertEquals("2) Check i 2", i[2], 1);
+ assertEquals("2) Check l 0", l[0], 3);
+ assertEquals("2) Check l 1", l[1], 2);
+ assertEquals("2) Check l 2", l[2], 1);
+ assertEquals("2) Check d 0", d[0], 3);
+ assertEquals("2) Check d 1", d[1], 2);
+ assertEquals("2) Check d 2", d[2], 1);
+ assertEquals("2) Check f 0", f[0], 3);
+ assertEquals("2) Check f 1", f[1], 2);
+ assertEquals("2) Check f 2", f[2], 1);
+ assertEquals("2) Check c 0", c[0], 'c');
+ assertEquals("2) Check c 1", c[1], 'b');
+ assertEquals("2) Check c 2", c[2], 'a');
+ assertFalse("2) Check bool 0", bool[0]);
+ assertFalse("2) Check bool 1", bool[0]);
+ assertFalse("2) Check bool 2", bool[0]);
+
+// upb = (Integer) props.get("upbs");
+// ups = (Integer) props.get("upss");
+// upi = (Integer) props.get("upis");
+// upl = (Integer) props.get("upls");
+// upd = (Integer) props.get("upds");
+// upf = (Integer) props.get("upfs");
+// upc = (Integer) props.get("upcs");
+// upbool = (Integer) props.get("upbools");
+//
+// assertEquals("2) Check upb", upb, new Integer(2));
+// assertEquals("2) Check ups", ups, new Integer(2));
+// assertEquals("2) Check upi", upi, new Integer(2));
+// assertEquals("2) Check upl", upl, new Integer(2));
+// assertEquals("2) Check upd", upd, new Integer(2));
+// assertEquals("2) Check upf", upf, new Integer(2));
+// assertEquals("2) Check upc", upc, new Integer(2));
+// assertEquals("2) Check upbool", upbool, new Integer(2));
+
+ }
+
+ public void testConfigurationPrimitiveArraysString() {
+ ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ CheckService check = (CheckService) context.getService(ref);
+ Properties props = check.getProps();
+
+ byte[] b = (byte[]) props.get("bs");
+ short[] s = (short[]) props.get("ss");
+ int[] i = (int[]) props.get("is");
+ long[] l = (long[]) props.get("ls");
+ double[] d = (double[]) props.get("ds");
+ float[] f = (float[]) props.get("fs");
+ char[] c = (char[]) props.get("cs");
+ boolean[] bool = (boolean[]) props.get("bools");
+
+ assertEquals("Check b 0", b[0], 1);
+ assertEquals("Check b 1", b[1], 2);
+ assertEquals("Check b 2", b[2], 3);
+ assertEquals("Check s 0", s[0], 1);
+ assertEquals("Check s 1", s[1], 2);
+ assertEquals("Check s 2", s[2], 3);
+ assertEquals("Check i 0", i[0], 1);
+ assertEquals("Check i 1", i[1], 2);
+ assertEquals("Check i 2", i[2], 3);
+ assertEquals("Check l 0", l[0], 1);
+ assertEquals("Check l 1", l[1], 2);
+ assertEquals("Check l 2", l[2], 3);
+ assertEquals("Check d 0", d[0], 1);
+ assertEquals("Check d 1", d[1], 2);
+ assertEquals("Check d 2", d[2], 3);
+ assertEquals("Check f 0", f[0], 1);
+ assertEquals("Check f 1", f[1], 2);
+ assertEquals("Check f 2", f[2], 3);
+ assertEquals("Check c 0", c[0], 'a');
+ assertEquals("Check c 1", c[1], 'b');
+ assertEquals("Check c 2", c[2], 'c');
+ assertTrue("Check bool 0", bool[0]);
+ assertTrue("Check bool 1", bool[0]);
+ assertTrue("Check bool 2", bool[0]);
+
+// Integer upb = (Integer) props.get("upbs");
+// Integer ups = (Integer) props.get("upss");
+// Integer upi = (Integer) props.get("upis");
+// Integer upl = (Integer) props.get("upls");
+// Integer upd = (Integer) props.get("upds");
+// Integer upf = (Integer) props.get("upfs");
+// Integer upc = (Integer) props.get("upcs");
+// Integer upbool = (Integer) props.get("upbools");
+//
+// assertEquals("Check upb", upb, new Integer(1));
+// assertEquals("Check ups", ups, new Integer(1));
+// assertEquals("Check upi", upi, new Integer(1));
+// assertEquals("Check upl", upl, new Integer(1));
+// assertEquals("Check upd", upd, new Integer(1));
+// assertEquals("Check upf", upf, new Integer(1));
+// assertEquals("Check upc", upc, new Integer(1));
+// assertEquals("Check upbool", upbool, new Integer(1));
+
+ reconfigureString(instance);
+
+ ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ check = (CheckService) context.getService(ref);
+ props = check.getProps();
+
+ b = (byte[]) props.get("bs");
+ s = (short[]) props.get("ss");
+ i = (int[]) props.get("is");
+ l = (long[]) props.get("ls");
+ d = (double[]) props.get("ds");
+ f = (float[]) props.get("fs");
+ c = (char[]) props.get("cs");
+ bool = (boolean[]) props.get("bools");
+
+ assertEquals("2) Check b 0", b[0], 3);
+ assertEquals("2) Check b 1", b[1], 2);
+ assertEquals("2) Check b 2", b[2], 1);
+ assertEquals("2) Check s 0", s[0], 3);
+ assertEquals("2) Check s 1", s[1], 2);
+ assertEquals("2) Check s 2", s[2], 1);
+ assertEquals("2) Check i 0", i[0], 3);
+ assertEquals("2) Check i 1", i[1], 2);
+ assertEquals("2) Check i 2", i[2], 1);
+ assertEquals("2) Check l 0", l[0], 3);
+ assertEquals("2) Check l 1", l[1], 2);
+ assertEquals("2) Check l 2", l[2], 1);
+ assertEquals("2) Check d 0", d[0], 3);
+ assertEquals("2) Check d 1", d[1], 2);
+ assertEquals("2) Check d 2", d[2], 1);
+ assertEquals("2) Check f 0", f[0], 3);
+ assertEquals("2) Check f 1", f[1], 2);
+ assertEquals("2) Check f 2", f[2], 1);
+ assertEquals("2) Check c 0", c[0], 'c');
+ assertEquals("2) Check c 1", c[1], 'b');
+ assertEquals("2) Check c 2", c[2], 'a');
+ assertFalse("2) Check bool 0", bool[0]);
+ assertFalse("2) Check bool 1", bool[0]);
+ assertFalse("2) Check bool 2", bool[0]);
+
+// upb = (Integer) props.get("upbs");
+// ups = (Integer) props.get("upss");
+// upi = (Integer) props.get("upis");
+// upl = (Integer) props.get("upls");
+// upd = (Integer) props.get("upds");
+// upf = (Integer) props.get("upfs");
+// upc = (Integer) props.get("upcs");
+// upbool = (Integer) props.get("upbools");
+//
+// assertEquals("2) Check upb", upb, new Integer(2));
+// assertEquals("2) Check ups", ups, new Integer(2));
+// assertEquals("2) Check upi", upi, new Integer(2));
+// assertEquals("2) Check upl", upl, new Integer(2));
+// assertEquals("2) Check upd", upd, new Integer(2));
+// assertEquals("2) Check upf", upf, new Integer(2));
+// assertEquals("2) Check upc", upc, new Integer(2));
+// assertEquals("2) Check upbool", upbool, new Integer(2));
+
+ }
+
+ public void testConfigurationObj() {
+ ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ CheckService check = (CheckService) context.getService(ref);
+ Properties props = check.getProps();
+
+ String s = (String) props.get("string");
+ String[] ss = (String[]) props.get("strings");
+
+ assertEquals("Check string", s, "foo");
+ assertEquals("Check strings 0", ss[0], "foo");
+ assertEquals("Check strings 1", ss[1], "bar");
+ assertEquals("Check strings 2", ss[2], "baz");
+
+// Integer upString = (Integer) props.get("upstring");
+// Integer upStrings = (Integer) props.get("upstrings");
+//
+// assertEquals("Check upString", upString, new Integer(1));
+// assertEquals("Check upStrings", upStrings, new Integer(1));
+
+ reconfigure(instance);
+
+ ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ check = (CheckService) context.getService(ref);
+ props = check.getProps();
+
+ s = (String) props.get("string");
+ ss = (String[]) props.get("strings");
+
+ assertEquals("2) Check string", s, "bar");
+ assertEquals("2) Check strings 0", ss[0], "baz");
+ assertEquals("2) Check strings 1", ss[1], "bar");
+ assertEquals("2) Check strings 2", ss[2], "foo");
+
+// upString = (Integer) props.get("upstring");
+// upStrings = (Integer) props.get("upstrings");
+//
+// assertEquals("2) Check upString", upString, new Integer(2));
+// assertEquals("2) Check upStrings", upStrings, new Integer(2));
+ }
+
+ public void testConfigurationObjString() {
+ ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ CheckService check = (CheckService) context.getService(ref);
+ Properties props = check.getProps();
+
+ String s = (String) props.get("string");
+ String[] ss = (String[]) props.get("strings");
+
+ assertEquals("Check string", s, "foo");
+ assertEquals("Check strings 0", ss[0], "foo");
+ assertEquals("Check strings 1", ss[1], "bar");
+ assertEquals("Check strings 2", ss[2], "baz");
+
+// Integer upString = (Integer) props.get("upstring");
+// Integer upStrings = (Integer) props.get("upstrings");
+//
+// assertEquals("Check upString", upString, new Integer(1));
+// assertEquals("Check upStrings", upStrings, new Integer(1));
+
+ reconfigureString(instance);
+
+ ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ check = (CheckService) context.getService(ref);
+ props = check.getProps();
+
+ s = (String) props.get("string");
+ ss = (String[]) props.get("strings");
+
+ assertEquals("2) Check string", s, "bar");
+ assertEquals("2) Check strings 0", ss[0], "baz");
+ assertEquals("2) Check strings 1", ss[1], "bar");
+ assertEquals("2) Check strings 2", ss[2], "foo");
+
+// upString = (Integer) props.get("upstring");
+// upStrings = (Integer) props.get("upstrings");
+//
+// assertEquals("2) Check upString", upString, new Integer(2));
+// assertEquals("2) Check upStrings", upStrings, new Integer(2));
+ }
+
+ public void testConfigurationPrimitive2() {
+ ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance2.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ CheckService check = (CheckService) context.getService(ref);
+ Properties props = check.getProps();
+
+ Byte b = (Byte) props.get("b");
+ Short s = (Short) props.get("s");
+ Integer i = (Integer) props.get("i");
+ Long l = (Long) props.get("l");
+ Double d = (Double) props.get("d");
+ Float f = (Float) props.get("f");
+ Character c = (Character) props.get("c");
+ Boolean bool = (Boolean) props.get("bool");
+
+ assertEquals("Check b", b, new Byte("1"));
+ assertEquals("Check s", s, new Short("1"));
+ assertEquals("Check i", i, new Integer("1"));
+ assertEquals("Check l", l, new Long("1"));
+ assertEquals("Check d", d, new Double("1"));
+ assertEquals("Check f", f, new Float("1"));
+ assertEquals("Check c", c, new Character('a'));
+ assertEquals("Check bool", bool, new Boolean("true"));
+
+// Integer upb = (Integer) props.get("upb");
+// Integer ups = (Integer) props.get("ups");
+// Integer upi = (Integer) props.get("upi");
+// Integer upl = (Integer) props.get("upl");
+// Integer upd = (Integer) props.get("upd");
+// Integer upf = (Integer) props.get("upf");
+// Integer upc = (Integer) props.get("upc");
+// Integer upbool = (Integer) props.get("upbool");
+//
+// assertEquals("Check upb", upb, new Integer(1));
+// assertEquals("Check ups", ups, new Integer(1));
+// assertEquals("Check upi", upi, new Integer(1));
+// assertEquals("Check upl", upl, new Integer(1));
+// assertEquals("Check upd", upd, new Integer(1));
+// assertEquals("Check upf", upf, new Integer(1));
+// assertEquals("Check upc", upc, new Integer(1));
+// assertEquals("Check upbool", upbool, new Integer(1));
+
+ reconfigure(instance2);
+
+ ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance2.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ check = (CheckService) context.getService(ref);
+ props = check.getProps();
+
+ b = (Byte) props.get("b");
+ s = (Short) props.get("s");
+ i = (Integer) props.get("i");
+ l = (Long) props.get("l");
+ d = (Double) props.get("d");
+ f = (Float) props.get("f");
+ c = (Character) props.get("c");
+ bool = (Boolean) props.get("bool");
+
+ assertEquals("2) Check b ("+b+")", b, new Byte("2"));
+ assertEquals("2) Check s", s, new Short("2"));
+ assertEquals("2) Check i", i, new Integer("2"));
+ assertEquals("2) Check l", l, new Long("2"));
+ assertEquals("2) Check d", d, new Double("2"));
+ assertEquals("2) Check f", f, new Float("2"));
+ assertEquals("2) Check c", c, new Character('b'));
+ assertEquals("2) Check bool", bool, new Boolean("false"));
+
+// upb = (Integer) props.get("upb");
+// ups = (Integer) props.get("ups");
+// upi = (Integer) props.get("upi");
+// upl = (Integer) props.get("upl");
+// upd = (Integer) props.get("upd");
+// upf = (Integer) props.get("upf");
+// upc = (Integer) props.get("upc");
+// upbool = (Integer) props.get("upbool");
+//
+// assertEquals("2) Check upb", upb, new Integer(2));
+// assertEquals("2) Check ups", ups, new Integer(2));
+// assertEquals("2) Check upi", upi, new Integer(2));
+// assertEquals("2) Check upl", upl, new Integer(2));
+// assertEquals("2) Check upd", upd, new Integer(2));
+// assertEquals("2) Check upf", upf, new Integer(2));
+// assertEquals("2) Check upc", upc, new Integer(2));
+// assertEquals("2) Check upbool", upbool, new Integer(2));
+
+ }
+
+ public void testConfigurationPrimitive2String() {
+ ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance2.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ CheckService check = (CheckService) context.getService(ref);
+ Properties props = check.getProps();
+
+ Byte b = (Byte) props.get("b");
+ Short s = (Short) props.get("s");
+ Integer i = (Integer) props.get("i");
+ Long l = (Long) props.get("l");
+ Double d = (Double) props.get("d");
+ Float f = (Float) props.get("f");
+ Character c = (Character) props.get("c");
+ Boolean bool = (Boolean) props.get("bool");
+
+ assertEquals("Check b", b, new Byte("1"));
+ assertEquals("Check s", s, new Short("1"));
+ assertEquals("Check i", i, new Integer("1"));
+ assertEquals("Check l", l, new Long("1"));
+ assertEquals("Check d", d, new Double("1"));
+ assertEquals("Check f", f, new Float("1"));
+ assertEquals("Check c", c, new Character('a'));
+ assertEquals("Check bool", bool, new Boolean("true"));
+
+// Integer upb = (Integer) props.get("upb");
+// Integer ups = (Integer) props.get("ups");
+// Integer upi = (Integer) props.get("upi");
+// Integer upl = (Integer) props.get("upl");
+// Integer upd = (Integer) props.get("upd");
+// Integer upf = (Integer) props.get("upf");
+// Integer upc = (Integer) props.get("upc");
+// Integer upbool = (Integer) props.get("upbool");
+//
+// assertEquals("Check upb", upb, new Integer(1));
+// assertEquals("Check ups", ups, new Integer(1));
+// assertEquals("Check upi", upi, new Integer(1));
+// assertEquals("Check upl", upl, new Integer(1));
+// assertEquals("Check upd", upd, new Integer(1));
+// assertEquals("Check upf", upf, new Integer(1));
+// assertEquals("Check upc", upc, new Integer(1));
+// assertEquals("Check upbool", upbool, new Integer(1));
+
+ reconfigureString(instance2);
+
+ ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance2.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ check = (CheckService) context.getService(ref);
+ props = check.getProps();
+
+ b = (Byte) props.get("b");
+ s = (Short) props.get("s");
+ i = (Integer) props.get("i");
+ l = (Long) props.get("l");
+ d = (Double) props.get("d");
+ f = (Float) props.get("f");
+ c = (Character) props.get("c");
+ bool = (Boolean) props.get("bool");
+
+ assertEquals("2) Check b ("+b+")", b, new Byte("2"));
+ assertEquals("2) Check s", s, new Short("2"));
+ assertEquals("2) Check i", i, new Integer("2"));
+ assertEquals("2) Check l", l, new Long("2"));
+ assertEquals("2) Check d", d, new Double("2"));
+ assertEquals("2) Check f", f, new Float("2"));
+ assertEquals("2) Check c", c, new Character('b'));
+ assertEquals("2) Check bool", bool, new Boolean("false"));
+
+// upb = (Integer) props.get("upb");
+// ups = (Integer) props.get("ups");
+// upi = (Integer) props.get("upi");
+// upl = (Integer) props.get("upl");
+// upd = (Integer) props.get("upd");
+// upf = (Integer) props.get("upf");
+// upc = (Integer) props.get("upc");
+// upbool = (Integer) props.get("upbool");
+//
+// assertEquals("2) Check upb", upb, new Integer(2));
+// assertEquals("2) Check ups", ups, new Integer(2));
+// assertEquals("2) Check upi", upi, new Integer(2));
+// assertEquals("2) Check upl", upl, new Integer(2));
+// assertEquals("2) Check upd", upd, new Integer(2));
+// assertEquals("2) Check upf", upf, new Integer(2));
+// assertEquals("2) Check upc", upc, new Integer(2));
+// assertEquals("2) Check upbool", upbool, new Integer(2));
+
+ }
+
+ public void testConfigurationPrimitiveArrays2() {
+ ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance2.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ CheckService check = (CheckService) context.getService(ref);
+ Properties props = check.getProps();
+
+ byte[] b = (byte[]) props.get("bs");
+ short[] s = (short[]) props.get("ss");
+ int[] i = (int[]) props.get("is");
+ long[] l = (long[]) props.get("ls");
+ double[] d = (double[]) props.get("ds");
+ float[] f = (float[]) props.get("fs");
+ char[] c = (char[]) props.get("cs");
+ boolean[] bool = (boolean[]) props.get("bools");
+
+ assertEquals("Check b 0", b[0], 1);
+ assertEquals("Check b 1", b[1], 2);
+ assertEquals("Check b 2", b[2], 3);
+ assertEquals("Check s 0", s[0], 1);
+ assertEquals("Check s 1", s[1], 2);
+ assertEquals("Check s 2", s[2], 3);
+ assertEquals("Check i 0", i[0], 1);
+ assertEquals("Check i 1", i[1], 2);
+ assertEquals("Check i 2", i[2], 3);
+ assertEquals("Check l 0", l[0], 1);
+ assertEquals("Check l 1", l[1], 2);
+ assertEquals("Check l 2", l[2], 3);
+ assertEquals("Check d 0", d[0], 1);
+ assertEquals("Check d 1", d[1], 2);
+ assertEquals("Check d 2", d[2], 3);
+ assertEquals("Check f 0", f[0], 1);
+ assertEquals("Check f 1", f[1], 2);
+ assertEquals("Check f 2", f[2], 3);
+ assertEquals("Check c 0", c[0], 'a');
+ assertEquals("Check c 1", c[1], 'b');
+ assertEquals("Check c 2", c[2], 'c');
+ assertTrue("Check bool 0", bool[0]);
+ assertTrue("Check bool 1", bool[0]);
+ assertTrue("Check bool 2", bool[0]);
+
+// Integer upb = (Integer) props.get("upbs");
+// Integer ups = (Integer) props.get("upss");
+// Integer upi = (Integer) props.get("upis");
+// Integer upl = (Integer) props.get("upls");
+// Integer upd = (Integer) props.get("upds");
+// Integer upf = (Integer) props.get("upfs");
+// Integer upc = (Integer) props.get("upcs");
+// Integer upbool = (Integer) props.get("upbools");
+//
+// assertEquals("Check upb", upb, new Integer(1));
+// assertEquals("Check ups", ups, new Integer(1));
+// assertEquals("Check upi", upi, new Integer(1));
+// assertEquals("Check upl", upl, new Integer(1));
+// assertEquals("Check upd", upd, new Integer(1));
+// assertEquals("Check upf", upf, new Integer(1));
+// assertEquals("Check upc", upc, new Integer(1));
+// assertEquals("Check upbool", upbool, new Integer(1));
+
+ reconfigure(instance2);
+
+ ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance2.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ check = (CheckService) context.getService(ref);
+ props = check.getProps();
+
+ b = (byte[]) props.get("bs");
+ s = (short[]) props.get("ss");
+ i = (int[]) props.get("is");
+ l = (long[]) props.get("ls");
+ d = (double[]) props.get("ds");
+ f = (float[]) props.get("fs");
+ c = (char[]) props.get("cs");
+ bool = (boolean[]) props.get("bools");
+
+ assertEquals("2) Check b 0", b[0], 3);
+ assertEquals("2) Check b 1", b[1], 2);
+ assertEquals("2) Check b 2", b[2], 1);
+ assertEquals("2) Check s 0", s[0], 3);
+ assertEquals("2) Check s 1", s[1], 2);
+ assertEquals("2) Check s 2", s[2], 1);
+ assertEquals("2) Check i 0", i[0], 3);
+ assertEquals("2) Check i 1", i[1], 2);
+ assertEquals("2) Check i 2", i[2], 1);
+ assertEquals("2) Check l 0", l[0], 3);
+ assertEquals("2) Check l 1", l[1], 2);
+ assertEquals("2) Check l 2", l[2], 1);
+ assertEquals("2) Check d 0", d[0], 3);
+ assertEquals("2) Check d 1", d[1], 2);
+ assertEquals("2) Check d 2", d[2], 1);
+ assertEquals("2) Check f 0", f[0], 3);
+ assertEquals("2) Check f 1", f[1], 2);
+ assertEquals("2) Check f 2", f[2], 1);
+ assertEquals("2) Check c 0", c[0], 'c');
+ assertEquals("2) Check c 1", c[1], 'b');
+ assertEquals("2) Check c 2", c[2], 'a');
+ assertFalse("2) Check bool 0", bool[0]);
+ assertFalse("2) Check bool 1", bool[0]);
+ assertFalse("2) Check bool 2", bool[0]);
+
+// upb = (Integer) props.get("upbs");
+// ups = (Integer) props.get("upss");
+// upi = (Integer) props.get("upis");
+// upl = (Integer) props.get("upls");
+// upd = (Integer) props.get("upds");
+// upf = (Integer) props.get("upfs");
+// upc = (Integer) props.get("upcs");
+// upbool = (Integer) props.get("upbools");
+//
+// assertEquals("2) Check upb", upb, new Integer(2));
+// assertEquals("2) Check ups", ups, new Integer(2));
+// assertEquals("2) Check upi", upi, new Integer(2));
+// assertEquals("2) Check upl", upl, new Integer(2));
+// assertEquals("2) Check upd", upd, new Integer(2));
+// assertEquals("2) Check upf", upf, new Integer(2));
+// assertEquals("2) Check upc", upc, new Integer(2));
+// assertEquals("2) Check upbool", upbool, new Integer(2));
+
+ }
+
+ public void testConfigurationPrimitiveArrays2String() {
+ ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance2.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ CheckService check = (CheckService) context.getService(ref);
+ Properties props = check.getProps();
+
+ byte[] b = (byte[]) props.get("bs");
+ short[] s = (short[]) props.get("ss");
+ int[] i = (int[]) props.get("is");
+ long[] l = (long[]) props.get("ls");
+ double[] d = (double[]) props.get("ds");
+ float[] f = (float[]) props.get("fs");
+ char[] c = (char[]) props.get("cs");
+ boolean[] bool = (boolean[]) props.get("bools");
+
+ assertEquals("Check b 0", b[0], 1);
+ assertEquals("Check b 1", b[1], 2);
+ assertEquals("Check b 2", b[2], 3);
+ assertEquals("Check s 0", s[0], 1);
+ assertEquals("Check s 1", s[1], 2);
+ assertEquals("Check s 2", s[2], 3);
+ assertEquals("Check i 0", i[0], 1);
+ assertEquals("Check i 1", i[1], 2);
+ assertEquals("Check i 2", i[2], 3);
+ assertEquals("Check l 0", l[0], 1);
+ assertEquals("Check l 1", l[1], 2);
+ assertEquals("Check l 2", l[2], 3);
+ assertEquals("Check d 0", d[0], 1);
+ assertEquals("Check d 1", d[1], 2);
+ assertEquals("Check d 2", d[2], 3);
+ assertEquals("Check f 0", f[0], 1);
+ assertEquals("Check f 1", f[1], 2);
+ assertEquals("Check f 2", f[2], 3);
+ assertEquals("Check c 0", c[0], 'a');
+ assertEquals("Check c 1", c[1], 'b');
+ assertEquals("Check c 2", c[2], 'c');
+ assertTrue("Check bool 0", bool[0]);
+ assertTrue("Check bool 1", bool[0]);
+ assertTrue("Check bool 2", bool[0]);
+
+// Integer upb = (Integer) props.get("upbs");
+// Integer ups = (Integer) props.get("upss");
+// Integer upi = (Integer) props.get("upis");
+// Integer upl = (Integer) props.get("upls");
+// Integer upd = (Integer) props.get("upds");
+// Integer upf = (Integer) props.get("upfs");
+// Integer upc = (Integer) props.get("upcs");
+// Integer upbool = (Integer) props.get("upbools");
+//
+// assertEquals("Check upb", upb, new Integer(1));
+// assertEquals("Check ups", ups, new Integer(1));
+// assertEquals("Check upi", upi, new Integer(1));
+// assertEquals("Check upl", upl, new Integer(1));
+// assertEquals("Check upd", upd, new Integer(1));
+// assertEquals("Check upf", upf, new Integer(1));
+// assertEquals("Check upc", upc, new Integer(1));
+// assertEquals("Check upbool", upbool, new Integer(1));
+
+ reconfigureString(instance2);
+
+ ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance2.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ check = (CheckService) context.getService(ref);
+ props = check.getProps();
+
+ b = (byte[]) props.get("bs");
+ s = (short[]) props.get("ss");
+ i = (int[]) props.get("is");
+ l = (long[]) props.get("ls");
+ d = (double[]) props.get("ds");
+ f = (float[]) props.get("fs");
+ c = (char[]) props.get("cs");
+ bool = (boolean[]) props.get("bools");
+
+ assertEquals("2) Check b 0", b[0], 3);
+ assertEquals("2) Check b 1", b[1], 2);
+ assertEquals("2) Check b 2", b[2], 1);
+ assertEquals("2) Check s 0", s[0], 3);
+ assertEquals("2) Check s 1", s[1], 2);
+ assertEquals("2) Check s 2", s[2], 1);
+ assertEquals("2) Check i 0", i[0], 3);
+ assertEquals("2) Check i 1", i[1], 2);
+ assertEquals("2) Check i 2", i[2], 1);
+ assertEquals("2) Check l 0", l[0], 3);
+ assertEquals("2) Check l 1", l[1], 2);
+ assertEquals("2) Check l 2", l[2], 1);
+ assertEquals("2) Check d 0", d[0], 3);
+ assertEquals("2) Check d 1", d[1], 2);
+ assertEquals("2) Check d 2", d[2], 1);
+ assertEquals("2) Check f 0", f[0], 3);
+ assertEquals("2) Check f 1", f[1], 2);
+ assertEquals("2) Check f 2", f[2], 1);
+ assertEquals("2) Check c 0", c[0], 'c');
+ assertEquals("2) Check c 1", c[1], 'b');
+ assertEquals("2) Check c 2", c[2], 'a');
+ assertFalse("2) Check bool 0", bool[0]);
+ assertFalse("2) Check bool 1", bool[0]);
+ assertFalse("2) Check bool 2", bool[0]);
+
+// upb = (Integer) props.get("upbs");
+// ups = (Integer) props.get("upss");
+// upi = (Integer) props.get("upis");
+// upl = (Integer) props.get("upls");
+// upd = (Integer) props.get("upds");
+// upf = (Integer) props.get("upfs");
+// upc = (Integer) props.get("upcs");
+// upbool = (Integer) props.get("upbools");
+//
+// assertEquals("2) Check upb", upb, new Integer(2));
+// assertEquals("2) Check ups", ups, new Integer(2));
+// assertEquals("2) Check upi", upi, new Integer(2));
+// assertEquals("2) Check upl", upl, new Integer(2));
+// assertEquals("2) Check upd", upd, new Integer(2));
+// assertEquals("2) Check upf", upf, new Integer(2));
+// assertEquals("2) Check upc", upc, new Integer(2));
+// assertEquals("2) Check upbool", upbool, new Integer(2));
+
+ }
+
+ public void testConfigurationObj2() {
+ ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance2.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ CheckService check = (CheckService) context.getService(ref);
+ Properties props = check.getProps();
+
+ String s = (String) props.get("string");
+ String[] ss = (String[]) props.get("strings");
+
+ assertEquals("Check string", s, "foo");
+ assertEquals("Check strings 0", ss[0], "foo");
+ assertEquals("Check strings 1", ss[1], "bar");
+ assertEquals("Check strings 2", ss[2], "baz");
+
+// Integer upString = (Integer) props.get("upstring");
+// Integer upStrings = (Integer) props.get("upstrings");
+//
+// assertEquals("Check upString", upString, new Integer(1));
+// assertEquals("Check upStrings", upStrings, new Integer(1));
+
+ reconfigure(instance2);
+
+ ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance2.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ check = (CheckService) context.getService(ref);
+ props = check.getProps();
+
+ s = (String) props.get("string");
+ ss = (String[]) props.get("strings");
+
+ assertEquals("2) Check string", s, "bar");
+ assertEquals("2) Check strings 0", ss[0], "baz");
+ assertEquals("2) Check strings 1", ss[1], "bar");
+ assertEquals("2) Check strings 2", ss[2], "foo");
+
+// upString = (Integer) props.get("upstring");
+// upStrings = (Integer) props.get("upstrings");
+//
+// assertEquals("2) Check upString", upString, new Integer(2));
+// assertEquals("2) Check upStrings", upStrings, new Integer(2));
+ }
+
+ public void testConfigurationObj2String() {
+ ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance2.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ CheckService check = (CheckService) context.getService(ref);
+ Properties props = check.getProps();
+
+ String s = (String) props.get("string");
+ String[] ss = (String[]) props.get("strings");
+
+ assertEquals("Check string", s, "foo");
+ assertEquals("Check strings 0", ss[0], "foo");
+ assertEquals("Check strings 1", ss[1], "bar");
+ assertEquals("Check strings 2", ss[2], "baz");
+
+// Integer upString = (Integer) props.get("upstring");
+// Integer upStrings = (Integer) props.get("upstrings");
+//
+// assertEquals("Check upString", upString, new Integer(1));
+// assertEquals("Check upStrings", upStrings, new Integer(1));
+
+ reconfigureString(instance2);
+
+ ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance2.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ check = (CheckService) context.getService(ref);
+ props = check.getProps();
+
+ s = (String) props.get("string");
+ ss = (String[]) props.get("strings");
+
+ assertEquals("2) Check string", s, "bar");
+ assertEquals("2) Check strings 0", ss[0], "baz");
+ assertEquals("2) Check strings 1", ss[1], "bar");
+ assertEquals("2) Check strings 2", ss[2], "foo");
+
+// upString = (Integer) props.get("upstring");
+// upStrings = (Integer) props.get("upstrings");
+//
+// assertEquals("2) Check upString", upString, new Integer(2));
+// assertEquals("2) Check upStrings", upStrings, new Integer(2));
+ }
+
+ private void reconfigure(ComponentInstance ci) {
+ Properties props2 = new Properties();
+ props2.put("name", "under-test");
+ props2.put("b", new Byte("2"));
+ props2.put("s", new Short("2"));
+ props2.put("i", new Integer("2"));
+ props2.put("l", new Long("2"));
+ props2.put("d", new Double("2"));
+ props2.put("f", new Float("2"));
+ props2.put("c", new Character('b'));
+ props2.put("bool", new Boolean(false));
+ props2.put("bs", new byte[]{(byte)3,(byte)2,(byte)1});
+ props2.put("ss", new short[]{(short)3,(short)2,(short)1});
+ props2.put("is", new int[]{3,2,1});
+ props2.put("ls", new long[]{3,2,1});
+ props2.put("ds", new double[]{3,2,1});
+ props2.put("fs", new float[]{3,2,1});
+ props2.put("cs", new char[]{'c','b','a'});
+ props2.put("bools", new boolean[]{false,false,false});
+ props2.put("string", "bar");
+ props2.put("strings", new String[]{"baz", "bar", "foo"});
+
+ ci.reconfigure(props2);
+ }
+
+ private void reconfigureString(ComponentInstance ci) {
+ Properties props2 = new Properties();
+ props2.put("name", "under-test");
+ props2.put("b", "2");
+ props2.put("s", "2");
+ props2.put("i", "2");
+ props2.put("l", "2");
+ props2.put("d", "2");
+ props2.put("f", "2");
+ props2.put("c", "b");
+ props2.put("bool", "false");
+ props2.put("bs", "{3, 2,1}");
+ props2.put("ss", "{3, 2,1}");
+ props2.put("is", "{3, 2,1}");
+ props2.put("ls", "{3, 2,1}");
+ props2.put("ds", "{3, 2,1}");
+ props2.put("fs", "{3, 2,1}");
+ props2.put("cs", "{c, b , a}");
+ props2.put("bools", "{false,false,false}");
+ props2.put("string", "bar");
+ props2.put("strings", "{baz, bar, foo}");
+
+ ci.reconfigure(props2);
+ }
+
+}
diff --git a/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/TestSuperMethodProperties.java b/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/TestSuperMethodProperties.java
new file mode 100644
index 0000000..99c477a
--- /dev/null
+++ b/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/TestSuperMethodProperties.java
@@ -0,0 +1,617 @@
+/*
+ * 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.configuration;
+
+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.configuration.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.ServiceReference;
+
+public class TestSuperMethodProperties extends OSGiTestCase {
+
+ ComponentInstance instance;
+
+ public void setUp() {
+ Factory fact = Utils.getFactoryByName(context, "CONFIG-ParentMethodConfigurableCheckService");
+ Properties props = new Properties();
+ props.put("name", "under-test");
+ props.put("b", "1");
+ props.put("s", "1");
+ props.put("i", "1");
+ props.put("l", "1");
+ props.put("d", "1");
+ props.put("f", "1");
+ props.put("c", "a");
+ props.put("bool", "true");
+ props.put("bs", "{1,2,3}");
+ props.put("ss", "{1,2,3}");
+ props.put("is", "{1,2,3}");
+ props.put("ls", "{1,2,3}");
+ props.put("ds", "{1,2,3}");
+ props.put("fs", "{1,2,3}");
+ props.put("cs", "{a,b,c}");
+ props.put("bools", "{true,true,true}");
+ props.put("string", "foo");
+ props.put("strings", "{foo, bar, baz}");
+
+ try {
+ instance = fact.createComponentInstance(props);
+ } catch (Exception e) {
+ fail("Cannot create the under-test instance : " + e.getMessage());
+ }
+
+
+ }
+
+ public void tearDown() {
+ instance.dispose();
+ instance = null;
+ }
+
+ public void testConfigurationPrimitive() {
+ ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ CheckService check = (CheckService) context.getService(ref);
+ Properties props = check.getProps();
+
+ Byte b = (Byte) props.get("b");
+ Short s = (Short) props.get("s");
+ Integer i = (Integer) props.get("i");
+ Long l = (Long) props.get("l");
+ Double d = (Double) props.get("d");
+ Float f = (Float) props.get("f");
+ Character c = (Character) props.get("c");
+ Boolean bool = (Boolean) props.get("bool");
+
+ assertEquals("Check b", b, new Byte("1"));
+ assertEquals("Check s", s, new Short("1"));
+ assertEquals("Check i", i, new Integer("1"));
+ assertEquals("Check l", l, new Long("1"));
+ assertEquals("Check d", d, new Double("1"));
+ assertEquals("Check f", f, new Float("1"));
+ assertEquals("Check c", c, new Character('a'));
+ assertEquals("Check bool", bool, new Boolean("true"));
+
+// Integer upb = (Integer) props.get("upb");
+// Integer ups = (Integer) props.get("ups");
+// Integer upi = (Integer) props.get("upi");
+// Integer upl = (Integer) props.get("upl");
+// Integer upd = (Integer) props.get("upd");
+// Integer upf = (Integer) props.get("upf");
+// Integer upc = (Integer) props.get("upc");
+// Integer upbool = (Integer) props.get("upbool");
+//
+// assertEquals("Check upb", upb, new Integer(1));
+// assertEquals("Check ups", ups, new Integer(1));
+// assertEquals("Check upi", upi, new Integer(1));
+// assertEquals("Check upl", upl, new Integer(1));
+// assertEquals("Check upd", upd, new Integer(1));
+// assertEquals("Check upf", upf, new Integer(1));
+// assertEquals("Check upc", upc, new Integer(1));
+// assertEquals("Check upbool", upbool, new Integer(1));
+
+ reconfigure();
+
+ ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ check = (CheckService) context.getService(ref);
+ props = check.getProps();
+
+ b = (Byte) props.get("b");
+ s = (Short) props.get("s");
+ i = (Integer) props.get("i");
+ l = (Long) props.get("l");
+ d = (Double) props.get("d");
+ f = (Float) props.get("f");
+ c = (Character) props.get("c");
+ bool = (Boolean) props.get("bool");
+
+ assertEquals("2) Check b ("+b+")", b, new Byte("2"));
+ assertEquals("2) Check s", s, new Short("2"));
+ assertEquals("2) Check i", i, new Integer("2"));
+ assertEquals("2) Check l", l, new Long("2"));
+ assertEquals("2) Check d", d, new Double("2"));
+ assertEquals("2) Check f", f, new Float("2"));
+ assertEquals("2) Check c", c, new Character('b'));
+ assertEquals("2) Check bool", bool, new Boolean("false"));
+
+// upb = (Integer) props.get("upb");
+// ups = (Integer) props.get("ups");
+// upi = (Integer) props.get("upi");
+// upl = (Integer) props.get("upl");
+// upd = (Integer) props.get("upd");
+// upf = (Integer) props.get("upf");
+// upc = (Integer) props.get("upc");
+// upbool = (Integer) props.get("upbool");
+//
+// assertEquals("2) Check upb", upb, new Integer(2));
+// assertEquals("2) Check ups", ups, new Integer(2));
+// assertEquals("2) Check upi", upi, new Integer(2));
+// assertEquals("2) Check upl", upl, new Integer(2));
+// assertEquals("2) Check upd", upd, new Integer(2));
+// assertEquals("2) Check upf", upf, new Integer(2));
+// assertEquals("2) Check upc", upc, new Integer(2));
+// assertEquals("2) Check upbool", upbool, new Integer(2));
+
+ }
+
+ public void testConfigurationPrimitiveString() {
+ ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ CheckService check = (CheckService) context.getService(ref);
+ Properties props = check.getProps();
+
+ Byte b = (Byte) props.get("b");
+ Short s = (Short) props.get("s");
+ Integer i = (Integer) props.get("i");
+ Long l = (Long) props.get("l");
+ Double d = (Double) props.get("d");
+ Float f = (Float) props.get("f");
+ Character c = (Character) props.get("c");
+ Boolean bool = (Boolean) props.get("bool");
+
+ assertEquals("Check b", b, new Byte("1"));
+ assertEquals("Check s", s, new Short("1"));
+ assertEquals("Check i", i, new Integer("1"));
+ assertEquals("Check l", l, new Long("1"));
+ assertEquals("Check d", d, new Double("1"));
+ assertEquals("Check f", f, new Float("1"));
+ assertEquals("Check c", c, new Character('a'));
+ assertEquals("Check bool", bool, new Boolean("true"));
+
+// Integer upb = (Integer) props.get("upb");
+// Integer ups = (Integer) props.get("ups");
+// Integer upi = (Integer) props.get("upi");
+// Integer upl = (Integer) props.get("upl");
+// Integer upd = (Integer) props.get("upd");
+// Integer upf = (Integer) props.get("upf");
+// Integer upc = (Integer) props.get("upc");
+// Integer upbool = (Integer) props.get("upbool");
+//
+// assertEquals("Check upb", upb, new Integer(1));
+// assertEquals("Check ups", ups, new Integer(1));
+// assertEquals("Check upi", upi, new Integer(1));
+// assertEquals("Check upl", upl, new Integer(1));
+// assertEquals("Check upd", upd, new Integer(1));
+// assertEquals("Check upf", upf, new Integer(1));
+// assertEquals("Check upc", upc, new Integer(1));
+// assertEquals("Check upbool", upbool, new Integer(1));
+
+ reconfigureString();
+
+ ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ check = (CheckService) context.getService(ref);
+ props = check.getProps();
+
+ b = (Byte) props.get("b");
+ s = (Short) props.get("s");
+ i = (Integer) props.get("i");
+ l = (Long) props.get("l");
+ d = (Double) props.get("d");
+ f = (Float) props.get("f");
+ c = (Character) props.get("c");
+ bool = (Boolean) props.get("bool");
+
+ assertEquals("2) Check b ("+b+")", b, new Byte("2"));
+ assertEquals("2) Check s", s, new Short("2"));
+ assertEquals("2) Check i", i, new Integer("2"));
+ assertEquals("2) Check l", l, new Long("2"));
+ assertEquals("2) Check d", d, new Double("2"));
+ assertEquals("2) Check f", f, new Float("2"));
+ assertEquals("2) Check c", c, new Character('b'));
+ assertEquals("2) Check bool", bool, new Boolean("false"));
+
+// upb = (Integer) props.get("upb");
+// ups = (Integer) props.get("ups");
+// upi = (Integer) props.get("upi");
+// upl = (Integer) props.get("upl");
+// upd = (Integer) props.get("upd");
+// upf = (Integer) props.get("upf");
+// upc = (Integer) props.get("upc");
+// upbool = (Integer) props.get("upbool");
+//
+// assertEquals("2) Check upb", upb, new Integer(2));
+// assertEquals("2) Check ups", ups, new Integer(2));
+// assertEquals("2) Check upi", upi, new Integer(2));
+// assertEquals("2) Check upl", upl, new Integer(2));
+// assertEquals("2) Check upd", upd, new Integer(2));
+// assertEquals("2) Check upf", upf, new Integer(2));
+// assertEquals("2) Check upc", upc, new Integer(2));
+// assertEquals("2) Check upbool", upbool, new Integer(2));
+
+ }
+
+ public void testConfigurationPrimitiveArrays() {
+ ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ CheckService check = (CheckService) context.getService(ref);
+ Properties props = check.getProps();
+
+ byte[] b = (byte[]) props.get("bs");
+ short[] s = (short[]) props.get("ss");
+ int[] i = (int[]) props.get("is");
+ long[] l = (long[]) props.get("ls");
+ double[] d = (double[]) props.get("ds");
+ float[] f = (float[]) props.get("fs");
+ char[] c = (char[]) props.get("cs");
+ boolean[] bool = (boolean[]) props.get("bools");
+
+ assertEquals("Check b 0", b[0], 1);
+ assertEquals("Check b 1", b[1], 2);
+ assertEquals("Check b 2", b[2], 3);
+ assertEquals("Check s 0", s[0], 1);
+ assertEquals("Check s 1", s[1], 2);
+ assertEquals("Check s 2", s[2], 3);
+ assertEquals("Check i 0", i[0], 1);
+ assertEquals("Check i 1", i[1], 2);
+ assertEquals("Check i 2", i[2], 3);
+ assertEquals("Check l 0", l[0], 1);
+ assertEquals("Check l 1", l[1], 2);
+ assertEquals("Check l 2", l[2], 3);
+ assertEquals("Check d 0", d[0], 1);
+ assertEquals("Check d 1", d[1], 2);
+ assertEquals("Check d 2", d[2], 3);
+ assertEquals("Check f 0", f[0], 1);
+ assertEquals("Check f 1", f[1], 2);
+ assertEquals("Check f 2", f[2], 3);
+ assertEquals("Check c 0", c[0], 'a');
+ assertEquals("Check c 1", c[1], 'b');
+ assertEquals("Check c 2", c[2], 'c');
+ assertTrue("Check bool 0", bool[0]);
+ assertTrue("Check bool 1", bool[0]);
+ assertTrue("Check bool 2", bool[0]);
+
+// Integer upb = (Integer) props.get("upbs");
+// Integer ups = (Integer) props.get("upss");
+// Integer upi = (Integer) props.get("upis");
+// Integer upl = (Integer) props.get("upls");
+// Integer upd = (Integer) props.get("upds");
+// Integer upf = (Integer) props.get("upfs");
+// Integer upc = (Integer) props.get("upcs");
+// Integer upbool = (Integer) props.get("upbools");
+//
+// assertEquals("Check upb", upb, new Integer(1));
+// assertEquals("Check ups", ups, new Integer(1));
+// assertEquals("Check upi", upi, new Integer(1));
+// assertEquals("Check upl", upl, new Integer(1));
+// assertEquals("Check upd", upd, new Integer(1));
+// assertEquals("Check upf", upf, new Integer(1));
+// assertEquals("Check upc", upc, new Integer(1));
+// assertEquals("Check upbool", upbool, new Integer(1));
+
+ reconfigure();
+
+ ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ check = (CheckService) context.getService(ref);
+ props = check.getProps();
+
+ b = (byte[]) props.get("bs");
+ s = (short[]) props.get("ss");
+ i = (int[]) props.get("is");
+ l = (long[]) props.get("ls");
+ d = (double[]) props.get("ds");
+ f = (float[]) props.get("fs");
+ c = (char[]) props.get("cs");
+ bool = (boolean[]) props.get("bools");
+
+ assertEquals("2) Check b 0", b[0], 3);
+ assertEquals("2) Check b 1", b[1], 2);
+ assertEquals("2) Check b 2", b[2], 1);
+ assertEquals("2) Check s 0", s[0], 3);
+ assertEquals("2) Check s 1", s[1], 2);
+ assertEquals("2) Check s 2", s[2], 1);
+ assertEquals("2) Check i 0", i[0], 3);
+ assertEquals("2) Check i 1", i[1], 2);
+ assertEquals("2) Check i 2", i[2], 1);
+ assertEquals("2) Check l 0", l[0], 3);
+ assertEquals("2) Check l 1", l[1], 2);
+ assertEquals("2) Check l 2", l[2], 1);
+ assertEquals("2) Check d 0", d[0], 3);
+ assertEquals("2) Check d 1", d[1], 2);
+ assertEquals("2) Check d 2", d[2], 1);
+ assertEquals("2) Check f 0", f[0], 3);
+ assertEquals("2) Check f 1", f[1], 2);
+ assertEquals("2) Check f 2", f[2], 1);
+ assertEquals("2) Check c 0", c[0], 'c');
+ assertEquals("2) Check c 1", c[1], 'b');
+ assertEquals("2) Check c 2", c[2], 'a');
+ assertFalse("2) Check bool 0", bool[0]);
+ assertFalse("2) Check bool 1", bool[0]);
+ assertFalse("2) Check bool 2", bool[0]);
+
+// upb = (Integer) props.get("upbs");
+// ups = (Integer) props.get("upss");
+// upi = (Integer) props.get("upis");
+// upl = (Integer) props.get("upls");
+// upd = (Integer) props.get("upds");
+// upf = (Integer) props.get("upfs");
+// upc = (Integer) props.get("upcs");
+// upbool = (Integer) props.get("upbools");
+//
+// assertEquals("2) Check upb", upb, new Integer(2));
+// assertEquals("2) Check ups", ups, new Integer(2));
+// assertEquals("2) Check upi", upi, new Integer(2));
+// assertEquals("2) Check upl", upl, new Integer(2));
+// assertEquals("2) Check upd", upd, new Integer(2));
+// assertEquals("2) Check upf", upf, new Integer(2));
+// assertEquals("2) Check upc", upc, new Integer(2));
+// assertEquals("2) Check upbool", upbool, new Integer(2));
+
+ }
+
+ public void testConfigurationPrimitiveArraysString() {
+ ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ CheckService check = (CheckService) context.getService(ref);
+ Properties props = check.getProps();
+
+ byte[] b = (byte[]) props.get("bs");
+ short[] s = (short[]) props.get("ss");
+ int[] i = (int[]) props.get("is");
+ long[] l = (long[]) props.get("ls");
+ double[] d = (double[]) props.get("ds");
+ float[] f = (float[]) props.get("fs");
+ char[] c = (char[]) props.get("cs");
+ boolean[] bool = (boolean[]) props.get("bools");
+
+ assertEquals("Check b 0", b[0], 1);
+ assertEquals("Check b 1", b[1], 2);
+ assertEquals("Check b 2", b[2], 3);
+ assertEquals("Check s 0", s[0], 1);
+ assertEquals("Check s 1", s[1], 2);
+ assertEquals("Check s 2", s[2], 3);
+ assertEquals("Check i 0", i[0], 1);
+ assertEquals("Check i 1", i[1], 2);
+ assertEquals("Check i 2", i[2], 3);
+ assertEquals("Check l 0", l[0], 1);
+ assertEquals("Check l 1", l[1], 2);
+ assertEquals("Check l 2", l[2], 3);
+ assertEquals("Check d 0", d[0], 1);
+ assertEquals("Check d 1", d[1], 2);
+ assertEquals("Check d 2", d[2], 3);
+ assertEquals("Check f 0", f[0], 1);
+ assertEquals("Check f 1", f[1], 2);
+ assertEquals("Check f 2", f[2], 3);
+ assertEquals("Check c 0", c[0], 'a');
+ assertEquals("Check c 1", c[1], 'b');
+ assertEquals("Check c 2", c[2], 'c');
+ assertTrue("Check bool 0", bool[0]);
+ assertTrue("Check bool 1", bool[0]);
+ assertTrue("Check bool 2", bool[0]);
+
+// Integer upb = (Integer) props.get("upbs");
+// Integer ups = (Integer) props.get("upss");
+// Integer upi = (Integer) props.get("upis");
+// Integer upl = (Integer) props.get("upls");
+// Integer upd = (Integer) props.get("upds");
+// Integer upf = (Integer) props.get("upfs");
+// Integer upc = (Integer) props.get("upcs");
+// Integer upbool = (Integer) props.get("upbools");
+//
+// assertEquals("Check upb", upb, new Integer(1));
+// assertEquals("Check ups", ups, new Integer(1));
+// assertEquals("Check upi", upi, new Integer(1));
+// assertEquals("Check upl", upl, new Integer(1));
+// assertEquals("Check upd", upd, new Integer(1));
+// assertEquals("Check upf", upf, new Integer(1));
+// assertEquals("Check upc", upc, new Integer(1));
+// assertEquals("Check upbool", upbool, new Integer(1));
+
+ reconfigureString();
+
+ ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ check = (CheckService) context.getService(ref);
+ props = check.getProps();
+
+ b = (byte[]) props.get("bs");
+ s = (short[]) props.get("ss");
+ i = (int[]) props.get("is");
+ l = (long[]) props.get("ls");
+ d = (double[]) props.get("ds");
+ f = (float[]) props.get("fs");
+ c = (char[]) props.get("cs");
+ bool = (boolean[]) props.get("bools");
+
+ assertEquals("2) Check b 0", b[0], 3);
+ assertEquals("2) Check b 1", b[1], 2);
+ assertEquals("2) Check b 2", b[2], 1);
+ assertEquals("2) Check s 0", s[0], 3);
+ assertEquals("2) Check s 1", s[1], 2);
+ assertEquals("2) Check s 2", s[2], 1);
+ assertEquals("2) Check i 0", i[0], 3);
+ assertEquals("2) Check i 1", i[1], 2);
+ assertEquals("2) Check i 2", i[2], 1);
+ assertEquals("2) Check l 0", l[0], 3);
+ assertEquals("2) Check l 1", l[1], 2);
+ assertEquals("2) Check l 2", l[2], 1);
+ assertEquals("2) Check d 0", d[0], 3);
+ assertEquals("2) Check d 1", d[1], 2);
+ assertEquals("2) Check d 2", d[2], 1);
+ assertEquals("2) Check f 0", f[0], 3);
+ assertEquals("2) Check f 1", f[1], 2);
+ assertEquals("2) Check f 2", f[2], 1);
+ assertEquals("2) Check c 0", c[0], 'c');
+ assertEquals("2) Check c 1", c[1], 'b');
+ assertEquals("2) Check c 2", c[2], 'a');
+ assertFalse("2) Check bool 0", bool[0]);
+ assertFalse("2) Check bool 1", bool[0]);
+ assertFalse("2) Check bool 2", bool[0]);
+
+// upb = (Integer) props.get("upbs");
+// ups = (Integer) props.get("upss");
+// upi = (Integer) props.get("upis");
+// upl = (Integer) props.get("upls");
+// upd = (Integer) props.get("upds");
+// upf = (Integer) props.get("upfs");
+// upc = (Integer) props.get("upcs");
+// upbool = (Integer) props.get("upbools");
+//
+// assertEquals("2) Check upb", upb, new Integer(2));
+// assertEquals("2) Check ups", ups, new Integer(2));
+// assertEquals("2) Check upi", upi, new Integer(2));
+// assertEquals("2) Check upl", upl, new Integer(2));
+// assertEquals("2) Check upd", upd, new Integer(2));
+// assertEquals("2) Check upf", upf, new Integer(2));
+// assertEquals("2) Check upc", upc, new Integer(2));
+// assertEquals("2) Check upbool", upbool, new Integer(2));
+
+ }
+
+ public void testConfigurationObj() {
+ ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ CheckService check = (CheckService) context.getService(ref);
+ Properties props = check.getProps();
+
+ String s = (String) props.get("string");
+ String[] ss = (String[]) props.get("strings");
+
+ assertEquals("Check string", s, "foo");
+ assertEquals("Check strings 0", ss[0], "foo");
+ assertEquals("Check strings 1", ss[1], "bar");
+ assertEquals("Check strings 2", ss[2], "baz");
+
+// Integer upString = (Integer) props.get("upstring");
+// Integer upStrings = (Integer) props.get("upstrings");
+//
+// assertEquals("Check upString", upString, new Integer(1));
+// assertEquals("Check upStrings", upStrings, new Integer(1));
+
+ reconfigure();
+
+ ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ check = (CheckService) context.getService(ref);
+ props = check.getProps();
+
+ s = (String) props.get("string");
+ ss = (String[]) props.get("strings");
+
+ assertEquals("2) Check string", s, "bar");
+ assertEquals("2) Check strings 0", ss[0], "baz");
+ assertEquals("2) Check strings 1", ss[1], "bar");
+ assertEquals("2) Check strings 2", ss[2], "foo");
+
+// upString = (Integer) props.get("upstring");
+// upStrings = (Integer) props.get("upstrings");
+//
+// assertEquals("2) Check upString", upString, new Integer(2));
+// assertEquals("2) Check upStrings", upStrings, new Integer(2));
+ }
+
+ public void testConfigurationObjString() {
+ ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ CheckService check = (CheckService) context.getService(ref);
+ Properties props = check.getProps();
+
+ String s = (String) props.get("string");
+ String[] ss = (String[]) props.get("strings");
+
+ assertEquals("Check string", s, "foo");
+ assertEquals("Check strings 0", ss[0], "foo");
+ assertEquals("Check strings 1", ss[1], "bar");
+ assertEquals("Check strings 2", ss[2], "baz");
+
+// Integer upString = (Integer) props.get("upstring");
+// Integer upStrings = (Integer) props.get("upstrings");
+//
+// assertEquals("Check upString", upString, new Integer(1));
+// assertEquals("Check upStrings", upStrings, new Integer(1));
+
+ reconfigureString();
+
+ ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Test check service availability", ref);
+ check = (CheckService) context.getService(ref);
+ props = check.getProps();
+
+ s = (String) props.get("string");
+ ss = (String[]) props.get("strings");
+
+ assertEquals("2) Check string", s, "bar");
+ assertEquals("2) Check strings 0", ss[0], "baz");
+ assertEquals("2) Check strings 1", ss[1], "bar");
+ assertEquals("2) Check strings 2", ss[2], "foo");
+
+// upString = (Integer) props.get("upstring");
+// upStrings = (Integer) props.get("upstrings");
+//
+// assertEquals("2) Check upString", upString, new Integer(2));
+// assertEquals("2) Check upStrings", upStrings, new Integer(2));
+ }
+
+ private void reconfigure() {
+ Properties props2 = new Properties();
+ props2.put("name", "under-test");
+ props2.put("b", new Byte("2"));
+ props2.put("s", new Short("2"));
+ props2.put("i", new Integer("2"));
+ props2.put("l", new Long("2"));
+ props2.put("d", new Double("2"));
+ props2.put("f", new Float("2"));
+ props2.put("c", new Character('b'));
+ props2.put("bool", new Boolean(false));
+ props2.put("bs", new byte[]{(byte)3,(byte)2,(byte)1});
+ props2.put("ss", new short[]{(short)3,(short)2,(short)1});
+ props2.put("is", new int[]{3,2,1});
+ props2.put("ls", new long[]{3,2,1});
+ props2.put("ds", new double[]{3,2,1});
+ props2.put("fs", new float[]{3,2,1});
+ props2.put("cs", new char[]{'c','b','a'});
+ props2.put("bools", new boolean[]{false,false,false});
+ props2.put("string", "bar");
+ props2.put("strings", new String[]{"baz", "bar", "foo"});
+
+ instance.reconfigure(props2);
+ }
+
+ private void reconfigureString() {
+ Properties props2 = new Properties();
+ props2.put("name", "under-test");
+ props2.put("b", "2");
+ props2.put("s", "2");
+ props2.put("i", "2");
+ props2.put("l", "2");
+ props2.put("d", "2");
+ props2.put("f", "2");
+ props2.put("c", "b");
+ props2.put("bool", "false");
+ props2.put("bs", "{3, 2,1}");
+ props2.put("ss", "{3, 2,1}");
+ props2.put("is", "{3, 2,1}");
+ props2.put("ls", "{3, 2,1}");
+ props2.put("ds", "{3, 2,1}");
+ props2.put("fs", "{3, 2,1}");
+ props2.put("cs", "{c, b , a}");
+ props2.put("bools", "{false,false,false}");
+ props2.put("string", "bar");
+ props2.put("strings", "{baz, bar, foo}");
+
+ instance.reconfigure(props2);
+ }
+
+}
diff --git a/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/service/CheckService.java b/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/service/CheckService.java
new file mode 100644
index 0000000..e8f89b9
--- /dev/null
+++ b/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/service/CheckService.java
@@ -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.configuration.service;
+
+import java.util.Properties;
+
+public interface CheckService {
+
+ public static final String foo = "foo";
+
+ public boolean check();
+
+ public Properties getProps();
+
+}
diff --git a/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/service/FooService.java b/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/service/FooService.java
new file mode 100644
index 0000000..7f6a005
--- /dev/null
+++ b/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/service/FooService.java
@@ -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.configuration.service;
+
+import java.util.Properties;
+
+public interface FooService {
+
+ boolean foo();
+
+ Properties fooProps();
+
+ Boolean getObject();
+
+ boolean getBoolean();
+
+ int getInt();
+
+ long getLong();
+
+ double getDouble();
+
+}
diff --git a/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java b/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
new file mode 100644
index 0000000..cb87c86
--- /dev/null
+++ b/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
@@ -0,0 +1,326 @@
+/*
+ * 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.apache.felix.ipojo.composite.CompositeManager;
+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;
+ }
+
+}
diff --git a/ipojo/tests/tests.core.configuration/src/main/resources/metadata.xml b/ipojo/tests/tests.core.configuration/src/main/resources/metadata.xml
new file mode 100644
index 0000000..b389cd5
--- /dev/null
+++ b/ipojo/tests/tests.core.configuration/src/main/resources/metadata.xml
@@ -0,0 +1,148 @@
+<ipojo>
+ <component
+ className="org.apache.felix.ipojo.test.scenarios.component.FooProviderTypeDyn"
+ factory="CONFIG-FooProviderType-Conf" architecture="true">
+ <provides />
+ <properties propagation="false">
+ <property name="int" field="intProp" value="2" />
+ <property name="boolean" field="boolProp" value="false" />
+ <property name="string" field="strProp" value="foo" />
+ <property name="strAProp" field="strAProp"
+ value="{foo, bar}" />
+ <property name="intAProp" field="intAProp" value="{1,2, 3}" />
+ </properties>
+ </component>
+ <component
+ className="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"
+ factory="CONFIG-FooProviderType-3" architecture="true">
+ <provides>
+ <property name="foo" field="m_foo" />
+ <property name="bar" field="m_bar" />
+ <property name="baz" type="java.lang.String" />
+ </provides>
+ <properties propagation="true">
+ <property name="foo" field="m_foo" />
+ <property name="bar" field="m_bar" />
+ </properties>
+ </component>
+ <!-- Configuration Management Test -->
+ <component factory="CONFIG-FieldConfigurableCheckService"
+ className="org.apache.felix.ipojo.test.scenarios.component.ConfigurableCheckServiceProvider"
+ architecture="true">
+ <provides />
+ <properties propagation="true">
+ <property field="b" />
+ <property field="s" />
+ <property field="i" />
+ <property field="l" />
+ <property field="d" />
+ <property field="f" />
+ <property field="c" />
+ <property field="bool" />
+ <property field="bs" />
+ <property field="ss" />
+ <property field="is" />
+ <property field="ls" />
+ <property field="ds" />
+ <property field="fs" />
+ <property field="cs" />
+ <property field="bools" />
+ <property field="string" />
+ <property field="strings" />
+ </properties>
+ </component>
+
+ <component factory="CONFIG-BothConfigurableCheckService"
+ className="org.apache.felix.ipojo.test.scenarios.component.ConfigurableCheckServiceProvider"
+ architecture="true">
+ <provides />
+ <properties propagation="true">
+ <property field="b" method="updateB" />
+ <property field="s" method="updateS" />
+ <property field="i" method="updateI" />
+ <property field="l" method="updateL" />
+ <property field="d" method="updateD" />
+ <property field="f" method="updateF" />
+ <property field="c" method="updateC" />
+ <property field="bool" method="updateBool" />
+ <property field="bs" method="updateBs" />
+ <property field="ss" method="updateSs" />
+ <property field="is" method="updateIs" />
+ <property field="ls" method="updateLs" />
+ <property field="ds" method="updateDs" />
+ <property field="fs" method="updateFs" />
+ <property field="cs" method="updateCs" />
+ <property field="bools" method="updateBools" />
+ <property field="string" method="updateString" />
+ <property field="strings" method="updateStrings" />
+ </properties>
+ </component>
+
+ <component factory="CONFIG-MethodConfigurableCheckService"
+ className="org.apache.felix.ipojo.test.scenarios.component.ConfigurableCheckServiceProvider"
+ architecture="true">
+ <provides />
+ <properties propagation="true">
+ <property method="updateB" name="b" />
+ <property method="updateS" name="s" />
+ <property method="updateI" name="i" />
+ <property method="updateL" name="l" />
+ <property method="updateD" name="d" />
+ <property method="updateF" name="f" />
+ <property method="updateC" name="c" />
+ <property method="updateBool" name="bool" />
+ <property method="updateBs" name="bs" />
+ <property method="updateSs" name="ss" />
+ <property method="updateIs" name="is" />
+ <property method="updateLs" name="ls" />
+ <property method="updateDs" name="ds" />
+ <property method="updateFs" name="fs" />
+ <property method="updateCs" name="cs" />
+ <property method="updateBools" name="bools" />
+ <property method="updateString" name="string" />
+ <property method="updateStrings" name="strings" />
+ </properties>
+ </component>
+
+ <component factory="CONFIG-ParentMethodConfigurableCheckService"
+ className="org.apache.felix.ipojo.test.scenarios.component.ParentConfigurableCheckServiceProvider"
+ architecture="true">
+ <provides />
+ <properties propagation="true">
+ <property method="updateB" name="b" />
+ <property method="updateS" name="s" />
+ <property method="updateI" name="i" />
+ <property method="updateL" name="l" />
+ <property method="updateD" name="d" />
+ <property method="updateF" name="f" />
+ <property method="updateC" name="c" />
+ <property method="updateBool" name="bool" />
+ <property method="updateBs" name="bs" />
+ <property method="updateSs" name="ss" />
+ <property method="updateIs" name="is" />
+ <property method="updateLs" name="ls" />
+ <property method="updateDs" name="ds" />
+ <property method="updateFs" name="fs" />
+ <property method="updateCs" name="cs" />
+ <property method="updateBools" name="bools" />
+ <property method="updateString" name="string" type="string" />
+ <property method="updateStrings" name="strings"
+ type="java.lang.String[]" />
+ </properties>
+ </component>
+
+ <component
+ className="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"
+ factory="CONFIG-FooProviderType-4" architecture="true">
+ <provides>
+ <property name="foo" field="m_foo" />
+ <property name="bar" field="m_bar" />
+ <property name="baz" type="java.lang.String" />
+ </provides>
+ <properties propagation="true" pid="FooProvider-3">
+ <property name="foo" field="m_foo" />
+ <property name="bar" field="m_bar" />
+ </properties>
+ </component>
+
+</ipojo>