use of org.grails.io.support.UrlResource in project grails-core by grails.
the class GrailsResourceUtilsTests method testGetTestNameResource.
public void testGetTestNameResource() throws Exception {
Resource r = new UrlResource(new URL(UNIT_TESTS_URL));
assertEquals("SomeTests", GrailsResourceUtils.getClassName(r));
}
use of org.grails.io.support.UrlResource in project grails-core by grails.
the class GrailsResourceUtilsTests method testGetPluginContextPath.
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()));
}
use of org.grails.io.support.UrlResource in project grails-core by grails.
the class GrailsResourceUtilsTests method testGetAppDir.
public void testGetAppDir() throws Exception {
Resource appDir = GrailsResourceUtils.getAppDir(new UrlResource(TEST_CONTROLLER_URL));
assertEquals(toFileUrl("/test/grails/app/grails-app"), appDir.getURL().toString());
appDir = GrailsResourceUtils.getAppDir(new UrlResource(TEST_URL));
assertEquals(toFileUrl("/test/grails/app/grails-app"), appDir.getURL().toString());
}
use of org.grails.io.support.UrlResource in project grails-core by grails.
the class GrailsResourceUtilsTests method testGetDirWithinWebInf.
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(toFileUrl("/test/grails/app/grails-app/views"), viewsDir.getURL().toString());
assertEquals(toFileUrl("/test/grails/app/plugins/myplugin/grails-app/views"), pluginViews.getURL().toString());
assertEquals(toFileUrl("/test/grails/app/WEB-INF/grails-app/views"), webInfViews.getURL().toString());
assertEquals(toFileUrl("/test/grails/app/WEB-INF/plugins/myplugin/grails-app/views"), webInfPluginViews.getURL().toString());
assertEquals("/WEB-INF/grails-app/views", GrailsResourceUtils.getRelativeInsideWebInf(webInfViews));
assertEquals("/WEB-INF/plugins/myplugin/grails-app/views", GrailsResourceUtils.getRelativeInsideWebInf(webInfPluginViews));
assertEquals("/WEB-INF/plugins/myplugin/grails-app/views", GrailsResourceUtils.getRelativeInsideWebInf(pluginViews));
assertEquals("/WEB-INF/grails-app/views", GrailsResourceUtils.getRelativeInsideWebInf(viewsDir));
}
use of org.grails.io.support.UrlResource in project grails-core by grails.
the class GrailsResourceUtilsTests method testGetViewsDirForURL.
public void testGetViewsDirForURL() throws Exception {
Resource viewsDir = GrailsResourceUtils.getViewsDir(new UrlResource(TEST_CONTROLLER_URL));
assertEquals(toFileUrl("/test/grails/app/grails-app/views"), viewsDir.getURL().toString());
viewsDir = GrailsResourceUtils.getViewsDir(new UrlResource(TEST_URL));
assertEquals(toFileUrl("/test/grails/app/grails-app/views"), viewsDir.getURL().toString());
}
Aggregations