Search in sources :

Example 11 with MockResource

use of org.apache.sling.commons.testing.sling.MockResource in project sling by apache.

the class TestFindResourceTag method init.

/**
	 * Initializes the fields for this test.
	 */
@SuppressWarnings("serial")
@Before
public void init() {
    log.info("init");
    final MockResourceResolver resolver = new MockResourceResolver() {

        @Override
        public Iterator<Resource> findResources(String query, String language) {
            if (query.equals("query") && language.equals("language")) {
                List<Resource> resources = new ArrayList<Resource>();
                resources.add(resource);
                return resources.iterator();
            } else {
                return null;
            }
        }
    };
    resource = new MockResource(resolver, TEST_PATH, "test");
    resolver.addResource(resource);
    getResourceTag = new FindResourcesTag() {

        protected ResourceResolver getResourceResolver() {
            return resolver;
        }
    };
    pageContext = new MockPageContext();
    getResourceTag.setPageContext(pageContext);
    log.info("init Complete");
}
Also used : MockResource(org.apache.sling.commons.testing.sling.MockResource) Resource(org.apache.sling.api.resource.Resource) MockResource(org.apache.sling.commons.testing.sling.MockResource) ArrayList(java.util.ArrayList) ResourceResolver(org.apache.sling.api.resource.ResourceResolver) MockResourceResolver(org.apache.sling.commons.testing.sling.MockResourceResolver) MockResourceResolver(org.apache.sling.commons.testing.sling.MockResourceResolver) Before(org.junit.Before)

Example 12 with MockResource

use of org.apache.sling.commons.testing.sling.MockResource in project sling by apache.

the class TestListChildrenTag method init.

/**
	 * Initializes the fields for this test.
	 */
@Before
public void init() {
    log.info("init");
    log.info("Creating Resource Structure");
    final MockResourceResolver resolver = new MockResourceResolver();
    resource = new MockResource(resolver, TEST_PATH, "test");
    resolver.addResource(resource);
    MockResource child1 = new MockResource(resolver, TEST_PATH + "/child1", "test");
    resolver.addResource(child1);
    MockResource child2 = new MockResource(resolver, TEST_PATH + "/child2", "test");
    resolver.addResource(child2);
    log.info("Adding page context");
    pageContext = new MockPageContext();
    listChildrenTag.setPageContext(pageContext);
    log.info("init Complete");
}
Also used : MockResource(org.apache.sling.commons.testing.sling.MockResource) MockResourceResolver(org.apache.sling.commons.testing.sling.MockResourceResolver) Before(org.junit.Before)

Example 13 with MockResource

use of org.apache.sling.commons.testing.sling.MockResource in project sling by apache.

the class JsonRendererServletTest method setup.

@org.junit.BeforeClass
public static void setup() {
    resolver = new MockResourceResolver();
    resolver.addResource(new MockResource(resolver, "/content/page", "page"));
    resolver.addResource(new MockResource(resolver, "/content/page/one", "one"));
    resolver.addResource(new MockResource(resolver, "/content/page/two", "two"));
    resolver.addResource(new MockResource(resolver, "/etc", "etc"));
    resolver.addResource(new MockResource(resolver, "/etc/tags", "tags"));
    for (int i = 0; i < 1085; i++) {
        resolver.addResource(new MockResource(resolver, "/etc/tags/" + i, "" + i));
    }
}
Also used : MockResource(org.apache.sling.commons.testing.sling.MockResource) MockResourceResolver(org.apache.sling.commons.testing.sling.MockResourceResolver)

Aggregations

MockResource (org.apache.sling.commons.testing.sling.MockResource)13 MockResourceResolver (org.apache.sling.commons.testing.sling.MockResourceResolver)8 Resource (org.apache.sling.api.resource.Resource)6 Before (org.junit.Before)6 ArrayList (java.util.ArrayList)4 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)4 MockSlingHttpServletRequest (org.apache.sling.commons.testing.sling.MockSlingHttpServletRequest)2 InputStream (java.io.InputStream)1 Annotation (java.lang.annotation.Annotation)1 Field (java.lang.reflect.Field)1 Date (java.util.Date)1 Dictionary (java.util.Dictionary)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 LoginException (org.apache.sling.api.resource.LoginException)1 ResourceResolverFactory (org.apache.sling.api.resource.ResourceResolverFactory)1 MockBundle (org.apache.sling.commons.testing.osgi.MockBundle)1 MockBundleContext (org.apache.sling.commons.testing.osgi.MockBundleContext)1 MockServiceReference (org.apache.sling.commons.testing.osgi.MockServiceReference)1