use of org.springframework.integration.core.MessagingTemplate in project spring-integration by spring-projects.
the class HeaderEnricherTests method priority.
@Test
public void priority() {
MessagingTemplate template = new MessagingTemplate();
MessageChannel channel = context.getBean("priorityInput", MessageChannel.class);
Message<?> result = template.sendAndReceive(channel, new GenericMessage<String>("test"));
assertNotNull(result);
assertEquals(new Integer(42), new IntegrationMessageHeaderAccessor(result).getPriority());
}
use of org.springframework.integration.core.MessagingTemplate in project spring-integration by spring-projects.
the class HeaderEnricherTests method refWithMethod.
@Test
public void refWithMethod() {
MessagingTemplate template = new MessagingTemplate();
MessageChannel channel = context.getBean("refWithMethod", MessageChannel.class);
Message<?> result = template.sendAndReceive(channel, new GenericMessage<String>("test"));
assertNotNull(result);
assertEquals(String.class, result.getHeaders().get("testHeader").getClass());
assertEquals("testBeanForMethodInvoker", result.getHeaders().get("testHeader"));
}
use of org.springframework.integration.core.MessagingTemplate in project spring-integration by spring-projects.
the class HeaderEnricherTests method ref.
@Test
public void ref() {
MessagingTemplate template = new MessagingTemplate();
MessageChannel channel = context.getBean("ref", MessageChannel.class);
Message<?> result = template.sendAndReceive(channel, new GenericMessage<String>("test"));
assertNotNull(result);
assertEquals(TestBean.class, result.getHeaders().get("testHeader").getClass());
TestBean testBeanForRef = context.getBean("testBean1", TestBean.class);
assertSame(testBeanForRef, result.getHeaders().get("testHeader"));
}
use of org.springframework.integration.core.MessagingTemplate in project spring-integration by spring-projects.
the class BridgeParserTests method bridgeWithSendTimeout.
@Test
public void bridgeWithSendTimeout() {
BridgeHandler handler = (BridgeHandler) new DirectFieldAccessor(bridgeWithSendTimeout).getPropertyValue("handler");
MessagingTemplate template = (MessagingTemplate) new DirectFieldAccessor(handler).getPropertyValue("messagingTemplate");
assertEquals(new Long(1234), new DirectFieldAccessor(template).getPropertyValue("sendTimeout"));
}
use of org.springframework.integration.core.MessagingTemplate in project spring-integration by spring-projects.
the class ControlBusTests method testControlHeaderChannelReaper.
@Test
public void testControlHeaderChannelReaper() throws InterruptedException {
MessagingTemplate messagingTemplate = new MessagingTemplate();
messagingTemplate.convertAndSend(input, "@integrationHeaderChannelRegistry.size()");
Message<?> result = this.output.receive(0);
assertNotNull(result);
// No channels in the registry
assertEquals(0, result.getPayload());
this.registry.channelToChannelName(new DirectChannel());
// Sleep a bit to be sure that we aren't reaped by registry TTL as 60000
Thread.sleep(100);
messagingTemplate.convertAndSend(input, "@integrationHeaderChannelRegistry.size()");
result = this.output.receive(0);
assertNotNull(result);
assertEquals(1, result.getPayload());
// Some DirectFieldAccessor magic to modify 'expireAt' to the past to avoid timing issues on high-loaded build
Object messageChannelWrapper = TestUtils.getPropertyValue(this.registry, "channels", Map.class).values().iterator().next();
DirectFieldAccessor dfa = new DirectFieldAccessor(messageChannelWrapper);
dfa.setPropertyValue("expireAt", System.currentTimeMillis() - 60000);
messagingTemplate.convertAndSend(input, "@integrationHeaderChannelRegistry.runReaper()");
messagingTemplate.convertAndSend(input, "@integrationHeaderChannelRegistry.size()");
result = this.output.receive(0);
assertNotNull(result);
assertEquals(0, result.getPayload());
}
Aggregations