use of org.apache.felix.ipojo.extender.DeclarationHandle in project felix by apache.
the class DefaultInstanceBuilderTestCase method testNameConfiguration.
public void testNameConfiguration() throws Exception {
InstanceBuilder builder = new DefaultInstanceBuilder(m_bundleContext, "type").name("John");
DeclarationHandle handle = builder.build();
InstanceDeclaration did = (InstanceDeclaration) handle;
assertEquals("type", did.getComponentName());
assertEquals("John", did.getInstanceName());
assertNull(did.getComponentVersion());
Dictionary<String, Object> configuration = did.getConfiguration();
assertEquals("John", configuration.get(Factory.INSTANCE_NAME_PROPERTY));
}
use of org.apache.felix.ipojo.extender.DeclarationHandle 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.extender.DeclarationHandle in project felix by apache.
the class DefaultInstanceBuilderTestCase method testNoConfiguration.
public void testNoConfiguration() throws Exception {
InstanceBuilder builder = new DefaultInstanceBuilder(m_bundleContext, "type");
DeclarationHandle handle = builder.build();
InstanceDeclaration did = (InstanceDeclaration) handle;
assertEquals("type", did.getComponentName());
assertEquals(InstanceDeclaration.UNNAMED_INSTANCE, did.getInstanceName());
assertNull(did.getComponentVersion());
Dictionary<String, Object> configuration = did.getConfiguration();
assertTrue(configuration.isEmpty());
}
Aggregations