Package org.apache.sling.commons.testing.sling

Examples of org.apache.sling.commons.testing.sling.MockResource


    private static final String SCRIPT_BASE = LOCATION + "/" + LOCATION_NAME;

    public void testCreateLocationResourceGET() {

        final MockResource res0 = new MockResource(null, SCRIPT_BASE, "foo:bar");

        // this resource has no extension, we require one
        final WeightedResource lr0 = createLocationResource(res0, "GET", null,
            "html");
        assertNull(lr0);
View Full Code Here


        assertNull(lr1);
    }

    public void testCreateLocationResourceGETEsp() {

        final MockResource res1 = new MockResource(null, SCRIPT_BASE + ".esp",
            "foo:bar");

        // allow simple name for GET and html
        final WeightedResource lr10 = createLocationResource(res1, "GET", null,
            "html");
View Full Code Here

            "foo");
        assertNull(lr11);
    }

    public void testCreateLocationResourceGETHtmlEsp() {
        final MockResource res2 = new MockResource(null, SCRIPT_BASE
            + ".html.esp", "foo:bar");

        // allow simple name for GET and html
        final WeightedResource lr20 = createLocationResource(res2, "GET", null,
            "html");
View Full Code Here

            "foo");
        assertNull(lr21);
    }

    public void testCreateLocationResourceGETFooEsp() {
        final MockResource res3 = new MockResource(null, SCRIPT_BASE
            + ".foo.esp", "foo:bar");

        // script does not match for .html request
        final WeightedResource lr30 = createLocationResource(res3, "GET", null,
            "html");
View Full Code Here

        assertEquals(WeightedResource.WEIGHT_PREFIX+WeightedResource.WEIGHT_EXTENSION, lr31.getMethodPrefixWeight());
    }

    public void testCreateLocationResourceGETGET() {

        final MockResource res0 = new MockResource(null, SCRIPT_BASE + ".GET",
            "foo:bar");

        // side-effect: .GET is assumed to be the script extension
        final WeightedResource lr0 = createLocationResource(res0, "GET", null,
            "html");
View Full Code Here

            "foo");
        assertNull(lr1);
    }

    public void testCreateLocationResourceGETGETEsp() {
        final MockResource res1 = new MockResource(null, SCRIPT_BASE
            + ".GET.esp", "foo:bar");

        // GET would be the extension and is not allowed like this
        final WeightedResource lr10 = createLocationResource(res1, "GET", null,
            "html");
View Full Code Here

        assertFalse(rIter.hasNext());
    }

    protected MockResource createScriptResource(String path, String type) {
        MockResource res = new MockResource(resourceResolver, path, type);
        resourceResolver.addResource(res);
        return res;
    }
View Full Code Here

    protected void assertScript(String method, String selectors, String extension,
            String [] scripts, String expectedScript)
    {
        // Add given scripts to our mock resource resolver
        for(String script : scripts) {
            final MockResource r = new MockResource(resourceResolver, script, "nt:file");
            resourceResolver.addResource(r);           
        }
       
        // Create mock request and get scripts from ResourceCollector
        final MockSlingHttpServletRequest req = makeRequest(method, selectors, extension);
View Full Code Here

            + ".servlet";
        MockServletResource res = new MockServletResource(mockResourceResolver,
            servlet, path);
        mockResourceResolver.addResource(res);

        MockResource parent = new MockResource(mockResourceResolver,
            ResourceUtil.getParent(res.getPath()), "nt:folder");
        mockResourceResolver.addResource(parent);

        List<Resource> childRes = new ArrayList<Resource>();
        childRes.add(res);
View Full Code Here

        assertFalse(rIter.hasNext());
    }

    protected MockResource createScriptResource(String path, String type) {
        MockResource res = new MockResource(resourceResolver, path, type);
        resourceResolver.addResource(res);
        return res;
    }
View Full Code Here

TOP

Related Classes of org.apache.sling.commons.testing.sling.MockResource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.