Search in sources :

Example 66 with PollableChannel

use of org.springframework.messaging.PollableChannel in project spring-integration by spring-projects.

the class SplitterParserTests method splitterImplementation.

@Test
public void splitterImplementation() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("splitterParserTests.xml", this.getClass());
    context.start();
    MessageChannel input = (MessageChannel) context.getBean("splitterImplementationInput");
    PollableChannel output = (PollableChannel) context.getBean("output");
    input.send(new GenericMessage<String>("this.is.a.test"));
    Message<?> result1 = output.receive(1000);
    assertEquals("this", result1.getPayload());
    Message<?> result2 = output.receive(1000);
    assertEquals("is", result2.getPayload());
    Message<?> result3 = output.receive(1000);
    assertEquals("a", result3.getPayload());
    Message<?> result4 = output.receive(1000);
    assertEquals("test", result4.getPayload());
    assertNull(output.receive(0));
    context.close();
}
Also used : MessageChannel(org.springframework.messaging.MessageChannel) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) PollableChannel(org.springframework.messaging.PollableChannel) Test(org.junit.Test)

Example 67 with PollableChannel

use of org.springframework.messaging.PollableChannel in project spring-integration by spring-projects.

the class JmsChannelHistoryTests method testFullConfig.

@Test
public void testFullConfig() throws Exception {
    ActiveMqTestUtils.prepare();
    ConfigurableApplicationContext ac = new ClassPathXmlApplicationContext("JmsChannelHistoryTests-context.xml", this.getClass());
    SubscribableChannel channel = ac.getBean("jmsChannel", SubscribableChannel.class);
    PollableChannel resultChannel = ac.getBean("resultChannel", PollableChannel.class);
    channel.send(new GenericMessage<String>("hello"));
    Message<?> resultMessage = resultChannel.receive(10000);
    MessageHistory history = MessageHistory.read(resultMessage);
    assertTrue(history.get(0).contains("jmsChannel"));
    ac.close();
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) MessageHistory(org.springframework.integration.history.MessageHistory) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) PollableChannel(org.springframework.messaging.PollableChannel) SubscribableChannel(org.springframework.messaging.SubscribableChannel) Test(org.junit.Test)

Example 68 with PollableChannel

use of org.springframework.messaging.PollableChannel in project spring-integration by spring-projects.

the class JmsInboundChannelAdapterParserTests method adapterWithConnectionFactoryAndDestination.

@Test
public void adapterWithConnectionFactoryAndDestination() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsInboundWithConnectionFactoryAndDestination.xml", this.getClass());
    PollableChannel output = (PollableChannel) context.getBean("output");
    Message<?> message = output.receive(timeoutOnReceive);
    assertNotNull("message should not be null", message);
    assertEquals("polling-test", message.getPayload());
    assertFalse(TestUtils.getPropertyValue(context.getBean("adapter"), "source.jmsTemplate", JmsTemplate.class).isSessionTransacted());
    context.close();
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) PollableChannel(org.springframework.messaging.PollableChannel) Test(org.junit.Test)

Example 69 with PollableChannel

use of org.springframework.messaging.PollableChannel in project spring-integration by spring-projects.

the class JmsInboundChannelAdapterParserTests method adapterWithConnectionFactoryAndDestinationName.

@Test
public void adapterWithConnectionFactoryAndDestinationName() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsInboundWithConnectionFactoryAndDestinationName.xml", this.getClass());
    PollableChannel output = (PollableChannel) context.getBean("output");
    Message<?> message = output.receive(timeoutOnReceive);
    assertNotNull("message should not be null", message);
    assertEquals("polling-test", message.getPayload());
    context.close();
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) PollableChannel(org.springframework.messaging.PollableChannel) Test(org.junit.Test)

Example 70 with PollableChannel

use of org.springframework.messaging.PollableChannel in project spring-integration by spring-projects.

the class JmsInboundChannelAdapterParserTests method adapterWithHeaderMapper.

@Test
public void adapterWithHeaderMapper() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsInboundWithHeaderMapper.xml", this.getClass());
    PollableChannel output = (PollableChannel) context.getBean("output");
    Message<?> message = output.receive(timeoutOnReceive);
    assertNotNull("message should not be null", message);
    assertEquals("polling-test", message.getPayload());
    assertEquals("foo", message.getHeaders().get("testProperty"));
    assertEquals(123, message.getHeaders().get("testAttribute"));
    context.close();
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) PollableChannel(org.springframework.messaging.PollableChannel) Test(org.junit.Test)

Aggregations

PollableChannel (org.springframework.messaging.PollableChannel)210 Test (org.junit.Test)190 MessageChannel (org.springframework.messaging.MessageChannel)89 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)82 QueueChannel (org.springframework.integration.channel.QueueChannel)52 GenericMessage (org.springframework.messaging.support.GenericMessage)52 Message (org.springframework.messaging.Message)40 BeanFactory (org.springframework.beans.factory.BeanFactory)25 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)20 EventDrivenConsumer (org.springframework.integration.endpoint.EventDrivenConsumer)19 MessagingException (org.springframework.messaging.MessagingException)16 SourcePollingChannelAdapter (org.springframework.integration.endpoint.SourcePollingChannelAdapter)13 MessagingTemplate (org.springframework.integration.core.MessagingTemplate)12 ErrorMessage (org.springframework.messaging.support.ErrorMessage)12 Document (org.w3c.dom.Document)12 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)11 Matchers.containsString (org.hamcrest.Matchers.containsString)11 Date (java.util.Date)10 ArrayList (java.util.ArrayList)9 MessageHistory (org.springframework.integration.history.MessageHistory)9