[jboss-cvs] JBoss Messaging SVN: r2354 - in projects/jms-integration/src: main/org/jboss/test/jms/integration/support/ejb20 and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Feb 19 18:01:12 EST 2007


Author: clebert.suconic at jboss.com
Date: 2007-02-19 18:01:12 -0500 (Mon, 19 Feb 2007)
New Revision: 2354

Modified:
   projects/jms-integration/src/etc/deployments/mdb-ejb20/META-INF/ejb-jar.xml
   projects/jms-integration/src/etc/deployments/mdb-ejb20/META-INF/jboss.xml
   projects/jms-integration/src/main/org/jboss/test/jms/integration/support/ejb20/TestMessageDriven.java
   projects/jms-integration/src/main/org/jboss/test/jms/integration/tests/SimpleMDBTest.java
Log:
few tweaks

Modified: projects/jms-integration/src/etc/deployments/mdb-ejb20/META-INF/ejb-jar.xml
===================================================================
--- projects/jms-integration/src/etc/deployments/mdb-ejb20/META-INF/ejb-jar.xml	2007-02-19 20:37:10 UTC (rev 2353)
+++ projects/jms-integration/src/etc/deployments/mdb-ejb20/META-INF/ejb-jar.xml	2007-02-19 23:01:12 UTC (rev 2354)
@@ -4,10 +4,10 @@
 
 <ejb-jar>
    <description>MBean Integration Tests</description>
-   <display-name>PublisherBean</display-name>
+   <display-name>QueueAdapter</display-name>
    <enterprise-beans>
       <message-driven>
-         <ejb-name>TopicAdapter</ejb-name>
+         <ejb-name>QueueAdapter</ejb-name>
          <ejb-class>
             org.jboss.test.messaging.integration.mdb.support.ejb20.TestMessageDriven
          </ejb-class>
@@ -25,18 +25,12 @@
             <res-type>javax.jms.ConnectionFactory</res-type>
             <res-auth>Container</res-auth>
          </resource-ref>
-         <resource-ref>
-            <description>A Queue</description>
-            <res-ref-name>jms/QueueName</res-ref-name>
-            <res-type>javax.jms.Queue</res-type>
-            <res-auth>Container</res-auth>
-         </resource-ref>
       </message-driven>
    </enterprise-beans>
    <assembly-descriptor>
       <container-transaction>
          <method>
-            <ejb-name>TopicAdapter</ejb-name>
+            <ejb-name>QueueAdapter</ejb-name>
             <method-name>*</method-name>
          </method>
          <trans-attribute>Required</trans-attribute>

Modified: projects/jms-integration/src/etc/deployments/mdb-ejb20/META-INF/jboss.xml
===================================================================
--- projects/jms-integration/src/etc/deployments/mdb-ejb20/META-INF/jboss.xml	2007-02-19 20:37:10 UTC (rev 2353)
+++ projects/jms-integration/src/etc/deployments/mdb-ejb20/META-INF/jboss.xml	2007-02-19 23:01:12 UTC (rev 2354)
@@ -5,17 +5,13 @@
 <jboss>
    <enterprise-beans>
       <message-driven>
-         <ejb-name>TopicAdapter</ejb-name>
+         <ejb-name>QueueAdapter</ejb-name>
          <destination-jndi-name>queue/testQueue</destination-jndi-name>
          <configuration-name>Standard Message Driven Bean</configuration-name>
          <resource-ref>
             <res-ref-name>connectionFactory</res-ref-name>
             <resource-name>connectionFactory</resource-name>
          </resource-ref>
-         <resource-ref>
-            <res-ref-name>jms/QueueName</res-ref-name>
-            <resource-name>queueref</resource-name>
-         </resource-ref>
       </message-driven>
    </enterprise-beans>
 

Modified: projects/jms-integration/src/main/org/jboss/test/jms/integration/support/ejb20/TestMessageDriven.java
===================================================================
--- projects/jms-integration/src/main/org/jboss/test/jms/integration/support/ejb20/TestMessageDriven.java	2007-02-19 20:37:10 UTC (rev 2353)
+++ projects/jms-integration/src/main/org/jboss/test/jms/integration/support/ejb20/TestMessageDriven.java	2007-02-19 23:01:12 UTC (rev 2354)
@@ -34,6 +34,9 @@
 import javax.jms.XAConnection;
 import javax.jms.XAConnectionFactory;
 import javax.jms.XASession;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Session;
 import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
@@ -59,8 +62,8 @@
 
    MessageDrivenContext messageDrivenContext;
    Context ctx;
-   XAConnectionFactory cf;
-   XAConnection conn;
+   ConnectionFactory cf;
+   Connection conn;
 
    // Static ---------------------------------------------------------------------------------------
 
@@ -78,8 +81,9 @@
       try
       {
          ctx = new InitialContext();
-         cf = (XAConnectionFactory) ctx.lookup(CONNECTION_FACTORY);
-         conn = cf.createXAConnection();
+         cf = (ConnectionFactory) ctx.lookup(CONNECTION_FACTORY);
+         conn = cf.createConnection();
+         conn.start();
          //ts = messageContext.getTimerService();
       }
       catch (NamingException e)
@@ -103,10 +107,10 @@
       try
       {
          Destination replyTo = message.getJMSReplyTo();
-         XASession session = null;
+         Session session = null;
          try
          {
-            session = conn.createXASession();
+            session = conn.createSession(true, Session.SESSION_TRANSACTED);
             MessageProducer producer = session.createProducer(replyTo);
             TextMessage reply = session.createTextMessage("reply to message " + message);
             reply.setStringProperty("toStringOnMessage", message.toString());
@@ -120,7 +124,7 @@
            }
          }
 
-      } catch (JMSException e)
+      } catch (Exception e)
       {
          log.error(e);
          messageDrivenContext.setRollbackOnly();

Modified: projects/jms-integration/src/main/org/jboss/test/jms/integration/tests/SimpleMDBTest.java
===================================================================
--- projects/jms-integration/src/main/org/jboss/test/jms/integration/tests/SimpleMDBTest.java	2007-02-19 20:37:10 UTC (rev 2353)
+++ projects/jms-integration/src/main/org/jboss/test/jms/integration/tests/SimpleMDBTest.java	2007-02-19 23:01:12 UTC (rev 2354)
@@ -41,7 +41,7 @@
  *
  * $Id$
  */
-public class SimpleMDBTest extends org.jboss.test.messaging.integration.MessagingIntegrationTestBase
+public class SimpleMDBTest extends MessagingIntegrationTestBase
 {
 
    // Constants ------------------------------------------------------------------------------------
@@ -55,8 +55,8 @@
 
    InitialContext ctx;
    ConnectionFactory cf;
-   Destination destination;
-   Destination response;
+   Destination targetDestination;
+   Destination responseDestination;
    Random random = new Random();
 
    // Static ---------------------------------------------------------------------------------------
@@ -73,26 +73,28 @@
    public void testSimpleMDB() throws Exception
    {
       Connection conn = cf.createConnection();
+      //conn.start();
       Session sess = null;
 
       try
       {
          sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         MessageProducer producer = sess.createProducer(destination);
-         MessageConsumer consumer = sess.createConsumer(response);
+         MessageProducer producer = sess.createProducer(targetDestination);
+         MessageConsumer consumer = sess.createConsumer(responseDestination);
          TextMessage message = sess.createTextMessage("Message " + random.nextLong());
-         message.setJMSReplyTo(response);
+         message.setJMSReplyTo(responseDestination);
          producer.send(message);
 
-         TextMessage messageResponse = (TextMessage)consumer.receive(5000);
+         TextMessage messageResponse = (TextMessage)consumer.receive(10000);
          assertNotNull(messageResponse);
+         System.out.println("Received message " + messageResponse.getText());
          assertEquals(message.toString(), messageResponse.getStringProperty("toStringOnMessage"));
       }
       finally
       {
-         if (sess!=null)
+         if (conn!=null)
          {
-            sess.close();
+            conn.close();
          }
       }
 
@@ -101,7 +103,7 @@
    public static Test suite() throws Exception
    {
       // This is from JBoss testsuite framework.. it will deploy the MDB before running the test
-     return getDeploySetup(SimpleMDBTest.class, //"test-mdb20-destination-service.xml," +
+     return getDeploySetup(SimpleMDBTest.class, //"test-mdb20-targetDestination-service.xml," +
                                                  "integration-mdb20.jar");
    }
 
@@ -116,8 +118,11 @@
       super.setUp();
       ctx = new InitialContext();
       cf = (ConnectionFactory)ctx.lookup(CONNECTION_FACTORY);
-      destination = (Destination) ctx.lookup(TEST_QUEUE);
-      response = (Destination) ctx.lookup(TEST_QUEUE_RESPONSE);
+      targetDestination = (Destination) ctx.lookup(TEST_QUEUE);
+      responseDestination = (Destination) ctx.lookup(TEST_QUEUE_RESPONSE);
+      drainDestination(cf, targetDestination);
+      drainDestination(cf, responseDestination);
+
    }
 
    protected void tearDown() throws Exception




More information about the jboss-cvs-commits mailing list