use of org.grails.io.support.Resource 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.Resource 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.Resource 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.Resource 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());
}
use of org.grails.io.support.Resource in project grails-core by grails.
the class GrailsASTUtils method getSourceUrl.
/**
* Find URL of SourceUnit
*
* source.getSource().getURI() fails in Groovy-Eclipse compiler
*
* @param source
* @return URL of SourceUnit
*/
public static URL getSourceUrl(SourceUnit source) {
URL url = null;
final String filename = source.getName();
if (filename == null) {
return null;
}
Resource resource = new FileSystemResource(filename);
if (resource.exists()) {
try {
url = resource.getURL();
} catch (IOException e) {
// ignore
}
}
return url;
}
Aggregations