Return-Path: X-Original-To: apmail-qpid-commits-archive@www.apache.org Delivered-To: apmail-qpid-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 49D19102DB for ; Mon, 17 Nov 2014 17:30:37 +0000 (UTC) Received: (qmail 4586 invoked by uid 500); 17 Nov 2014 17:30:37 -0000 Delivered-To: apmail-qpid-commits-archive@qpid.apache.org Received: (qmail 4479 invoked by uid 500); 17 Nov 2014 17:30:37 -0000 Mailing-List: contact commits-help@qpid.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@qpid.apache.org Delivered-To: mailing list commits@qpid.apache.org Received: (qmail 4447 invoked by uid 99); 17 Nov 2014 17:30:37 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Nov 2014 17:30:37 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id D9F6A98D86B; Mon, 17 Nov 2014 17:30:36 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: robbie@apache.org To: commits@qpid.apache.org Date: Mon, 17 Nov 2014 17:30:37 -0000 Message-Id: In-Reply-To: <07a769339bcf44d38ef34618b7eab58e@git.apache.org> References: <07a769339bcf44d38ef34618b7eab58e@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/5] qpid-jms git commit: add test that only receives some of the available messages in the transaction add test that only receives some of the available messages in the transaction Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/f9e4a6ca Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/f9e4a6ca Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/f9e4a6ca Branch: refs/heads/master Commit: f9e4a6ca5664838596192c1563beea02924a6581 Parents: c839773 Author: Robert Gemmell Authored: Mon Nov 17 15:47:29 2014 +0000 Committer: Robert Gemmell Committed: Mon Nov 17 15:47:29 2014 +0000 ---------------------------------------------------------------------- .../jms/integration/SessionIntegrationTest.java | 35 ++++++++++++++------ 1 file changed, 25 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/f9e4a6ca/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java ---------------------------------------------------------------------- diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java index 498af7f..af03f37 100644 --- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java +++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java @@ -326,7 +326,16 @@ public class SessionIntegrationTest extends QpidJmsTestCase { } @Test(timeout=5000) - public void testCommitTransactedSessionWithConsumer() throws Exception { + public void testCommitTransactedSessionWithConsumerReceivingAllMessages() throws Exception { + doCommitTransactedSessionWithConsumerTestImpl(1, 1); + } + + @Test(timeout=5000) + public void testCommitTransactedSessionWithConsumerReceivingSomeMessages() throws Exception { + doCommitTransactedSessionWithConsumerTestImpl(5, 2); + } + + private void doCommitTransactedSessionWithConsumerTestImpl(int transferCount, int consumeCount) throws Exception { try (TestAmqpPeer testPeer = new TestAmqpPeer(IntegrationTestFixture.PORT);) { Connection connection = testFixture.establishConnecton(testPeer); connection.start(); @@ -339,7 +348,7 @@ public class SessionIntegrationTest extends QpidJmsTestCase { Queue queue = session.createQueue("myQueue"); testPeer.expectReceiverAttach(); - testPeer.expectLinkFlowRespondWithTransfer(null, null, null, null, new AmqpValueDescribedType("content")); + testPeer.expectLinkFlowRespondWithTransfer(null, null, null, null, new AmqpValueDescribedType("content"), transferCount); // First expect an unsettled 'declare' transfer to the txn coordinator, and // reply with a declared disposition state containing the txnId. @@ -348,17 +357,23 @@ public class SessionIntegrationTest extends QpidJmsTestCase { declareMatcher.setMessageContentMatcher(new EncodedAmqpValueMatcher(new Declare())); testPeer.expectTransfer(declareMatcher, false, new Declared().setTxnId(txnId), true); - // Then expect a TransactionalState disposition for the applications message once consumed - TransactionalStateMatcher stateMatcher = new TransactionalStateMatcher(); - stateMatcher.withTxnId(equalTo(txnId)); - stateMatcher.withOutcome(new DescriptorMatcher(Accepted.DESCRIPTOR_CODE, Accepted.DESCRIPTOR_SYMBOL)); - testPeer.expectDisposition(false, stateMatcher); + + for (int i = 1; i <= consumeCount; i++) { + // Then expect a TransactionalState disposition for each message once received by the consumer + TransactionalStateMatcher stateMatcher = new TransactionalStateMatcher(); + stateMatcher.withTxnId(equalTo(txnId)); + stateMatcher.withOutcome(new DescriptorMatcher(Accepted.DESCRIPTOR_CODE, Accepted.DESCRIPTOR_SYMBOL)); + testPeer.expectDisposition(false, stateMatcher); + } MessageConsumer messageConsumer = session.createConsumer(queue); - Message receivedMessage = messageConsumer.receive(1000); - assertNotNull(receivedMessage); - assertTrue(receivedMessage instanceof TextMessage); + for (int i = 1; i <= consumeCount; i++) { + Message receivedMessage = messageConsumer.receive(1000); + + assertNotNull(receivedMessage); + assertTrue(receivedMessage instanceof TextMessage); + } // Expect an unsettled 'discharge' transfer to the txn coordinator containing the txnId, // and reply with accepted and settled disposition to indicate the commit succeeded --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org For additional commands, e-mail: commits-help@qpid.apache.org