Search in sources :

Example 76 with ClassPathXmlApplicationContext

use of org.springframework.context.support.ClassPathXmlApplicationContext in project Dempsy by Dempsy.

the class TestFullApp method testSeparateClustersInOneVm.

@Test
public void testSeparateClustersInOneVm() throws Throwable {
    // now start each cluster
    ctx[0] = "fullApp/Dempsy-FullUp.xml";
    Map<ClusterId, DempsyHolder> dempsys = new HashMap<ClusterId, DempsyHolder>();
    try {
        ApplicationDefinition ad = new FullApplication().getTopology();
        ad.initialize();
        List<ClusterDefinition> clusters = ad.getClusterDefinitions();
        for (int i = clusters.size() - 1; i >= 0; i--) {
            ClusterDefinition cluster = clusters.get(i);
            CheckCluster.toCheckAgainst = cluster.getClusterId();
            DempsyHolder cur = new DempsyHolder();
            cur.clusterid = cluster.getClusterId();
            cur.actx = new ClassPathXmlApplicationContext(ctx);
            cur.actx.registerShutdownHook();
            cur.dempsy = (Dempsy) cur.actx.getBean("dempsy");
            cur.dempsy.start();
            dempsys.put(cluster.getClusterId(), cur);
        }
        // get the last FullApplication in the processing chain.
        ClassPathXmlApplicationContext actx = dempsys.get(new ClusterId(FullApplication.class.getSimpleName(), MyRankMp.class.getSimpleName())).actx;
        final FullApplication app = (FullApplication) actx.getBean("app");
        // this checks that the throughput works.
        assertTrue(poll(baseTimeoutMillis * 5, app, new Condition<Object>() {

            @Override
            public boolean conditionMet(Object o) {
                return app.finalMessageCount.get() > 100;
            }
        }));
    } finally {
        ctx[0] = dempsyConfig;
        for (DempsyHolder cur : dempsys.values()) {
            cur.dempsy.stop();
            cur.actx.close();
        }
    }
}
Also used : Condition(com.nokia.dempsy.TestUtils.Condition) ClusterDefinition(com.nokia.dempsy.config.ClusterDefinition) HashMap(java.util.HashMap) ClusterId(com.nokia.dempsy.config.ClusterId) ApplicationDefinition(com.nokia.dempsy.config.ApplicationDefinition) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) MyRankMp(com.nokia.dempsy.cluster.zookeeper.FullApplication.MyRankMp) Test(org.junit.Test)

Example 77 with ClassPathXmlApplicationContext

use of org.springframework.context.support.ClassPathXmlApplicationContext in project Dempsy by Dempsy.

the class TestMpContainer method setUp.

@SuppressWarnings("unchecked")
public void setUp(String failFast) throws Exception {
    System.setProperty("failFast", failFast);
    context = new ClassPathXmlApplicationContext("TestMPContainer.xml");
    container = (MpContainer) context.getBean("container");
    assertNotNull(container.getSerializer());
    inputQueue = (BlockingQueue<Object>) context.getBean("inputQueue");
    outputQueue = (BlockingQueue<Object>) context.getBean("outputQueue");
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext)

Example 78 with ClassPathXmlApplicationContext

use of org.springframework.context.support.ClassPathXmlApplicationContext in project Dempsy by Dempsy.

the class BlockingQueueTest method setUp2.

public void setUp2(String applicationContextFilename) throws Exception {
    ctx = new ClassPathXmlApplicationContext(applicationContextFilename, getClass());
    ctx.registerShutdownHook();
    SenderFactory lsender = (SenderFactory) ctx.getBean("senderFactory");
    senderFactory = lsender;
    destinationFactory = (BlockingQueueAdaptor) ctx.getBean("adaptor");
    pojo = (MyPojo) ctx.getBean("testPojo");
    overflowHandler = (MyOverflowHandler) ctx.getBean("testOverflowHandler");
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) SenderFactory(com.nokia.dempsy.messagetransport.SenderFactory)

Example 79 with ClassPathXmlApplicationContext

use of org.springframework.context.support.ClassPathXmlApplicationContext in project Dempsy by Dempsy.

the class RunAppInVm method run.

public static ClassPathXmlApplicationContext run(boolean startUp) throws Throwable {
    //======================================================
    // Handle all of the options.
    String appCtxFilename = System.getProperty(appdefParam);
    if (appCtxFilename == null || appCtxFilename.length() == 0) {
        //         usage("the java vm option \"-D" + appdefParam + "\" wasn't specified.");
        String application = System.getProperty(applicationParam);
        if (application == null || application.length() == 0)
            usage("the java vm option \"-D" + appdefParam + "\" or the java vm option \"-D" + applicationParam + "\" wasn't specified.");
        appCtxFilename = "DempsyApplicationContext-" + application + ".xml";
    }
    //======================================================
    String contextFile = "classpath:Dempsy-localVm.xml";
    context = null;
    try {
        // Initialize Spring
        context = new ClassPathXmlApplicationContext(new String[] { appCtxFilename, contextFile });
        context.registerShutdownHook();
    } catch (Throwable e) {
        logger.error(MarkerFactory.getMarker("FATAL"), "Failed to start the application ", e);
        throw e;
    }
    if (context != null) {
        try {
            Dempsy dempsy = context.getBean(Dempsy.class);
            if (startUp) {
                dempsy.start();
                dempsy.waitToBeStopped();
            }
        } catch (InterruptedException e) {
            logger.error("Interrupted . . . ", e);
        } finally {
            if (startUp)
                context.stop();
        }
        logger.info("Shut down dempsy appliction " + appCtxFilename + ", bye!");
    }
    return context;
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) Dempsy(com.nokia.dempsy.Dempsy)

Example 80 with ClassPathXmlApplicationContext

use of org.springframework.context.support.ClassPathXmlApplicationContext in project RESTdoclet by IG-Group.

the class SampleControllerTest method setUp.

/**
    * Spring-wire the service implementation to be tested using the project
    * wiring file
    */
@Before
public void setUp() {
    ApplicationContext context = new ClassPathXmlApplicationContext(new String[] { "dispatcher-servlet.xml" });
    setService((SampleService) context.getBean("sampleService"));
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) Before(org.junit.Before)

Aggregations

ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)561 Test (org.junit.Test)265 ApplicationContext (org.springframework.context.ApplicationContext)167 Before (org.junit.Before)53 ConfigurableMessenger (org.springframework.scripting.ConfigurableMessenger)33 ITestBean (org.springframework.tests.sample.beans.ITestBean)30 Messenger (org.springframework.scripting.Messenger)29 CamelContext (org.apache.camel.CamelContext)25 Refreshable (org.springframework.aop.target.dynamic.Refreshable)23 AbstractXmlApplicationContext (org.springframework.context.support.AbstractXmlApplicationContext)22 DataSource (javax.sql.DataSource)18 SpringCamelContext (org.apache.camel.spring.SpringCamelContext)16 AbstractApplicationContext (org.springframework.context.support.AbstractApplicationContext)16 Bus (org.apache.cxf.Bus)14 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)14 ArrayList (java.util.ArrayList)13 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)12 DemoService (com.alibaba.dubbo.config.spring.api.DemoService)11 IOException (java.io.IOException)10 ProducerTemplate (org.apache.camel.ProducerTemplate)10