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
}
}
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"));
}
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");
}
}
Aggregations