use of org.springframework.context.support.GenericXmlApplicationContext in project spring-integration-samples by spring-projects.
the class AggregatorDemoTest method testGatewayDemo.
@Test
public void testGatewayDemo() throws InterruptedException {
System.setProperty("spring.profiles.active", "testCase");
final GenericXmlApplicationContext applicationContext = new GenericXmlApplicationContext(configFilesGatewayDemo);
final MessageChannel stdinToJmsOutChannel = applicationContext.getBean("stdinToJmsOutChannel", MessageChannel.class);
stdinToJmsOutChannel.send(MessageBuilder.withPayload("jms test").build());
final QueueChannel queueChannel = applicationContext.getBean("queueChannel", QueueChannel.class);
@SuppressWarnings("unchecked") Message<List<String>> reply = (Message<List<String>>) queueChannel.receive(600000);
Assert.assertNotNull(reply);
List<String> out = reply.getPayload();
Assert.assertEquals("[JMS TEST, JMS TEST]", out.toString());
applicationContext.close();
}
use of org.springframework.context.support.GenericXmlApplicationContext in project spring-integration-samples by spring-projects.
the class Main method setupContext.
public static GenericXmlApplicationContext setupContext() {
final GenericXmlApplicationContext context = new GenericXmlApplicationContext();
if (System.getProperty(AVAILABLE_SERVER_SOCKET) == null) {
System.out.print("Detect open server socket...");
int availableServerSocket = SocketUtils.findAvailableTcpPort(5678);
final Map<String, Object> sockets = new HashMap<>();
sockets.put(AVAILABLE_SERVER_SOCKET, availableServerSocket);
final MapPropertySource propertySource = new MapPropertySource("sockets", sockets);
context.getEnvironment().getPropertySources().addLast(propertySource);
}
System.out.println("using port " + context.getEnvironment().getProperty(AVAILABLE_SERVER_SOCKET));
context.load("classpath:META-INF/spring/integration/tcpClientServerDemo-context.xml");
context.registerShutdownHook();
context.refresh();
return context;
}
use of org.springframework.context.support.GenericXmlApplicationContext in project spring-integration by spring-projects.
the class MessageIdGenerationTests method testCustomIdGenerationWithParentChildIndependentCreationChildrenRegistrarsOneAtTheTime.
// similar to the last test, but should not fail because child AC is closed before second child AC is started
@Test
public void testCustomIdGenerationWithParentChildIndependentCreationChildrenRegistrarsOneAtTheTime() throws Exception {
ClassPathXmlApplicationContext parent = new ClassPathXmlApplicationContext("MessageIdGenerationTests-context.xml", this.getClass());
GenericXmlApplicationContext childA = new GenericXmlApplicationContext();
childA.load("classpath:/org/springframework/integration/core/MessageIdGenerationTests-context-withGenerator.xml");
childA.setParent(parent);
childA.refresh();
childA.close();
GenericXmlApplicationContext childB = new GenericXmlApplicationContext();
childB.load("classpath:/org/springframework/integration/core/MessageIdGenerationTests-context-withGenerator.xml");
childB.setParent(parent);
childB.refresh();
parent.close();
childB.close();
this.assertDestroy();
}
use of org.springframework.context.support.GenericXmlApplicationContext in project spring-integration by spring-projects.
the class MBeanExporterIntegrationTests method testCircularReferenceNoChannel.
@Test
public void testCircularReferenceNoChannel() throws Exception {
context = new GenericXmlApplicationContext(getClass(), "oref-nonchannel.xml");
messageChannelsMonitor = context.getBean(IntegrationMBeanExporter.class);
assertNotNull(messageChannelsMonitor);
}
use of org.springframework.context.support.GenericXmlApplicationContext in project spring-integration by spring-projects.
the class MBeanExporterIntegrationTests method testCircularReferenceWithChannelInFactoryBeanAutodetected.
@Test
public void testCircularReferenceWithChannelInFactoryBeanAutodetected() throws Exception {
context = new GenericXmlApplicationContext(getClass(), "oref-factory-channel-autodetect.xml");
messageChannelsMonitor = context.getBean(IntegrationMBeanExporter.class);
assertNotNull(messageChannelsMonitor);
}
Aggregations