Search in sources :

Example 6 with MessagingTemplate

use of org.springframework.integration.core.MessagingTemplate in project spring-integration by spring-projects.

the class HeaderEnricherTests method innerBean.

@Test
public void innerBean() {
    MessagingTemplate template = new MessagingTemplate();
    MessageChannel channel = context.getBean("innerBean", MessageChannel.class);
    Message<?> result = template.sendAndReceive(channel, new GenericMessage<String>("test"));
    assertNotNull(result);
    assertEquals(TestBean.class, result.getHeaders().get("testHeader").getClass());
    TestBean testBeanForInnerBean = new TestBean("testBeanForInnerBean");
    assertEquals(testBeanForInnerBean, result.getHeaders().get("testHeader"));
}
Also used : MessagingTemplate(org.springframework.integration.core.MessagingTemplate) MessageChannel(org.springframework.messaging.MessageChannel) Test(org.junit.Test)

Example 7 with MessagingTemplate

use of org.springframework.integration.core.MessagingTemplate in project spring-integration by spring-projects.

the class HeaderEnricherTests method expirationDateRef.

@Test
public void expirationDateRef() {
    MessagingTemplate template = new MessagingTemplate();
    MessageChannel channel = context.getBean("expirationDateRefInput", MessageChannel.class);
    Message<?> result = template.sendAndReceive(channel, new GenericMessage<String>("test"));
    assertNotNull(result);
    assertEquals(new Long(9999), new IntegrationMessageHeaderAccessor(result).getExpirationDate());
}
Also used : MessagingTemplate(org.springframework.integration.core.MessagingTemplate) IntegrationMessageHeaderAccessor(org.springframework.integration.IntegrationMessageHeaderAccessor) MessageChannel(org.springframework.messaging.MessageChannel) Test(org.junit.Test)

Example 8 with MessagingTemplate

use of org.springframework.integration.core.MessagingTemplate in project spring-integration by spring-projects.

the class HeaderEnricherTests method expressionWithDateType.

@Test
public void expressionWithDateType() {
    MessagingTemplate template = new MessagingTemplate();
    MessageChannel channel = context.getBean("expressionWithDateTypeInput", MessageChannel.class);
    Message<?> result = template.sendAndReceive(channel, new GenericMessage<String>("test"));
    assertNotNull(result);
    Object headerValue = result.getHeaders().get("currentDate");
    assertEquals(Date.class, headerValue.getClass());
    Date date = (Date) headerValue;
    assertTrue(new Date().getTime() - date.getTime() < 1000);
}
Also used : MessagingTemplate(org.springframework.integration.core.MessagingTemplate) MessageChannel(org.springframework.messaging.MessageChannel) Date(java.util.Date) Test(org.junit.Test)

Example 9 with MessagingTemplate

use of org.springframework.integration.core.MessagingTemplate in project spring-integration by spring-projects.

the class HeaderEnricherTests method expirationDateValue.

@Test
public void expirationDateValue() {
    MessagingTemplate template = new MessagingTemplate();
    MessageChannel channel = context.getBean("expirationDateValueInput", MessageChannel.class);
    Message<?> result = template.sendAndReceive(channel, new GenericMessage<String>("test"));
    assertNotNull(result);
    assertEquals(new Long(1111), new IntegrationMessageHeaderAccessor(result).getExpirationDate());
}
Also used : MessagingTemplate(org.springframework.integration.core.MessagingTemplate) IntegrationMessageHeaderAccessor(org.springframework.integration.IntegrationMessageHeaderAccessor) MessageChannel(org.springframework.messaging.MessageChannel) Test(org.junit.Test)

Example 10 with MessagingTemplate

use of org.springframework.integration.core.MessagingTemplate in project spring-integration by spring-projects.

the class HeaderEnricherTests method expressionUsingPayload.

@Test
public void expressionUsingPayload() {
    MessagingTemplate template = new MessagingTemplate();
    MessageChannel channel = context.getBean("payloadExpressionInput", MessageChannel.class);
    Message<?> result = template.sendAndReceive(channel, new GenericMessage<TestBean>(new TestBean("foo")));
    assertNotNull(result);
    assertEquals("foobar", result.getHeaders().get("testHeader"));
}
Also used : MessagingTemplate(org.springframework.integration.core.MessagingTemplate) MessageChannel(org.springframework.messaging.MessageChannel) Test(org.junit.Test)

Aggregations

MessagingTemplate (org.springframework.integration.core.MessagingTemplate)63 Test (org.junit.Test)58 MessageChannel (org.springframework.messaging.MessageChannel)22 PollableChannel (org.springframework.messaging.PollableChannel)12 GenericMessage (org.springframework.messaging.support.GenericMessage)11 IntegrationMessageHeaderAccessor (org.springframework.integration.IntegrationMessageHeaderAccessor)9 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)8 Message (org.springframework.messaging.Message)6 File (java.io.File)5 Map (java.util.Map)5 Matchers.containsString (org.hamcrest.Matchers.containsString)4 Assert.assertThat (org.junit.Assert.assertThat)4 Assert.assertTrue (org.junit.Assert.assertTrue)4 Assert.fail (org.junit.Assert.fail)4 MessageHandler (org.springframework.messaging.MessageHandler)4 Date (java.util.Date)3 HashMap (java.util.HashMap)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 Matchers.instanceOf (org.hamcrest.Matchers.instanceOf)3 Assert.assertEquals (org.junit.Assert.assertEquals)3