reduce duplication for durable subscription attach matching
Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/6b24bd27 Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/6b24bd27 Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/6b24bd27 Branch: refs/heads/master Commit: 6b24bd27d4bc7858df71cc6cbae68d2a34de4bc9 Parents: 599585b Author: Robert Gemmell <[email protected]> Authored: Wed Nov 12 14:56:50 2014 +0000 Committer: Robert Gemmell <[email protected]> Committed: Wed Nov 12 14:56:50 2014 +0000 ---------------------------------------------------------------------- .../qpid/jms/test/testpeer/TestAmqpPeer.java | 56 +++++--------------- 1 file changed, 14 insertions(+), 42 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/6b24bd27/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 e73b231..a5d62b5 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 @@ -581,19 +581,10 @@ public class TestAmqpPeer implements AutoCloseable addHandler(attachMatcher); } - public void expectDurableSubscriberAttach(String topicName, String subscriptionName) + public void expectReceiverAttach(final Matcher<?> linkNameMatcher, final Matcher<?> sourceMatcher) { - String topicPrefix = "topic://"; //TODO: this will be removed, delete when tests start failing - - SourceMatcher sourceMatcher = new SourceMatcher(); - sourceMatcher.withAddress(equalTo(topicPrefix + topicName)); - sourceMatcher.withDynamic(equalTo(false)); - //TODO: will possibly be changed to a 1/config durability - sourceMatcher.withDurable(equalTo(TerminusDurability.UNSETTLED_STATE)); - sourceMatcher.withExpiryPolicy(equalTo(TerminusExpiryPolicy.NEVER)); - final AttachMatcher attachMatcher = new AttachMatcher() - .withName(equalTo(subscriptionName)) + .withName(linkNameMatcher) .withHandle(notNullValue()) .withRole(equalTo(Role.RECEIVER)) .withSndSettleMode(equalTo(SenderSettleMode.UNSETTLED)) @@ -630,40 +621,21 @@ public class TestAmqpPeer implements AutoCloseable public void expectReceiverAttach() { - final AttachMatcher attachMatcher = new AttachMatcher() - .withName(notNullValue()) - .withHandle(notNullValue()) - .withRole(equalTo(Role.RECEIVER)) - .withSndSettleMode(equalTo(SenderSettleMode.UNSETTLED)) - .withRcvSettleMode(equalTo(ReceiverSettleMode.FIRST)) - .withSource(notNullValue()) - .withTarget(notNullValue()); - - UnsignedInteger linkHandle = UnsignedInteger.valueOf(_nextLinkHandle++); - final AttachFrame attachResponse = new AttachFrame() - .setHandle(linkHandle) - .setRole(Role.SENDER) - .setSndSettleMode(SenderSettleMode.UNSETTLED) - .setRcvSettleMode(ReceiverSettleMode.FIRST) - .setInitialDeliveryCount(UnsignedInteger.ZERO); + expectReceiverAttach(notNullValue(), notNullValue()); + } - // 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()); - } - }); + public void expectDurableSubscriberAttach(String topicName, String subscriptionName) + { + String topicPrefix = "topic://"; //TODO: this will be removed, delete when tests start failing - attachMatcher.onSuccess(attachResponseSender); + SourceMatcher sourceMatcher = new SourceMatcher(); + sourceMatcher.withAddress(equalTo(topicPrefix + topicName)); + sourceMatcher.withDynamic(equalTo(false)); + //TODO: will possibly be changed to a 1/config durability + sourceMatcher.withDurable(equalTo(TerminusDurability.UNSETTLED_STATE)); + sourceMatcher.withExpiryPolicy(equalTo(TerminusExpiryPolicy.NEVER)); - addHandler(attachMatcher); + expectReceiverAttach(equalTo(subscriptionName), sourceMatcher); } public void expectDetach(boolean expectClosed, boolean sendResponse, boolean replyClosed) --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
