[jboss-cvs] JBoss Messaging SVN: r5876 - trunk/tests/joram-tests/src/org/objectweb/jtests/jms/conform/message/properties.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Feb 16 10:55:36 EST 2009
Author: jmesnil
Date: 2009-02-16 10:55:36 -0500 (Mon, 16 Feb 2009)
New Revision: 5876
Modified:
trunk/tests/joram-tests/src/org/objectweb/jtests/jms/conform/message/properties/MessagePropertyTest.java
Log:
rewrite getPropertyNames() tests.
The spec does not specified that the enumeration must be empty for a new created message
Modified: trunk/tests/joram-tests/src/org/objectweb/jtests/jms/conform/message/properties/MessagePropertyTest.java
===================================================================
--- trunk/tests/joram-tests/src/org/objectweb/jtests/jms/conform/message/properties/MessagePropertyTest.java 2009-02-16 15:54:21 UTC (rev 5875)
+++ trunk/tests/joram-tests/src/org/objectweb/jtests/jms/conform/message/properties/MessagePropertyTest.java 2009-02-16 15:55:36 UTC (rev 5876)
@@ -272,7 +272,7 @@
/**
* Test that the <code>Message.getPropertyNames()</code> method does not return
- * the name of the JMS standard header fields (e.g. <code>JMSCorrelationID</code>.
+ * the name of the JMS standard header fields (e.g. <code>JMSCorrelationID</code>).
*/
public void testGetPropertyNames()
{
@@ -281,8 +281,14 @@
Message message = senderSession.createMessage();
message.setJMSCorrelationID("foo");
Enumeration enumeration = message.getPropertyNames();
- assertTrue("sec. 3.5.6 The getPropertyNames method does not return the names of "
- + "the JMS standard header field [e.g. JMSCorrelationID].\n", !enumeration.hasMoreElements());
+ while (enumeration.hasMoreElements())
+ {
+ String propName = (String)enumeration.nextElement();
+ boolean valid = !propName.startsWith("JMS")|| propName.startsWith("JMSX");
+ assertTrue("sec. 3.5.6 The getPropertyNames method does not return the names of "
+ + "the JMS standard header field [e.g. JMSCorrelationID]: " + propName,
+ valid);
+ }
}
catch (JMSException e)
{
@@ -291,10 +297,7 @@
}
/**
- * 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.
+ * Test that the <code>Message.getPropertyNames()</code> methods.
*/
public void testPropertyIteration()
{
@@ -302,10 +305,28 @@
{
Message message = senderSession.createMessage();
Enumeration enumeration = message.getPropertyNames();
- assertTrue("No property yet defined.\n", !enumeration.hasMoreElements());
+ // there can be some properties already defined (e.g. JMSXDeliveryCount)
+ int originalCount = 0;
+ while (enumeration.hasMoreElements())
+ {
+ enumeration.nextElement();
+ originalCount ++;
+ }
message.setDoubleProperty("pi", 3.14159);
enumeration = message.getPropertyNames();
- assertEquals("One property defined of name 'pi'.\n", "pi", (String) enumeration.nextElement());
+ boolean foundPiProperty = false;
+ int newCount = 0;
+ while (enumeration.hasMoreElements())
+ {
+ String propName = (String)enumeration.nextElement();
+ newCount++;
+ if ("pi".equals(propName))
+ {
+ foundPiProperty = true;
+ }
+ }
+ assertEquals(originalCount + 1, newCount);
+ assertTrue(foundPiProperty);
}
catch (JMSException e)
{
More information about the jboss-cvs-commits
mailing list