Search in sources :

Example 6 with MockBundle

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"));
}
Also used : MockBundle(org.apache.sling.testing.mock.osgi.MockBundle) Bundle(org.osgi.framework.Bundle) Resource(org.apache.sling.api.resource.Resource) Session(javax.jcr.Session) Test(org.junit.Test)

Example 7 with MockBundle

use of org.apache.sling.testing.mock.osgi.MockBundle in project sling by apache.

the class BundleContentLoaderTest method newBundleWithInitialContent.

private MockBundle newBundleWithInitialContent(String initialContentHeader) {
    MockBundle mockBundle = new MockBundle(context.bundleContext());
    mockBundle.setHeaders(singletonMap("Sling-Initial-Content", initialContentHeader));
    return mockBundle;
}
Also used : MockBundle(org.apache.sling.testing.mock.osgi.MockBundle)

Example 8 with MockBundle

use of org.apache.sling.testing.mock.osgi.MockBundle in project sling by apache.

the class BundleContentLoaderTest method loadContentWithSpecificPath.

@Test
public void loadContentWithSpecificPath() throws Exception {
    Bundle mockBundle = newBundleWithInitialContent("SLING-INF/libs/app;path:=/libs/app");
    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"));
}
Also used : MockBundle(org.apache.sling.testing.mock.osgi.MockBundle) Bundle(org.osgi.framework.Bundle) Resource(org.apache.sling.api.resource.Resource) Session(javax.jcr.Session) Test(org.junit.Test)

Aggregations

MockBundle (org.apache.sling.testing.mock.osgi.MockBundle)8 Test (org.junit.Test)5 Session (javax.jcr.Session)3 Resource (org.apache.sling.api.resource.Resource)3 Bundle (org.osgi.framework.Bundle)3 ObjectName (javax.management.ObjectName)2 Ignore (org.junit.Ignore)1