Search in sources :

Example 21 with MessagingTemplate

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

the class RouterParserTests method timeoutValueConfigured.

@Test
public void timeoutValueConfigured() {
    assertTrue(this.routerWithTimeout instanceof MethodInvokingRouter);
    MessagingTemplate template = TestUtils.getPropertyValue(this.routerWithTimeout, "messagingTemplate", MessagingTemplate.class);
    Long timeout = TestUtils.getPropertyValue(template, "sendTimeout", Long.class);
    assertEquals(new Long(1234), timeout);
}
Also used : MessagingTemplate(org.springframework.integration.core.MessagingTemplate) MethodInvokingRouter(org.springframework.integration.router.MethodInvokingRouter) Test(org.junit.Test)

Example 22 with MessagingTemplate

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

the class HttpInboundGatewayParserTests method checkConfig.

@Test
public void checkConfig() {
    assertNotNull(this.gateway);
    assertTrue(getPropertyValue(this.gateway, "expectReply", Boolean.class));
    assertTrue(getPropertyValue(this.gateway, "convertExceptions", Boolean.class));
    assertSame(this.responses, getPropertyValue(this.gateway, "replyChannel"));
    assertNotNull(TestUtils.getPropertyValue(this.gateway, "errorChannel"));
    MessagingTemplate messagingTemplate = TestUtils.getPropertyValue(this.gateway, "messagingTemplate", MessagingTemplate.class);
    assertEquals(1234L, TestUtils.getPropertyValue(messagingTemplate, "sendTimeout"));
    assertEquals(4567L, TestUtils.getPropertyValue(messagingTemplate, "receiveTimeout"));
    boolean registerDefaultConverters = TestUtils.getPropertyValue(this.gateway, "mergeWithDefaultConverters", Boolean.class);
    assertFalse("By default the register-default-converters flag should be false", registerDefaultConverters);
    @SuppressWarnings("unchecked") List<HttpMessageConverter<?>> messageConverters = TestUtils.getPropertyValue(this.gateway, "messageConverters", List.class);
    assertTrue("The default converters should have been registered, given there are no custom converters", messageConverters.size() > 0);
    assertFalse(TestUtils.getPropertyValue(this.gateway, "autoStartup", Boolean.class));
    assertEquals(1001, TestUtils.getPropertyValue(this.gateway, "phase"));
}
Also used : MessagingTemplate(org.springframework.integration.core.MessagingTemplate) SerializingHttpMessageConverter(org.springframework.integration.http.converter.SerializingHttpMessageConverter) HttpMessageConverter(org.springframework.http.converter.HttpMessageConverter) Test(org.junit.Test)

Example 23 with MessagingTemplate

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

the class JmsDynamicDestinationTests method gateway.

@Test
public void gateway() throws Exception {
    Message<?> message1 = MessageBuilder.withPayload("test-1").setHeader("destinationNumber", 1).build();
    Message<?> message2 = MessageBuilder.withPayload("test-2").setHeader("destinationNumber", 2).build();
    MessagingTemplate template = new MessagingTemplate();
    Message<?> result1 = template.sendAndReceive(gatewayChannel, message1);
    Message<?> result2 = template.sendAndReceive(gatewayChannel, message2);
    assertNotNull(result1);
    assertNotNull(result2);
    assertEquals("test-1!", result1.getPayload());
    assertEquals("test-2!!", result2.getPayload());
}
Also used : MessagingTemplate(org.springframework.integration.core.MessagingTemplate) Test(org.junit.Test)

Example 24 with MessagingTemplate

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

the class UpdateMappingsTests method testChangeRouterMappings.

@Test
public void testChangeRouterMappings() {
    MessagingTemplate messagingTemplate = new MessagingTemplate();
    messagingTemplate.setReceiveTimeout(1000);
    messagingTemplate.convertAndSend(control, "@'router.handler'.replaceChannelMappings('foo=bar \n baz=qux')");
    Map<?, ?> mappings = messagingTemplate.convertSendAndReceive(control, "@'router.handler'.getChannelMappings()", Map.class);
    assertNotNull(mappings);
    assertEquals(2, mappings.size());
    assertEquals("bar", mappings.get("foo"));
    assertEquals("qux", mappings.get("baz"));
    messagingTemplate.convertAndSend(control, "@'router.handler'.replaceChannelMappings('foo=qux \n baz=bar')");
    mappings = messagingTemplate.convertSendAndReceive(control, "@'router.handler'.getChannelMappings()", Map.class);
    assertEquals(2, mappings.size());
    assertEquals("bar", mappings.get("baz"));
    assertEquals("qux", mappings.get("foo"));
}
Also used : MessagingTemplate(org.springframework.integration.core.MessagingTemplate) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 25 with MessagingTemplate

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

the class WebServiceHeaderEnricherTests method expression.

@Test
public void expression() {
    MessagingTemplate template = new MessagingTemplate();
    template.setDefaultDestination(expressionInput);
    Message<?> result = template.sendAndReceive(new GenericMessage<String>("foo"));
    Map<String, Object> headers = result.getHeaders();
    assertEquals("http://foo", headers.get(WebServiceHeaders.SOAP_ACTION));
}
Also used : MessagingTemplate(org.springframework.integration.core.MessagingTemplate) 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