Repository: qpid-jms Updated Branches: refs/heads/master cc1559be5 -> 2dafb519b
start on session integration test for temporary queues Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/82a1fbe2 Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/82a1fbe2 Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/82a1fbe2 Branch: refs/heads/master Commit: 82a1fbe2017cd4644382bf4bcf23ea8d0f811c36 Parents: cc1559b Author: Robert Gemmell <rob...@apache.org> Authored: Fri Oct 24 13:41:08 2014 +0100 Committer: Robert Gemmell <rob...@apache.org> Committed: Fri Oct 24 13:41:08 2014 +0100 ---------------------------------------------------------------------- .../jms/integration/SessionIntegrationTest.java | 21 +++++++ .../qpid/jms/test/testpeer/TestAmqpPeer.java | 60 ++++++++++++++++++++ 2 files changed, 81 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/82a1fbe2/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 b1888ee..6a4514e 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 @@ -23,6 +23,7 @@ import static org.junit.Assert.assertNotNull; import javax.jms.Connection; import javax.jms.Queue; import javax.jms.Session; +import javax.jms.TemporaryQueue; import org.apache.qpid.jms.test.QpidJmsTestCase; import org.apache.qpid.jms.test.testpeer.TestAmqpPeer; @@ -77,4 +78,24 @@ public class SessionIntegrationTest extends QpidJmsTestCase { testPeer.waitForAllHandlersToComplete(3000); } } + + @Test(timeout = 5000) + public void testCreateTemporaryQueue() throws Exception { + try (TestAmqpPeer testPeer = new TestAmqpPeer(IntegrationTestFixture.PORT);) { + Connection connection = testFixture.establishConnecton(testPeer); + connection.start(); + + testPeer.expectBegin(true); + + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + + testPeer.expectTempQueueCreationAttach(); + + TemporaryQueue tempQueue = session.createTemporaryQueue(); + assertNotNull("TemporaryQueue object was null", tempQueue); + assertNotNull("TemporaryQueue queue name was null", tempQueue.getQueueName()); + + testPeer.waitForAllHandlersToComplete(1000); + } + } } http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/82a1fbe2/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java ---------------------------------------------------------------------- diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java index a8f367e..855769f 100644 --- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java +++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java @@ -387,6 +387,66 @@ public class TestAmqpPeer implements AutoCloseable addHandler(endMatcher); } + public void expectTempQueueCreationAttach() + { + final AttachMatcher attachMatcher = new AttachMatcher() + .withName(notNullValue()) + .withHandle(notNullValue()) + .withRole(equalTo(SENDER_ROLE)) + .withSndSettleMode(equalTo(ATTACH_SND_SETTLE_MODE_UNSETTLED)) + .withRcvSettleMode(equalTo(ATTACH_RCV_SETTLE_MODE_FIRST)) + .withSource(notNullValue()) + .withTarget(notNullValue());//TODO match on the actual Target object details + + UnsignedInteger linkHandle = UnsignedInteger.valueOf(_nextLinkHandle++); + final AttachFrame attachResponse = new AttachFrame() + .setHandle(linkHandle) + .setRole(RECEIVER_ROLE) + .setSndSettleMode(ATTACH_SND_SETTLE_MODE_UNSETTLED) + .setRcvSettleMode(ATTACH_RCV_SETTLE_MODE_FIRST); + + // The response frame channel will be dynamically set based on the incoming frame. Using the -1 is an illegal placeholder. + final FrameSender attachResponseSender = new FrameSender(this, FrameType.AMQP, -1, attachResponse, null); + attachResponseSender.setValueProvider(new ValueProvider() + { + @Override + public void setValues() + { + attachResponseSender.setChannel(attachMatcher.getActualChannel()); + attachResponse.setName(attachMatcher.getReceivedName()); + attachResponse.setSource(attachMatcher.getReceivedSource()); + attachResponse.setTarget(attachMatcher.getReceivedTarget());//TODO: need to create the new target and set its address + } + }); + + final FlowFrame flowFrame = new FlowFrame().setNextIncomingId(UnsignedInteger.ZERO) + .setIncomingWindow(UnsignedInteger.valueOf(2048)) + .setNextOutgoingId(UnsignedInteger.ZERO) + .setOutgoingWindow(UnsignedInteger.valueOf(2048)) + .setLinkCredit(UnsignedInteger.valueOf(100)) + .setHandle(linkHandle); + + // The flow frame channel will be dynamically set based on the incoming frame. Using the -1 is an illegal placeholder. + final FrameSender flowFrameSender = new FrameSender(this, FrameType.AMQP, -1, flowFrame, null); + flowFrameSender.setValueProvider(new ValueProvider() + { + @Override + public void setValues() + { + flowFrameSender.setChannel(attachMatcher.getActualChannel()); + flowFrame.setDeliveryCount(attachMatcher.getReceivedInitialDeliveryCount()); + } + }); + + CompositeAmqpPeerRunnable composite = new CompositeAmqpPeerRunnable(); + composite.add(attachResponseSender); + composite.add(flowFrameSender); + + attachMatcher.onSuccess(composite); + + addHandler(attachMatcher); + } + public void expectSenderAttach() { final AttachMatcher attachMatcher = new AttachMatcher() --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org