Search in sources :

Example 1 with DeclarationHandle

use of org.apache.felix.ipojo.extender.DeclarationHandle in project felix by apache.

the class DefaultDeclarationBuilderServiceTestCase method testNewType.

public void testNewType() throws Exception {
    DefaultDeclarationBuilderService service = new DefaultDeclarationBuilderService(m_bundleContext);
    DeclarationHandle type = service.newType(new Element("component", null));
    assertNotNull(type);
    type.publish();
    verify(m_bundleContext).registerService(eq(TypeDeclaration.class.getName()), anyObject(), isNull(Dictionary.class));
}
Also used : Dictionary(java.util.Dictionary) Element(org.apache.felix.ipojo.metadata.Element) DeclarationHandle(org.apache.felix.ipojo.extender.DeclarationHandle)

Example 2 with DeclarationHandle

use of org.apache.felix.ipojo.extender.DeclarationHandle 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));
}
Also used : Dictionary(java.util.Dictionary) DeclarationHandle(org.apache.felix.ipojo.extender.DeclarationHandle) InstanceBuilder(org.apache.felix.ipojo.extender.InstanceBuilder)

Example 3 with DeclarationHandle

use of org.apache.felix.ipojo.extender.DeclarationHandle in project felix by apache.

the class DefaultDeclarationBuilderServiceTestCase method testNewExtension.

public void testNewExtension() throws Exception {
    DefaultDeclarationBuilderService service = new DefaultDeclarationBuilderService(m_bundleContext);
    DeclarationHandle extension = service.newExtension("test", m_factoryBuilder);
    assertNotNull(extension);
    extension.publish();
    verify(m_bundleContext).registerService(eq(ExtensionDeclaration.class.getName()), anyObject(), any(Dictionary.class));
}
Also used : Dictionary(java.util.Dictionary) DeclarationHandle(org.apache.felix.ipojo.extender.DeclarationHandle)

Example 4 with DeclarationHandle

use of org.apache.felix.ipojo.extender.DeclarationHandle 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());
}
Also used : DefaultInstanceDeclaration(org.apache.felix.ipojo.extender.internal.declaration.DefaultInstanceDeclaration) DeclarationHandle(org.apache.felix.ipojo.extender.DeclarationHandle) InstanceBuilder(org.apache.felix.ipojo.extender.InstanceBuilder)

Example 5 with DeclarationHandle

use of org.apache.felix.ipojo.extender.DeclarationHandle 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));
}
Also used : DefaultInstanceDeclaration(org.apache.felix.ipojo.extender.internal.declaration.DefaultInstanceDeclaration) InstanceDeclaration(org.apache.felix.ipojo.extender.InstanceDeclaration) DeclarationHandle(org.apache.felix.ipojo.extender.DeclarationHandle) InstanceBuilder(org.apache.felix.ipojo.extender.InstanceBuilder)

Aggregations

DeclarationHandle (org.apache.felix.ipojo.extender.DeclarationHandle)8 InstanceBuilder (org.apache.felix.ipojo.extender.InstanceBuilder)5 DefaultInstanceDeclaration (org.apache.felix.ipojo.extender.internal.declaration.DefaultInstanceDeclaration)4 Dictionary (java.util.Dictionary)3 InstanceDeclaration (org.apache.felix.ipojo.extender.InstanceDeclaration)3 Element (org.apache.felix.ipojo.metadata.Element)1 HelloService (org.apache.felix.ipojo.runtime.core.test.services.HelloService)1 Test (org.junit.Test)1