Package org.grails.spring

Examples of org.grails.spring.GrailsApplicationContext


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

        GrailsRuntimeConfigurator conf = new GrailsRuntimeConfigurator(app,parent);
        GrailsApplicationContext ctx = (GrailsApplicationContext)conf.configure(new MockServletContext());
        assertNotNull(ctx);

        ctx.registerSingleton("Test", dc);

        GroovyObject testInstance = getBean(ctx, "Test");
        assertNotNull(testInstance);

        // now test override bean
        gcl = new GroovyClassLoader();
        dc = gcl.parseClass("class Test { Long id; Long version;String updatedProp = 'hello'; }");
        ctx.registerSingleton("Test",dc);
        testInstance = getBean(ctx, "Test");
        assertNotNull(testInstance);
        assertEquals("hello",testInstance.getProperty("updatedProp"));
    }
View Full Code Here


        app.getMetadata().getConfigMap().put(Metadata.APPLICATION_NAME, getClass().getName());

        MockApplicationContext parent = new MockApplicationContext();
        parent.registerMockBean(GrailsApplication.APPLICATION_ID, app);
        GrailsRuntimeConfigurator conf = new GrailsRuntimeConfigurator(app, parent);
        GrailsApplicationContext ctx = (GrailsApplicationContext)conf.configure(new MockServletContext());

        WebRuntimeSpringConfiguration springConfig = conf.getWebRuntimeSpringConfiguration();
        GrailsRuntimeConfigurator.loadExternalSpringConfig(springConfig, app);

        springConfig.registerBeansWithContext(ctx);
        assertTrue(ctx.containsBean("foo"));
        assertTrue(ctx.containsBean("bar"));
//        assertTrue(ctx.containsBean("grapp"));
    }
View Full Code Here

TOP

Related Classes of org.grails.spring.GrailsApplicationContext

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.