[jboss-cvs] JBoss Messaging SVN: r2392 - in projects/jms-integration/src/main/org/jboss/test/jms/integration: mdb and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Feb 21 18:25:21 EST 2007


Author: clebert.suconic at jboss.com
Date: 2007-02-21 18:25:21 -0500 (Wed, 21 Feb 2007)
New Revision: 2392

Added:
   projects/jms-integration/src/main/org/jboss/test/jms/integration/mdb/
   projects/jms-integration/src/main/org/jboss/test/jms/integration/mdb/MDBTestBase.java
   projects/jms-integration/src/main/org/jboss/test/jms/integration/mdb/SimpleMDBDurableTest.java
   projects/jms-integration/src/main/org/jboss/test/jms/integration/mdb/SimpleMDBTest.java
   projects/jms-integration/src/main/org/jboss/test/jms/integration/mdb/SimpleMDBUserTransactionDupsOKTest.java
   projects/jms-integration/src/main/org/jboss/test/jms/integration/mdb/SimpleMDBUserTransactionTest.java
   projects/jms-integration/src/main/org/jboss/test/jms/integration/mdb/SimpleMDBWithSelectorTest.java
Removed:
   projects/jms-integration/src/main/org/jboss/test/jms/integration/mdb/SimpleMDBTest.java
   projects/jms-integration/src/main/org/jboss/test/jms/integration/tests/
Log:
renaming directory

Copied: projects/jms-integration/src/main/org/jboss/test/jms/integration/mdb (from rev 2353, projects/jms-integration/src/main/org/jboss/test/jms/integration/tests)

Copied: projects/jms-integration/src/main/org/jboss/test/jms/integration/mdb/MDBTestBase.java (from rev 2391, projects/jms-integration/src/main/org/jboss/test/jms/integration/tests/MDBTestBase.java)
===================================================================
--- projects/jms-integration/src/main/org/jboss/test/jms/integration/mdb/MDBTestBase.java	                        (rev 0)
+++ projects/jms-integration/src/main/org/jboss/test/jms/integration/mdb/MDBTestBase.java	2007-02-21 23:25:21 UTC (rev 2392)
@@ -0,0 +1,90 @@
+/*
+   * 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.jms.integration.mdb;
+
+import org.jboss.test.jms.integration.MessagingIntegrationTestBase;
+import javax.naming.InitialContext;
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+import java.util.Random;
+
+/**
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ * @version <tt>$Revision$</tt>
+ *          $Id$
+ */
+public class MDBTestBase extends MessagingIntegrationTestBase
+{
+
+   // Constants ------------------------------------------------------------------------------------
+
+   // Constants ------------------------------------------------------------------------------------
+
+   static final String CONNECTION_FACTORY  = "ConnectionFactory";
+   static final String TEST_TOPIC          = "topic/testTopic";
+   static final String TEST_QUEUE          = "queue/testQueue";
+   static final String TEST_QUEUE_RESPONSE = "queue/testQueueResponse";
+
+
+   // Attributes -----------------------------------------------------------------------------------
+
+   InitialContext ctx;
+   ConnectionFactory cf;
+   Destination topicDestination;
+   Destination queueDestination;
+   Destination responseDestination;
+   Random random = new Random();
+
+   // Static ---------------------------------------------------------------------------------------
+
+   // Constructors ---------------------------------------------------------------------------------
+
+   public MDBTestBase(String name)
+   {
+      super(name);
+   }
+
+   // Public ---------------------------------------------------------------------------------------
+
+   // Package protected ----------------------------------------------------------------------------
+
+   // Protected ------------------------------------------------------------------------------------
+
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      ctx = new InitialContext();
+      cf = (ConnectionFactory)ctx.lookup(CONNECTION_FACTORY);
+      topicDestination = (Destination) ctx.lookup(TEST_TOPIC);
+      queueDestination = (Destination) ctx.lookup(TEST_QUEUE);
+      responseDestination = (Destination) ctx.lookup(TEST_QUEUE_RESPONSE);
+      drainDestination(cf, topicDestination);
+      drainDestination(cf, responseDestination);
+
+   }
+
+   // Private --------------------------------------------------------------------------------------
+
+   // Inner classes --------------------------------------------------------------------------------
+
+}

Copied: projects/jms-integration/src/main/org/jboss/test/jms/integration/mdb/SimpleMDBDurableTest.java (from rev 2391, projects/jms-integration/src/main/org/jboss/test/jms/integration/tests/SimpleMDBDurableTest.java)
===================================================================
--- projects/jms-integration/src/main/org/jboss/test/jms/integration/mdb/SimpleMDBDurableTest.java	                        (rev 0)
+++ projects/jms-integration/src/main/org/jboss/test/jms/integration/mdb/SimpleMDBDurableTest.java	2007-02-21 23:25:21 UTC (rev 2392)
@@ -0,0 +1,126 @@
+/*
+   * 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.jms.integration.mdb;
+
+import javax.jms.Connection;
+import javax.jms.Session;
+import javax.jms.MessageProducer;
+import javax.jms.MessageConsumer;
+import javax.jms.TextMessage;
+import junit.framework.Test;
+
+/**
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public class SimpleMDBDurableTest extends MDBTestBase
+{
+
+   // Static ---------------------------------------------------------------------------------------
+
+   // Constructors ---------------------------------------------------------------------------------
+
+   public SimpleMDBDurableTest(String name)
+   {
+      super(name);
+   }
+
+   // Public ---------------------------------------------------------------------------------------
+
+   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(topicDestination);
+         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;
+            }
+            System.out.println("-----" + message.getText());
+            messagesReceived++;
+         }
+
+         assertEquals(200, 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(SimpleMDBDurableTest.class, "integration-mdb20-durable.jar");
+   }
+
+
+
+   // Package protected ----------------------------------------------------------------------------
+
+   // Protected ------------------------------------------------------------------------------------
+
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+   }
+
+   protected void tearDown() throws Exception
+   {
+      super.tearDown();
+   }
+
+   // Private --------------------------------------------------------------------------------------
+
+   // Inner classes --------------------------------------------------------------------------------
+
+}

Deleted: projects/jms-integration/src/main/org/jboss/test/jms/integration/mdb/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/mdb/SimpleMDBTest.java	2007-02-21 23:25:21 UTC (rev 2392)
@@ -1,132 +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.integration.mdb.tests;
-
-
-import javax.naming.InitialContext;
-import javax.jms.ConnectionFactory;
-import javax.jms.Connection;
-import javax.jms.Session;
-import javax.jms.MessageProducer;
-import javax.jms.Destination;
-import javax.jms.TextMessage;
-import javax.jms.MessageConsumer;
-import java.util.Random;
-import junit.framework.Test;
-import org.jboss.test.messaging.integration.MessagingIntegrationTestBase;
-
-/**
- * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class SimpleMDBTest extends org.jboss.test.messaging.integration.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 destination;
-   Destination response;
-   Random random = new Random();
-
-   // Static ---------------------------------------------------------------------------------------
-
-   // Constructors ---------------------------------------------------------------------------------
-
-   public SimpleMDBTest(String name)
-   {
-      super(name);
-   }
-
-   // Public ---------------------------------------------------------------------------------------
-
-   public void testSimpleMDB() throws Exception
-   {
-      Connection conn = cf.createConnection();
-      Session sess = null;
-
-      try
-      {
-         sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         MessageProducer producer = sess.createProducer(destination);
-         MessageConsumer consumer = sess.createConsumer(response);
-         TextMessage message = sess.createTextMessage("Message " + random.nextLong());
-         message.setJMSReplyTo(response);
-         producer.send(message);
-
-         TextMessage messageResponse = (TextMessage)consumer.receive(5000);
-         assertNotNull(messageResponse);
-         assertEquals(message.toString(), messageResponse.getStringProperty("toStringOnMessage"));
-      }
-      finally
-      {
-         if (sess!=null)
-         {
-            sess.close();
-         }
-      }
-
-   }
-
-   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," +
-                                                 "integration-mdb20.jar");
-   }
-
-
-
-   // Package protected ----------------------------------------------------------------------------
-
-   // Protected ------------------------------------------------------------------------------------
-
-   protected void setUp() throws Exception
-   {
-      super.setUp();
-      ctx = new InitialContext();
-      cf = (ConnectionFactory)ctx.lookup(CONNECTION_FACTORY);
-      destination = (Destination) ctx.lookup(TEST_QUEUE);
-      response = (Destination) ctx.lookup(TEST_QUEUE_RESPONSE);
-   }
-
-   protected void tearDown() throws Exception
-   {
-      super.tearDown();
-   }
-
-   // Private --------------------------------------------------------------------------------------
-
-   // Inner classes --------------------------------------------------------------------------------
-
-}

Copied: projects/jms-integration/src/main/org/jboss/test/jms/integration/mdb/SimpleMDBTest.java (from rev 2391, projects/jms-integration/src/main/org/jboss/test/jms/integration/tests/SimpleMDBTest.java)
===================================================================
--- projects/jms-integration/src/main/org/jboss/test/jms/integration/mdb/SimpleMDBTest.java	                        (rev 0)
+++ projects/jms-integration/src/main/org/jboss/test/jms/integration/mdb/SimpleMDBTest.java	2007-02-21 23:25:21 UTC (rev 2392)
@@ -0,0 +1,114 @@
+/*
+   * 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.jms.integration.mdb;
+
+
+import javax.jms.Connection;
+import javax.jms.Session;
+import javax.jms.MessageProducer;
+import javax.jms.TextMessage;
+import javax.jms.MessageConsumer;
+import junit.framework.Test;
+
+/**
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public class SimpleMDBTest extends MDBTestBase
+{
+
+   // Constants ------------------------------------------------------------------------------------
+
+   // Attributes -----------------------------------------------------------------------------------
+
+   // Static ---------------------------------------------------------------------------------------
+
+   // Constructors ---------------------------------------------------------------------------------
+
+   public SimpleMDBTest(String name)
+   {
+      super(name);
+   }
+
+   // Public ---------------------------------------------------------------------------------------
+
+   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(queueDestination);
+         MessageConsumer consumer = sess.createConsumer(responseDestination);
+         TextMessage message = sess.createTextMessage("Message " + random.nextLong());
+         message.setJMSReplyTo(responseDestination);
+         producer.send(message);
+
+         TextMessage messageResponse = (TextMessage)consumer.receive(10000);
+         assertNotNull(messageResponse);
+         System.out.println("Received message " + messageResponse.getText());
+         assertEquals(message.toString(), messageResponse.getStringProperty("toStringOnMessage"));
+      }
+      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(SimpleMDBTest.class, "integration-mdb20.jar");
+   }
+
+
+
+   // Package protected ----------------------------------------------------------------------------
+
+   // Protected ------------------------------------------------------------------------------------
+
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+
+   }
+
+   protected void tearDown() throws Exception
+   {
+      super.tearDown();
+   }
+
+   // Private --------------------------------------------------------------------------------------
+
+   // Inner classes --------------------------------------------------------------------------------
+
+}

Copied: projects/jms-integration/src/main/org/jboss/test/jms/integration/mdb/SimpleMDBUserTransactionDupsOKTest.java (from rev 2391, projects/jms-integration/src/main/org/jboss/test/jms/integration/tests/SimpleMDBUserTransactionDupsOKTest.java)
===================================================================
--- projects/jms-integration/src/main/org/jboss/test/jms/integration/mdb/SimpleMDBUserTransactionDupsOKTest.java	                        (rev 0)
+++ projects/jms-integration/src/main/org/jboss/test/jms/integration/mdb/SimpleMDBUserTransactionDupsOKTest.java	2007-02-21 23:25:21 UTC (rev 2392)
@@ -0,0 +1,112 @@
+/*
+   * 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.jms.integration.mdb;
+
+import javax.jms.Connection;
+import javax.jms.Session;
+import javax.jms.MessageProducer;
+import javax.jms.MessageConsumer;
+import javax.jms.TextMessage;
+import junit.framework.Test;
+
+/**
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ * @version <tt>$Revision$</tt>
+ *          $Id$
+ */
+public class SimpleMDBUserTransactionDupsOKTest extends MDBTestBase
+{
+
+   // Constants ------------------------------------------------------------------------------------
+
+   // Attributes -----------------------------------------------------------------------------------
+
+   // Static ---------------------------------------------------------------------------------------
+
+   // Constructors ---------------------------------------------------------------------------------
+
+   public SimpleMDBUserTransactionDupsOKTest(String name)
+   {
+      super(name);
+   }
+
+   // Public ---------------------------------------------------------------------------------------
+
+   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(queueDestination);
+         MessageConsumer consumer = sess.createConsumer(responseDestination);
+         TextMessage message = sess.createTextMessage("Message " + random.nextLong());
+         message.setBooleanProperty("commit",true);
+         message.setJMSReplyTo(responseDestination);
+         producer.send(message);
+
+         TextMessage messageResponse = (TextMessage)consumer.receive(10000);
+         assertNotNull(messageResponse);
+         System.out.println("Received message " + messageResponse.getText());
+         assertEquals(message.toString(), messageResponse.getStringProperty("toStringOnMessage"));
+
+
+         message = sess.createTextMessage("Message " + random.nextLong());
+         message.setBooleanProperty("commit",false);
+         message.setJMSReplyTo(responseDestination);
+         producer.send(message);
+
+         messageResponse = (TextMessage)consumer.receive(10000);
+         assertNull(messageResponse);
+      }
+      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(SimpleMDBUserTransactionDupsOKTest.class,
+        "integration-mdb20-userTransactionDups.jar");
+   }
+
+   // Package protected ----------------------------------------------------------------------------
+
+   // Protected ------------------------------------------------------------------------------------
+
+   // Private --------------------------------------------------------------------------------------
+
+   // Inner classes --------------------------------------------------------------------------------
+
+}

Copied: projects/jms-integration/src/main/org/jboss/test/jms/integration/mdb/SimpleMDBUserTransactionTest.java (from rev 2391, projects/jms-integration/src/main/org/jboss/test/jms/integration/tests/SimpleMDBUserTransactionTest.java)
===================================================================
--- projects/jms-integration/src/main/org/jboss/test/jms/integration/mdb/SimpleMDBUserTransactionTest.java	                        (rev 0)
+++ projects/jms-integration/src/main/org/jboss/test/jms/integration/mdb/SimpleMDBUserTransactionTest.java	2007-02-21 23:25:21 UTC (rev 2392)
@@ -0,0 +1,112 @@
+/*
+   * 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.jms.integration.mdb;
+
+import junit.framework.Test;
+import javax.jms.Connection;
+import javax.jms.Session;
+import javax.jms.MessageProducer;
+import javax.jms.MessageConsumer;
+import javax.jms.TextMessage;
+
+/**
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ * @version <tt>$Revision$</tt>
+ *          $Id$
+ */
+public class SimpleMDBUserTransactionTest extends MDBTestBase
+{
+
+   // Constants ------------------------------------------------------------------------------------
+
+   // Attributes -----------------------------------------------------------------------------------
+
+   // Static ---------------------------------------------------------------------------------------
+
+   // Constructors ---------------------------------------------------------------------------------
+
+   public SimpleMDBUserTransactionTest(String name)
+   {
+      super(name);
+   }
+
+   // Public ---------------------------------------------------------------------------------------
+
+   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(queueDestination);
+         MessageConsumer consumer = sess.createConsumer(responseDestination);
+         TextMessage message = sess.createTextMessage("Message " + random.nextLong());
+         message.setBooleanProperty("commit",true);
+         message.setJMSReplyTo(responseDestination);
+         producer.send(message);
+
+         TextMessage messageResponse = (TextMessage)consumer.receive(10000);
+         assertNotNull(messageResponse);
+         System.out.println("Received message " + messageResponse.getText());
+         assertEquals(message.toString(), messageResponse.getStringProperty("toStringOnMessage"));
+
+
+         message = sess.createTextMessage("Message " + random.nextLong());
+         message.setBooleanProperty("commit",false);
+         message.setJMSReplyTo(responseDestination);
+         producer.send(message);
+
+         messageResponse = (TextMessage)consumer.receive(10000);
+         assertNull(messageResponse);
+      }
+      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(SimpleMDBUserTransactionTest.class,
+        "integration-mdb20-userTransaction.jar");
+   }
+
+   // Package protected ----------------------------------------------------------------------------
+
+   // Protected ------------------------------------------------------------------------------------
+
+   // Private --------------------------------------------------------------------------------------
+
+   // Inner classes --------------------------------------------------------------------------------
+
+}

Copied: projects/jms-integration/src/main/org/jboss/test/jms/integration/mdb/SimpleMDBWithSelectorTest.java (from rev 2391, projects/jms-integration/src/main/org/jboss/test/jms/integration/tests/SimpleMDBWithSelectorTest.java)
===================================================================
--- projects/jms-integration/src/main/org/jboss/test/jms/integration/mdb/SimpleMDBWithSelectorTest.java	                        (rev 0)
+++ projects/jms-integration/src/main/org/jboss/test/jms/integration/mdb/SimpleMDBWithSelectorTest.java	2007-02-21 23:25:21 UTC (rev 2392)
@@ -0,0 +1,133 @@
+/*
+   * 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.jms.integration.mdb;
+
+import javax.jms.Connection;
+import javax.jms.Session;
+import javax.jms.MessageProducer;
+import javax.jms.MessageConsumer;
+import javax.jms.TextMessage;
+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 MDBTestBase
+{
+
+   // Constants ------------------------------------------------------------------------------------
+
+   // Attributes -----------------------------------------------------------------------------------
+
+   // 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(queueDestination);
+         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();
+   }
+
+   protected void tearDown() throws Exception
+   {
+      super.tearDown();
+   }
+
+   // Private --------------------------------------------------------------------------------------
+
+   // Inner classes --------------------------------------------------------------------------------
+
+}




More information about the jboss-cvs-commits mailing list