[jboss-cvs] JBossAS SVN: r61818 - trunk/testsuite/src/main/org/jboss/test/mdb/test.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Mar 28 19:50:15 EDT 2007


Author: scott.stark at jboss.org
Date: 2007-03-28 19:50:14 -0400 (Wed, 28 Mar 2007)
New Revision: 61818

Modified:
   trunk/testsuite/src/main/org/jboss/test/mdb/test/MDBUnitTestCase.java
Log:
Cleanup some issues, this test does not validate receipt of msgs by the mdbs, so its questionable

Modified: trunk/testsuite/src/main/org/jboss/test/mdb/test/MDBUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/mdb/test/MDBUnitTestCase.java	2007-03-28 23:23:53 UTC (rev 61817)
+++ trunk/testsuite/src/main/org/jboss/test/mdb/test/MDBUnitTestCase.java	2007-03-28 23:50:14 UTC (rev 61818)
@@ -1,80 +1,94 @@
 /*
-  * 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.
-  */
+ * 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.mdb.test;
 
+import javax.jms.ObjectMessage;
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueSender;
+import javax.jms.QueueSession;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.jms.Topic;
+import javax.jms.TopicConnection;
+import javax.jms.TopicConnectionFactory;
+import javax.jms.TopicPublisher;
+import javax.jms.TopicSession;
 import javax.management.ObjectName;
-import javax.jms.*;
-import javax.naming.*;
+import javax.naming.NamingException;
 
 import junit.framework.Test;
-import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
-import org.jboss.test.mdb.bean.CustomMessage;
-
 import org.jboss.test.JBossTestCase;
 import org.jboss.test.JBossTestSetup;
-import org.jboss.test.jbossmq.test.SecurityUnitTestCase;
+import org.jboss.test.mdb.bean.CustomMessage;
 
 /**
  * Some simple tests of MDB. These could be much more elaborated.
- *
+ * These are also largely useless as they don't validate that the mdb
+ * actually gets the messages.
+ * 
  * In the future at least the following tests should be done some how:
  * <ol>
- *   <li>Queue
- *   <li>Topic
- *   <li>Durable topic
- *   <li>Bean TX - with AUTO_ACK and DUPS_OK
- *   <li>CMT Required
- *   <li>CMT NotSupported
- *   <li>Selector
- *   <li>User and password login
- *   <li>Al the stuff with the context
+ * <li>Queue
+ * <li>Topic
+ * <li>Durable topic
+ * <li>Bean TX - with AUTO_ACK and DUPS_OK
+ * <li>CMT Required
+ * <li>CMT NotSupported
+ * <li>Selector
+ * <li>User and password login
+ * <li>Al the stuff with the context
  * </ol>
- *
- * <p>Created: Fri Dec 29 16:53:26 2000
- *
- * @author  <a href="mailto:peter.antman at tim.se">Peter Antman</a>
- * @author  <a href="mailto:jason at planet57.com">Jason Dillon</a>
- * @author  <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
- * @version <pre>$Revision$</pre>
+ * 
+ * <p>
+ * Created: Fri Dec 29 16:53:26 2000
+ * 
+ * @author <a href="mailto:peter.antman at tim.se">Peter Antman</a>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
+ * @version $Revision$
  */
-public class MDBUnitTestCase
-   extends JBossTestCase
+public class MDBUnitTestCase extends JBossTestCase
 {
    // Static --------------------------------------------------------
 
    // Provider specific
    static String TOPIC_FACTORY = "ConnectionFactory";
+
    static String QUEUE_FACTORY = "ConnectionFactory";
 
    QueueConnection queueConnection;
+
    TopicConnection topicConnection;
 
    // JMSProviderAdapter providerAdapter;
 
    String dest;
 
-   public MDBUnitTestCase(String name, String dest) {
+   public MDBUnitTestCase(String name, String dest)
+   {
       super(name);
       this.dest = dest;
       // Get JMS JNDI Adapter
@@ -84,55 +98,64 @@
       // provider specific queue and topic names!!
    }
 
-
-   protected void tearDown() throws Exception {
-      if (topicConnection != null) {
+   protected void tearDown() throws Exception
+   {
+      if (topicConnection != null)
+      {
          topicConnection.close();
       }
-      if (queueConnection != null) {
+      if (queueConnection != null)
+      {
          queueConnection.close();
       }
    }
 
-   protected void printHeader() {
-      getLog().info("\n---- Testing method " + getName() +
-                         " for destination " +dest);
+   protected void printHeader()
+   {
+      getLog().info(
+            "\n---- Testing method " + getName() + " for destination " + dest);
    }
 
-   private QueueSession getQueueSession() throws Exception {
-      if (queueConnection == null) {
-         QueueConnectionFactory queueFactory =
-            (QueueConnectionFactory)getInitialContext().lookup(QUEUE_FACTORY);
+   private QueueSession getQueueSession() throws Exception
+   {
+      if (queueConnection == null)
+      {
+         QueueConnectionFactory queueFactory = (QueueConnectionFactory) getInitialContext()
+               .lookup(QUEUE_FACTORY);
 
          queueConnection = queueFactory.createQueueConnection();
       }
-      return queueConnection.createQueueSession(false,
-                                                Session.AUTO_ACKNOWLEDGE);
+      return queueConnection
+            .createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
    }
 
-   private TopicSession getTopicSession() throws Exception {
-      if (topicConnection == null) {
-         TopicConnectionFactory topicFactory =
-            (TopicConnectionFactory)getInitialContext().lookup(TOPIC_FACTORY);
+   private TopicSession getTopicSession() throws Exception
+   {
+      if (topicConnection == null)
+      {
+         TopicConnectionFactory topicFactory = (TopicConnectionFactory) getInitialContext()
+               .lookup(TOPIC_FACTORY);
          topicConnection = topicFactory.createTopicConnection();
       }
 
       // No transaction & auto ack
-      return topicConnection.createTopicSession(false,
-                                                Session.AUTO_ACKNOWLEDGE);
+      return topicConnection
+            .createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
    }
 
    /**
     * Test sending messages to Topic testTopic
     */
-   public void testQueue() throws Exception {
+   public void testQueue() throws Exception
+   {
       printHeader();
       QueueSession session = getQueueSession();
-      Queue queue = (Queue)getInitialContext().lookup(dest);
+      Queue queue = (Queue) getInitialContext().lookup(dest);
       QueueSender sender = session.createSender(queue);
 
       getLog().debug("TestQueue: " + dest + " Sending 10 messages 1-10");
-      for (int i = 1; i < 11; i++) {
+      for (int i = 1; i < 11; i++)
+      {
          TextMessage message = session.createTextMessage();
          message.setText("Queue Message " + dest + " nr " + i);
          sender.send(queue, message);
@@ -144,16 +167,17 @@
    /**
     * Test sending messages to Queue testQueue
     */
-   public void testTopic() throws Exception {
+   public void testTopic() throws Exception
+   {
       printHeader();
       TopicSession session = getTopicSession();
-      Topic topic = (Topic)getInitialContext().lookup(dest);
+      Topic topic = (Topic) getInitialContext().lookup(dest);
       TopicPublisher pub = session.createPublisher(topic);
 
-      getLog().debug("TestTopic: " + dest +
-                         ": Sending 10st messages 1-10");
+      getLog().debug("TestTopic: " + dest + ": Sending 10st messages 1-10");
 
-      for (int i = 1; i < 11; i++) {
+      for (int i = 1; i < 11; i++)
+      {
          TextMessage message = session.createTextMessage();
          message.setText("Topic Message " + dest + " nr " + i);
          pub.publish(topic, message);
@@ -165,15 +189,18 @@
    /**
     * Test sending messages to queue testObjectMessage
     */
-   public void testObjectMessage() throws Exception {
+   public void testObjectMessage() throws Exception
+   {
       printHeader();
       QueueSession session = getQueueSession();
       // Non portable!!
-      Queue queue = (Queue)getInitialContext().lookup("queue/testObjectMessage");
+      Queue queue = (Queue) getInitialContext().lookup(
+            "queue/testObjectMessage");
       QueueSender sender = session.createSender(queue);
 
       getLog().debug("TestQueue: Sending 10 messages 1-10");
-      for (int i = 1; i < 11; i++) {
+      for (int i = 1; i < 11; i++)
+      {
          ObjectMessage message = session.createObjectMessage();
          message.setObject(new CustomMessage(i));
          sender.send(queue, message);
@@ -183,14 +210,18 @@
       session.close();
    }
 
-
-   public void testWaitForCompleation() throws Exception {
-      try { Thread.currentThread().sleep(1000*20);
-      } catch ( InterruptedException e ) {}
+   public void testWaitForCompleation() throws Exception
+   {
+      try
+      {
+         Thread.currentThread().sleep(1000 * 20);
+      }
+      catch (InterruptedException e)
+      {
+      }
    }
 
-   public void testNoQueueConstructionForAlreadyExists()
-      throws Exception
+   public void testNoQueueConstructionForAlreadyExists() throws Exception
    {
       try
       {
@@ -203,8 +234,7 @@
       fail("It should not create queue/QueueInADifferentContext");
    }
 
-   public void testNoTopicConstructionForAlreadyExists()
-      throws Exception
+   public void testNoTopicConstructionForAlreadyExists() throws Exception
    {
       try
       {
@@ -224,58 +254,67 @@
    {
       TestSuite suite = new TestSuite();
 
-      //suite.addTest(new MDBUnitTestCase("testServerFound",""));
-      suite.addTest(new MDBUnitTestCase("testNoQueueConstructionForAlreadyExists",""));
-      suite.addTest(new MDBUnitTestCase("testNoTopicConstructionForAlreadyExists",""));
-      suite.addTest(new MDBUnitTestCase("testObjectMessage",""));
-      suite.addTest(new MDBUnitTestCase("testQueue","queue/testQueue"));
-      suite.addTest(new MDBUnitTestCase("testTopic","topic/testTopic"));
-      suite.addTest(new MDBUnitTestCase("testTopic","topic/testDurableTopic"));
-      suite.addTest(new MDBUnitTestCase("testQueue","queue/ex"));
-      suite.addTest(new MDBUnitTestCase("testQueue","queue/A"));
-      suite.addTest(new MDBUnitTestCase("testWaitForCompleation",""));
-      suite.addTest(new MDBUnitTestCase("testQueue","queue/B"));
+      // suite.addTest(new MDBUnitTestCase("testServerFound",""));
+      suite.addTest(new MDBUnitTestCase(
+            "testNoQueueConstructionForAlreadyExists", ""));
+      suite.addTest(new MDBUnitTestCase(
+            "testNoTopicConstructionForAlreadyExists", ""));
+      suite.addTest(new MDBUnitTestCase("testObjectMessage", ""));
+      suite.addTest(new MDBUnitTestCase("testQueue", "queue/testQueue"));
+      suite.addTest(new MDBUnitTestCase("testTopic", "topic/testTopic"));
+      suite.addTest(new MDBUnitTestCase("testTopic", "topic/testDurableTopic"));
+      suite.addTest(new MDBUnitTestCase("testQueue", "queue/ex"));
+      suite.addTest(new MDBUnitTestCase("testQueue", "queue/A"));
+      suite.addTest(new MDBUnitTestCase("testWaitForCompleation", ""));
+      suite.addTest(new MDBUnitTestCase("testQueue", "queue/B"));
 
       Test wrapper = new JBossTestSetup(suite)
-         {
+      {
          protected void setUp() throws Exception
          {
             super.setUp();
             ClassLoader loader = Thread.currentThread().getContextClassLoader();
-            deploy (loader.getResource("messaging/test-destinations-full-service.xml").toString());
-            deploy ("mdb.jar");
+            deploy(loader.getResource(
+                  "messaging/test-destinations-full-service.xml").toString());
+            deploy("mdb.jar");
          }
-             protected void tearDown() throws Exception
-             {
-                super.tearDown();
 
-                // Remove the DLQ messages created by the TxTimeout test
-                getServer().invoke
-                (
-                   new ObjectName("jboss.mq.destination:service=Queue,name=DLQ"),
-                   "removeAllMessages",
-                   new Object[0],
-                   new String[0]
-                );
+         protected void tearDown() throws Exception
+         {
+            super.tearDown();
 
-                ClassLoader loader = Thread.currentThread().getContextClassLoader();
-                undeploy ("mdb.jar");
+            // Remove the DLQ messages created by the TxTimeout test
+            try
+            {
+               getServer().invoke(
+                     new ObjectName(
+                           "jboss.messaging.destination:service=Queue,name=DLQ"),
+                     "removeAllMessages", new Object[0], new String[0]);
+            }
+            catch (Exception e)
+            {
+               e.printStackTrace();
+            }
 
-                // Remove the durable subscription
-                TopicConnectionFactory topicFactory = (TopicConnectionFactory) getInitialContext().lookup(TOPIC_FACTORY);
-                TopicConnection topicConnection = topicFactory.createTopicConnection("john", "needle");
-                TopicSession session = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
-                session.unsubscribe("DurableSubscriberExample");
-                topicConnection.close();
+            ClassLoader loader = Thread.currentThread().getContextClassLoader();
+            undeploy("mdb.jar");
 
-                undeploy (loader.getResource("messaging/test-destinations-full-service.xml").toString());
+            // Remove the durable subscription
+            TopicConnectionFactory topicFactory = (TopicConnectionFactory) getInitialContext()
+                  .lookup(TOPIC_FACTORY);
+            TopicConnection topicConnection = topicFactory
+                  .createTopicConnection("john", "needle");
+            TopicSession session = topicConnection.createTopicSession(false,
+                  Session.AUTO_ACKNOWLEDGE);
+            session.unsubscribe("DurableSubscriberExample");
+            topicConnection.close();
 
-             }
-          };
+            undeploy(loader.getResource(
+                  "messaging/test-destinations-full-service.xml").toString());
 
+         }
+      };
+
       return wrapper;
    }
 }
-
-
-




More information about the jboss-cvs-commits mailing list