Search in sources :

Example 11 with MockResourceResolver

use of org.apache.sling.commons.testing.sling.MockResourceResolver 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 12 with MockResourceResolver

use of org.apache.sling.commons.testing.sling.MockResourceResolver 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)

Example 13 with MockResourceResolver

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

the class RedirectServletTest method testEmptyPath.

public void testEmptyPath() {
    MockSlingHttpServletRequest request = new MockSlingHttpServletRequest("/", null, null, null, null, "", TEST_SCHEME, TEST_HOST, TEST_PORT, "/webapp");
    request.setResourceResolver(new MockResourceResolver());
    String path = RedirectServlet.toRedirectPath("/index.html", request);
    assertEqualsUri("/webapp/index.html", path, false);
    request = new MockSlingHttpServletRequest("/", null, null, null, null, "/", TEST_SCHEME, TEST_HOST, TEST_PORT, "/webapp");
    request.setResourceResolver(new MockResourceResolver());
    path = RedirectServlet.toRedirectPath("/index.html", request);
    assertEqualsUri("/webapp/index.html", path, false);
}
Also used : MockSlingHttpServletRequest(org.apache.sling.commons.testing.sling.MockSlingHttpServletRequest) MockResourceResolver(org.apache.sling.commons.testing.sling.MockResourceResolver)

Aggregations

MockResourceResolver (org.apache.sling.commons.testing.sling.MockResourceResolver)13 MockResource (org.apache.sling.commons.testing.sling.MockResource)8 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)7 ArrayList (java.util.ArrayList)6 Resource (org.apache.sling.api.resource.Resource)6 Before (org.junit.Before)6 Map (java.util.Map)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 Calendar (java.util.Calendar)3 HashMap (java.util.HashMap)3 HttpServletResponse (javax.servlet.http.HttpServletResponse)3 Part (javax.servlet.http.Part)3 SlingHttpServletRequest (org.apache.sling.api.SlingHttpServletRequest)3 ModifiableValueMap (org.apache.sling.api.resource.ModifiableValueMap)3 PersistenceException (org.apache.sling.api.resource.PersistenceException)3 ValueMap (org.apache.sling.api.resource.ValueMap)3 AbstractPostResponse (org.apache.sling.servlets.post.AbstractPostResponse)3 Modification (org.apache.sling.servlets.post.Modification)3