[jboss-cvs] JBoss Messaging SVN: r2357 - in projects/jms-integration: src/etc/deployments and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Feb 19 19:11:25 EST 2007


Author: clebert.suconic at jboss.com
Date: 2007-02-19 19:11:24 -0500 (Mon, 19 Feb 2007)
New Revision: 2357

Added:
   projects/jms-integration/src/etc/deployments/mdb-ejb20-selector/
   projects/jms-integration/src/etc/deployments/mdb-ejb20-selector/META-INF/
   projects/jms-integration/src/etc/deployments/mdb-ejb20-selector/META-INF/ejb-jar.xml
   projects/jms-integration/src/etc/deployments/mdb-ejb20-selector/META-INF/jboss.xml
   projects/jms-integration/src/main/org/jboss/test/jms/integration/tests/SimpleMDBWithSelectorTest.java
Modified:
   projects/jms-integration/build.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:
adding MDB test using selectors

Modified: projects/jms-integration/build.xml
===================================================================
--- projects/jms-integration/build.xml	2007-02-19 23:08:24 UTC (rev 2356)
+++ projects/jms-integration/build.xml	2007-02-20 00:11:24 UTC (rev 2357)
@@ -148,8 +148,6 @@
       </condition>
    </target>
 
-   <property name="integration.test.mdb20" value="integration-mdb20.jar"/>
-
    <property name="jboss-home"
              value="/extra/clebert/jboss/jboss-4.0.5.GA"/>
 
@@ -183,11 +181,13 @@
              failonerror="${javac.fail.onerror}">
          <src path="${source-14.tests.java}"/>
          <classpath refid="integration.classpath"/>
-         <include name="**/*.java"/>
       </javac>
 
    </target>
 
+   <property name="integration.test.mdb20" value="integration-mdb20.jar"/>
+   <property name="integration.test.mdb20.selector" value="integration-mdb20-selector.jar"/>
+
    <target name="integration-ejb20-jar" depends="compile">
       <mkdir dir="${build.tests.lib}"/>
       <jar jarfile="${build.tests.lib}/${integration.test.mdb20}">
@@ -198,9 +198,19 @@
       </jar>
    </target>
 
-   <target name="tests-jar" depends="compile, integration-ejb20-jar"/>
+   <target name="integration-ejb20-selector-jar" depends="compile">
+      <mkdir dir="${build.tests.lib}"/>
+      <jar jarfile="${build.tests.lib}/${integration.test.mdb20.selector}">
+         <metainf dir="${tests.root}/src/etc/deployments/mdb-ejb20-selector/META-INF"/>
+         <fileset dir="${build.tests.classes}">
+            <include name="org/jboss/test/messaging/integration/mdb/support/ejb20/**"/>
+         </fileset>
+      </jar>
+   </target>
 
+   <target name="tests-jar" depends="compile, integration-ejb20-jar, integration-ejb20-selector-jar"/>
 
+
    <target name="integration-tests"
            depends="tests-jar, integration-ejb20-jar"
            description="Runs the clustering tests">

Added: projects/jms-integration/src/etc/deployments/mdb-ejb20-selector/META-INF/ejb-jar.xml
===================================================================
--- projects/jms-integration/src/etc/deployments/mdb-ejb20-selector/META-INF/ejb-jar.xml	                        (rev 0)
+++ projects/jms-integration/src/etc/deployments/mdb-ejb20-selector/META-INF/ejb-jar.xml	2007-02-20 00:11:24 UTC (rev 2357)
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/j2ee/dtds/ejb-jar_2_0.dtd">
+
+<ejb-jar>
+   <description>MBean Integration Tests</description>
+   <display-name>QueueAdapter</display-name>
+   <enterprise-beans>
+      <message-driven>
+         <ejb-name>QueueAdapter</ejb-name>
+         <ejb-class>
+            org.jboss.test.messaging.integration.mdb.support.ejb20.TestMessageDriven
+         </ejb-class>
+         <transaction-type>Container</transaction-type>
+         <message-selector>pair='odd'</message-selector>
+         <message-driven-destination>
+            <destination-type>javax.jms.Queue</destination-type>
+            <subscription-durability>
+               NonDurable
+            </subscription-durability>
+         </message-driven-destination>
+         <resource-ref>
+            <description>A ConnectionFactory</description>
+            <res-ref-name>connectionFactory</res-ref-name>
+            <res-type>javax.jms.ConnectionFactory</res-type>
+            <res-auth>Container</res-auth>
+         </resource-ref>
+      </message-driven>
+   </enterprise-beans>
+   <assembly-descriptor>
+      <container-transaction>
+         <method>
+            <ejb-name>QueueAdapter</ejb-name>
+            <method-name>*</method-name>
+         </method>
+         <trans-attribute>Required</trans-attribute>
+      </container-transaction>
+   </assembly-descriptor>
+</ejb-jar>


Property changes on: projects/jms-integration/src/etc/deployments/mdb-ejb20-selector/META-INF/ejb-jar.xml
___________________________________________________________________
Name: svn:keywords
   + Id LastChangedDate Author Revision

Added: projects/jms-integration/src/etc/deployments/mdb-ejb20-selector/META-INF/jboss.xml
===================================================================
--- projects/jms-integration/src/etc/deployments/mdb-ejb20-selector/META-INF/jboss.xml	                        (rev 0)
+++ projects/jms-integration/src/etc/deployments/mdb-ejb20-selector/META-INF/jboss.xml	2007-02-20 00:11:24 UTC (rev 2357)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 4.0//EN" "http://www.jboss.org/j2ee/dtd/jboss_4_0.dtd">
+
+<jboss>
+   <enterprise-beans>
+      <message-driven>
+         <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>
+      </message-driven>
+   </enterprise-beans>
+
+   <resource-managers>
+      <resource-manager>
+         <res-name>connectionFactory</res-name>
+         <res-jndi-name>java:/JmsXA</res-jndi-name>
+      </resource-manager>
+   </resource-managers>
+</jboss>
+


Property changes on: projects/jms-integration/src/etc/deployments/mdb-ejb20-selector/META-INF/jboss.xml
___________________________________________________________________
Name: svn:keywords
   + Id LastChangedDate Author Revision

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 23:08:24 UTC (rev 2356)
+++ projects/jms-integration/src/main/org/jboss/test/jms/integration/support/ejb20/TestMessageDriven.java	2007-02-20 00:11:24 UTC (rev 2357)
@@ -111,8 +111,27 @@
          {
             session = conn.createSession(true, Session.SESSION_TRANSACTED);
             MessageProducer producer = session.createProducer(replyTo);
-            TextMessage reply = session.createTextMessage("reply to message " + message);
+
+            TextMessage reply = null;
+
+            if (message instanceof TextMessage)
+            {
+               TextMessage txtMessage = (TextMessage)message;
+               reply = session.createTextMessage("reply to message " + txtMessage.getText());
+            }
+            else
+            {
+               reply = session.createTextMessage("reply to message " + message);
+            }
+
             reply.setStringProperty("toStringOnMessage", message.toString());
+
+            String prop = message.getStringProperty("pair");
+            if (prop!=null)
+            {
+               reply.setStringProperty("pair", prop);
+            }
+
             producer.send(reply);
          }
          finally

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 23:08:24 UTC (rev 2356)
+++ projects/jms-integration/src/main/org/jboss/test/jms/integration/tests/SimpleMDBTest.java	2007-02-20 00:11:24 UTC (rev 2357)
@@ -20,7 +20,7 @@
    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
    */
 
-package org.jboss.test.messaging.integration.mdb.tests;
+package org.jboss.test.messaging.integration.tests;
 
 
 import javax.naming.InitialContext;
@@ -103,8 +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-targetDestination-service.xml," +
-                                                 "integration-mdb20.jar");
+     return getDeploySetup(SimpleMDBTest.class, "integration-mdb20.jar");
    }
 
 

Added: projects/jms-integration/src/main/org/jboss/test/jms/integration/tests/SimpleMDBWithSelectorTest.java
===================================================================
--- projects/jms-integration/src/main/org/jboss/test/jms/integration/tests/SimpleMDBWithSelectorTest.java	                        (rev 0)
+++ projects/jms-integration/src/main/org/jboss/test/jms/integration/tests/SimpleMDBWithSelectorTest.java	2007-02-20 00:11:24 UTC (rev 2357)
@@ -0,0 +1,156 @@
+/*
+   * 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.integration.tests;
+
+import org.jboss.test.messaging.integration.MessagingIntegrationTestBase;
+import javax.naming.InitialContext;
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+import javax.jms.Connection;
+import javax.jms.Session;
+import javax.jms.MessageProducer;
+import javax.jms.MessageConsumer;
+import javax.jms.TextMessage;
+import java.util.Random;
+import junit.framework.Test;
+
+/**
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public class SimpleMDBWithSelectorTest extends MessagingIntegrationTestBase
+{
+
+   // Constants ------------------------------------------------------------------------------------
+
+   static final String CONNECTION_FACTORY  = "ConnectionFactory";
+   static final String TEST_QUEUE          = "queue/testQueue";
+   static final String TEST_QUEUE_RESPONSE = "queue/testQueueResponse";
+
+
+   // Attributes -----------------------------------------------------------------------------------
+
+   InitialContext ctx;
+   ConnectionFactory cf;
+   Destination targetDestination;
+   Destination responseDestination;
+   Random random = new Random();
+
+   // Static ---------------------------------------------------------------------------------------
+
+   // Constructors ---------------------------------------------------------------------------------
+
+   public SimpleMDBWithSelectorTest(String name)
+   {
+      super(name);
+   }
+
+   // Public ---------------------------------------------------------------------------------------
+
+   public void testSimpleSelectorMDB() throws Exception
+   {
+      Connection conn = cf.createConnection();
+      conn.start();
+      Session sess = null;
+
+      try
+      {
+         sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+         MessageProducer producer = sess.createProducer(targetDestination);
+         MessageConsumer consumer = sess.createConsumer(responseDestination);
+
+         for (int i=0;i<100;i++)
+         {
+            TextMessage message = sess.createTextMessage("Message " + i);
+            message.setStringProperty("pair", i%2==0?"even":"odd");
+            message.setJMSReplyTo(responseDestination);
+            producer.send(message);
+         }
+
+         Thread.sleep(2000);
+
+         int messagesReceived = 0;
+
+         while (true)
+         {
+            TextMessage message = (TextMessage) consumer.receive(5000);
+            if (message == null)
+            {
+               break;
+            }
+
+            assertEquals("odd", message.getStringProperty("pair"));
+            System.out.println("-----" + message.getText());
+            //assertEquals("reply to message Message " + (messagesReceived*2 + 1), message.getText());
+            messagesReceived++;
+         }
+
+         assertEquals(50, messagesReceived);
+
+      }
+      finally
+      {
+         if (conn!=null)
+         {
+            conn.close();
+         }
+      }
+
+   }
+
+   public static Test suite() throws Exception
+   {
+      // This is from JBoss testsuite framework.. it will deploy the MDB before running the test
+     return getDeploySetup(SimpleMDBWithSelectorTest.class, "integration-mdb20-selector.jar");
+   }
+
+
+
+   // Package protected ----------------------------------------------------------------------------
+
+   // Protected ------------------------------------------------------------------------------------
+
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      ctx = new InitialContext();
+      cf = (ConnectionFactory)ctx.lookup(CONNECTION_FACTORY);
+      targetDestination = (Destination) ctx.lookup(TEST_QUEUE);
+      responseDestination = (Destination) ctx.lookup(TEST_QUEUE_RESPONSE);
+      drainDestination(cf, targetDestination);
+      drainDestination(cf, responseDestination);
+
+   }
+
+   protected void tearDown() throws Exception
+   {
+      super.tearDown();
+   }
+
+   // Private --------------------------------------------------------------------------------------
+
+   // Inner classes --------------------------------------------------------------------------------
+
+}


Property changes on: projects/jms-integration/src/main/org/jboss/test/jms/integration/tests/SimpleMDBWithSelectorTest.java
___________________________________________________________________
Name: svn:keywords
   + Id LastChangedDate Author Revision




More information about the jboss-cvs-commits mailing list