@Test public void testItfsExposition() { ServiceReference refFoo = ipojoHelper.getServiceReferenceByName( FooService.class.getName(), fooBarProvider.getInstanceName()); assertNotNull( "Check the availability of the FS from " + fooBarProvider.getInstanceName(), refFoo); ServiceReference refBar = ipojoHelper.getServiceReferenceByName( BarService.class.getName(), fooBarProvider.getInstanceName()); assertNotNull( "Check the availability of the BS from " + fooBarProvider.getInstanceName(), refBar); assertSame("Check service reference equality", refFoo, refBar); FooService fs = (FooService) osgiHelper.getServiceObject(refFoo); assertTrue("Check fs invocation", fs.foo()); fs = null; BarService bs = (BarService) osgiHelper.getServiceObject(refBar); assertTrue("Check bs invocation", bs.bar()); bs = null; fooBarProvider.stop(); refFoo = ipojoHelper.getServiceReferenceByName( FooService.class.getName(), fooBarProvider.getInstanceName()); refBar = ipojoHelper.getServiceReferenceByName( BarService.class.getName(), fooBarProvider.getInstanceName()); assertNull("Check the absence of the FS from " + fooBarProvider.getInstanceName(), refFoo); assertNull("Check the absence of the BS from " + fooBarProvider.getInstanceName(), refBar); }
@Test public void testItfExposition() { ServiceReference ref = ipojoHelper.getServiceReferenceByName( FooService.class.getName(), fooProviderItf.getInstanceName()); assertNotNull("Check the availability of the FS from " + fooProviderItf.getInstanceName(), ref); FooService fs = (FooService) osgiHelper.getServiceObject(ref); assertTrue("Check fs invocation", fs.foo()); fs = null; fooProviderItf.stop(); ref = ipojoHelper.getServiceReferenceByName( FooService.class.getName(), fooProviderItf.getInstanceName()); assertNull("Check the absence of the FS from " + fooProviderItf.getInstanceName(), ref); }
@Test public void testConfiguration() throws IOException { if (isKnopflerfish()) { return; // Test disabled on KF } TimeUtils.grace(500); osgiHelper.waitForService(FooService.class, null, 10000); // Check configuration FooService fs = osgiHelper.getServiceObject(FooService.class); Assert.assertTrue(fs.foo()); Assert.assertEquals(fs.getDouble(), 1.0, 0); Assert.assertEquals(fs.getInt(), 1); Assert.assertEquals(fs.getLong(), 1l); }
@Test public void testItfsExposition3() { ServiceReference refFoo = ipojoHelper.getServiceReferenceByName( FooService.class.getName(), fooBarProvider3.getInstanceName()); assertNotNull( "Check the availability of the FS from " + fooBarProvider3.getInstanceName(), refFoo); ServiceReference refBar = ipojoHelper.getServiceReferenceByName( BarService.class.getName(), fooBarProvider3.getInstanceName()); assertNotNull( "Check the availability of the BS from " + fooBarProvider3.getInstanceName(), refBar); assertNotSame("Check service reference inequality", refFoo, refBar); FooService fs = (FooService) osgiHelper.getServiceObject(refFoo); assertTrue("Check fs invocation", fs.foo()); fs = null; BarService bs = (BarService) osgiHelper.getServiceObject(refBar); assertTrue("Check bs invocation", bs.bar()); bs = null; // Check properties String baz1 = (String) refFoo.getProperty("baz"); String baz2 = (String) refBar.getProperty("baz"); assertEquals("Check Baz Property 1", baz1, "foo"); assertEquals("Check Baz Property 2", baz2, "bar"); fooBarProvider3.stop(); refFoo = ipojoHelper.getServiceReferenceByName( FooService.class.getName(), fooBarProvider3.getInstanceName()); refBar = ipojoHelper.getServiceReferenceByName( BarService.class.getName(), fooBarProvider3.getInstanceName()); assertNull("Check the absence of the FS from " + fooBarProvider.getInstanceName(), refFoo); assertNull("Check the absence of the BS from " + fooBarProvider.getInstanceName(), refBar); }