Search in sources :

Example 1 with GrailsApplicationAttributes

use of org.grails.web.util.GrailsApplicationAttributes in project grails-core by grails.

the class GrailsApplicationAttributesTests method testGetViewUri.

/*
     * Test method for 'org.grails.web.servlet.DefaultGrailsApplicationAttributes.getViewUri(String, ServletRequest)'
     */
public void testGetViewUri() throws Exception {
    GrailsApplicationAttributes attrs = new DefaultGrailsApplicationAttributes(new MockServletContext());
    GroovyClassLoader gcl = new GroovyClassLoader();
    Class<?> controllerClass = gcl.parseClass("class TestController {\n" + "def controllerUri = '/test'\n" + "def controllerName = 'test'\n" + "}");
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setAttribute(GrailsApplicationAttributes.CONTROLLER, controllerClass.newInstance());
    assertEquals("/WEB-INF/grails-app/views/test/aView.gsp", attrs.getViewUri("aView", request));
    assertEquals("/WEB-INF/grails-app/views/shared.gsp", attrs.getViewUri("/shared", request));
}
Also used : GrailsApplicationAttributes(org.grails.web.util.GrailsApplicationAttributes) GroovyClassLoader(groovy.lang.GroovyClassLoader) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) MockServletContext(org.springframework.mock.web.MockServletContext)

Example 2 with GrailsApplicationAttributes

use of org.grails.web.util.GrailsApplicationAttributes in project grails-core by grails.

the class GrailsApplicationAttributesTests method testGetTemplateUri.

/*
     * Test method for 'org.grails.web.servlet.DefaultGrailsApplicationAttributes.getTemplateUri(String, ServletRequest)'
     */
public void testGetTemplateUri() {
    GrailsApplicationAttributes attrs = new DefaultGrailsApplicationAttributes(new MockServletContext());
    assertEquals("/_test.gsp", attrs.getTemplateUri("/test", new MockHttpServletRequest()));
    assertEquals("/shared/_test.gsp", attrs.getTemplateUri("/shared/test", new MockHttpServletRequest()));
}
Also used : GrailsApplicationAttributes(org.grails.web.util.GrailsApplicationAttributes) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) MockServletContext(org.springframework.mock.web.MockServletContext)

Aggregations

GrailsApplicationAttributes (org.grails.web.util.GrailsApplicationAttributes)2 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)2 MockServletContext (org.springframework.mock.web.MockServletContext)2 GroovyClassLoader (groovy.lang.GroovyClassLoader)1