use of org.apache.sling.testing.mock.osgi.MockBundle in project sling by apache.
the class BundleMetricsMapperTest method mappedName_Header.
@Test
public void mappedName_Header() throws Exception {
MockBundle bundle = new MockBundle(context.bundleContext());
bundle.setSymbolicName("com.example");
bundle.setHeaders(ImmutableMap.of(BundleMetricsMapper.HEADER_DOMAIN_NAME, "com.test"));
mapper.addMapping("bar", bundle);
ObjectName name = mapper.createName("counter", "foo", "bar");
assertEquals("com.test", name.getDomain());
}
use of org.apache.sling.testing.mock.osgi.MockBundle in project sling by apache.
the class InternalMetricsServiceFactoryTest method cb.
private Bundle cb(String name) {
MockBundle bundle = new MockBundle(context.bundleContext());
bundle.setSymbolicName(name);
return bundle;
}
use of org.apache.sling.testing.mock.osgi.MockBundle in project sling by apache.
the class BundleContentLoaderTest method loadXmlAsIs.
@Test
@Ignore("TODO - unregister or somehow ignore the XmlReader component for this test")
public void loadXmlAsIs() throws Exception {
dumpRepo("/", 2);
Bundle mockBundle = newBundleWithInitialContent("SLING-INF/libs/app;path:=/libs/app;ignoreImportProviders:=xml");
contentLoader.registerBundle(context.resourceResolver().adaptTo(Session.class), mockBundle, false);
Resource imported = context.resourceResolver().getResource("/libs/app");
assertThat("Resource was not imported", imported, notNullValue());
assertThat("sling:resourceType was not properly set", imported.getResourceType(), equalTo("sling:Folder"));
Resource xmlFile = context.resourceResolver().getResource("/libs/app.xml");
dumpRepo("/", 2);
assertThat("XML file was was not imported", xmlFile, notNullValue());
}
use of org.apache.sling.testing.mock.osgi.MockBundle in project sling by apache.
the class ContentLoaderServiceTest method createNewBundle.
private Bundle createNewBundle() {
MockBundle b = new MockBundle(context.bundleContext());
b.setSymbolicName(uniqueId());
return b;
}
use of org.apache.sling.testing.mock.osgi.MockBundle in project sling by apache.
the class BundleContentLoaderTest method loadContentWithRootPath.
@Test
public void loadContentWithRootPath() throws Exception {
Bundle mockBundle = newBundleWithInitialContent("SLING-INF/");
contentLoader.registerBundle(context.resourceResolver().adaptTo(Session.class), mockBundle, false);
Resource imported = context.resourceResolver().getResource("/libs/app");
assertThat("Resource was not imported", imported, notNullValue());
assertThat("sling:resourceType was not properly set", imported.getResourceType(), equalTo("sling:Folder"));
}
Aggregations