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();
}
}
}
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");
}
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");
}
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;
}
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"));
}
Aggregations