Examples of registerMockBean()


Examples of org.grails.support.MockApplicationContext.registerMockBean()

        assertEquals(src, output.htmlParts[0]);
    }

    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);
        Holders.setConfig(new PropertySourcesConfig().merge(config));
        appCtx.registerMockBean(GrailsApplication.APPLICATION_ID, grailsApplication);
View Full Code Here

Examples of org.grails.support.MockApplicationContext.registerMockBean()

        appCtx.registerMockBean(GroovyPagesUriService.BEAN_ID, new DefaultGroovyPagesUriService());

        DefaultGrailsApplication grailsApplication = new DefaultGrailsApplication();
        grailsApplication.setConfig(config);
        Holders.setConfig(new PropertySourcesConfig().merge(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);
    }
View Full Code Here

Examples of org.grails.support.MockApplicationContext.registerMockBean()

public class GrailsLayoutDecoratorMapperTests extends TestCase {

    private GrailsWebRequest buildMockRequest(grails.config.Config config) throws Exception {
        MockApplicationContext appCtx = new MockApplicationContext();
        appCtx.registerMockBean(GroovyPagesUriService.BEAN_ID, new DefaultGroovyPagesUriService());

        DefaultGrailsApplication grailsApplication = new DefaultGrailsApplication();
        grailsApplication.setConfig(config);
        Holders.setConfig(config);
        appCtx.registerMockBean(GrailsApplication.APPLICATION_ID, grailsApplication);
View Full Code Here

Examples of org.grails.support.MockApplicationContext.registerMockBean()

        appCtx.registerMockBean(GroovyPagesUriService.BEAN_ID, new DefaultGroovyPagesUriService());

        DefaultGrailsApplication grailsApplication = new DefaultGrailsApplication();
        grailsApplication.setConfig(config);
        Holders.setConfig(config);
        appCtx.registerMockBean(GrailsApplication.APPLICATION_ID, grailsApplication);
        GrailsConventionGroovyPageLocator pageLocator = new GrailsConventionGroovyPageLocator();
        pageLocator.setApplicationContext(appCtx);

        GroovyPagesTemplateEngine gpte = new GroovyPagesTemplateEngine();
        gpte.setServletContext(appCtx.getServletContext());
View Full Code Here

Examples of org.grails.support.MockApplicationContext.registerMockBean()

        layoutFinder.setViewResolver(grailsViewResolver);
        @SuppressWarnings("rawtypes")
        Map flat = config != null ?  config.flatten() : Collections.emptyMap();
        layoutFinder.setDefaultDecoratorName(flat.get("grails.sitemesh.default.layout") != null ? flat.get("grails.sitemesh.default.layout").toString(): "application");

        appCtx.registerMockBean("groovyPageLocator", pageLocator);
        appCtx.registerMockBean("groovyPageLayoutFinder", layoutFinder);
        DefaultCodecLookup codecLookup=new DefaultCodecLookup();
        codecLookup.setGrailsApplication(grailsApplication);
        codecLookup.afterPropertiesSet();
        appCtx.registerMockBean("codecLookup", codecLookup);
View Full Code Here

Examples of org.grails.support.MockApplicationContext.registerMockBean()

        @SuppressWarnings("rawtypes")
        Map flat = config != null ?  config.flatten() : Collections.emptyMap();
        layoutFinder.setDefaultDecoratorName(flat.get("grails.sitemesh.default.layout") != null ? flat.get("grails.sitemesh.default.layout").toString(): "application");

        appCtx.registerMockBean("groovyPageLocator", pageLocator);
        appCtx.registerMockBean("groovyPageLayoutFinder", layoutFinder);
        DefaultCodecLookup codecLookup=new DefaultCodecLookup();
        codecLookup.setGrailsApplication(grailsApplication);
        codecLookup.afterPropertiesSet();
        appCtx.registerMockBean("codecLookup", codecLookup);
        appCtx.getServletContext().setAttribute(GrailsApplicationAttributes.APPLICATION_CONTEXT, appCtx);
View Full Code Here

Examples of org.grails.support.MockApplicationContext.registerMockBean()

        appCtx.registerMockBean("groovyPageLocator", pageLocator);
        appCtx.registerMockBean("groovyPageLayoutFinder", layoutFinder);
        DefaultCodecLookup codecLookup=new DefaultCodecLookup();
        codecLookup.setGrailsApplication(grailsApplication);
        codecLookup.afterPropertiesSet();
        appCtx.registerMockBean("codecLookup", codecLookup);
        appCtx.getServletContext().setAttribute(GrailsApplicationAttributes.APPLICATION_CONTEXT, appCtx);
        appCtx.getServletContext().setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, appCtx);
        grailsApplication.setMainContext(appCtx);
        return GrailsWebMockUtil.bindMockWebRequest(appCtx, new MockHttpServletRequest(appCtx.getServletContext()) {
            @Override
View Full Code Here

Examples of org.grails.support.MockApplicationContext.registerMockBean()

        GroovyClassLoader gcl = new GroovyClassLoader();

        GrailsApplication app = new DefaultGrailsApplication(new Class[0], gcl);
        MockApplicationContext parent = new MockApplicationContext();
        parent.registerMockBean(GrailsApplication.APPLICATION_ID, app);

        GrailsRuntimeConfigurator conf = new GrailsRuntimeConfigurator(app,
                parent);
        DefaultGrailsPluginManager manager = new DefaultGrailsPluginManager(
                new Class[0], app);
View Full Code Here

Examples of org.grails.support.MockApplicationContext.registerMockBean()

        GrailsRuntimeConfigurator conf = new GrailsRuntimeConfigurator(app,
                parent);
        DefaultGrailsPluginManager manager = new DefaultGrailsPluginManager(
                new Class[0], app);
        manager.setParentApplicationContext(parent);
        parent.registerMockBean("manager", manager);
        conf.setPluginManager(manager);

        List pluginList = new ArrayList();

        addPlugin(gcl, app, pluginList, "OneGrailsPlugin", null);
View Full Code Here

Examples of org.grails.support.MockApplicationContext.registerMockBean()

        MockServletContext servletContext = new MockServletContext();
        servletContext.setAttribute(GrailsApplicationAttributes.APPLICATION_CONTEXT,context);

        GrailsApplication app = new DefaultGrailsApplication(classes,gcl);
        app.initialise();
        context.registerMockBean(GrailsApplication.APPLICATION_ID,app);

        GrailsClass[] controllers = app.getArtefacts(ControllerArtefactHandler.TYPE);
        for (int i = 0; i < controllers.length; i++) {
            context.registerMockBean(controllers[i].getFullName(), controllers[i].newInstance());
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.