use of org.apache.felix.ipojo.runtime.externalhandlers.services.FooService in project felix by apache.
the class HandlerWithFieldInterceptorTest method testFieldInterception.
@Test
public void testFieldInterception() {
// Check the availability of CheckService
String name = "HandlerTest-1";
ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), name);
assertNotNull("Check the check service availability", ref);
CheckService cs = (CheckService) osgiHelper.getRawServiceObject(ref);
Dictionary<String, Object> p = cs.getProps();
assertEquals("Assert 'simple' equality", p.get("Simple"), "simple");
assertEquals("Assert 'a' equality", p.get("Map1"), "a");
assertEquals("Assert 'b' equality", p.get("Map2"), "b");
assertEquals("Assert 'c' equality", p.get("Map3"), "c");
assertEquals("check foo value", FooService.VALUE, cs.getProps().get("foo"));
// Change value.
ServiceReference ref2 = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), name);
assertNotNull("Check the foo service availability", ref2);
FooService fs = (FooService) osgiHelper.getRawServiceObject(ref2);
// This trigger the changes.
fs.foo();
assertEquals("check foo value", FooService.VALUE_2, cs.getProps().get("foo"));
}
Aggregations