Search in sources :

Example 11 with PrimitiveComponentType

use of org.apache.felix.ipojo.api.PrimitiveComponentType in project felix by apache.

the class PrimitiveComponentTest method killTheFactory.

@Test
public void killTheFactory() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
    assertThat(context, is(notNullValue()));
    ComponentInstance ci = null;
    PrimitiveComponentType type = createAProvider();
    ci = type.createInstance();
    assertThat("Ci is valid", ci.getState(), is(ComponentInstance.VALID));
    assertThat(ipojoHelper.isServiceAvailableByName(Foo.class.getName(), ci.getInstanceName()), is(true));
    type.stop();
    assertThat("Ci is disposed", ci.getState(), is(ComponentInstance.DISPOSED));
    assertThat(ipojoHelper.isServiceAvailableByName(Foo.class.getName(), ci.getInstanceName()), is(false));
}
Also used : PrimitiveComponentType(org.apache.felix.ipojo.api.PrimitiveComponentType) Test(org.junit.Test)

Example 12 with PrimitiveComponentType

use of org.apache.felix.ipojo.api.PrimitiveComponentType in project felix by apache.

the class PrimitiveComponentTest method notManipulatedComponent.

@Test
public void notManipulatedComponent() throws Exception {
    assertThat(context, is(notNullValue()));
    ComponentInstance ci;
    PrimitiveComponentType x = new PrimitiveComponentType().setBundleContext(context).setClassName(PlainHelloImpl.class.getName()).setValidateMethod("start").setInvalidateMethod("stop");
    x.start();
    assertThat(x, is(notNullValue()));
    assertThat(x.getFactory().getState(), is(Factory.VALID));
    ci = x.createInstance();
    ci.start();
    assertThat(ci.getState(), is(ComponentInstance.VALID));
    x.stop();
}
Also used : PlainHelloImpl(org.apache.felix.ipojo.runtime.core.api.components.PlainHelloImpl) PrimitiveComponentType(org.apache.felix.ipojo.api.PrimitiveComponentType) Test(org.junit.Test)

Aggregations

PrimitiveComponentType (org.apache.felix.ipojo.api.PrimitiveComponentType)12 Test (org.junit.Test)12 Foo (org.apache.felix.ipojo.runtime.core.api.services.Foo)6 ServiceReference (org.osgi.framework.ServiceReference)3 ComponentInstance (org.apache.felix.ipojo.ComponentInstance)2 HandlerDescription (org.apache.felix.ipojo.architecture.HandlerDescription)2 PlainHelloImpl (org.apache.felix.ipojo.runtime.core.api.components.PlainHelloImpl)1