From 923e5b0a202be9f6f2be5b153ce3c57355559b0c Mon Sep 17 00:00:00 2001 From: David Syer Date: Sat, 19 Jun 2010 06:33:42 +0000 Subject: [PATCH] INT-1069: Add namespace support for persistent queues --- ...nelWithMessageStoreParserTests-context.xml | 23 ++++++ .../ChannelWithMessageStoreParserTests.java | 78 +++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 spring-integration-core/src/test/java/org/springframework/integration/config/ChannelWithMessageStoreParserTests-context.xml create mode 100644 spring-integration-core/src/test/java/org/springframework/integration/config/ChannelWithMessageStoreParserTests.java diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/ChannelWithMessageStoreParserTests-context.xml b/spring-integration-core/src/test/java/org/springframework/integration/config/ChannelWithMessageStoreParserTests-context.xml new file mode 100644 index 0000000000..0ad011ce13 --- /dev/null +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/ChannelWithMessageStoreParserTests-context.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/ChannelWithMessageStoreParserTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/ChannelWithMessageStoreParserTests.java new file mode 100644 index 0000000000..c2dc4e33ed --- /dev/null +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/ChannelWithMessageStoreParserTests.java @@ -0,0 +1,78 @@ +/* + * Copyright 2002-2010 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.integration.config; + +import static org.junit.Assert.assertEquals; + +import java.util.concurrent.TimeUnit; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.integration.channel.PollableChannel; +import org.springframework.integration.core.Message; +import org.springframework.integration.core.MessageChannel; +import org.springframework.integration.message.MessageBuilder; +import org.springframework.integration.store.MessageGroupStore; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +/** + * @author Dave Syer + */ +@ContextConfiguration +@RunWith(SpringJUnit4ClassRunner.class) +public class ChannelWithMessageStoreParserTests { + + @Autowired + @Qualifier("input") + private MessageChannel input; + + @Autowired + @Qualifier("output") + private PollableChannel output; + + @Autowired + private TestHandler handler; + + @Autowired + private MessageGroupStore messageGroupStore; + + @Test + @DirtiesContext + public void testAggregation() throws Exception { + + input.send(createMessage("123", "id1", 3, 1, null)); + assertEquals(1, messageGroupStore.getMessageGroup("id1").size()); + handler.getLatch().await(100, TimeUnit.MILLISECONDS); + assertEquals("The message payload is not correct", "123", handler.getMessageString()); + assertEquals(0, messageGroupStore.getMessageGroup("id1").size()); + + Message result = output.receive(100); + assertEquals("hello", result.getPayload()); + + } + + private static Message createMessage(T payload, Object correlationId, int sequenceSize, int sequenceNumber, + MessageChannel outputChannel) { + return MessageBuilder.withPayload(payload).setCorrelationId(correlationId).setSequenceSize(sequenceSize) + .setSequenceNumber(sequenceNumber).setReplyChannel(outputChannel).build(); + } + +}