Search in sources :

Example 56 with MessagingTemplate

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

the class WebServiceHeaderEnricherTests method literalValue.

@Test
public void literalValue() {
    MessagingTemplate template = new MessagingTemplate();
    template.setDefaultDestination(literalValueInput);
    Message<?> result = template.sendAndReceive(new GenericMessage<String>("foo"));
    Map<String, Object> headers = result.getHeaders();
    assertEquals("http://test", headers.get(WebServiceHeaders.SOAP_ACTION));
}
Also used : MessagingTemplate(org.springframework.integration.core.MessagingTemplate) Test(org.junit.Test)

Example 57 with MessagingTemplate

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

the class ParserUnitTests method testOutGateway.

@Test
public void testOutGateway() {
    DirectFieldAccessor dfa = new DirectFieldAccessor(tcpOutboundGateway);
    assertSame(cfC2, dfa.getPropertyValue("connectionFactory"));
    assertEquals(234L, dfa.getPropertyValue("requestTimeout"));
    MessagingTemplate messagingTemplate = TestUtils.getPropertyValue(tcpOutboundGateway, "messagingTemplate", MessagingTemplate.class);
    assertEquals(Long.valueOf(567), TestUtils.getPropertyValue(messagingTemplate, "sendTimeout", Long.class));
    assertEquals("789", TestUtils.getPropertyValue(tcpOutboundGateway, "remoteTimeoutExpression.literalValue"));
    assertEquals("outGateway", tcpOutboundGateway.getComponentName());
    assertEquals("ip:tcp-outbound-gateway", tcpOutboundGateway.getComponentType());
    assertTrue(cfC2.isLookupHost());
    assertEquals(24, dfa.getPropertyValue("order"));
    assertEquals("4000", TestUtils.getPropertyValue(outAdviceGateway, "remoteTimeoutExpression.expression"));
}
Also used : MessagingTemplate(org.springframework.integration.core.MessagingTemplate) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) Test(org.junit.Test)

Example 58 with MessagingTemplate

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

the class StopStartTests method test.

@Test
public void test() {
    MessagingTemplate template = new MessagingTemplate(this.test);
    this.outGateway.start();
    assertEquals("FOO", template.convertSendAndReceive("foo", String.class));
    this.outGateway.stop();
    this.outGateway.start();
    assertEquals("BAR", template.convertSendAndReceive("bar", String.class));
    this.outGateway.stop();
}
Also used : MessagingTemplate(org.springframework.integration.core.MessagingTemplate) Test(org.junit.Test)

Example 59 with MessagingTemplate

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

the class UpdateMappingsTests method testJmx.

@Test
public void testJmx() throws Exception {
    MessagingTemplate messagingTemplate = new MessagingTemplate();
    messagingTemplate.setReceiveTimeout(1000);
    Set<ObjectName> names = this.server.queryNames(ObjectName.getInstance("update.mapping.domain:type=MessageHandler,name=router,bean=endpoint"), null);
    assertEquals(1, names.size());
    Map<String, String> map = new HashMap<String, String>();
    map.put("foo", "bar");
    map.put("baz", "qux");
    Object[] params = new Object[] { map };
    this.server.invoke(names.iterator().next(), "setChannelMappings", params, new String[] { "java.util.Map" });
    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"));
}
Also used : MessagingTemplate(org.springframework.integration.core.MessagingTemplate) HashMap(java.util.HashMap) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 60 with MessagingTemplate

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

the class ControlBusParserTests method testControlMessageToChannelMetrics.

@Test
public void testControlMessageToChannelMetrics() throws InterruptedException {
    MessageChannel control = this.context.getBean("controlChannel", MessageChannel.class);
    MessagingTemplate messagingTemplate = new MessagingTemplate();
    Object value = messagingTemplate.convertSendAndReceive(control, "@integrationMbeanExporter.getChannelSendRate('testChannel').count", Object.class);
    assertEquals(0, value);
    MBeanExporter exporter = this.context.getBean(MBeanExporter.class);
    exporter.destroy();
}
Also used : MessagingTemplate(org.springframework.integration.core.MessagingTemplate) MessageChannel(org.springframework.messaging.MessageChannel) MBeanExporter(org.springframework.jmx.export.MBeanExporter) 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