[jboss-cvs] joramtests/src/main/java/org/objectweb/jtests/jms/conform/message/properties ...
Scott Stark
scott.stark at jboss.com
Thu Mar 29 00:28:34 EDT 2007
User: starksm
Date: 07/03/29 00:28:34
Added: src/main/java/org/objectweb/jtests/jms/conform/message/properties
MessagePropertyConversionTest.java package.html
MessagePropertyTest.java JMSXPropertyTest.java
Log:
+ covert to mvn
+ Drop the poor properties file setup logic and require that the properties be passed in
Revision Changes Path
1.1 date: 2007/03/29 04:28:34; author: starksm; state: Exp;joramtests/src/main/java/org/objectweb/jtests/jms/conform/message/properties/MessagePropertyConversionTest.java
Index: MessagePropertyConversionTest.java
===================================================================
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2002 INRIA
* Contact: joram-team at objectweb.org
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* Initial developer(s): Jeff Mesnil (jmesnil at inrialpes.fr)
* Contributor(s): ______________________________________.
*/
package org.objectweb.jtests.jms.conform.message.properties;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageFormatException;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.objectweb.jtests.jms.framework.PTPTestCase;
/**
* Test the conversion of primitive types for the <code>javax.jms.Message</code> properties.
* <br />
* See JMS Specification, §3.5.4 Property Value Conversion and the corresponding table (p.33-34).
* <br />
* The method name <code>testXXX2YYY</code> means that we test if a property
* which has been set as a <code>XXX</code> type can be read as a <code>YYY</code> type,
* where <code>XXX</code> and <code>YYY</code> can be <code>boolean, byte, short, long, float
* double</code> or <code>String</code>.
*
* <pre>
* ---------------------------------------------------------------|
* | boolean | byte | short | int | long | float | double | String|
* |-----------------------------------------------------------------------|
* |boolean | X X |
* |byte | X X X X X |
* |short | X X X X |
* |int | X X X |
* |long | X X |
* |float | X X X |
* |double | X X |
* |String | Y Y Y Y Y Y Y X |
* |-----------------------------------------------------------------------|
* </pre>
* A value set as the row type can be read as the column type.
* <br />
* The unmarked cases must throw a <code>javax.jms.MessageFormatException</code>
* <br />
* The cases marked with a Y should throw a <code>java.lang.MessageFormatException</code> <strong>if</strong> the
* String is not a correct representation of the column type (otherwise, it returns the property).
*
* @author Jeff Mesnil (jmesnil at inrialpes.fr)
* @version $Id: MessagePropertyConversionTest.java,v 1.1 2007/03/29 04:28:34 starksm Exp $
*/
public class MessagePropertyConversionTest extends PTPTestCase
{
/**
* if a property is set as a <code>java.lang.String</code>,
* it can also be read as a <code>java.lang.String</code>.
*/
public void testString2String()
{
try
{
Message message = senderSession.createMessage();
message.setStringProperty("pi", "3.14159");
assertEquals("3.14159", message.getStringProperty("pi"));
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>java.lang.String</code>,
* to get it as a <code>double</code> throws a <code>java.lang.NuberFormatException</code>
* if the <code>String</code> is not a correct representation for a <code>double</code>
* (e.g. <code>"not a number"</code>).
*/
public void testString2Double_2()
{
try
{
Message message = senderSession.createMessage();
message.setStringProperty("pi", "not_a_number");
message.getDoubleProperty("pi");
fail("§3.5.4 The String to numeric conversions must throw the java.lang.NumberFormatException "
+ " if the numeric's valueOf() method does not accept the String value as a valid representation.\n");
}
catch (java.lang.NumberFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>java.lang.String</code>,
* it can also be read as a <code>double</code> as long as the <code>String</code>
* is a correct representation of a <code>double</code> (e.g. <code>"3.14159"</code>).
*/
public void testString2Double_1()
{
try
{
Message message = senderSession.createMessage();
message.setStringProperty("pi", "3.14159");
assertEquals(3.14159, message.getDoubleProperty("pi"), 0);
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>java.lang.String</code>,
* to get it as a <code>float</code> throws a <code>java.lang.NuberFormatException</code>
* if the <code>String</code> is not a correct representation for a <code>float</code>
* (e.g. <code>"not_a_number"</code>).
*/
public void testString2Float_2()
{
try
{
Message message = senderSession.createMessage();
message.setStringProperty("pi", "not_a_number");
message.getFloatProperty("pi");
fail("§3.5.4 The String to numeric conversions must throw the java.lang.NumberFormatException "
+ " if the numeric's valueOf() method does not accept the String value as a valid representation.\n");
}
catch (java.lang.NumberFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>java.lang.String</code>,
* it can also be read as a <code>float</code> as long as the <code>String</code>
* is a correct representation of a <code>float</code> (e.g. <code>"3.14159"</code>).
*/
public void testString2Float_1()
{
try
{
Message message = senderSession.createMessage();
message.setStringProperty("pi", "3.14159");
assertEquals(3.14159F, message.getFloatProperty("pi"), 0);
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>java.lang.String</code>,
* to get it as a <code>long</code> throws a <code>java.lang.NuberFormatException</code>
* if the <code>String</code> is not a correct representation for a <code>long</code>
* (e.g. <code>"3.14159"</code>).
*/
public void testString2Long_2()
{
try
{
Message message = senderSession.createMessage();
message.setStringProperty("pi", "3.14159");
message.getLongProperty("pi");
fail("§3.5.4 The String to numeric conversions must throw the java.lang.NumberFormatException "
+ " if the numeric's valueOf() method does not accept the String value as a valid representation.\n");
}
catch (java.lang.NumberFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>java.lang.String</code>,
* it can also be read as a <code>long</code> as long as the <code>String</code>
* is a correct representation of a <code>long</code> (e.g. <code>"0"</code>).
*/
public void testString2Long_1()
{
try
{
Message message = senderSession.createMessage();
message.setStringProperty("prop", "0");
assertEquals(0l, message.getLongProperty("prop"));
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>java.lang.String</code>,
* to get it as a <code>int</code> throws a <code>java.lang.NuberFormatException</code>
* if the <code>String</code> is not a correct representation for a <code>int</code>
* (e.g. <code>"3.14159"</code>).
*/
public void testString2Int_2()
{
try
{
Message message = senderSession.createMessage();
message.setStringProperty("pi", "3.14159");
message.getIntProperty("pi");
fail("§3.5.4 The String to numeric conversions must throw the java.lang.NumberFormatException "
+ " if the numeric's valueOf() method does not accept the String value as a valid representation.\n");
}
catch (java.lang.NumberFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>java.lang.String</code>,
* it can also be read as a <code>int</code> as long as the <code>String</code>
* is a correct representation of a <code>int</code> (e.g. <code>"0"</code>).
*/
public void testString2Int_1()
{
try
{
Message message = senderSession.createMessage();
message.setStringProperty("prop", "0");
assertEquals(0, message.getIntProperty("prop"));
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>java.lang.String</code>,
* to get it as a <code>short</code> throws a <code>java.lang.NuberFormatException</code>
* if the <code>String</code> is not a correct representation for a <code>short</code>
* (e.g. <code>"3.14159"</code>).
*/
public void testString2Short_2()
{
try
{
Message message = senderSession.createMessage();
message.setStringProperty("pi", "3.14159");
message.getShortProperty("pi");
fail("§3.5.4 The String to numeric conversions must throw the java.lang.NumberFormatException "
+ " if the numeric's valueOf() method does not accept the String value as a valid representation.\n");
}
catch (java.lang.NumberFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>java.lang.String</code>,
* it can also be read as a <code>short</code> as long as the <code>String</code>
* is a correct representation of a <code>short</code> (e.g. <code>"0"</code>).
*/
public void testString2Short_1()
{
try
{
Message message = senderSession.createMessage();
message.setStringProperty("prop", "0");
assertEquals((short) 0, message.getShortProperty("prop"));
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>java.lang.String</code>,
* to get it as a <code>byte</code> throws a <code>java.lang.NuberFormatException</code>
* if the <code>String</code> is not a correct representation for a <code>byte</code>
* (e.g. <code>"3.14159"</code>).
*/
public void testString2Byte_2()
{
try
{
Message message = senderSession.createMessage();
message.setStringProperty("pi", "3.14159");
message.getByteProperty("pi");
fail("§3.5.4 The String to numeric conversions must throw the java.lang.NumberFormatException "
+ " if the numeric's valueOf() method does not accept the String value as a valid representation.\n");
}
catch (java.lang.NumberFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>java.lang.String</code>,
* it can also be read as a <code>byte</code> if the <code>String</code>
* is a correct representation of a <code>byte</code> (e.g. <code>"0"</code>).
*/
public void testString2Byte_1()
{
try
{
Message message = senderSession.createMessage();
message.setStringProperty("prop", "0");
assertEquals((byte) 0, message.getByteProperty("prop"));
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>java.lang.String</code>,
* to get it as a <code>boolean</code> returns <code>true</code> if the property is not
* null and is equal, ignoring case, to the string "true" (.eg. "True" is ok), else it
* returns <code>false</code> (e.g. "test")
*/
public void testString2Boolean_2()
{
try
{
Message message = senderSession.createMessage();
message.setStringProperty("prop", "test");
assertEquals(false, message.getBooleanProperty("prop"));
}
catch (MessageFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>java.lang.String</code>,
* it can also be read as a <code>boolean</code> if the <code>String</code>
* is a correct representation of a <code>boolean</code> (e.g. <code>"true"</code>).
*/
public void testString2Boolean_1()
{
try
{
Message message = senderSession.createMessage();
message.setStringProperty("prop", "true");
assertEquals(true, message.getBooleanProperty("prop"));
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>double</code>,
* it can also be read as a <code>java.lang.String</code>.
*/
public void testDouble2String()
{
try
{
Message message = senderSession.createMessage();
message.setDoubleProperty("prop", 127.0);
assertEquals("127.0", message.getStringProperty("prop"));
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>double</code>,
* it can also be read as a <code>double</code>.
*/
public void testDouble2Double()
{
try
{
Message message = senderSession.createMessage();
message.setDoubleProperty("prop", 127.0);
assertEquals(127.0, message.getDoubleProperty("prop"), 0);
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>double</code>,
* to get is as a <code>float</code> throws a <code>javax.jms.MessageFormatException</code>.
*/
public void testDouble2Float()
{
try
{
Message message = senderSession.createMessage();
message.setDoubleProperty("prop", 127.0);
message.getFloatProperty("prop");
fail("§3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
}
catch (MessageFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>double</code>,
* to get is as a <code>long</code> throws a <code>javax.jms.MessageFormatException</code>.
*/
public void testDouble2Long()
{
try
{
Message message = senderSession.createMessage();
message.setDoubleProperty("prop", 127.0);
message.getLongProperty("prop");
fail("§3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
}
catch (MessageFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>double</code>,
* to get is as an <code>int</code> throws a <code>javax.jms.MessageFormatException</code>.
*/
public void testDouble2Int()
{
try
{
Message message = senderSession.createMessage();
message.setDoubleProperty("prop", 127.0);
message.getIntProperty("prop");
fail("§3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
}
catch (MessageFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>double</code>,
* to get is as a <code>short</code> throws a <code>javax.jms.MessageFormatException</code>.
*/
public void testDouble2Short()
{
try
{
Message message = senderSession.createMessage();
// store a value that can't be converted to short
message.setDoubleProperty("prop", 127.0);
message.getShortProperty("prop");
fail("§3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
}
catch (MessageFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>double</code>,
* to get is as a <code>byte</code> throws a <code>javax.jms.MessageFormatException</code>.
*/
public void testDouble2Byte()
{
try
{
Message message = senderSession.createMessage();
// store a value that can't be converted to byte
message.setDoubleProperty("prop", 127.0);
message.getByteProperty("prop");
fail("§3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
}
catch (MessageFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>double</code>,
* to get is as a <code>boolean</code> throws a <code>javax.jms.MessageFormatException</code>.
*/
public void testDouble2Boolean()
{
try
{
Message message = senderSession.createMessage();
// store a value that can be converted to boolean
message.setDoubleProperty("prop", 127.0);
message.getBooleanProperty("prop");
fail("§3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
}
catch (MessageFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>float</code>,
* it can also be read as a <code>String</code>.
*/
public void testFloat2String()
{
try
{
Message message = senderSession.createMessage();
message.setFloatProperty("prop", 127.0F);
assertEquals("127.0", message.getStringProperty("prop"));
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>float</code>,
* it can also be read as a <code>double</code>.
*/
public void testFloat2Double()
{
try
{
Message message = senderSession.createMessage();
message.setFloatProperty("prop", 127.0F);
assertEquals(127.0, message.getDoubleProperty("prop"), 0);
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>float</code>,
* it can also be read as a <code>float</code>.
*/
public void testFloat2Float()
{
try
{
Message message = senderSession.createMessage();
message.setFloatProperty("prop", 127.0F);
assertEquals(127.0F, message.getFloatProperty("prop"), 0);
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>float</code>,
* to get is as a <code>long</code> throws a <code>javax.jms.MessageFormatException</code>.
*/
public void testFloat2Long()
{
try
{
Message message = senderSession.createMessage();
message.setFloatProperty("prop", 127.0F);
message.getLongProperty("prop");
fail("§3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
}
catch (MessageFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>float</code>,
* to get is as a <code>int</code> throws a <code>javax.jms.MessageFormatException</code>.
*/
public void testFloat2Int()
{
try
{
Message message = senderSession.createMessage();
message.setFloatProperty("prop", 127.0F);
message.getIntProperty("prop");
fail("§3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
}
catch (MessageFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>float</code>,
* to get is as a <code>short</code> throws a <code>javax.jms.MessageFormatException</code>.
*/
public void testFloat2Short()
{
try
{
Message message = senderSession.createMessage();
// store a value that can't be converted to short
message.setFloatProperty("prop", 127.0F);
message.getShortProperty("prop");
fail("§3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
}
catch (MessageFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>float</code>,
* to get is as a <code>byte</code> throws a <code>javax.jms.MessageFormatException</code>.
*/
public void testFloat2Byte()
{
try
{
Message message = senderSession.createMessage();
// store a value that can't be converted to byte
message.setFloatProperty("prop", 127.0F);
message.getByteProperty("prop");
fail("§3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
}
catch (MessageFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>float</code>,
* to get is as a <code>boolean</code> throws a <code>javax.jms.MessageFormatException</code>.
*/
public void testFloat2Boolean()
{
try
{
Message message = senderSession.createMessage();
// store a value that can be converted to boolean
message.setFloatProperty("prop", 127.0F);
message.getBooleanProperty("prop");
fail("§3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
}
catch (MessageFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>long</code>,
* it can also be read as a <code>String</code>.
*/
public void testLong2String()
{
try
{
Message message = senderSession.createMessage();
message.setLongProperty("prop", 127L);
assertEquals("127", message.getStringProperty("prop"));
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>long</code>,
* to get is as a <code>double</code> throws a <code>javax.jms.MessageFormatException</code>.
*/
public void testLong2Double()
{
try
{
Message message = senderSession.createMessage();
message.setLongProperty("prop", 127L);
message.getDoubleProperty("prop");
fail("§3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
}
catch (MessageFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>long</code>,
* to get is as a <code>float</code> throws a <code>javax.jms.MessageFormatException</code>.
*/
public void testLong2Float()
{
try
{
Message message = senderSession.createMessage();
message.setLongProperty("prop", 127L);
message.getFloatProperty("prop");
fail("§3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
}
catch (MessageFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>long</code>,
* it can also be read as a <code>long</code>.
*/
public void testLong2Long()
{
try
{
Message message = senderSession.createMessage();
message.setLongProperty("prop", 127L);
assertEquals(127L, message.getLongProperty("prop"));
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>long</code>,
* to get is as an <code>int</code> throws a <code>javax.jms.MessageFormatException</code>.
*/
public void testLong2Int()
{
try
{
Message message = senderSession.createMessage();
message.setLongProperty("prop", 127L);
message.getIntProperty("prop");
fail("§3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
}
catch (MessageFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>long</code>,
* to get is as a <code>short</code> throws a <code>javax.jms.MessageFormatException</code>.
*/
public void testLong2Short()
{
try
{
Message message = senderSession.createMessage();
// store a value that can't be converted to short
message.setLongProperty("prop", 127L);
message.getShortProperty("prop");
fail("§3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
}
catch (MessageFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>long</code>,
* to get is as a <code>byte</code> throws a <code>javax.jms.MessageFormatException</code>.
*/
public void testLong2Byte()
{
try
{
Message message = senderSession.createMessage();
// store a value that can't be converted to byte
message.setLongProperty("prop", 127L);
message.getByteProperty("prop");
fail("§3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
}
catch (MessageFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>long</code>,
* to get is as a <code>boolean</code> throws a <code>javax.jms.MessageFormatException</code>.
*/
public void testLong2Boolean()
{
try
{
Message message = senderSession.createMessage();
// store a value that can be converted to boolean
message.setLongProperty("prop", 127L);
message.getBooleanProperty("prop");
fail("§3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
}
catch (MessageFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as an <code>int</code>,
* it can also be read as a <code>String</code>.
*/
public void testInt2String()
{
try
{
Message message = senderSession.createMessage();
message.setIntProperty("prop", 127);
assertEquals("127", message.getStringProperty("prop"));
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>int</code>,
* to get is as a <code>double</code> throws a <code>javax.jms.MessageFormatException</code>.
*/
public void testInt2Double()
{
try
{
Message message = senderSession.createMessage();
message.setIntProperty("prop", 127);
message.getDoubleProperty("prop");
fail("§3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
}
catch (MessageFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>int</code>,
* to get is as a <code>float</code> throws a <code>javax.jms.MessageFormatException</code>.
*/
public void testInt2Float()
{
try
{
Message message = senderSession.createMessage();
message.setIntProperty("prop", 127);
message.getFloatProperty("prop");
fail("§3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
}
catch (MessageFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as an <code>int</code>,
* it can also be read as a <code>long</code>.
*/
public void testInt2Long()
{
try
{
Message message = senderSession.createMessage();
message.setIntProperty("prop", 127);
assertEquals(127L, message.getLongProperty("prop"));
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as an <code>int</code>,
* it can also be read as an <code>int</code>.
*/
public void testInt2Int()
{
try
{
Message message = senderSession.createMessage();
message.setIntProperty("prop", 127);
assertEquals(127, message.getIntProperty("prop"));
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>int</code>,
* to get is as a <code>short</code> throws a <code>javax.jms.MessageFormatException</code>.
*/
public void testInt2Short()
{
try
{
Message message = senderSession.createMessage();
// store a value that can't be converted to short
message.setIntProperty("prop", Integer.MAX_VALUE);
message.getShortProperty("prop");
fail("§3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
}
catch (MessageFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>int</code>,
* to get is as a <code>byte</code> throws a <code>javax.jms.MessageFormatException</code>.
*/
public void testInt2Byte()
{
try
{
Message message = senderSession.createMessage();
// store a value that can't be converted to byte
message.setIntProperty("prop", Integer.MAX_VALUE);
message.getByteProperty("prop");
fail("§3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
}
catch (MessageFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>int</code>,
* to get is as a <code>boolean</code> throws a <code>javax.jms.MessageFormatException</code>.
*/
public void testInt2Boolean()
{
try
{
Message message = senderSession.createMessage();
// store a value that can be converted to boolean
message.setIntProperty("prop", Integer.MAX_VALUE);
message.getBooleanProperty("prop");
fail("§3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
}
catch (MessageFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>short</code>,
* it can also be read as a <code>String</code>.
*/
public void testShort2String()
{
try
{
Message message = senderSession.createMessage();
message.setShortProperty("prop", (short) 127);
assertEquals("127", message.getStringProperty("prop"));
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>short</code>,
* to get is as a <code>double</code> throws a <code>javax.jms.MessageFormatException</code>.
*/
public void testShort2Double()
{
try
{
Message message = senderSession.createMessage();
message.setShortProperty("prop", (short) 127);
message.getDoubleProperty("prop");
fail("§3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
}
catch (MessageFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>short</code>,
* to get is as a <code>float</code> throws a <code>javax.jms.MessageFormatException</code>.
*/
public void testShort2Float()
{
try
{
Message message = senderSession.createMessage();
message.setShortProperty("prop", (short) 127);
message.getFloatProperty("prop");
fail("§3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
}
catch (MessageFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>short</code>,
* it can also be read as a <code>long</code>.
*/
public void testShort2Long()
{
try
{
Message message = senderSession.createMessage();
message.setShortProperty("prop", (short) 127);
assertEquals(127L, message.getLongProperty("prop"));
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>short</code>,
* it can also be read as an <code>int</code>.
*/
public void testShort2Int()
{
try
{
Message message = senderSession.createMessage();
message.setShortProperty("prop", (short) 127);
assertEquals(127, message.getIntProperty("prop"));
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>short</code>,
* it can also be read as a <code>short</code>.
*/
public void testShort2Short()
{
try
{
Message message = senderSession.createMessage();
message.setShortProperty("prop", (short) 127);
assertEquals((short) 127, message.getShortProperty("prop"));
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>short</code>,
* to get is as a <code>byte</code> throws a <code>javax.jms.MessageFormatException</code>.
*/
public void testShort2Byte()
{
try
{
Message message = senderSession.createMessage();
message.setShortProperty("prop", (short) 127);
message.getByteProperty("prop");
fail("§3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
}
catch (MessageFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>short</code>,
* to get is as a <code>boolean</code> throws a <code>javax.jms.MessageFormatException</code>.
*/
public void testShort2Boolean()
{
try
{
Message message = senderSession.createMessage();
// store a value that can't be converted to boolean
message.setShortProperty("prop", (short) 127);
message.getBooleanProperty("prop");
fail("§3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
}
catch (MessageFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>byte</code>,
* it can also be read as a <code>String</code>.
*/
public void testByte2String()
{
try
{
Message message = senderSession.createMessage();
message.setByteProperty("prop", (byte) 127);
assertEquals("127", message.getStringProperty("prop"));
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>byte</code>,
* to get is as a <code>double</code> throws a <code>javax.jms.MessageFormatException</code>.
*/
public void testByte2Double()
{
try
{
Message message = senderSession.createMessage();
message.setByteProperty("prop", (byte) 127);
message.getDoubleProperty("prop");
fail("§3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
}
catch (MessageFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>byte</code>,
* to get is as a <code>float</code> throws a <code>javax.jms.MessageFormatException</code>.
*/
public void testByte2Float()
{
try
{
Message message = senderSession.createMessage();
message.setByteProperty("prop", (byte) 127);
message.getFloatProperty("prop");
fail("§3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
}
catch (MessageFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>byte</code>,
* it can also be read as a <code>long</code>.
*/
public void testByte2Long()
{
try
{
Message message = senderSession.createMessage();
message.setByteProperty("prop", (byte) 127);
assertEquals(127L, message.getLongProperty("prop"));
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>byte</code>,
* it can also be read as an <code>int</code>.
*/
public void testByte2Int()
{
try
{
Message message = senderSession.createMessage();
message.setByteProperty("prop", (byte) 127);
assertEquals(127, message.getIntProperty("prop"));
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>byte</code>,
* it can also be read as a <code>short</code>.
*/
public void testByte2Short()
{
try
{
Message message = senderSession.createMessage();
message.setByteProperty("prop", (byte) 127);
assertEquals((short) 127, message.getShortProperty("prop"));
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>byte</code>,
* it can also be read as a <code>byte</code>.
*/
public void testByte2Byte()
{
try
{
Message message = senderSession.createMessage();
message.setByteProperty("prop", (byte) 127);
assertEquals((byte) 127, message.getByteProperty("prop"));
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>byte</code>,
* to get is as a <code>boolean</code> throws a <code>javax.jms.MessageFormatException</code>.
*/
public void testByte2Boolean()
{
try
{
Message message = senderSession.createMessage();
// store a value that can't be converted to boolean
message.setByteProperty("prop", (byte) 127);
message.getBooleanProperty("prop");
fail("§3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
}
catch (MessageFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>boolean</code>,
* it can also be read as a <code>String</code>.
*/
public void testBoolean2String()
{
try
{
Message message = senderSession.createMessage();
message.setBooleanProperty("prop", true);
assertEquals("true", message.getStringProperty("prop"));
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>boolean</code>,
* to get is as a <code>double</code> throws a <code>javax.jms.MessageFormatException</code>.
*/
public void testBoolean2Double()
{
try
{
Message message = senderSession.createMessage();
// store a value that can't be converted to double
message.setBooleanProperty("prop", true);
message.getDoubleProperty("prop");
fail("§3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
}
catch (MessageFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>boolean</code>,
* to get is as a <code>float</code> throws a <code>javax.jms.MessageFormatException</code>.
*/
public void testBoolean2Float()
{
try
{
Message message = senderSession.createMessage();
// store a value that can't be converted to float
message.setBooleanProperty("prop", true);
message.getFloatProperty("prop");
fail("§3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
}
catch (MessageFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>boolean</code>,
* to get is as a <code>long</code> throws a <code>javax.jms.MessageFormatException</code>.
*/
public void testBoolean2Long()
{
try
{
Message message = senderSession.createMessage();
// store a value that can't be converted to long
message.setBooleanProperty("true", true);
message.getLongProperty("true");
fail("§3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
}
catch (MessageFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>boolean</code>,
* to get is as a <code>int</code> throws a <code>javax.jms.MessageFormatException</code>.
*/
public void testBoolean2Int()
{
try
{
Message message = senderSession.createMessage();
// store a value that can't be converted to int
message.setBooleanProperty("prop", true);
message.getIntProperty("prop");
fail("§3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
}
catch (MessageFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>boolean</code>,
* to get is as a <code>short</code> throws a <code>javax.jms.MessageFormatException</code>.
*/
public void testBoolean2Short()
{
try
{
Message message = senderSession.createMessage();
// store a value that can't be converted to short
message.setBooleanProperty("prop", true);
message.getShortProperty("prop");
fail("§3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
}
catch (MessageFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>boolean</code>,
* to get is as a <code>byte</code> throws a <code>javax.jms.MessageFormatException</code>.
*/
public void testBoolean2Byte()
{
try
{
Message message = senderSession.createMessage();
// store a value that can't be converted to byte
message.setBooleanProperty("prop", true);
message.getByteProperty("prop");
fail("§3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
}
catch (MessageFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* if a property is set as a <code>boolean</code>,
* it can also be read as a <code>boolean</code>.
*/
public void testBoolean2Boolean()
{
try
{
Message message = senderSession.createMessage();
message.setBooleanProperty("prop", true);
assertEquals(true, message.getBooleanProperty("prop"));
}
catch (JMSException e)
{
fail(e);
}
}
/**
* Method to use this class in a Test suite
*/
public static Test suite()
{
return new TestSuite(MessagePropertyConversionTest.class);
}
public MessagePropertyConversionTest(String name)
{
super(name);
}
}
1.1 date: 2007/03/29 04:28:34; author: starksm; state: Exp;joramtests/src/main/java/org/objectweb/jtests/jms/conform/message/properties/package.html
Index: package.html
===================================================================
<body>
Tests JMS <em>Message Properties</em> features.
</body>
1.1 date: 2007/03/29 04:28:34; author: starksm; state: Exp;joramtests/src/main/java/org/objectweb/jtests/jms/conform/message/properties/MessagePropertyTest.java
Index: MessagePropertyTest.java
===================================================================
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2002 INRIA
* Contact: joram-team at objectweb.org
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* Initial developer(s): Jeff Mesnil (jmesnil at inrialpes.fr)
* Contributor(s): ______________________________________.
*/
package org.objectweb.jtests.jms.conform.message.properties;
import java.util.Enumeration;
import java.util.Vector;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageFormatException;
import javax.jms.TextMessage;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.objectweb.jtests.jms.framework.PTPTestCase;
/**
* Test the <code>javax.jms.Message</code> properties.
* <br />
* See JMS Specification, §3.5 Message Properties (p.32-37)
*
* @author Jeff Mesnil (jmesnil at inrialpes.fr)
* @version $Id: MessagePropertyTest.java,v 1.1 2007/03/29 04:28:34 starksm Exp $
*/
public class MessagePropertyTest extends PTPTestCase
{
/**
* Test that any other class than <code>Boolean, Byte, Short, Integer, Long,
* Float, Double</code> and <code>String</code> used in the <code>Message.setObjectProperty()</code>
* method throws a <code>javax.jms.MessageFormatException</code>.
*/
public void testSetObjectProperty_2()
{
try
{
Message message = senderSession.createMessage();
message.setObjectProperty("prop", new Vector());
fail("§3.5.5 An attempt to use any other class [than Boolean, Byte,...,String] must throw "
+ "a JMS MessageFormatException.\n");
}
catch (MessageFormatException e)
{
}
catch (JMSException e)
{
fail("Should throw a javax.jms.MessageFormatException, not a " + e);
}
}
/**
* if a property is set as a <code>Float</code> with the <code>Message.setObjectProperty()</code>
* method, it can be retrieve directly as a <code>double</code> by <code>Message.getFloatProperty()</code>
*/
public void testSetObjectProperty_1()
{
try
{
Message message = senderSession.createMessage();
message.setObjectProperty("pi", new Float(3.14159f));
assertEquals(3.14159f, message.getFloatProperty("pi"), 0);
}
catch (JMSException e)
{
fail(e);
}
}
/**
* Test that a <code>null</code> value is returned by the <code>Message.getObjectProperty()</code> method
* if a property by the specified name does not exits.
*/
public void testGetObjectProperty()
{
try
{
Message message = senderSession.createMessage();
assertEquals(
"§3.5.5 A null value is returned [by the getObjectProperty method] if a property by the specified "
+ "name does not exits.\n", null, message.getObjectProperty("prop"));
}
catch (JMSException e)
{
fail(e);
}
}
/**
* Test that a <code>null</code> value is returned by the <code>Message.getStringProperty()</code> method
* if a property by the specified name does not exits.
*/
public void testGetStringProperty()
{
try
{
Message message = senderSession.createMessage();
assertEquals(
"§3.5.5 A null value is returned [by the getStringProperty method] if a property by the specified "
+ "name does not exits.\n", null, message.getStringProperty("prop"));
}
catch (JMSException e)
{
fail(e);
}
}
/**
* Test that an attempt to get a <code>double</code> property which does not exist throw
* a <code>java.lang.NullPointerException</code>
*/
public void testGetDoubleProperty()
{
try
{
Message message = senderSession.createMessage();
message.getDoubleProperty("prop");
fail("Should raise a NullPointerException.\n");
}
catch (NullPointerException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* Test that an attempt to get a <code>float</code> property which does not exist throw
* a <code>java.lang.NullPointerException</code>
*/
public void testGetFloatProperty()
{
try
{
Message message = senderSession.createMessage();
message.getFloatProperty("prop");
fail("Should raise a NullPointerException.\n");
}
catch (NullPointerException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* Test that an attempt to get a <code>long</code> property which does not exist throw
* a <code>java.lang.NumberFormatException</code>
*/
public void testGetLongProperty()
{
try
{
Message message = senderSession.createMessage();
message.getLongProperty("prop");
fail("Should raise a NumberFormatException.\n");
}
catch (NumberFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* Test that an attempt to get a <code>int</code> property which does not exist throw
* a <code>java.lang.NumberFormatException</code>
*/
public void testGetIntProperty()
{
try
{
Message message = senderSession.createMessage();
message.getIntProperty("prop");
fail("Should raise a NumberFormatException.\n");
}
catch (NumberFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* Test that an attempt to get a <code>short</code> property which does not exist throw
* a <code>java.lang.NumberFormatException</code>
*/
public void testGetShortProperty()
{
try
{
Message message = senderSession.createMessage();
message.getShortProperty("prop");
fail("Should raise a NumberFormatException.\n");
}
catch (NumberFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* Test that an attempt to get a <code>byte</code> property which does not exist throw
* a <code>java.lang.NumberFormatException</code>
*/
public void testGetByteProperty()
{
try
{
Message message = senderSession.createMessage();
message.getByteProperty("prop");
fail("Should raise a NumberFormatException.\n");
}
catch (NumberFormatException e)
{
}
catch (JMSException e)
{
fail(e);
}
}
/**
* Test that an attempt to get a <code>boolean</code> property which does not exist
* returns <code>false</code>
*/
public void testGetBooleanProperty()
{
try
{
Message message = senderSession.createMessage();
assertEquals(false, message.getBooleanProperty("prop"));
}
catch (JMSException e)
{
fail(e);
}
}
/**
* Test that the <code>Message.getPropertyNames()</code> method does not return
* the name of the JMS standard header fields (e.g. <code>JMSCorrelationID</code>.
*/
public void testGetPropertyNames()
{
try
{
Message message = senderSession.createMessage();
message.setJMSCorrelationID("foo");
Enumeration enumeration = message.getPropertyNames();
assertTrue("§3.5.6 The getPropertyNames method does not return the names of "
+ "the JMS standard header field [e.g. JMSCorrelationID].\n", !enumeration.hasMoreElements());
}
catch (JMSException e)
{
fail(e);
}
}
/**
* Test that the <code>Message.getPropertyNames()</code> method returns an empty
* <code>java.util.Enumeration</code> if there is no properties.
* <br />
* If there are some, test that it properly return their names.
*/
public void testPropertyIteration()
{
try
{
Message message = senderSession.createMessage();
Enumeration enumeration = message.getPropertyNames();
assertTrue("No property yet defined.\n", !enumeration.hasMoreElements());
message.setDoubleProperty("pi", 3.14159);
enumeration = message.getPropertyNames();
assertEquals("One property defined of name 'pi'.\n", "pi", (String) enumeration.nextElement());
}
catch (JMSException e)
{
fail(e);
}
}
/**
* Test that the <code>Message.clearProperties()</code> method does not clear the
* value of the Message's body.
*/
public void testClearProperties_2()
{
try
{
TextMessage message = senderSession.createTextMessage();
message.setText("foo");
message.clearProperties();
assertEquals("§3.5.7 Clearing a message's property entries does not clear the value of its body.\n", "foo",
message.getText());
}
catch (JMSException e)
{
fail(e);
}
}
/**
* Test that the <code>Message.clearProperties()</code> method deletes all the
* properties of the Message.
*/
public void testClearProperties_1()
{
try
{
TextMessage message = senderSession.createTextMessage();
message.setStringProperty("prop", "foo");
message.clearProperties();
assertEquals("§3.5.7 A message's properties are deleted by the clearProperties method.\n", null, message
.getStringProperty("prop"));
}
catch (JMSException e)
{
fail(e);
}
}
/**
* Method to use this class in a Test suite
*/
public static Test suite()
{
return new TestSuite(MessagePropertyTest.class);
}
public MessagePropertyTest(String name)
{
super(name);
}
}
1.1 date: 2007/03/29 04:28:34; author: starksm; state: Exp;joramtests/src/main/java/org/objectweb/jtests/jms/conform/message/properties/JMSXPropertyTest.java
Index: JMSXPropertyTest.java
===================================================================
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2002 INRIA
* Contact: joram-team at objectweb.org
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* Initial developer(s): Jeff Mesnil (jmesnil at inrialpes.fr)
* Contributor(s): ______________________________________.
*/
package org.objectweb.jtests.jms.conform.message.properties;
import java.util.Enumeration;
import javax.jms.ConnectionMetaData;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.TextMessage;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.objectweb.jtests.jms.framework.PTPTestCase;
import org.objectweb.jtests.jms.framework.TestConfig;
/**
* Test the JMSX defined properties.
* <br />
* See JMS Specification, §3.5.9 JMS Defined Properties
*
* @author Jeff Mesnil (jmesnil at inrialpes.fr)
* @version $Id: JMSXPropertyTest.java,v 1.1 2007/03/29 04:28:34 starksm Exp $
*/
public class JMSXPropertyTest extends PTPTestCase
{
/**
* Test that the JMSX property <code>JMSXGroupID</code> is supported.
*/
public void testSupportsJMSXGroupID()
{
try
{
boolean found = false;
ConnectionMetaData metaData = senderConnection.getMetaData();
Enumeration enumeration = metaData.getJMSXPropertyNames();
while (enumeration.hasMoreElements())
{
String jmsxPropertyName = (String) enumeration.nextElement();
if (jmsxPropertyName.equals("JMSXGroupID"))
{
found = true;
}
}
assertTrue("JMSXGroupID property is not supported", found);
}
catch (JMSException e)
{
fail(e);
}
}
/**
* Test that the JMSX property <code>JMSXGroupID</code> works
*/
public void testJMSXGroupID_1()
{
try
{
String groupID = "testSupportsJMSXGroupID_1:group";
TextMessage message = senderSession.createTextMessage();
message.setStringProperty("JMSXGroupID", groupID);
message.setText("testSupportsJMSXGroupID_1");
sender.send(message);
Message m = receiver.receive(TestConfig.TIMEOUT);
assertTrue(m instanceof TextMessage);
TextMessage msg = (TextMessage) m;
assertEquals(groupID, msg.getStringProperty("JMSXGroupID"));
assertEquals("testSupportsJMSXGroupID_1", msg.getText());
}
catch (JMSException e)
{
fail(e);
}
}
/**
* Test that the JMSX property <code>JMSXGroupSeq</code> is supported.
*/
public void testSupportsJMSXGroupSeq()
{
try
{
boolean found = false;
ConnectionMetaData metaData = senderConnection.getMetaData();
Enumeration enumeration = metaData.getJMSXPropertyNames();
while (enumeration.hasMoreElements())
{
String jmsxPropertyName = (String) enumeration.nextElement();
if (jmsxPropertyName.equals("JMSXGroupSeq"))
{
found = true;
}
}
assertTrue("JMSXGroupSeq property is not supported", found);
}
catch (JMSException e)
{
fail(e);
}
}
/**
* Test that the JMSX property <code>JMSXDeliveryCount</code> is supported.
*/
public void testSupportsJMSXDeliveryCount()
{
try
{
boolean found = false;
ConnectionMetaData metaData = senderConnection.getMetaData();
Enumeration enumeration = metaData.getJMSXPropertyNames();
while (enumeration.hasMoreElements())
{
String jmsxPropertyName = (String) enumeration.nextElement();
if (jmsxPropertyName.equals("JMSXDeliveryCount"))
{
found = true;
}
}
assertTrue("JMSXDeliveryCount property is not supported", found);
}
catch (JMSException e)
{
fail(e);
}
}
/**
* Test that the JMSX property <code>JMSXDeliveryCount</code> works.
*/
public void testJMSXDeliveryCount()
{
try
{
senderConnection.stop();
// senderSession has been created as non transacted
// we create it again but as a transacted session
senderSession = senderConnection.createQueueSession(true, 0);
assertEquals(true, senderSession.getTransacted());
// we create again the sender
sender = senderSession.createSender(senderQueue);
senderConnection.start();
receiverConnection.stop();
// receiverSession has been created as non transacted
// we create it again but as a transacted session
receiverSession = receiverConnection.createQueueSession(true, 0);
assertEquals(true, receiverSession.getTransacted());
// we create again the receiver
receiver = receiverSession.createReceiver(receiverQueue);
receiverConnection.start();
// we send a message...
TextMessage message = senderSession.createTextMessage();
message.setText("testJMSXDeliveryCount");
sender.send(message);
// ... and commit the *producer* transaction
senderSession.commit();
// we receive a message...
Message m = receiver.receive(TestConfig.TIMEOUT);
assertTrue(m != null);
assertTrue(m instanceof TextMessage);
TextMessage msg = (TextMessage) m;
// ... which is the one which was sent...
assertEquals("testJMSXDeliveryCount", msg.getText());
// ...and has not been redelivered
assertEquals(false, msg.getJMSRedelivered());
// ... so it has been delivered once
int jmsxDeliveryCount = msg.getIntProperty("JMSXDeliveryCount");
assertEquals(1, jmsxDeliveryCount);
// we rollback the *consumer* transaction
receiverSession.rollback();
// we receive again a message
m = receiver.receive(TestConfig.TIMEOUT);
assertTrue(m != null);
assertTrue(m instanceof TextMessage);
msg = (TextMessage) m;
// ... which is still the one which was sent...
assertEquals("testJMSXDeliveryCount", msg.getText());
// .. but this time, it has been redelivered
assertEquals(true, msg.getJMSRedelivered());
// ... so it has been delivered a second time
jmsxDeliveryCount = msg.getIntProperty("JMSXDeliveryCount");
assertEquals(2, jmsxDeliveryCount);
}
catch (JMSException e)
{
fail(e);
}
catch (Exception e)
{
fail(e);
}
}
/**
* Method to use this class in a Test suite
*/
public static Test suite()
{
return new TestSuite(JMSXPropertyTest.class);
}
public JMSXPropertyTest(String name)
{
super(name);
}
}
More information about the jboss-cvs-commits
mailing list