Package org.grails.io.support

Examples of org.grails.io.support.UrlResource


    public boolean isArtefact(ClassNode classNode) {
        int modifiers = classNode.getModifiers();
        URI uri = classNode.getModule().getContext().getSource().getURI();
        if(uri == null) return false;
        try {
            UrlResource resource = new UrlResource(uri);
            if(!isArtefactResource(resource)) return false;
        } catch (IOException e) {
            return false;
        }
View Full Code Here


        assertEquals("mycompany/Test.groovy", GrailsResourceUtils.getPathFromRoot(TEST_PACKAGE_URL));
        assertEquals("Test.groovy", GrailsResourceUtils.getPathFromRoot(TEST_URL));
    }

    public void testGetClassNameResource() throws Exception {
        Resource r = new UrlResource(new URL(TEST_URL));
        assertEquals("Test", GrailsResourceUtils.getClassName(r));
    }
View Full Code Here

    public void testIsTestPath() {
        assertTrue(GrailsResourceUtils.isGrailsPath(UNIT_TESTS_URL));
    }

    public void testGetTestNameResource() throws Exception {
        Resource r = new UrlResource(new URL(UNIT_TESTS_URL));
        assertEquals("SomeTests", GrailsResourceUtils.getClassName(r));
    }
View Full Code Here

    public void testGetTestNameString() {
        assertEquals("SomeTests", GrailsResourceUtils.getClassName(UNIT_TESTS_URL));
    }

    public void testGetViewsDirForURL() throws Exception {
        Resource viewsDir = GrailsResourceUtils.getViewsDir(new UrlResource(TEST_CONTROLLER_URL));
        assertEquals("file:/test/grails/app/grails-app/views", viewsDir.getURL().toString());

        viewsDir = GrailsResourceUtils.getViewsDir(new UrlResource(TEST_URL));
        assertEquals("file:/test/grails/app/grails-app/views", viewsDir.getURL().toString());
    }
View Full Code Here

        viewsDir = GrailsResourceUtils.getViewsDir(new UrlResource(TEST_URL));
        assertEquals("file:/test/grails/app/grails-app/views", viewsDir.getURL().toString());
    }

    public void testGetAppDir() throws Exception {
        Resource appDir = GrailsResourceUtils.getAppDir(new UrlResource(TEST_CONTROLLER_URL));
        assertEquals("file:/test/grails/app/grails-app", appDir.getURL().toString());

        appDir = GrailsResourceUtils.getAppDir(new UrlResource(TEST_URL));
        assertEquals("file:/test/grails/app/grails-app", appDir.getURL().toString());
    }
View Full Code Here

        appDir = GrailsResourceUtils.getAppDir(new UrlResource(TEST_URL));
        assertEquals("file:/test/grails/app/grails-app", appDir.getURL().toString());
    }

    public void testGetDirWithinWebInf() throws Exception {
        Resource viewsDir = GrailsResourceUtils.getViewsDir(new UrlResource(TEST_CONTROLLER_URL));
        Resource pluginViews = GrailsResourceUtils.getViewsDir(new UrlResource(TEST_PLUGIN_CTRL));

        Resource webInfViews = GrailsResourceUtils.getViewsDir(new UrlResource(WEBINF_CONTROLLER));
        Resource webInfPluginViews = GrailsResourceUtils.getViewsDir(new UrlResource(WEBINF_PLUGIN_CTRL));

        assertEquals("file:/test/grails/app/grails-app/views", viewsDir.getURL().toString());
        assertEquals("file:/test/grails/app/plugins/myplugin/grails-app/views",
                pluginViews.getURL().toString());
        assertEquals("file:/test/grails/app/WEB-INF/grails-app/views",
View Full Code Here

    public void testGetPluginContextPath() throws Exception {
        MockServletContext servletContext = new MockServletContext("/myapp");
        MockHttpServletRequest request = new MockHttpServletRequest(servletContext);
        request.setContextPath("/myapp");

        assertEquals("", GrailsResourceUtils.getStaticResourcePathForResource(new UrlResource(TEST_CONTROLLER_URL), null));
        assertEquals("plugins/myplugin", GrailsResourceUtils.getStaticResourcePathForResource(
                new UrlResource(TEST_PLUGIN_CTRL), null));
        assertEquals("", GrailsResourceUtils.getStaticResourcePathForResource(new UrlResource(WEBINF_CONTROLLER), null));
        assertEquals("plugins/myplugin", GrailsResourceUtils.getStaticResourcePathForResource(
                new UrlResource(WEBINF_PLUGIN_CTRL), null));
        assertEquals("/myapp", GrailsResourceUtils.getStaticResourcePathForResource(
                new UrlResource(WEBINF_CONTROLLER), request.getContextPath()));
        assertEquals("/myapp/plugins/myplugin", GrailsResourceUtils.getStaticResourcePathForResource(
                new UrlResource(WEBINF_PLUGIN_CTRL), request.getContextPath()));
    }
View Full Code Here

TOP

Related Classes of org.grails.io.support.UrlResource

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.