Package grails.web.util

Examples of grails.web.util.GrailsApplicationAttributes


                        }
                        url = URL_PREFIX + urlPrefix + fileName;
                    }
                    else {
                        url = gspFile;
                        GrailsApplicationAttributes attrs = null;
                        try {
                            attrs = grailsApplicationAttributesConstructor.newInstance(servletContext);
                        }
                        catch (Exception e) {
                            ReflectionUtils.rethrowRuntimeException(e);
                        }
                        ResourceAwareTemplateEngine engine = attrs.getPagesTemplateEngine();
                        lineNumber = engine.mapStackLineNumber(url, lineNumber);
                    }
                    fileLocation = "grails-app" + urlPrefix + fileName;
                }
View Full Code Here


    /*
     * 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()));
    }
View Full Code Here

    /*
     * 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 "+ControllerDynamicMethods.CONTROLLER_URI_PROPERTY+" = '/test'\n" +
                "def "+ControllerDynamicMethods.CONTROLLER_NAME_PROPERTY+" = '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));
    }
View Full Code Here

                         "class SecondTagLib {\n" +
                             "Closure secondTag = {\n" +
                         "}\n" +
                "}");

        GrailsApplicationAttributes attrs = getAttributesForClasses(gcl.getLoadedClasses(),gcl);
        assertNotNull(attrs);
        assertNotNull(attrs.getApplicationContext());
        assertNotNull(attrs.getGrailsApplication());

        MockHttpServletRequest request = new MockHttpServletRequest();
        MockHttpServletResponse response = new MockHttpServletResponse();
        GroovyObject controller = (GroovyObject)attrs.getApplicationContext().getBean("TestController");
        request.setAttribute(GrailsApplicationAttributes.CONTROLLER, controller);
        GroovyObject tagLib1 = attrs.getTagLibraryForTag(request,response,"firstTag");
        assertNotNull(tagLib1);
    }
View Full Code Here

TOP

Related Classes of grails.web.util.GrailsApplicationAttributes

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.