You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cl...@apache.org on 2008/01/28 00:21:37 UTC
svn commit: r615675 [19/21] - in /felix/sandbox/clement/ipojo: ./
annotations/ ant/ arch/ core/
core/src/main/java/org/apache/felix/ipojo/handlers/configuration/
core/src/main/java/org/apache/felix/ipojo/handlers/dependency/
core/src/main/java/org/apac...
Added: felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/ImmediateCallbackTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/ImmediateCallbackTest.java?rev=615675&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/ImmediateCallbackTest.java (added)
+++ felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/ImmediateCallbackTest.java Sun Jan 27 15:21:24 2008
@@ -0,0 +1,96 @@
+package org.apache.felix.ipojo.test.scenarios.lifecycle;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.architecture.Architecture;
+import org.apache.felix.ipojo.architecture.InstanceDescription;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.ServiceReference;
+
+public class ImmediateCallbackTest extends OSGiTestCase {
+
+ ComponentInstance instance; // Instance under test
+ ComponentInstance fooProvider;
+
+ public void setUp() {
+ Properties p2 = new Properties();
+ p2.put("name", "fooProvider");
+ fooProvider = Utils.getComponentInstance(context, "FooProviderType-1", p2);
+ fooProvider.stop();
+
+ Properties p1 = new Properties();
+ p1.put("name", "callback");
+ instance = Utils.getComponentInstance(context, "ImmediateCallbackCheckService", p1);
+
+ }
+
+ public void tearDown() {
+ instance.dispose();
+ fooProvider.dispose();
+ instance= null;
+ fooProvider = null;
+ }
+
+ public void testCallback() {
+ // Check instance is invalid
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ref);
+ InstanceDescription id_dep = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 1", id_dep.getState() == ComponentInstance.INVALID);
+ assertEquals("Check pojo count - 1", id_dep.getCreatedObjects().length, 0);
+
+ // Start fooprovider
+ fooProvider.start();
+
+ // Check instance validity
+ id_dep = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 1", id_dep.getState() == ComponentInstance.VALID);
+
+ // Check service providing
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Check CheckService availability", cs_ref);
+ CheckService cs = (CheckService) context.getService(cs_ref);
+ assertTrue("check CheckService invocation", cs.check());
+
+ assertEquals("Check pojo count - 2", id_dep.getCreatedObjects().length, 1);
+ // Check int property
+ Integer index = (Integer) (cs.getProps().get("int"));
+ assertEquals("Check int property - 1 (" + index.intValue() +")", index.intValue(), 1);
+
+ fooProvider.stop();
+
+ id_dep = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.INVALID);
+
+ assertEquals("Check pojo count - 3", id_dep.getCreatedObjects().length, 1);
+
+ fooProvider.start();
+
+ // Check instance validity
+ id_dep = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 2", id_dep.getState() == ComponentInstance.VALID);
+
+ // Check service providing
+ cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Check CheckService availability", cs_ref);
+ cs = (CheckService) context.getService(cs_ref);
+ assertTrue("check CheckService invocation", cs.check());
+
+ // Check int property
+ index = (Integer) (cs.getProps().get("int"));
+ assertEquals("Check int property - 2 ("+index.intValue()+")", index.intValue(), 3);
+
+ assertEquals("Check pojo count - 4 ", id_dep.getCreatedObjects().length, 1);
+
+ // Clean up
+ context.ungetService(arch_ref);
+ context.ungetService(cs_ref);
+ cs = null;
+ id_dep = null;
+ }
+
+
+}
Added: felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/LifeCycleCallbackTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/LifeCycleCallbackTest.java?rev=615675&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/LifeCycleCallbackTest.java (added)
+++ felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/LifeCycleCallbackTest.java Sun Jan 27 15:21:24 2008
@@ -0,0 +1,20 @@
+package org.apache.felix.ipojo.test.scenarios.lifecycle;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
+import org.osgi.framework.BundleContext;
+
+public class LifeCycleCallbackTest extends TestSuite {
+
+
+ public static Test suite(BundleContext bc) {
+ OSGiTestSuite ots = new OSGiTestSuite("Lifecycle callbacks Test Suite", bc);
+ ots.addTestSuite(CallbackTestCase.class);
+ ots.addTestSuite(ParentCallbackTestCase.class);
+ ots.addTestSuite(ImmediateCallbackTest.class);
+ return ots;
+ }
+
+}
Added: felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/ParentCallbackTestCase.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/ParentCallbackTestCase.java?rev=615675&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/ParentCallbackTestCase.java (added)
+++ felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/lifecycle/ParentCallbackTestCase.java Sun Jan 27 15:21:24 2008
@@ -0,0 +1,84 @@
+package org.apache.felix.ipojo.test.scenarios.lifecycle;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.architecture.Architecture;
+import org.apache.felix.ipojo.architecture.InstanceDescription;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.ServiceReference;
+
+public class ParentCallbackTestCase extends OSGiTestCase {
+
+ ComponentInstance instance; // Instance under test
+ ComponentInstance fooProvider;
+
+ public void setUp() {
+ Properties p2 = new Properties();
+ p2.put("name", "fooProvider");
+ fooProvider = Utils.getComponentInstance(context, "FooProviderType-1", p2);
+ fooProvider.stop();
+
+ Properties p1 = new Properties();
+ p1.put("name", "callback");
+ instance = Utils.getComponentInstance(context, "ParentCallbackCheckService", p1);
+
+ }
+
+ public void tearDown() {
+ instance.dispose();
+ fooProvider.dispose();
+ instance= null;
+ fooProvider = null;
+ }
+
+ public void testCallback() {
+ // Check instance is invalid
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ref);
+ InstanceDescription id_dep = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 1", id_dep.getState() == ComponentInstance.INVALID);
+
+ // Start fooprovider
+ fooProvider.start();
+
+ // Check instance validity
+ id_dep = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 1", id_dep.getState() == ComponentInstance.VALID);
+
+ // Check service providing
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Check CheckService availability", cs_ref);
+ CheckService cs = (CheckService) context.getService(cs_ref);
+
+ // Check int property
+ assertEquals("Check pojo count - 2", id_dep.getCreatedObjects().length, 1);
+
+ fooProvider.stop();
+
+ id_dep = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.INVALID);
+
+ fooProvider.start();
+
+ // Check instance validity
+ id_dep = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 2", id_dep.getState() == ComponentInstance.VALID);
+
+ // Check service providing
+ cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Check CheckService availability", cs_ref);
+ cs = (CheckService) context.getService(cs_ref);
+ assertTrue("check CheckService invocation", cs.check());
+
+ // Clean up
+ context.ungetService(arch_ref);
+ context.ungetService(cs_ref);
+ cs = null;
+ id_dep = null;
+ }
+
+
+}
Propchange: felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Jan 27 15:21:24 2008
@@ -0,0 +1,6 @@
+target*
+bin*
+.settings*
+.classpath
+.project
+.checkstyle
Added: felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ExceptionTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ExceptionTest.java?rev=615675&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ExceptionTest.java (added)
+++ felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ExceptionTest.java Sun Jan 27 15:21:24 2008
@@ -0,0 +1,83 @@
+package org.apache.felix.ipojo.test.scenarios.manipulation;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.architecture.Architecture;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.component.FooProviderType1;
+import org.apache.felix.ipojo.test.scenarios.service.FooService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+
+public class ExceptionTest extends OSGiTestCase {
+
+ private ComponentInstance ci_lazzy;
+ private ComponentInstance ci_immediate;
+
+ private ServiceReference lazzyRef;
+ private ServiceReference immRef;
+
+ public void setUp() {
+ String factName = "FooProviderType-1";
+ String compName = "FooProvider-1";
+
+ Properties p = new Properties();
+ p.put("name", compName);
+ ci_lazzy = Utils.getComponentInstance(context, factName, p);
+
+ String factName2 = "ImmediateFooProviderType";
+ String compName2 = "FooProvider-2";
+
+ Properties p2 = new Properties();
+ p2.put("name", compName2);
+ ci_immediate = Utils.getComponentInstance(context, factName2, p2);
+
+ lazzyRef = Utils.getServiceReference(context, Architecture.class.getName(), "(instance.name="+compName+")");
+ immRef = Utils.getServiceReference(context, Architecture.class.getName(), "(instance.name="+compName2+")");
+ assertNotNull("LazzyRef", lazzyRef);
+ assertNotNull("ImmRef", immRef);
+ }
+
+ public void tearDown() {
+ context.ungetService(lazzyRef);
+ context.ungetService(immRef);
+ ci_lazzy.dispose();
+ ci_immediate.dispose();
+ }
+
+
+ public void testException() {
+ ServiceReference[] refs = null;
+ try {
+ refs = context.getServiceReferences(FooService.class.getName(), "(instance.name="+ci_lazzy.getInstanceName()+")");
+ } catch (InvalidSyntaxException e) { e.printStackTrace(); }
+ assertNotNull("Check that a FooService from " + ci_lazzy.getInstanceName() + " is available",refs);
+ FooProviderType1 fs = (FooProviderType1) context.getService(refs[0]);
+ try {
+ fs.testException();
+ context.ungetService(refs[0]);
+ fail("The method must returns an exception");
+ } catch(Exception e) {
+ context.ungetService(refs[0]);
+ }
+ }
+
+ public void testTry() {
+ ServiceReference[] refs = null;
+ try {
+ refs = context.getServiceReferences(FooService.class.getName(), "(instance.name="+ci_lazzy.getInstanceName()+")");
+ } catch (InvalidSyntaxException e) { e.printStackTrace(); }
+ assertNotNull("Check that a FooService from " + ci_lazzy.getInstanceName() + " is available",refs);
+ FooProviderType1 fs = (FooProviderType1) context.getService(refs[0]);
+ try {
+ fs.testTry();
+ context.ungetService(refs[0]);
+ } catch(Exception e) {
+ context.ungetService(refs[0]);
+ fail("The method has returned an exception");
+ }
+ }
+
+}
Added: felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/GetComponentInstanceTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/GetComponentInstanceTest.java?rev=615675&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/GetComponentInstanceTest.java (added)
+++ felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/GetComponentInstanceTest.java Sun Jan 27 15:21:24 2008
@@ -0,0 +1,69 @@
+package org.apache.felix.ipojo.test.scenarios.manipulation;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.Factory;
+import org.apache.felix.ipojo.Pojo;
+import org.apache.felix.ipojo.architecture.InstanceDescription;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.service.FooService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+
+public class GetComponentInstanceTest extends OSGiTestCase {
+
+ public void testGetComponentInstance() {
+ String factName = "FooProviderType-1";
+ String compName = "FooProvider-1";
+ ServiceReference[] refs = null;
+
+ // Get the facotry to create a component instance
+ Factory fact = Utils.getFactoryByName(context, factName);
+ assertNotNull("Cannot find the factory FooProvider-1", fact);
+
+ Properties props = new Properties();
+ props.put("name", compName);
+ ComponentInstance ci = null;
+ try {
+ ci = fact.createComponentInstance(props);
+ } catch (Exception e1) { fail(e1.getMessage()); }
+
+ // Get a FooService provider
+ try {
+ refs = context.getServiceReferences(FooService.class.getName(), "(instance.name=" + compName + ")");
+ } catch (InvalidSyntaxException e) { fail("Service query failed (2) " + e); }
+
+ assertNotNull("FS not available", refs);
+
+ // Get foo object
+ FooService fs = (FooService) context.getService(refs[0]);
+
+ // Cast to POJO
+ Pojo pojo = (Pojo) fs;
+
+ // GetComponentInstance
+ ComponentInstance instance = pojo.getComponentInstance();
+ assertEquals("Check component instance name", instance.getInstanceName(), compName);
+ assertEquals("Check component factory name", instance.getFactory().getName(), factName);
+ assertNotNull("Instance description not null", instance.getInstanceDescription());
+ InstanceDescription id = instance.getInstanceDescription();
+ assertTrue("Check instance state", id.getState() == ComponentInstance.VALID);
+ assertEquals("Check created pojo count", id.getCreatedObjects().length, 1);
+ assertEquals("Check instance description name", id.getName(), compName);
+
+ // Unget the service
+ context.ungetService(refs[0]);
+
+ ci.dispose();
+
+ // Check that there is no more FooService
+ try {
+ refs = context.getServiceReferences(FooService.class.getName(), null);
+ } catch (InvalidSyntaxException e) { fail("Service query failed (3) : " + e.getMessage()); }
+
+ assertNull("FS available, but component instance stopped", refs);
+ }
+
+}
Added: felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationMetadata.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationMetadata.java?rev=615675&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationMetadata.java (added)
+++ felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationMetadata.java Sun Jan 27 15:21:24 2008
@@ -0,0 +1,219 @@
+package org.apache.felix.ipojo.test.scenarios.manipulation;
+
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.metadata.Element;
+import org.apache.felix.ipojo.parser.ManifestMetadataParser;
+import org.apache.felix.ipojo.parser.ParseException;
+import org.apache.felix.ipojo.parser.ParseUtils;
+import org.apache.felix.ipojo.test.scenarios.service.BarService;
+import org.apache.felix.ipojo.test.scenarios.service.FooService;
+
+public class ManipulationMetadata extends OSGiTestCase {
+
+ public void testGetMetadata() {
+ String header = (String) context.getBundle().getHeaders().get("iPOJO-Components");
+ Element elem = null;
+ try {
+ elem = ManifestMetadataParser.parse(header);
+ } catch (ParseException e) {
+ fail("Parse Exception when parsing iPOJO-Component");
+ }
+
+ assertNotNull("Check elem not null", elem);
+
+ Element manip = getManipulationForComponent(elem, "FooProviderType-1");
+ assertNotNull("Check manipulation metadata not null for " + "FooProviderType-1", manip);
+ }
+
+ public void testInterface() {
+ String comp_name = "FooProviderType-1";
+ Element manip = getManipulationForComponent(comp_name);
+ Element[] itf = manip.getElements("Interface");
+ assertEquals("Check interfaces number", itf.length, 1);
+ assertEquals("Check itf name", itf[0].getAttribute("name"), FooService.class.getName());
+ }
+
+ public void testInterfaces() {
+ String comp_name = "FooBarProviderType-1";
+ Element manip = getManipulationForComponent(comp_name);
+ Element[] itf = manip.getElements("Interface");
+ assertEquals("Check interfaces number", itf.length, 2);
+ assertEquals("Check itf name", itf[0].getAttribute("name"), FooService.class.getName());
+ assertEquals("Check itf name", itf[1].getAttribute("name"), BarService.class.getName());
+ }
+
+ public void testFields() {
+ String comp_name = "FooProviderType-Dyn";
+ Element manip = getManipulationForComponent(comp_name);
+ Element[] fields = manip.getElements("field");
+ assertEquals("Check field count " + fields.length, fields.length, 5);
+ /*
+ private int intProp;
+ private String strProp;
+ private String[] strAProp;
+ private int[] intAProp;
+ private boolean boolProp;
+ */
+
+ Element field;
+
+ field = getFieldFromName(manip, "intProp");
+ assertEquals("Check field name : " + field.getAttribute("name"), field.getAttribute("name"), "intProp");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "int");
+
+ field = getFieldFromName(manip, "strProp");
+ assertEquals("Check field name : " + field.getAttribute("name"), field.getAttribute("name"), "strProp");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "java.lang.String");
+
+ field = getFieldFromName(manip, "strAProp");
+ assertEquals("Check field name : " + field.getAttribute("name"), field.getAttribute("name"), "strAProp");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "java.lang.String[]");
+
+ field = getFieldFromName(manip, "intAProp");
+ assertEquals("Check field name : " + field.getAttribute("name"), field.getAttribute("name"), "intAProp");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "int[]");
+
+ field = getFieldFromName(manip, "boolProp");
+ assertEquals("Check field name : " + field.getAttribute("name"), field.getAttribute("name"), "boolProp");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "boolean");
+ }
+
+ public void testPrimitivesFields() {
+ String comp_name = "PrimitiveManipulationTester";
+ Element manip = getManipulationForComponent(comp_name);
+ Element[] fields = manip.getElements("Field");
+ assertEquals("Check field count", fields.length, 16);
+ /*
+ byte b = 1;
+ short s = 1;
+ int i = 1;
+ long l = 1;
+ double d = 1.1;
+ float f = 1.1f;
+ char c = 'a';
+ boolean bool = false;
+ byte[] bs = new byte[] {0,1,2};
+ short[] ss = new short[] {0,1,2};
+ int[] is = new int[] {0,1,2};
+ long[] ls = new long[] {0,1,2};
+ double[] ds = new double[] {0.0, 1.1, 2.2};
+ float[] fs = new float[] {0.0f, 1.1f, 2.2f};
+ char[] cs = new char[] {'a', 'b', 'c'};
+ boolean[] bools = new boolean[] {false, true, false};
+ */
+ Element field;
+
+ field = getFieldFromName(manip, "b");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "byte");
+ field = getFieldFromName(manip, "s");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "short");
+ field = getFieldFromName(manip, "i");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "int");
+ field = getFieldFromName(manip, "l");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "long");
+ field = getFieldFromName(manip, "d");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "double");
+ field = getFieldFromName(manip, "f");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "float");
+ field = getFieldFromName(manip, "c");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "char");
+ field = getFieldFromName(manip, "bool");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "boolean");
+
+ field = getFieldFromName(manip, "bs");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "byte[]");
+ field = getFieldFromName(manip, "ss");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "short[]");
+ field = getFieldFromName(manip, "is");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "int[]");
+ field = getFieldFromName(manip, "ls");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "long[]");
+ field = getFieldFromName(manip, "ds");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "double[]");
+ field = getFieldFromName(manip, "fs");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "float[]");
+ field = getFieldFromName(manip, "cs");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "char[]");
+ field = getFieldFromName(manip, "bools");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "boolean[]");
+ }
+
+ public void testNoArgMethod() {
+ String comp_name = "SimpleMultipleCheckServiceProvider";
+ Element manip = getManipulationForComponent(comp_name);
+ Element method = getMethodFromName(manip, "check");
+ assertFalse("Check no args", method.containsAttribute("arguments"));
+ assertEquals("Check return", method.getAttribute("return"), "boolean");
+ }
+
+ public void testOneArgsMethod() {
+ String comp_name = "SimpleMultipleCheckServiceProvider";
+ Element manip = getManipulationForComponent(comp_name);
+ Element method = getMethodFromName(manip, "refBind");
+ assertEquals("Check args", method.getAttribute("arguments"), "{org.osgi.framework.ServiceReference}");
+ assertEquals("Check args count", 1, ParseUtils.parseArrays("{org.osgi.framework.ServiceReference}").length);
+ assertFalse("Check return", method.containsAttribute("return"));
+ }
+
+ public void testTwoArgsMethod() {
+ String comp_name = "SimpleMultipleCheckServiceProvider";
+ Element manip = getManipulationForComponent(comp_name);
+ Element method = getMethodFromName(manip, "doNothing");
+ assertEquals("Check args", method.getAttribute("arguments"), "{java.lang.Object,java.lang.String}");
+ assertEquals("Check args count", 2, ParseUtils.parseArrays("{java.lang.Object,java.lang.String}").length);
+ assertEquals("Check return", method.getAttribute("return"), "java.lang.Object");
+ }
+
+ private Element getManipulationForComponent(Element metadata, String comp_name) {
+ Element[] comps = metadata.getElements("component");
+ for(int i = 0; i < comps.length; i++) {
+ if(comps[i].containsAttribute("factory") && comps[i].getAttribute("factory").equals(comp_name)) {
+ return comps[i].getElements("manipulation")[0];
+ }
+ if(comps[i].containsAttribute("name") && comps[i].getAttribute("name").equals(comp_name)) {
+ return comps[i].getElements("manipulation")[0];
+ }
+ }
+ return null;
+ }
+
+ private Element getManipulationForComponent(String comp_name) {
+ String header = (String) context.getBundle().getHeaders().get("iPOJO-Components");
+ Element elem = null;
+ try {
+ elem = ManifestMetadataParser.parse(header);
+ } catch (ParseException e) {
+ fail("Parse Exception when parsing iPOJO-Component");
+ }
+
+ assertNotNull("Check elem not null", elem);
+
+ Element manip = getManipulationForComponent(elem, comp_name);
+ assertNotNull("Check manipulation metadata not null for " + comp_name, manip);
+ return manip;
+ }
+
+ private Element getMethodFromName(Element manip, String name) {
+ Element methods[] = manip.getElements("Method");
+ for(int i = 0; i < methods.length; i++) {
+ if(methods[i].containsAttribute("name") && methods[i].getAttribute("name").equals(name)) {
+ return methods[i];
+ }
+ }
+ fail("Method " + name + " not found");
+ return null;
+ }
+
+ private Element getFieldFromName(Element manip, String name) {
+ Element fields[] = manip.getElements("Field");
+ for(int i = 0; i < fields.length; i++) {
+ if(fields[i].containsAttribute("name") && fields[i].getAttribute("name").equals(name)) {
+ return fields[i];
+ }
+ }
+ fail("Field " + name + " not found");
+ return null;
+ }
+
+
+}
Added: felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationMetadataAPI.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationMetadataAPI.java?rev=615675&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationMetadataAPI.java (added)
+++ felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationMetadataAPI.java Sun Jan 27 15:21:24 2008
@@ -0,0 +1,260 @@
+package org.apache.felix.ipojo.test.scenarios.manipulation;
+
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.metadata.Element;
+import org.apache.felix.ipojo.parser.FieldMetadata;
+import org.apache.felix.ipojo.parser.ManifestMetadataParser;
+import org.apache.felix.ipojo.parser.MethodMetadata;
+import org.apache.felix.ipojo.parser.ParseException;
+import org.apache.felix.ipojo.parser.PojoMetadata;
+import org.apache.felix.ipojo.test.scenarios.service.BarService;
+import org.apache.felix.ipojo.test.scenarios.service.FooService;
+
+public class ManipulationMetadataAPI extends OSGiTestCase {
+
+ PojoMetadata FooProviderType1, FooBarProviderType1, FooProviderTypeDyn, PrimitiveManipulationTester, SimpleMultipleCheckServiceProvider;
+
+ public void setUp() {
+ String comp_name = "FooProviderType-1";
+ FooProviderType1 = getManipulationMetadataForComponent(comp_name);
+
+ comp_name = "FooBarProviderType-1";
+ FooBarProviderType1 = getManipulationMetadataForComponent(comp_name);
+
+ comp_name = "FooProviderType-Dyn";
+ FooProviderTypeDyn = getManipulationMetadataForComponent(comp_name);
+
+ comp_name = "PrimitiveManipulationTester";
+ PrimitiveManipulationTester = getManipulationMetadataForComponent(comp_name);
+
+ comp_name = "SimpleMultipleCheckServiceProvider";
+ SimpleMultipleCheckServiceProvider = getManipulationMetadataForComponent(comp_name);
+ }
+
+ public void testGetMetadata() {
+ String header = (String) context.getBundle().getHeaders().get("iPOJO-Components");
+ Element elem = null;
+ try {
+ elem = ManifestMetadataParser.parse(header);
+ } catch (ParseException e) {
+ fail("Parse Exception when parsing iPOJO-Component");
+ }
+
+ assertNotNull("Check elem not null", elem);
+
+ Element manip = getMetadataForComponent(elem, "FooProviderType-1");
+ assertNotNull("Check manipulation metadata not null for " + "FooProviderType-1", manip);
+ PojoMetadata mm = new PojoMetadata(manip);
+ assertNotNull("Check mm not null", mm);
+ }
+
+ public void testInterface() {
+ PojoMetadata manip = FooProviderType1;
+
+ String[] itf = manip.getInterfaces();
+ assertEquals("Check interfaces number", itf.length, 1);
+ assertEquals("Check itf name", itf[0], FooService.class.getName());
+
+ assertTrue("Check Foo Service implementation", manip.isInterfaceImplemented(FooService.class.getName()));
+ assertFalse("Check Bar Service implementation", manip.isInterfaceImplemented(BarService.class.getName()));
+ }
+
+ public void testInterfaces() {
+ PojoMetadata manip = FooBarProviderType1;
+ String[] itf = manip.getInterfaces();
+ assertEquals("Check interfaces number", itf.length, 2);
+ assertEquals("Check itf name", itf[0], FooService.class.getName());
+ assertEquals("Check itf name", itf[1], BarService.class.getName());
+
+ assertTrue("Check Foo Service implementation", manip.isInterfaceImplemented(FooService.class.getName()));
+ assertTrue("Check Bar Service implementation", manip.isInterfaceImplemented(BarService.class.getName()));
+ }
+
+ public void testFields() {
+ PojoMetadata manip = FooProviderTypeDyn;
+
+ FieldMetadata[] fields = manip.getFields();
+ assertEquals("Check field count + " + fields.length, fields.length, 5);
+ /*
+ private int intProp;
+ private String strProp;
+ private String[] strAProp;
+ private int[] intAProp;
+ private boolean boolProp;
+ */
+
+ FieldMetadata field;
+
+ field = manip.getField("intProp");
+ assertEquals("Check field name : " + field.getFieldName(), field.getFieldName(), "intProp");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "int");
+ assertEquals("Check field reflective type : " + field.getFieldName(), field.getReflectionType(), "int");
+
+ field = manip.getField("intProp", "int");
+ assertEquals("Check field name : " + field.getFieldName(), field.getFieldName(), "intProp");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "int");
+
+ field = manip.getField("intProp", "long");
+ assertNull("Check bad field", field);
+
+ field = manip.getField("strProp");
+ assertEquals("Check field name : " + field.getFieldName(), field.getFieldName(), "strProp");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "java.lang.String");
+ assertEquals("Check field reflective type : " + field.getFieldName(), field.getReflectionType(), "java.lang.String");
+
+ field = manip.getField("strProp", "String");
+ assertNull("Check bad field", field);
+
+ field = manip.getField("strProp", "java.lang.String");
+ assertEquals("Check field name : " + field.getFieldName(), field.getFieldName(), "strProp");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "java.lang.String");
+
+ field = manip.getField("strAProp");
+ assertEquals("Check field name : " + field.getFieldName(), field.getFieldName(), "strAProp");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "java.lang.String[]");
+ assertEquals("Check field reflective type : " + field.getFieldName() + " -> " + field.getReflectionType(), field.getReflectionType(), "[Ljava.lang.String;");
+
+ field = manip.getField("strAProp", "java.lang.String[]");
+ assertEquals("Check field name : " + field.getFieldName(), field.getFieldName(), "strAProp");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "java.lang.String[]");
+
+ field = manip.getField("strAProp", "String[]");
+ assertNull("Check bad field", field);
+
+ field = manip.getField("intAProp");
+ assertEquals("Check field name : " + field.getFieldName(), field.getFieldName(), "intAProp");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "int[]");
+ assertEquals("Check field reflective type : " + field.getFieldName() + " -> " + field.getReflectionType(), field.getReflectionType(), "[I");
+
+ field = manip.getField("intAProp", "int[]");
+ assertEquals("Check field name : " + field.getFieldName(), field.getFieldName(), "intAProp");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "int[]");
+
+ field = manip.getField("intAProp", "String[]");
+ assertNull("Check bad field", field);
+
+ field = manip.getField("boolProp");
+ assertEquals("Check field name : " + field.getFieldName(), field.getFieldName(), "boolProp");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "boolean");
+ assertEquals("Check field reflective type : " + field.getFieldName(), field.getReflectionType(), "boolean");
+
+ field = manip.getField("boolProp", "boolean");
+ assertEquals("Check field name : " + field.getFieldName(), field.getFieldName(), "boolProp");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "boolean");
+
+ field = manip.getField("boolProp", "bool");
+ assertNull("Check bad field", field);
+ }
+
+ public void testPrimitivesFields() {
+ PojoMetadata manip = PrimitiveManipulationTester;
+ FieldMetadata[] fields = manip.getFields();
+ assertEquals("Check field count", fields.length, 16);
+
+ FieldMetadata field;
+
+ field = manip.getField("b");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "byte");
+ field = manip.getField("s");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "short");
+ field = manip.getField("i");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "int");
+ field = manip.getField("l");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "long");
+ field = manip.getField("d");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "double");
+ field = manip.getField("f");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "float");
+ field = manip.getField("c");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "char");
+ field = manip.getField("bool");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "boolean");
+
+ field = manip.getField("bs");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "byte[]");
+ field = manip.getField("ss");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "short[]");
+ field = manip.getField("is");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "int[]");
+ field = manip.getField("ls");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "long[]");
+ field = manip.getField("ds");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "double[]");
+ field = manip.getField("fs");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "float[]");
+ field = manip.getField("cs");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "char[]");
+ field = manip.getField("bools");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "boolean[]");
+ }
+
+ public void testNoArgMethod() {
+ PojoMetadata manip = SimpleMultipleCheckServiceProvider;
+ MethodMetadata method = manip.getMethod("check");
+ assertEquals("Check no args", method.getMethodArguments().length, 0);
+ assertEquals("Check return", method.getMethodReturn(), "boolean");
+
+ method = manip.getMethod("check", new String[0]);
+ assertEquals("Check no args", method.getMethodArguments().length, 0);
+ assertEquals("Check return", method.getMethodReturn(), "boolean");
+ }
+
+ public void testOneArgsMethod() {
+ PojoMetadata manip = SimpleMultipleCheckServiceProvider;
+ MethodMetadata method = manip.getMethods("refBind")[0];
+ assertEquals("Check args count", method.getMethodArguments().length, 1);
+ assertEquals("Check args", method.getMethodArguments()[0], "org.osgi.framework.ServiceReference");
+ assertEquals("Check return", method.getMethodReturn(), "void");
+
+ method = manip.getMethod("refBind", new String[] {"org.osgi.framework.ServiceReference"});
+ assertEquals("Check args count", method.getMethodArguments().length, 1);
+ assertEquals("Check args", method.getMethodArguments()[0], "org.osgi.framework.ServiceReference");
+ assertEquals("Check return", method.getMethodReturn(), "void");
+ }
+
+ public void testTwoArgsMethod() {
+ PojoMetadata manip = SimpleMultipleCheckServiceProvider;
+ MethodMetadata method = manip.getMethods("doNothing")[0];
+ assertEquals("Check args count", 2, method.getMethodArguments().length);
+ assertEquals("Check args - 1", method.getMethodArguments()[0], "java.lang.Object");
+ assertEquals("Check args - 2", method.getMethodArguments()[1], "java.lang.String");
+ assertEquals("Check return", method.getMethodReturn(), "java.lang.Object");
+
+ method = manip.getMethod("doNothing", new String[] {"java.lang.Object", "java.lang.String"});
+ assertEquals("Check args count", 2, method.getMethodArguments().length);
+ assertEquals("Check args - 1", method.getMethodArguments()[0], "java.lang.Object");
+ assertEquals("Check args - 2", method.getMethodArguments()[1], "java.lang.String");
+ assertEquals("Check return", method.getMethodReturn(), "java.lang.Object");
+ }
+
+ private Element getMetadataForComponent(Element metadata, String comp_name) {
+ Element[] comps = metadata.getElements("component");
+ for(int i = 0; i < comps.length; i++) {
+ if(comps[i].containsAttribute("factory") && comps[i].getAttribute("factory").equals(comp_name)) {
+ return comps[i];
+ }
+ if(comps[i].containsAttribute("name") && comps[i].getAttribute("name").equals(comp_name)) {
+ return comps[i];
+ }
+ }
+ return null;
+ }
+
+
+ private PojoMetadata getManipulationMetadataForComponent(String comp_name) {
+ String header = (String) context.getBundle().getHeaders().get("iPOJO-Components");
+ Element elem = null;
+ try {
+ elem = ManifestMetadataParser.parse(header);
+ } catch (ParseException e) {
+ fail("Parse Exception when parsing iPOJO-Component");
+ }
+
+ assertNotNull("Check elem not null", elem);
+
+ Element manip = getMetadataForComponent(elem, comp_name);
+ assertNotNull("Check manipulation metadata not null for " + comp_name, manip);
+ return new PojoMetadata(manip);
+ }
+
+}
Added: felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java?rev=615675&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java (added)
+++ felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java Sun Jan 27 15:21:24 2008
@@ -0,0 +1,21 @@
+package org.apache.felix.ipojo.test.scenarios.manipulation;
+
+import junit.framework.Test;
+
+import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
+import org.osgi.framework.BundleContext;
+
+public class ManipulationTestSuite {
+
+ public static Test suite(BundleContext bc) {
+ OSGiTestSuite ots = new OSGiTestSuite("Manipulation Test Suite", bc);
+ ots.addTestSuite(ManipulationMetadata.class);
+ ots.addTestSuite(PrimitiveTypeTest.class);
+ ots.addTestSuite(PrimitiveTypeTest2.class);
+ ots.addTestSuite(GetComponentInstanceTest.class);
+ ots.addTestSuite(ManipulationMetadataAPI.class);
+ ots.addTestSuite(ExceptionTest.class);
+ return ots;
+ }
+
+}
Added: felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/PrimitiveTypeTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/PrimitiveTypeTest.java?rev=615675&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/PrimitiveTypeTest.java (added)
+++ felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/PrimitiveTypeTest.java Sun Jan 27 15:21:24 2008
@@ -0,0 +1,83 @@
+package org.apache.felix.ipojo.test.scenarios.manipulation;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.service.PrimitiveManipulationTestService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.ServiceReference;
+
+public class PrimitiveTypeTest extends OSGiTestCase {
+
+ ComponentInstance instance; // Instance under test
+ PrimitiveManipulationTestService prim;
+ ServiceReference prim_ref;
+
+ public void setUp() {
+ Properties p1 = new Properties();
+ p1.put("name", "primitives");
+ instance = Utils.getComponentInstance(context, "PrimitiveManipulationTester", p1);
+ assertTrue("check instance state", instance.getState() == ComponentInstance.VALID);
+ prim_ref = Utils.getServiceReferenceByName(context, PrimitiveManipulationTestService.class.getName(), instance.getInstanceName());
+ assertNotNull("Check prim availability", prim_ref);
+ prim = (PrimitiveManipulationTestService) context.getService(prim_ref);
+ }
+
+ public void tearDown() {
+ context.ungetService(prim_ref);
+ prim = null;
+ instance.dispose();
+ instance = null;
+ }
+
+ public void testByte() {
+ assertEquals("Check - 1", prim.getByte(), 1);
+ prim.setByte((byte) 2);
+ assertEquals("Check - 2", prim.getByte(), 2);
+ }
+
+ public void testShort() {
+ assertEquals("Check - 1", prim.getShort(), 1);
+ prim.setShort((short) 2);
+ assertEquals("Check - 2", prim.getShort(), 2);
+ }
+
+ public void testInt() {
+ assertEquals("Check - 1", prim.getInt(), 1);
+ prim.setInt((int) 2);
+ assertEquals("Check - 2", prim.getInt(), 2);
+ }
+
+ public void testLong() {
+ assertEquals("Check - 1", prim.getLong(), 1);
+ prim.setLong((long) 2);
+ assertEquals("Check - 2", prim.getLong(), 2);
+ }
+
+ public void testFloat() {
+ assertEquals("Check - 1", prim.getFloat(), 1.1f);
+ prim.setFloat(2.2f);
+ assertEquals("Check - 2", prim.getFloat(), 2.2f);
+ }
+
+ public void testDouble() {
+ assertEquals("Check - 1", prim.getDouble(), 1.1);
+ prim.setDouble(2.2);
+ assertEquals("Check - 2", prim.getDouble(), 2.2);
+ }
+
+ public void testBoolean() {
+ assertFalse("Check - 1", prim.getBoolean());
+ prim.setBoolean(true);
+ assertTrue("Check - 2", prim.getBoolean());
+ }
+
+ public void testChar() {
+ assertEquals("Check - 1", prim.getChar(), 'a');
+ prim.setChar('b');
+ assertEquals("Check - 2", prim.getChar(), 'b');
+ }
+
+
+}
Added: felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/PrimitiveTypeTest2.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/PrimitiveTypeTest2.java?rev=615675&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/PrimitiveTypeTest2.java (added)
+++ felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/PrimitiveTypeTest2.java Sun Jan 27 15:21:24 2008
@@ -0,0 +1,83 @@
+package org.apache.felix.ipojo.test.scenarios.manipulation;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.service.PrimitiveManipulationTestService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.ServiceReference;
+
+public class PrimitiveTypeTest2 extends OSGiTestCase {
+
+ ComponentInstance instance; // Instance under test
+ PrimitiveManipulationTestService prim;
+ ServiceReference prim_ref;
+
+ public void setUp() {
+ Properties p1 = new Properties();
+ p1.put("name", "primitives");
+ instance = Utils.getComponentInstance(context, "PrimitiveManipulationTesterA", p1);
+ assertTrue("check instance state", instance.getState() == ComponentInstance.VALID);
+ prim_ref = Utils.getServiceReferenceByName(context, PrimitiveManipulationTestService.class.getName(), instance.getInstanceName());
+ assertNotNull("Check prim availability", prim_ref);
+ prim = (PrimitiveManipulationTestService) context.getService(prim_ref);
+ }
+
+ public void tearDown() {
+ context.ungetService(prim_ref);
+ prim = null;
+ instance.dispose();
+ instance = null;
+ }
+
+ public void testByte() {
+ assertEquals("Check - 1", prim.getByte(), 1);
+ prim.setByte((byte) 2);
+ assertEquals("Check - 2", prim.getByte(), 2);
+ }
+
+ public void testShort() {
+ assertEquals("Check - 1", prim.getShort(), 1);
+ prim.setShort((short) 2);
+ assertEquals("Check - 2", prim.getShort(), 2);
+ }
+
+ public void testInt() {
+ assertEquals("Check - 1", prim.getInt(), 1);
+ prim.setInt((int) 2);
+ assertEquals("Check - 2", prim.getInt(), 2);
+ }
+
+ public void testLong() {
+ assertEquals("Check - 1", prim.getLong(), 1);
+ prim.setLong((long) 2);
+ assertEquals("Check - 2", prim.getLong(), 2);
+ }
+
+ public void testFloat() {
+ assertEquals("Check - 1", prim.getFloat(), 1.1f);
+ prim.setFloat(2.2f);
+ assertEquals("Check - 2", prim.getFloat(), 2.2f);
+ }
+
+ public void testDouble() {
+ assertEquals("Check - 1", prim.getDouble(), 1.1);
+ prim.setDouble(2.2);
+ assertEquals("Check - 2", prim.getDouble(), 2.2);
+ }
+
+ public void testBoolean() {
+ assertFalse("Check - 1", prim.getBoolean());
+ prim.setBoolean(true);
+ assertTrue("Check - 2", prim.getBoolean());
+ }
+
+ public void testChar() {
+ assertEquals("Check - 1", prim.getChar(), 'a');
+ prim.setChar('b');
+ assertEquals("Check - 2", prim.getChar(), 'b');
+ }
+
+
+}
Propchange: felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Jan 27 15:21:24 2008
@@ -0,0 +1,6 @@
+target*
+bin*
+.settings*
+.classpath
+.project
+.checkstyle
Propchange: felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/A123/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Jan 27 15:21:24 2008
@@ -0,0 +1,6 @@
+target*
+bin*
+.settings*
+.classpath
+.project
+.checkstyle
Added: felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/A123/CheckService2.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/A123/CheckService2.java?rev=615675&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/A123/CheckService2.java (added)
+++ felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/A123/CheckService2.java Sun Jan 27 15:21:24 2008
@@ -0,0 +1,7 @@
+package org.apache.felix.ipojo.test.scenarios.service.A123;
+
+public interface CheckService2 {
+
+ public boolean check();
+
+}
Added: felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/BarService.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/BarService.java?rev=615675&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/BarService.java (added)
+++ felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/BarService.java Sun Jan 27 15:21:24 2008
@@ -0,0 +1,11 @@
+package org.apache.felix.ipojo.test.scenarios.service;
+
+import java.util.Properties;
+
+public interface BarService {
+
+ public boolean bar();
+
+ public Properties getProps();
+
+}
Added: felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/BazService.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/BazService.java?rev=615675&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/BazService.java (added)
+++ felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/BazService.java Sun Jan 27 15:21:24 2008
@@ -0,0 +1,21 @@
+package org.apache.felix.ipojo.test.scenarios.service;
+
+import java.util.Properties;
+
+public interface BazService {
+
+ boolean foo();
+
+ Properties fooProps();
+
+ Boolean getObject();
+
+ boolean getBoolean();
+
+ int getInt();
+
+ long getLong();
+
+ double getDouble();
+
+}
Added: felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/CheckService.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/CheckService.java?rev=615675&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/CheckService.java (added)
+++ felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/CheckService.java Sun Jan 27 15:21:24 2008
@@ -0,0 +1,13 @@
+package org.apache.felix.ipojo.test.scenarios.service;
+
+import java.util.Properties;
+
+public interface CheckService {
+
+ public static final String foo = "foo";
+
+ public boolean check();
+
+ public Properties getProps();
+
+}
Added: felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/ChildInterface.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/ChildInterface.java?rev=615675&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/ChildInterface.java (added)
+++ felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/ChildInterface.java Sun Jan 27 15:21:24 2008
@@ -0,0 +1,7 @@
+package org.apache.felix.ipojo.test.scenarios.service;
+
+public interface ChildInterface extends ParentInterface1, ParentInterface2 {
+
+ public void processChild();
+
+}
Added: felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/FooService.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/FooService.java?rev=615675&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/FooService.java (added)
+++ felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/FooService.java Sun Jan 27 15:21:24 2008
@@ -0,0 +1,21 @@
+package org.apache.felix.ipojo.test.scenarios.service;
+
+import java.util.Properties;
+
+public interface FooService {
+
+ boolean foo();
+
+ Properties fooProps();
+
+ Boolean getObject();
+
+ boolean getBoolean();
+
+ int getInt();
+
+ long getLong();
+
+ double getDouble();
+
+}
Added: felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/ParentInterface1.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/ParentInterface1.java?rev=615675&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/ParentInterface1.java (added)
+++ felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/ParentInterface1.java Sun Jan 27 15:21:24 2008
@@ -0,0 +1,7 @@
+package org.apache.felix.ipojo.test.scenarios.service;
+
+public interface ParentInterface1 extends ParentParentInterface {
+
+ public void processParent1();
+
+}
Added: felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/ParentInterface2.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/ParentInterface2.java?rev=615675&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/ParentInterface2.java (added)
+++ felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/ParentInterface2.java Sun Jan 27 15:21:24 2008
@@ -0,0 +1,7 @@
+package org.apache.felix.ipojo.test.scenarios.service;
+
+public interface ParentInterface2 {
+
+ public void processParent2();
+
+}
Added: felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/ParentParentInterface.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/ParentParentInterface.java?rev=615675&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/ParentParentInterface.java (added)
+++ felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/ParentParentInterface.java Sun Jan 27 15:21:24 2008
@@ -0,0 +1,7 @@
+package org.apache.felix.ipojo.test.scenarios.service;
+
+public interface ParentParentInterface {
+
+ public void processParentParent();
+
+}
Added: felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/PrimitiveManipulationTestService.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/PrimitiveManipulationTestService.java?rev=615675&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/PrimitiveManipulationTestService.java (added)
+++ felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/PrimitiveManipulationTestService.java Sun Jan 27 15:21:24 2008
@@ -0,0 +1,54 @@
+package org.apache.felix.ipojo.test.scenarios.service;
+
+public interface PrimitiveManipulationTestService {
+
+ byte getByte();
+ void setByte(byte b);
+
+ short getShort();
+ void setShort(short s);
+
+ int getInt();
+ void setInt(int i);
+
+ long getLong();
+ void setLong(long l);
+
+ float getFloat();
+ void setFloat(float f);
+
+ double getDouble();
+ void setDouble(double d);
+
+ char getChar();
+ void setChar(char c);
+
+ boolean getBoolean();
+ void setBoolean(boolean b);
+
+ // Array types
+ byte[] getBytes();
+ void setBytes(byte[] bs);
+
+ short[] getShorts();
+ void setShorts(short[] ss);
+
+ int[] getInts();
+ void setInts(int is[]);
+
+ long[] getLongs();
+ void setLongs(long[] ls);
+
+ float[] getFloats();
+ void setFloats(float[] fs);
+
+ double[] getDoubles();
+ void setDoubles(double[] ds);
+
+ char[] getChars();
+ void setChars(char[] cs);
+
+ boolean[] getBooleans();
+ void setBooleans(boolean[] bs);
+
+}
Propchange: felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/providing/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Jan 27 15:21:24 2008
@@ -0,0 +1,6 @@
+target*
+bin*
+.settings*
+.classpath
+.project
+.checkstyle
Added: felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/providing/DynamicProps.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/providing/DynamicProps.java?rev=615675&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/providing/DynamicProps.java (added)
+++ felix/sandbox/clement/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/service/providing/DynamicProps.java Sun Jan 27 15:21:24 2008
@@ -0,0 +1,213 @@
+package org.apache.felix.ipojo.test.scenarios.service.providing;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.service.FooService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.ServiceReference;
+
+public class DynamicProps extends OSGiTestCase {
+
+ ComponentInstance fooProvider1;
+ ComponentInstance fooProvider2;
+ ComponentInstance fooProvider3;
+
+ public void setUp() {
+ String type = "FooProviderType-Dyn";
+
+ 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);
+
+ String type2 = "FooProviderType-Dyn2";
+ Properties p3 = new Properties();
+ p3.put("name", "FooProvider-3");
+ p3.put("int", new Integer(0));
+ p3.put("boolean", new Boolean(true));
+ p3.put("string", new String(""));
+ p3.put("strAProp", new String[0]);
+ p3.put("intAProp", new int[0]);
+ fooProvider3 = Utils.getComponentInstance(context, type2, p3);
+
+ }
+
+ public void tearDown() {
+ fooProvider1.dispose();
+ fooProvider1 = null;
+ fooProvider2.dispose();
+ fooProvider2 = null;
+ fooProvider3.dispose();
+ fooProvider3 = null;
+ }
+
+ public void testProperties1() {
+ ServiceReference sr = Utils.getServiceReferenceByName(context, FooService.class.getName(), "FooProvider-1");
+ assertNotNull("Check the availability of the FS service", sr);
+
+ // Check service properties
+ Integer intProp = (Integer) sr.getProperty("int");
+ Boolean boolProp = (Boolean) sr.getProperty("boolean");
+ String strProp = (String) sr.getProperty("string");
+ String[] strAProp = (String[]) sr.getProperty("strAProp");
+ int[] intAProp = (int[]) sr.getProperty("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)"); }
+ }
+ 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)"); }
+ }
+
+ // Invoke
+ FooService fs = (FooService) context.getService(sr);
+ assertTrue("invoke fs", fs.foo());
+
+ // Re-check the property (change)
+ intProp = (Integer) sr.getProperty("int");
+ boolProp = (Boolean) sr.getProperty("boolean");
+ strProp = (String) sr.getProperty("string");
+ strAProp = (String[]) sr.getProperty("strAProp");
+ intAProp = (int[]) sr.getProperty("intAProp");
+
+ assertEquals("Check intProp equality (2)", 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)"); }
+ }
+
+ fs = null;
+ context.ungetService(sr);
+ }
+
+ public void testProperties2() {
+ ServiceReference sr = Utils.getServiceReferenceByName(context, FooService.class.getName(), "FooProvider-2");
+ assertNotNull("Check the availability of the FS service", sr);
+
+ // Check service properties
+ Integer intProp = (Integer) sr.getProperty("int");
+ Boolean boolProp = (Boolean) sr.getProperty("boolean");
+ String strProp = (String) sr.getProperty("string");
+ String[] strAProp = (String[]) sr.getProperty("strAProp");
+ int[] intAProp = (int[]) sr.getProperty("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"); }
+ }
+
+ // Invoke
+ FooService fs = (FooService) context.getService(sr);
+ assertTrue("invoke fs", fs.foo());
+
+ // Re-check the property (change)
+ intProp = (Integer) sr.getProperty("int");
+ boolProp = (Boolean) sr.getProperty("boolean");
+ strProp = (String) sr.getProperty("string");
+ strAProp = (String[]) sr.getProperty("strAProp");
+ intAProp = (int[]) sr.getProperty("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);
+ }
+
+ public void testProperties3() {
+ ServiceReference sr = Utils.getServiceReferenceByName(context, FooService.class.getName(), "FooProvider-3");
+ assertNotNull("Check the availability of the FS service", sr);
+
+ // Check service properties
+ Integer intProp = (Integer) sr.getProperty("int");
+ Boolean boolProp = (Boolean) sr.getProperty("boolean");
+ String strProp = (String) sr.getProperty("string");
+ String[] strAProp = (String[]) sr.getProperty("strAProp");
+ int[] intAProp = (int[]) sr.getProperty("intAProp");
+
+ assertEquals("Check intProp equality", intProp, new Integer(0));
+ assertEquals("Check longProp equality", boolProp, new Boolean(true));
+ assertEquals("Check strProp equality", strProp, new String(""));
+ assertNotNull("Check strAProp not nullity", strAProp);
+ String[] v = new String[0];
+ 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[0];
+ for (int i = 0; i < intAProp.length; i++) {
+ if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality"); }
+ }
+
+ // Invoke
+ FooService fs = (FooService) context.getService(sr);
+ assertTrue("invoke fs", fs.foo());
+
+ // Re-check the property (change)
+ intProp = (Integer) sr.getProperty("int");
+ boolProp = (Boolean) sr.getProperty("boolean");
+ strProp = (String) sr.getProperty("string");
+ strAProp = (String[]) sr.getProperty("strAProp");
+ intAProp = (int[]) sr.getProperty("intAProp");
+
+ assertEquals("Check intProp equality", intProp, new Integer(2));
+ 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"};
+ for (int i = 0; i < strAProp.length; i++) {
+ if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality"); }
+ }
+ assertNull("Check intAProp hidding (no value)", intAProp);
+
+ fs = null;
+ context.ungetService(sr);
+
+ }
+
+}