use of org.apache.felix.ipojo.handler.temporal.services.CheckService in project felix by apache.
the class DelayTest method testTimeoutWithProxy.
@Test
public void testTimeoutWithProxy() {
String prov = "provider";
ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
String un = "under-1";
ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-ProxiedCheckServiceProvider", 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, 4000);
dp.start();
cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
try {
cs.check();
} catch (RuntimeException e) {
// OK
dp.stop();
provider.stop();
provider.dispose();
under.stop();
under.dispose();
return;
}
fail("Timeout expected");
}
use of org.apache.felix.ipojo.handler.temporal.services.CheckService in project felix by apache.
the class DelayTest method testTimeout.
@Test
public void testTimeout() {
String prov = "provider";
ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
String un = "under-1";
ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-CheckServiceProvider", 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, 4000);
dp.start();
cs = (CheckService) osgiHelper.getServiceObject(ref_cs);
try {
cs.check();
} catch (RuntimeException e) {
// OK
dp.stop();
provider.stop();
provider.dispose();
under.stop();
under.dispose();
return;
}
fail("Timeout expected");
}
use of org.apache.felix.ipojo.handler.temporal.services.CheckService in project felix by apache.
the class DelayTest method testDelayWithProxy.
@Test
public void testDelayWithProxy() {
String prov = "provider";
ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
String un = "under-1";
ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-ProxiedCheckServiceProvider", 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();
}
use of org.apache.felix.ipojo.handler.temporal.services.CheckService in project felix by apache.
the class DelayTest method testDelayTimeout.
@Test
public void testDelayTimeout() {
String prov = "provider";
ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
String un = "under-1";
ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-CheckServiceProviderTimeout", 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();
}
use of org.apache.felix.ipojo.handler.temporal.services.CheckService in project felix by apache.
the class EmptyTest method testEmptyProxiedCollectionTimeout.
@Test
public void testEmptyProxiedCollectionTimeout() {
String prov = "provider";
ComponentInstance provider = ipojoHelper.createComponentInstance("TEMPORAL-FooProvider", prov);
String un = "under-1";
ComponentInstance under = ipojoHelper.createComponentInstance("TEMPORAL-EmptyProxiedColCheckServiceProviderTimeout", 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("An empty array was expected ...");
}
assertTrue("Check empty array", res);
dp.stop();
provider.stop();
provider.dispose();
under.stop();
under.dispose();
return;
}
Aggregations