Search in sources :

Example 11 with MockApplicationContext

use of org.grails.support.MockApplicationContext in project grails-core by grails.

the class ParseTests method buildMockRequest.

private GrailsWebRequest buildMockRequest(ConfigObject config) throws Exception {
    MockApplicationContext appCtx = new MockApplicationContext();
    appCtx.registerMockBean(GroovyPagesUriService.BEAN_ID, new DefaultGroovyPagesUriService());
    DefaultGrailsApplication grailsApplication = new DefaultGrailsApplication();
    grailsApplication.setConfig(config);
    appCtx.registerMockBean(GrailsApplication.APPLICATION_ID, grailsApplication);
    appCtx.getServletContext().setAttribute(GrailsApplicationAttributes.APPLICATION_CONTEXT, appCtx);
    appCtx.getServletContext().setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, appCtx);
    return GrailsWebMockUtil.bindMockWebRequest(appCtx);
}
Also used : DefaultGrailsApplication(grails.core.DefaultGrailsApplication) MockApplicationContext(org.grails.support.MockApplicationContext)

Aggregations

MockApplicationContext (org.grails.support.MockApplicationContext)11 PropertySourcesConfig (org.grails.config.PropertySourcesConfig)8 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)8 Decorator (com.opensymphony.module.sitemesh.Decorator)7 Page (com.opensymphony.module.sitemesh.Page)7 HTMLPageParser (com.opensymphony.module.sitemesh.parser.HTMLPageParser)7 Config (grails.config.Config)7 ServletContext (javax.servlet.ServletContext)7 GrailsWebRequest (org.grails.web.servlet.mvc.GrailsWebRequest)7 MockServletConfig (org.springframework.mock.web.MockServletConfig)7 GroovyClassLoader (groovy.lang.GroovyClassLoader)5 GroovyObject (groovy.lang.GroovyObject)5 DefaultGrailsApplication (grails.core.DefaultGrailsApplication)4 ConfigObject (groovy.util.ConfigObject)2 ConfigSlurper (groovy.util.ConfigSlurper)2 GrailsApplication (grails.core.GrailsApplication)1 GrailsClass (grails.core.GrailsClass)1 Map (java.util.Map)1 RequestDispatcher (javax.servlet.RequestDispatcher)1 GroovyPagesTemplateEngine (org.grails.gsp.GroovyPagesTemplateEngine)1