use of org.apache.felix.ipojo.ComponentInstance in project felix by apache.
the class NoDelayTest method testMultipleNoDelay.
@Test
public void testMultipleNoDelay() {
String prov1 = "provider-1";
ComponentInstance provider1 = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov1);
String un = "under-2";
ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-MultipleCheckServiceProvider", un);
ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov1);
assertNotNull("Check foo availability", ref_fs);
ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
assertNotNull("Check cs availability", ref_cs);
CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
assertTrue("Check invocation", cs.check());
provider1.stop();
provider1.dispose();
under.stop();
under.dispose();
}
use of org.apache.felix.ipojo.ComponentInstance in project felix by apache.
the class NoDelayTest method testProxiedCollectionNoDelay.
@Test
public void testProxiedCollectionNoDelay() {
String prov1 = "provider-1";
ComponentInstance provider1 = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov1);
String un = "under-2";
ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-ProxiedColCheckServiceProvider", un);
ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov1);
assertNotNull("Check foo availability", ref_fs);
ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
assertNotNull("Check cs availability", ref_cs);
CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
assertTrue("Check invocation", cs.check());
provider1.stop();
provider1.dispose();
under.stop();
under.dispose();
}
use of org.apache.felix.ipojo.ComponentInstance in project felix by apache.
the class NullTest method testNullCollectionTimeout.
@Test
public void testNullCollectionTimeout() {
String prov = "provider";
ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
String un = "under-1";
ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-NullColCheckServiceProviderTimeout", un);
ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
assertNotNull("Check foo availability", ref_fs);
ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
assertNotNull("Check cs availability", ref_cs);
CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
assertTrue("Check invocation", cs.check());
// Stop the provider.
provider.stop();
ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
assertNotNull("Check cs availability - 2", ref_cs);
DelayedProvider dp = new DelayedProvider(provider, 400);
dp.start();
cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
boolean res = false;
try {
res = cs.check();
} catch (RuntimeException e) {
fail("A null was expected ...");
}
assertTrue("Check nullable", res);
dp.stop();
provider.stop();
provider.dispose();
under.stop();
under.dispose();
return;
}
use of org.apache.felix.ipojo.ComponentInstance in project felix by apache.
the class NullTest method testNullMultipleTimeout.
@Test
public void testNullMultipleTimeout() {
String prov = "provider";
ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
String un = "under-1";
ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-NullMultipleCheckServiceProviderTimeout", un);
ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
assertNotNull("Check foo availability", ref_fs);
ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
assertNotNull("Check cs availability", ref_cs);
CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
assertTrue("Check invocation", cs.check());
// Stop the provider.
provider.stop();
ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
assertNotNull("Check cs availability - 2", ref_cs);
DelayedProvider dp = new DelayedProvider(provider, 400);
dp.start();
cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
boolean res = false;
try {
res = cs.check();
} catch (RuntimeException e) {
fail("A null was expected ...");
}
assertTrue("Check nullable", res);
dp.stop();
provider.stop();
provider.dispose();
under.stop();
under.dispose();
return;
}
use of org.apache.felix.ipojo.ComponentInstance in project felix by apache.
the class NullTest method testNullWithProxy.
@Test
public void testNullWithProxy() {
String prov = "provider";
ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
String un = "under-1";
ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-NullProxiedCheckServiceProvider", un);
ServiceReference ref_fs = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), prov);
assertNotNull("Check foo availability", ref_fs);
ServiceReference ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
assertNotNull("Check cs availability", ref_cs);
CheckService cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
assertTrue("Check invocation", cs.check());
// Stop the provider.
provider.stop();
ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
assertNotNull("Check cs availability - 2", ref_cs);
long begin = System.currentTimeMillis();
DelayedProvider dp = new DelayedProvider(provider, 200);
dp.start();
cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
assertTrue("Check invocation - 2", cs.check());
long end = System.currentTimeMillis();
assertTrue("Assert delay", (end - begin) >= 200);
ref_cs = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), un);
assertNotNull("Check cs availability - 3", ref_cs);
cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
assertTrue("Check invocation - 3", cs.check());
provider.stop();
provider.dispose();
under.stop();
under.dispose();
}
Aggregations