diff options
| author | Robert Greig <rgreig@apache.org> | 2006-12-15 14:12:24 +0000 |
|---|---|---|
| committer | Robert Greig <rgreig@apache.org> | 2006-12-15 14:12:24 +0000 |
| commit | 75793016c7cc8fc156411041e4399243aadc563e (patch) | |
| tree | 418a201fa99bf12b32f5b77722ce92ed34e66e2f /java/client/src/test | |
| parent | 6ca88beeea89e37ec725e5e99bada7ae48d2870f (diff) | |
| download | qpid-python-75793016c7cc8fc156411041e4399243aadc563e.tar.gz | |
QPID-183 Patch supplied by Rob Godfrey. Major changes to durable topic subscription handling.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@487562 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/client/src/test')
8 files changed, 262 insertions, 151 deletions
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/basic/MapMessageTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/basic/MapMessageTest.java index 823406daa4..02a98f67d9 100644 --- a/java/client/src/test/java/org/apache/qpid/test/unit/basic/MapMessageTest.java +++ b/java/client/src/test/java/org/apache/qpid/test/unit/basic/MapMessageTest.java @@ -20,20 +20,19 @@ */ package org.apache.qpid.test.unit.basic; +import junit.framework.Assert; +import junit.framework.TestCase; +import org.apache.log4j.Logger; import org.apache.qpid.client.AMQConnection; import org.apache.qpid.client.AMQQueue; import org.apache.qpid.client.AMQSession; import org.apache.qpid.client.message.JMSMapMessage; -import org.apache.qpid.testutil.VMBrokerSetup; -import org.apache.log4j.Logger; +import org.apache.qpid.client.transport.TransportConnection; +import javax.jms.*; import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import javax.jms.*; - -import junit.framework.TestCase; -import junit.framework.Assert; public class MapMessageTest extends TestCase implements MessageListener { @@ -56,7 +55,7 @@ public class MapMessageTest extends TestCase implements MessageListener super.setUp(); try { - //TransportConnection.createVMBroker(1); + TransportConnection.createVMBroker(1); init(new AMQConnection(_connectionString, "guest", "guest", randomize("Client"), "/test_path")); } catch (Exception e) @@ -69,7 +68,7 @@ public class MapMessageTest extends TestCase implements MessageListener { _logger.info("Tearing Down unit.basic.MapMessageTest"); super.tearDown(); - //TransportConnection.killAllVMBrokers(); + TransportConnection.killAllVMBrokers(); } private void init(AMQConnection connection) throws Exception @@ -166,12 +165,12 @@ public class MapMessageTest extends TestCase implements MessageListener testMapValues(m, count); - testPropertyWriteStatus(m); - testCorrectExceptions(m); testMessageWriteStatus(m); + testPropertyWriteStatus(m); + count++; } } @@ -207,9 +206,9 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getByte("message"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } - catch (MessageFormatException nfe) + catch (NumberFormatException nfe) { //normal execution } @@ -217,9 +216,9 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getShort("message"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } - catch (MessageFormatException nfe) + catch (NumberFormatException nfe) { //normal execution } @@ -228,9 +227,9 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getChar("message"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } - catch (MessageFormatException nfe) + catch (MessageFormatException npe) { //normal execution } @@ -238,18 +237,18 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getInt("message"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } - catch (MessageFormatException nfe) + catch (NumberFormatException nfe) { //normal execution } try { m.getLong("message"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } - catch (MessageFormatException nfe) + catch (NumberFormatException nfe) { //normal execution } @@ -258,9 +257,9 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getFloat("message"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } - catch (MessageFormatException nfe) + catch (NumberFormatException nfe) { //normal execution } @@ -268,9 +267,9 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getDouble("message"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } - catch (MessageFormatException nfe) + catch (NumberFormatException nfe) { //normal execution } @@ -278,7 +277,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getBytes("message"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -295,7 +294,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getBoolean("short"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -305,7 +304,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getByte("short"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -318,9 +317,9 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getChar("short"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } - catch (MessageFormatException nfe) + catch (MessageFormatException npe) { //normal execution } @@ -333,7 +332,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getFloat("short"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -343,7 +342,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getDouble("short"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -353,7 +352,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getBytes("short"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -370,7 +369,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getBoolean("long"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -380,7 +379,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getByte("long"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -390,7 +389,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getShort("long"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -401,9 +400,9 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getChar("long"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } - catch (MessageFormatException nfe) + catch (MessageFormatException npe) { //normal execution } @@ -411,7 +410,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getInt("long"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -424,7 +423,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getFloat("long"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -434,7 +433,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getDouble("long"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -444,7 +443,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getBytes("long"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -461,7 +460,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getBoolean("double"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -471,7 +470,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getByte("double"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -481,7 +480,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getShort("double"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -492,9 +491,9 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getChar("double"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } - catch (MessageFormatException nfe) + catch (MessageFormatException npe) { //normal execution } @@ -502,7 +501,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getInt("double"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -511,7 +510,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getLong("double"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -522,7 +521,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getFloat("double"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -536,7 +535,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getBytes("double"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -554,7 +553,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getBoolean("float"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -564,7 +563,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getByte("float"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -574,7 +573,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getShort("float"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -585,9 +584,9 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getChar("float"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } - catch (MessageFormatException nfe) + catch (MessageFormatException npe) { //normal execution } @@ -595,7 +594,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getInt("float"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -604,7 +603,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getLong("float"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -620,7 +619,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getBytes("float"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -638,7 +637,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getBoolean("int"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -648,7 +647,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getByte("int"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -658,7 +657,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getShort("int"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -669,9 +668,9 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getChar("int"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } - catch (MessageFormatException nfe) + catch (MessageFormatException npe) { //normal execution } @@ -684,7 +683,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getFloat("int"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -694,7 +693,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getDouble("int"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -704,7 +703,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getBytes("int"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -722,7 +721,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getBoolean("char"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -732,7 +731,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getByte("char"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -742,7 +741,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getShort("char"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -754,7 +753,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getInt("char"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -763,7 +762,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getLong("char"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -774,7 +773,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getFloat("char"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -784,7 +783,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getDouble("char"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -794,7 +793,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getBytes("char"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -810,7 +809,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getBoolean("bytes"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -820,7 +819,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getByte("bytes"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -830,7 +829,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getShort("bytes"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -841,9 +840,9 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getChar("bytes"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } - catch (MessageFormatException nfe) + catch (MessageFormatException npe) { //normal execution } @@ -851,7 +850,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getInt("bytes"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -861,7 +860,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getLong("bytes"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -872,7 +871,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getFloat("bytes"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -882,7 +881,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getDouble("bytes"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -895,7 +894,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getString("bytes"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -911,7 +910,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getBoolean("byte"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -926,9 +925,9 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getChar("byte"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } - catch (MessageFormatException nfe) + catch (MessageFormatException npe) { //normal execution } @@ -942,7 +941,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getFloat("byte"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -952,7 +951,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getDouble("byte"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -962,7 +961,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getBytes("byte"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -982,7 +981,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getByte("odd"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -993,7 +992,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getShort("odd"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -1003,7 +1002,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getChar("odd"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException npe) { @@ -1013,7 +1012,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getInt("odd"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -1023,7 +1022,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getLong("odd"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -1033,7 +1032,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getFloat("odd"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -1043,7 +1042,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getDouble("odd"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -1053,7 +1052,7 @@ public class MapMessageTest extends TestCase implements MessageListener try { m.getBytes("odd"); - fail("MessageFormatException expected as value doesn't exist."); + fail("Exception Expected."); } catch (MessageFormatException nfe) { @@ -1224,6 +1223,7 @@ public class MapMessageTest extends TestCase implements MessageListener { synchronized(received) { + _logger.info("****************** Recevied Messgage:" + (JMSMapMessage) message); received.add((JMSMapMessage) message); received.notify(); } @@ -1248,6 +1248,6 @@ public class MapMessageTest extends TestCase implements MessageListener public static junit.framework.Test suite() { - return new VMBrokerSetup(new junit.framework.TestSuite(MapMessageTest.class)); + return new junit.framework.TestSuite(MapMessageTest.class); } } diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java index 80af81652e..c88024f39f 100644 --- a/java/client/src/test/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java +++ b/java/client/src/test/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java @@ -6,9 +6,9 @@ * 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 @@ -19,18 +19,15 @@ */ package org.apache.qpid.test.unit.basic; +import junit.framework.TestCase; import org.apache.qpid.client.AMQConnection; import org.apache.qpid.client.AMQDestination; import org.apache.qpid.client.AMQSession; import org.apache.qpid.client.AMQTopic; -import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException; import org.apache.qpid.client.transport.TransportConnection; -import org.apache.qpid.testutil.VMBrokerSetup; import javax.jms.*; -import junit.framework.TestCase; - public class MultipleConnectionTest extends TestCase { public static final String _defaultBroker = "vm://:1"; @@ -138,6 +135,19 @@ public class MultipleConnectionTest extends TestCase } } + + protected void setUp() throws Exception + { + super.setUp(); + TransportConnection.createVMBroker(1); + } + + protected void tearDown() throws Exception + { + super.tearDown(); + TransportConnection.killAllVMBrokers(); + } + private static void waitForCompletion(int expected, long wait, Receiver[] receivers) throws InterruptedException { for (int i = 0; i < receivers.length; i++) @@ -209,6 +219,6 @@ public class MultipleConnectionTest extends TestCase public static junit.framework.Test suite() { - return new VMBrokerSetup(new junit.framework.TestSuite(MultipleConnectionTest.class)); + return new junit.framework.TestSuite(MultipleConnectionTest.class); } } diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/message/BytesMessageTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/message/BytesMessageTest.java index 7ffb3ca469..a0e4aa9787 100644 --- a/java/client/src/test/java/org/apache/qpid/test/unit/client/message/BytesMessageTest.java +++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/message/BytesMessageTest.java @@ -552,16 +552,6 @@ public class BytesMessageTest extends TestCase assertEquals((byte)0, result[2]); } - public void testToBodyString() throws Exception - { - JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage(); - final String testText = "This is a test"; - bm.writeUTF(testText); - bm.reset(); - String result = bm.toBodyString(); - assertEquals(testText, result); - } - public void testToBodyStringWithNull() throws Exception { JMSBytesMessage bm = TestMessageHelper.newJMSBytesMessage(); diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/message/MapMessageTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/message/MapMessageTest.java index 58e62e8252..276067a28d 100644 --- a/java/client/src/test/java/org/apache/qpid/test/unit/client/message/MapMessageTest.java +++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/message/MapMessageTest.java @@ -14,18 +14,16 @@ * "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. + * under the License. + * * - * */ package org.apache.qpid.test.unit.client.message; -import junit.framework.TestCase; import junit.framework.Assert; -import org.apache.qpid.framing.PropertyFieldTable; +import junit.framework.TestCase; import org.apache.qpid.client.message.JMSMapMessage; import org.apache.qpid.client.message.TestMessageHelper; -import org.apache.log4j.Logger; import javax.jms.JMSException; import javax.jms.MessageFormatException; @@ -204,9 +202,9 @@ public class MapMessageTest extends TestCase { JMSMapMessage mm = TestMessageHelper.newJMSMapMessage(); mm.getByte("random"); - Assert.fail("MessageFormatException expected"); + Assert.fail("NumberFormatException expected"); } - catch (MessageFormatException e) + catch (NumberFormatException e) { //normal execution } @@ -295,9 +293,9 @@ public class MapMessageTest extends TestCase { JMSMapMessage mm = TestMessageHelper.newJMSMapMessage(); mm.getInt("random"); - Assert.fail("MessageFormatException should be received."); + Assert.fail("NumberFormatException should be received."); } - catch (MessageFormatException e) + catch (NumberFormatException e) { //normal execution } @@ -313,9 +311,9 @@ public class MapMessageTest extends TestCase { JMSMapMessage mm = TestMessageHelper.newJMSMapMessage(); mm.getLong("random"); - Assert.fail("MessageFormatException should be received."); + Assert.fail("NumberFormatException should be received."); } - catch (MessageFormatException e) + catch (NumberFormatException e) { //normal execution } @@ -331,9 +329,9 @@ public class MapMessageTest extends TestCase { JMSMapMessage mm = TestMessageHelper.newJMSMapMessage(); mm.getShort("random"); - Assert.fail("MessageFormatException should be received."); + Assert.fail("NumberFormatException should be received."); } - catch (MessageFormatException e) + catch (NumberFormatException e) { //normal execution } diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/message/TextMessageTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/message/TextMessageTest.java index 1345c0defb..64d10fb13f 100644 --- a/java/client/src/test/java/org/apache/qpid/test/unit/client/message/TextMessageTest.java +++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/message/TextMessageTest.java @@ -7,9 +7,9 @@ * 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 @@ -190,9 +190,9 @@ public class TextMessageTest extends TestCase { JMSMapMessage mm = TestMessageHelper.newJMSMapMessage(); mm.getByteProperty("random"); - Assert.fail("MessageFormatException expected"); + Assert.fail("NumberFormatException expected"); } - catch (MessageFormatException e) + catch (NumberFormatException e) { //normal execution } @@ -245,9 +245,9 @@ public class TextMessageTest extends TestCase { JMSMapMessage mm = TestMessageHelper.newJMSMapMessage(); mm.getIntProperty("random"); - Assert.fail("MessageFormatException should be received."); + Assert.fail("NumberFormatException should be received."); } - catch (MessageFormatException e) + catch (NumberFormatException e) { //normal execution } @@ -263,9 +263,9 @@ public class TextMessageTest extends TestCase { JMSMapMessage mm = TestMessageHelper.newJMSMapMessage(); mm.getLongProperty("random"); - Assert.fail("MessageFormatException should be received."); + Assert.fail("NumberFormatException should be received."); } - catch (MessageFormatException e) + catch (NumberFormatException e) { //normal execution } @@ -281,9 +281,9 @@ public class TextMessageTest extends TestCase { JMSMapMessage mm = TestMessageHelper.newJMSMapMessage(); mm.getShortProperty("random"); - Assert.fail("MessageFormatException should be received."); + Assert.fail("NumberFormatException should be received."); } - catch (MessageFormatException e) + catch (NumberFormatException e) { //normal execution } diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java index 98e355b0da..eee9b2de9f 100644 --- a/java/client/src/test/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java +++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java @@ -7,9 +7,9 @@ * 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 @@ -87,19 +87,19 @@ public class AMQProtocolSessionTest extends TestCase _testSession.getMinaProtocolSession().setLocalPort(_port); testAddress = _testSession.genQueueName(); - assertEquals("Failure when generating a queue name from an address with special chars",_generatedAddress,testAddress); + assertEquals("Failure when generating a queue exchange from an address with special chars",_generatedAddress,testAddress); //test empty address _testSession.getMinaProtocolSession().setStringLocalAddress(_emptyAddress); testAddress = _testSession.genQueueName(); - assertEquals("Failure when generating a queue name from an empty address",_generatedAddress_2,testAddress); + assertEquals("Failure when generating a queue exchange from an empty address",_generatedAddress_2,testAddress); //test address with no special chars _testSession.getMinaProtocolSession().setStringLocalAddress(_validAddress); testAddress = _testSession.genQueueName(); - assertEquals("Failure when generating a queue name from an address with no special chars",_generatedAddress_3,testAddress); + assertEquals("Failure when generating a queue exchange from an address with no special chars",_generatedAddress_3,testAddress); } diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/message/StreamMessageTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/message/StreamMessageTest.java index 50944730c3..315ba6ae4c 100644 --- a/java/client/src/test/java/org/apache/qpid/test/unit/message/StreamMessageTest.java +++ b/java/client/src/test/java/org/apache/qpid/test/unit/message/StreamMessageTest.java @@ -73,7 +73,7 @@ public class StreamMessageTest extends TestCase MessageProducer mandatoryProducer = producerSession.createProducer(queue); // Third test - should be routed - _logger.info("Sending routable message"); + _logger.info("Sending isBound message"); StreamMessage msg = producerSession.createStreamMessage(); msg.setStringProperty("F1000","1"); diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/topic/TopicSessionTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/topic/TopicSessionTest.java index fa46a4bcfb..3b6e3517c2 100644 --- a/java/client/src/test/java/org/apache/qpid/test/unit/topic/TopicSessionTest.java +++ b/java/client/src/test/java/org/apache/qpid/test/unit/topic/TopicSessionTest.java @@ -26,10 +26,8 @@ import org.apache.qpid.client.AMQSession; import org.apache.qpid.client.AMQTopic; import org.apache.qpid.client.transport.TransportConnection; -import javax.jms.TopicSession; -import javax.jms.TextMessage; -import javax.jms.TopicPublisher; -import javax.jms.MessageConsumer; +import javax.jms.*; + /** * @author Apache Software Foundation @@ -46,12 +44,126 @@ public class TopicSessionTest extends TestCase { super.tearDown(); TransportConnection.killAllVMBrokers(); + //Thread.sleep(2000); } - public void testTextMessageCreation() throws Exception + + public void testTopicSubscriptionUnsubscription() throws Exception { AMQTopic topic = new AMQTopic("MyTopic"); - AMQConnection con = new AMQConnection("vm://:1", "guest", "guest", "test", "/test"); + AMQConnection con = new AMQConnection("vm://:1?retries='0'", "guest", "guest", "test", "/test"); + TopicSession session1 = con.createTopicSession(false, AMQSession.NO_ACKNOWLEDGE); + TopicSubscriber sub = session1.createDurableSubscriber(topic,"subscription0"); + TopicPublisher publisher = session1.createPublisher(topic); + + con.start(); + + TextMessage tm = session1.createTextMessage("Hello"); + publisher.publish(tm); + + tm = (TextMessage) sub.receive(2000); + assertNotNull(tm); + + session1.unsubscribe("subscription0"); + + try + { + session1.unsubscribe("not a subscription"); + fail("expected InvalidDestinationException when unsubscribing from unknown subscription"); + } + catch(InvalidDestinationException e) + { + ; // PASS + } + catch(Exception e) + { + fail("expected InvalidDestinationException when unsubscribing from unknown subscription, got: " + e); + } + + con.close(); + } + + public void testSubscriptionNameReuseForDifferentTopicSingleConnection() throws Exception + { + subscriptionNameReuseForDifferentTopic(false); + } + + public void testSubscriptionNameReuseForDifferentTopicTwoConnections() throws Exception + { + subscriptionNameReuseForDifferentTopic(true); + } + + private void subscriptionNameReuseForDifferentTopic(boolean shutdown) throws Exception + { + AMQTopic topic = new AMQTopic("MyTopic1" + String.valueOf(shutdown)); + AMQTopic topic2 = new AMQTopic("MyOtherTopic1" + String.valueOf(shutdown)); + AMQConnection con = new AMQConnection("vm://:1?retries='0'", "guest", "guest", "test", "/test"); + TopicSession session1 = con.createTopicSession(false, AMQSession.NO_ACKNOWLEDGE); + TopicSubscriber sub = session1.createDurableSubscriber(topic, "subscription0"); + TopicPublisher publisher = session1.createPublisher(null); + + con.start(); + + publisher.publish(topic, session1.createTextMessage("hello")); + TextMessage m = (TextMessage) sub.receive(2000); + assertNotNull(m); + + if (shutdown) + { + session1.close(); + con.close(); + con = new AMQConnection("vm://:1?retries='0'", "guest", "guest", "test", "/test"); + con.start(); + session1 = con.createTopicSession(false, AMQSession.NO_ACKNOWLEDGE); + publisher = session1.createPublisher(null); + } + TopicSubscriber sub2 = session1.createDurableSubscriber(topic2, "subscription0"); + publisher.publish(topic, session1.createTextMessage("hello")); + if (!shutdown) + { + m = (TextMessage) sub.receive(2000); + assertNull(m); + } + publisher.publish(topic2, session1.createTextMessage("goodbye")); + m = (TextMessage) sub2.receive(2000); + assertNotNull(m); + assertEquals("goodbye", m.getText()); + con.close(); + } + + public void testUnsubscriptionAfterConnectionClose() throws Exception + { + AMQTopic topic = new AMQTopic("MyTopic3"); + AMQConnection con1 = new AMQConnection("vm://:1?retries='0'", "guest", "guest", "test", "/test"); + TopicSession session1 = con1.createTopicSession(false, AMQSession.NO_ACKNOWLEDGE); + TopicPublisher publisher = session1.createPublisher(topic); + + AMQConnection con2 = new AMQConnection("vm://:1?retries='0'", "guest", "guest", "test2", "/test"); + TopicSession session2 = con2.createTopicSession(false, AMQSession.NO_ACKNOWLEDGE); + TopicSubscriber sub = session2.createDurableSubscriber(topic, "subscription0"); + + con2.start(); + + publisher.publish(session1.createTextMessage("Hello")); + TextMessage tm = (TextMessage) sub.receive(2000); + assertNotNull(tm); + con2.close(); + publisher.publish(session1.createTextMessage("Hello2")); + con2 = new AMQConnection("vm://:1?retries='0'", "guest", "guest", "test2", "/test"); + session2 = con2.createTopicSession(false, AMQSession.NO_ACKNOWLEDGE); + sub = session2.createDurableSubscriber(topic, "subscription0"); + con2.start(); + tm = (TextMessage) sub.receive(2000); + assertNotNull(tm); + assertEquals("Hello2", tm.getText()); + con1.close(); + con2.close(); + } + + public void testTextMessageCreation() throws Exception + { + AMQTopic topic = new AMQTopic("MyTopic4"); + AMQConnection con = new AMQConnection("vm://:1?retries='0'", "guest", "guest", "test", "/test"); TopicSession session1 = con.createTopicSession(false, AMQSession.NO_ACKNOWLEDGE); TopicPublisher publisher = session1.createPublisher(topic); MessageConsumer consumer1 = session1.createConsumer(topic); @@ -85,6 +197,7 @@ public class TopicSessionTest extends TestCase tm = (TextMessage) consumer1.receive(2000); assertNotNull(tm); assertEquals("Empty string not returned", "", msgText); + con.close(); } public static junit.framework.Test suite() |
