diff options
author | Martin Ritchie <ritchiem@apache.org> | 2007-10-11 11:46:10 +0000 |
---|---|---|
committer | Martin Ritchie <ritchiem@apache.org> | 2007-10-11 11:46:10 +0000 |
commit | b20578bae01868717f7a8a7d2da06cb6a9b61133 (patch) | |
tree | 77e024ae7a24c26b1db02f45495132114d3e1456 | |
parent | 92cda1886a5823fda4c043ade181ebde426611f4 (diff) | |
download | qpid-python-b20578bae01868717f7a8a7d2da06cb6a9b61133.tar.gz |
Merged revisions 573738-573739,573741-574077,574079-574236,574238-574265,574267-574503,574505-574554,574556-574584,574586-574873,574875-574901,574903-575737,575739-575787,575789-575810,575812-577772,577774-577940,577942-578057,578059-578732,578734,578736-578744,578746-578827,578829-578844,578846-579114,579116-579146,579148-579197,579199-579228,579230-579573,579575-579576,579579-579601,579603-579613,579615-579708,579710-580021,580023-580039,580042-580060,580062-580065,580067-580080,580082-580257,580259-580264,580266-580350,580352-580984,580986-580991,580994-581001,581003-581170,581172-581188,581190-581206,581208-581245,581247-581292,581294-581539,581541-581565,581567-581620,581622-581626,581628-581646,581648-581967,581969-582197,582199-582200,582203-582204,582206-582262,582264,582267-583084,583087,583089-583104,583106-583146,583148-583153,583155-583169,583171-583172,583174-583398,583400-583414,583416-583417,583419-583437,583439-583482,583484-583517,583519-583545,583547,583549-583777 via svnmerge from
https://svn.apache.org/repos/asf/incubator/qpid/branches/M2.1
........
r583775 | ritchiem | 2007-10-11 12:24:36 +0100 (Thu, 11 Oct 2007) | 1 line
QPID-635 Added a unit test and implemented the equals() method on BlockingMethodFrameListener and SpecificMethodFrameListener.
........
r583776 | ritchiem | 2007-10-11 12:28:36 +0100 (Thu, 11 Oct 2007) | 1 line
QPID-632 ImmediateMessageTest may not have sufficient time to see the exception. Performing the close before checking for exceptions should give it this time.
........
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/M2@583781 13f79535-47bb-0310-9956-ffa450edef68
4 files changed, 105 insertions, 3 deletions
diff --git a/java/client/src/main/java/org/apache/qpid/client/protocol/BlockingMethodFrameListener.java b/java/client/src/main/java/org/apache/qpid/client/protocol/BlockingMethodFrameListener.java index 0c59188de1..1badbb601c 100644 --- a/java/client/src/main/java/org/apache/qpid/client/protocol/BlockingMethodFrameListener.java +++ b/java/client/src/main/java/org/apache/qpid/client/protocol/BlockingMethodFrameListener.java @@ -293,4 +293,19 @@ public abstract class BlockingMethodFrameListener implements AMQMethodListener _lock.unlock(); } } + + public boolean equals(Object o) + { + + if (o instanceof BlockingMethodFrameListener) + { + BlockingMethodFrameListener other = (BlockingMethodFrameListener) o; + + return _channelId == other._channelId; + } + + return false; + } + + } diff --git a/java/client/src/main/java/org/apache/qpid/client/state/listener/SpecificMethodFrameListener.java b/java/client/src/main/java/org/apache/qpid/client/state/listener/SpecificMethodFrameListener.java index 623591e0b6..4a4f4a0a38 100644 --- a/java/client/src/main/java/org/apache/qpid/client/state/listener/SpecificMethodFrameListener.java +++ b/java/client/src/main/java/org/apache/qpid/client/state/listener/SpecificMethodFrameListener.java @@ -36,6 +36,22 @@ public class SpecificMethodFrameListener extends BlockingMethodFrameListener public boolean processMethod(int channelId, AMQMethodBody frame) //throws AMQException { + + //equiv to: (frame instanceof _expectedClass) return _expectedClass.isInstance(frame); } + + public boolean equals(Object o) + { + if (o instanceof SpecificMethodFrameListener) + { + SpecificMethodFrameListener other = (SpecificMethodFrameListener) o; + + // here we need to check if the two classes are the same. + return (_channelId == other._channelId) && (_expectedClass.equals(other._expectedClass)); + } + + return false; + } + } diff --git a/java/client/src/test/java/org/apache/qpid/client/SpecificMethodFrameListenerTest.java b/java/client/src/test/java/org/apache/qpid/client/SpecificMethodFrameListenerTest.java new file mode 100644 index 0000000000..4cffcecf8a --- /dev/null +++ b/java/client/src/test/java/org/apache/qpid/client/SpecificMethodFrameListenerTest.java @@ -0,0 +1,71 @@ +package org.apache.qpid.framing; + +import junit.framework.TestCase; +import org.apache.qpid.client.state.listener.SpecificMethodFrameListener; +import org.apache.mina.common.ByteBuffer; + +/* +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you 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. +* +*/ + +public class SpecificMethodFrameListenerTest extends TestCase +{ + + SpecificMethodFrameListener close1a = new SpecificMethodFrameListener(1, ChannelCloseOkBody.class); + SpecificMethodFrameListener close1b = new SpecificMethodFrameListener(1, ChannelCloseOkBody.class); + SpecificMethodFrameListener close2 = new SpecificMethodFrameListener(2, ChannelCloseOkBody.class); + SpecificMethodFrameListener open1a = new SpecificMethodFrameListener(1, ChannelOpenOkBody.class); + SpecificMethodFrameListener open1b = new SpecificMethodFrameListener(1, ChannelOpenOkBody.class); + + public void testEquals() + { + //Check that the the same objects are equal + assertEquals("ChannelCloseOKBody a should equal a", close1a, close1a); + assertEquals("ChannelOpenOkBody a should equal a", open1a, open1a); + + //check that the same values in differnt objects are equal + assertEquals("ChannelCloseOKBody b should equal a", close1b, close1a); + assertEquals("ChannelCloseOKBody a should equal b", close1a, close1b); + assertEquals("ChannelOpenOkBody a should equal b", open1a, open1b); + assertEquals("ChannelOpenOkBody a should equal b", open1a, open1b); + + //Chec that different values fail + //Different channels + assertFalse("ChannelCloseOKBody channel 1 should NOT equal channel 2", close1a.equals(close2)); + assertFalse("ChannelCloseOKBody channel 1 should NOT equal channel 2", close2.equals(close1a)); + + //Different Bodies + assertFalse("ChannelCloseOKBody should not equal ChannelOpenOkBody", close1a.equals(open1a)); + assertFalse("ChannelOpenOkBody should not equal ChannelCloseOKBody", open1a.equals(close1a)); + } + + public void testProcessMethod() throws AMQFrameDecodingException + { + ChannelCloseOkBody ccob = (ChannelCloseOkBody) ChannelCloseOkBody.getFactory().newInstance((byte) 8, (byte) 0, ByteBuffer.allocate(0), 0); + ChannelOpenOkBody coob = (ChannelOpenOkBody) ChannelOpenOkBody.getFactory().newInstance((byte) 8, (byte) 0, ByteBuffer.allocate(0), 0); + + assertTrue("This SpecificMethodFrameListener should process a ChannelCloseOkBody", close1a.processMethod(1, ccob)); + assertFalse("This SpecificMethodFrameListener should NOT process a ChannelOpenOkBody", close1a.processMethod(1, coob)); + + + + + } +} diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/localcircuit/LocalCircuitImpl.java b/java/systests/src/main/java/org/apache/qpid/test/framework/localcircuit/LocalCircuitImpl.java index 38b7758e7c..010669a7c2 100644 --- a/java/systests/src/main/java/org/apache/qpid/test/framework/localcircuit/LocalCircuitImpl.java +++ b/java/systests/src/main/java/org/apache/qpid/test/framework/localcircuit/LocalCircuitImpl.java @@ -406,12 +406,12 @@ public class LocalCircuitImpl implements Circuit // Request a status report.
check();
- // Apply all of the requested assertions, keeping record of any that fail.
- List<Assertion> failures = applyAssertions(assertions);
-
// Clean up the publisher/receivers/controlSession/connections.
close();
+ // Apply all of the requested assertions, keeping record of any that fail.
+ List<Assertion> failures = applyAssertions(assertions);
+
// Return any failed assertions to the caller.
return failures;
}
|