if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality"); }
}
// Reconfiguration
ServiceReference fact_ref = helper.getServiceReferenceByName(ManagedServiceFactory.class.getName() , "PS-FooProviderType-Dyn2");
ManagedServiceFactory fact = (ManagedServiceFactory) getServiceObject(fact_ref);
Properties p3 = new Properties();
p3.put("int", new Integer(1));
p3.put("boolean", new Boolean(true));
p3.put("string", new String("foo"));
p3.put("strAProp", new String[] {"foo", "bar", "baz"});
p3.put("intAProp", new int[] { 1, 2, 3});
try {
fact.updated("FooProvider-3", p3);
} catch (ConfigurationException e) {
fail("Unable to reconfigure the instance with : " + p3);
}
sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-3");
assertNotNull("Check the availability of the FS service", sr);
// Check service properties
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(1));
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[] { 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) getServiceObject(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);
// Reconfiguration
fact_ref = helper.getServiceReferenceByName(ManagedServiceFactory.class.getName() , "PS-FooProviderType-Dyn2");
fact = (ManagedServiceFactory) getServiceObject(fact_ref);
p3 = new Properties();
p3.put("int", new Integer(1));
p3.put("boolean", new Boolean(true));
p3.put("string", new String("foo"));
p3.put("strAProp", new String[] {"foo", "bar", "baz"});
p3.put("intAProp", new int[] { 1, 2, 3});
try {
fact.updated("FooProvider-3", p3);
} catch (ConfigurationException e) {
fail("Unable to reconfigure the instance with : " + p3);
}
sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProvider-3");