use of org.apache.felix.ipojo.runtime.core.test.services.HelloService in project felix by apache.
the class TestDeclarationBuilderService method testConfiguredInstanceCreation.
@Test
public void testConfiguredInstanceCreation() {
handle = builder.newInstance("org.apache.felix.ipojo.runtime.core.test.components.FrenchHelloService").name("bonjour-service").configure().property("message", "Salut").build();
handle.publish();
assertTrue(ipojoHelper.isServiceAvailableByName(HelloService.class.getName(), "bonjour-service"));
HelloService service = osgiHelper.getServiceObject(HelloService.class, format("(instance.name=%s)", "bonjour-service"));
assertEquals(service.hello("Guillaume"), "Salut Guillaume");
}
use of org.apache.felix.ipojo.runtime.core.test.services.HelloService in project felix by apache.
the class TestDeclarationBuilderService method testAnonymousInstanceCreation.
@Test
public void testAnonymousInstanceCreation() {
handle = builder.newInstance("org.apache.felix.ipojo.runtime.core.test.components.FrenchHelloService").build();
// When a service is registered, all events are fired synchronously, we
// can safely test the declaration binding
assertFalse(handle.getStatus().isBound());
handle.publish();
// This test has been already ssen as failed.
HelloService hs = osgiHelper.waitForService(HelloService.class, "(factory.name=org.apache.felix.ipojo.runtime" + ".core.test.components.FrenchHelloService)", 1000);
assertNotNull(hs);
System.out.println("Status: " + handle.getStatus().isBound());
assertTrue(handle.getStatus().isBound());
handle.retract();
assertFalse(handle.getStatus().isBound());
}
use of org.apache.felix.ipojo.runtime.core.test.services.HelloService in project felix by apache.
the class TestDeclarationBuilderService method testTypeCreation.
@Test
public void testTypeCreation() throws Exception {
handle = builder.newType(germanComponent());
handle.publish();
DeclarationHandle instance = builder.newInstance("german-service").name("german-hello").build();
instance.publish();
System.out.println(instance.getStatus().getMessage());
String filter = format("(instance.name=%s)", "german-hello");
osgiHelper.waitForService(HelloService.class, filter, 1000);
HelloService service = osgiHelper.getServiceObject(HelloService.class, filter);
assertEquals(service.hello("Guillaume"), "Hallo Guillaume");
instance.retract();
}
use of org.apache.felix.ipojo.runtime.core.test.services.HelloService in project felix by apache.
the class TestDeclarationBuilderService method testVersionedTypeInstanceCreation.
@Test
public void testVersionedTypeInstanceCreation() {
handle = builder.newInstance("hello-service").version("2.0").name("hello2").build();
handle.publish();
String filter = format("(instance.name=%s)", "hello2");
osgiHelper.waitForService(HelloService.class, filter, 1000);
HelloService service = osgiHelper.getServiceObject(HelloService.class, filter);
assertEquals(service.hello("Guillaume"), "Hello2 Guillaume");
}
Aggregations