Spring Framework AbstractXmlApplicationContext - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework AbstractXmlApplicationContext class.

This code example shows how to use the following methods:getBean, start, stop
        return new ClassPathXmlApplicationContext("org/apache/camel/spring/issues/SpringTwoCamelContextDirectEndpointTest.xml");
    } 
 
    public void testSpringTwoCamelContextDirectEndpoint() throws Exception {
        AbstractXmlApplicationContext ac = createApplicationContext();
        ac.start();
 
        CamelContext camel1 = ac.getBean("camel-1", CamelContext.class);
        CamelContext camel2 = ac.getBean("camel-2", CamelContext.class);
 
        Endpoint start1 = camel1.getEndpoint("direct:start");
        Endpoint start2 = camel2.getEndpoint("direct:start");
        assertNotSame(start1, start2);
        Endpoint foo1 = camel1.getEndpoint("direct:foo");
        Endpoint foo2 = camel2.getEndpoint("direct:foo");
        assertNotSame(foo1, foo2);
 
        MockEndpoint mock1 = camel1.getEndpoint("mock:a", MockEndpoint.class);
        mock1.expectedBodiesReceived("Hello World");
 

7
CodeRank
This code example shows how to use the following methods:getBean, start, stop
        return new ClassPathXmlApplicationContext("org/apache/camel/spring/config/RouteRefPropertyPlaceholderMultipleCamelContextRefsTest.xml");
    } 
 
    public void testSpringTwoCamelContextDirectEndpoint() throws Exception {
        AbstractXmlApplicationContext ac = createApplicationContext();
        ac.start();
 
        CamelContext camel1 = ac.getBean("myCamel-1", CamelContext.class);
        CamelContext camel2 = ac.getBean("myCamel-2", CamelContext.class);
 
        Endpoint start1 = camel1.getEndpoint("direct:start");
        Endpoint start2 = camel2.getEndpoint("direct:start");
        assertNotSame(start1, start2);
         
        MockEndpoint mock1 = camel1.getEndpoint("mock:end-1", MockEndpoint.class);
        mock1.expectedBodiesReceived("Hello World");
 
        MockEndpoint mock2 = camel2.getEndpoint("mock:end-2", MockEndpoint.class);
        mock2.expectedBodiesReceived("Bye World");
 

7
CodeRank
This code example shows how to use the following methods:getBean
 
public class SpringRemotingTwoCamelContextTest extends TestCase {
     
    public void testProxyWithTwoCamelContext() throws Exception {
        AbstractXmlApplicationContext applicationContext = createApplicationContext();
        CamelContext camelContext = SpringCamelContext.springCamelContext(applicationContext);
         
        ISay proxy = applicationContext.getBean("sayProxy1", ISay.class);
        String rc = proxy.say();
        assertEquals("context-1", rc);
         
        proxy = applicationContext.getBean("sayProxy2", ISay.class);
        rc = proxy.say();
        assertEquals("context-2", rc);
        
 
        camelContext.stop();
        IOHelper.close(applicationContext);
    } 
 

7
CodeRank
This code example shows how to use the following methods:getBean, start, stop
import org.springframework.context.support.ClassPathXmlApplicationContext;
 
public class SpringBrokerFactoryTest extends TestCase {
 
    public void testEmbeddedBroker() throws Exception {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/activemq-embedded-factory.xml");
        context.start();
 
        BrokerService broker = (BrokerService) context.getBean("broker");
        assertNotNull(broker);
 
        assertEquals("test", broker.getBrokerName());
 
        broker.stop();
        context.stop();
    } 
 
} 
7
CodeRank
This code example shows how to use the following methods:getBean, start, stop
        return new ClassPathXmlApplicationContext("org/apache/camel/spring/config/RouteRefMultipleCamelContextRefsTest.xml");
    } 
 
    public void testSpringTwoCamelContextDirectEndpoint() throws Exception {
        AbstractXmlApplicationContext ac = createApplicationContext();
        ac.start();
 
        CamelContext camel1 = ac.getBean("myCamel-1", CamelContext.class);
        CamelContext camel2 = ac.getBean("myCamel-2", CamelContext.class);
 
        Endpoint start1 = camel1.getEndpoint("direct:start");
        Endpoint start2 = camel2.getEndpoint("direct:start");
        assertNotSame(start1, start2);
         
        MockEndpoint mock1 = camel1.getEndpoint("mock:result", MockEndpoint.class);
        mock1.expectedBodiesReceived("Hello World");
 
        MockEndpoint mock2 = camel2.getEndpoint("mock:result", MockEndpoint.class);
        mock2.expectedBodiesReceived("Bye World");
 

7
CodeRank
This code example shows how to use the following methods:getBean
public class SpringRemotingBeanConverterTest extends TestCase {
     
    public void testBeanRoutes() throws Exception {
        AbstractXmlApplicationContext applicationContext = createApplicationContext();
 
        CamelContext camelContext = SpringCamelContext.springCamelContext(applicationContext);
         
        Invoker invoker = applicationContext.getBean("invokerProxy", Invoker.class);
        String response = invoker.invoke(new Bean.SubClass());
        assertEquals("Hello from Sub" , response);
 
        camelContext.stop();
        IOHelper.close(applicationContext);
    } 
 
    protected AbstractXmlApplicationContext createApplicationContext() {
        return new ClassPathXmlApplicationContext("org/apache/camel/spring/remoting/beanConverter.xml");
    } 
} 
7
CodeRank
This code example shows how to use the following methods:getBean
 */ 
public class SpringRemotingRouteTest extends TestCase {
     
    public void testBeanRoutes() throws Exception {
        AbstractXmlApplicationContext applicationContext = createApplicationContext();
        CamelContext camelContext = SpringCamelContext.springCamelContext(applicationContext);
 
        // START SNIPPET: invoke 
        ISay proxy = applicationContext.getBean("sayProxy", ISay.class);
        String rc = proxy.say();
        assertEquals("Hello", rc);
        // END SNIPPET: invoke 
 
        camelContext.stop();
        IOHelper.close(applicationContext);
    } 
 
    protected AbstractXmlApplicationContext createApplicationContext() {
        return new ClassPathXmlApplicationContext("org/apache/camel/spring/remoting/spring.xml");
    } 
7
CodeRank
This code example shows how to use the following methods:getBean, start, stop
        // Both times it retrieves back the cron expression, accessing it via trigger (so, using value stored in DB). 
        // After that it asserts that two cron expressions are not equal. 
 
        // load spring app 
        app = new ClassPathXmlApplicationContext("org/apache/camel/component/quartz/SpringQuartzPersistentStoreRestartAppChangeCronExpressionTest1.xml");
        app.start();
        CamelContext camel = app.getBean("camelContext", CamelContext.class);
        assertNotNull(camel);
        String cronExpression = ((CronTrigger) getTrigger(camel, "quartzRoute")).getCronExpression();
        app.stop();
 
        log.info("Restarting ..."); 
        log.info("Restarting ..."); 
        log.info("Restarting ..."); 
 
        // load spring app 
        app2 = new ClassPathXmlApplicationContext("org/apache/camel/component/quartz/SpringQuartzPersistentStoreRestartAppChangeCronExpressionTest2.xml");
        app2.start();
        CamelContext camel2 = app2.getBean("camelContext", CamelContext.class);
        assertNotNull(camel2);
6
CodeRank
This code example shows how to use the following methods:refresh, setConfigLocations
 */ 
public class JaggerXmlApplicationContext extends AbstractXmlApplicationContext {
    private final URL directory;
    private final Properties environmentProperties;
 
    public JaggerXmlApplicationContext(URL directory, Properties environmentProperties, String[] configLocations) {
        if (directory.toString().endsWith("/")) {
            this.directory = directory;
        } else { 
            try { 
                this.directory = new URL(directory, "/");
            } catch (MalformedURLException e) {
                throw new RuntimeException(e);
            } 
        } 
 
        this.environmentProperties = environmentProperties;
 
        setConfigLocations(configLocations);
        refresh();

6
CodeRank
This code example shows how to use the following methods:getBean, start, stop
        log.info("Restarting ..."); 
        log.info("Restarting ..."); 
 
        // load spring app 
        app2 = new ClassPathXmlApplicationContext("org/apache/camel/component/quartz2/SpringQuartzPersistentStoreRestartAppChangeCronExpressionTest2.xml");
        app2.start();
        CamelContext camel2 = app2.getBean("camelContext", CamelContext.class);
        assertNotNull(camel2);
        String cronExpression2 = ((CronTrigger) getTrigger(camel2, "quartzRoute")).getCronExpression();
        app2.stop();
 
        assertNotEquals(cronExpression, cronExpression2);
         
        // load spring app 
        app3 = new ClassPathXmlApplicationContext("org/apache/camel/component/quartz2/SpringQuartzPersistentStoreRestartAppChangeCronExpressionTest3.xml");
        app3.start();
        CamelContext camel3 = app3.getBean("camelContext3", CamelContext.class);
        assertNotNull(camel3);
        String cronExpression3 = ((CronTrigger) getTrigger(camel3, "quartzRoute")).getCronExpression();
        app3.stop();
6
CodeRank