Package org.springframework.context.support

Examples of org.springframework.context.support.AbstractApplicationContext


        expect(bundleContext.registerService(aryEq(new String[] { KeystoreInstance.class.getName() }),
                                             anyObject(), EasyMock.<Dictionary>anyObject())).andReturn(reg);

        replay(bundleContext, bundle);

        AbstractApplicationContext ctx = new ClassPathXmlApplicationContext(new String[] { "classpath:config.xml" }, false) {
            protected DefaultListableBeanFactory createBeanFactory() {
                DefaultListableBeanFactory f = super.createBeanFactory();
                f.addBeanPostProcessor(new BundleContextAwareProcessor(bundleContext));
                return f;
            }
        };
        ctx.refresh();

        verify(bundleContext, bundle);

        // Test realm
        Object obj = ctx.getBean("realm");
        assertNotNull(obj);
        assertTrue(obj instanceof Config);
        Config cfg = (Config) obj;
        assertNotNull(cfg.getBundleContext());
        assertEquals("realm", cfg.getName());
        assertNotNull(cfg.getModules());
        assertEquals(1, cfg.getModules().length);
        assertNotNull(cfg.getModules()[0]);
        assertEquals("org.apache.servicemix.kernel.jaas.config.SimpleLoginModule", cfg.getModules()[0].getClassName());
        assertEquals("required", cfg.getModules()[0].getFlags());
        assertNotNull(cfg.getModules()[0].getOptions());
        assertEquals(1, cfg.getModules()[0].getOptions().size());
        assertEquals("value", cfg.getModules()[0].getOptions().get("key"));
        AppConfigurationEntry[] entries = cfg.getEntries();
        assertNotNull(entries);
        assertEquals(1, entries.length);
        assertNotNull(entries[0]);
        assertEquals(ProxyLoginModule.class.getName(), entries[0].getLoginModuleName());
        assertEquals(AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, entries[0].getControlFlag());
        Map<String,?> options = entries[0].getOptions();
        assertNotNull(options);
        assertEquals(3, options.size());
        assertEquals("value", options.get("key"));
        assertEquals("org.apache.servicemix.kernel.jaas.config.SimpleLoginModule", options.get(ProxyLoginModule.PROPERTY_MODULE));
        assertEquals("32", options.get(ProxyLoginModule.PROPERTY_BUNDLE));

        // Test keystore
        obj = ctx.getBean("keystore");
        assertNotNull(obj);
        assertTrue(obj instanceof KeystoreInstance);
        KeystoreInstance ks = (KeystoreInstance) obj;
        assertEquals("ks", ks.getName());
        assertEquals(1, ks.getRank());
View Full Code Here


public class LoanBrokerServerTest extends Assert {
   
    @Test
    public void startLoanBroker() throws Exception {
        AbstractApplicationContext applicationContext =
            new ClassPathXmlApplicationContext(new String[]{"/META-INF/spring/queueCamelContext.xml"});
        CamelContext camelContext = (CamelContext)applicationContext.getBean("camelContext");
        assertNotNull("The camel context should not be null", camelContext);
        Thread.sleep(2000);       
        camelContext.stop();
        applicationContext.stop();       
    }
View Full Code Here

    }
   
    void configure(Object beanInstance) {
        // check the ApplicationContext states first , and call the refresh if necessary
        if (applicationContext instanceof AbstractApplicationContext) {
            AbstractApplicationContext context = (AbstractApplicationContext) applicationContext;
            if (!context.isActive()) {
                context.refresh();
            }
        }
        configurer.configureBean(beanId, beanInstance);
    }
View Full Code Here

* @version
*/
public class CamelProxyUsingRefTest extends TestCase {

    public void testCamelProxyUsingRef() throws Exception {
        AbstractApplicationContext ac = new ClassPathXmlApplicationContext("org/apache/camel/spring/config/CamelProxyUsingRefTest.xml");

        MyProxySender sender = ac.getBean("myProxySender", MyProxySender.class);
        String reply = sender.hello("World");

        assertEquals("Hello World", reply);

        // we're done so let's properly close the application context
View Full Code Here

* @version
*/
public class RouteBuilderRefTest extends XmlConfigTestSupport {

    public void testUsingRouteBuilderRefInCamelXml() throws Exception {
        AbstractApplicationContext applicationContext = new ClassPathXmlApplicationContext("org/apache/camel/spring/config/routeBuilderRef.xml");

        CamelContext context = applicationContext.getBean("camel5", CamelContext.class);
        assertValidContext(context);

        // we're done so let's properly close the application context
        IOHelper.close(applicationContext);
    }
View Full Code Here

public class DefaultStreamCachingTest extends TestCase {
   
   
    public void testStreamCaching() throws Exception {
        AbstractApplicationContext appContext = new ClassPathXmlApplicationContext(new String[] {"org/apache/camel/spring/streamCaching.xml"});
        CamelContext camelContext = appContext.getBean("camelContext", CamelContext.class);
        assertFalse("StreamCaching should not be enabled", camelContext.isStreamCaching());

        // we're done so let's properly close the application context
        IOHelper.close(appContext);
    }
View Full Code Here

*/
public class AnotherCamelProxyTest extends TestCase {

    public void testAnotherCamelProxy() throws Exception {
        // START SNIPPET: e1
        AbstractApplicationContext ac = new ClassPathXmlApplicationContext("org/apache/camel/spring/config/AnotherCamelProxyTest.xml");

        MyProxySender sender = ac.getBean("myProxySender", MyProxySender.class);
        String reply = sender.hello("Camel");

        assertEquals("Bye Camel", reply);

        // we're done so let's properly close the application context
View Full Code Here

* @version
*/
public class CamelProxyTest extends TestSupport {

    public void testCamelProxy() throws Exception {
        AbstractApplicationContext ac = new ClassPathXmlApplicationContext("org/apache/camel/spring/config/CamelProxyTest.xml");

        MyProxySender sender = ac.getBean("myProxySender", MyProxySender.class);
        String reply = sender.hello("World");

        assertEquals("Hello World", reply);
       
        // test sending inOnly message
        MyProxySender anotherSender = ac.getBean("myAnotherProxySender", MyProxySender.class);
        SpringCamelContext context = ac.getBeansOfType(SpringCamelContext.class).values().iterator().next();
        MockEndpoint result = resolveMandatoryEndpoint(context, "mock:result", MockEndpoint.class);
        result.expectedBodiesReceived("Hello my friends!");
       
        anotherSender.greeting("Hello my friends!");
        result.assertIsSatisfied();
       
        result.reset();
        // test sending inOnly message with other sender
        MyProxySender myProxySenderWithCamelContextId = ac.getBean("myProxySenderWithCamelContextId", MyProxySender.class);
       
        result.expectedBodiesReceived("Hello my friends again!");
        myProxySenderWithCamelContextId.greeting("Hello my friends again!");
        result.assertIsSatisfied();

View Full Code Here

    public Component build(CompositeComponent parent,
                           ComponentDefinition<SpringImplementation> componentDefinition,
                           DeploymentContext deploymentContext) throws BuilderConfigException {
        String name = componentDefinition.getName();
        SpringImplementation implementation = componentDefinition.getImplementation();
        AbstractApplicationContext applicationContext = implementation.getComponentType().getApplicationContext();
        SpringCompositeComponent component =
            new SpringCompositeComponent(name, applicationContext, parent, connector, null);
        CompositeComponentType<BoundServiceDefinition<? extends Binding>,
            BoundReferenceDefinition<? extends Binding>,
            ? extends Property> componentType = implementation.getComponentType();
View Full Code Here

* @version $Rev: 476842 $ $Date: 2006-11-19 08:03:50 -0800 (Sun, 19 Nov 2006) $
*/
public class SpringCompositeComponentTestCase extends TestCase {

    public void testAppContextStart() {
        AbstractApplicationContext appContext = EasyMock.createMock(AbstractApplicationContext.class);
        appContext.refresh();
        appContext.setParent(EasyMock.isA(ApplicationContext.class));
        appContext.start();
        replay(appContext);
        SpringCompositeComponent component = new SpringCompositeComponent("spring", appContext, null, null, null);
        component.start();
        verify(appContext);
    }
View Full Code Here

TOP

Related Classes of org.springframework.context.support.AbstractApplicationContext

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.