Add claimCheckIn(), claimCheckOut EIP-methods

This commit is contained in:
Artem Bilan
2014-03-24 14:57:22 +02:00
parent 59a2a37813
commit a7fd45c7eb
2 changed files with 65 additions and 0 deletions

View File

@@ -20,6 +20,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -85,8 +86,10 @@ import org.springframework.integration.handler.advice.ExpressionEvaluatingReques
import org.springframework.integration.router.MethodInvokingRouter;
import org.springframework.integration.scheduling.PollerMetadata;
import org.springframework.integration.splitter.DefaultMessageSplitter;
import org.springframework.integration.store.MessageStore;
import org.springframework.integration.store.SimpleMessageStore;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.support.MutableMessageBuilder;
import org.springframework.integration.transformer.PayloadDeserializingTransformer;
import org.springframework.integration.transformer.PayloadSerializingTransformer;
import org.springframework.integration.xml.transformer.support.XPathExpressionEvaluatingHeaderValueMessageProcessor;
@@ -233,6 +236,13 @@ public class IntegrationFlowTests {
@Qualifier("defaultOutputChannel")
private QueueChannel defaultOutputChannel;
@Autowired
private MessageStore messageStore;
@Autowired
@Qualifier("claimCheckInput")
private MessageChannel claimCheckInput;
@Test
public void testPollingFlow() {
assertThat(this.beanFactory.getBean("integerChannel"), Matchers.instanceOf(FixedSubscriberChannel.class));
@@ -629,6 +639,22 @@ public class IntegrationFlowTests {
}
@Test
public void testClaimCheck() {
QueueChannel replyChannel = new QueueChannel();
Message<String> message = MutableMessageBuilder.withPayload("foo").setReplyChannel(replyChannel).build();
this.claimCheckInput.send(message);
Message<?> receive = replyChannel.receive(2000);
assertNotNull(receive);
assertSame(message, receive);
assertEquals(1, this.messageStore.getMessageCount());
assertSame(message, this.messageStore.getMessage(message.getHeaders().getId()));
}
@MessagingGateway(defaultRequestChannel = "controlBus")
private static interface ControlBusGateway {
@@ -780,6 +806,19 @@ public class IntegrationFlowTests {
.get();
}
@Bean
public MessageStore messageStore() {
return new SimpleMessageStore();
}
@Bean
public IntegrationFlow claimCheckFlow() {
return IntegrationFlows.from("claimCheckInput")
.claimCheckIn(this.messageStore())
.claimCheckOut(this.messageStore())
.get();
}
@Bean(name = "foo-channel")
public QueueChannel fooChannel() {
return new QueueChannel();