[jboss-cvs] JBossAS SVN: r64261 - in branches/Branch_4_4/testsuite/src/main/org/jboss/test/jbossmessaging: test and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jul 24 17:13:43 EDT 2007
Author: clebert.suconic at jboss.com
Date: 2007-07-24 17:13:43 -0400 (Tue, 24 Jul 2007)
New Revision: 64261
Modified:
branches/Branch_4_4/testsuite/src/main/org/jboss/test/jbossmessaging/JMSBase.java
branches/Branch_4_4/testsuite/src/main/org/jboss/test/jbossmessaging/test/JBossJMSUnitTest.java
branches/Branch_4_4/testsuite/src/main/org/jboss/test/jbossmessaging/test/Jms11UnitTest.java
branches/Branch_4_4/testsuite/src/main/org/jboss/test/jbossmessaging/test/UnackedUnitTestCase.java
branches/Branch_4_4/testsuite/src/main/org/jboss/test/jbossmessaging/test/XAResourceUnitTestCase.java
Log:
Fixing testcases
Modified: branches/Branch_4_4/testsuite/src/main/org/jboss/test/jbossmessaging/JMSBase.java
===================================================================
--- branches/Branch_4_4/testsuite/src/main/org/jboss/test/jbossmessaging/JMSBase.java 2007-07-24 20:33:53 UTC (rev 64260)
+++ branches/Branch_4_4/testsuite/src/main/org/jboss/test/jbossmessaging/JMSBase.java 2007-07-24 21:13:43 UTC (rev 64261)
@@ -679,11 +679,13 @@
throw new JMSException("Publish must have a MessageCreator set");
creator.setSession(session);
- log.debug("Publishing " + nr + " messages");
+ System.out.println("Publishing " + nr + " messages");
for (int i = 0; i < nr; i++)
{
+ System.out.println("Sending Message");
if (qosConfig != null)
{
+ System.out.println("Sending Message(a)");
((TopicPublisher) producer).publish(creator.createMessage(i),
qosConfig.deliveryMode,
qosConfig.priority,
@@ -691,6 +693,7 @@
}
else
{
+ System.out.println("Sending Message(b)");
((TopicPublisher) producer).publish(creator.createMessage(i));
}
Modified: branches/Branch_4_4/testsuite/src/main/org/jboss/test/jbossmessaging/test/JBossJMSUnitTest.java
===================================================================
--- branches/Branch_4_4/testsuite/src/main/org/jboss/test/jbossmessaging/test/JBossJMSUnitTest.java 2007-07-24 20:33:53 UTC (rev 64260)
+++ branches/Branch_4_4/testsuite/src/main/org/jboss/test/jbossmessaging/test/JBossJMSUnitTest.java 2007-07-24 21:13:43 UTC (rev 64261)
@@ -125,9 +125,24 @@
protected void disconnect() throws Exception
{
- queueConnection.close();
- topicConnection.close();
+ if (queueConnection != null)
+ {
+ queueConnection.close();
+ queueConnection = null;
+ }
+
+ if (topicConnection != null)
+ {
+ topicConnection.close();
+ topicConnection = null;
+ }
}
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ disconnect();
+ }
/**
* Test that messages are ordered by message arrival and priority.
Modified: branches/Branch_4_4/testsuite/src/main/org/jboss/test/jbossmessaging/test/Jms11UnitTest.java
===================================================================
--- branches/Branch_4_4/testsuite/src/main/org/jboss/test/jbossmessaging/test/Jms11UnitTest.java 2007-07-24 20:33:53 UTC (rev 64260)
+++ branches/Branch_4_4/testsuite/src/main/org/jboss/test/jbossmessaging/test/Jms11UnitTest.java 2007-07-24 21:13:43 UTC (rev 64261)
@@ -87,6 +87,13 @@
super(name);
}
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ disconnect();
+
+ }
+
// Emptys out all the messages in a queue
protected void drainQueue() throws Exception
{
@@ -124,8 +131,17 @@
protected void disconnect() throws Exception
{
- queueConnection.close();
- topicConnection.close();
+ if (queueConnection!=null)
+ {
+ queueConnection.close();
+ queueConnection = null;
+ }
+
+ if (topicConnection != null)
+ {
+ topicConnection.close();
+ topicConnection = null;
+ }
}
/**
Modified: branches/Branch_4_4/testsuite/src/main/org/jboss/test/jbossmessaging/test/UnackedUnitTestCase.java
===================================================================
--- branches/Branch_4_4/testsuite/src/main/org/jboss/test/jbossmessaging/test/UnackedUnitTestCase.java 2007-07-24 20:33:53 UTC (rev 64260)
+++ branches/Branch_4_4/testsuite/src/main/org/jboss/test/jbossmessaging/test/UnackedUnitTestCase.java 2007-07-24 21:13:43 UTC (rev 64261)
@@ -591,9 +591,23 @@
protected void tearDown() throws Exception
{
- queueConnection.close();
- topicConnection.close();
- topicDurableConnection.close();
+ if (queueConnection != null)
+ {
+ queueConnection.close();
+ queueConnection = null;
+ }
+
+ if (topicConnection != null)
+ {
+ topicConnection.close();
+ topicConnection = null;
+ }
+
+ if (topicDurableConnection != null)
+ {
+ topicDurableConnection.close();
+ topicDurableConnection = null;
+ }
}
// Emptys out all the messages in a queue
Modified: branches/Branch_4_4/testsuite/src/main/org/jboss/test/jbossmessaging/test/XAResourceUnitTestCase.java
===================================================================
--- branches/Branch_4_4/testsuite/src/main/org/jboss/test/jbossmessaging/test/XAResourceUnitTestCase.java 2007-07-24 20:33:53 UTC (rev 64260)
+++ branches/Branch_4_4/testsuite/src/main/org/jboss/test/jbossmessaging/test/XAResourceUnitTestCase.java 2007-07-24 21:13:43 UTC (rev 64261)
@@ -21,6 +21,7 @@
*/
package org.jboss.test.jbossmessaging.test;
+import javax.jms.ConnectionFactory;
import javax.jms.Message;
import javax.jms.Topic;
import javax.jms.TopicPublisher;
@@ -45,6 +46,7 @@
public class XAResourceUnitTestCase extends JMSTestCase
{
static String XA_TOPIC_FACTORY = "XAConnectionFactory";
+ static String FACTORY = "ConnectionFactory";
static String TEST_TOPIC = "topic/testTopic";
@@ -107,6 +109,7 @@
{
InitialContext context = getInitialContext();
XATopicConnectionFactory factory = (XATopicConnectionFactory) context.lookup(XA_TOPIC_FACTORY);
+
Topic topic = (Topic) context.lookup(TEST_TOPIC);
XATopicConnection connection = factory.createXATopicConnection();
@@ -114,6 +117,12 @@
{
// Set up
XATopicSession xaSession = connection.createXATopicSession();
+
+ // Add the xa resource to xid1
+ MyXid xid1 = new MyXid();
+ XAResource resource = xaSession.getXAResource();
+ resource.start(xid1, XAResource.TMNOFLAGS);
+
TopicSession session = xaSession.getTopicSession();
TopicSubscriber subscriber = session.createSubscriber(topic);
connection.start();
@@ -123,13 +132,18 @@
// Publish a message using "AutoAcknowledge"
publisher.publish(message);
- // Add the xa resource to xid1
- MyXid xid1 = new MyXid();
- XAResource resource = xaSession.getXAResource();
+ resource.end(xid1, XAResource.TMSUCCESS);
+ resource.prepare(xid1);
+ // JBossMessaging only sends the message when a commit is done, while JBossMQ would send messages to consumers on the same session,
+ // doing something differently on the transaction isolation.
+ // Because of that this commit is necessary to complete this testcase.
+ resource.commit(xid1, false);
+
+ xid1 = new MyXid();
resource.start(xid1, XAResource.TMNOFLAGS);
// Receive the message
- message = subscriber.receiveNoWait();
+ message = subscriber.receive(1000);
if (message == null)
fail("No message?");
@@ -139,11 +153,15 @@
// Rollback
resource.rollback(xid1);
-
+
+ xid1 = new MyXid();
+ resource.start(xid1, XAResource.TMNOFLAGS);
// Receive the message using "AutoAcknowledge"
message = subscriber.receiveNoWait();
if (message == null)
fail("No message after rollback?");
+ resource.commit(xid1, true);
+
}
finally
{
@@ -157,10 +175,12 @@
static byte next = 0;
byte[] xid;
+ byte[] branch;
public MyXid()
{
xid = new byte[] { ++next };
+ branch = new byte[] { ++ next };
}
public int getFormatId()
@@ -175,7 +195,7 @@
public byte[] getBranchQualifier()
{
- return null;
+ return branch;
}
}
}
More information about the jboss-cvs-commits
mailing list