Package org.apache.felix.ipojo.extender

Examples of org.apache.felix.ipojo.extender.DeclarationHandle


    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();

    }
View Full Code Here


        MockitoAnnotations.initMocks(this);
    }

    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());
View Full Code Here

    }

    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());
View Full Code Here

    }

    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());
View Full Code Here

    }


    public void testDeclarationIsNotAutomaticallyStarted() throws Exception {
        InstanceBuilder builder = new DefaultInstanceBuilder(m_bundleContext, "type");
        DeclarationHandle handle = builder.build();
        DefaultInstanceDeclaration did = (DefaultInstanceDeclaration) handle;

        assertFalse(did.isRegistered());
    }
View Full Code Here

        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));
    }
View Full Code Here

                any(Dictionary.class));
    }

    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));
    }
View Full Code Here

                any(Dictionary.class));
    }

    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));
    }
View Full Code Here

TOP

Related Classes of org.apache.felix.ipojo.extender.DeclarationHandle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.