summaryrefslogtreecommitdiff
path: root/java/client/src/test
diff options
context:
space:
mode:
authorMartin Ritchie <ritchiem@apache.org>2006-12-15 08:33:10 +0000
committerMartin Ritchie <ritchiem@apache.org>2006-12-15 08:33:10 +0000
commita96152eea7e7ce48bb9340f477f3935744ee5ea6 (patch)
treeada0a6c314add42f32e5143e298c010ecc4b997c /java/client/src/test
parentb6e573a5889ff89ccceeab3d3dc0504157a8c285 (diff)
downloadqpid-python-a96152eea7e7ce48bb9340f477f3935744ee5ea6.tar.gz
QPID-181 QPID-180
AbstractJMSMessage.java - updated to use getJMSHeaders JMSMapMessage.java - JMSPropertyFieldTable.java - Moved functionality of setting and retrieving a JMS property. Now shared by the Headers and MapMessageTest.java MapMessageTest.java - Updated the exceptions that are caught as all methods should throw a JMSException i.e. MessageFormatException TextMessageTest.java - Added tests for the Message Properties common/pom.xml - Added JMS dependency for the JMSPropertyFieldTable.java and associated tests EncodingUtils.java - changed comments and changed getencodedCharLength return to an int PropertyFieldTable.java - Cleaned up and now uses enum for prefixs. Created comprehensive test of both PropertyFieldTable classes. AMQPInvalidClassException.java - created to throw a runtime exception when trying to add a non-primative value. Forcing clients to handle this would break the Map usage of the FieldTable. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@487481 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/client/src/test')
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/basic/MapMessageTest.java167
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/message/MapMessageTest.java14
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/message/TextMessageTest.java247
3 files changed, 337 insertions, 91 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 1a469c1d12..823406daa4 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
@@ -166,12 +166,12 @@ public class MapMessageTest extends TestCase implements MessageListener
testMapValues(m, count);
- testMessageWriteStatus(m);
-
testPropertyWriteStatus(m);
testCorrectExceptions(m);
+ testMessageWriteStatus(m);
+
count++;
}
}
@@ -207,9 +207,9 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getByte("message");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
- catch (NumberFormatException nfe)
+ catch (MessageFormatException nfe)
{
//normal execution
}
@@ -217,9 +217,9 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getShort("message");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
- catch (NumberFormatException nfe)
+ catch (MessageFormatException nfe)
{
//normal execution
}
@@ -228,7 +228,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getChar("message");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -238,18 +238,18 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getInt("message");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
- catch (NumberFormatException nfe)
+ catch (MessageFormatException nfe)
{
//normal execution
}
try
{
m.getLong("message");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
- catch (NumberFormatException nfe)
+ catch (MessageFormatException nfe)
{
//normal execution
}
@@ -258,9 +258,9 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getFloat("message");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
- catch (NumberFormatException nfe)
+ catch (MessageFormatException nfe)
{
//normal execution
}
@@ -268,9 +268,9 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getDouble("message");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
- catch (NumberFormatException nfe)
+ catch (MessageFormatException nfe)
{
//normal execution
}
@@ -278,7 +278,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getBytes("message");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -295,7 +295,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getBoolean("short");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -305,7 +305,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getByte("short");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -318,7 +318,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getChar("short");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -333,7 +333,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getFloat("short");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -343,7 +343,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getDouble("short");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -353,7 +353,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getBytes("short");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -370,7 +370,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getBoolean("long");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -380,7 +380,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getByte("long");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -390,7 +390,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getShort("long");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -401,7 +401,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getChar("long");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -411,7 +411,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getInt("long");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -424,7 +424,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getFloat("long");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -434,7 +434,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getDouble("long");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -444,7 +444,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getBytes("long");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -461,7 +461,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getBoolean("double");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -471,7 +471,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getByte("double");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -481,7 +481,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getShort("double");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -492,7 +492,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getChar("double");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -502,7 +502,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getInt("double");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -511,7 +511,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getLong("double");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -522,7 +522,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getFloat("double");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -536,7 +536,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getBytes("double");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -554,7 +554,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getBoolean("float");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -564,7 +564,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getByte("float");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -574,7 +574,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getShort("float");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -585,7 +585,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getChar("float");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -595,7 +595,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getInt("float");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -604,7 +604,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getLong("float");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -620,7 +620,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getBytes("float");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -638,7 +638,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getBoolean("int");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -648,7 +648,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getByte("int");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -658,7 +658,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getShort("int");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -669,7 +669,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getChar("int");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -684,7 +684,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getFloat("int");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -694,7 +694,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getDouble("int");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -704,7 +704,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getBytes("int");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -722,7 +722,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getBoolean("char");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -732,7 +732,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getByte("char");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -742,7 +742,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getShort("char");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -754,7 +754,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getInt("char");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -763,7 +763,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getLong("char");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -774,7 +774,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getFloat("char");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -784,7 +784,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getDouble("char");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -794,7 +794,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getBytes("char");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -810,7 +810,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getBoolean("bytes");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -820,7 +820,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getByte("bytes");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -830,7 +830,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getShort("bytes");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -841,7 +841,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getChar("bytes");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -851,7 +851,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getInt("bytes");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -861,7 +861,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getLong("bytes");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -872,7 +872,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getFloat("bytes");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -882,7 +882,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getDouble("bytes");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -895,7 +895,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getString("bytes");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -911,7 +911,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getBoolean("byte");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -926,7 +926,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getChar("byte");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -942,7 +942,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getFloat("byte");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -952,7 +952,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getDouble("byte");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -962,7 +962,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getBytes("byte");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -982,7 +982,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getByte("odd");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -993,7 +993,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getShort("odd");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -1003,9 +1003,9 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getChar("odd");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
- catch (MessageFormatException nfe)
+ catch (MessageFormatException npe)
{
//normal execution
}
@@ -1013,7 +1013,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getInt("odd");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -1023,7 +1023,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getLong("odd");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -1033,7 +1033,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getFloat("odd");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -1043,7 +1043,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getDouble("odd");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -1053,7 +1053,7 @@ public class MapMessageTest extends TestCase implements MessageListener
try
{
m.getBytes("odd");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -1224,7 +1224,6 @@ public class MapMessageTest extends TestCase implements MessageListener
{
synchronized(received)
{
- _logger.info("****************** Recevied Messgage:" + (JMSMapMessage) message);
received.add((JMSMapMessage) message);
received.notify();
}
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 e5458fd89e..58e62e8252 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
@@ -206,7 +206,7 @@ public class MapMessageTest extends TestCase
mm.getByte("random");
Assert.fail("MessageFormatException expected");
}
- catch (NumberFormatException e)
+ catch (MessageFormatException e)
{
//normal execution
}
@@ -295,9 +295,9 @@ public class MapMessageTest extends TestCase
{
JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
mm.getInt("random");
- Assert.fail("NumberFormatException should be received.");
+ Assert.fail("MessageFormatException should be received.");
}
- catch (NumberFormatException e)
+ catch (MessageFormatException e)
{
//normal execution
}
@@ -313,9 +313,9 @@ public class MapMessageTest extends TestCase
{
JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
mm.getLong("random");
- Assert.fail("NumberFormatException should be received.");
+ Assert.fail("MessageFormatException should be received.");
}
- catch (NumberFormatException e)
+ catch (MessageFormatException e)
{
//normal execution
}
@@ -331,9 +331,9 @@ public class MapMessageTest extends TestCase
{
JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
mm.getShort("random");
- Assert.fail("NumberFormatException should be received.");
+ Assert.fail("MessageFormatException should be received.");
}
- catch (NumberFormatException e)
+ catch (MessageFormatException 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 337b0f3bbc..1345c0defb 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
@@ -22,8 +22,13 @@ package org.apache.qpid.test.unit.client.message;
import org.apache.qpid.client.message.TestMessageHelper;
import org.apache.qpid.client.message.JMSTextMessage;
+import org.apache.qpid.client.message.JMSMapMessage;
import junit.framework.TestCase;
+import junit.framework.Assert;
+
+import javax.jms.JMSException;
+import javax.jms.MessageFormatException;
public class TextMessageTest extends TestCase
{
@@ -47,6 +52,248 @@ public class TextMessageTest extends TestCase
assertEquals(val, "Banana");
}
+
+ public void testBooleanPropertyLookup()
+ {
+ try
+ {
+ JMSTextMessage tm = TestMessageHelper.newJMSTextMessage();
+
+ tm.setBooleanProperty("value", true);
+ Assert.assertEquals(true, tm.getBooleanProperty("value"));
+ Assert.assertEquals("true", tm.getStringProperty("value"));
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received." + e);
+ }
+ }
+
+ public void testBytePropertyLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ mm.setByteProperty("value", Byte.MAX_VALUE);
+
+ Assert.assertEquals(Byte.MAX_VALUE, mm.getByteProperty("value"));
+ Assert.assertEquals((short) Byte.MAX_VALUE, mm.getShortProperty("value"));
+ Assert.assertEquals(Byte.MAX_VALUE, mm.getIntProperty("value"));
+ Assert.assertEquals((long) Byte.MAX_VALUE, mm.getLongProperty("value"));
+ Assert.assertEquals("" + Byte.MAX_VALUE, mm.getStringProperty("value"));
+
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received." + e);
+ }
+ }
+
+ public void testShortPropertyLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ mm.setShortProperty("value", Short.MAX_VALUE);
+ Assert.assertEquals(Short.MAX_VALUE, mm.getShortProperty("value"));
+ Assert.assertEquals((int) Short.MAX_VALUE, mm.getIntProperty("value"));
+ Assert.assertEquals((long) Short.MAX_VALUE, mm.getLongProperty("value"));
+ Assert.assertEquals("" + Short.MAX_VALUE, mm.getStringProperty("value"));
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received." + e);
+ }
+ }
+
+ public void testDoublePropertyLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ mm.setDoubleProperty("value", Double.MAX_VALUE);
+ Assert.assertEquals(Double.MAX_VALUE, mm.getDoubleProperty("value"));
+ Assert.assertEquals("" + Double.MAX_VALUE, mm.getStringProperty("value"));
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received." + e);
+ }
+ }
+
+ public void testFloatPropertyLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ mm.setFloatProperty("value", Float.MAX_VALUE);
+ Assert.assertEquals(Float.MAX_VALUE, mm.getFloatProperty("value"));
+ Assert.assertEquals((double) Float.MAX_VALUE, mm.getDoubleProperty("value"));
+ Assert.assertEquals("" + Float.MAX_VALUE, mm.getStringProperty("value"));
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received." + e);
+ }
+ }
+
+ public void testIntPropertyLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ mm.setIntProperty("value", Integer.MAX_VALUE);
+ Assert.assertEquals(Integer.MAX_VALUE, mm.getIntProperty("value"));
+ Assert.assertEquals((long) Integer.MAX_VALUE, mm.getLongProperty("value"));
+ Assert.assertEquals("" + Integer.MAX_VALUE, mm.getStringProperty("value"));
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received." + e);
+ }
+ }
+
+ public void testLongPropertyLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ mm.setLongProperty("value", Long.MAX_VALUE);
+ Assert.assertEquals(Long.MAX_VALUE, mm.getLongProperty("value"));
+ Assert.assertEquals("" + Long.MAX_VALUE, mm.getStringProperty("value"));
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received." + e);
+ }
+ }
+
+
+ // Failed Lookups
+
+ public void testFailedBooleanPropertyLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ Assert.assertEquals(false, mm.getBooleanProperty("int"));
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received." + e);
+ }
+ }
+
+ public void testFailedBytePropertyLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ mm.getByteProperty("random");
+ Assert.fail("MessageFormatException expected");
+ }
+ catch (MessageFormatException e)
+ {
+ //normal execution
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received:" + e);
+ }
+
+ }
+
+ public void testFailedDoublePropertyLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ mm.getDoubleProperty("random");
+ Assert.fail("NullPointerException should be received.");
+ }
+ catch (NullPointerException e)
+ {
+ //normal execution
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received:" + e);
+ }
+ }
+
+ public void testFailedFloatPropertyLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ mm.getFloatProperty("random");
+ Assert.fail("NullPointerException should be received.");
+ }
+ catch (NullPointerException e)
+ {
+ //normal execution
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received:" + e);
+ }
+ }
+
+ public void testFailedIntPropertyLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ mm.getIntProperty("random");
+ Assert.fail("MessageFormatException should be received.");
+ }
+ catch (MessageFormatException e)
+ {
+ //normal execution
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received:" + e);
+ }
+ }
+
+ public void testFailedLongPropertyLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ mm.getLongProperty("random");
+ Assert.fail("MessageFormatException should be received.");
+ }
+ catch (MessageFormatException e)
+ {
+ //normal execution
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received:" + e);
+ }
+ }
+
+ public void testFailedShortPropertyLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ mm.getShortProperty("random");
+ Assert.fail("MessageFormatException should be received.");
+ }
+ catch (MessageFormatException e)
+ {
+ //normal execution
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received:" + e);
+ }
+ }
+
+
public static junit.framework.Test suite()
{
return new junit.framework.TestSuite(TextMessageTest.class);