use of org.springframework.integration.core.MessagingTemplate in project spring-integration by spring-projects.
the class ControlBusRecipientListRouterTests method testAddRecipientWithNullExpression.
@Test
public void testAddRecipientWithNullExpression() {
MessagingTemplate messagingTemplate = new MessagingTemplate();
messagingTemplate.setReceiveTimeout(1000);
messagingTemplate.convertAndSend(input, "@'simpleRouter.handler'.addRecipient('channel3')");
Message<?> message = new GenericMessage<Integer>(1);
channel.send(message);
PollableChannel chanel3 = (PollableChannel) context.getBean("channel3");
assertTrue(chanel3.receive(0).getPayload().equals(1));
}
use of org.springframework.integration.core.MessagingTemplate in project spring-integration by spring-projects.
the class ControlBusRecipientListRouterTests method testGetRecipients.
@Test
@SuppressWarnings("unchecked")
public void testGetRecipients() {
MessagingTemplate messagingTemplate = new MessagingTemplate();
messagingTemplate.setReceiveTimeout(1000);
messagingTemplate.convertAndSend(input, "@'simpleRouter.handler'.addRecipient('channel1')");
messagingTemplate.convertAndSend(input, "@'simpleRouter.handler'.getRecipients()");
PollableChannel channel1 = (PollableChannel) context.getBean("channel1");
Message<?> result = this.output.receive(0);
Collection<Recipient> mappings = (Collection<Recipient>) result.getPayload();
assertEquals(channel1, mappings.iterator().next().getChannel());
}
use of org.springframework.integration.core.MessagingTemplate in project spring-integration by spring-projects.
the class ControlBusRecipientListRouterTests method testRemoveRecipient.
@Test
public void testRemoveRecipient() {
MessagingTemplate messagingTemplate = new MessagingTemplate();
messagingTemplate.setReceiveTimeout(1000);
messagingTemplate.convertAndSend(input, "@'simpleRouter.handler'.addRecipient('channel1')");
messagingTemplate.convertAndSend(input, "@'simpleRouter.handler'.addRecipient('channel4')");
messagingTemplate.convertAndSend(input, "@'simpleRouter.handler'.removeRecipient('channel4')");
Message<?> message = new GenericMessage<Integer>(1);
channel.send(message);
PollableChannel chanel1 = (PollableChannel) context.getBean("channel1");
PollableChannel chanel4 = (PollableChannel) context.getBean("channel4");
assertTrue(chanel1.receive(0).getPayload().equals(1));
assertNull(chanel4.receive(0));
}
use of org.springframework.integration.core.MessagingTemplate in project spring-integration by spring-projects.
the class ControlBusRecipientListRouterTests method testReplaceRecipients.
@Test
public void testReplaceRecipients() {
MessagingTemplate messagingTemplate = new MessagingTemplate();
messagingTemplate.setReceiveTimeout(1000);
messagingTemplate.convertAndSend(input, "@'simpleRouter.handler'.replaceRecipients('channel7=true')");
Message<?> message = new GenericMessage<Integer>(1);
channel.send(message);
PollableChannel chanel7 = (PollableChannel) context.getBean("channel7");
assertTrue(chanel7.receive(0).getPayload().equals(1));
}
use of org.springframework.integration.core.MessagingTemplate in project spring-integration by spring-projects.
the class HeaderChannelRegistryTests method testReplaceCustomTtl.
@Test
public void testReplaceCustomTtl() {
MessagingTemplate template = new MessagingTemplate();
template.setDefaultDestination(this.inputCustomTtl);
Message<String> requestMessage = MessageBuilder.withPayload("ttl").setHeader("channelTTL", 180000).build();
Message<?> reply = template.sendAndReceive(requestMessage);
assertNotNull(reply);
assertEquals("echo:ttl", reply.getPayload());
String stringReplyChannel = reply.getHeaders().get("stringReplyChannel", String.class);
assertThat(TestUtils.getPropertyValue(TestUtils.getPropertyValue(registry, "channels", Map.class).get(stringReplyChannel), "expireAt", Long.class) - System.currentTimeMillis(), allOf(greaterThan(160000L), lessThan(181000L)));
// Now for Elvis...
reply = template.sendAndReceive(new GenericMessage<String>("ttl"));
assertNotNull(reply);
assertEquals("echo:ttl", reply.getPayload());
stringReplyChannel = reply.getHeaders().get("stringReplyChannel", String.class);
assertThat(TestUtils.getPropertyValue(TestUtils.getPropertyValue(registry, "channels", Map.class).get(stringReplyChannel), "expireAt", Long.class) - System.currentTimeMillis(), greaterThan(220000L));
}
Aggregations