use of org.apache.aries.blueprint.itests.cm.service.Foo in project aries by apache.
the class ManagedServiceFactoryTest method test3.
@Test
public void test3() throws Exception {
Configuration cf = ca.createFactoryConfiguration("blueprint-sample-managed-service-factory3", null);
Hashtable<String, String> props = new Hashtable<String, String>();
props.put("a", "5");
cf.update(props);
@SuppressWarnings("rawtypes") ServiceReference sr = getServiceRef(Foo.class, "(&(key=foo3)(a=5))");
assertNotNull(sr);
Foo foo = (Foo) context().getService(sr);
assertNotNull(foo);
assertEquals(5, foo.getA());
assertEquals("default", foo.getB());
assertEquals("5", sr.getProperty("a"));
assertNull(sr.getProperty("b"));
props = new Hashtable<String, String>();
props.put("a", "5");
props.put("b", "foo");
cf.update(props);
// Update after creation
Thread.sleep(500);
assertEquals(5, foo.getA());
assertEquals("foo", foo.getB());
// Update of service properties
assertEquals("5", sr.getProperty("a"));
assertEquals("foo", sr.getProperty("b"));
cf.delete();
}
use of org.apache.aries.blueprint.itests.cm.service.Foo in project aries by apache.
the class ManagedServiceFactoryTest method test1.
@Test
public void test1() throws Exception {
Configuration cf = ca.createFactoryConfiguration("blueprint-sample-managed-service-factory", null);
Hashtable<String, String> props = new Hashtable<String, String>();
props.put("a", "5");
cf.update(props);
@SuppressWarnings("rawtypes") ServiceReference sr = getServiceRef(Foo.class, "(key=foo1)");
Foo foo = (Foo) context().getService(sr);
assertNotNull(foo);
assertEquals(5, foo.getA());
assertEquals("default", foo.getB());
assertEquals("5", sr.getProperty("a"));
assertNull(sr.getProperty("b"));
props = new Hashtable<String, String>();
props.put("a", "5");
props.put("b", "foo");
cf.update(props);
Thread.sleep(500);
// No update of bean after creation
assertEquals(5, foo.getA());
assertEquals("default", foo.getB());
// Only initial update of service properties
assertEquals("5", sr.getProperty("a"));
assertNull(sr.getProperty("b"));
}
use of org.apache.aries.blueprint.itests.cm.service.Foo in project aries by apache.
the class ManagedServiceFactoryTest method test2.
@Test
public void test2() throws Exception {
Configuration cf = ca.createFactoryConfiguration("blueprint-sample-managed-service-factory2", null);
Hashtable<String, String> props = new Hashtable<String, String>();
props.put("a", "5");
cf.update(props);
@SuppressWarnings("rawtypes") ServiceReference sr = getServiceRef(Foo.class, "(key=foo2)");
Foo foo = (Foo) context().getService(sr);
assertNotNull(foo);
assertEquals(5, foo.getA());
assertEquals("default", foo.getB());
assertNull(sr.getProperty("a"));
assertNull(sr.getProperty("b"));
props = new Hashtable<String, String>();
props.put("a", "5");
props.put("b", "foo");
cf.update(props);
// Update after creation
Thread.sleep(500);
assertEquals(5, foo.getA());
assertEquals("foo", foo.getB());
// No update of service properties
assertNull(sr.getProperty("a"));
assertNull(sr.getProperty("b"));
}
use of org.apache.aries.blueprint.itests.cm.service.Foo in project aries by apache.
the class ManagedServiceFactoryTest method testFactoryCreation.
@Test
public void testFactoryCreation() throws Exception {
Configuration cf = ca.createFactoryConfiguration("blueprint-sample-managed-service-factory5", null);
Hashtable<String, String> props = new Hashtable<String, String>();
props.put("a", "5");
cf.update(props);
@SuppressWarnings("rawtypes") ServiceReference sr = getServiceRef(Foo.class, "(key=foo5)");
Foo foo = (Foo) context().getService(sr);
assertNotNull(foo);
assertEquals(5, foo.getA());
assertEquals("default", foo.getB());
assertEquals("5", sr.getProperty("a"));
assertNull(sr.getProperty("b"));
props = new Hashtable<String, String>();
props.put("a", "5");
props.put("b", "foo");
cf.update(props);
Thread.sleep(500);
// No update of bean after creation
assertEquals(5, foo.getA());
assertEquals("default", foo.getB());
// Only initial update of service properties
assertEquals("5", sr.getProperty("a"));
assertNull(sr.getProperty("b"));
}
use of org.apache.aries.blueprint.itests.cm.service.Foo in project aries by apache.
the class ManagedServiceFactoryTest method testCreateAndUpdateUsingUpdateMethod.
@SuppressWarnings("rawtypes")
@Test
public void testCreateAndUpdateUsingUpdateMethod() throws Exception {
Configuration cf = ca.createFactoryConfiguration("blueprint-sample-managed-service-factory4", null);
Hashtable<String, String> props = new Hashtable<String, String>();
props.put("a", "5");
cf.update(props);
Configuration cf2 = ca.createFactoryConfiguration("blueprint-sample-managed-service-factory4", null);
Hashtable<String, String> props2 = new Hashtable<String, String>();
props2.put("a", "7");
cf2.update(props2);
ServiceReference sr = getServiceRef(Foo.class, "(&(key=foo4)(a=5))");
ServiceReference sr2 = getServiceRef(Foo.class, "(&(key=foo4)(a=7))");
Foo foo = (Foo) context().getService(sr);
assertNotNull(foo);
assertEquals(5, foo.getA());
assertEquals("default", foo.getB());
assertEquals("5", sr.getProperty("a"));
assertNull(sr.getProperty("b"));
Foo foo2 = (Foo) context().getService(sr2);
assertNotNull(foo2);
assertEquals(7, foo2.getA());
assertEquals("default", foo2.getB());
assertEquals("7", sr2.getProperty("a"));
assertNull(sr2.getProperty("b"));
props = new Hashtable<String, String>();
props.put("a", "5");
props.put("b", "foo");
cf.update(props);
props2 = new Hashtable<String, String>();
props2.put("a", "7");
props2.put("b", "foo2");
cf2.update(props2);
// Update after creation
Thread.sleep(500);
assertEquals(5, foo.getA());
assertEquals("foo", foo.getB());
// Update of service properties
assertEquals("5", sr.getProperty("a"));
assertEquals("foo", sr.getProperty("b"));
// 2a Update after creation
assertEquals(7, foo2.getA());
assertEquals("foo2", foo2.getB());
// 2b Update of service properties
assertEquals("7", sr2.getProperty("a"));
assertEquals("foo2", sr2.getProperty("b"));
}
Aggregations