use of org.apache.felix.ipojo.extender.InstanceBuilder in project felix by apache.
the class DefaultDeclarationBuilderServiceTestCase method testNewInstance.
public void testNewInstance() throws Exception {
DefaultDeclarationBuilderService service = new DefaultDeclarationBuilderService(m_bundleContext);
assertNotNull(service.newInstance("type.of.component"));
assertNotNull(service.newInstance("type.of.component", "instance.name"));
InstanceBuilder builder = service.newInstance("type.of.component", "instance.name", "component.version");
assertNotNull(builder);
DeclarationHandle instance = builder.build();
instance.publish();
verify(m_bundleContext).registerService(eq(InstanceDeclaration.class.getName()), anyObject(), any(Dictionary.class));
}
use of org.apache.felix.ipojo.extender.InstanceBuilder in project felix by apache.
the class DefaultInstanceBuilderTestCase method testDeclarationIsNotAutomaticallyStarted.
public void testDeclarationIsNotAutomaticallyStarted() throws Exception {
InstanceBuilder builder = new DefaultInstanceBuilder(m_bundleContext, "type");
DeclarationHandle handle = builder.build();
DefaultInstanceDeclaration did = (DefaultInstanceDeclaration) handle;
assertFalse(did.isRegistered());
}
use of org.apache.felix.ipojo.extender.InstanceBuilder in project felix by apache.
the class DefaultInstanceBuilderTestCase method testVersionConfiguration.
public void testVersionConfiguration() throws Exception {
InstanceBuilder builder = new DefaultInstanceBuilder(m_bundleContext, "type").name("John").version("1.0");
DeclarationHandle handle = builder.build();
InstanceDeclaration did = (InstanceDeclaration) handle;
assertEquals("type", did.getComponentName());
assertEquals("John", did.getInstanceName());
assertEquals("1.0", did.getComponentVersion());
Dictionary<String, Object> configuration = did.getConfiguration();
assertEquals("John", configuration.get(Factory.INSTANCE_NAME_PROPERTY));
assertEquals("1.0", configuration.get(Factory.FACTORY_VERSION_PROPERTY));
}
use of org.apache.felix.ipojo.extender.InstanceBuilder 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.InstanceBuilder in project felix by apache.
the class DefaultInstanceBuilderTestCase method testBuilderReUseProvidesDifferentInstances.
public void testBuilderReUseProvidesDifferentInstances() throws Exception {
InstanceBuilder builder = new DefaultInstanceBuilder(m_bundleContext, "type");
assertNotSame(builder.build(), builder.build());
}
Aggregations