[jboss-cvs] JBoss Messaging SVN: r2666 - in branches/Branch_1_0: docs and 19 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu May 10 11:36:45 EDT 2007


Author: timfox
Date: 2007-05-10 11:36:44 -0400 (Thu, 10 May 2007)
New Revision: 2666

Added:
   branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/DurableSubscriptionTest.java
   branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/stress/ConcurrentStopStartStressTest.java
   branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/stress/ConnectionConsumerStressTest.java
   branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/stress/QueueStressTest.java
   branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/stress/TopicStressTest.java
Removed:
   branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/DuplicateClientIDTest.java
   branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/DurableSubscriberTest.java
   branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/crash/CallbackFailureTest.java
   branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/stress/StressTest.java
Modified:
   branches/Branch_1_0/.classpath
   branches/Branch_1_0/build-messaging.xml
   branches/Branch_1_0/build-thirdparty.xml
   branches/Branch_1_0/docs/README.html
   branches/Branch_1_0/src/etc/server/default/deploy/hsqldb-persistence-service.xml
   branches/Branch_1_0/src/etc/server/default/deploy/messaging-service.xml
   branches/Branch_1_0/src/etc/server/default/deploy/mssql-persistence-service.xml
   branches/Branch_1_0/src/etc/server/default/deploy/mysql-persistence-service.xml
   branches/Branch_1_0/src/etc/server/default/deploy/oracle-persistence-service.xml
   branches/Branch_1_0/src/etc/server/default/deploy/postgresql-persistence-service.xml
   branches/Branch_1_0/src/etc/server/default/deploy/sybase-persistence-service.xml
   branches/Branch_1_0/src/etc/xmdesc/ServerPeer-xmbean.xml
   branches/Branch_1_0/src/main/org/jboss/jms/client/container/AsfAspect.java
   branches/Branch_1_0/src/main/org/jboss/jms/client/container/ConnectionAspect.java
   branches/Branch_1_0/src/main/org/jboss/jms/client/container/ConsumerAspect.java
   branches/Branch_1_0/src/main/org/jboss/jms/client/container/SessionAspect.java
   branches/Branch_1_0/src/main/org/jboss/jms/client/container/StateCreationAspect.java
   branches/Branch_1_0/src/main/org/jboss/jms/client/container/TransactionAspect.java
   branches/Branch_1_0/src/main/org/jboss/jms/client/delegate/ClientConnectionFactoryDelegate.java
   branches/Branch_1_0/src/main/org/jboss/jms/client/remoting/CallbackManager.java
   branches/Branch_1_0/src/main/org/jboss/jms/client/state/ConnectionState.java
   branches/Branch_1_0/src/main/org/jboss/jms/client/state/SessionState.java
   branches/Branch_1_0/src/main/org/jboss/jms/server/ConnectionManager.java
   branches/Branch_1_0/src/main/org/jboss/jms/server/ServerPeer.java
   branches/Branch_1_0/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java
   branches/Branch_1_0/src/main/org/jboss/jms/server/connectionmanager/SimpleConnectionManager.java
   branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/ClientDelivery.java
   branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/DeliveryRunnable.java
   branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java
   branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/ServerConnectionFactoryEndpoint.java
   branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java
   branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java
   branches/Branch_1_0/src/main/org/jboss/jms/server/plugin/JDBCChannelMapper.java
   branches/Branch_1_0/src/main/org/jboss/jms/server/remoting/JMSServerInvocationHandler.java
   branches/Branch_1_0/tests/build.xml
   branches/Branch_1_0/tests/smoke/build.xml
   branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/ConnectionTest.java
   branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/MessageConsumerTest.java
   branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/WireFormatTest.java
   branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/XATest.java
   branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/message/JMSExpirationHeaderTest.java
   branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/message/JMSReplyToHeaderTest.java
   branches/Branch_1_0/tests/src/org/jboss/test/messaging/tools/jmx/MockJBossSecurityManager.java
Log:
Merged from 1_0_1_SP into 1_0


Modified: branches/Branch_1_0/.classpath
===================================================================
--- branches/Branch_1_0/.classpath	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/.classpath	2007-05-10 15:36:44 UTC (rev 2666)
@@ -30,13 +30,12 @@
 	<classpathentry kind="lib" path="tests/lib/mysql-connector-java-3.1.13-bin.jar"/>
 	<classpathentry kind="lib" path="thirdparty/jgroups/lib/jgroups.jar"/>
 	<classpathentry kind="lib" path="thirdparty/apache-log4j/lib/log4j.jar"/>
-	<classpathentry sourcepath="/home/clebert/workspaces/jboss-head/aop/src/main" kind="lib" path="thirdparty/jboss/aop/lib/jboss-aop.jar"/>
+	<classpathentry kind="lib" path="thirdparty/jboss/aop/lib/jboss-aop.jar" sourcepath="/home/clebert/workspaces/jboss-head/aop/src/main"/>
 	<classpathentry kind="lib" path="thirdparty/junit/lib/junit.jar"/>
 	<classpathentry kind="lib" path="thirdparty/jboss/profiler/jvmti/lib/jboss-profiler-jvmti.jar"/>
 	<classpathentry kind="lib" path="thirdparty/hsqldb/lib/hsqldb.jar"/>
 	<classpathentry kind="lib" path="thirdparty/apache-logging/lib/commons-logging.jar"/>
-	<classpathentry kind="var" path="ANT_HOME/lib/ant-junit.jar"/>
-	<classpathentry sourcepath="/JBossRemoting" kind="lib" path="thirdparty/jboss/remoting/lib/jboss-remoting.jar"/>
+	<classpathentry kind="lib" path="thirdparty/jboss/remoting/lib/jboss-remoting.jar" sourcepath="/JBossRemoting"/>
 	<classpathentry kind="lib" path="thirdparty/jboss/serialization/lib/jboss-serialization.jar"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry kind="lib" path="thirdparty/sun-javacc/lib/javacc.jar"/>
@@ -58,9 +57,9 @@
 	<classpathentry kind="lib" path="thirdparty/retrotranslator/lib/retrotranslator-runtime.jar"/>
 	<classpathentry kind="lib" path="thirdparty/retrotranslator/lib/retrotranslator-transformer.jar"/>
 	<classpathentry kind="lib" path="thirdparty/trove/lib/trove.jar"/>
-	<classpathentry kind="lib" path="thirdparty/jboss/jbossts/lib/jbossjta.jar"/>
-	<classpathentry kind="lib" path="thirdparty/jboss/common-logging-log4j/lib/jboss-logging-log4j.jar"/>
-	<classpathentry kind="lib" path="thirdparty/jboss/common-core/lib/jboss-common-core.jar"/>
 	<classpathentry kind="lib" path="thirdparty/jboss/common-logging-spi/lib/jboss-logging-spi.jar"/>
+	<classpathentry kind="lib" path="thirdparty/jboss/common-core/lib/jboss-common-core.jar"/>
+	<classpathentry kind="var" path="ANT_HOME/lib/ant.jar"/>
+	<classpathentry kind="var" path="ANT_HOME/lib/ant-junit.jar"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>

Modified: branches/Branch_1_0/build-messaging.xml
===================================================================
--- branches/Branch_1_0/build-messaging.xml	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/build-messaging.xml	2007-05-10 15:36:44 UTC (rev 2666)
@@ -47,9 +47,9 @@
 
    <property name="messaging.version.major" value="1"/>
    <property name="messaging.version.minor" value="0"/>
-   <property name="messaging.version.revision" value="2"/>
-   <property name="messaging.version.incrementing" value="7"/>
-   <property name="messaging.version.tag" value="CR1"/>
+   <property name="messaging.version.revision" value="1"/>
+   <property name="messaging.version.incrementing" value="13"/>
+   <property name="messaging.version.tag" value="SP5"/>
    <property name="messaging.version.name" value=""/>
    <property name="messaging.version.cvstag" value="JBossMessaging_1_0_2_CR1"/>
    <property name="module.name" value="messaging"/>

Modified: branches/Branch_1_0/build-thirdparty.xml
===================================================================
--- branches/Branch_1_0/build-thirdparty.xml	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/build-thirdparty.xml	2007-05-10 15:36:44 UTC (rev 2666)
@@ -87,12 +87,12 @@
       <componentref name="javassist" version="3.2.0.GA"/>
       <componentref name="jgroups" version="2.3"/>
       <componentref name="trove" version="1.0.2"/>
-      <componentref name="jboss/common-core" version="2.0.2.GA"/>
+      <componentref name="jboss/common-core" version="2.0.3.GA"/>
       <componentref name="jboss/common-logging-log4j" version="2.0.2.GA"/>
       <componentref name="jboss/common-logging-spi" version="2.0.2.GA"/>
       <componentref name="jboss/aop" version="1.5.0.GA"/>
       <componentref name="jboss/serialization" version="1.0.3.GA"/>
-      <componentref name="jboss/remoting" version="2.2.0.Alpha7"/>
+      <componentref name="jboss/remoting" version="2.2.0.SP4"/>
       <componentref name="jboss/jbossts" version="4.2.2.GA"/>
 
       <!-- Need this otherwise project doesn't build in Eclipse -->

Modified: branches/Branch_1_0/docs/README.html
===================================================================
--- branches/Branch_1_0/docs/README.html	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/docs/README.html	2007-05-10 15:36:44 UTC (rev 2666)
@@ -26,84 +26,28 @@
 <br>
 <br>
 <h2>Summary of Changes</h2>
-This service pack fixes several major bugs present in 1.0.1.SP2 and
+This service pack fixes several major bugs present in 1.0.1.SP4 and
 previous releases.<br>
 <br>
-The most serious is <a
- href="http://jira.jboss.org/jira/browse/JBMESSAGING-721">http://jira.jboss.org/jira/browse/JBMESSAGING-721</a>,
-which was causing message redelivery not to function properly. This bug
-fix alone should justify an upgrade to 1.0.1.SP4, especially if you use
-Message Driven Beans and Container Managed Transactions.<br>
-<br>
-Another potentially dangerous misbehavior is
-<a href="http://jira.jboss.org/jira/browse/JBMESSAGING-787">http://jira.jboss.org/jira/browse/JBMESSAGING-787</a>
-that was causing
-long-running invocations (such as sending a large transaction to the
-server) to time out inadvertently. The root cause was identified to be
-<a href="http://jira.jboss.org/jira/browse/JBREM-691">http://jira.jboss.org/jira/browse/JBREM-691</a>.
-The new
-Remoting library incorporated by 1.0.1.SP4 contains the fix for this
-bug.<br>
-<br>
-Other bugs fixes address the following 1.0.1.SP2 problems:<br>
+
+Release Notes - JBoss Messaging - Version 1.0.1.SP5
+    
+<h2>Bug</h2>
 <ul>
-  <li>Broken QueueBrowser behavior (<a
- href="http://jira.jboss.org/jira/browse/JBMESSAGING-803">http://jira.jboss.org/jira/browse/JBMESSAGING-803</a>)</li>
-  <li>Non-compliant client ID behavior - the previous version
-allowed simultaneous clients with same client ID
-(<a href="http://jira.jboss.org/jira/browse/JBMESSAGING-791">http://jira.jboss.org/jira/browse/JBMESSAGING-791</a>)</li>
-  <li>Incorrect handling of the replyTo property for persistent
-messages
-in some situations (<a
- href="http://jira.jboss.org/jira/browse/JBMESSAGING-757">http://jira.jboss.org/jira/browse/JBMESSAGING-757</a>)</li>
-  <li>Corruption of the security context in managed environment (<a
- href="http://jira.jboss.org/jira/browse/JBMESSAGING-807">http://jira.jboss.org/jira/browse/JBMESSAGING-807</a>)</li>
-  <li>Potential deadlock during the client initialization (<a
- href="http://jira.jboss.org/jira/browse/JBMESSAGING-800">http://jira.jboss.org/jira/browse/JBMESSAGING-800</a>)</li>
-  <li>Memory leaks (<a
- href="http://jira.jboss.org/jira/browse/JBMESSAGING-638">http://jira.jboss.org/jira/browse/JBMESSAGING-638</a>)</li>
+<li>[<a href='http://jira.jboss.com/jira/browse/JBMESSAGING-622'>JBMESSAGING-622</a>] - JBossMessage.setJMSReplyTo() method does not allow to set up nulls</li>
+<li>[<a href='http://jira.jboss.com/jira/browse/JBMESSAGING-817'>JBMESSAGING-817</a>] - Db2 Persistence in Jboss</li>
+<li>[<a href='http://jira.jboss.com/jira/browse/JBMESSAGING-828'>JBMESSAGING-828</a>] - Use of pre configured ClientID on the database will change the pre configured clientID on the datasource</li>
+<li>[<a href='http://jira.jboss.com/jira/browse/JBMESSAGING-836'>JBMESSAGING-836</a>] - Deadlock on ServerConnectionEndpoint </li>
+<li>[<a href='http://jira.jboss.com/jira/browse/JBMESSAGING-851'>JBMESSAGING-851</a>] - Issue with remoting MAX_RETRIES</li>
+<li>[<a href='http://jira.jboss.com/jira/browse/JBMESSAGING-852'>JBMESSAGING-852</a>] - Unacked message state is not cleaned up after failure in ack</li>
+<li>[<a href='http://jira.jboss.com/jira/browse/JBMESSAGING-864'>JBMESSAGING-864</a>] - Memory leak when using JCA layer and creating consumer on each send</li>
+<li>[<a href='http://jira.jboss.com/jira/browse/JBMESSAGING-885'>JBMESSAGING-885</a>] - Connecting to two JBoss messaging servers causes interference</li>
+<li>[<a href='http://jira.jboss.com/jira/browse/JBMESSAGING-886'>JBMESSAGING-886</a>] - Client unable to reconnect to JBoss 1.0.1.SP4 after restart</li>
+<li>[<a href='http://jira.jboss.com/jira/browse/JBMESSAGING-929'>JBMESSAGING-929</a>] - Implement a proper fix for JBMESSAGING-928</li>
+<li>[<a href='http://jira.jboss.com/jira/browse/JBMESSAGING-944'>JBMESSAGING-944</a>] - Messages ending up on different connections when there is more than one server</li>
+<li>[<a href='http://jira.jboss.com/jira/browse/JBMESSAGING-950'>JBMESSAGING-950</a>] - Unacked messages on recovery with JCA adaptor</li>
+<li>[<a href='http://jira.jboss.com/jira/browse/JBMESSAGING-954'>JBMESSAGING-954</a>] - We should be able to have multiple connections with the same client id....</li>
 </ul>
-<br>
-<h2>Release Notes</h2>
-<h2 style="margin-left: 40px;">Bugs</h2>
-<ul style="margin-left: 40px;">
-  <li>[<a href="http://jira.jboss.com/jira/browse/JBMESSAGING-417">JBMESSAGING-417</a>]
-- JMS Client does not exit</li>
-  <li>[<a href="http://jira.jboss.com/jira/browse/JBMESSAGING-638">JBMESSAGING-638</a>]
-- Potential memory leak when using 2pc via JCA adapter.</li>
-  <li>[<a href="http://jira.jboss.com/jira/browse/JBMESSAGING-664">JBMESSAGING-664</a>]
-- The 4.0.5.GA jnlp installer smoke test fails</li>
-  <li>[<a href="http://jira.jboss.com/jira/browse/JBMESSAGING-721">JBMESSAGING-721</a>]
-- Message redelivery doesn't work </li>
-  <li>[<a href="http://jira.jboss.com/jira/browse/JBMESSAGING-757">JBMESSAGING-757</a>]
-- JDBCPersistenceManager incorrectly detects if a replytoId was null
-when restoring a message from a ResultSet</li>
-  <li>[<a href="http://jira.jboss.com/jira/browse/JBMESSAGING-787">JBMESSAGING-787</a>]
-- Invocations time out because remoting mismanages client invokers,
-sending bussines traffic over client invokers with small timeout</li>
-  <li>[<a href="http://jira.jboss.com/jira/browse/JBMESSAGING-791">JBMESSAGING-791</a>]
-- Duplicates clientIDs are not throwing InvalidClientIDException</li>
-  <li>[<a href="http://jira.jboss.com/jira/browse/JBMESSAGING-800">JBMESSAGING-800</a>]
-- Deadlock in aop stack deployment</li>
-  <li>[<a href="http://jira.jboss.com/jira/browse/JBMESSAGING-803">JBMESSAGING-803</a>]
-- QueueBrowser doesn't refresh the content of its Enumeration on the
-second getEnumeration() call</li>
-  <li>[<a href="http://jira.jboss.com/jira/browse/JBMESSAGING-807">JBMESSAGING-807</a>]
-- security context switch after sending a message</li>
-  <li>[<a href="http://jira.jboss.com/jira/browse/JBMESSAGING-821">JBMESSAGING-821</a>]
-- org.jboss.test.messaging.core.paging tests fail in-VM on Linux</li>
-  <li>[<a href="http://jira.jboss.com/jira/browse/JBMESSAGING-824">JBMESSAGING-824</a>]
-- queue smoke test fails</li>
-</ul>
-<h2 style="margin-left: 40px;">Tasks</h2>
-<ul style="margin-left: 40px;">
-  <li>[<a href="http://jira.jboss.com/jira/browse/JBMESSAGING-755">JBMESSAGING-755</a>]
-- Bring mdb-failure's README.html up to date</li>
-  <li>[<a href="http://jira.jboss.com/jira/browse/JBMESSAGING-756">JBMESSAGING-756</a>]
-- Enable mdb-failure smoke test so it will run with the smoke test suite<br>
-  </li>
-</ul>
-<br>
-<hr style="width: 100%; height: 2px;">
+                            
 </body>
 </html>

Modified: branches/Branch_1_0/src/etc/server/default/deploy/hsqldb-persistence-service.xml
===================================================================
--- branches/Branch_1_0/src/etc/server/default/deploy/hsqldb-persistence-service.xml	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/src/etc/server/default/deploy/hsqldb-persistence-service.xml	2007-05-10 15:36:44 UTC (rev 2666)
@@ -32,6 +32,9 @@
       <depends optional-attribute-name="TransactionManager">jboss:service=TransactionManager</depends>
       <attribute name="DataSource">java:/DefaultDS</attribute>
       <attribute name="CreateTablesOnStartup">true</attribute>
+      <attribute name="SqlProperties"><![CDATA[
+POPULATE.TABLES.1=INSERT INTO JMS_USER (USERID,PASSWD,CLIENTID) VALUES ('dilbert','dogbert','dilbert-id')
+      ]]></attribute>
    </mbean>         
    
 </server>
\ No newline at end of file

Modified: branches/Branch_1_0/src/etc/server/default/deploy/messaging-service.xml
===================================================================
--- branches/Branch_1_0/src/etc/server/default/deploy/messaging-service.xml	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/src/etc/server/default/deploy/messaging-service.xml	2007-05-10 15:36:44 UTC (rev 2666)
@@ -14,7 +14,7 @@
 
       <constructor>
          <!-- ServerPeerID -->
-         <arg type="java.lang.String" value="server.0" />
+         <arg type="java.lang.String" value="0" />
          <!-- DefaultQueueJNDIContext -->
          <arg type="java.lang.String" value="/queue" />
          <!-- DefaultTopicJNDIContext -->

Modified: branches/Branch_1_0/src/etc/server/default/deploy/mssql-persistence-service.xml
===================================================================
--- branches/Branch_1_0/src/etc/server/default/deploy/mssql-persistence-service.xml	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/src/etc/server/default/deploy/mssql-persistence-service.xml	2007-05-10 15:36:44 UTC (rev 2666)
@@ -81,6 +81,8 @@
 SELECT_ID_FOR_DESTINATION=SELECT ID FROM JMS_CHANNEL_MAPPING WHERE TYPE=? AND JMS_DEST_NAME=?
 SELECT_DURABLE_SUB=SELECT JMS_DEST_NAME, ID, SELECTOR, NO_LOCAL FROM JMS_CHANNEL_MAPPING WHERE CLIENT_ID=? AND JMS_SUB_NAME=?
 SELECT_SUBSCRIPTIONS_FOR_TOPIC=SELECT ID, CLIENT_ID, JMS_SUB_NAME, SELECTOR, NO_LOCAL FROM JMS_CHANNEL_MAPPING WHERE TYPE='D' AND JMS_DEST_NAME=?
+POPULATE.TABLES.1=INSERT INTO JMS_USER (USERID,PASSWD,CLIENTID) VALUES ('dilbert','dogbert','dilbert-id')
+      ]]></attribute>
            ]]></attribute>
    </mbean>
 

Modified: branches/Branch_1_0/src/etc/server/default/deploy/mysql-persistence-service.xml
===================================================================
--- branches/Branch_1_0/src/etc/server/default/deploy/mysql-persistence-service.xml	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/src/etc/server/default/deploy/mysql-persistence-service.xml	2007-05-10 15:36:44 UTC (rev 2666)
@@ -81,6 +81,7 @@
 SELECT_ID_FOR_DESTINATION=SELECT ID FROM JMS_CHANNEL_MAPPING WHERE TYPE=? AND JMS_DEST_NAME=?
 SELECT_DURABLE_SUB=SELECT JMS_DEST_NAME, ID, SELECTOR, NO_LOCAL FROM JMS_CHANNEL_MAPPING WHERE CLIENT_ID=? AND JMS_SUB_NAME=?            
 SELECT_SUBSCRIPTIONS_FOR_TOPIC=SELECT ID, CLIENT_ID, JMS_SUB_NAME, SELECTOR, NO_LOCAL FROM JMS_CHANNEL_MAPPING WHERE TYPE='D' AND JMS_DEST_NAME=?      
+PPOPULATE.TABLES.1=INSERT INTO JMS_USER (USERID,PASSWD,CLIENTID) VALUES ('dilbert','dogbert','dilbert-id')
       ]]></attribute>
    </mbean>
       

Modified: branches/Branch_1_0/src/etc/server/default/deploy/oracle-persistence-service.xml
===================================================================
--- branches/Branch_1_0/src/etc/server/default/deploy/oracle-persistence-service.xml	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/src/etc/server/default/deploy/oracle-persistence-service.xml	2007-05-10 15:36:44 UTC (rev 2666)
@@ -81,6 +81,7 @@
 SELECT_ID_FOR_DESTINATION=SELECT ID FROM JMS_CHANNEL_MAPPING WHERE TYPE=? AND JMS_DEST_NAME=?
 SELECT_DURABLE_SUB=SELECT JMS_DEST_NAME, ID, SELECTOR, NO_LOCAL FROM JMS_CHANNEL_MAPPING WHERE CLIENT_ID=? AND JMS_SUB_NAME=?            
 SELECT_SUBSCRIPTIONS_FOR_TOPIC=SELECT ID, CLIENT_ID, JMS_SUB_NAME, SELECTOR, NO_LOCAL FROM JMS_CHANNEL_MAPPING WHERE TYPE='D' AND JMS_DEST_NAME=?      
+POPULATE.TABLES.1=INSERT INTO JMS_USER (USERID,PASSWD,CLIENTID) VALUES ('dilbert','dogbert','dilbert-id')
       ]]></attribute>
    </mbean>
 </server>
\ No newline at end of file

Modified: branches/Branch_1_0/src/etc/server/default/deploy/postgresql-persistence-service.xml
===================================================================
--- branches/Branch_1_0/src/etc/server/default/deploy/postgresql-persistence-service.xml	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/src/etc/server/default/deploy/postgresql-persistence-service.xml	2007-05-10 15:36:44 UTC (rev 2666)
@@ -81,6 +81,7 @@
 SELECT_ID_FOR_DESTINATION=SELECT ID FROM JMS_CHANNEL_MAPPING WHERE TYPE=? AND JMS_DEST_NAME=?
 SELECT_DURABLE_SUB=SELECT JMS_DEST_NAME, ID, SELECTOR, NO_LOCAL FROM JMS_CHANNEL_MAPPING WHERE CLIENT_ID=? AND JMS_SUB_NAME=?
 SELECT_SUBSCRIPTIONS_FOR_TOPIC=SELECT ID, CLIENT_ID, JMS_SUB_NAME, SELECTOR, NO_LOCAL FROM JMS_CHANNEL_MAPPING WHERE TYPE='D' AND JMS_DEST_NAME=?
+POPULATE.TABLES.1=INSERT INTO JMS_USER (USERID,PASSWD,CLIENTID) VALUES ('dilbert','dogbert','dilbert-id')
            ]]></attribute>
    </mbean>
 

Modified: branches/Branch_1_0/src/etc/server/default/deploy/sybase-persistence-service.xml
===================================================================
--- branches/Branch_1_0/src/etc/server/default/deploy/sybase-persistence-service.xml	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/src/etc/server/default/deploy/sybase-persistence-service.xml	2007-05-10 15:36:44 UTC (rev 2666)
@@ -93,6 +93,7 @@
 SELECT_ID_FOR_DESTINATION=SELECT ID FROM JMS_CHANNEL_MAPPING WHERE TYPE=? AND JMS_DEST_NAME=?
 SELECT_DURABLE_SUB=SELECT JMS_DEST_NAME, ID, SELECTOR, NO_LOCAL FROM JMS_CHANNEL_MAPPING WHERE CLIENT_ID=? AND JMS_SUB_NAME=?
 SELECT_SUBSCRIPTIONS_FOR_TOPIC=SELECT ID, CLIENT_ID, JMS_SUB_NAME, SELECTOR, NO_LOCAL FROM JMS_CHANNEL_MAPPING WHERE TYPE='D' AND JMS_DEST_NAME=?      
+POPULATE.TABLES.1=INSERT INTO JBM_USER (USER_ID,PASSWD,CLIENTID) VALUES ('dilbert','dogbert','dilbert-id')
       ]]>
 		</attribute>
 	</mbean>

Modified: branches/Branch_1_0/src/etc/xmdesc/ServerPeer-xmbean.xml
===================================================================
--- branches/Branch_1_0/src/etc/xmdesc/ServerPeer-xmbean.xml	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/src/etc/xmdesc/ServerPeer-xmbean.xml	2007-05-10 15:36:44 UTC (rev 2666)
@@ -189,7 +189,7 @@
       </parameter>
       <return-type>java.lang.String</return-type>
    </operation>
-   
+
    <operation>
       <description>
          Creates a queue with the specified name/JNDI name and paging parameters. The corresponding destination service will be instantiated, created and started.
@@ -214,12 +214,56 @@
       <parameter>
          <name>downCacheSize</name>
          <type>int</type>
-      </parameter>            
+      </parameter>
       <return-type>java.lang.String</return-type>
-   </operation>   
+   </operation>
 
    <operation>
       <description>
+         Creates a queue with the specified name/JNDI name. The corresponding destination service will be instantiated, created and started.
+      </description>
+      <name>deployQueue</name>
+      <parameter>
+         <name>name</name>
+         <type>java.lang.String</type>
+      </parameter>
+      <parameter>
+         <name>jndiName</name>
+         <type>java.lang.String</type>
+      </parameter>
+      <return-type>java.lang.String</return-type>
+   </operation>
+
+   <operation>
+      <description>
+         Creates a queue with the specified name/JNDI name and paging parameters. The corresponding destination service will be instantiated, created and started.
+      </description>
+      <name>deployQueue</name>
+      <parameter>
+         <name>name</name>
+         <type>java.lang.String</type>
+      </parameter>
+      <parameter>
+         <name>jndiName</name>
+         <type>java.lang.String</type>
+      </parameter>
+      <parameter>
+         <name>fullSize</name>
+         <type>int</type>
+      </parameter>
+      <parameter>
+         <name>pageSize</name>
+         <type>int</type>
+      </parameter>
+      <parameter>
+         <name>downCacheSize</name>
+         <type>int</type>
+      </parameter>
+      <return-type>java.lang.String</return-type>
+   </operation>
+
+   <operation>
+      <description>
          Stops, destroys and unregisters from the MBean server the corresponding destination service, but only if the destination in question was created programatically with createQueue(). Returns true on success. Returns false if the destination does not exist or was not created programatically. A deployed destination must be undeployed to achieve the same effect.
       </description>
       <name>destroyQueue</name>
@@ -254,12 +298,40 @@
       <parameter>
          <name>downCacheSize</name>
          <type>int</type>
-      </parameter>         
+      </parameter>
       <return-type>java.lang.String</return-type>
    </operation>
-   
+
    <operation>
       <description>
+         Creates a topic with the specified name/JNDI name. The corresponding destination service will be instantiated, created and started.
+      </description>
+      <name>deployTopic</name>
+      <parameter>
+         <name>name</name>
+         <type>java.lang.String</type>
+      </parameter>
+      <parameter>
+         <name>jndiName</name>
+         <type>java.lang.String</type>
+      </parameter>
+      <parameter>
+         <name>fullSize</name>
+         <type>int</type>
+      </parameter>
+      <parameter>
+         <name>pageSize</name>
+         <type>int</type>
+      </parameter>
+      <parameter>
+         <name>downCacheSize</name>
+         <type>int</type>
+      </parameter>
+      <return-type>java.lang.String</return-type>
+   </operation>
+
+   <operation>
+      <description>
          Creates a topic with the specified name/JNDI name and paging parameters. The corresponding destination service will be instantiated, created and started.
       </description>
       <name>createTopic</name>
@@ -272,10 +344,26 @@
          <type>java.lang.String</type>
       </parameter>
       <return-type>java.lang.String</return-type>
-   </operation>   
+   </operation>
 
    <operation>
       <description>
+         Creates a topic with the specified name/JNDI name and paging parameters. The corresponding destination service will be instantiated, created and started.
+      </description>
+      <name>deployTopic</name>
+      <parameter>
+         <name>name</name>
+         <type>java.lang.String</type>
+      </parameter>
+      <parameter>
+         <name>jndiName</name>
+         <type>java.lang.String</type>
+      </parameter>
+      <return-type>java.lang.String</return-type>
+   </operation>
+
+   <operation>
+      <description>
          Stops, destroys and unregisters from the MBean server the corresponding destination service, but only if the destination in question was created programatically with createTopic(). Returns true on success. Returns false if the destination does not exist or was not created programatically. A deployed destination must be undeployed to achieve the same effect.
       </description>
       <name>destroyTopic</name>

Modified: branches/Branch_1_0/src/main/org/jboss/jms/client/container/AsfAspect.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/client/container/AsfAspect.java	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/src/main/org/jboss/jms/client/container/AsfAspect.java	2007-05-10 15:36:44 UTC (rev 2666)
@@ -66,9 +66,6 @@
    //The list of messages that get processed on a call to run()
    protected LinkedList msgs = new LinkedList();
    
-   //The distinguished message listener
-   protected MessageListener sessionListener;
-   
    protected SessionState state;
    
    // Static --------------------------------------------------------
@@ -89,9 +86,9 @@
       {
          throw new IllegalStateException("Cannot set a null MessageListener on the session");
       }
-      
-      sessionListener = listener;
-      
+
+      getSessionState(invocation).setDistinguishedListener(listener);
+
       return null;
    }
    
@@ -99,7 +96,7 @@
    {
       if (trace) { log.trace("getMessageListener()"); }
       
-      return sessionListener;
+      return getSessionState(invocation).getDistinguishedListener();
    }
    
    public Object handleCreateConnectionConsumer(Invocation invocation) throws Throwable
@@ -164,7 +161,7 @@
 
          if (trace) { log.trace("sending " + holder.msg + " to the message listener" ); }
          
-         MessageCallbackHandler.callOnMessage(del, sessionListener, holder.consumerID, false,
+         MessageCallbackHandler.callOnMessage(del, getSessionState(invocation).getDistinguishedListener(), holder.consumerID, false,
                                               holder.msg, ackMode, holder.maxDeliveries);                          
       }
       
@@ -179,7 +176,15 @@
    
    private SessionState getSessionState(Invocation inv)
    {
-      return (SessionState)((DelegateSupport)inv.getTargetObject()).getState();
+      if (state != null)
+      {
+         return state;
+      }
+      else
+      {
+         state = (SessionState)((DelegateSupport)inv.getTargetObject()).getState();
+         return state;
+      }
    }
 
    // Inner Classes --------------------------------------------------

Modified: branches/Branch_1_0/src/main/org/jboss/jms/client/container/ConnectionAspect.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/client/container/ConnectionAspect.java	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/src/main/org/jboss/jms/client/container/ConnectionAspect.java	2007-05-10 15:36:44 UTC (rev 2666)
@@ -176,10 +176,10 @@
       state.getRemotingConnection().stop();
       
       // Remove reference to resource manager
-      ResourceManagerFactory.instance.checkInResourceManager(state.getServerID());
+      ResourceManagerFactory.instance.checkInResourceManager(String.valueOf(state.getServerID()));
       
       // Remove reference to message id generator
-      MessageIdGeneratorFactory.instance.checkInGenerator(state.getServerID());
+      MessageIdGeneratorFactory.instance.checkInGenerator(String.valueOf(state.getServerID()));
       
       return ret;
    }

Modified: branches/Branch_1_0/src/main/org/jboss/jms/client/container/ConsumerAspect.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/client/container/ConsumerAspect.java	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/src/main/org/jboss/jms/client/container/ConsumerAspect.java	2007-05-10 15:36:44 UTC (rev 2666)
@@ -89,7 +89,7 @@
       sessionState.addCallbackHandler(messageHandler);
       
       CallbackManager cm = connectionState.getRemotingConnection().getCallbackManager();
-      cm.registerHandler(consumerID, messageHandler);
+      cm.registerHandler(connectionState.getServerID(), consumerID, messageHandler);
          
       consumerState.setMessageCallbackHandler(messageHandler);
       
@@ -118,7 +118,7 @@
       sessionState.removeCallbackHandler(consumerState.getMessageCallbackHandler());
 
       CallbackManager cm = connectionState.getRemotingConnection().getCallbackManager();
-      cm.unregisterHandler(consumerState.getConsumerID());
+      cm.unregisterHandler(connectionState.getServerID(), consumerState.getConsumerID());
             
       return res;
    }      

Modified: branches/Branch_1_0/src/main/org/jboss/jms/client/container/SessionAspect.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/client/container/SessionAspect.java	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/src/main/org/jboss/jms/client/container/SessionAspect.java	2007-05-10 15:36:44 UTC (rev 2666)
@@ -42,7 +42,7 @@
 
 /**
  * This aspect handles JMS session related logic
- * 
+ *
  * This aspect is PER_VM
  *
  * @author <a href="mailto:tim.fox at jboss.com>Tim Fox</a>
@@ -53,25 +53,26 @@
 public class SessionAspect
 {
    // Constants -----------------------------------------------------
-   
+
    private static final Logger log = Logger.getLogger(SessionAspect.class);
-   
+
    // Attributes ----------------------------------------------------
-   
+
    private boolean trace = log.isTraceEnabled();
-   
+
    // Static --------------------------------------------------------
-   
+
    // Constructors --------------------------------------------------
-   
+
    // Public --------------------------------------------------------
 
+   
    public Object handleClosing(Invocation invocation) throws Throwable
    {
       MethodInvocation mi = (MethodInvocation)invocation;
       SessionState state = getState(invocation);
       SessionDelegate del = (SessionDelegate)mi.getTargetObject();
-      
+
       int ackMode = state.getAcknowledgeMode();
 
       // select eligible acknowledgments
@@ -83,7 +84,7 @@
          if (ackMode == Session.AUTO_ACKNOWLEDGE ||
              ackMode == Session.DUPS_OK_ACKNOWLEDGE)
          {
-            acks.add(ack);            
+            acks.add(ack);
          }
          else
          {
@@ -91,7 +92,7 @@
          }
          i.remove();
       }
-      
+
       // On closing we acknowlege any AUTO_ACKNOWLEDGE or DUPS_OK_ACKNOWLEDGE, since the session
       // might have closed before the onMessage had finished executing.
       // We cancel any client ack or transactional, we do this explicitly so we can pass the updated
@@ -112,7 +113,7 @@
 
 
    public Object handleClose(Invocation invocation) throws Throwable
-   {      
+   {
       Object res = invocation.invokeNext();
 
       // We must explicitly shutdown the executor
@@ -122,14 +123,14 @@
 
       return res;
    }
-   
+
    public Object handlePreDeliver(Invocation invocation) throws Throwable
-   { 
+   {
       MethodInvocation mi = (MethodInvocation)invocation;
       SessionState state = getState(invocation);
-      
+
       int ackMode = state.getAcknowledgeMode();
-      
+
       if (ackMode == Session.CLIENT_ACKNOWLEDGE ||
           ackMode == Session.AUTO_ACKNOWLEDGE ||
           ackMode == Session.DUPS_OK_ACKNOWLEDGE)
@@ -137,52 +138,52 @@
          // We collect acknowledgments (and not transact them) for CLIENT, AUTO and DUPS_OK
 
          SessionDelegate del = (SessionDelegate)mi.getTargetObject();
-         
+
          // We store the ack in a list for later acknowledgement or recovery
-    
+
          Object[] args = mi.getArguments();
          MessageProxy mp = (MessageProxy)args[0];
          int consumerID = ((Integer)args[1]).intValue();
          AckInfo info = new AckInfo(mp, consumerID);
-         
+
          state.getToAck().add(info);
-         
+
          if (trace) { log.trace("ack mode is " + Util.acknowledgmentModeToString(ackMode)+ ", acknowledged on " + del); }
       }
 
       return invocation.invokeNext();
    }
-   
+
    public Object handleAcknowledgeAll(Invocation invocation) throws Throwable
-   {    
+   {
       MethodInvocation mi = (MethodInvocation)invocation;
       SessionState state = getState(invocation);
       SessionDelegate del = (SessionDelegate)mi.getTargetObject();
-    
+
       if (!state.getToAck().isEmpty())
-      {                  
+      {
          del.acknowledgeBatch(state.getToAck());
-      
+
          state.getToAck().clear();
       }
-        
+
       return null;
    }
-   
+
    public Object handlePostDeliver(Invocation invocation) throws Throwable
-   { 
+   {
       MethodInvocation mi = (MethodInvocation)invocation;
       SessionState state = getState(invocation);
-      
+
       int ackMode = state.getAcknowledgeMode();
-      
+
       boolean cancel = ((Boolean)mi.getArguments()[0]).booleanValue();
-      
+
       if (cancel && ackMode != Session.AUTO_ACKNOWLEDGE && ackMode != Session.DUPS_OK_ACKNOWLEDGE)
       {
          throw new IllegalStateException("Ack mode must be AUTO_ACKNOWLEDGE or DUPS_OK_ACKNOWLEDGE");
       }
-      
+
       if (ackMode == Session.AUTO_ACKNOWLEDGE ||
           ackMode == Session.DUPS_OK_ACKNOWLEDGE)
       {
@@ -194,27 +195,37 @@
          if (!state.isRecoverCalled())
          {
             if (trace) { log.trace("acknowledging NON-transactionally"); }
-                        
+
             List acks = state.getToAck();
-            
+
             // Sanity check
             if (acks.size() != 1)
             {
                throw new IllegalStateException("Should only be one entry in list. " +
                                                "There are " + acks.size());
             }
-            
+
             AckInfo ack = (AckInfo)acks.get(0);
-            
-            if (cancel)
+
+            try
             {
-               sd.cancelDeliveries(acks);
+               if (cancel)
+               {
+                  sd.cancelDeliveries(acks);
+               }
+               else
+               {
+                  sd.acknowledge(ack);
+               }
             }
-            else
+            finally
             {
-               sd.acknowledge(ack);
+               //We clear the state in a finally so if an ack/cancel fails then
+               //we don't get a knock on exception on the next ack since we haven't
+               //cleared the state:
+               //http://jira.jboss.org/jira/browse/JBMESSAGING-852
+               state.getToAck().clear();
             }
-            state.getToAck().clear();
          }
          else
          {
@@ -226,39 +237,39 @@
 
       return null;
    }
-                  
+
    /*
     * Called when session.recover is called
     */
    public Object handleRecover(Invocation invocation) throws Throwable
    {
       if (trace) { log.trace("recover called"); }
-      
+
       MethodInvocation mi = (MethodInvocation)invocation;
-            
+
       SessionState state = getState(invocation);
-      
+
       int ackMode = state.getAcknowledgeMode();
-         
+
       if (ackMode == Session.SESSION_TRANSACTED)
       {
          throw new IllegalStateException("Cannot recover a transacted session");
       }
-      
+
       if (trace) { log.trace("recovering the session"); }
-       
+
       //Call redeliver
       SessionDelegate del = (SessionDelegate)mi.getTargetObject();
-      
+
       del.redeliver(state.getToAck());
-            
+
       state.getToAck().clear();
 
       state.setRecoverCalled(true);
-      
-      return null;  
+
+      return null;
    }
-   
+
    /**
     * Redelivery occurs in two situations:
     *
@@ -282,35 +293,35 @@
     *
     * So on rollback we do session recovery (local redelivery) in the same as if session.recover()
     * was called.
-    * 
+    *
     * There is a conflict here though. It seems a CTS test requires messages to be available to
     * OTHER sessions on rollback - see CTSMiscellaneousTest.testContestedQueueOnRollback(), which
     * seems in direct contradiction to the spec.
-    * 
+    *
     * In order to satisfy the test, on session recovery, if there are no local consumers available
     * to consume the message, we cancel the message back to the channel.
     */
    public Object handleRedeliver(Invocation invocation) throws Throwable
    {
       if (trace) { log.trace(this + " redeliver called"); }
-      
+
       MethodInvocation mi = (MethodInvocation)invocation;
       SessionState state = getState(invocation);
-            
+
       // We put the messages back in the front of their appropriate consumer buffers and set
       // JMSRedelivered to true.
-      
+
       List toRedeliver = (List)mi.getArguments()[0];
       LinkedList toCancel = new LinkedList();
-      
+
       // Need to be recovered in reverse order.
       for (int i = toRedeliver.size() - 1; i >= 0; i--)
       {
          AckInfo info = (AckInfo)toRedeliver.get(i);
-         MessageProxy proxy = info.getMessage();        
-         
+         MessageProxy proxy = info.getMessage();
+
          MessageCallbackHandler handler = state.getCallbackHandler(info.getConsumerID());
-              
+
          if (handler == null)
          {
             // This is ok. The original consumer has closed, this message wil get cancelled back
@@ -325,36 +336,36 @@
             if (trace) { log.trace("Adding message " + proxy + " back to front of buffer"); }
             
             handler.addToFrontOfBuffer(proxy);
-         }                                    
+         }
       }
-      
+
       if (!toCancel.isEmpty())
       {
          // Cancel the messages that can't be redelivered locally
-         
+
          SessionDelegate del = (SessionDelegate)mi.getTargetObject();
          del.cancelDeliveries(toCancel);
       }
-            
-      return null;  
+
+      return null;
    }
-   
+
    public Object handleGetXAResource(Invocation invocation) throws Throwable
    {
       return getState(invocation).getXAResource();
    }
-   
+
    public Object handleGetTransacted(Invocation invocation) throws Throwable
    {
       return getState(invocation).isTransacted() ? Boolean.TRUE : Boolean.FALSE;
    }
-   
+
    public Object handleGetAcknowledgeMode(Invocation invocation) throws Throwable
    {
       return new Integer(getState(invocation).getAcknowledgeMode());
    }
-   
 
+
    // Class YYY overrides -------------------------------------------
 
    // Protected -----------------------------------------------------
@@ -362,13 +373,13 @@
    // Package Private -----------------------------------------------
 
    // Private -------------------------------------------------------
-   
+
    private SessionState getState(Invocation inv)
    {
       return (SessionState)((DelegateSupport)inv.getTargetObject()).getState();
    }
 
    // Inner Classes -------------------------------------------------
-   
+
 }
 

Modified: branches/Branch_1_0/src/main/org/jboss/jms/client/container/StateCreationAspect.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/client/container/StateCreationAspect.java	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/src/main/org/jboss/jms/client/container/StateCreationAspect.java	2007-05-10 15:36:44 UTC (rev 2666)
@@ -81,11 +81,11 @@
       ClientConnectionDelegate connectionDelegate = (ClientConnectionDelegate)inv.invokeNext();
       connectionDelegate.init();
 
-      String serverID = cfd.getServerID();
+      int serverID = cfd.getServerID();
 
-      ResourceManager rm = ResourceManagerFactory.instance.checkOutResourceManager(serverID);
+      ResourceManager rm = ResourceManagerFactory.instance.checkOutResourceManager(String.valueOf(serverID));
       MessageIdGenerator gen =
-         MessageIdGeneratorFactory.instance.checkOutGenerator(serverID, cfd);
+         MessageIdGeneratorFactory.instance.checkOutGenerator(String.valueOf(serverID), cfd);
 
       ConnectionState connectionState =
          new ConnectionState(serverID, connectionDelegate,

Modified: branches/Branch_1_0/src/main/org/jboss/jms/client/container/TransactionAspect.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/client/container/TransactionAspect.java	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/src/main/org/jboss/jms/client/container/TransactionAspect.java	2007-05-10 15:36:44 UTC (rev 2666)
@@ -64,6 +64,7 @@
 
    // Public --------------------------------------------------------
 
+   
    public Object handleClose(Invocation invocation) throws Throwable
    {
       Object res = invocation.invokeNext();

Modified: branches/Branch_1_0/src/main/org/jboss/jms/client/delegate/ClientConnectionFactoryDelegate.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/client/delegate/ClientConnectionFactoryDelegate.java	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/src/main/org/jboss/jms/client/delegate/ClientConnectionFactoryDelegate.java	2007-05-10 15:36:44 UTC (rev 2666)
@@ -68,7 +68,7 @@
 
    protected String serverLocatorURI;
    protected Version serverVersion;
-   protected String serverID;
+   protected int serverID;
    protected boolean clientPing;
 
    private boolean trace;
@@ -78,7 +78,7 @@
    // Constructors --------------------------------------------------
 
    public ClientConnectionFactoryDelegate(int objectID, String serverLocatorURI,
-                                          Version serverVersion, String serverID,
+                                          Version serverVersion, int serverID,
                                           boolean clientPing)
    {
       super(objectID);
@@ -246,7 +246,7 @@
       return serverVersion;
    }
 
-   public String getServerID()
+   public int getServerID()
    {
       return serverID;
    }

Modified: branches/Branch_1_0/src/main/org/jboss/jms/client/remoting/CallbackManager.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/client/remoting/CallbackManager.java	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/src/main/org/jboss/jms/client/remoting/CallbackManager.java	2007-05-10 15:36:44 UTC (rev 2666)
@@ -28,6 +28,7 @@
 
 import org.jboss.jms.server.endpoint.ClientDelivery;
 import org.jboss.jms.server.remoting.MessagingMarshallable;
+import org.jboss.logging.Logger;
 import org.jboss.remoting.InvocationRequest;
 import org.jboss.remoting.ServerInvocationHandler;
 import org.jboss.remoting.ServerInvoker;
@@ -50,20 +51,26 @@
 public class CallbackManager implements ServerInvocationHandler
 {
    protected Map callbackHandlers;
-
+   
+   private static final Logger log = Logger.getLogger(CallbackManager.class);
+   
    public CallbackManager()
    {
       callbackHandlers = new ConcurrentReaderHashMap();
    }
    
-   public void registerHandler(int consumerID, MessageCallbackHandler handler)
+   public void registerHandler(int serverID, int consumerID, MessageCallbackHandler handler)
    {
-      callbackHandlers.put(new Integer(consumerID), handler);
+      Long lookup = calcLookup(serverID, consumerID);
+            
+      callbackHandlers.put(lookup, handler);
    }
    
-   public void unregisterHandler(int consumerID)
+   public void unregisterHandler(int serverID, int consumerID)
    {
-      callbackHandlers.remove(new Integer(consumerID));
+      Long lookup = calcLookup(serverID, consumerID);
+      
+      callbackHandlers.remove(lookup);
    }
    
    public void addListener(InvokerCallbackHandler arg0)
@@ -78,10 +85,18 @@
       
       int consumerID = dr.getConsumerID();
       
+      int serverID = dr.getServerID();
+      
+      Long lookup = calcLookup(serverID, consumerID);
+         
       List msgs = dr.getMessages();
 
+      //In 1.0.x there is only one callback server per protocol
+      //So we need to key on the server id too to make sure messages make it to the correct
+      //connection
+      
       MessageCallbackHandler handler =
-         (MessageCallbackHandler)callbackHandlers.get(new Integer(consumerID));
+         (MessageCallbackHandler)callbackHandlers.get(lookup);
       
       if (handler == null)
       {
@@ -102,5 +117,18 @@
    public void setMBeanServer(MBeanServer arg0)
    {
    }
+   
+   private Long calcLookup(int serverId, int consumerId)
+   {
+      long id1 = serverId;
+      
+      id1 <<= 32;
+             
+      long id2 = (consumerId + Integer.MIN_VALUE);
+        
+      long lookup = id1 | id2;
+      
+      return new Long(lookup);
+   }
 
 }

Modified: branches/Branch_1_0/src/main/org/jboss/jms/client/state/ConnectionState.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/client/state/ConnectionState.java	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/src/main/org/jboss/jms/client/state/ConnectionState.java	2007-05-10 15:36:44 UTC (rev 2666)
@@ -52,11 +52,11 @@
    
    private MessageIdGenerator idGenerator;
    
-   private String serverID;
+   private int serverID;
    
    private Version versionToUse;
     
-   public ConnectionState(String serverID, ConnectionDelegate delegate,
+   public ConnectionState(int serverID, ConnectionDelegate delegate,
                           JMSRemotingConnection remotingConnection, Version versionToUse,
                           ResourceManager rm, MessageIdGenerator gen)
       throws Exception
@@ -98,7 +98,7 @@
       return versionToUse;
    }
    
-   public String getServerID()
+   public int getServerID()
    {
       return serverID;
    }

Modified: branches/Branch_1_0/src/main/org/jboss/jms/client/state/SessionState.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/client/state/SessionState.java	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/src/main/org/jboss/jms/client/state/SessionState.java	2007-05-10 15:36:44 UTC (rev 2666)
@@ -34,6 +34,7 @@
 
 import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
 import EDU.oswego.cs.dl.util.concurrent.QueuedExecutor;
+import javax.jms.MessageListener;
 
 /**
  * State corresponding to a session. This state is acessible inside aspects/interceptors.
@@ -60,6 +61,9 @@
    
    private boolean recoverCalled;
 
+   //The distinguished message listener
+   protected MessageListener sessionListener;
+
    // List<AckInfo>
    private List toAck;
    
@@ -98,6 +102,17 @@
       callbackHandlers = new HashMap();
    }
 
+   public MessageListener getDistinguishedListener()
+   {
+      return this.sessionListener;
+   }
+
+   public void setDistinguishedListener(MessageListener listener)
+   {
+      this.sessionListener = listener;
+   }
+
+
    /**
     * @return List<AckInfo>
     */

Modified: branches/Branch_1_0/src/main/org/jboss/jms/server/ConnectionManager.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/server/ConnectionManager.java	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/src/main/org/jboss/jms/server/ConnectionManager.java	2007-05-10 15:36:44 UTC (rev 2666)
@@ -43,8 +43,6 @@
     */
    ConnectionEndpoint unregisterConnection(String jmsClientVMId, String remotingClientSessionID);
 
-   void handleClientFailure(String remotingSessionID);
-
    boolean containsSession(String remotingClientSessionID);
 
    /**
@@ -55,4 +53,7 @@
     * @return List<ConnectionEndpoint>
     */
    List getActiveConnections();
+   
+   void handleClientFailure(String remotingSessionID);
+
 }

Modified: branches/Branch_1_0/src/main/org/jboss/jms/server/ServerPeer.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/server/ServerPeer.java	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/src/main/org/jboss/jms/server/ServerPeer.java	2007-05-10 15:36:44 UTC (rev 2666)
@@ -107,6 +107,8 @@
    private int maxDeliveryAttempts = 10;
    
    private String dlqName;
+   
+   private int serverIdAsInt;
 
    // wired components
 
@@ -145,6 +147,16 @@
                      String defaultQueueJNDIContext,
                      String defaultTopicJNDIContext) throws Exception
    {
+      try
+      {
+         serverIdAsInt = Integer.valueOf(serverPeerID).intValue();
+      }
+      catch (NumberFormatException e)
+      {
+         throw new IllegalArgumentException("Server peer id must be a valid integer");
+      }
+      
+      
       this.serverPeerID = serverPeerID;
       this.defaultQueueJNDIContext = defaultQueueJNDIContext;
       this.defaultTopicJNDIContext = defaultTopicJNDIContext;
@@ -228,6 +240,10 @@
    
          initializeRemoting(mbeanServer);
 
+         //Now everything is started we can tell the invocation handler to start handling invocations
+         //We do this right at the end otherwise it can start handling invocations before we are properly started
+         JMSServerInvocationHandler.setClosed(false);
+         
          started = true;
    
          log.info("JBoss Messaging " + getVersion().getProviderVersion() + " server [" +
@@ -251,6 +267,11 @@
          log.debug(this + " stopping");
    
          started = false;
+         
+         //Tell the invocation handler we are closed - this is so we don't attempt to handle
+         //any invocations when we are in a partial closing down state - which can give strange
+         //"object not found with id" exceptions and stuff like that
+         JMSServerInvocationHandler.setClosed(true);
    
          // stop the internal components
          memoryManager.stop();
@@ -435,7 +456,7 @@
       catch (Throwable t)
       {
          throw ExceptionUtil.handleJMXInvocation(t, this + " createQueue");
-      } 
+      }
    }
 
    public String createQueue(String name, String jndiName, int fullSize, int pageSize, int downCacheSize) throws Exception
@@ -447,9 +468,35 @@
       catch (Throwable t)
       {
          throw ExceptionUtil.handleJMXInvocation(t, this + " createQueue(2)");
-      } 
+      }
    }
 
+   // Added this method just to have ServerPeer compatible between 1.0 and 1.2
+   public String deployQueue(String name, String jndiName) throws Exception
+   {
+      try
+      {
+         return createDestinationDefault(true, name, jndiName);
+      }
+      catch (Throwable t)
+      {
+         throw ExceptionUtil.handleJMXInvocation(t, this + " createQueue");
+      }
+   }
+
+   // Added this method just to have ServerPeer compatible between 1.0 and 1.2
+   public String deployQueue(String name, String jndiName, int fullSize, int pageSize, int downCacheSize) throws Exception
+   {
+      try
+      {
+         return createDestination(true, name, jndiName, fullSize, pageSize, downCacheSize);
+      }
+      catch (Throwable t)
+      {
+         throw ExceptionUtil.handleJMXInvocation(t, this + " createQueue(2)");
+      }
+   }
+
    public boolean destroyQueue(String name) throws Exception
    {
       try
@@ -471,9 +518,35 @@
       catch (Throwable t)
       {
          throw ExceptionUtil.handleJMXInvocation(t, this + " createTopic");
-      } 
+      }
    }
 
+   // Added this method just to have ServerPeer compatible between 1.0 and 1.2
+   public String deployTopic(String name, String jndiName) throws Exception
+   {
+      try
+      {
+         return createDestinationDefault(false, name, jndiName);
+      }
+      catch (Throwable t)
+      {
+         throw ExceptionUtil.handleJMXInvocation(t, this + " createTopic");
+      }
+   }
+
+   // Added this method just to have ServerPeer compatible between 1.0 and 1.2
+   public String deployTopic(String name, String jndiName, int fullSize, int pageSize, int downCacheSize) throws Exception
+   {
+      try
+      {
+         return createDestination(false, name, jndiName, fullSize, pageSize, downCacheSize);
+      }
+      catch (Throwable t)
+      {
+         throw ExceptionUtil.handleJMXInvocation(t, this + " createTopic(2)");
+      }
+   }
+
    public String createTopic(String name, String jndiName, int fullSize, int pageSize, int downCacheSize) throws Exception
    {
       try
@@ -483,7 +556,7 @@
       catch (Throwable t)
       {
          throw ExceptionUtil.handleJMXInvocation(t, this + " createTopic(2)");
-      } 
+      }
    }
 
    public boolean destroyTopic(String name) throws Exception
@@ -624,29 +697,10 @@
       return queuedExecutorPool;
    }
    
-   public void checkClientID(String clientID) throws Exception
-   {   
-      // verify the clientID is unique
    
-      // JMS 1.1 Specifications, Section 4.3.2:
-      // "By definition, the client state identified by a client identifier can be 'in use' by
-      // only one client at a time. A JMS provider must prevent concurrently executing clients
-      // from using it."
-         
-      if (clientID != null)
-      {      
-         List conns = connectionManager.getActiveConnections();
-      
-         for(Iterator i = conns.iterator(); i.hasNext(); )
-         {
-            ServerConnectionEndpoint sce = (ServerConnectionEndpoint)i.next();
-            if (clientID != null && clientID.equals(sce.getClientID()))
-            {
-               throw new InvalidClientIDException(
-                  "Client ID '" + clientID + "' already used by " + sce);
-            }
-         }
-      }
+   public int getServerIDAsInt()
+   {
+      return serverIdAsInt;
    }
 
    public String toString()

Modified: branches/Branch_1_0/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java	2007-05-10 15:36:44 UTC (rev 2666)
@@ -92,7 +92,7 @@
 
       ClientConnectionFactoryDelegate delegate =
          new ClientConnectionFactoryDelegate(id, locatorURI, serverPeer.getVersion(),
-                                             serverPeer.getServerPeerID(), clientPing);
+                                             serverPeer.getServerIDAsInt(), clientPing);
 
       ConnectionFactoryAdvised connFactoryAdvised;
       

Modified: branches/Branch_1_0/src/main/org/jboss/jms/server/connectionmanager/SimpleConnectionManager.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/server/connectionmanager/SimpleConnectionManager.java	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/src/main/org/jboss/jms/server/connectionmanager/SimpleConnectionManager.java	2007-05-10 15:36:44 UTC (rev 2666)
@@ -130,6 +130,32 @@
       return null;
    }
    
+   
+
+   public synchronized List getActiveConnections()
+   {
+      // I will make a copy to avoid ConcurrentModification
+      ArrayList list = new ArrayList();
+      list.addAll(activeConnectionEndpoints);
+      return list;
+   }
+
+   /*
+    * Used in testing only
+    */
+   public synchronized boolean containsSession(String remotingClientSessionID)
+   {
+      return sessions.containsKey(remotingClientSessionID);
+   }
+   
+   /*
+    * Used in testing only
+    */
+   public synchronized Map getClients()
+   {
+      return Collections.unmodifiableMap(jmsClients);
+   }
+   
    public synchronized void handleClientFailure(String remotingSessionID)
    {
       String jmsClientId = (String)sessions.get(remotingSessionID);
@@ -186,30 +212,6 @@
       } 
    }
 
-   public synchronized List getActiveConnections()
-   {
-      // I will make a copy to avoid ConcurrentModification
-      ArrayList list = new ArrayList();
-      list.addAll(activeConnectionEndpoints);
-      return list;
-   }
-
-   /*
-    * Used in testing only
-    */
-   public synchronized boolean containsSession(String remotingClientSessionID)
-   {
-      return sessions.containsKey(remotingClientSessionID);
-   }
-   
-   /*
-    * Used in testing only
-    */
-   public synchronized Map getClients()
-   {
-      return Collections.unmodifiableMap(jmsClients);
-   }
-
    // ConnectionListener --------------------------------------------
 
    /**
@@ -248,6 +250,8 @@
    // Protected -----------------------------------------------------
 
    // Private -------------------------------------------------------
+   
+   
 
    // Inner classes -------------------------------------------------
 

Modified: branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/ClientDelivery.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/ClientDelivery.java	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/ClientDelivery.java	2007-05-10 15:36:44 UTC (rev 2666)
@@ -57,6 +57,8 @@
    private List msgs;
          
    private int consumerID;
+   
+   private int serverID;
     
    // Constructors --------------------------------------------------
    
@@ -64,11 +66,13 @@
    {      
    }
 
-   public ClientDelivery(List msgs, int consumerID)
+   public ClientDelivery(List msgs, int consumerID, int serverID)
    {
       this.msgs = msgs;
       
-      this.consumerID = consumerID;      
+      this.consumerID = consumerID; 
+      
+      this.serverID = serverID;
    }
   
    // Externalizable implementation
@@ -78,6 +82,8 @@
    {
       out.writeInt(consumerID);
       
+      out.writeInt(serverID);
+      
       out.writeInt(msgs.size());
       
       Iterator iter = msgs.iterator();
@@ -98,6 +104,8 @@
    {
       consumerID = in.readInt();
       
+      serverID = in.readInt();
+      
       int numMessages = in.readInt();
       
       msgs = new ArrayList(numMessages);
@@ -129,6 +137,11 @@
    {
       return consumerID;
    }
+   
+   public int getServerID()
+   {
+      return serverID;
+   }
 
    // Package protected ---------------------------------------------
    

Modified: branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/DeliveryRunnable.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/DeliveryRunnable.java	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/DeliveryRunnable.java	2007-05-10 15:36:44 UTC (rev 2666)
@@ -93,9 +93,8 @@
             log.trace("Failed to deliver message", t);
          }
          
-         ConnectionManager mgr = connection.getServerPeer().getConnectionManager();
-         
-         mgr.handleClientFailure(connection.getRemotingClientSessionId());
+         // When the leaser detects the connection broken it will close the connection
+
       }
    }
 

Modified: branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java	2007-05-10 15:36:44 UTC (rev 2666)
@@ -242,8 +242,6 @@
             throw new IllegalStateException("Cannot set clientID, already set as " + this.clientID);
          }
 
-         serverPeer.checkClientID(clientID);
-
          log.debug(this + "setting client ID to " + clientID);
 
          this.clientID = clientID;
@@ -751,16 +749,13 @@
    
    private void setStarted(boolean s) throws Throwable
    {
-      synchronized(sessions)
+      for(Iterator i = new HashSet(sessions.values()).iterator(); i.hasNext(); )
       {
-         for (Iterator i = sessions.values().iterator(); i.hasNext(); )
-         {
-            ServerSessionEndpoint sd = (ServerSessionEndpoint)i.next();
-            sd.setStarted(s);
-         }
-         started = s;
+         ServerSessionEndpoint sd = (ServerSessionEndpoint)i.next();
+         sd.setStarted(s);
       }
-   }   
+      started = s;
+   }
    
    private void processTransaction(TxState txState, Transaction tx) throws Throwable
    {

Modified: branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/ServerConnectionFactoryEndpoint.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/ServerConnectionFactoryEndpoint.java	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/ServerConnectionFactoryEndpoint.java	2007-05-10 15:36:44 UTC (rev 2666)
@@ -113,25 +113,25 @@
 
          // We don't need the SubjectContext on thread local anymore, clean it up
          SecurityAssociation.popSubjectContext();
-
+         
+         String clientIDUsed = clientID;
+         
          // see if there is a preconfigured client id for the user
          if (username != null)
          {
             String preconfClientID =
                serverPeer.getChannelMapperDelegate().getPreConfiguredClientID(username);
-
+            
             if (preconfClientID != null)
             {
-               clientID = preconfClientID;
+               clientIDUsed = preconfClientID;
             }
          }
 
-         serverPeer.checkClientID(clientID);
-
          // create the corresponding "server-side" connection endpoint and register it with the
          // server peer's ClientManager
          ServerConnectionEndpoint endpoint =
-            new ServerConnectionEndpoint(serverPeer, clientID, username, password, prefetchSize,
+            new ServerConnectionEndpoint(serverPeer, clientIDUsed, username, password, prefetchSize,
                                          defaultTempQueueFullSize, defaultTempQueuePageSize, defaultTempQueueDownCacheSize);
 
          int connectionID = endpoint.getConnectionID();

Modified: branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java	2007-05-10 15:36:44 UTC (rev 2666)
@@ -375,6 +375,18 @@
             {
                channel.removeAllReferences();
             }
+
+            //Fix for http://jira.jboss.org/jira/browse/JBMESSAGING-864
+            //When this is closed, if there are no deliveries then we can remove immediately
+            //otherwise we must wait to session close
+            //This is because it is perfectly valid to close a consumer then ack
+            //it's deliveries later on the session (e.g. when it commits or client ack)
+            //In the case of JCA which caches sessions, there won't be any deliveries
+            //so we will close immediately - preventing a leak
+            if (deliveries.isEmpty())
+            {
+               remove();
+            }
             
             closed = true;
          }
@@ -790,7 +802,7 @@
                log.trace(sb.toString());
             }
             
-            ClientDelivery del = new ClientDelivery(list, id);
+            ClientDelivery del = new ClientDelivery(list, id, connection.getServerPeer().getServerIDAsInt());
 
             // TODO How can we ensure that messages for the same consumer aren't delivered
             // concurrently to the same consumer on different threads?
@@ -813,12 +825,9 @@
          }
          catch(Throwable t)
          {
-            log.warn("Failed to deliver the message to the client. See the server log for more details.");
             log.debug(ServerConsumerEndpoint.this + " failed to deliver the message to the client.", t);
-
-            ConnectionManager mgr = connection.getServerPeer().getConnectionManager();
-
-            mgr.handleClientFailure(connection.getRemotingClientSessionId());
+            
+            //When the leaser detects the connection broken it will close the connection
          }
       }
 

Modified: branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java	2007-05-10 15:36:44 UTC (rev 2666)
@@ -208,6 +208,13 @@
                else
                {
                   if (trace) { log.trace("subscription " + subscriptionName + " already exists"); }
+                  
+                  //Can't create subscriber if there is already an active subscriber
+                  if (subscription.iterator().hasNext())
+                  {
+                  	throw new IllegalStateException("Cannot create a subscriber on the durable subscription since it already has subscriber(s)");
+
+                  }
    
                   // From javax.jms.Session Javadoc (and also JMS 1.1 6.11.1):
                   // A client can change an existing durable subscription by creating a durable
@@ -812,22 +819,19 @@
     */
    protected void setStarted(boolean s) throws Throwable
    {
-      synchronized(consumers)
+      for(Iterator i = new HashSet(consumers.values()).iterator(); i.hasNext(); )
       {
-         for(Iterator i = consumers.values().iterator(); i.hasNext(); )
+         ServerConsumerEndpoint sce = (ServerConsumerEndpoint)i.next();
+         if (s)
          {
-            ServerConsumerEndpoint sce = (ServerConsumerEndpoint)i.next();
-            if (s)
-            {
-               sce.start();
-            }
-            else
-            {
-               sce.stop();
-            }
+            sce.start();
          }
+         else
+         {
+            sce.stop();
+         }
       }
-   }   
+   }
 
    // Private -------------------------------------------------------
 

Modified: branches/Branch_1_0/src/main/org/jboss/jms/server/plugin/JDBCChannelMapper.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/server/plugin/JDBCChannelMapper.java	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/src/main/org/jboss/jms/server/plugin/JDBCChannelMapper.java	2007-05-10 15:36:44 UTC (rev 2666)
@@ -680,7 +680,6 @@
             {
                clientID = rs.getString(1);
             }
-
             return clientID;
          }
          catch (SQLException e)
@@ -1213,8 +1212,10 @@
          Map.Entry entry = (Map.Entry) i.next();
          String key = (String) entry.getKey();
          if (key.startsWith("POPULATE.TABLES."))
+         {
             populateTables.add(entry.getValue());
-      }
+         }
+      }      
    }
 
    protected void createSchema() throws Exception
@@ -1266,8 +1267,9 @@
             Statement st = null;
             try
             {
-               nextQry = (String) iter.next();
-               st = conn.createStatement();
+               nextQry = (String) iter.next();               
+               st = conn.createStatement();      
+               
                st.executeUpdate(nextQry);
             }
             catch (SQLException ignored)

Modified: branches/Branch_1_0/src/main/org/jboss/jms/server/remoting/JMSServerInvocationHandler.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/server/remoting/JMSServerInvocationHandler.java	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/src/main/org/jboss/jms/server/remoting/JMSServerInvocationHandler.java	2007-05-10 15:36:44 UTC (rev 2666)
@@ -31,6 +31,7 @@
 import org.jboss.aop.joinpoint.InvocationResponse;
 import org.jboss.aop.joinpoint.MethodInvocation;
 import org.jboss.aop.util.PayloadKey;
+import org.jboss.jms.util.MessagingJMSException;
 import org.jboss.logging.Logger;
 import org.jboss.messaging.util.Util;
 import org.jboss.remoting.InvocationRequest;
@@ -62,7 +63,15 @@
    protected Map callbackHandlers;
    
    private boolean trace;
+
+   // We need some way the server peer can call the invocation handler to make it open/closed
+   private static boolean closed = true;
    
+   public static synchronized void setClosed(boolean closed)
+   {
+      JMSServerInvocationHandler.closed = closed;
+   }
+   
    // Constructors --------------------------------------------------
 
    public JMSServerInvocationHandler()
@@ -89,46 +98,54 @@
    {      
       if (trace) { log.trace("invoking " + invocation); }
       
-      MessagingMarshallable mm = (MessagingMarshallable)invocation.getParameter();
-      
-      MethodInvocation i = (MethodInvocation)mm.getLoad();
-            
-      // put the version number into meta data for use in the InjectionInterceptor
-      i.getMetaData().addMetaData(MetaDataConstants.JMS,
-                                  MetaDataConstants.VERSION_NUMBER,
-                                  new Byte(mm.getVersion()),
-                                  PayloadKey.TRANSIENT);
-            
-      String s =
-         (String)i.getMetaData(MetaDataConstants.JMS, MetaDataConstants.REMOTING_SESSION_ID);
-      
-      if (s != null)
-      {
-         Object callbackHandler = null;
-         synchronized(callbackHandlers)
+      synchronized (JMSServerInvocationHandler.class)
+      {         
+         if (closed)
          {
-            callbackHandler = callbackHandlers.get(s);
+            throw new MessagingJMSException("Cannot handle invocation since messaging server is not active (it is either starting up or shutting down)");
          }
-         if (callbackHandler != null)
+      
+         MessagingMarshallable mm = (MessagingMarshallable)invocation.getParameter();
+         
+         MethodInvocation i = (MethodInvocation)mm.getLoad();
+               
+         // put the version number into meta data for use in the InjectionInterceptor
+         i.getMetaData().addMetaData(MetaDataConstants.JMS,
+                                     MetaDataConstants.VERSION_NUMBER,
+                                     new Byte(mm.getVersion()),
+                                     PayloadKey.TRANSIENT);
+               
+         String s =
+            (String)i.getMetaData(MetaDataConstants.JMS, MetaDataConstants.REMOTING_SESSION_ID);
+         
+         if (s != null)
          {
-            log.debug("found calllback handler for remoting session " + Util.guidToString(s));
-            
-            i.getMetaData().addMetaData(MetaDataConstants.JMS,
-                                        MetaDataConstants.CALLBACK_HANDLER,
-                                        callbackHandler, PayloadKey.TRANSIENT);
+            Object callbackHandler = null;
+            synchronized(callbackHandlers)
+            {
+               callbackHandler = callbackHandlers.get(s);
+            }
+            if (callbackHandler != null)
+            {
+               log.debug("found calllback handler for remoting session " + Util.guidToString(s));
+               
+               i.getMetaData().addMetaData(MetaDataConstants.JMS,
+                                           MetaDataConstants.CALLBACK_HANDLER,
+                                           callbackHandler, PayloadKey.TRANSIENT);
+            }
+            else
+            {
+               throw new javax.jms.IllegalStateException("Cannot find callback handler " +
+                                                         "for session id " + s);
+            }
          }
-         else
-         {
-            throw new javax.jms.IllegalStateException("Cannot find callback handler " +
-                                                      "for session id " + s);
-         }
+   
+         InvocationResponse resp = JMSDispatcher.instance.invoke(i);
+         
+         byte version = mm.getVersion();
+         
+         return new MessagingMarshallable(version, resp.getResponse());
       }
-
-      InvocationResponse resp = JMSDispatcher.instance.invoke(i);
-      
-      byte version = mm.getVersion();
-      
-      return new MessagingMarshallable(version, resp.getResponse());
    }
 
    public void addListener(InvokerCallbackHandler callbackHandler)

Modified: branches/Branch_1_0/tests/build.xml
===================================================================
--- branches/Branch_1_0/tests/build.xml	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/tests/build.xml	2007-05-10 15:36:44 UTC (rev 2666)
@@ -57,7 +57,7 @@
         Functional tests.
    -->
 
-   <property name="functional.tests.database" value="mysql"/>
+   <property name="functional.tests.database" value="hsqldb"/>
    <property name="functional.tests.serialization" value="jboss"/>
 
    <!--
@@ -550,6 +550,7 @@
                <exclude name="org/jboss/test/messaging/jms/MemLeakTest.class"/>
                <exclude name="org/jboss/test/messaging/jms/ManifestTest.class"/>
                <exclude name="org/jboss/test/messaging/jms/JCAWrapperTest.class"/>
+               <exclude name="org/jboss/test/messaging/jms/XATest.class"/>
                <exclude name="org/jboss/test/thirdparty/jbosssx/SecurityAssociationTest.class"/>
             </fileset>
          </batchtest>
@@ -651,10 +652,6 @@
 
       <antcall target="start-rmi-server"/>
 
-      <antcall target="crash-test">
-          <param name="crash.test.name" value="org.jboss.test.messaging.jms.crash.CallbackFailureTest"/>
-      </antcall>
-
    </target>
 
 

Modified: branches/Branch_1_0/tests/smoke/build.xml
===================================================================
--- branches/Branch_1_0/tests/smoke/build.xml	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/tests/smoke/build.xml	2007-05-10 15:36:44 UTC (rev 2666)
@@ -80,7 +80,7 @@
       -->
 
       <antcall target="installation-test">
-         <param name="jboss.home" value="${jboss401sp1.home}"/>
+         <param name="jboss.home" value="${jboss401SP1.home}"/>
          <param name="run.secure-socket.example" value="false"/>
       </antcall>
 
@@ -102,11 +102,12 @@
          <param name="run.secure-socket.example" value="false"/>
       </antcall>
 
+<!--
       <antcall target="installation-test">
          <param name="jboss.home" value="${jboss403-installer.home}"/>
          <param name="run.secure-socket.example" value="false"/>
       </antcall>
-
+-->
       <!--
            4.0.3SP1
       -->

Modified: branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/ConnectionTest.java
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/ConnectionTest.java	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/ConnectionTest.java	2007-05-10 15:36:44 UTC (rev 2666)
@@ -145,16 +145,16 @@
       
       assertTrue(rm1 == rm2);
       
-      assertTrue(ResourceManagerFactory.instance.containsResourceManager(state2.getServerID()));
+      assertTrue(ResourceManagerFactory.instance.containsResourceManager(String.valueOf(state2.getServerID())));
       
       conn1.close();
       
       //Check reference counting
-      assertTrue(ResourceManagerFactory.instance.containsResourceManager(state2.getServerID()));
+      assertTrue(ResourceManagerFactory.instance.containsResourceManager(String.valueOf(state2.getServerID())));
            
       conn2.close();
       
-      assertFalse(ResourceManagerFactory.instance.containsResourceManager(state2.getServerID()));     
+      assertFalse(ResourceManagerFactory.instance.containsResourceManager(String.valueOf(state2.getServerID())));     
    }
    
    public void testMessageIDGeneratorsForSameServer() throws Exception
@@ -179,16 +179,16 @@
       
       assertTrue(gen1 == gen2);
       
-      assertTrue(MessageIdGeneratorFactory.instance.containsMessageIdGenerator(state2.getServerID()));
+      assertTrue(MessageIdGeneratorFactory.instance.containsMessageIdGenerator(String.valueOf(state2.getServerID())));
       
       conn1.close();
       
       //Check reference counting
-      assertTrue(MessageIdGeneratorFactory.instance.containsMessageIdGenerator(state2.getServerID()));
+      assertTrue(MessageIdGeneratorFactory.instance.containsMessageIdGenerator(String.valueOf(state2.getServerID())));
            
       conn2.close();
       
-      assertFalse(MessageIdGeneratorFactory.instance.containsMessageIdGenerator(state2.getServerID()));     
+      assertFalse(MessageIdGeneratorFactory.instance.containsMessageIdGenerator(String.valueOf(state2.getServerID())));     
    }
       
 

Deleted: branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/DuplicateClientIDTest.java
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/DuplicateClientIDTest.java	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/DuplicateClientIDTest.java	2007-05-10 15:36:44 UTC (rev 2666)
@@ -1,158 +0,0 @@
-/*
-   * JBoss, Home of Professional Open Source
-   * Copyright 2005, JBoss Inc., and individual contributors as indicated
-   * by the @authors tag. See the copyright.txt in the distribution for a
-   * full listing of individual contributors.
-   *
-   * This 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 (at your option) any later version.
-   *
-   * This software 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 software; if not, write to the Free
-   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-   */
-
-package org.jboss.test.messaging.jms;
-
-import org.jboss.test.messaging.MessagingTestCase;
-import org.jboss.test.messaging.tools.ServerManagement;
-import javax.naming.InitialContext;
-import javax.jms.ConnectionFactory;
-import javax.jms.Connection;
-import javax.jms.InvalidClientIDException;
-
-/**
- * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
- * @version <tt>$Revision$</tt>
- * $Id$
- */
-public class DuplicateClientIDTest extends MessagingTestCase
-{
-
-   // Constants ------------------------------------------------------------------------------------
-
-   // Attributes -----------------------------------------------------------------------------------
-
-   protected InitialContext ic;
-   protected ConnectionFactory cf;
-
-   // Static ---------------------------------------------------------------------------------------
-
-   // Constructors ---------------------------------------------------------------------------------
-
-   public DuplicateClientIDTest(String name)
-   {
-      super(name);
-   }
-
-   // Public ---------------------------------------------------------------------------------------
-
-   public void testDuplicate() throws Exception
-   {
-
-      Connection c1 = null;
-      Connection c2 = null;
-      try
-      {
-
-         c1 = cf.createConnection();
-         c1.setClientID("Duplicated");
-
-         try
-         {
-            c2 = cf.createConnection();
-            c2.setClientID("Duplicated");
-            fail("JBossMessaging is allowing duplicate clients!");
-         }
-         catch (InvalidClientIDException e)
-         {
-         }
-      }
-      finally
-      {
-         if (c1 != null) c1.close();
-         if (c2 != null) c2.close();
-      }
-
-   }
-
-   public void testPreconfiguredDuplicateClientID() throws Exception
-   {
-      Connection c1 = null;
-      Connection c2 = null;
-      try
-      {
-
-         c1 = cf.createConnection("john", "needle");
-         c1.setClientID("Duplicated");
-
-         try
-         {
-            c2 = cf.createConnection("john", "needle");
-            c2.setClientID("Duplicated");
-            fail("JBossMessaging is allowing duplicate clients!");
-         }
-         catch (InvalidClientIDException e)
-         {
-         }
-      }
-      finally
-      {
-         if (c1 != null) c1.close();
-         if (c2 != null) c2.close();
-      }
-   }
-
-   public void testNotDuplicateClientID() throws Exception
-   {
-      Connection c1 = null;
-      Connection c2 = null;
-      try
-      {
-
-         c1 = cf.createConnection();
-
-         c2 = cf.createConnection();
-      }
-      finally
-      {
-         if (c1 != null) c1.close();
-         if (c2 != null) c2.close();
-      }
-   }
-
-   // Package protected ----------------------------------------------------------------------------
-
-   // Protected ------------------------------------------------------------------------------------
-
-   protected void setUp() throws Exception
-   {
-      super.setUp();
-
-      ServerManagement.start("all");
-
-      ic = new InitialContext(ServerManagement.getJNDIEnvironment());
-
-      cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
-
-
-   }
-
-   protected void tearDown() throws Exception
-   {
-      super.tearDown();
-   }
-
-   // Private --------------------------------------------------------------------------------------
-
-   // Inner classes --------------------------------------------------------------------------------
-
-}

Deleted: branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/DurableSubscriberTest.java
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/DurableSubscriberTest.java	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/DurableSubscriberTest.java	2007-05-10 15:36:44 UTC (rev 2666)
@@ -1,522 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This 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 (at your option) any later version.
-  *
-  * This software 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 software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.test.messaging.jms;
-
-import org.jboss.test.messaging.MessagingTestCase;
-import org.jboss.test.messaging.tools.ServerManagement;
-
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.jms.ConnectionFactory;
-import javax.jms.Connection;
-import javax.jms.Session;
-import javax.jms.MessageProducer;
-import javax.jms.Topic;
-import javax.jms.DeliveryMode;
-import javax.jms.MessageConsumer;
-import javax.jms.TextMessage;
-import javax.jms.Message;
-import javax.jms.InvalidDestinationException;
-import javax.jms.JMSException;
-import javax.jms.InvalidSelectorException;
-import javax.jms.TopicSubscriber;
-import javax.jms.IllegalStateException;
-import java.util.Set;
-
-
-/**
- * Tests focused on durable subscription behavior. More durable subscription tests can be found in
- * MessageConsumerTest.
- *
- * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- * $Id$
- */
-public class DurableSubscriberTest extends MessagingTestCase
-{
-   // Constants -----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   protected InitialContext ic;
-
-   // Constructors --------------------------------------------------
-
-   public DurableSubscriberTest(String name)
-   {
-      super(name);
-   }
-
-   // Public --------------------------------------------------------
-
-   public void setUp() throws Exception
-   {
-      super.setUp();
-
-      ServerManagement.start("all");
-            
-      ServerManagement.undeployTopic("Topic");
-      ServerManagement.deployTopic("Topic");
-
-      ic = new InitialContext(ServerManagement.getJNDIEnvironment());
-
-      log.debug("setup done");
-   }
-
-   public void tearDown() throws Exception
-   {
-      log.debug("starting tear down");
-
-      ic.close();
-
-      ServerManagement.undeployTopic("Topic");
-        
-      super.tearDown();
-   }
-
-   public void testSimplestDurableSubscription() throws Exception
-   {
-      ConnectionFactory cf = (ConnectionFactory)ic.lookup("ConnectionFactory");
-      Topic topic = (Topic)ic.lookup("/topic/Topic");
-      Connection conn = cf.createConnection();
-
-      conn.setClientID("brookeburke");
-
-      Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageProducer prod = s.createProducer(topic);
-      prod.setDeliveryMode(DeliveryMode.PERSISTENT);
-
-      s.createDurableSubscriber(topic, "monicabelucci");
-
-
-      Set subs = (Set)ServerManagement.
-         invoke(ServerManagement.getChannelMapperObjectName(),
-                "getSubscriptions",
-                new Object[] { "brookeburke" },
-                new String[] { "java.lang.String" });
-
-      assertEquals(1, subs.size());
-      assertEquals("monicabelucci", subs.iterator().next());
-
-      prod.send(s.createTextMessage("k"));
-
-      conn.close();
-
-      subs = (Set)ServerManagement.
-         invoke(ServerManagement.getChannelMapperObjectName(),
-                "getSubscriptions",
-                new Object[] { "brookeburke" },
-                new String[] { "java.lang.String" });
-
-      assertEquals(1, subs.size());
-      assertEquals("monicabelucci", subs.iterator().next());
-
-      conn = cf.createConnection();
-      conn.setClientID("brookeburke");
-
-      s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      MessageConsumer durable = s.createDurableSubscriber(topic, "monicabelucci");
-
-      conn.start();
-
-      TextMessage tm = (TextMessage)durable.receive();
-      assertEquals("k", tm.getText());
-
-      Message m = durable.receive(1000);
-      assertNull(m);
-      
-      conn.close();
-   }
-
-   /**
-    * JMS 1.1 6.11.1: A client can change an existing durable subscription by creating a durable
-    * TopicSubscriber with the same name and a new topic and/or message selector, or NoLocal
-    * attribute. Changing a durable subscription is equivalent to deleting and recreating it.
-    *
-    * Test with a different topic (a redeployed topic is a different topic).
-    */
-   public void testDurableSubscriptionOnNewTopic() throws Exception
-   {
-      ServerManagement.deployTopic("CompletelyNewTopic");
-
-      ConnectionFactory cf = (ConnectionFactory)ic.lookup("ConnectionFactory");
-      Topic topic = (Topic)ic.lookup("/topic/CompletelyNewTopic");
-      Connection conn = cf.createConnection();
-
-      conn.setClientID("brookeburke");
-
-      Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageProducer prod = s.createProducer(topic);
-      prod.setDeliveryMode(DeliveryMode.PERSISTENT);
-
-      s.createDurableSubscriber(topic, "monicabelucci");
-
-      prod.send(s.createTextMessage("one"));
-
-      conn.close();
-
-      ServerManagement.deployTopic("CompletelyNewTopic2");
-
-      Topic topic2 = (Topic)ic.lookup("/topic/CompletelyNewTopic2");
-      conn = cf.createConnection();
-
-      conn.setClientID("brookeburke");
-
-      s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageConsumer durable = s.createDurableSubscriber(topic2, "monicabelucci");
-
-      conn.start();
-
-      Message m = durable.receive(1000);
-      assertNull(m);
-
-      ServerManagement.undeployTopic("CompletelyNewTopic");
-      ServerManagement.undeployTopic("CompletelyNewTopic2");
-      
-      conn.close();
-   }
-
-   /**
-    * JMS 1.1 6.11.1: A client can change an existing durable subscription by creating a durable
-    * TopicSubscriber with the same name and a new topic and/or message selector, or NoLocal
-    * attribute. Changing a durable subscription is equivalent to deleting and recreating it.
-    *
-    * Test with a different selector.
-    */
-   public void testDurableSubscriptionDifferentSelector() throws Exception
-   {
-      ServerManagement.deployTopic("CompletelyNewTopic2");
-      
-      ConnectionFactory cf = (ConnectionFactory)ic.lookup("ConnectionFactory");
-      Topic topic = (Topic)ic.lookup("/topic/Topic");
-      Connection conn = cf.createConnection();
-
-      conn.setClientID("brookeburke");
-
-      Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageProducer prod = s.createProducer(topic);
-      prod.setDeliveryMode(DeliveryMode.PERSISTENT);
-
-      
-      //fails here
-      MessageConsumer durable =
-         s.createDurableSubscriber(topic,
-                                   "monicabelucci",
-                                   "color = 'red' AND shape = 'square'",
-                                   false);
-
-      TextMessage tm = s.createTextMessage("A red square message");
-      tm.setStringProperty("color", "red");
-      tm.setStringProperty("shape", "square");
-      prod.send(tm);
-
-      conn.start();
-
-      TextMessage rm = (TextMessage)durable.receive(5000);
-      assertEquals("A red square message", rm.getText());
-
-      tm = s.createTextMessage("Another red square message");
-      tm.setStringProperty("color", "red");
-      tm.setStringProperty("shape", "square");
-      prod.send(tm);
-
-      // TODO: when subscriptions/durable subscription will be registered as MBean, use the JMX
-      //       interface to make sure the 'another red square message' is maintained by the
-      //       durable subascription
-      //       http://jira.jboss.org/jira/browse/JBMESSAGING-217
-
-      conn.close();
-
-      conn = cf.createConnection();
-
-      conn.setClientID("brookeburke");
-
-      s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      // modify the selector
-      durable = s.createDurableSubscriber(topic,
-                                          "monicabelucci",
-                                          "color = 'red'",
-                                          false);
-
-      conn.start();
-
-      Message m = durable.receive(1000);
-
-      // the durable subscription is destroyed and re-created. The red square message stored by
-      // the previous durable subscription is lost and (hopefully) garbage collected.
-      assertNull(m);
-      
-      ServerManagement.undeployTopic("CompletelyNewTopic2");
-      
-      conn.close();
-   }
-
-   /**
-    * JMS 1.1 6.11.1: A client can change an existing durable subscription by creating a durable
-    * TopicSubscriber with the same name and a new topic and/or message selector, or NoLocal
-    * attribute. Changing a durable subscription is equivalent to deleting and recreating it.
-    *
-    * Test with a different noLocal flag.
-    */
-   public void testDurableSubscriptionDifferentNoLocal() throws Exception
-   {
-      ConnectionFactory cf = (ConnectionFactory)ic.lookup("ConnectionFactory");
-      Topic topic = (Topic)ic.lookup("/topic/Topic");
-
-      Connection conn = cf.createConnection();
-      conn.setClientID("ID0");
-
-      Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageProducer prod = s.createProducer(topic);
-      prod.setDeliveryMode(DeliveryMode.PERSISTENT);
-
-      MessageConsumer durable = s.createDurableSubscriber(topic, "mySubscription", null, false);
-
-      TextMessage tm = null;
-      tm = s.createTextMessage("Message One");
-      prod.send(tm);
-      tm = s.createTextMessage("Message Two");
-      prod.send(tm);
-
-
-      conn.start();
-
-      TextMessage rm = (TextMessage)durable.receive(5000);
-      assertEquals("Message One", rm.getText());
-
-      conn.close();
-
-      conn = cf.createConnection();
-      conn.setClientID("ID0");
-      s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      // modify the nolocal flag
-      durable = s.createDurableSubscriber(topic, "mySubscription", null, true);
-
-      conn.start();
-
-      Message m = durable.receive(1000);
-
-      // the durable subscription is destroyed and re-created. "Message Two" stored by the previous
-      // durable subscription is lost and (hopefully) garbage collected.
-      assertNull(m);
-      
-      conn.close();
-   }
-
-   public void testDurableSubscriptionOnTemporaryTopic() throws Exception
-   {
-      ConnectionFactory cf = (ConnectionFactory)ic.lookup("ConnectionFactory");
-      Connection conn = cf.createConnection();
-      conn.setClientID("doesn't actually matter");
-      Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Topic temporaryTopic = s.createTemporaryTopic();
-
-      try
-      {
-         s.createDurableSubscriber(temporaryTopic, "mySubscription");
-         fail("this should throw exception");
-      }
-      catch(InvalidDestinationException e)
-      {
-         // OK
-      }
-      
-      conn.close();
-   }
-
-   /**
-    * Topic undeployment/redeployment has an activation/deactivation semantic, so undeploying a
-    * topic for which there are durable subscriptions preserves the content of those durable
-    * subscriptions, which can be then access upon topic redeployment.
-    * @throws Exception
-    */
-   public void testDurableSubscriptionOnTopicRedeployment() throws Exception
-   {
-      try
-      {
-         ic.lookup("/topic/TopicToBeRedeployed");
-         fail("should throw exception, topic shouldn't be deployed on the server");
-      }
-      catch(NamingException e)
-      {
-         // OK
-      }
-
-      ServerManagement.deployTopic("TopicToBeRedeployed");
-
-      ConnectionFactory cf = (ConnectionFactory)ic.lookup("ConnectionFactory");
-      Topic topic = (Topic)ic.lookup("/topic/TopicToBeRedeployed");
-
-      Connection conn = cf.createConnection();
-      conn.setClientID("brookeburke");
-
-      Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageProducer prod = s.createProducer(topic);
-      prod.setDeliveryMode(DeliveryMode.PERSISTENT);
-      MessageConsumer ds = s.createDurableSubscriber(topic, "monicabelucci");
-      conn.start();
-
-      prod.send(s.createTextMessage("one"));
-      prod.send(s.createTextMessage("two"));
-
-      ServerManagement.undeployTopic("TopicToBeRedeployed");
-      log.debug("topic undeployed");
-
-      try
-      {
-         topic = (Topic)ic.lookup("/topic/TopicToBeRedeployed");
-         fail("should throw exception");
-      }
-      catch(NamingException e)
-      {
-         // OK
-      }
-
-      TextMessage tm = (TextMessage)ds.receive();
-      assertEquals("one", tm.getText());
-      conn.close();
-
-      conn = cf.createConnection();
-      conn.setClientID("brookeburke");
-
-      s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      try
-      {
-         s.createDurableSubscriber(topic, "monicabelucci");
-         fail("should throw exception");
-      }
-      catch(JMSException e)
-      {
-         // OK
-      }
-
-      ServerManagement.deployTopic("TopicToBeRedeployed");
-      log.debug("topic redeployed");
-
-      // since redeployment has an activation semantic, I expect to find the messages there
-
-      topic = (Topic)ic.lookup("/topic/TopicToBeRedeployed");
-      ds =  s.createDurableSubscriber(topic, "monicabelucci");
-      conn.start();
-
-      tm = (TextMessage)ds.receive();
-      assertEquals("two", tm.getText());
-
-      conn.close();
-      ServerManagement.undeployTopic("TopicToBeRedeployed");
-   }
-
-   public void testUnsubscribeDurableSubscription() throws Exception
-   {
-      ConnectionFactory cf = (ConnectionFactory)ic.lookup("ConnectionFactory");
-      Topic topic = (Topic)ic.lookup("/topic/Topic");
-
-      Connection conn = cf.createConnection();
-      conn.setClientID("ak47");
-
-      Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageConsumer cons = s.createDurableSubscriber(topic, "uzzi");
-      MessageProducer prod = s.createProducer(topic);
-      prod.setDeliveryMode(DeliveryMode.PERSISTENT);
-
-      prod.send(s.createTextMessage("one"));
-
-      log.debug("unsubscribing ...");
-
-      cons.close();
-      s.unsubscribe("uzzi");
-
-      log.debug("resubscribing ...");
-
-      MessageConsumer ds = s.createDurableSubscriber(topic, "uzzi");
-      conn.start();
-
-      assertNull(ds.receive(1000));
-
-      conn.close();
-   }
-
-   public void testInvalidSelectorException() throws Exception
-   {
-      ConnectionFactory cf = (ConnectionFactory)ic.lookup("ConnectionFactory");
-      Topic topic = (Topic)ic.lookup("/topic/Topic");
-      Connection c = cf.createConnection();
-      c.setClientID("sofiavergara");
-      Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      try
-      {
-         s.createDurableSubscriber(topic, "mysubscribption", "=TEST 'test'", true);
-         fail("this should fail");
-      }
-      catch(InvalidSelectorException e)
-      {
-         // OK
-      }
-      
-      c.close();
-   }
-
-   //See JMS 1.1. spec sec 6.11
-   public void testUnsubscribeWithActiveConsumer() throws Exception
-   {
-      ConnectionFactory cf = (ConnectionFactory)ic.lookup("ConnectionFactory");
-      Topic topic = (Topic)ic.lookup("/topic/Topic");
-
-      Connection conn = cf.createConnection();
-      conn.setClientID("zeke");
-
-      Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      TopicSubscriber dursub = s.createDurableSubscriber(topic, "dursub0");
-
-      try
-      {
-         s.unsubscribe("dursub0");
-         fail();
-      }
-      catch (IllegalStateException e)
-      {
-         //Ok - it is illegal to ubscribe a subscription if it has active consumers
-      }
-
-      dursub.close();
-
-      conn.close();
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-
-}

Copied: branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/DurableSubscriptionTest.java (from rev 2665, branches/Branch_1_0_1_SP/tests/src/org/jboss/test/messaging/jms/DurableSubscriptionTest.java)
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/DurableSubscriptionTest.java	                        (rev 0)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/DurableSubscriptionTest.java	2007-05-10 15:36:44 UTC (rev 2666)
@@ -0,0 +1,551 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This 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 (at your option) any later version.
+  *
+  * This software 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 software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.test.messaging.jms;
+
+import org.jboss.test.messaging.MessagingTestCase;
+import org.jboss.test.messaging.tools.ServerManagement;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.jms.ConnectionFactory;
+import javax.jms.Connection;
+import javax.jms.Session;
+import javax.jms.MessageProducer;
+import javax.jms.Topic;
+import javax.jms.DeliveryMode;
+import javax.jms.MessageConsumer;
+import javax.jms.TextMessage;
+import javax.jms.Message;
+import javax.jms.InvalidDestinationException;
+import javax.jms.JMSException;
+import javax.jms.InvalidSelectorException;
+import javax.jms.TopicSubscriber;
+import javax.jms.IllegalStateException;
+import java.util.Set;
+
+
+/**
+ * Tests focused on durable subscription behavior. More durable subscription tests can be found in
+ * MessageConsumerTest.
+ *
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ * $Id$
+ */
+public class DurableSubscriptionTest extends MessagingTestCase
+{
+   // Constants -----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   protected InitialContext ic;
+
+   // Constructors --------------------------------------------------
+
+   public DurableSubscriptionTest(String name)
+   {
+      super(name);
+   }
+
+   // Public --------------------------------------------------------
+
+   public void setUp() throws Exception
+   {
+      super.setUp();
+
+      ServerManagement.start("all");
+            
+      ServerManagement.undeployTopic("Topic");
+      ServerManagement.deployTopic("Topic");
+
+      ic = new InitialContext(ServerManagement.getJNDIEnvironment());
+
+      log.debug("setup done");
+   }
+
+   public void tearDown() throws Exception
+   {
+      log.debug("starting tear down");
+
+      ic.close();
+
+      ServerManagement.undeployTopic("Topic");
+        
+      super.tearDown();
+   }
+
+   public void testSimplestDurableSubscription() throws Exception
+   {
+      ConnectionFactory cf = (ConnectionFactory)ic.lookup("ConnectionFactory");
+      Topic topic = (Topic)ic.lookup("/topic/Topic");
+      Connection conn = cf.createConnection();
+
+      conn.setClientID("brookeburke");
+
+      Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      MessageProducer prod = s.createProducer(topic);
+      prod.setDeliveryMode(DeliveryMode.PERSISTENT);
+
+      s.createDurableSubscriber(topic, "monicabelucci");
+
+
+      Set subs = (Set)ServerManagement.
+         invoke(ServerManagement.getChannelMapperObjectName(),
+                "getSubscriptions",
+                new Object[] { "brookeburke" },
+                new String[] { "java.lang.String" });
+
+      assertEquals(1, subs.size());
+      assertEquals("monicabelucci", subs.iterator().next());
+
+      prod.send(s.createTextMessage("k"));
+
+      conn.close();
+
+      subs = (Set)ServerManagement.
+         invoke(ServerManagement.getChannelMapperObjectName(),
+                "getSubscriptions",
+                new Object[] { "brookeburke" },
+                new String[] { "java.lang.String" });
+
+      assertEquals(1, subs.size());
+      assertEquals("monicabelucci", subs.iterator().next());
+
+      conn = cf.createConnection();
+      conn.setClientID("brookeburke");
+
+      s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+      MessageConsumer durable = s.createDurableSubscriber(topic, "monicabelucci");
+
+      conn.start();
+
+      TextMessage tm = (TextMessage)durable.receive();
+      assertEquals("k", tm.getText());
+
+      Message m = durable.receive(1000);
+      assertNull(m);
+      
+      conn.close();
+   }
+
+   /**
+    * JMS 1.1 6.11.1: A client can change an existing durable subscription by creating a durable
+    * TopicSubscriber with the same name and a new topic and/or message selector, or NoLocal
+    * attribute. Changing a durable subscription is equivalent to deleting and recreating it.
+    *
+    * Test with a different topic (a redeployed topic is a different topic).
+    */
+   public void testDurableSubscriptionOnNewTopic() throws Exception
+   {
+      ServerManagement.deployTopic("CompletelyNewTopic");
+
+      ConnectionFactory cf = (ConnectionFactory)ic.lookup("ConnectionFactory");
+      Topic topic = (Topic)ic.lookup("/topic/CompletelyNewTopic");
+      Connection conn = cf.createConnection();
+
+      conn.setClientID("brookeburke");
+
+      Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      MessageProducer prod = s.createProducer(topic);
+      prod.setDeliveryMode(DeliveryMode.PERSISTENT);
+
+      s.createDurableSubscriber(topic, "monicabelucci");
+
+      prod.send(s.createTextMessage("one"));
+
+      conn.close();
+
+      ServerManagement.deployTopic("CompletelyNewTopic2");
+
+      Topic topic2 = (Topic)ic.lookup("/topic/CompletelyNewTopic2");
+      conn = cf.createConnection();
+
+      conn.setClientID("brookeburke");
+
+      s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      MessageConsumer durable = s.createDurableSubscriber(topic2, "monicabelucci");
+
+      conn.start();
+
+      Message m = durable.receive(1000);
+      assertNull(m);
+
+      ServerManagement.undeployTopic("CompletelyNewTopic");
+      ServerManagement.undeployTopic("CompletelyNewTopic2");
+      
+      conn.close();
+   }
+
+   /**
+    * JMS 1.1 6.11.1: A client can change an existing durable subscription by creating a durable
+    * TopicSubscriber with the same name and a new topic and/or message selector, or NoLocal
+    * attribute. Changing a durable subscription is equivalent to deleting and recreating it.
+    *
+    * Test with a different selector.
+    */
+   public void testDurableSubscriptionDifferentSelector() throws Exception
+   {
+      ServerManagement.deployTopic("CompletelyNewTopic2");
+      
+      ConnectionFactory cf = (ConnectionFactory)ic.lookup("ConnectionFactory");
+      Topic topic = (Topic)ic.lookup("/topic/Topic");
+      Connection conn = cf.createConnection();
+
+      conn.setClientID("brookeburke");
+
+      Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      MessageProducer prod = s.createProducer(topic);
+      prod.setDeliveryMode(DeliveryMode.PERSISTENT);
+
+      
+      //fails here
+      MessageConsumer durable =
+         s.createDurableSubscriber(topic,
+                                   "monicabelucci",
+                                   "color = 'red' AND shape = 'square'",
+                                   false);
+
+      TextMessage tm = s.createTextMessage("A red square message");
+      tm.setStringProperty("color", "red");
+      tm.setStringProperty("shape", "square");
+      prod.send(tm);
+
+      conn.start();
+
+      TextMessage rm = (TextMessage)durable.receive(5000);
+      assertEquals("A red square message", rm.getText());
+
+      tm = s.createTextMessage("Another red square message");
+      tm.setStringProperty("color", "red");
+      tm.setStringProperty("shape", "square");
+      prod.send(tm);
+
+      // TODO: when subscriptions/durable subscription will be registered as MBean, use the JMX
+      //       interface to make sure the 'another red square message' is maintained by the
+      //       durable subascription
+      //       http://jira.jboss.org/jira/browse/JBMESSAGING-217
+
+      conn.close();
+
+      conn = cf.createConnection();
+
+      conn.setClientID("brookeburke");
+
+      s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+      // modify the selector
+      durable = s.createDurableSubscriber(topic,
+                                          "monicabelucci",
+                                          "color = 'red'",
+                                          false);
+
+      conn.start();
+
+      Message m = durable.receive(1000);
+
+      // the durable subscription is destroyed and re-created. The red square message stored by
+      // the previous durable subscription is lost and (hopefully) garbage collected.
+      assertNull(m);
+      
+      ServerManagement.undeployTopic("CompletelyNewTopic2");
+      
+      conn.close();
+   }
+
+   /**
+    * JMS 1.1 6.11.1: A client can change an existing durable subscription by creating a durable
+    * TopicSubscriber with the same name and a new topic and/or message selector, or NoLocal
+    * attribute. Changing a durable subscription is equivalent to deleting and recreating it.
+    *
+    * Test with a different noLocal flag.
+    */
+   public void testDurableSubscriptionDifferentNoLocal() throws Exception
+   {
+      ConnectionFactory cf = (ConnectionFactory)ic.lookup("ConnectionFactory");
+      Topic topic = (Topic)ic.lookup("/topic/Topic");
+
+      Connection conn = cf.createConnection();
+      conn.setClientID("ID0");
+
+      Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      MessageProducer prod = s.createProducer(topic);
+      prod.setDeliveryMode(DeliveryMode.PERSISTENT);
+
+      MessageConsumer durable = s.createDurableSubscriber(topic, "mySubscription", null, false);
+
+      TextMessage tm = null;
+      tm = s.createTextMessage("Message One");
+      prod.send(tm);
+      tm = s.createTextMessage("Message Two");
+      prod.send(tm);
+
+
+      conn.start();
+
+      TextMessage rm = (TextMessage)durable.receive(5000);
+      assertEquals("Message One", rm.getText());
+
+      conn.close();
+
+      conn = cf.createConnection();
+      conn.setClientID("ID0");
+      s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+      // modify the nolocal flag
+      durable = s.createDurableSubscriber(topic, "mySubscription", null, true);
+
+      conn.start();
+
+      Message m = durable.receive(1000);
+
+      // the durable subscription is destroyed and re-created. "Message Two" stored by the previous
+      // durable subscription is lost and (hopefully) garbage collected.
+      assertNull(m);
+      
+      conn.close();
+   }
+
+   public void testDurableSubscriptionOnTemporaryTopic() throws Exception
+   {
+      ConnectionFactory cf = (ConnectionFactory)ic.lookup("ConnectionFactory");
+      Connection conn = cf.createConnection();
+      conn.setClientID("doesn't actually matter");
+      Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      Topic temporaryTopic = s.createTemporaryTopic();
+
+      try
+      {
+         s.createDurableSubscriber(temporaryTopic, "mySubscription");
+         fail("this should throw exception");
+      }
+      catch(InvalidDestinationException e)
+      {
+         // OK
+      }
+      
+      conn.close();
+   }
+
+   /**
+    * Topic undeployment/redeployment has an activation/deactivation semantic, so undeploying a
+    * topic for which there are durable subscriptions preserves the content of those durable
+    * subscriptions, which can be then access upon topic redeployment.
+    * @throws Exception
+    */
+   public void testDurableSubscriptionOnTopicRedeployment() throws Exception
+   {
+      try
+      {
+         ic.lookup("/topic/TopicToBeRedeployed");
+         fail("should throw exception, topic shouldn't be deployed on the server");
+      }
+      catch(NamingException e)
+      {
+         // OK
+      }
+
+      ServerManagement.deployTopic("TopicToBeRedeployed");
+
+      ConnectionFactory cf = (ConnectionFactory)ic.lookup("ConnectionFactory");
+      Topic topic = (Topic)ic.lookup("/topic/TopicToBeRedeployed");
+
+      Connection conn = cf.createConnection();
+      conn.setClientID("brookeburke");
+
+      Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      MessageProducer prod = s.createProducer(topic);
+      prod.setDeliveryMode(DeliveryMode.PERSISTENT);
+      MessageConsumer ds = s.createDurableSubscriber(topic, "monicabelucci");
+      conn.start();
+
+      prod.send(s.createTextMessage("one"));
+      prod.send(s.createTextMessage("two"));
+
+      ServerManagement.undeployTopic("TopicToBeRedeployed");
+      log.debug("topic undeployed");
+
+      try
+      {
+         topic = (Topic)ic.lookup("/topic/TopicToBeRedeployed");
+         fail("should throw exception");
+      }
+      catch(NamingException e)
+      {
+         // OK
+      }
+
+      TextMessage tm = (TextMessage)ds.receive();
+      assertEquals("one", tm.getText());
+      conn.close();
+
+      conn = cf.createConnection();
+      conn.setClientID("brookeburke");
+
+      s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+      try
+      {
+         s.createDurableSubscriber(topic, "monicabelucci");
+         fail("should throw exception");
+      }
+      catch(JMSException e)
+      {
+         // OK
+      }
+
+      ServerManagement.deployTopic("TopicToBeRedeployed");
+      log.debug("topic redeployed");
+
+      // since redeployment has an activation semantic, I expect to find the messages there
+
+      topic = (Topic)ic.lookup("/topic/TopicToBeRedeployed");
+      ds =  s.createDurableSubscriber(topic, "monicabelucci");
+      conn.start();
+
+      tm = (TextMessage)ds.receive();
+      assertEquals("two", tm.getText());
+
+      conn.close();
+      ServerManagement.undeployTopic("TopicToBeRedeployed");
+   }
+
+   public void testUnsubscribeDurableSubscription() throws Exception
+   {
+      ConnectionFactory cf = (ConnectionFactory)ic.lookup("ConnectionFactory");
+      Topic topic = (Topic)ic.lookup("/topic/Topic");
+
+      Connection conn = cf.createConnection();
+      conn.setClientID("ak47");
+
+      Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      MessageConsumer cons = s.createDurableSubscriber(topic, "uzzi");
+      MessageProducer prod = s.createProducer(topic);
+      prod.setDeliveryMode(DeliveryMode.PERSISTENT);
+
+      prod.send(s.createTextMessage("one"));
+
+      log.debug("unsubscribing ...");
+
+      cons.close();
+      s.unsubscribe("uzzi");
+
+      log.debug("resubscribing ...");
+
+      MessageConsumer ds = s.createDurableSubscriber(topic, "uzzi");
+      conn.start();
+
+      assertNull(ds.receive(1000));
+
+      conn.close();
+   }
+
+   public void testInvalidSelectorException() throws Exception
+   {
+      ConnectionFactory cf = (ConnectionFactory)ic.lookup("ConnectionFactory");
+      Topic topic = (Topic)ic.lookup("/topic/Topic");
+      Connection c = cf.createConnection();
+      c.setClientID("sofiavergara");
+      Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+      try
+      {
+         s.createDurableSubscriber(topic, "mysubscribption", "=TEST 'test'", true);
+         fail("this should fail");
+      }
+      catch(InvalidSelectorException e)
+      {
+         // OK
+      }
+      
+      c.close();
+   }
+
+   //See JMS 1.1. spec sec 6.11
+   public void testUnsubscribeWithActiveConsumer() throws Exception
+   {
+      ConnectionFactory cf = (ConnectionFactory)ic.lookup("ConnectionFactory");
+      Topic topic = (Topic)ic.lookup("/topic/Topic");
+
+      Connection conn = cf.createConnection();
+      conn.setClientID("zeke");
+
+      Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+      TopicSubscriber dursub = s.createDurableSubscriber(topic, "dursub0");
+
+      try
+      {
+         s.unsubscribe("dursub0");
+         fail();
+      }
+      catch (IllegalStateException e)
+      {
+         //Ok - it is illegal to ubscribe a subscription if it has active consumers
+      }
+
+      dursub.close();
+
+      conn.close();
+   }
+   
+   public void testSubscribeWithActiveSubscription() throws Exception
+   {
+   	ConnectionFactory cf = (ConnectionFactory)ic.lookup("ConnectionFactory");
+      Topic topic = (Topic)ic.lookup("/topic/Topic");
+
+      Connection conn = cf.createConnection();
+      conn.setClientID("zeke");
+
+      Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+      TopicSubscriber dursub1 = s.createDurableSubscriber(topic, "dursub1");
+
+      try
+      {      
+      	s.createDurableSubscriber(topic, "dursub1");
+         fail();
+      }
+      catch (IllegalStateException e)
+      {
+         //Ok - it is illegal to have more than one active subscriber on a subscrtiption at any one time
+      }
+         
+      dursub1.close();
+      
+      s.unsubscribe("dursub1");
+
+      conn.close();
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+}

Modified: branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/MessageConsumerTest.java
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/MessageConsumerTest.java	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/MessageConsumerTest.java	2007-05-10 15:36:44 UTC (rev 2666)
@@ -276,58 +276,6 @@
       
    }
   
-   
-   public void testRedeliveryToCompetingConsumerOnSubscription() throws Exception
-   {
-      Connection conn = cf.createConnection();
-      
-      conn.setClientID("wibble");
-      
-      Session sessSend = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      
-      MessageProducer prod = sessSend.createProducer(topic);
-      
-      conn.start();
-      
-      Session sessConsume1 = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-      
-      MessageConsumer cons1 = sessConsume1.createDurableSubscriber(topic, "sub1");
-      
-      TextMessage tm = sessSend.createTextMessage();
-      
-      tm.setText("Your mum");
-      
-      prod.send(tm);
-      
-      TextMessage tm2 = (TextMessage)cons1.receive();
-      
-      assertNotNull(tm2);
-      
-      assertEquals("Your mum", tm2.getText());
-      
-      //Don't ack
-      
-      //Create another consumer
-                 
-      Session sessConsume2 = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-       
-      MessageConsumer cons2 = sessConsume2.createDurableSubscriber(topic, "sub1");
-          
-      //this should cancel message and cause delivery to other consumer
-      
-      sessConsume1.close();
-               
-      TextMessage tm3 = (TextMessage)cons2.receive(1000);
-      
-      assertNotNull(tm3);
-      
-      assertEquals("Your mum", tm3.getText());
-      
-      tm3.acknowledge();            
-      
-      conn.close();
-      
-   }
 
    /**
     * The simplest possible receive() test for a non-persistent message.

Modified: branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/WireFormatTest.java
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/WireFormatTest.java	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/WireFormatTest.java	2007-05-10 15:36:44 UTC (rev 2666)
@@ -72,7 +72,7 @@
    private static final Logger log = Logger.getLogger(WireFormatTest.class);
 
    // TODO - replace with a dynamic value
-   private static final byte CURRENT_VERSION = 7;
+   private static final byte CURRENT_VERSION = 13;
 
    // Static --------------------------------------------------------
       
@@ -1100,6 +1100,7 @@
       
       public void testCallback() throws Exception
       {
+         int serverID = 716267;
          int consumerID = 12345678;
          
          JBossMessage m1 = new JBossMessage(123);
@@ -1120,7 +1121,7 @@
          msgs.add(del2);
          msgs.add(del3);         
          
-         ClientDelivery dr = new ClientDelivery(msgs, consumerID);
+         ClientDelivery dr = new ClientDelivery(msgs, consumerID, serverID);
          
          ByteArrayOutputStream bos = new ByteArrayOutputStream();
          
@@ -1147,8 +1148,10 @@
          assertEquals(JMSWireFormat.CALLBACK, ois.readByte());
          
          //Next int should be consumer id
-         assertEquals(12345678, ois.readInt());
+         assertEquals(consumerID, ois.readInt());
          
+         assertEquals(serverID, ois.readInt());
+         
          //Next int should be number of messages
          assertEquals(3, ois.readInt());
          
@@ -1220,6 +1223,8 @@
          
          assertEquals(consumerID, dr2.getConsumerID());
          
+         assertEquals(serverID, dr2.getServerID());
+         
          MessageProxy p1 = (MessageProxy)msgs2.get(0);
          MessageProxy p2 = (MessageProxy)msgs2.get(1);
          MessageProxy p3 = (MessageProxy)msgs2.get(2);
@@ -1360,4 +1365,4 @@
          assertEquals(h.getNumberAccepted(), h3.getNumberAccepted());                 
       }    
    }
-}
\ No newline at end of file
+}

Modified: branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/XATest.java
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/XATest.java	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/XATest.java	2007-05-10 15:36:44 UTC (rev 2666)
@@ -45,35 +45,28 @@
 import org.jboss.jms.tx.MessagingXAResource;
 import org.jboss.jms.tx.ResourceManager;
 import org.jboss.test.messaging.MessagingTestCase;
-import org.jboss.test.messaging.util.TransactionManagerLocator;
 import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.tm.TxUtils;
+import org.jboss.tm.TransactionManagerLocator;
 
 /**
- * 
- * A XATest
- *
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision: 1.1 $</tt>
- * @author <a href="mailto:juha at jboss.org">Juha Lindfors</a>
  *
  * $Id$
- *
  */
 public class XATest extends MessagingTestCase
 {
    // Constants ------------------------------------------------------------------------------------
 
    // Static ---------------------------------------------------------------------------------------
-   
+
    // Attributes -----------------------------------------------------------------------------------
 
    protected InitialContext initialContext;
-   
+
    protected JBossConnectionFactory cf;
    protected Destination queue;
    protected TransactionManager tm;
-   
+
    protected Transaction suspendedTx;
 
    // Constructors ---------------------------------------------------------------------------------
@@ -83,6 +76,7 @@
       super(name);
    }
 
+   
    // TestCase overrides --------------------------------------------------------------------------
 
    public void setUp() throws Exception
@@ -90,10 +84,10 @@
       super.setUp();
       ServerManagement.start("all");
       initialContext = new InitialContext();
-      
+
       initialContext = new InitialContext(ServerManagement.getJNDIEnvironment());
       cf = (JBossConnectionFactory)initialContext.lookup("/ConnectionFactory");
-            
+
       if (!ServerManagement.isRemote())
       {
          tm = TransactionManagerLocator.getInstance().locate();
@@ -114,22 +108,16 @@
    public void tearDown() throws Exception
    {
       ServerManagement.undeployQueue("Queue");
-      
+
       if (!ServerManagement.isRemote())
       {
-         if (TxUtils.isUncommitted(tm))
+         if (tm.getTransaction() != null)
          {
             //roll it back
             tm.rollback();
          }
-         if (tm.getTransaction() != null)
-         {
-            Transaction tx = tm.suspend();
-            if (tx != null)
-               log.warn("Transaction still associated with thread " + tx + " at status " + TxUtils.getStatusAsString(tx.getStatus()));
-         }
       }
-      
+
       if (suspendedTx != null)
       {
          tm.resume(suspendedTx);
@@ -137,12 +125,143 @@
 
       super.tearDown();
    }
-   
-   
 
 
+
+
    // Public ---------------------------------------------------------------------------------------
+
+   // See http://jira.jboss.com/jira/browse/JBMESSAGING-638
+   public void testResourceManagerMemoryLeakOnCommit() throws Exception
+   {
+      if (ServerManagement.isRemote()) return;
+      
+      XAConnection xaConn = null;
+      
+      try
+      {
+         xaConn = cf.createXAConnection();
+         
+         JBossConnection jbConn = (JBossConnection)xaConn;
+         
+         ClientConnectionDelegate del = (ClientConnectionDelegate)jbConn.getDelegate();
+         
+         ConnectionState state = (ConnectionState)del.getState();
+         
+         ResourceManager rm = state.getResourceManager();
+         
+         XASession xaSession = xaConn.createXASession();
+         
+         xaConn.start();
+         
+         XAResource res = xaSession.getXAResource();
+         
+         XAResource dummy = new DummyXAResource();
+         
+         for (int i = 0; i < 100; i++)
+         {
+            
+            tm.begin();
+                     
+            Transaction tx = tm.getTransaction();
+            
+            tx.enlistResource(res);
+            
+            tx.enlistResource(dummy);
+            
+            assertEquals(1, rm.size());
+            
+            tx.delistResource(res, XAResource.TMSUCCESS);
+            
+            tx.delistResource(dummy, XAResource.TMSUCCESS);
+            
+            tm.commit();
+         }                  
+         
+         assertEquals(1, rm.size());
+         
+         xaConn.close();
+         
+         xaConn = null;
+         
+         assertEquals(0, rm.size());
+
+      }
+      finally
+      {
+         if (xaConn != null)
+         {
+            xaConn.close();
+         }
+      }
+   }
    
+   //See http://jira.jboss.com/jira/browse/JBMESSAGING-638
+   public void testResourceManagerMemoryLeakOnRollback() throws Exception
+   { 
+      if (ServerManagement.isRemote()) return;
+      
+      
+      XAConnection xaConn = null;
+      
+      try
+      {
+         xaConn = cf.createXAConnection();
+         
+         JBossConnection jbConn = (JBossConnection)xaConn;
+         
+         ClientConnectionDelegate del = (ClientConnectionDelegate)jbConn.getDelegate();
+         
+         ConnectionState state = (ConnectionState)del.getState();
+         
+         ResourceManager rm = state.getResourceManager();
+         
+         XASession xaSession = xaConn.createXASession();
+         
+         xaConn.start();
+         
+         XAResource res = xaSession.getXAResource();
+         
+         XAResource dummy = new DummyXAResource();
+         
+         for (int i = 0; i < 100; i++)
+         {            
+            tm.begin();
+                     
+            Transaction tx = tm.getTransaction();
+            
+            tx.enlistResource(res);
+            
+            tx.enlistResource(dummy);
+            
+            assertEquals(1, rm.size());
+            
+            tx.delistResource(res, XAResource.TMSUCCESS);
+            
+            tx.delistResource(dummy, XAResource.TMSUCCESS);
+            
+            tm.rollback();
+         }                  
+         
+         assertEquals(1, rm.size());
+         
+         xaConn.close();
+         
+         xaConn = null;
+         
+         assertEquals(0, rm.size());
+
+      }
+      finally
+      {
+         if (xaConn != null)
+         {
+            xaConn.close();
+         }
+      }
+   }
+   
+
    //http://jira.jboss.com/jira/browse/JBMESSAGING-721
    public void testConvertFromLocalTx() throws Exception
    {
@@ -226,6 +345,10 @@
          //Now rollback the tx - this should cause redelivery of the two messages
          tx.rollback();
          
+         //Give enough time for the messages to get back in the queue (cancel is asynch)
+         
+         Thread.sleep(500);
+         
          rm1 = (TextMessage)cons.receive(1000);
          
          assertNotNull(rm1);
@@ -341,6 +464,10 @@
          //Now rollback the tx - this should cause redelivery of the two messages
          tx.rollback();
          
+         //Give enough time for the messages to get back in the queue (cancel is asynch)
+         
+         Thread.sleep(500);
+         
          rm1 = (TextMessage)cons.receive(1000);
          
          assertNotNull(rm1);
@@ -421,8 +548,12 @@
          tx.delistResource(res, XAResource.TMSUCCESS);
          
          //Then we do a rollback
-         tm.rollback();                 
+         tm.rollback();           
          
+         //Give enough time for the messages to get back in the queue (cancel is asynch)
+         
+         Thread.sleep(500);
+         
          //Then we receive the messages outside the global tx
          
          TextMessage rm1 = (TextMessage)cons.receive(1000);
@@ -454,6 +585,10 @@
          //Now rollback the tx - this should cause redelivery of the two messages
          tx.rollback();
          
+         //Give enough time for the messages to get back in the queue (cancel is asynch)
+         
+         Thread.sleep(500);
+         
          rm1 = (TextMessage)cons.receive(1000);
          
          assertNotNull(rm1);
@@ -485,71 +620,7 @@
 
    }
 
-   //See http://jira.jboss.com/jira/browse/JBMESSAGING-638
-   public void testResourceManagerMemoryLeakOnRollback() throws Exception
-   {
-      if (ServerManagement.isRemote()) return;
 
-
-      XAConnection xaConn = null;
-
-      try
-      {
-         xaConn = cf.createXAConnection();
-
-         JBossConnection jbConn = (JBossConnection)xaConn;
-
-         ClientConnectionDelegate del = (ClientConnectionDelegate)jbConn.getDelegate();
-
-         ConnectionState state = (ConnectionState)del.getState();
-
-         ResourceManager rm = state.getResourceManager();
-
-         XASession xaSession = xaConn.createXASession();
-
-         xaConn.start();
-
-         XAResource res = xaSession.getXAResource();
-
-         XAResource dummy = new DummyXAResource();
-
-         for (int i = 0; i < 100; i++)
-         {
-            tm.begin();
-
-            Transaction tx = tm.getTransaction();
-
-            tx.enlistResource(res);
-
-            tx.enlistResource(dummy);
-
-            assertEquals(1, rm.size());
-
-            tx.delistResource(res, XAResource.TMSUCCESS);
-
-            tx.delistResource(dummy, XAResource.TMSUCCESS);
-
-            tm.rollback();
-         }
-
-         assertEquals(1, rm.size());
-
-         xaConn.close();
-
-         xaConn = null;
-
-         assertEquals(0, rm.size());
-
-      }
-      finally
-      {
-         if (xaConn != null)
-         {
-            xaConn.close();
-         }
-      }
-   }
-
    public void test2PCSendCommit1PCOptimization() throws Exception
    {
       if (ServerManagement.isRemote()) return;
@@ -560,7 +631,8 @@
       Connection conn2 = null;
       
       try
-      {      
+      {
+      
          conn = cf.createXAConnection();
          
          tm.begin();
@@ -581,7 +653,7 @@
          m = sess.createTextMessage("XATest2");
          prod.send(queue, m);
          
-         tm.commit();
+         tx.commit();
          
          conn2 = cf.createConnection();
          conn2.start();
@@ -607,52 +679,50 @@
       }
 
    }
-
-
-
+   
    public void test2PCSendCommit() throws Exception
    {
       if (ServerManagement.isRemote()) return;
-
+      
       XAConnection conn = null;
       Connection conn2 = null;
-
+      
       try
       {
-
+      
          conn = cf.createXAConnection();
-
+         
          tm.begin();
-
+         
          XASession sess = conn.createXASession();
-
-         MessagingXAResource res = (MessagingXAResource)sess.getXAResource();
+         
+         MessagingXAResource res = (MessagingXAResource)sess.getXAResource();         
          XAResource res2 = new DummyXAResource();
-
+         
          //To prevent 1PC optimization being used
          res.setPreventJoining(true);
-
+         
          Transaction tx = tm.getTransaction();
          tx.enlistResource(res);
          tx.enlistResource(res2);
-
+         
          MessageProducer prod = sess.createProducer(queue);
          prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
          Message m = sess.createTextMessage("XATest1");
          prod.send(queue, m);
          m = sess.createTextMessage("XATest2");
          prod.send(queue, m);
-
-         tm.commit();
-
+         
+         tx.commit();
+         
          conn2 = cf.createConnection();
          conn2.start();
          Session sessReceiver = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
          MessageConsumer cons = sessReceiver.createConsumer(queue);
-         TextMessage m2 = (TextMessage)cons.receive(MAX_TIMEOUT);
+         TextMessage m2 = (TextMessage)cons.receive(1000);
          assertNotNull(m2);
          assertEquals("XATest1", m2.getText());
-         m2 = (TextMessage)cons.receive(MAX_TIMEOUT);
+         m2 = (TextMessage)cons.receive(1000);
          assertNotNull(m2);
          assertEquals("XATest2", m2.getText());
       }
@@ -669,47 +739,51 @@
       }
 
    }
-
-
+   
+   
    public void test2PCSendRollback1PCOptimization() throws Exception
    {
       if (ServerManagement.isRemote()) return;
-
+      
       //Since both resources have some RM, TM will probably use 1PC optimization
-
+      
       XAConnection conn = null;
       Connection conn2 = null;
       try
       {
          conn = cf.createXAConnection();
-
+         
          tm.begin();
-
+         
          XASession sess = conn.createXASession();
          XAResource res = sess.getXAResource();
-
+         
          XAResource res2 = new DummyXAResource();
-
+         
          Transaction tx = tm.getTransaction();
          tx.enlistResource(res);
          tx.enlistResource(res2);
-
+         
          MessageProducer prod = sess.createProducer(queue);
          prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
          Message m = sess.createTextMessage("XATest1");
-         prod.send(queue, m);
+         prod.send(queue, m);   
          m = sess.createTextMessage("XATest2");
          prod.send(queue, m);
-
-         tm.rollback();
-
+         
+         tx.rollback();
+         
+         //Give enough time for the messages to get back in the queue (cancel is asynch)
+         
+         Thread.sleep(500);
+         
          conn2 = cf.createConnection();
          conn2.start();
          Session sessReceiver = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
          MessageConsumer cons = sessReceiver.createConsumer(queue);
-         Message m2 = cons.receive(MIN_TIMEOUT);
+         Message m2 = cons.receive(1000);
          assertNull(m2);
-
+   
       }
       finally
       {
@@ -723,61 +797,59 @@
          }
       }
    }
-
-
+   
+   
    public void test2PCSendFailOnPrepare() throws Exception
    {
       if (ServerManagement.isRemote()) return;
-
+      
       XAConnection conn = null;
       Connection conn2 = null;
       try
       {
          conn = cf.createXAConnection();
-
+         
          tm.begin();
-
+         
          XASession sess = conn.createXASession();
          MessagingXAResource res = (MessagingXAResource)sess.getXAResource();
-
+         
          //prevent 1Pc optimisation
          res.setPreventJoining(true);
-
+         
          XAResource res2 = new DummyXAResource(true);
          XAResource res3 = new DummyXAResource();
          XAResource res4 = new DummyXAResource();
-
+         
          Transaction tx = tm.getTransaction();
          tx.enlistResource(res);
          tx.enlistResource(res2);
          tx.enlistResource(res3);
          tx.enlistResource(res4);
-
+         
          MessageProducer prod = sess.createProducer(queue);
          prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
          Message m = sess.createTextMessage("XATest1");
-         prod.send(queue, m);
+         prod.send(queue, m);   
          m = sess.createTextMessage("XATest2");
          prod.send(queue, m);
-
+         
          try
          {
-            tm.commit();
-
-            fail("should not get here");
+            tx.commit();         
          }
          catch (Exception e)
          {
             //We should expect this
          }
-
+         
          conn2 = cf.createConnection();
          conn2.start();
          Session sessReceiver = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
          MessageConsumer cons = sessReceiver.createConsumer(queue);
-         Message m2 = cons.receive(MIN_TIMEOUT);
+         Message m2 = cons.receive(1000);
          assertNull(m2);
-
+   
       }
       finally
       {
@@ -791,47 +863,51 @@
          }
       }
    }
-
+   
    public void test2PCSendRollback() throws Exception
    {
       if (ServerManagement.isRemote()) return;
-
+      
       XAConnection conn = null;
       Connection conn2 = null;
       try
       {
          conn = cf.createXAConnection();
-
+         
          tm.begin();
-
+         
          XASession sess = conn.createXASession();
          MessagingXAResource res = (MessagingXAResource)sess.getXAResource();
-
+         
          //prevent 1Pc optimisation
          res.setPreventJoining(true);
-
+         
          XAResource res2 = new DummyXAResource();
-
+         
          Transaction tx = tm.getTransaction();
          tx.enlistResource(res);
          tx.enlistResource(res2);
-
+         
          MessageProducer prod = sess.createProducer(queue);
          prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
          Message m = sess.createTextMessage("XATest1");
-         prod.send(queue, m);
+         prod.send(queue, m);   
          m = sess.createTextMessage("XATest2");
          prod.send(queue, m);
-
-         tm.rollback();
-
+         
+         tx.rollback();
+         
+         //Give enough time for the messages to get back in the queue (cancel is asynch)
+         
+         Thread.sleep(500);
+         
          conn2 = cf.createConnection();
          conn2.start();
          Session sessReceiver = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
          MessageConsumer cons = sessReceiver.createConsumer(queue);
-         Message m2 = cons.receive(MIN_TIMEOUT);
+         Message m2 = cons.receive(1000);
          assertNull(m2);
-
+   
       }
       finally
       {
@@ -849,12 +925,12 @@
    public void test2PCReceiveCommit1PCOptimization() throws Exception
    {
       if (ServerManagement.isRemote()) return;
-
+            
       //Since both resources have some RM, TM will probably use 1PC optimization
-
+      
       XAConnection conn = null;
       Connection conn2 = null;
-
+      
       try
       {
          conn2 = cf.createConnection();
@@ -865,49 +941,49 @@
          prod.send(m);
          m = sessProducer.createTextMessage("XATest2");
          prod.send(m);
-
+         
          conn = cf.createXAConnection();
          conn.start();
-
+         
          tm.begin();
-
+         
          XASession sess = conn.createXASession();
          XAResource res = sess.getXAResource();
-
+         
          XAResource res2 = new DummyXAResource();
-
+         
          Transaction tx = tm.getTransaction();
          tx.enlistResource(res);
          tx.enlistResource(res2);
-
+         
          MessageConsumer cons = sess.createConsumer(queue);
+         
 
-
-         TextMessage m2 = (TextMessage)cons.receive(MAX_TIMEOUT);
-
+         TextMessage m2 = (TextMessage)cons.receive(1000);
+         
          assertNotNull(m2);
          assertEquals("XATest1", m2.getText());
-
-         m2 = (TextMessage)cons.receive(MAX_TIMEOUT);
-
+         
+         m2 = (TextMessage)cons.receive(1000);
+         
          assertNotNull(m2);
          assertEquals("XATest2", m2.getText());
-
-         tm.commit();
-
+         
+         tx.commit();
+         
          //New tx
          tm.begin();
          tx = tm.getTransaction();
          tx.enlistResource(res);
          tx.enlistResource(res2);
-
-         Message m3 = cons.receive(MIN_TIMEOUT);
-
+         
+         Message m3 = cons.receive(1000);
+         
          assertNull(m3);
-
+         
          tm.commit();
+         
 
-
       }
       finally
       {
@@ -920,16 +996,16 @@
             conn2.close();
          }
       }
-
+      
    }
-
+   
    public void test2PCReceiveCommit() throws Exception
    {
       if (ServerManagement.isRemote()) return;
-
+            
       XAConnection conn = null;
       Connection conn2 = null;
-
+      
       try
       {
          conn2 = cf.createConnection();
@@ -940,50 +1016,50 @@
          prod.send(m);
          m = sessProducer.createTextMessage("XATest2");
          prod.send(m);
-
+         
          conn = cf.createXAConnection();
          conn.start();
-
+         
          tm.begin();
-
+         
          XASession sess = conn.createXASession();
          MessagingXAResource res = (MessagingXAResource)sess.getXAResource();
          res.setPreventJoining(true);
-
+         
          XAResource res2 = new DummyXAResource();
-
+         
          Transaction tx = tm.getTransaction();
          tx.enlistResource(res);
          tx.enlistResource(res2);
-
+         
          MessageConsumer cons = sess.createConsumer(queue);
+         
 
-
-         TextMessage m2 = (TextMessage)cons.receive(MAX_TIMEOUT);
-
+         TextMessage m2 = (TextMessage)cons.receive(1000);
+         
          assertNotNull(m2);
          assertEquals("XATest1", m2.getText());
-
-         m2 = (TextMessage)cons.receive(MAX_TIMEOUT);
-
+         
+         m2 = (TextMessage)cons.receive(1000);
+         
          assertNotNull(m2);
          assertEquals("XATest2", m2.getText());
-
-         tm.commit();
-
+         
+         tx.commit();
+         
          //New tx
          tm.begin();
          tx = tm.getTransaction();
          tx.enlistResource(res);
          tx.enlistResource(res2);
-
-         Message m3 = cons.receive(MIN_TIMEOUT);
-
+         
+         Message m3 = cons.receive(1000);
+         
          assertNull(m3);
-
+         
          tm.commit();
+         
 
-
       }
       finally
       {
@@ -996,18 +1072,18 @@
             conn2.close();
          }
       }
-
+      
    }
-
+   
    public void test2PCReceiveRollback1PCOptimization() throws Exception
    {
       if (ServerManagement.isRemote()) return;
-
+      
       //Since both resources have some RM, TM will probably use 1PC optimization
-
+      
       XAConnection conn = null;
       Connection conn2 = null;
-
+      
       try
       {
          conn2 = cf.createConnection();
@@ -1015,54 +1091,58 @@
          MessageProducer prod  = sessProducer.createProducer(queue);
          Message m = sessProducer.createTextMessage("XATest1");
          prod.send(m);
-
+         
          m = sessProducer.createTextMessage("XATest2");
          prod.send(m);
-
-
+         
+         
          conn = cf.createXAConnection();
-         conn.start();
-
+         conn.start();   
+         
          tm.begin();
-
+         
          XASession sess = conn.createXASession();
          XAResource res = sess.getXAResource();
-
+         
          XAResource res2 = new DummyXAResource();
-
+         
          Transaction tx = tm.getTransaction();
          tx.enlistResource(res);
          tx.enlistResource(res2);
-
+         
          MessageConsumer cons = sess.createConsumer(queue);
+         
 
-
-         TextMessage m2 = (TextMessage)cons.receive(MAX_TIMEOUT);
+         TextMessage m2 = (TextMessage)cons.receive(1000);         
          assertNotNull(m2);
          assertEquals("XATest1", m2.getText());
-         m2 = (TextMessage)cons.receive(MAX_TIMEOUT);
+         m2 = (TextMessage)cons.receive(1000);         
          assertNotNull(m2);
          assertEquals("XATest2", m2.getText());
-
-         tm.rollback();
-
+         
+         tx.rollback();
+         
+         //Give enough time for the messages to get back in the queue (cancel is asynch)
+         
+         Thread.sleep(500);
+         
          //Message should be redelivered
-
+         
          //New tx
          tm.begin();
          tx = tm.getTransaction();
          tx.enlistResource(res);
          tx.enlistResource(res2);
-
-         TextMessage m3 = (TextMessage)cons.receive(MAX_TIMEOUT);
+         
+         TextMessage m3 = (TextMessage)cons.receive(1000);         
          assertNotNull(m3);
          assertEquals("XATest1", m3.getText());
-         m3 = (TextMessage)cons.receive(MAX_TIMEOUT);
+         m3 = (TextMessage)cons.receive(1000);         
          assertNotNull(m3);
          assertEquals("XATest2", m3.getText());
-
+         
          assertTrue(m3.getJMSRedelivered());
-
+         
          tm.commit();
 
       }
@@ -1077,16 +1157,16 @@
             conn2.close();
          }
       }
-
+      
    }
-
+   
    public void test2PCReceiveRollback() throws Exception
    {
       if (ServerManagement.isRemote()) return;
-
+      
       XAConnection conn = null;
       Connection conn2 = null;
-
+      
       try
       {
          conn2 = cf.createConnection();
@@ -1094,55 +1174,59 @@
          MessageProducer prod  = sessProducer.createProducer(queue);
          Message m = sessProducer.createTextMessage("XATest1");
          prod.send(m);
-
+         
          m = sessProducer.createTextMessage("XATest2");
          prod.send(m);
-
-
+         
+         
          conn = cf.createXAConnection();
-         conn.start();
-
+         conn.start();   
+         
          tm.begin();
-
+         
          XASession sess = conn.createXASession();
          MessagingXAResource res = (MessagingXAResource)sess.getXAResource();
          res.setPreventJoining(true);
-
+         
          XAResource res2 = new DummyXAResource();
-
+         
          Transaction tx = tm.getTransaction();
          tx.enlistResource(res);
          tx.enlistResource(res2);
-
+         
          MessageConsumer cons = sess.createConsumer(queue);
+         
 
-
-         TextMessage m2 = (TextMessage)cons.receive(MAX_TIMEOUT);
+         TextMessage m2 = (TextMessage)cons.receive(1000);         
          assertNotNull(m2);
          assertEquals("XATest1", m2.getText());
-         m2 = (TextMessage)cons.receive(MAX_TIMEOUT);
+         m2 = (TextMessage)cons.receive(1000);         
          assertNotNull(m2);
          assertEquals("XATest2", m2.getText());
-
-         tm.rollback();
-
+         
+         tx.rollback();
+         
+         //Give enough time for the messages to get back in the queue (cancel is asynch)
+         
+         Thread.sleep(500);
+         
          //Message should be redelivered
-
+         
          //New tx
          tm.begin();
          tx = tm.getTransaction();
          tx.enlistResource(res);
          tx.enlistResource(res2);
-
-         TextMessage m3 = (TextMessage)cons.receive(MAX_TIMEOUT);
+         
+         TextMessage m3 = (TextMessage)cons.receive(1000);         
          assertNotNull(m3);
          assertEquals("XATest1", m3.getText());
-         m3 = (TextMessage)cons.receive(MAX_TIMEOUT);
+         m3 = (TextMessage)cons.receive(1000);         
          assertNotNull(m3);
          assertEquals("XATest2", m3.getText());
-
+         
          assertTrue(m3.getJMSRedelivered());
-
+         
          tm.commit();
 
       }
@@ -1157,49 +1241,49 @@
             conn2.close();
          }
       }
-
+      
    }
-
-
+   
+   
    public void test1PCSendCommit() throws Exception
    {
       if (ServerManagement.isRemote()) return;
-
+      
       XAConnection conn = null;
       Connection conn2 = null;
-
+      
       try
       {
-
+      
          conn = cf.createXAConnection();
-
+         
          tm.begin();
-
+         
          XASession sess = conn.createXASession();
          XAResource res = sess.getXAResource();
-
-
+         
+         
          Transaction tx = tm.getTransaction();
          tx.enlistResource(res);
 
-
+         
          MessageProducer prod = sess.createProducer(queue);
          prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
          Message m = sess.createTextMessage("XATest1");
          prod.send(queue, m);
          m = sess.createTextMessage("XATest2");
          prod.send(queue, m);
-
-         tm.commit();
-
+         
+         tx.commit();
+         
          conn2 = cf.createConnection();
          conn2.start();
          Session sessReceiver = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
          MessageConsumer cons = sessReceiver.createConsumer(queue);
-         TextMessage m2 = (TextMessage)cons.receive(MAX_TIMEOUT);
+         TextMessage m2 = (TextMessage)cons.receive(1000);
          assertNotNull(m2);
          assertEquals("XATest1", m2.getText());
-         m2 = (TextMessage)cons.receive(MAX_TIMEOUT);
+         m2 = (TextMessage)cons.receive(1000);
          assertNotNull(m2);
          assertEquals("XATest2", m2.getText());
       }
@@ -1216,20 +1300,20 @@
       }
 
    }
-
-
+   
+   
    public void test1PCSendRollback() throws Exception
    {
       if (ServerManagement.isRemote()) return;
-
+      
       XAConnection conn = null;
       Connection conn2 = null;
       try
       {
          conn = cf.createXAConnection();
-
+         
          tm.begin();
-
+         
          XASession sess = conn.createXASession();
          XAResource res = sess.getXAResource();
 
@@ -1239,19 +1323,23 @@
          MessageProducer prod = sess.createProducer(queue);
          prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
          Message m = sess.createTextMessage("XATest1");
-         prod.send(queue, m);
+         prod.send(queue, m); 
          m = sess.createTextMessage("XATest2");
-         prod.send(queue, m);
-
-         tm.rollback();
-
+         prod.send(queue, m); 
+         
+         tx.rollback();
+         
+         //Give enough time for the messages to get back in the queue (cancel is asynch)
+         
+         Thread.sleep(500);
+         
          conn2 = cf.createConnection();
          conn2.start();
          Session sessReceiver = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
          MessageConsumer cons = sessReceiver.createConsumer(queue);
-         Message m2 = cons.receive(MIN_TIMEOUT);
+         Message m2 = cons.receive(1000);
          assertNull(m2);
-
+   
       }
       finally
       {
@@ -1269,10 +1357,10 @@
    public void test1PCReceiveCommit() throws Exception
    {
       if (ServerManagement.isRemote()) return;
-
+      
       XAConnection conn = null;
       Connection conn2 = null;
-
+      
       try
       {
          conn2 = cf.createConnection();
@@ -1283,44 +1371,44 @@
          prod.send(m);
          m = sessProducer.createTextMessage("XATest2");
          prod.send(m);
-
+         
          conn = cf.createXAConnection();
          conn.start();
-
+         
          tm.begin();
-
+         
          XASession sess = conn.createXASession();
          XAResource res = sess.getXAResource();
-
+         
          Transaction tx = tm.getTransaction();
          tx.enlistResource(res);
-
+         
          MessageConsumer cons = sess.createConsumer(queue);
+         
 
-
-         TextMessage m2 = (TextMessage)cons.receive(MAX_TIMEOUT);
-
+         TextMessage m2 = (TextMessage)cons.receive(1000);
+         
          assertNotNull(m2);
          assertEquals("XATest1", m2.getText());
-         m2 = (TextMessage)cons.receive(MAX_TIMEOUT);
-
+         m2 = (TextMessage)cons.receive(1000);
+         
          assertNotNull(m2);
          assertEquals("XATest2", m2.getText());
-
-         tm.commit();
-
+         
+         tx.commit();
+         
          //New tx
          tm.begin();
          tx = tm.getTransaction();
          tx.enlistResource(res);
-
-         Message m3 = cons.receive(MIN_TIMEOUT);
-
+         
+         Message m3 = cons.receive(1000);
+         
          assertNull(m3);
-
+         
          tm.commit();
+         
 
-
       }
       finally
       {
@@ -1333,16 +1421,16 @@
             conn2.close();
          }
       }
-
+      
    }
-
+   
    public void test1PCReceiveRollback() throws Exception
    {
       if (ServerManagement.isRemote()) return;
-
+      
       XAConnection conn = null;
       Connection conn2 = null;
-
+      
       try
       {
          conn2 = cf.createConnection();
@@ -1352,53 +1440,57 @@
          prod.send(m);
          m = sessProducer.createTextMessage("XATest2");
          prod.send(m);
-
-
+         
+         
          conn = cf.createXAConnection();
-         conn.start();
-
+         conn.start();   
+         
          tm.begin();
-
+         
          XASession sess = conn.createXASession();
          XAResource res = sess.getXAResource();
-
+         
          Transaction tx = tm.getTransaction();
          tx.enlistResource(res);
 
          MessageConsumer cons = sess.createConsumer(queue);
+         
 
-
-         TextMessage m2 = (TextMessage)cons.receive(MAX_TIMEOUT);
-
+         TextMessage m2 = (TextMessage)cons.receive(1000);
+         
          assertNotNull(m2);
          assertEquals("XATest1", m2.getText());
-
-         m2 = (TextMessage)cons.receive(MAX_TIMEOUT);
-
+         
+         m2 = (TextMessage)cons.receive(1000);
+         
          assertNotNull(m2);
          assertEquals("XATest2", m2.getText());
-
-         tm.rollback();
-
+         
+         tx.rollback();
+         
+         //Give enough time for the messages to get back in the queue (cancel is asynch)
+         
+         Thread.sleep(500);
+         
          //Message should be redelivered
-
+         
          //New tx
          tm.begin();
          tx = tm.getTransaction();
          tx.enlistResource(res);
-
-         TextMessage m3 = (TextMessage)cons.receive(MAX_TIMEOUT);
-
+         
+         TextMessage m3 = (TextMessage)cons.receive(1000);
+         
          assertNotNull(m3);
          assertEquals("XATest1", m3.getText());
-
-         m3 = (TextMessage)cons.receive(MAX_TIMEOUT);
-
+         
+         m3 = (TextMessage)cons.receive(1000);
+         
          assertNotNull(m3);
          assertEquals("XATest2", m3.getText());
-
+         
          assertTrue(m3.getJMSRedelivered());
-
+         
          tm.commit();
 
       }
@@ -1413,18 +1505,18 @@
             conn2.close();
          }
       }
-
+      
    }
-
+   
    public void testMultipleSessionsOneTxCommitAcknowledge1PCOptimization() throws Exception
    {
       if (ServerManagement.isRemote()) return;
-
+      
       XAConnection conn = null;
       Connection conn2 = null;
-
+      
       //Since both resources have some RM, TM will probably use 1PC optimization
-
+      
       try
       {
          //First send 2 messages
@@ -1435,50 +1527,50 @@
          prod.send(m);
          m = sessProducer.createTextMessage("jellyfish2");
          prod.send(m);
-
-
+         
+         
          conn = cf.createXAConnection();
-         conn.start();
-
+         conn.start();   
+         
          tm.begin();
-
+         
          //Create 2 sessions and enlist them
          XASession sess1 = conn.createXASession();
          XAResource res1 = sess1.getXAResource();
          XASession sess2 = conn.createXASession();
          XAResource res2 = sess2.getXAResource();
-
+         
          Transaction tx = tm.getTransaction();
          tx.enlistResource(res1);
          tx.enlistResource(res2);
-
+         
          //Receive the messages, one on each consumer
          MessageConsumer cons1 = sess1.createConsumer(queue);
-         TextMessage r1 = (TextMessage)cons1.receive(MAX_TIMEOUT);
-
+         TextMessage r1 = (TextMessage)cons1.receive(1000);
+         
          assertNotNull(r1);
          assertEquals("jellyfish1", r1.getText());
-
+                  
          cons1.close();
-
+         
          MessageConsumer cons2 = sess2.createConsumer(queue);
-         TextMessage r2 = (TextMessage)cons2.receive(MAX_TIMEOUT);
-
+         TextMessage r2 = (TextMessage)cons2.receive(1000);
+         
          assertNotNull(r2);
          assertEquals("jellyfish2", r2.getText());
-
-         //commit
-         tm.commit();
-
+         
+         //commit        
+         tx.commit();
+         
          Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
          MessageConsumer cons = sess.createConsumer(queue);
          conn2.start();
-
-         TextMessage r3 = (TextMessage)cons.receive(MIN_TIMEOUT);
+         
+         TextMessage r3 = (TextMessage)cons.receive(1000);
          assertNull(r3);
+       
+         
 
-
-
       }
       finally
       {
@@ -1491,16 +1583,16 @@
             conn2.close();
          }
       }
-
+      
    }
-
+   
    public void testMultipleSessionsOneTxCommitAcknowledge() throws Exception
    {
       if (ServerManagement.isRemote()) return;
-
+      
       XAConnection conn = null;
       Connection conn2 = null;
-
+      
       try
       {
          //First send 2 messages
@@ -1511,13 +1603,13 @@
          prod.send(m);
          m = sessProducer.createTextMessage("jellyfish2");
          prod.send(m);
-
-
+         
+         
          conn = cf.createXAConnection();
-         conn.start();
-
+         conn.start();   
+         
          tm.begin();
-
+         
          //Create 2 sessions and enlist them
          XASession sess1 = conn.createXASession();
          MessagingXAResource res1 = (MessagingXAResource)sess1.getXAResource();
@@ -1525,36 +1617,36 @@
          MessagingXAResource res2 = (MessagingXAResource)sess2.getXAResource();
          res1.setPreventJoining(true);
          res2.setPreventJoining(true);
-
+         
          Transaction tx = tm.getTransaction();
          tx.enlistResource(res1);
          tx.enlistResource(res2);
-
+         
          //Receive the messages, one on each consumer
          MessageConsumer cons1 = sess1.createConsumer(queue);
-         TextMessage r1 = (TextMessage)cons1.receive(MAX_TIMEOUT);
-
+         TextMessage r1 = (TextMessage)cons1.receive(1000);
+         
          assertNotNull(r1);
          assertEquals("jellyfish1", r1.getText());
-
+                  
          cons1.close();
-
+         
          MessageConsumer cons2 = sess2.createConsumer(queue);
-         TextMessage r2 = (TextMessage)cons2.receive(MAX_TIMEOUT);
-
+         TextMessage r2 = (TextMessage)cons2.receive(1000);
+         
          assertNotNull(r2);
          assertEquals("jellyfish2", r2.getText());
-
-         //commit
-         tm.commit();
-
+         
+         //commit        
+         tx.commit();
+         
          Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
          MessageConsumer cons = sess.createConsumer(queue);
          conn2.start();
-
-         TextMessage r3 = (TextMessage)cons.receive(MIN_TIMEOUT);
+         
+         TextMessage r3 = (TextMessage)cons.receive(1000);
          assertNull(r3);
-
+       
       }
       finally
       {
@@ -1567,19 +1659,19 @@
             conn2.close();
          }
       }
-
+      
    }
-
-
+   
+   
    public void testMultipleSessionsOneTxRollbackAcknowledge1PCOptimization() throws Exception
    {
       if (ServerManagement.isRemote()) return;
-
+      
       XAConnection conn = null;
       Connection conn2 = null;
-
+      
       //Since both resources have some RM, TM will probably use 1PC optimization
-
+      
       try
       {
          //First send 2 messages
@@ -1594,129 +1686,79 @@
          prod.send(m);
          m = sessProducer.createTextMessage("jellyfish4");
          prod.send(m);
-
-
+         
+         
          conn = cf.createXAConnection();
-         conn.start();
-
+         conn.start();   
+         
          tm.begin();
-
+         
          //Create 2 sessions and enlist them
          XASession sess1 = conn.createXASession();
          MessagingXAResource res1 = (MessagingXAResource)sess1.getXAResource();
          XASession sess2 = conn.createXASession();
          MessagingXAResource res2 = (MessagingXAResource)sess2.getXAResource();
-
+ 
          Transaction tx = tm.getTransaction();
          tx.enlistResource(res1);
          tx.enlistResource(res2);
-
+         
          //Receive the messages, two on each consumer
          MessageConsumer cons1 = sess1.createConsumer(queue);
-         TextMessage r1 = (TextMessage)cons1.receive(MAX_TIMEOUT);
-
+         TextMessage r1 = (TextMessage)cons1.receive(1000);
+         
          assertNotNull(r1);
          assertEquals("jellyfish1", r1.getText());
-
-         r1 = (TextMessage)cons1.receive(MAX_TIMEOUT);
-
+         
+         r1 = (TextMessage)cons1.receive(1000);
+         
          assertNotNull(r1);
          assertEquals("jellyfish2", r1.getText());
-
+                  
          cons1.close();
-
+      
          MessageConsumer cons2 = sess2.createConsumer(queue);
-         TextMessage r2 = (TextMessage)cons2.receive(MAX_TIMEOUT);
-
+         TextMessage r2 = (TextMessage)cons2.receive(1000);
+         
          assertNotNull(r2);
          assertEquals("jellyfish3", r2.getText());
-
-         r2 = (TextMessage)cons2.receive(MAX_TIMEOUT);
-
+         
+         r2 = (TextMessage)cons2.receive(1000);
+         
          assertNotNull(r2);
          assertEquals("jellyfish4", r2.getText());
-
-         cons2.close();
-
-         //rollback
-
-         tm.rollback();
-           
-         //Rollback causes cancel which is asynch
-         Thread.sleep(1000);
          
-         //We cannot assume anything about the order in which the transaction manager rollsback
-         //the sessions - this is implementation dependent
-
-         Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         MessageConsumer cons = sess.createConsumer(queue);
-         conn2.start();         
+         cons2.close();            
          
-         TextMessage r = (TextMessage)cons.receive(MAX_TIMEOUT);
-         assertNotNull(r);
+         //rollback                          
          
-         boolean session1First = false;
+         tx.rollback();
          
-         if (r.getText().equals("jellyfish1"))
-         {
-            session1First = true;
-         }
-         else if (r.getText().equals("jellyfish3"))
-         {
-            session1First = false;
-         }
-         else
-         {
-            fail("Unexpected message");
-         }
+         //Give enough time for the messages to get back in the queue (cancel is asynch)
          
-         if (session1First)
-         {
-            r = (TextMessage)cons.receive(MAX_TIMEOUT);
-            
-            assertNotNull(r);
-            
-            assertEquals("jellyfish2", r.getText());
-            
-            r = (TextMessage)cons.receive(MAX_TIMEOUT);
-            
-            assertNotNull(r);
-            
-            assertEquals("jellyfish3", r.getText());
-            
-            r = (TextMessage)cons.receive(MAX_TIMEOUT);
-            
-            assertNotNull(r);
-            
-            assertEquals("jellyfish4", r.getText());
-            
-            
-         }
-         else
-         {
-            r = (TextMessage)cons.receive(MAX_TIMEOUT);
-            
-            assertNotNull(r);
-            
-            assertEquals("jellyfish4", r.getText());
-            
-            r = (TextMessage)cons.receive(MAX_TIMEOUT);
-            
-            assertNotNull(r);
-            
-            assertEquals("jellyfish1", r.getText());
-            
-            r = (TextMessage)cons.receive(MAX_TIMEOUT);
-            
-            assertNotNull(r);
-            
-            assertEquals("jellyfish2", r.getText());
-         }
+         Thread.sleep(500);
          
-         r = (TextMessage)cons.receive(MIN_TIMEOUT);
+         Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+         MessageConsumer cons = sess.createConsumer(queue);
+         conn2.start();
          
-         assertNull(r);
+         TextMessage r3 = (TextMessage)cons.receive(1000);         
+         assertNotNull(r3);
+         assertEquals("jellyfish1", r3.getText());
+         
+         r3 = (TextMessage)cons.receive(1000);         
+         assertNotNull(r3);
+         assertEquals("jellyfish2", r3.getText());
 
+         TextMessage r4 = (TextMessage)cons.receive(1000);         
+         assertNotNull(r4);
+         assertEquals("jellyfish3", r4.getText());
+
+         r4 = (TextMessage)cons.receive(1000);         
+         assertNotNull(r4);
+         assertEquals("jellyfish4", r4.getText());
+         
+
       }
       finally
       {
@@ -1729,13 +1771,13 @@
             conn2.close();
          }
       }
-
+      
    }
-
+   
    public void testMultipleSessionsOneTxRollbackAcknowledge() throws Exception
    {
       if (ServerManagement.isRemote()) return;
-
+      
       XAConnection conn = null;
       Connection conn2 = null;
 
@@ -1753,13 +1795,13 @@
          prod.send(m);
          m = sessProducer.createTextMessage("jellyfish4");
          prod.send(m);
-
-
+         
+         
          conn = cf.createXAConnection();
-         conn.start();
-
+         conn.start();   
+         
          tm.begin();
-
+         
          //Create 2 sessions and enlist them
          XASession sess1 = conn.createXASession();
          MessagingXAResource res1 = (MessagingXAResource)sess1.getXAResource();
@@ -1767,119 +1809,73 @@
          MessagingXAResource res2 = (MessagingXAResource)sess2.getXAResource();
          res1.setPreventJoining(true);
          res2.setPreventJoining(true);
-
+         
          Transaction tx = tm.getTransaction();
          tx.enlistResource(res1);
          tx.enlistResource(res2);
-
+         
          //Receive the messages, two on each consumer
          MessageConsumer cons1 = sess1.createConsumer(queue);
-         TextMessage r1 = (TextMessage)cons1.receive(MAX_TIMEOUT);
-
+         TextMessage r1 = (TextMessage)cons1.receive(1000);
+         
          assertNotNull(r1);
          assertEquals("jellyfish1", r1.getText());
-
-         r1 = (TextMessage)cons1.receive(MAX_TIMEOUT);
-
+         
+         r1 = (TextMessage)cons1.receive(1000);
+         
          assertNotNull(r1);
          assertEquals("jellyfish2", r1.getText());
-
+                  
          cons1.close();
-
+         
          MessageConsumer cons2 = sess2.createConsumer(queue);
-         TextMessage r2 = (TextMessage)cons2.receive(MAX_TIMEOUT);
-
+         TextMessage r2 = (TextMessage)cons2.receive(1000);
+         
          assertNotNull(r2);
          assertEquals("jellyfish3", r2.getText());
-
-         r2 = (TextMessage)cons2.receive(MAX_TIMEOUT);
-
+         
+         r2 = (TextMessage)cons2.receive(1000);
+         
          assertNotNull(r2);
          assertEquals("jellyfish4", r2.getText());
-
-         //rollback
-
+         
+         //rollback                 
+         
          cons2.close();
-
-         tm.rollback();
          
-         // Rollback causes cancel which is asynch
-         Thread.sleep(1000);
+         tx.rollback();
          
-         //We cannot assume anything about the order in which the transaction manager rollsback
-         //the sessions - this is implementation dependent
-
-
+         //Give enough time for the messages to get back in the queue (cancel is asynch)
+         
+         Thread.sleep(500);
+         
          Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
          MessageConsumer cons = sess.createConsumer(queue);
-         conn2.start();
-
-         TextMessage r = (TextMessage)cons.receive(MAX_TIMEOUT);
-         assertNotNull(r);
+         conn2.start();         
          
-         boolean session1First = false;
+         //NOTE
+         //The order here is actually probably dependent on the transaction manager implementation
+         //In this case, rollback will be called on each session, but whether it is called first on res1
+         //or res2 determines the order the messages are put back in the queue
+         //This test assumes it is called in order res1, res2
          
-         if (r.getText().equals("jellyfish1"))
-         {
-            session1First = true;
-         }
-         else if (r.getText().equals("jellyfish3"))
-         {
-            session1First = false;
-         }
-         else
-         {
-            fail("Unexpected message");
-         }
+         TextMessage r3 = (TextMessage)cons.receive(1000);         
+         assertNotNull(r3);
+         assertEquals("jellyfish3", r3.getText());
          
-         if (session1First)
-         {
-            r = (TextMessage)cons.receive(MAX_TIMEOUT);
-            
-            assertNotNull(r);
-            
-            assertEquals("jellyfish2", r.getText());
-            
-            r = (TextMessage)cons.receive(MAX_TIMEOUT);
-            
-            assertNotNull(r);
-            
-            assertEquals("jellyfish3", r.getText());
-            
-            r = (TextMessage)cons.receive(MAX_TIMEOUT);
-            
-            assertNotNull(r);
-            
-            assertEquals("jellyfish4", r.getText());
-            
-            
-         }
-         else
-         {
-            r = (TextMessage)cons.receive(MAX_TIMEOUT);
-            
-            assertNotNull(r);
-            
-            assertEquals("jellyfish4", r.getText());
-            
-            r = (TextMessage)cons.receive(MAX_TIMEOUT);
-            
-            assertNotNull(r);
-            
-            assertEquals("jellyfish1", r.getText());
-            
-            r = (TextMessage)cons.receive(MAX_TIMEOUT);
-            
-            assertNotNull(r);
-            
-            assertEquals("jellyfish2", r.getText());
-         }
+         r3 = (TextMessage)cons.receive(1000);         
+         assertNotNull(r3);
+         assertEquals("jellyfish4", r3.getText());
+
+         TextMessage r4 = (TextMessage)cons.receive(1000);         
+         assertNotNull(r4);
+         assertEquals("jellyfish1", r4.getText());
+  
+         r4 = (TextMessage)cons.receive(1000);         
+         assertNotNull(r4);
+         assertEquals("jellyfish2", r4.getText());
          
-         r = (TextMessage)cons.receive(MIN_TIMEOUT);
-         
-         assertNull(r);
 
-
       }
       finally
       {
@@ -1892,13 +1888,13 @@
             conn2.close();
          }
       }
-
+      
    }
-
+   
    public void testMultipleSessionsOneTxRollbackAcknowledgeForceFailureInCommit() throws Exception
    {
       if (ServerManagement.isRemote()) return;
-
+      
       XAConnection conn = null;
       Connection conn2 = null;
 
@@ -1908,7 +1904,6 @@
          conn2 = cf.createConnection();
          Session sessProducer = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
          MessageProducer prod  = sessProducer.createProducer(queue);
-         
          Message m = sessProducer.createTextMessage("jellyfish1");
          prod.send(m);
          m = sessProducer.createTextMessage("jellyfish2");
@@ -1917,101 +1912,79 @@
          prod.send(m);
          m = sessProducer.createTextMessage("jellyfish4");
          prod.send(m);
-
+         
+         
          conn = cf.createXAConnection();
-         conn.start();
+         conn.start();   
          
          tm.begin();
-
+         
          XASession sess1 = conn.createXASession();
          MessagingXAResource res1 = (MessagingXAResource)sess1.getXAResource();
          DummyXAResource res2 = new DummyXAResource(true);
          res1.setPreventJoining(true);
-
+                  
          Transaction tx = tm.getTransaction();
          tx.enlistResource(res1);
          tx.enlistResource(res2);
-
+         
          MessageConsumer cons1 = sess1.createConsumer(queue);
-         TextMessage r1 = (TextMessage)cons1.receive(MAX_TIMEOUT);
-
+         TextMessage r1 = (TextMessage)cons1.receive(1000);
+         
          assertNotNull(r1);
          assertEquals("jellyfish1", r1.getText());
-
-         r1 = (TextMessage)cons1.receive(MAX_TIMEOUT);
-
+         
+         r1 = (TextMessage)cons1.receive(1000);
+         
          assertNotNull(r1);
          assertEquals("jellyfish2", r1.getText());
-
-         r1 = (TextMessage)cons1.receive(MAX_TIMEOUT);
-
+         
+         r1 = (TextMessage)cons1.receive(1000);
+         
          assertNotNull(r1);
          assertEquals("jellyfish3", r1.getText());
-
-         r1 = (TextMessage)cons1.receive(MAX_TIMEOUT);
-
-         assertNotNull(r1);
-         assertEquals("jellyfish4", r1.getText());
          
          r1 = (TextMessage)cons1.receive(1000);
          
-         assertNull(r1);
-
+         assertNotNull(r1);
+         assertEquals("jellyfish4", r1.getText());
+                  
          cons1.close();
-
-
-         //try and commit - and we're going to make the dummyxaresource throw an exception on commit,
-         //which should cause rollback to be called on the other resource
          
          
-         //rollback will cause an attemp to deliver messages locally to the original consumers.
-         //the original consumer has closed, so it will cancelled to the server
-         //the server cancel is asynch, so we need to sleep for a bit to make sure it completes
-         log.trace("Forcing failure");
+         
+         //try and commit - and we're going to make the dummyxaresource throw an exception on commit,
+         //which should cause rollback to be called on the other resource
          try
          {
-            tm.commit();
-            fail("should not get here");
+            tx.commit();
          }
          catch (Exception e)
          {
             //We should expect this
          }
          
-         Thread.sleep(1000);
-         
-         
          Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
          MessageConsumer cons = sess.createConsumer(queue);
          conn2.start();
-
-         TextMessage r = (TextMessage)cons.receive(MAX_TIMEOUT);
+          
+         TextMessage r3 = (TextMessage)cons.receive(1000);         
+         assertNotNull(r3);
+         assertEquals("jellyfish1", r3.getText());
          
-         assertNotNull(r);
+         r3 = (TextMessage)cons.receive(1000);         
+         assertNotNull(r3);
+         assertEquals("jellyfish2", r3.getText());
+  
+         TextMessage r4 = (TextMessage)cons.receive(1000);         
+         assertNotNull(r4);
+         assertEquals("jellyfish3", r4.getText());
+      
+         r4 = (TextMessage)cons.receive(1000);         
+         assertNotNull(r4);
+         assertEquals("jellyfish4", r4.getText());
          
-         assertEquals("jellyfish1", r.getText());
-         
-         r = (TextMessage)cons.receive(MAX_TIMEOUT);
-         
-         assertNotNull(r);
-         
-         assertEquals("jellyfish2", r.getText());
-         
-         r = (TextMessage)cons.receive(MAX_TIMEOUT);
-         
-         assertNotNull(r);
-         
-         assertEquals("jellyfish3", r.getText());
-         
-         r = (TextMessage)cons.receive(MAX_TIMEOUT);
-         
-         assertNotNull(r);
-         
-         assertEquals("jellyfish4", r.getText());         
-         
-         r = (TextMessage)cons.receive(MIN_TIMEOUT);
-         
-         assertNull(r);
+
       }
       finally
       {
@@ -2024,59 +1997,60 @@
             conn2.close();
          }
       }
-
+      
    }
-
+   
    public void testMultipleSessionsOneTxCommitSend1PCOptimization() throws Exception
    {
       if (ServerManagement.isRemote()) return;
-
+      
       //Since both resources have some RM, TM will probably use 1PC optimization
-
+      
       XAConnection conn = null;
-
+      
       Connection conn2 = null;
-
+      
       try
       {
+         
          conn = cf.createXAConnection();
-         conn.start();
-
+         conn.start();   
+         
          tm.begin();
-
+         
          //Create 2 sessions and enlist them
          XASession sess1 = conn.createXASession();
          XAResource res1 = sess1.getXAResource();
          XASession sess2 = conn.createXASession();
          XAResource res2 = sess2.getXAResource();
-
+         
          Transaction tx = tm.getTransaction();
          tx.enlistResource(res1);
          tx.enlistResource(res2);
-
+         
          // Send 2 messages - one from each session
-
+         
          MessageProducer prod1 = sess1.createProducer(queue);
          MessageProducer prod2 = sess2.createProducer(queue);
-
+         
          prod1.send(sess1.createTextMessage("echidna1"));
          prod2.send(sess2.createTextMessage("echidna2"));
-
+         
          //commit
-         tm.commit();
-
+         tx.commit();
+         
          //Messages should be in queue
-
+         
          conn2 = cf.createConnection();
          Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
          MessageConsumer cons = sess.createConsumer(queue);
          conn2.start();
-
-         TextMessage r1 = (TextMessage)cons.receive(MAX_TIMEOUT);
+         
+         TextMessage r1 = (TextMessage)cons.receive(1000);
          assertNotNull(r1);
          assertEquals("echidna1", r1.getText());
-
-         TextMessage r2 = (TextMessage)cons.receive(MAX_TIMEOUT);
+         
+         TextMessage r2 = (TextMessage)cons.receive(1000);
          assertNotNull(r2);
          assertEquals("echidna2", r2.getText());
 
@@ -2093,27 +2067,27 @@
          }
 
       }
-
+      
    }
-
+   
    public void testMultipleSessionsOneTxCommitSend() throws Exception
    {
       if (ServerManagement.isRemote()) return;
-
+      
       //Since both resources have some RM, TM will probably use 1PC optimization
-
+      
       XAConnection conn = null;
-
+      
       Connection conn2 = null;
-
+      
       try
       {
-
+         
          conn = cf.createXAConnection();
-         conn.start();
-
+         conn.start();   
+         
          tm.begin();
-
+         
          //Create 2 sessions and enlist them
          XASession sess1 = conn.createXASession();
          MessagingXAResource res1 = (MessagingXAResource)sess1.getXAResource();
@@ -2121,34 +2095,34 @@
          MessagingXAResource res2 = (MessagingXAResource)sess2.getXAResource();
          res1.setPreventJoining(true);
          res2.setPreventJoining(true);
-
+         
          Transaction tx = tm.getTransaction();
          tx.enlistResource(res1);
          tx.enlistResource(res2);
-
+         
          // Send 2 messages - one from each session
-
+         
          MessageProducer prod1 = sess1.createProducer(queue);
          MessageProducer prod2 = sess2.createProducer(queue);
-
+         
          prod1.send(sess1.createTextMessage("echidna1"));
          prod2.send(sess2.createTextMessage("echidna2"));
-
+         
          //commit
-         tm.commit();
-
+         tx.commit();
+         
          //Messages should be in queue
-
+         
          conn2 = cf.createConnection();
          Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
          MessageConsumer cons = sess.createConsumer(queue);
          conn2.start();
-
-         TextMessage r1 = (TextMessage)cons.receive(MAX_TIMEOUT);
+         
+         TextMessage r1 = (TextMessage)cons.receive(1000);
          assertNotNull(r1);
          assertEquals("echidna1", r1.getText());
-
-         TextMessage r2 = (TextMessage)cons.receive(MAX_TIMEOUT);
+         
+         TextMessage r2 = (TextMessage)cons.receive(1000);
          assertNotNull(r2);
          assertEquals("echidna2", r2.getText());
 
@@ -2165,60 +2139,64 @@
          }
 
       }
-
+      
    }
-
-
+   
+   
    public void testMultipleSessionsOneTxRollbackSend1PCOptimization() throws Exception
    {
       if (ServerManagement.isRemote()) return;
-
+      
       //Since both resources have some RM, TM will probably use 1PC optimization
-
+      
       XAConnection conn = null;
-
+      
       Connection conn2 = null;
-
+      
       try
       {
-
+         
          conn = cf.createXAConnection();
-         conn.start();
-
+         conn.start();   
+         
          tm.begin();
-
+         
          //Create 2 sessions and enlist them
          XASession sess1 = conn.createXASession();
          XAResource res1 = sess1.getXAResource();
          XASession sess2 = conn.createXASession();
          XAResource res2 = sess2.getXAResource();
-
+         
          Transaction tx = tm.getTransaction();
          tx.enlistResource(res1);
          tx.enlistResource(res2);
-
+         
          // Send 2 messages - one from each session
-
+         
          MessageProducer prod1 = sess1.createProducer(queue);
          MessageProducer prod2 = sess2.createProducer(queue);
-
+         
          prod1.send(sess1.createTextMessage("echidna1"));
          prod2.send(sess2.createTextMessage("echidna2"));
-
+         
          //rollback
-         tm.rollback();
-
+         tx.rollback();
+         
+         //Give enough time for the messages to get back in the queue (cancel is asynch)
+         
+         Thread.sleep(500);
+         
          //Messages should not be in queue
-
+         
          conn2 = cf.createConnection();
          Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
          MessageConsumer cons = sess.createConsumer(queue);
          conn2.start();
-
-         TextMessage r1 = (TextMessage)cons.receive(MIN_TIMEOUT);
+         
+         TextMessage r1 = (TextMessage)cons.receive(1000);
          assertNull(r1);
+         
 
-
       }
       finally
       {
@@ -2232,25 +2210,25 @@
          }
 
       }
-
+      
    }
-
+   
    public void testMultipleSessionsOneTxRollbackSend() throws Exception
    {
       if (ServerManagement.isRemote()) return;
-
+      
       XAConnection conn = null;
-
+      
       Connection conn2 = null;
-
+      
       try
       {
-
+         
          conn = cf.createXAConnection();
-         conn.start();
-
+         conn.start();   
+         
          tm.begin();
-
+         
          //Create 2 sessions and enlist them
          XASession sess1 = conn.createXASession();
          MessagingXAResource res1 = (MessagingXAResource)sess1.getXAResource();
@@ -2258,33 +2236,37 @@
          MessagingXAResource res2 = (MessagingXAResource)sess2.getXAResource();
          res1.setPreventJoining(true);
          res2.setPreventJoining(true);
-
+         
          Transaction tx = tm.getTransaction();
          tx.enlistResource(res1);
          tx.enlistResource(res2);
-
+         
          // Send 2 messages - one from each session
-
+         
          MessageProducer prod1 = sess1.createProducer(queue);
          MessageProducer prod2 = sess2.createProducer(queue);
-
+         
          prod1.send(sess1.createTextMessage("echidna1"));
          prod2.send(sess2.createTextMessage("echidna2"));
-
+         
          //rollback
-         tm.rollback();
-
+         tx.rollback();
+         
+         //Give enough time for the messages to get back in the queue (cancel is asynch)
+         
+         Thread.sleep(500);
+         
          //Messages should not be in queue
-
+         
          conn2 = cf.createConnection();
          Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
          MessageConsumer cons = sess.createConsumer(queue);
          conn2.start();
-
-         TextMessage r1 = (TextMessage)cons.receive(MIN_TIMEOUT);
+         
+         TextMessage r1 = (TextMessage)cons.receive(1000);
          assertNull(r1);
+         
 
-
       }
       finally
       {
@@ -2298,20 +2280,20 @@
          }
 
       }
-
+      
    }
-
-
+   
+ 
    public void testOneSessionTwoTransactionsCommitAcknowledge() throws Exception
    {
       if (ServerManagement.isRemote()) return;
-
+      
       XAConnection conn = null;
-
+      
       Connection conn2 = null;
-
+      
       try
-      {
+      {         
          //First send 2 messages
          conn2 = cf.createConnection();
          Session sessProducer = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -2320,56 +2302,56 @@
          prod.send(m);
          m = sessProducer.createTextMessage("jellyfish2");
          prod.send(m);
-
+         
          conn = cf.createXAConnection();
 
          //Create a session
          XASession sess1 = conn.createXASession();
          XAResource res1 = sess1.getXAResource();
-
+                  
          conn.start();
          MessageConsumer cons1 = sess1.createConsumer(queue);
-
+                  
          tm.begin();
-
+         
          Transaction tx1 = tm.getTransaction();
          tx1.enlistResource(res1);
-
+         
          //Receive one message in one tx
-
-         TextMessage r1 = (TextMessage)cons1.receive(MAX_TIMEOUT);
+         
+         TextMessage r1 = (TextMessage)cons1.receive(1000);
          assertNotNull(r1);
          assertEquals("jellyfish1", r1.getText());
-
+         
          //suspend the tx
          Transaction suspended = tm.suspend();
-
+         
          tm.begin();
-
+                  
          Transaction tx2 = tm.getTransaction();
          tx2.enlistResource(res1);
-
+         
          //Receive 2nd message in a different tx
-         TextMessage r2 = (TextMessage)cons1.receive(MAX_TIMEOUT);
+         TextMessage r2 = (TextMessage)cons1.receive(1000);
          assertNotNull(r2);
          assertEquals("jellyfish2", r2.getText());
-
+         
          //commit this transaction
-         tm.commit();
-
+         tx2.commit();
+         
          //verify that no messages are available
          conn2 = cf.createConnection();
          Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
          conn2.start();
          MessageConsumer cons = sess.createConsumer(queue);
-         TextMessage r3 = (TextMessage)cons.receive(MIN_TIMEOUT);
+         TextMessage r3 = (TextMessage)cons.receive(1000);
          assertNull(r3);
-
+         
          //now resume the first tx and then commit it
          tm.resume(suspended);
-         tm.commit();
+         suspended.commit();
+         
 
-
       }
       finally
       {
@@ -2383,20 +2365,20 @@
          }
 
       }
-
+      
    }
-
-
+   
+   
    public void testOneSessionTwoTransactionsRollbackAcknowledge() throws Exception
    {
       if (ServerManagement.isRemote()) return;
-
+       
       XAConnection conn = null;
-
+      
       Connection conn2 = null;
-
+      
       try
-      {
+      {         
          //First send 2 messages
          conn2 = cf.createConnection();
          Session sessProducer = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -2405,70 +2387,78 @@
          prod.send(m);
          m = sessProducer.createTextMessage("jellyfish2");
          prod.send(m);
-
+         
          conn = cf.createXAConnection();
 
          //Create a session
          XASession sess1 = conn.createXASession();
          XAResource res1 = sess1.getXAResource();
-
+                  
          conn.start();
          MessageConsumer cons1 = sess1.createConsumer(queue);
-
+                  
          tm.begin();
-
+         
          Transaction tx1 = tm.getTransaction();
          tx1.enlistResource(res1);
-
+         
          //Receive one message in one tx
-
-         TextMessage r1 = (TextMessage)cons1.receive(MAX_TIMEOUT);
+         
+         TextMessage r1 = (TextMessage)cons1.receive(1000);
          assertNotNull(r1);
          assertEquals("jellyfish1", r1.getText());
-
+         
          //suspend the tx
          Transaction suspended = tm.suspend();
-
+         
          tm.begin();
-
+                  
          Transaction tx2 = tm.getTransaction();
          tx2.enlistResource(res1);
-
+         
          //Receive 2nd message in a different tx
-         TextMessage r2 = (TextMessage)cons1.receive(MAX_TIMEOUT);
+         TextMessage r2 = (TextMessage)cons1.receive(1000);
          assertNotNull(r2);
          assertEquals("jellyfish2", r2.getText());
-
+         
          cons1.close();
-
+         
          //rollback this transaction
-         tm.rollback();
-
+         tx2.rollback();
+         
+         //Give enough time for the messages to get back in the queue (cancel is asynch)
+         
+         Thread.sleep(500);
+     
          //verify that second message is available
          conn2 = cf.createConnection();
          Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
          conn2.start();
          MessageConsumer cons = sess.createConsumer(queue);
 
-         TextMessage r3 = (TextMessage)cons.receive(MAX_TIMEOUT);
+         TextMessage r3 = (TextMessage)cons.receive(1000);
 
          assertNotNull(r3);
          assertEquals("jellyfish2", r3.getText());
-         r3 = (TextMessage)cons.receive(MIN_TIMEOUT);
+         r3 = (TextMessage)cons.receive(1000);
          assertNull(r3);
-
-
+         
+         
          //rollback the other tx
          tm.resume(suspended);
-         tm.rollback();
-
+         suspended.rollback();
+         
+         //Give enough time for the messages to get back in the queue (cancel is asynch)
+         
+         Thread.sleep(500);
+       
          //Verify the first message is now available
-         r3 = (TextMessage)cons.receive(MAX_TIMEOUT);
+         r3 = (TextMessage)cons.receive(1000);
          assertNotNull(r3);
          assertEquals("jellyfish1", r3.getText());
-         r3 = (TextMessage)cons.receive(MIN_TIMEOUT);
+         r3 = (TextMessage)cons.receive(1000);
          assertNull(r3);
-
+         
       }
       finally
       {
@@ -2482,72 +2472,72 @@
          }
 
       }
-
+      
    }
+   
 
-
    public void testOneSessionTwoTransactionsCommitSend() throws Exception
    {
       if (ServerManagement.isRemote()) return;
-
+      
       XAConnection conn = null;
-
+      
       Connection conn2 = null;
-
+      
       try
       {
-
+         
          conn = cf.createXAConnection();
 
          //Create a session
          XASession sess1 = conn.createXASession();
          XAResource res1 = sess1.getXAResource();
-
+         
          MessageProducer prod1 = sess1.createProducer(queue);
-
+                  
          tm.begin();
-
+         
          Transaction tx1 = tm.getTransaction();
          tx1.enlistResource(res1);
-
+         
          //Send a message
          prod1.send(sess1.createTextMessage("kangaroo1"));
-
+         
          //suspend the tx
          Transaction suspended = tm.suspend();
-
+         
          tm.begin();
-
+         
          //Send another message in another tx using the same session
          Transaction tx2 = tm.getTransaction();
          tx2.enlistResource(res1);
-
+         
          //Send a message
          prod1.send(sess1.createTextMessage("kangaroo2"));
-
+         
          //commit this transaction
-         tm.commit();
-
+         tx2.commit();
+         
          //verify only kangaroo2 message is sent
          conn2 = cf.createConnection();
          Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
          conn2.start();
          MessageConsumer cons = sess.createConsumer(queue);
-         TextMessage r1 = (TextMessage)cons.receive(MAX_TIMEOUT);
+         TextMessage r1 = (TextMessage)cons.receive(1000);
          assertNotNull(r1);
          assertEquals("kangaroo2", r1.getText());
-         TextMessage r2 = (TextMessage)cons.receive(MIN_TIMEOUT);
+         TextMessage r2 = (TextMessage)cons.receive(1000);
          assertNull(r2);
-
+         
          //now resume the first tx and then commit it
          tm.resume(suspended);
-         tm.commit();
-
+         suspended.commit();
+         
          //verify that the first text message is received
-         TextMessage r3 = (TextMessage)cons.receive(MAX_TIMEOUT);
+         TextMessage r3 = (TextMessage)cons.receive(1000);
          assertNotNull(r3);
          assertEquals("kangaroo1", r3.getText());
-
+         
       }
       finally
       {
@@ -2561,71 +2551,74 @@
          }
 
       }
-
+      
    }
-
-
+   
+   
    public void testOneSessionTwoTransactionsRollbackSend() throws Exception
    {
       if (ServerManagement.isRemote()) return;
-
+      
       XAConnection conn = null;
-
+      
       Connection conn2 = null;
-
+      
       try
       {
-
+         
          conn = cf.createXAConnection();
 
          //Create a session
          XASession sess1 = conn.createXASession();
          XAResource res1 = sess1.getXAResource();
-
+         
          MessageProducer prod1 = sess1.createProducer(queue);
-
+                  
          tm.begin();
-
+         
          Transaction tx1 = tm.getTransaction();
          tx1.enlistResource(res1);
-
+         
          //Send a message
          prod1.send(sess1.createTextMessage("kangaroo1"));
-
+         
          //suspend the tx
          Transaction suspended = tm.suspend();
-
+         
          tm.begin();
-
+         
          //Send another message in another tx using the same session
          Transaction tx2 = tm.getTransaction();
          tx2.enlistResource(res1);
-
+         
          //Send a message
          prod1.send(sess1.createTextMessage("kangaroo2"));
-
+         
          //rollback this transaction
-         tm.rollback();
-
+         tx2.rollback();
+         
+         //Give enough time for the messages to get back in the queue (cancel is asynch)
+         
+         Thread.sleep(500);
+         
          //verify no messages are sent
          conn2 = cf.createConnection();
          Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
          conn2.start();
          MessageConsumer cons = sess.createConsumer(queue);
-         TextMessage r1 = (TextMessage)cons.receive(MIN_TIMEOUT);
-
+         TextMessage r1 = (TextMessage)cons.receive(1000);
          assertNull(r1);
-
-
+         
+         
          //now resume the first tx and then commit it
          tm.resume(suspended);
-         tm.commit();
-
+         suspended.commit();
+         
          //verify that the first text message is received
-         TextMessage r3 = (TextMessage)cons.receive(MAX_TIMEOUT);
+         TextMessage r3 = (TextMessage)cons.receive(1000);
          assertNotNull(r3);
          assertEquals("kangaroo1", r3.getText());
-
+         
       }
       finally
       {
@@ -2639,9 +2632,9 @@
          }
 
       }
-
+      
    }
-
+   
    // Package protected ----------------------------------------------------------------------------
    
    // Protected ------------------------------------------------------------------------------------

Deleted: branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/crash/CallbackFailureTest.java
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/crash/CallbackFailureTest.java	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/crash/CallbackFailureTest.java	2007-05-10 15:36:44 UTC (rev 2666)
@@ -1,169 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This 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 (at your option) any later version.
-  *
-  * This software 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 software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.test.messaging.jms.crash;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.management.ObjectName;
-import javax.naming.InitialContext;
-
-import org.jboss.jms.server.ConnectionManager;
-import org.jboss.logging.Logger;
-import org.jboss.test.messaging.MessagingTestCase;
-import org.jboss.test.messaging.jms.CreateHangingConsumerCommand;
-import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.test.messaging.tools.jmx.ServiceContainer;
-import org.jboss.test.messaging.tools.jmx.rmi.LocalTestServer;
-import org.jboss.test.messaging.tools.jmx.rmi.Server;
-import org.jboss.test.messaging.tools.jndi.InVMInitialContextFactory;
-
-/**
- * 
- * A CallbackFailureTest.
- * 
- * @author <a href="tim.fox at jboss.com">Tim Fox</a>
- * @version 1.1
- *
- * CallbackFailureTest.java,v 1.1 2006/02/21 08:22:28 timfox Exp
- */
-public class CallbackFailureTest extends MessagingTestCase
-{
-   // Constants -----------------------------------------------------
-
-   // Static --------------------------------------------------------
-   
-   private static final Logger log = Logger.getLogger(CallbackFailureTest.class);
-   
-   // Attributes ----------------------------------------------------
-   
-   protected Server localServer;
-   
-   protected Server remoteServer;
-
-   // Constructors --------------------------------------------------
-
-   public CallbackFailureTest(String name)
-   {
-      super(name);
-   }
-
-   // Public --------------------------------------------------------
-
-   public void setUp() throws Exception
-   {
-      super.setUp();
-      
-      //Start the local server
-      localServer = new LocalTestServer();
-      
-      //Start all the services locally
-      localServer.start("all");
-            
-      localServer.deployQueue("Queue", null);
-           
-      //Connect to the remote server, but don't start a servicecontainer on it
-      //We are only using the remote server to open a client connection to the local server
-      ServerManagement.create();
-          
-      remoteServer = ServerManagement.getServer();
-   }
-
-   public void tearDown() throws Exception
-   {       
-      localServer.stop();
-   }
-        
-   /*
-    * Test that when a client callback fails, server side resources for connections are cleaned-up
-    */
-   public void testCallbackFailure() throws Exception
-   {
-      if (!ServerManagement.isRemote()) return;
-      
-      //We need to disable exception listener otherwise it will clear up the connection itself
-      
-      ObjectName connectorName = ServiceContainer.REMOTING_OBJECT_NAME;
-      
-      ConnectionManager cm = localServer.getServerPeer().getConnectionManager();
-      
-      localServer.getServerPeer().getServer().invoke(connectorName, "removeConnectionListener",
-                                                     new Object[] {cm},
-                                                     new String[] {"org.jboss.remoting.ConnectionListener"}); 
-       
-      InitialContext ic = new InitialContext(InVMInitialContextFactory.getJNDIEnvironment());
-      
-      ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
-      
-      Queue queue = (Queue)ic.lookup("/queue/Queue");
-      
-      CreateHangingConsumerCommand command = new CreateHangingConsumerCommand(cf, queue);
-      
-      String remotingSessionId = (String)remoteServer.executeCommand(command);
-      
-      remoteServer.exit();
-        
-      //we have removed the exception listener so the server side resouces shouldn't be cleared up
-      
-      Thread.sleep(20000);
-                 
-      assertTrue(cm.containsSession(remotingSessionId));
-      
-      //Now we send a message which should prompt delivery to the dead consumer causing
-      //an exception which should cause connection cleanup
-                  
-      Connection conn = cf.createConnection();
-      
-      Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-        
-      MessageProducer prod = sess.createProducer(queue);
-      
-      prod.send(sess.createMessage());
-      prod.send(sess.createMessage());
-      prod.send(sess.createMessage());
-      prod.send(sess.createMessage());
-      prod.send(sess.createMessage());
-      prod.send(sess.createMessage());
-      prod.send(sess.createMessage());
-      prod.send(sess.createMessage());
-      prod.send(sess.createMessage());
-      prod.send(sess.createMessage());
-      prod.send(sess.createMessage());
-      
-      Thread.sleep(45000);
-      
-      assertFalse(cm.containsSession(remotingSessionId));   
-               
-   }
-   
-   // Package protected ---------------------------------------------
-   
-   // Protected -----------------------------------------------------
-   
-   // Private -------------------------------------------------------
-   
-  
-   // Inner classes -------------------------------------------------
-
-}

Modified: branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/message/JMSExpirationHeaderTest.java
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/message/JMSExpirationHeaderTest.java	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/message/JMSExpirationHeaderTest.java	2007-05-10 15:36:44 UTC (rev 2666)
@@ -88,7 +88,7 @@
    {
       Message m = queueProducerSession.createMessage();
       queueProducer.send(m, DeliveryMode.NON_PERSISTENT, 4, 5000);
-      Message result = queueConsumer.receive(100);
+      Message result = queueConsumer.receive(1000);
       assertEquals(m.getJMSMessageID(), result.getJMSMessageID());
    }
 

Modified: branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/message/JMSReplyToHeaderTest.java
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/message/JMSReplyToHeaderTest.java	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/message/JMSReplyToHeaderTest.java	2007-05-10 15:36:44 UTC (rev 2666)
@@ -76,10 +76,7 @@
       queueConsumer.receive();
       assertNull(m.getJMSReplyTo());
    }
-   
-   
 
-
    // Package protected ---------------------------------------------
    
    // Protected -----------------------------------------------------

Copied: branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/stress/ConcurrentStopStartStressTest.java (from rev 2665, branches/Branch_1_0_1_SP/tests/src/org/jboss/test/messaging/jms/stress/ConcurrentStopStartStressTest.java)
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/stress/ConcurrentStopStartStressTest.java	                        (rev 0)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/stress/ConcurrentStopStartStressTest.java	2007-05-10 15:36:44 UTC (rev 2666)
@@ -0,0 +1,369 @@
+/*
+   * JBoss, Home of Professional Open Source
+   * Copyright 2005, JBoss Inc., and individual contributors as indicated
+   * by the @authors tag. See the copyright.txt in the distribution for a
+   * full listing of individual contributors.
+   *
+   * This 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 (at your option) any later version.
+   *
+   * This software 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 software; if not, write to the Free
+   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+   */
+
+package org.jboss.test.messaging.jms.stress;
+
+import org.jboss.test.messaging.MessagingTestCase;
+import org.jboss.test.messaging.tools.ServerManagement;
+import org.jboss.jms.client.JBossConnectionFactory;
+import javax.naming.InitialContext;
+import javax.jms.Connection;
+import javax.jms.Session;
+import javax.jms.Destination;
+import javax.jms.MessageProducer;
+import javax.jms.MessageConsumer;
+import javax.jms.TextMessage;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Random;
+
+/**
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public class ConcurrentStopStartStressTest extends MessagingTestCase
+{
+
+   // Constants ------------------------------------------------------------------------------------
+
+   // Attributes -----------------------------------------------------------------------------------
+
+   InitialContext ic;
+   JBossConnectionFactory cf;
+   protected Destination queue;
+   boolean running = false;
+   Object semaphore = new Object();
+
+   // Static ---------------------------------------------------------------------------------------
+
+   // Constructors ---------------------------------------------------------------------------------
+
+   public ConcurrentStopStartStressTest(String name)
+   {
+      super(name);
+   }
+
+   // Public ---------------------------------------------------------------------------------------
+
+   public void testConcurrentStopStart() throws Throwable
+   {
+      Connection conn = cf.createConnection();
+
+      ArrayList threads = new ArrayList();
+
+      for (int i = 0; i < 10; i++)
+      {
+         threads.add(new ThreadProducer("Producer " + i, conn));
+         threads.add(new ThreadConsumer("Consumer " + i, conn));
+      }
+      for (int i = 0; i < 10; i++)
+      {
+         threads.add(new ThreadConnectionStarter("Connect Starter(" + i + ")", conn, i == 0));
+      }
+
+      for (Iterator iter = threads.iterator(); iter.hasNext();)
+      {
+         Thread thread = (Thread) iter.next();
+         thread.start();
+      }
+
+      conn.start();
+
+      // Wait enough time to everybody line up
+      Thread.sleep(1000);
+      synchronized (semaphore)
+      {
+         this.running = true;
+         semaphore.notifyAll();
+      }
+
+      Thread.sleep(30000);
+      synchronized (semaphore)
+      {
+         running = false;
+      }
+
+      for (Iterator iter = threads.iterator(); iter.hasNext();)
+      {
+         Thread thread = (Thread) iter.next();
+         thread.join();
+      }
+
+      int produced = 0;
+      int consumed = 0;
+
+      for (Iterator iter = threads.iterator(); iter.hasNext();)
+      {
+         TestThread thread = (TestThread) iter.next();
+         if (thread.e != null)
+         {
+            throw thread.e;
+         }
+
+         if (thread instanceof ThreadProducer)
+         {
+            produced += thread.counter;
+         } else if (thread instanceof ThreadConsumer)
+         {
+            consumed += thread.counter;
+         }
+      }
+
+      assertEquals(produced, consumed);
+
+
+   }
+   // Package protected ----------------------------------------------------------------------------
+
+   // Protected ------------------------------------------------------------------------------------
+
+   public void setUp() throws Exception
+   {
+      super.setUp();
+
+      running = false;
+
+      ServerManagement.start("all");
+
+
+      ic = new InitialContext(ServerManagement.getJNDIEnvironment());
+      cf = (JBossConnectionFactory) ic.lookup("/ConnectionFactory");
+
+      ServerManagement.undeployQueue("TestQueue");
+      ServerManagement.deployQueue("TestQueue");
+
+      queue = (Destination) ic.lookup("queue/TestQueue");
+
+      drainDestination(cf, queue);
+
+      log.debug("setup done");
+   }
+
+   public void tearDown() throws Exception
+   {
+      System.getProperties().remove("jboss.messaging.callback.bind.address");
+      ServerManagement.undeployQueue("TestQueue");
+      super.tearDown();
+
+      log.debug("tear down done");
+   }
+
+   // Private --------------------------------------------------------------------------------------
+
+   // Innert classes used by testInvalidClientIP ---------------------------------------------------
+
+   class TestThread extends Thread
+   {
+      Throwable e;
+      Connection conn;
+      Session session;
+      int counter = 0;
+
+
+      public TestThread(String name, Connection conn) throws Exception
+      {
+         super(name);
+         this.conn = conn;
+      }
+
+      protected void createSession() throws Exception
+      {
+         this.session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      }
+
+      public void waitSemaphore() throws Exception
+      {
+         synchronized (semaphore)
+         {
+            if (!running)
+            {
+               semaphore.wait();
+            }
+         }
+      }
+   }
+
+   class ThreadProducer extends TestThread
+   {
+      MessageProducer producer;
+
+
+      public ThreadProducer(String name, Connection conn) throws Exception
+      {
+         super(name, conn);
+         createSession();
+         this.producer = session.createProducer(queue);
+      }
+
+
+      public void run()
+      {
+         try
+         {
+            waitSemaphore();
+            int i = 0;
+            while (true)
+            {
+               synchronized (semaphore)
+               {
+                  if (!running)
+                  {
+                     break;
+                  }
+               }
+               producer.send(session.createTextMessage("Message " + i));
+               counter++;
+               log.info("Message " + (i++) + " sent");
+               Thread.sleep(500);
+            }
+         }
+         catch (Throwable e)
+         {
+            this.e = e;
+         }
+
+      }
+   }
+
+   class ThreadConsumer extends TestThread
+   {
+      MessageConsumer consumer;
+
+
+      public ThreadConsumer(String name, Connection conn) throws Exception
+      {
+         super(name, conn);
+         createSession();
+         this.consumer = session.createConsumer(queue);
+      }
+
+
+      public void run()
+      {
+         try
+         {
+            waitSemaphore();
+            while (true)
+            {
+               TextMessage message = (TextMessage) consumer.receive(3000);
+               if (message == null && !running)
+               {
+                  break;
+               }
+
+               log.info("message " + message.getText() + " received");
+               counter++;
+            }
+         }
+         catch (Throwable e)
+         {
+            this.e = e;
+         }
+
+      }
+   }
+
+   class ThreadConnectionStarter extends TestThread
+   {
+
+      Random random = new Random();
+      boolean master;
+
+      public ThreadConnectionStarter(String name, Connection conn, boolean master) throws Exception
+      {
+         super(name, conn);
+         this.master = master;
+      }
+
+
+      public void run()
+      {
+         try
+         {
+            waitSemaphore();
+            Thread.sleep(3000); // Three seconds until first attempt;
+            boolean willBreak = false;
+            while (!willBreak)
+            {
+               if (master)
+               {
+                  Thread.sleep(1000);
+               }
+               
+               synchronized (semaphore)
+               {
+                  /// The master thread will synchronize everybody to ensure we are
+                  /// having everybody trying to stop/start simultaneously
+                  if (master)
+                  {
+                     semaphore.notifyAll();
+                  } else
+                  {
+                     // I want to synchronize everybody on stopping closing the session
+                     semaphore.wait();
+                  }
+
+                  if (!running)
+                  {
+                     willBreak = true;
+                  }
+               }
+
+               if (willBreak)
+               {
+                  if (master)
+                  {
+                     // An extra notify to make sure everybody stops
+                     Thread.sleep(3000);
+                     synchronized (semaphore)
+                     {
+                        semaphore.notifyAll();
+                     }
+                     break;
+                  }
+                  else
+                  {
+                     break;
+                  }
+               }
+
+               // Randomly few threads are starting the connection first
+               if (random.nextBoolean())
+               {
+                  conn.start();
+               }
+               conn.stop();
+               conn.start(); // ensure we start right after stopping, so testcase will complete
+            }
+         }
+         catch (Throwable e)
+         {
+            this.e = e;
+         }
+
+      }
+   }
+
+
+}

Copied: branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/stress/ConnectionConsumerStressTest.java (from rev 2665, branches/Branch_1_0_1_SP/tests/src/org/jboss/test/messaging/jms/stress/ConnectionConsumerStressTest.java)
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/stress/ConnectionConsumerStressTest.java	                        (rev 0)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/stress/ConnectionConsumerStressTest.java	2007-05-10 15:36:44 UTC (rev 2666)
@@ -0,0 +1,75 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This 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 (at your option) any later version.
+  *
+  * This software 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 software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.test.messaging.jms.stress;
+
+import javax.jms.Connection;
+import javax.jms.DeliveryMode;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+
+/**
+ * 
+ * A ConnectionConsumerStressTest.
+ * 
+ * @author <a href="tim.fox at jboss.com">Tim Fox</a>
+ * @version 1.1
+ *
+ * StressTest.java,v 1.1 2006/04/24 13:14:31 timfox Exp
+ */
+public class ConnectionConsumerStressTest extends StressTestBase
+{
+   public ConnectionConsumerStressTest(String name)
+   {
+      super(name);
+   }
+   
+   public void setUp() throws Exception
+   {
+      super.setUp();      
+   }
+   
+   public void tearDown() throws Exception
+   {     
+      super.tearDown();            
+   }
+   
+   public void testConnectionConsumer() throws Exception
+   {
+      Connection conn = cf.createConnection();
+      conn.start();
+      
+      Session sessSend = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      
+      Session sessReceive = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      
+      MessageProducer prod = sessSend.createProducer(queue1);
+      prod.setDeliveryMode(DeliveryMode.PERSISTENT);
+      
+      Runner[] runners = new Runner[] { new Sender("prod1", sessSend, prod, 100000),
+                                        new Receiver(conn, sessReceive, 100000, queue1) };
+
+      runRunners(runners);
+
+      conn.close();      
+   }
+
+}

Copied: branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/stress/QueueStressTest.java (from rev 2665, branches/Branch_1_0_1_SP/tests/src/org/jboss/test/messaging/jms/stress/QueueStressTest.java)
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/stress/QueueStressTest.java	                        (rev 0)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/stress/QueueStressTest.java	2007-05-10 15:36:44 UTC (rev 2666)
@@ -0,0 +1,195 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This 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 (at your option) any later version.
+  *
+  * This software 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 software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.test.messaging.jms.stress;
+
+import javax.jms.Connection;
+import javax.jms.DeliveryMode;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.XAConnection;
+import javax.jms.XASession;
+
+/**
+ * 
+ * A QueueStressTest.
+ * 
+ * @author <a href="tim.fox at jboss.com">Tim Fox</a>
+ * @version 1.1
+ *
+ * StressTest.java,v 1.1 2006/04/24 13:14:31 timfox Exp
+ */
+public class QueueStressTest extends StressTestBase
+{
+   public QueueStressTest(String name)
+   {
+      super(name);
+   }
+   
+   public void setUp() throws Exception
+   {
+      super.setUp();      
+   }
+   
+   public void tearDown() throws Exception
+   {     
+      super.tearDown();            
+   }
+   
+   /*
+    * Stress a queue with transational, non transactional and 2pc senders sending both persistent
+    * and non persistent messages
+    * Transactional senders go through a cycle of sending and rolling back
+    * 
+    */
+   public void testQueueMultipleSenders() throws Exception
+   {
+      Connection conn1 = cf.createConnection();
+      
+      Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      Session sess2 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      Session sess3 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      Session sess4 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      Session sess5 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      Session sess6 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      Session sess7 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      Session sess8 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      
+      Session sess9 = conn1.createSession(true, Session.SESSION_TRANSACTED);
+      Session sess10 = conn1.createSession(true, Session.SESSION_TRANSACTED);
+      Session sess11 = conn1.createSession(true, Session.SESSION_TRANSACTED);
+      Session sess12 = conn1.createSession(true, Session.SESSION_TRANSACTED);
+      Session sess13 = conn1.createSession(true, Session.SESSION_TRANSACTED);
+      Session sess14 = conn1.createSession(true, Session.SESSION_TRANSACTED);
+      Session sess15 = conn1.createSession(true, Session.SESSION_TRANSACTED);
+      Session sess16 = conn1.createSession(true, Session.SESSION_TRANSACTED);
+      
+      XASession xaSess1 = ((XAConnection)conn1).createXASession();
+      XASession xaSess2 = ((XAConnection)conn1).createXASession();
+      XASession xaSess3 = ((XAConnection)conn1).createXASession();
+      XASession xaSess4 = ((XAConnection)conn1).createXASession();
+      XASession xaSess5 = ((XAConnection)conn1).createXASession();
+      XASession xaSess6 = ((XAConnection)conn1).createXASession();
+      XASession xaSess7 = ((XAConnection)conn1).createXASession();
+      XASession xaSess8 = ((XAConnection)conn1).createXASession();
+      
+      Session sess17 = xaSess1.getSession();
+      Session sess18 = xaSess2.getSession();
+      Session sess19 = xaSess3.getSession();
+      Session sess20 = xaSess4.getSession();
+      Session sess21 = xaSess5.getSession();
+      Session sess22 = xaSess6.getSession();
+      Session sess23 = xaSess7.getSession();
+      Session sess24 = xaSess8.getSession();
+      
+      MessageProducer prod1 = sess1.createProducer(queue1);
+      prod1.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+      MessageProducer prod2 = sess2.createProducer(queue1);
+      prod2.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+      MessageProducer prod3 = sess3.createProducer(queue1);
+      prod3.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+      MessageProducer prod4 = sess4.createProducer(queue1);
+      prod4.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+      MessageProducer prod5 = sess5.createProducer(queue1);
+      prod5.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+      MessageProducer prod6 = sess6.createProducer(queue1);
+      prod6.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+      MessageProducer prod7 = sess7.createProducer(queue1);
+      prod7.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+      MessageProducer prod8 = sess8.createProducer(queue1);
+      prod8.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+      MessageProducer prod9 = sess9.createProducer(queue1);
+      prod9.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+      MessageProducer prod10 = sess10.createProducer(queue1);
+      prod10.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+      MessageProducer prod11 = sess11.createProducer(queue1);
+      prod11.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+      MessageProducer prod12 = sess12.createProducer(queue1);
+      prod12.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+      MessageProducer prod13 = sess13.createProducer(queue1);
+      prod13.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+      MessageProducer prod14 = sess14.createProducer(queue1);
+      prod14.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+      MessageProducer prod15 = sess15.createProducer(queue1);
+      prod15.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+      MessageProducer prod16 = sess16.createProducer(queue1);
+      prod16.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+      MessageProducer prod17 = sess17.createProducer(queue1);
+      prod17.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+      MessageProducer prod18 = sess18.createProducer(queue1);
+      prod18.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+      MessageProducer prod19 = sess19.createProducer(queue1);
+      prod19.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+      MessageProducer prod20 = sess20.createProducer(queue1);
+      prod20.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+      MessageProducer prod21 = sess21.createProducer(queue1);
+      prod21.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+      MessageProducer prod22 = sess22.createProducer(queue1);
+      prod22.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+      MessageProducer prod23 = sess23.createProducer(queue1);
+      prod23.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+      MessageProducer prod24 = sess24.createProducer(queue1);
+      prod24.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+
+
+      Connection conn2 = cf.createConnection();
+      conn2.start();
+      Session sessReceive = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);      
+      MessageConsumer cons = sessReceive.createConsumer(queue1);
+      
+  
+      Runner[] runners = new Runner[] {
+      new Sender("prod1", sess1, prod1, NUM_NON_PERSISTENT_MESSAGES),
+      new Sender("prod2", sess2, prod2, NUM_PERSISTENT_MESSAGES),
+      new Sender("prod3", sess3, prod3, NUM_NON_PERSISTENT_MESSAGES),
+      new Sender("prod4", sess4, prod4, NUM_PERSISTENT_MESSAGES),
+      new Sender("prod5", sess5, prod5, NUM_NON_PERSISTENT_MESSAGES),
+      new Sender("prod6", sess6, prod6, NUM_PERSISTENT_MESSAGES),
+      new Sender("prod7", sess7, prod7, NUM_NON_PERSISTENT_MESSAGES),
+      new Sender("prod8", sess8, prod8, NUM_PERSISTENT_MESSAGES),
+      new TransactionalSender("prod9", sess9, prod9, NUM_NON_PERSISTENT_MESSAGES, 1, 1),
+      new TransactionalSender("prod10", sess10, prod10, NUM_PERSISTENT_MESSAGES, 1, 1),
+      new TransactionalSender("prod11", sess11, prod11, NUM_NON_PERSISTENT_MESSAGES, 10, 7),
+      new TransactionalSender("prod12", sess12, prod12, NUM_PERSISTENT_MESSAGES, 10, 7),
+      new TransactionalSender("prod13", sess13, prod13, NUM_NON_PERSISTENT_MESSAGES, 50, 21),
+      new TransactionalSender("prod14", sess14, prod14, NUM_PERSISTENT_MESSAGES, 50, 21),
+      new TransactionalSender("prod15", sess15, prod15, NUM_NON_PERSISTENT_MESSAGES, 100, 67),
+      new TransactionalSender("prod16", sess16, prod16, NUM_PERSISTENT_MESSAGES, 100, 67),            
+      new Transactional2PCSender("prod17", xaSess1, prod17, NUM_NON_PERSISTENT_MESSAGES, 1, 1),
+      new Transactional2PCSender("prod18", xaSess2, prod18, NUM_PERSISTENT_MESSAGES, 1, 1),
+      new Transactional2PCSender("prod19", xaSess3, prod19, NUM_NON_PERSISTENT_MESSAGES, 10, 7),
+      new Transactional2PCSender("prod20", xaSess4, prod20, NUM_PERSISTENT_MESSAGES, 10, 7),
+      new Transactional2PCSender("prod21", xaSess5, prod21, NUM_NON_PERSISTENT_MESSAGES, 50, 21),
+      new Transactional2PCSender("prod22", xaSess6, prod22, NUM_PERSISTENT_MESSAGES, 50, 21),
+      new Transactional2PCSender("prod23", xaSess7, prod23, NUM_NON_PERSISTENT_MESSAGES, 100, 67),
+      new Transactional2PCSender("prod24", xaSess8, prod24, NUM_PERSISTENT_MESSAGES, 100, 67), 
+      new Receiver(sessReceive, cons,
+                   12 * NUM_NON_PERSISTENT_MESSAGES + 12 * NUM_PERSISTENT_MESSAGES, false) };
+      
+      runRunners(runners);
+      
+      conn1.close();
+      
+      conn2.close();      
+   }
+   
+}

Deleted: branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/stress/StressTest.java
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/stress/StressTest.java	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/stress/StressTest.java	2007-05-10 15:36:44 UTC (rev 2666)
@@ -1,352 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This 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 (at your option) any later version.
-  *
-  * This software 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 software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.test.messaging.jms.stress;
-
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.XAConnection;
-import javax.jms.XASession;
-
-/**
- * 
- * A StressTest.
- * 
- * @author <a href="tim.fox at jboss.com">Tim Fox</a>
- * @version 1.1
- *
- * StressTest.java,v 1.1 2006/04/24 13:14:31 timfox Exp
- */
-public class StressTest extends StressTestBase
-{
-   public StressTest(String name)
-   {
-      super(name);
-   }
-   
-   public void setUp() throws Exception
-   {
-      super.setUp();      
-   }
-   
-   public void tearDown() throws Exception
-   {     
-      super.tearDown();            
-   }
-   
-   /*
-    * Stress a queue with transational, non transactional and 2pc senders sending both persistent
-    * and non persistent messages
-    * Transactional senders go through a cycle of sending and rolling back
-    * 
-    */
-   public void testQueueMultipleSenders() throws Exception
-   {
-      Connection conn1 = cf.createConnection();
-      
-      Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Session sess2 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Session sess3 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Session sess4 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Session sess5 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Session sess6 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Session sess7 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Session sess8 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      
-      Session sess9 = conn1.createSession(true, Session.SESSION_TRANSACTED);
-      Session sess10 = conn1.createSession(true, Session.SESSION_TRANSACTED);
-      Session sess11 = conn1.createSession(true, Session.SESSION_TRANSACTED);
-      Session sess12 = conn1.createSession(true, Session.SESSION_TRANSACTED);
-      Session sess13 = conn1.createSession(true, Session.SESSION_TRANSACTED);
-      Session sess14 = conn1.createSession(true, Session.SESSION_TRANSACTED);
-      Session sess15 = conn1.createSession(true, Session.SESSION_TRANSACTED);
-      Session sess16 = conn1.createSession(true, Session.SESSION_TRANSACTED);
-      
-      XASession xaSess1 = ((XAConnection)conn1).createXASession();
-      XASession xaSess2 = ((XAConnection)conn1).createXASession();
-      XASession xaSess3 = ((XAConnection)conn1).createXASession();
-      XASession xaSess4 = ((XAConnection)conn1).createXASession();
-      XASession xaSess5 = ((XAConnection)conn1).createXASession();
-      XASession xaSess6 = ((XAConnection)conn1).createXASession();
-      XASession xaSess7 = ((XAConnection)conn1).createXASession();
-      XASession xaSess8 = ((XAConnection)conn1).createXASession();
-      
-      Session sess17 = xaSess1.getSession();
-      Session sess18 = xaSess2.getSession();
-      Session sess19 = xaSess3.getSession();
-      Session sess20 = xaSess4.getSession();
-      Session sess21 = xaSess5.getSession();
-      Session sess22 = xaSess6.getSession();
-      Session sess23 = xaSess7.getSession();
-      Session sess24 = xaSess8.getSession();
-      
-      MessageProducer prod1 = sess1.createProducer(queue1);
-      prod1.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-      MessageProducer prod2 = sess2.createProducer(queue1);
-      prod2.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-      MessageProducer prod3 = sess3.createProducer(queue1);
-      prod3.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-      MessageProducer prod4 = sess4.createProducer(queue1);
-      prod4.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-      MessageProducer prod5 = sess5.createProducer(queue1);
-      prod5.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-      MessageProducer prod6 = sess6.createProducer(queue1);
-      prod6.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-      MessageProducer prod7 = sess7.createProducer(queue1);
-      prod7.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-      MessageProducer prod8 = sess8.createProducer(queue1);
-      prod8.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-      MessageProducer prod9 = sess9.createProducer(queue1);
-      prod9.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-      MessageProducer prod10 = sess10.createProducer(queue1);
-      prod10.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-      MessageProducer prod11 = sess11.createProducer(queue1);
-      prod11.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-      MessageProducer prod12 = sess12.createProducer(queue1);
-      prod12.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-      MessageProducer prod13 = sess13.createProducer(queue1);
-      prod13.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-      MessageProducer prod14 = sess14.createProducer(queue1);
-      prod14.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-      MessageProducer prod15 = sess15.createProducer(queue1);
-      prod15.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-      MessageProducer prod16 = sess16.createProducer(queue1);
-      prod16.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-      MessageProducer prod17 = sess17.createProducer(queue1);
-      prod17.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-      MessageProducer prod18 = sess18.createProducer(queue1);
-      prod18.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-      MessageProducer prod19 = sess19.createProducer(queue1);
-      prod19.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-      MessageProducer prod20 = sess20.createProducer(queue1);
-      prod20.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-      MessageProducer prod21 = sess21.createProducer(queue1);
-      prod21.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-      MessageProducer prod22 = sess22.createProducer(queue1);
-      prod22.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-      MessageProducer prod23 = sess23.createProducer(queue1);
-      prod23.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-      MessageProducer prod24 = sess24.createProducer(queue1);
-      prod24.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-
-
-      Connection conn2 = cf.createConnection();
-      conn2.start();
-      Session sessReceive = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);      
-      MessageConsumer cons = sessReceive.createConsumer(queue1);
-      
-  
-      Runner[] runners = new Runner[] {
-      new Sender("prod1", sess1, prod1, NUM_NON_PERSISTENT_MESSAGES),
-      new Sender("prod2", sess2, prod2, NUM_PERSISTENT_MESSAGES),
-      new Sender("prod3", sess3, prod3, NUM_NON_PERSISTENT_MESSAGES),
-      new Sender("prod4", sess4, prod4, NUM_PERSISTENT_MESSAGES),
-      new Sender("prod5", sess5, prod5, NUM_NON_PERSISTENT_MESSAGES),
-      new Sender("prod6", sess6, prod6, NUM_PERSISTENT_MESSAGES),
-      new Sender("prod7", sess7, prod7, NUM_NON_PERSISTENT_MESSAGES),
-      new Sender("prod8", sess8, prod8, NUM_PERSISTENT_MESSAGES),
-      new TransactionalSender("prod9", sess9, prod9, NUM_NON_PERSISTENT_MESSAGES, 1, 1),
-      new TransactionalSender("prod10", sess10, prod10, NUM_PERSISTENT_MESSAGES, 1, 1),
-      new TransactionalSender("prod11", sess11, prod11, NUM_NON_PERSISTENT_MESSAGES, 10, 7),
-      new TransactionalSender("prod12", sess12, prod12, NUM_PERSISTENT_MESSAGES, 10, 7),
-      new TransactionalSender("prod13", sess13, prod13, NUM_NON_PERSISTENT_MESSAGES, 50, 21),
-      new TransactionalSender("prod14", sess14, prod14, NUM_PERSISTENT_MESSAGES, 50, 21),
-      new TransactionalSender("prod15", sess15, prod15, NUM_NON_PERSISTENT_MESSAGES, 100, 67),
-      new TransactionalSender("prod16", sess16, prod16, NUM_PERSISTENT_MESSAGES, 100, 67),            
-      new Transactional2PCSender("prod17", xaSess1, prod17, NUM_NON_PERSISTENT_MESSAGES, 1, 1),
-      new Transactional2PCSender("prod18", xaSess2, prod18, NUM_PERSISTENT_MESSAGES, 1, 1),
-      new Transactional2PCSender("prod19", xaSess3, prod19, NUM_NON_PERSISTENT_MESSAGES, 10, 7),
-      new Transactional2PCSender("prod20", xaSess4, prod20, NUM_PERSISTENT_MESSAGES, 10, 7),
-      new Transactional2PCSender("prod21", xaSess5, prod21, NUM_NON_PERSISTENT_MESSAGES, 50, 21),
-      new Transactional2PCSender("prod22", xaSess6, prod22, NUM_PERSISTENT_MESSAGES, 50, 21),
-      new Transactional2PCSender("prod23", xaSess7, prod23, NUM_NON_PERSISTENT_MESSAGES, 100, 67),
-      new Transactional2PCSender("prod24", xaSess8, prod24, NUM_PERSISTENT_MESSAGES, 100, 67), 
-      new Receiver(sessReceive, cons,
-                   12 * NUM_NON_PERSISTENT_MESSAGES + 12 * NUM_PERSISTENT_MESSAGES, false) };
-      
-      runRunners(runners);
-      
-      conn1.close();
-      
-      conn2.close();      
-   }
-   
-   /*
-    * Stress a topic with with many non transactional, transactional and 2pc receivers.
-    * Non transactional receivers use ack modes of auto, dups and client ack.
-    * Client ack receivers go through a cycle of receving a batch, acking and recovering
-    * Transactional receivers go through a cycle of receiving commiting and rolling back.
-    * Half the consumers are durable and half non durable.
-    * 
-    */
-   public void testTopicMultipleReceivers() throws Exception
-   {
-      Connection conn1 = cf.createConnection();
-      
-      Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Session sess2 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      MessageProducer prod1 = sess1.createProducer(topic1);
-      prod1.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-      
-      MessageProducer prod2 = sess2.createProducer(topic1);
-      prod2.setDeliveryMode(DeliveryMode.PERSISTENT);
-                  
-      Connection conn2 = cf.createConnection();
-      conn2.setClientID("clientid1");
-      conn2.start();
-      
-      //4 auto ack
-      Session rsess1 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Session rsess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Session rsess3 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Session rsess4 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      
-      //4 dups
-      Session rsess5 = conn2.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
-      Session rsess6 = conn2.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
-      Session rsess7 = conn2.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
-      Session rsess8 = conn2.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
-      
-      //4 client
-      Session rsess9 = conn2.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-      Session rsess10 = conn2.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-      Session rsess11 = conn2.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-      Session rsess12 = conn2.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-      
-      
-      //4 transactional
-      Session rsess13 = conn2.createSession(true, Session.SESSION_TRANSACTED);
-      Session rsess14 = conn2.createSession(true, Session.SESSION_TRANSACTED);
-      Session rsess15 = conn2.createSession(true, Session.SESSION_TRANSACTED);
-      Session rsess16 = conn2.createSession(true, Session.SESSION_TRANSACTED);
-      
-      //4 2pc transactional
-      XASession rxaSess1 = ((XAConnection)conn2).createXASession();
-      XASession rxaSess2 = ((XAConnection)conn2).createXASession();
-      XASession rxaSess3 = ((XAConnection)conn2).createXASession();
-      XASession rxaSess4 = ((XAConnection)conn2).createXASession();
-         
-      Session rsess17 = rxaSess1.getSession();
-      Session rsess18 = rxaSess2.getSession();
-      Session rsess19 = rxaSess3.getSession();
-      Session rsess20 = rxaSess4.getSession();
-
-                      
-      MessageConsumer cons1 = rsess1.createConsumer(topic1);
-      MessageConsumer cons2 = rsess2.createDurableSubscriber(topic1, "sub1");
-      MessageConsumer cons3 = rsess3.createConsumer(topic1);
-      MessageConsumer cons4 = rsess4.createDurableSubscriber(topic1, "sub2");
-      MessageConsumer cons5 = rsess5.createConsumer(topic1);
-      MessageConsumer cons6 = rsess6.createDurableSubscriber(topic1, "sub3");
-      MessageConsumer cons7 = rsess7.createConsumer(topic1);
-      MessageConsumer cons8 = rsess8.createDurableSubscriber(topic1, "sub4");
-      MessageConsumer cons9 = rsess9.createConsumer(topic1);
-      MessageConsumer cons10 = rsess10.createDurableSubscriber(topic1, "sub5");
-      MessageConsumer cons11 = rsess11.createConsumer(topic1);
-      MessageConsumer cons12 = rsess12.createDurableSubscriber(topic1, "sub6");
-      MessageConsumer cons13 = rsess13.createConsumer(topic1);
-      MessageConsumer cons14 = rsess14.createDurableSubscriber(topic1, "sub7");
-      MessageConsumer cons15 = rsess15.createConsumer(topic1);
-      MessageConsumer cons16 = rsess16.createDurableSubscriber(topic1, "sub8");
-      MessageConsumer cons17 = rsess17.createConsumer(topic1);
-      MessageConsumer cons18 = rsess18.createDurableSubscriber(topic1, "sub9");
-      MessageConsumer cons19 = rsess19.createConsumer(topic1);
-      MessageConsumer cons20 = rsess20.createDurableSubscriber(topic1, "sub10");
-
-      
-      //To make sure paging occurs first send some messages before receiving
-  
-      Runner[] runners = new Runner[] {
-            
-      new Sender("prod1", sess1, prod1, NUM_NON_PERSISTENT_PRESEND),
-      new Sender("prod2", sess2, prod2, NUM_PERSISTENT_PRESEND)
-      };
-      
-      runRunners(runners);
-      
-      runners = new Runner[] {
-      //4 auto ack
-      new Receiver(rsess1, cons1, NUM_NON_PERSISTENT_MESSAGES + NUM_PERSISTENT_MESSAGES + NUM_NON_PERSISTENT_PRESEND + NUM_PERSISTENT_PRESEND, false),      
-      new Receiver(rsess2, cons2, NUM_NON_PERSISTENT_MESSAGES + NUM_PERSISTENT_MESSAGES + NUM_NON_PERSISTENT_PRESEND + NUM_PERSISTENT_PRESEND, true),
-      new Receiver(rsess3, cons3, NUM_NON_PERSISTENT_MESSAGES + NUM_PERSISTENT_MESSAGES + NUM_NON_PERSISTENT_PRESEND + NUM_PERSISTENT_PRESEND, false),
-      new Receiver(rsess4, cons4, NUM_NON_PERSISTENT_MESSAGES + NUM_PERSISTENT_MESSAGES + NUM_NON_PERSISTENT_PRESEND + NUM_PERSISTENT_PRESEND, true),
-     
-      //4 dups ok
-      new Receiver(rsess5, cons5, NUM_NON_PERSISTENT_MESSAGES + NUM_PERSISTENT_MESSAGES + NUM_NON_PERSISTENT_PRESEND + NUM_PERSISTENT_PRESEND, false),
-      new Receiver(rsess6, cons6, NUM_NON_PERSISTENT_MESSAGES + NUM_PERSISTENT_MESSAGES + NUM_NON_PERSISTENT_PRESEND + NUM_PERSISTENT_PRESEND, true),
-      new Receiver(rsess7, cons7, NUM_NON_PERSISTENT_MESSAGES + NUM_PERSISTENT_MESSAGES + NUM_NON_PERSISTENT_PRESEND + NUM_PERSISTENT_PRESEND, false),
-      new Receiver(rsess8, cons8, NUM_NON_PERSISTENT_MESSAGES + NUM_PERSISTENT_MESSAGES + NUM_NON_PERSISTENT_PRESEND + NUM_PERSISTENT_PRESEND, true),
-      
-      //4 client ack
-      new RecoveringReceiver(rsess9, cons9, NUM_NON_PERSISTENT_MESSAGES + NUM_PERSISTENT_MESSAGES + NUM_NON_PERSISTENT_PRESEND + NUM_PERSISTENT_PRESEND, 1, 1, false),
-      new RecoveringReceiver(rsess10, cons10, NUM_NON_PERSISTENT_MESSAGES + NUM_PERSISTENT_MESSAGES + NUM_NON_PERSISTENT_PRESEND + NUM_PERSISTENT_PRESEND, 10, 7, true),
-      new RecoveringReceiver(rsess11, cons11, NUM_NON_PERSISTENT_MESSAGES + NUM_PERSISTENT_MESSAGES + NUM_NON_PERSISTENT_PRESEND + NUM_PERSISTENT_PRESEND, 50, 21, false),
-      new RecoveringReceiver(rsess12, cons12, NUM_NON_PERSISTENT_MESSAGES + NUM_PERSISTENT_MESSAGES + NUM_NON_PERSISTENT_PRESEND + NUM_PERSISTENT_PRESEND, 100, 67, true),
-       
-      //4 transactional
-      
-      new TransactionalReceiver(rsess13, cons13, NUM_NON_PERSISTENT_MESSAGES + NUM_PERSISTENT_MESSAGES + NUM_NON_PERSISTENT_PRESEND + NUM_PERSISTENT_PRESEND, 1, 1, false),
-      new TransactionalReceiver(rsess14, cons14, NUM_NON_PERSISTENT_MESSAGES + NUM_PERSISTENT_MESSAGES + NUM_NON_PERSISTENT_PRESEND + NUM_PERSISTENT_PRESEND, 10, 7, true),
-      new TransactionalReceiver(rsess15, cons15, NUM_NON_PERSISTENT_MESSAGES + NUM_PERSISTENT_MESSAGES + NUM_NON_PERSISTENT_PRESEND + NUM_PERSISTENT_PRESEND, 50, 21, false),
-      new TransactionalReceiver(rsess16, cons16, NUM_NON_PERSISTENT_MESSAGES + NUM_PERSISTENT_MESSAGES + NUM_NON_PERSISTENT_PRESEND + NUM_PERSISTENT_PRESEND, 100, 67, true),
-      
-      //4 2pc transactional
-      new Transactional2PCReceiver(rxaSess1, cons17, NUM_NON_PERSISTENT_MESSAGES + NUM_PERSISTENT_MESSAGES + NUM_NON_PERSISTENT_PRESEND + NUM_PERSISTENT_PRESEND, 1, 1, false),
-      new Transactional2PCReceiver(rxaSess2, cons18, NUM_NON_PERSISTENT_MESSAGES + NUM_PERSISTENT_MESSAGES + NUM_NON_PERSISTENT_PRESEND + NUM_PERSISTENT_PRESEND, 10, 7, true),
-      new Transactional2PCReceiver(rxaSess3, cons19, NUM_NON_PERSISTENT_MESSAGES + NUM_PERSISTENT_MESSAGES + NUM_NON_PERSISTENT_PRESEND + NUM_PERSISTENT_PRESEND, 50, 21, false),
-      new Transactional2PCReceiver(rxaSess4, cons20, NUM_NON_PERSISTENT_MESSAGES + NUM_PERSISTENT_MESSAGES + NUM_NON_PERSISTENT_PRESEND + NUM_PERSISTENT_PRESEND, 100, 67, true),
-       
-      new Sender("prod3", sess1, prod1, NUM_NON_PERSISTENT_MESSAGES),
-      new Sender("prod4", sess2, prod2, NUM_PERSISTENT_MESSAGES) 
-      };
-      
-      runRunners(runners);
-      
-      conn1.close();
-      
-      conn2.close();      
-   }    
-   
-   public void testConnectionConsumer() throws Exception
-   {
-      Connection conn = cf.createConnection();
-      conn.start();
-      
-      Session sessSend = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      
-      Session sessReceive = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      
-      MessageProducer prod = sessSend.createProducer(queue1);
-      prod.setDeliveryMode(DeliveryMode.PERSISTENT);
-      
-      Runner[] runners = new Runner[] { new Sender("prod1", sessSend, prod, 100000),
-                                        new Receiver(conn, sessReceive, 100000, queue1) };
-
-      runRunners(runners);
-
-      conn.close();      
-   }
-
-}

Copied: branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/stress/TopicStressTest.java (from rev 2665, branches/Branch_1_0_1_SP/tests/src/org/jboss/test/messaging/jms/stress/TopicStressTest.java)
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/stress/TopicStressTest.java	                        (rev 0)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/stress/TopicStressTest.java	2007-05-10 15:36:44 UTC (rev 2666)
@@ -0,0 +1,194 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This 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 (at your option) any later version.
+  *
+  * This software 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 software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.test.messaging.jms.stress;
+
+import javax.jms.Connection;
+import javax.jms.DeliveryMode;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.XAConnection;
+import javax.jms.XASession;
+
+/**
+ * 
+ * A TopicStressTest.
+ * 
+ * @author <a href="tim.fox at jboss.com">Tim Fox</a>
+ * @version 1.1
+ *
+ * StressTest.java,v 1.1 2006/04/24 13:14:31 timfox Exp
+ */
+public class TopicStressTest extends StressTestBase
+{
+   public TopicStressTest(String name)
+   {
+      super(name);
+   }
+   
+   public void setUp() throws Exception
+   {
+      super.setUp();      
+   }
+   
+   public void tearDown() throws Exception
+   {     
+      super.tearDown();            
+   }
+   
+   /*
+    * Stress a topic with with many non transactional, transactional and 2pc receivers.
+    * Non transactional receivers use ack modes of auto, dups and client ack.
+    * Client ack receivers go through a cycle of receving a batch, acking and recovering
+    * Transactional receivers go through a cycle of receiving commiting and rolling back.
+    * Half the consumers are durable and half non durable.
+    * 
+    */
+   public void testTopicMultipleReceivers() throws Exception
+   {
+      Connection conn1 = cf.createConnection();
+      
+      Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      Session sess2 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+      MessageProducer prod1 = sess1.createProducer(topic1);
+      prod1.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+      
+      MessageProducer prod2 = sess2.createProducer(topic1);
+      prod2.setDeliveryMode(DeliveryMode.PERSISTENT);
+                  
+      Connection conn2 = cf.createConnection();
+      conn2.setClientID("clientid1");
+      conn2.start();
+      
+      //4 auto ack
+      Session rsess1 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      Session rsess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      Session rsess3 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      Session rsess4 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      
+      //4 dups
+      Session rsess5 = conn2.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
+      Session rsess6 = conn2.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
+      Session rsess7 = conn2.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
+      Session rsess8 = conn2.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
+      
+      //4 client
+      Session rsess9 = conn2.createSession(false, Session.CLIENT_ACKNOWLEDGE);
+      Session rsess10 = conn2.createSession(false, Session.CLIENT_ACKNOWLEDGE);
+      Session rsess11 = conn2.createSession(false, Session.CLIENT_ACKNOWLEDGE);
+      Session rsess12 = conn2.createSession(false, Session.CLIENT_ACKNOWLEDGE);
+      
+      
+      //4 transactional
+      Session rsess13 = conn2.createSession(true, Session.SESSION_TRANSACTED);
+      Session rsess14 = conn2.createSession(true, Session.SESSION_TRANSACTED);
+      Session rsess15 = conn2.createSession(true, Session.SESSION_TRANSACTED);
+      Session rsess16 = conn2.createSession(true, Session.SESSION_TRANSACTED);
+      
+      //4 2pc transactional
+      XASession rxaSess1 = ((XAConnection)conn2).createXASession();
+      XASession rxaSess2 = ((XAConnection)conn2).createXASession();
+      XASession rxaSess3 = ((XAConnection)conn2).createXASession();
+      XASession rxaSess4 = ((XAConnection)conn2).createXASession();
+         
+      Session rsess17 = rxaSess1.getSession();
+      Session rsess18 = rxaSess2.getSession();
+      Session rsess19 = rxaSess3.getSession();
+      Session rsess20 = rxaSess4.getSession();
+
+                      
+      MessageConsumer cons1 = rsess1.createConsumer(topic1);
+      MessageConsumer cons2 = rsess2.createDurableSubscriber(topic1, "sub1");
+      MessageConsumer cons3 = rsess3.createConsumer(topic1);
+      MessageConsumer cons4 = rsess4.createDurableSubscriber(topic1, "sub2");
+      MessageConsumer cons5 = rsess5.createConsumer(topic1);
+      MessageConsumer cons6 = rsess6.createDurableSubscriber(topic1, "sub3");
+      MessageConsumer cons7 = rsess7.createConsumer(topic1);
+      MessageConsumer cons8 = rsess8.createDurableSubscriber(topic1, "sub4");
+      MessageConsumer cons9 = rsess9.createConsumer(topic1);
+      MessageConsumer cons10 = rsess10.createDurableSubscriber(topic1, "sub5");
+      MessageConsumer cons11 = rsess11.createConsumer(topic1);
+      MessageConsumer cons12 = rsess12.createDurableSubscriber(topic1, "sub6");
+      MessageConsumer cons13 = rsess13.createConsumer(topic1);
+      MessageConsumer cons14 = rsess14.createDurableSubscriber(topic1, "sub7");
+      MessageConsumer cons15 = rsess15.createConsumer(topic1);
+      MessageConsumer cons16 = rsess16.createDurableSubscriber(topic1, "sub8");
+      MessageConsumer cons17 = rsess17.createConsumer(topic1);
+      MessageConsumer cons18 = rsess18.createDurableSubscriber(topic1, "sub9");
+      MessageConsumer cons19 = rsess19.createConsumer(topic1);
+      MessageConsumer cons20 = rsess20.createDurableSubscriber(topic1, "sub10");
+
+      
+      //To make sure paging occurs first send some messages before receiving
+  
+      Runner[] runners = new Runner[] {
+            
+      new Sender("prod1", sess1, prod1, NUM_NON_PERSISTENT_PRESEND),
+      new Sender("prod2", sess2, prod2, NUM_PERSISTENT_PRESEND)
+      };
+      
+      runRunners(runners);
+      
+      runners = new Runner[] {
+      //4 auto ack
+      new Receiver(rsess1, cons1, NUM_NON_PERSISTENT_MESSAGES + NUM_PERSISTENT_MESSAGES + NUM_NON_PERSISTENT_PRESEND + NUM_PERSISTENT_PRESEND, false),      
+      new Receiver(rsess2, cons2, NUM_NON_PERSISTENT_MESSAGES + NUM_PERSISTENT_MESSAGES + NUM_NON_PERSISTENT_PRESEND + NUM_PERSISTENT_PRESEND, true),
+      new Receiver(rsess3, cons3, NUM_NON_PERSISTENT_MESSAGES + NUM_PERSISTENT_MESSAGES + NUM_NON_PERSISTENT_PRESEND + NUM_PERSISTENT_PRESEND, false),
+      new Receiver(rsess4, cons4, NUM_NON_PERSISTENT_MESSAGES + NUM_PERSISTENT_MESSAGES + NUM_NON_PERSISTENT_PRESEND + NUM_PERSISTENT_PRESEND, true),
+     
+      //4 dups ok
+      new Receiver(rsess5, cons5, NUM_NON_PERSISTENT_MESSAGES + NUM_PERSISTENT_MESSAGES + NUM_NON_PERSISTENT_PRESEND + NUM_PERSISTENT_PRESEND, false),
+      new Receiver(rsess6, cons6, NUM_NON_PERSISTENT_MESSAGES + NUM_PERSISTENT_MESSAGES + NUM_NON_PERSISTENT_PRESEND + NUM_PERSISTENT_PRESEND, true),
+      new Receiver(rsess7, cons7, NUM_NON_PERSISTENT_MESSAGES + NUM_PERSISTENT_MESSAGES + NUM_NON_PERSISTENT_PRESEND + NUM_PERSISTENT_PRESEND, false),
+      new Receiver(rsess8, cons8, NUM_NON_PERSISTENT_MESSAGES + NUM_PERSISTENT_MESSAGES + NUM_NON_PERSISTENT_PRESEND + NUM_PERSISTENT_PRESEND, true),
+      
+      //4 client ack
+      new RecoveringReceiver(rsess9, cons9, NUM_NON_PERSISTENT_MESSAGES + NUM_PERSISTENT_MESSAGES + NUM_NON_PERSISTENT_PRESEND + NUM_PERSISTENT_PRESEND, 1, 1, false),
+      new RecoveringReceiver(rsess10, cons10, NUM_NON_PERSISTENT_MESSAGES + NUM_PERSISTENT_MESSAGES + NUM_NON_PERSISTENT_PRESEND + NUM_PERSISTENT_PRESEND, 10, 7, true),
+      new RecoveringReceiver(rsess11, cons11, NUM_NON_PERSISTENT_MESSAGES + NUM_PERSISTENT_MESSAGES + NUM_NON_PERSISTENT_PRESEND + NUM_PERSISTENT_PRESEND, 50, 21, false),
+      new RecoveringReceiver(rsess12, cons12, NUM_NON_PERSISTENT_MESSAGES + NUM_PERSISTENT_MESSAGES + NUM_NON_PERSISTENT_PRESEND + NUM_PERSISTENT_PRESEND, 100, 67, true),
+       
+      //4 transactional
+      
+      new TransactionalReceiver(rsess13, cons13, NUM_NON_PERSISTENT_MESSAGES + NUM_PERSISTENT_MESSAGES + NUM_NON_PERSISTENT_PRESEND + NUM_PERSISTENT_PRESEND, 1, 1, false),
+      new TransactionalReceiver(rsess14, cons14, NUM_NON_PERSISTENT_MESSAGES + NUM_PERSISTENT_MESSAGES + NUM_NON_PERSISTENT_PRESEND + NUM_PERSISTENT_PRESEND, 10, 7, true),
+      new TransactionalReceiver(rsess15, cons15, NUM_NON_PERSISTENT_MESSAGES + NUM_PERSISTENT_MESSAGES + NUM_NON_PERSISTENT_PRESEND + NUM_PERSISTENT_PRESEND, 50, 21, false),
+      new TransactionalReceiver(rsess16, cons16, NUM_NON_PERSISTENT_MESSAGES + NUM_PERSISTENT_MESSAGES + NUM_NON_PERSISTENT_PRESEND + NUM_PERSISTENT_PRESEND, 100, 67, true),
+      
+      //4 2pc transactional
+      new Transactional2PCReceiver(rxaSess1, cons17, NUM_NON_PERSISTENT_MESSAGES + NUM_PERSISTENT_MESSAGES + NUM_NON_PERSISTENT_PRESEND + NUM_PERSISTENT_PRESEND, 1, 1, false),
+      new Transactional2PCReceiver(rxaSess2, cons18, NUM_NON_PERSISTENT_MESSAGES + NUM_PERSISTENT_MESSAGES + NUM_NON_PERSISTENT_PRESEND + NUM_PERSISTENT_PRESEND, 10, 7, true),
+      new Transactional2PCReceiver(rxaSess3, cons19, NUM_NON_PERSISTENT_MESSAGES + NUM_PERSISTENT_MESSAGES + NUM_NON_PERSISTENT_PRESEND + NUM_PERSISTENT_PRESEND, 50, 21, false),
+      new Transactional2PCReceiver(rxaSess4, cons20, NUM_NON_PERSISTENT_MESSAGES + NUM_PERSISTENT_MESSAGES + NUM_NON_PERSISTENT_PRESEND + NUM_PERSISTENT_PRESEND, 100, 67, true),
+       
+      new Sender("prod3", sess1, prod1, NUM_NON_PERSISTENT_MESSAGES),
+      new Sender("prod4", sess2, prod2, NUM_PERSISTENT_MESSAGES) 
+      };
+      
+      runRunners(runners);
+      
+      conn1.close();
+      
+      conn2.close();      
+   }       
+}

Modified: branches/Branch_1_0/tests/src/org/jboss/test/messaging/tools/jmx/MockJBossSecurityManager.java
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/messaging/tools/jmx/MockJBossSecurityManager.java	2007-05-09 19:12:32 UTC (rev 2665)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/tools/jmx/MockJBossSecurityManager.java	2007-05-10 15:36:44 UTC (rev 2666)
@@ -138,6 +138,17 @@
             addRole(activeSubject, "durpublisher");
          }
       }
+      else if ("dilbert".equals(username))
+      {
+         isValid = "dogbert".equals(password);
+
+         if (isValid && simulateJBossJaasSecurityManager)
+         {
+            addRole(activeSubject, "publisher");
+            addRole(activeSubject, "durpublisher");
+            addRole(activeSubject, "def");
+         }
+      }
       else
       {
          isValid = false;




More information about the jboss-cvs-commits mailing list