Search in sources :

Example 1 with FooProviderType1

use of org.apache.felix.ipojo.runtime.core.components.FooProviderType1 in project felix by apache.

the class TestExceptionHandling method testException.

/**
 * Check that the exception is correctly propagated.
 */
@Test
public void testException() {
    ServiceReference ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), ci_lazzy.getInstanceName());
    assertNotNull("Check that a FooService from " + ci_lazzy.getInstanceName() + " is available", ref);
    FooProviderType1 fs = (FooProviderType1) osgiHelper.getServiceObject(ref);
    try {
        fs.testException();
        fail("The method must returns an exception");
    } catch (Exception e) {
    // OK
    }
}
Also used : FooService(org.apache.felix.ipojo.runtime.core.services.FooService) FooProviderType1(org.apache.felix.ipojo.runtime.core.components.FooProviderType1) ServiceReference(org.osgi.framework.ServiceReference) Test(org.junit.Test) BaseTest(org.ow2.chameleon.testing.helpers.BaseTest)

Example 2 with FooProviderType1

use of org.apache.felix.ipojo.runtime.core.components.FooProviderType1 in project felix by apache.

the class TestPOJOCreation method testCustomConstuctor.

/**
 * Test a custom constructor.
 * Not manipulated.
 */
@Test
public void testCustomConstuctor() {
    FooService fs = new FooProviderType1(0, "foo", bc);
    Properties props = fs.fooProps();
    assertEquals("Check bar", 0, ((Integer) props.get("bar")).intValue());
    assertEquals("Check foo", "foo", props.get("foo"));
    assertEquals("Check context", bc, props.get("context"));
}
Also used : FooService(org.apache.felix.ipojo.runtime.core.services.FooService) Properties(java.util.Properties) FooProviderType1(org.apache.felix.ipojo.runtime.core.components.FooProviderType1) Test(org.junit.Test) BaseTest(org.ow2.chameleon.testing.helpers.BaseTest)

Example 3 with FooProviderType1

use of org.apache.felix.ipojo.runtime.core.components.FooProviderType1 in project felix by apache.

the class TestExceptionHandling method testTry.

/**
 * Check that the exception is correctly catch by the POJO.
 */
@Test
public void testTry() {
    ServiceReference ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), ci_lazzy.getInstanceName());
    assertNotNull("Check that a FooService from " + ci_lazzy.getInstanceName() + " is available", ref);
    FooProviderType1 fs = (FooProviderType1) osgiHelper.getServiceObject(ref);
    try {
        fs.testTry();
    } catch (Exception e) {
        fail("The method has returned an exception");
    }
}
Also used : FooService(org.apache.felix.ipojo.runtime.core.services.FooService) FooProviderType1(org.apache.felix.ipojo.runtime.core.components.FooProviderType1) ServiceReference(org.osgi.framework.ServiceReference) Test(org.junit.Test) BaseTest(org.ow2.chameleon.testing.helpers.BaseTest)

Aggregations

FooProviderType1 (org.apache.felix.ipojo.runtime.core.components.FooProviderType1)3 FooService (org.apache.felix.ipojo.runtime.core.services.FooService)3 Test (org.junit.Test)3 BaseTest (org.ow2.chameleon.testing.helpers.BaseTest)3 ServiceReference (org.osgi.framework.ServiceReference)2 Properties (java.util.Properties)1