Search in sources :

Example 1 with ContentLoader

use of org.apache.sling.testing.mock.sling.loader.ContentLoader in project sling by apache.

the class AbstractSlingContextImplTest method setUp.

@Before
public void setUp() throws Exception {
    // make sure ResourceResolverFactory is available immediately and not lazily
    assertEquals(1, context.getServices(ResourceResolverFactory.class, null).length);
    context.addModelsForPackage("org.apache.sling.testing.mock.sling.context.models");
    ContentLoader contentLoader = this.context.load();
    contentLoader.json("/json-import-samples/content.json", "/content/sample/en");
}
Also used : ContentLoader(org.apache.sling.testing.mock.sling.loader.ContentLoader) Before(org.junit.Before)

Example 2 with ContentLoader

use of org.apache.sling.testing.mock.sling.loader.ContentLoader in project sling by apache.

the class AbstractJcrNamespaceTest method testSling4362.

@Test
public void testSling4362() throws RepositoryException {
    BundleContext bundleContext = MockOsgi.newBundleContext();
    ResourceResolver resolver = MockSling.newResourceResolver(getResourceResolverType(), bundleContext);
    ContentLoader contentLoader = new ContentLoader(resolver);
    contentLoader.json("/json-import-samples/SLING-4362.json", context.uniqueRoot().content() + "/foo");
    Resource resource = resolver.getResource(context.uniqueRoot().content() + "/foo");
    ValueMap props = ResourceUtil.getValueMap(resource);
    assertEquals("fooType", props.get("sling:resourceType"));
    assertEquals("fooType", resource.getResourceType());
    MockOsgi.shutdown(bundleContext);
}
Also used : ContentLoader(org.apache.sling.testing.mock.sling.loader.ContentLoader) ValueMap(org.apache.sling.api.resource.ValueMap) ResourceResolver(org.apache.sling.api.resource.ResourceResolver) Resource(org.apache.sling.api.resource.Resource) BundleContext(org.osgi.framework.BundleContext) Test(org.junit.Test)

Example 3 with ContentLoader

use of org.apache.sling.testing.mock.sling.loader.ContentLoader in project sling by apache.

the class AbstractJcrNamespaceTest method testSling4362_ViaContextRule.

@Test
public void testSling4362_ViaContextRule() throws RepositoryException {
    ResourceResolver resolver = context.resourceResolver();
    ContentLoader contentLoader = new ContentLoader(resolver);
    contentLoader.json("/json-import-samples/SLING-4362.json", context.uniqueRoot().content() + "/foo");
    Resource resource = resolver.getResource(context.uniqueRoot().content() + "/foo");
    ValueMap props = ResourceUtil.getValueMap(resource);
    assertEquals("fooType", props.get("sling:resourceType"));
    assertEquals("fooType", resource.getResourceType());
}
Also used : ContentLoader(org.apache.sling.testing.mock.sling.loader.ContentLoader) ValueMap(org.apache.sling.api.resource.ValueMap) ResourceResolver(org.apache.sling.api.resource.ResourceResolver) Resource(org.apache.sling.api.resource.Resource) Test(org.junit.Test)

Aggregations

ContentLoader (org.apache.sling.testing.mock.sling.loader.ContentLoader)3 Resource (org.apache.sling.api.resource.Resource)2 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)2 ValueMap (org.apache.sling.api.resource.ValueMap)2 Test (org.junit.Test)2 Before (org.junit.Before)1 BundleContext (org.osgi.framework.BundleContext)1