Search in sources :

Example 11 with GenericXmlApplicationContext

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();
}
Also used : MessageChannel(org.springframework.messaging.MessageChannel) QueueChannel(org.springframework.integration.channel.QueueChannel) Message(org.springframework.messaging.Message) List(java.util.List) GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext) Test(org.junit.Test)

Example 12 with GenericXmlApplicationContext

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;
}
Also used : HashMap(java.util.HashMap) MapPropertySource(org.springframework.core.env.MapPropertySource) GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext)

Example 13 with GenericXmlApplicationContext

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();
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext) Test(org.junit.Test)

Example 14 with GenericXmlApplicationContext

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);
}
Also used : GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext) Test(org.junit.Test)

Example 15 with GenericXmlApplicationContext

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);
}
Also used : GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext) Test(org.junit.Test)

Aggregations

GenericXmlApplicationContext (org.springframework.context.support.GenericXmlApplicationContext)61 Test (org.junit.Test)21 Test (org.junit.jupiter.api.Test)13 MBeanServer (javax.management.MBeanServer)5 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)5 Scanner (java.util.Scanner)4 ObjectName (javax.management.ObjectName)4 Resource (org.springframework.core.io.Resource)4 QueueChannel (org.springframework.integration.channel.QueueChannel)4 MessageChannel (org.springframework.messaging.MessageChannel)4 ApplicationContext (org.springframework.context.ApplicationContext)3 ByteArrayResource (org.springframework.core.io.ByteArrayResource)3 Message (org.springframework.messaging.Message)3 MBeanOperationInfo (javax.management.MBeanOperationInfo)2 Server (org.eclipse.jetty.server.Server)2 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)2 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)2 BatchStatus (org.springframework.batch.core.BatchStatus)2 BeanDefinitionParsingException (org.springframework.beans.factory.parsing.BeanDefinitionParsingException)2 CacheInterceptor (org.springframework.cache.interceptor.CacheInterceptor)2