[jboss-cvs] JBoss Messaging SVN: r2497 - trunk/tests/src/org/jboss/test/messaging/jms.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Feb 28 11:07:58 EST 2007
Author: clebert.suconic at jboss.com
Date: 2007-02-28 11:07:58 -0500 (Wed, 28 Feb 2007)
New Revision: 2497
Modified:
trunk/tests/src/org/jboss/test/messaging/jms/QueueTest.java
Log:
Removing counter as test was meant to be
Modified: trunk/tests/src/org/jboss/test/messaging/jms/QueueTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/QueueTest.java 2007-02-28 15:22:29 UTC (rev 2496)
+++ trunk/tests/src/org/jboss/test/messaging/jms/QueueTest.java 2007-02-28 16:07:58 UTC (rev 2497)
@@ -123,74 +123,56 @@
{
Queue queue = (Queue)ic.lookup("/queue/TestQueue");
- // Maybe we could remove this counter after we are sure this test is fixed!
- // I had to use a counter because this can work in some iterations.
- for (int counter = 0; counter < 20; counter++)
- {
- log.info("Iteration = " + counter);
+ Connection conn1 = cf.createConnection();
- Connection conn1 = cf.createConnection();
+ assertEquals(0, ((JBossConnection)conn1).getServerID());
- assertEquals(0, ((JBossConnection)conn1).getServerID());
+ Connection conn2 = cf.createConnection();
- Connection conn2 = cf.createConnection();
+ assertEquals(0, ((JBossConnection)conn2).getServerID());
- assertEquals(0, ((JBossConnection)conn2).getServerID());
+ try
+ {
+ Session s = conn1.createSession(true, Session.AUTO_ACKNOWLEDGE);
- try
+ MessageProducer p = s.createProducer(queue);
+
+ for (int i = 0; i < 20; i++)
{
- Session s = conn1.createSession(true, Session.AUTO_ACKNOWLEDGE);
+ p.send(s.createTextMessage("message " + i));
+ }
- MessageProducer p = s.createProducer(queue);
+ s.commit();
- for (int i = 0; i < 20; i++)
- {
- p.send(s.createTextMessage("message " + i));
- }
+ Session s2 = conn2.createSession(true, Session.AUTO_ACKNOWLEDGE);
- s.commit();
+ // these next three lines are an anti-pattern but they shouldn't loose any messages
+ MessageConsumer c2 = s2.createConsumer(queue);
+ conn2.start();
+ c2.close();
- Session s2 = conn2.createSession(true, Session.AUTO_ACKNOWLEDGE);
+ c2 = s2.createConsumer(queue);
- // these next three lines are an anti-pattern but they shouldn't loose any messages
- MessageConsumer c2 = s2.createConsumer(queue);
- conn2.start();
- c2.close();
+ for (int i = 0; i < 20; i++)
+ {
+ TextMessage txt = (TextMessage)c2.receive(5000);
+ assertNotNull(txt);
+ assertEquals("message " + i, txt.getText());
+ }
- c2 = s2.createConsumer(queue);
+ assertNull(c2.receive(1000));
- for (int i = 0; i < 20; i++)
- {
- TextMessage txt = (TextMessage)c2.receive(5000);
- assertNotNull(txt);
- assertEquals("message " + i, txt.getText());
- }
-
- // Ovidiu: the test was originally invalid, a locally transacted session that is closed
- // rolls back its transaction. I added s2.commit() to correct the test.
- // JMS 1.1 Specifications, Section 4.3.5:
- // "Closing a connection must roll back the transactions in progress on its
- // transacted sessions*.
- // *) The term 'transacted session' refers to the case where a session's commit and
- // rollback methods are used to demarcate a transaction local to the session. In the
- // case where a session's work is coordinated by an external transaction manager, a
- // session's commit and rollback methods are not used and the result of a closed
- // session's work is determined later by the transaction manager.
-
- s2.commit();
-
- assertNull(c2.receive(1000));
+ s2.commit();
+ }
+ finally
+ {
+ if (conn1 != null)
+ {
+ conn1.close();
}
- finally
+ if (conn2 != null)
{
- if (conn1 != null)
- {
- conn1.close();
- }
- if (conn2 != null)
- {
- conn2.close();
- }
+ conn2.close();
}
}
}
More information about the jboss-cvs-commits
mailing list