private GrailsWebRequest buildMockRequest() throws Exception {
   MockApplicationContext appCtx = new MockApplicationContext();
   appCtx.registerMockBean(GroovyPagesUriService.BEAN_ID, new DefaultGroovyPagesUriService());
   appCtx
       .getServletContext()
       .setAttribute(GrailsApplicationAttributes.APPLICATION_CONTEXT, appCtx);
   appCtx
       .getServletContext()
       .setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, appCtx);
   return GrailsWebUtil.bindMockWebRequest(appCtx);
 }
Esempio n. 2
0
 /**
  * Bootstraps Grails with the given GrailsApplication instance.
  *
  * @param application The GrailsApplication instance
  * @return A Grails ApplicationContext
  */
 public static ApplicationContext bootstrapGrailsFromApplication(GrailsApplication application) {
   MockApplicationContext parent = new MockApplicationContext();
   parent.registerMockBean(GrailsApplication.APPLICATION_ID, application);
   return createGrailsApplicationContext(parent, application);
 }