use of org.ops4j.pax.web.resources.extender.internal.IndexedOsgiResourceLocator in project org.ops4j.pax.web by ops4j.
the class IndexedOsgiResourceLocaterTests method setUp.
@Before
public void setUp() throws Exception {
context = mock(BundleContext.class);
resourceBundleOne = new BundleBuilder().withBundleId(100).withSymbolicName("resourcebundle-one").buildWithResources("template.html", "base.css");
resourceBundleTwo = new BundleBuilder().withBundleId(100).withSymbolicName("resourcebundle-two").buildWithResources("footer.html", "js/some.js", "folder/subfolder/a.js", "folder/subfolder/b.js", "folder/bla/a.js", "en/libraryname/test.css/2_4.css");
sut = new IndexedOsgiResourceLocator(context);
sut.register(resourceBundleOne);
sut.register(resourceBundleTwo);
}
use of org.ops4j.pax.web.resources.extender.internal.IndexedOsgiResourceLocator in project org.ops4j.pax.web by ops4j.
the class AbstractWarJsfResourcehandlerIntegrationTest method testServiceOverride.
/**
* The default implementation {@link IndexedOsgiResourceLocator} is
* registered with {@link Constants#SERVICE_RANKING} of -1, so when
* registering a new implementation, this new class must be served.
*/
@Test
public void testServiceOverride() throws Exception {
OsgiResourceLocatorForTest expectedService = new OsgiResourceLocatorForTest();
bundleContext.registerService(OsgiResourceLocator.class, new OsgiResourceLocatorForTest(), null);
ServiceReference<OsgiResourceLocator> ref = bundleContext.getServiceReference(OsgiResourceLocator.class);
if (ref != null) {
OsgiResourceLocator service = bundleContext.getService(ref);
if (service != null) {
assertThat("'OsgiResourceLocatorForTest' must be found due to higher service-ranking!", service.getClass().getName(), serviceName -> expectedService.getClass().getName().equals(serviceName));
} else {
fail("Service could not be retrieved");
}
} else {
fail("Service-Reference could not be retrieved");
}
}
Aggregations