[jboss-cvs] JBossAS SVN: r58423 - in trunk/testsuite: . src/main/org/jboss/test/jbossmessaging src/main/org/jboss/test/jbossmessaging/ra

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Nov 15 17:27:24 EST 2006


Author: rachmatowicz at jboss.com
Date: 2006-11-15 17:27:23 -0500 (Wed, 15 Nov 2006)
New Revision: 58423

Added:
   trunk/testsuite/src/main/org/jboss/test/jbossmessaging/ra/
   trunk/testsuite/src/main/org/jboss/test/jbossmessaging/ra/RaJMSSessionUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/jbossmessaging/ra/RaQueueUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/jbossmessaging/ra/RaSyncRecUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/jbossmessaging/ra/RaTest.java
   trunk/testsuite/src/main/org/jboss/test/jbossmessaging/ra/RaTopicUnitTestCase.java
Modified:
   trunk/testsuite/build.xml
Log:
More refactored JMS tests

Modified: trunk/testsuite/build.xml
===================================================================
--- trunk/testsuite/build.xml	2006-11-15 22:11:09 UTC (rev 58422)
+++ trunk/testsuite/build.xml	2006-11-15 22:27:23 UTC (rev 58423)
@@ -666,6 +666,7 @@
    <patternset id="jbossmessaging.includes">
      <include name="org/jboss/test/jbossmessaging/test/*UnitTestCase.class"/> 
      <include name="org/jboss/test/jbossmessaging/perf/*StressTestCase.class"/>
+     <include name="org/jboss/test/jbossmessaging/ra/*UnitTestCase.class"/>
    </patternset>
    <!-- Tests needing xml binding setup -->
    <patternset id="jbossxb.includes">

Added: trunk/testsuite/src/main/org/jboss/test/jbossmessaging/ra/RaJMSSessionUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/jbossmessaging/ra/RaJMSSessionUnitTestCase.java	2006-11-15 22:11:09 UTC (rev 58422)
+++ trunk/testsuite/src/main/org/jboss/test/jbossmessaging/ra/RaJMSSessionUnitTestCase.java	2006-11-15 22:27:23 UTC (rev 58423)
@@ -0,0 +1,88 @@
+/*
+  * 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.jbossmessaging.ra;
+
+import javax.jms.*;
+import javax.naming.InitialContext;
+
+import org.jboss.test.jbossmessaging.JMSTestCase;
+import org.jboss.test.JBossTestSetup;
+import org.jboss.test.client.test.AppClientUnitTestCase;
+
+import org.jboss.test.jmsra.bean.*;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Test for jmsra.
+ *
+ * @author <a href="richard.achmatowicz at jboss.com">Richard Achmatowicz</a>
+ * @author <a href="mailto:Adrian at jboss.org">Adrian Brock</a>
+ * @version $Revision: 37406 $
+ */
+
+public class RaJMSSessionUnitTestCase extends JMSTestCase
+{
+   public RaJMSSessionUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testSendToQueueAndTopic()
+      throws Exception
+   {
+      JMSSessionHome home = (JMSSessionHome) getInitialContext().lookup("JMSSession");
+      JMSSession session = home.create();
+      session.sendToQueueAndTopic();
+   }
+
+   public static Test suite() throws Exception
+   {
+      TestSuite suite = new TestSuite();
+
+      suite.addTest(new JBossTestSetup(new TestSuite(RaJMSSessionUnitTestCase.class))
+      {
+         protected void setUp() throws Exception
+         {
+            ClassLoader loader = Thread.currentThread().getContextClassLoader();
+	    String resourceName = getJMSResourceRelativePathname("test-destinations-service.xml") ;
+            deploy (loader.getResource(resourceName).toString());
+            deploy ("jmsra.jar");
+         }
+         protected void tearDown() throws Exception
+         {
+            ClassLoader loader = Thread.currentThread().getContextClassLoader();
+            String resourceName = getJMSResourceRelativePathname("test-destinations-service.xml") ;
+            undeploy ("jmsra.jar");
+            undeploy (loader.getResource(resourceName).toString());
+         }
+      });
+
+      return suite;
+   }
+}
+
+
+
+
+

Added: trunk/testsuite/src/main/org/jboss/test/jbossmessaging/ra/RaQueueUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/jbossmessaging/ra/RaQueueUnitTestCase.java	2006-11-15 22:11:09 UTC (rev 58422)
+++ trunk/testsuite/src/main/org/jboss/test/jbossmessaging/ra/RaQueueUnitTestCase.java	2006-11-15 22:27:23 UTC (rev 58423)
@@ -0,0 +1,120 @@
+/*
+  * 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.jbossmessaging.ra;
+
+import javax.jms.MessageConsumer;
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueSession;
+import javax.jms.Session;
+
+import javax.management.ObjectName;
+
+import javax.naming.Context;
+
+import junit.framework.Test;
+
+import org.jboss.test.JBossTestSetup;
+
+/**
+ * Test cases for JMS Resource Adapter use a <em>Queue</em> . <p>
+ *
+ * Created: Mon Apr 23 21:35:25 2001
+ *
+ * @author    <a href="mailto:peter.antman at tim.se">Peter Antman</a>
+ * @author    <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ * @version   $Revision: 37406 $
+ */
+public class RaQueueUnitTestCase
+       extends RaTest
+{
+   private final static String QUEUE_FACTORY = "ConnectionFactory";
+   private final static String QUEUE = "queue/testQueue";
+   private final static String JNDI = "TxPublisher";
+
+   /**
+    * Constructor for the RaQueueUnitTestCase object
+    *
+    * @param name           Description of Parameter
+    * @exception Exception  Description of Exception
+    */
+   public RaQueueUnitTestCase(String name) throws Exception
+   {
+      super(name, JNDI);
+   }
+
+   /**
+    * #Description of the Method
+    *
+    * @param context        Description of Parameter
+    * @exception Exception  Description of Exception
+    */
+   protected void init(final Context context) throws Exception
+   {
+      QueueConnectionFactory factory =
+            (QueueConnectionFactory)context.lookup(QUEUE_FACTORY);
+
+      connection = factory.createQueueConnection();
+
+      session = ((QueueConnection)connection).createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
+
+      Queue queue = (Queue)context.lookup(QUEUE);
+
+      consumer = ((QueueSession)session).createReceiver(queue);
+   }
+
+   public static Test suite() throws Exception
+   {
+      return new JBossTestSetup(getDeploySetup(RaQueueUnitTestCase.class, "jmsra.jar"))
+         {
+            protected void setUp() throws Exception
+            {
+               super.setUp();
+               ClassLoader loader = Thread.currentThread().getContextClassLoader();
+	       String resourceName = getJMSResourceRelativePathname("test-destinations-service.xml") ;
+               deploy (loader.getResource(resourceName).toString());
+            }
+
+             protected void tearDown() throws Exception
+             {
+                super.tearDown();
+
+                // Remove the messages
+		// richard.achmatowicz: removed this seeminly unnecessary task
+                //getServer().invoke
+                //(
+                //   new ObjectName("jboss.mq.destination:service=Queue,name=testQueue"),
+                //   "removeAllMessages",
+                //   new Object[0],
+                //   new String[0]
+                //);
+                ClassLoader loader = Thread.currentThread().getContextClassLoader();
+	        String resourceName = getJMSResourceRelativePathname("test-destinations-service.xml") ;
+                undeploy (loader.getResource(resourceName).toString());
+             }
+          };
+   }
+
+
+}

Added: trunk/testsuite/src/main/org/jboss/test/jbossmessaging/ra/RaSyncRecUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/jbossmessaging/ra/RaSyncRecUnitTestCase.java	2006-11-15 22:11:09 UTC (rev 58422)
+++ trunk/testsuite/src/main/org/jboss/test/jbossmessaging/ra/RaSyncRecUnitTestCase.java	2006-11-15 22:27:23 UTC (rev 58423)
@@ -0,0 +1,220 @@
+/*
+  * 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.jbossmessaging.ra;
+
+import javax.jms.Connection;
+import javax.jms.Message;
+
+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.Queue;
+import javax.naming.Context;
+
+import javax.management.ObjectName;
+
+import javax.naming.InitialContext;
+import junit.framework.Assert;
+
+import junit.framework.Test;
+
+import org.jboss.test.jbossmessaging.JMSTestCase;
+import org.jboss.test.JBossTestSetup;
+
+import org.jboss.test.jmsra.bean.*;
+
+/**
+ * 
+ * <p>Test sync receive.
+ *
+ * <p>Created: Sat Sep 22 13:31:54 2001.
+ *
+ * @author <a href="mailto:richard.achmatowicz at jboss.com">Richard Achmatowicz</a>
+ * @author <a href="mailto:peter.antman at tim.se">Peter Antman</a>
+ * @version $Revision: 37406 $
+ */
+
+public class RaSyncRecUnitTestCase extends JMSTestCase {
+
+   private final static String BEAN_JNDI = "QueueRec";
+   private final static String QUEUE_FACTORY = "ConnectionFactory";
+   private final static String QUEUE = "queue/A";
+   private final static int MESSAGE_NR = 10;
+   
+   /**
+    * JMS connection
+    */
+   protected QueueConnection connection;
+   /**
+    * JMS session
+    */
+   protected QueueSession session;
+   /**
+    * JMS sender
+    */
+   protected QueueSender sender;
+
+   /**
+    * Receiving bean
+    */ 
+   protected QueueRec rec;
+
+   /**
+    *   
+    * Constructor for the RaSyncRecUnitTestCase object
+    *
+    * @param name           Description of Parameter
+    * @exception Exception  Description of Exception
+    */
+   public RaSyncRecUnitTestCase(String name) {
+      super(name);
+   }
+   
+   /**
+    * The JUnit setup method
+    *
+    * @exception Exception  Description of Exception
+    */
+   protected void setUp() throws Exception
+   {
+       // call setUp() in super class
+       super.setUp() ;
+
+      // Create a receiver
+      Context context = getInitialContext();
+      try
+      {
+         QueueRecHome home = (QueueRecHome)context.lookup(BEAN_JNDI);
+         rec = home.create();
+
+         init(context);
+      }
+      finally
+      {
+         context.close();
+      }
+
+      // start up the session
+      connection.start();
+
+   }
+
+   /**
+    * #Description of the Method
+    *
+    * @param context        Description of Parameter
+    * @exception Exception  Description of Exception
+    */
+   protected void init(final Context context) throws Exception
+   {
+      QueueConnectionFactory factory =
+	 (QueueConnectionFactory)context.lookup(QUEUE_FACTORY);
+      
+      connection = factory.createQueueConnection();
+      
+      session = ((QueueConnection)connection).createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
+      
+      Queue queue = (Queue)context.lookup(QUEUE);
+      
+      sender = ((QueueSession)session).createSender(queue);
+   }
+
+   /**
+    * The teardown method for JUnit
+    *
+    * @exception Exception  Description of Exception
+    */
+   protected void tearDown() throws Exception
+   {
+      if (sender != null)
+      {
+         sender.close();
+      }
+      if (session != null) { 
+	 session.close();
+      }
+      if (connection != null)
+      {
+         connection.close();
+      }
+
+      // call tearDown() in superclass
+      super.tearDown() ;
+   }
+
+   /**
+    * Test sync receive of message with jms ra.
+    */
+   public void testSyncRec() throws Exception {
+      // Send a message to queue
+      TextMessage message = session.createTextMessage();
+      message.setText(String.valueOf(MESSAGE_NR));
+      message.setIntProperty(Publisher.JMS_MESSAGE_NR, MESSAGE_NR);
+      sender.send(message);
+      getLog().debug("sent message with nr = " + MESSAGE_NR);
+
+      // Let bean fetch it sync
+      int res = rec.getMessage();
+      Assert.assertEquals(MESSAGE_NR, res);
+      getLog().debug("testSyncRec() OK");
+   }
+
+   public static Test suite() throws Exception
+   {
+      return new JBossTestSetup(getDeploySetup(RaSyncRecUnitTestCase.class, "jmsra.jar"))
+         {
+            protected void setUp() throws Exception
+            {
+               super.setUp();
+               ClassLoader loader = Thread.currentThread().getContextClassLoader();
+	       String resourceName = getJMSResourceRelativePathname("test-destinations-full-service.xml") ;
+               deploy (loader.getResource(resourceName).toString());
+            }
+
+             protected void tearDown() throws Exception
+             {
+                super.tearDown();
+
+                // Remove the messages
+		// richard.achmatowicz: why do we need to drain a Queue before we undeploy it?
+                //getServer().invoke
+                //(
+                //   new ObjectName("jboss.mq.destination:service=Queue,name=testQueue"),
+                //   "removeAllMessages",
+                //   new Object[0],
+                //   new String[0]
+                //);
+                ClassLoader loader = Thread.currentThread().getContextClassLoader();
+		String resourceName = getJMSResourceRelativePathname("test-destinations-full-service.xml") ;
+                undeploy (loader.getResource(resourceName).toString());
+             }
+          };
+   }
+} // RaSyncRecUnitTestCase
+
+
+
+
+

Added: trunk/testsuite/src/main/org/jboss/test/jbossmessaging/ra/RaTest.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/jbossmessaging/ra/RaTest.java	2006-11-15 22:11:09 UTC (rev 58422)
+++ trunk/testsuite/src/main/org/jboss/test/jbossmessaging/ra/RaTest.java	2006-11-15 22:27:23 UTC (rev 58423)
@@ -0,0 +1,308 @@
+/*
+  * 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.jbossmessaging.ra;
+
+import javax.jms.Connection;
+import javax.jms.Message;
+
+import javax.jms.MessageConsumer;
+import javax.jms.Session;
+import javax.naming.Context;
+
+import javax.naming.InitialContext;
+import junit.framework.Assert;
+
+import junit.framework.TestCase;
+
+import org.jboss.test.jbossmessaging.JMSTestCase;
+
+import org.jboss.test.jmsra.bean.*;
+
+/**
+ * Abstract test cases for JMS Resource Adapter. <p>
+ *
+ * Created: Mon Apr 23 21:35:25 2001
+ *
+ * @author <a href="richard.achmatowicz at jboss.com">Richard Achmatowicz</a>
+ * @author    <a href="mailto:peter.antman at tim.se">Peter Antman</a>
+ * @author    <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ * @version   $Revision: 37406 $
+ */
+public abstract class RaTest extends JMSTestCase
+{
+   /**
+    * Description of the Field
+    */
+   public final static long DEFAULT_TIMEOUT = 500L;
+   /**
+    * Description of the Field
+    */
+   public final static long FLUSH_TIMEOUT = 500L;
+
+   /**
+    * Description of the Field
+    */
+   protected String beanJNDI;
+   /**
+    * Description of the Field
+    */
+   protected MessageConsumer consumer;
+   /**
+    * Description of the Field
+    */
+   protected Publisher publisher;
+   /**
+    * Description of the Field
+    */
+   protected Connection connection;
+   /**
+    * Description of the Field
+    */
+   protected Session session;
+
+   /**
+    * Constructor for the RaTest object
+    *
+    * @param name           Description of Parameter
+    * @param beanJNDI       Description of Parameter
+    * @exception Exception  Description of Exception
+    */
+   protected RaTest(final String name, final String beanJNDI)
+          throws Exception
+   {
+      super(name);
+      this.beanJNDI = beanJNDI;
+   }
+
+   /**
+    * A unit test for JUnit
+    *
+    * @exception Exception  Description of Exception
+    */
+   public void testSimple() throws Exception
+   {
+      printHeader();
+      getLog().debug("Verify simple send of message");
+      publisher.simple(1);
+
+      Assert.assertEquals(1, getJmsMessage());
+      printOK();
+   }
+
+   /**
+    * A unit test for JUnit
+    *
+    * @exception Exception  Description of Exception
+    */
+   public void testSimpleFail() throws Exception
+   {
+      printHeader();
+      getLog().debug("Verify simple failed transaction");
+      publisher.simpleFail(2);
+
+      Assert.assertEquals(-1, getJmsMessage());
+      printOK();
+   }
+
+   /**
+    * A unit test for JUnit
+    *
+    * @exception Exception  Description of Exception
+    */
+   public void testBeanOk() throws Exception
+   {
+      printHeader();
+      getLog().debug("Verify bean ok");
+      publisher.beanOk(3);
+
+      Assert.assertEquals(3, getJmsMessage());
+      printOK();
+   }
+
+   /**
+    * A unit test for JUnit
+    *
+    * @exception Exception  Description of Exception
+    */
+   public void testBeanError() throws Exception
+   {
+      printHeader();
+      getLog().debug("Verify bean eroor failed transaction");
+
+      try
+      {
+         publisher.beanError(4);
+      }
+      catch (Exception ignore)
+      {
+      }
+
+      Assert.assertEquals(-1, getJmsMessage());
+      printOK();
+   }
+
+   /**
+    * The JUnit setup method
+    *
+    * @exception Exception  Description of Exception
+    */
+   protected void setUp() throws Exception
+   {
+       // call setUp() in superclass
+       super.setUp() ;
+
+      // Create a publisher
+      Context context = getInitialContext();
+      try
+      {
+         PublisherHome home = (PublisherHome)context.lookup(beanJNDI);
+         publisher = home.create();
+
+         init(context);
+      }
+      finally
+      {
+         context.close();
+      }
+
+      // start up the session
+      connection.start();
+
+      // flush the destination
+      flush();
+   }
+
+   /**
+    * Check if we got a message.
+    *
+    * @return               Publisher.JMS_MESSAGE_NR int property or -1 if no
+    *      message was received.
+    * @exception Exception  Description of Exception
+    */
+   protected int getJmsMessage() throws Exception
+   {
+      return getJmsMessage(DEFAULT_TIMEOUT);
+   }
+
+   /**
+    * Check if we got a message.
+    *
+    * @param timeout        The time to wait for a message.
+    * @return               Publisher.JMS_MESSAGE_NR int property or -1 if no
+    *      message was received.
+    * @exception Exception  Description of Exception
+    */
+   protected int getJmsMessage(long timeout) throws Exception
+   {
+      Message msg = consumer.receive(timeout);
+      if (msg != null)
+      {
+         getLog().debug("Recived message: " + msg);
+         int nr = msg.getIntProperty(Publisher.JMS_MESSAGE_NR);
+         getLog().debug("nr: " + nr);
+         return nr;
+      }
+      else
+      {
+         getLog().debug("NO message recived");
+         return -1;
+      }
+   }
+
+   /**
+    * #Description of the Method
+    *
+    * @param context        Description of Parameter
+    * @exception Exception  Description of Exception
+    */
+   protected abstract void init(final Context context) throws Exception;
+
+   /**
+    * The teardown method for JUnit
+    *
+    * @exception Exception  Description of Exception
+    */
+   protected void tearDown() throws Exception
+   {
+      if (consumer != null)
+      {
+         consumer.close();
+      }
+      if (connection != null)
+      {
+         connection.close();
+      }
+
+      //call tearDown() in superclass
+      super.tearDown() ;
+   }
+
+   /**
+    * #Description of the Method
+    */
+   protected void printHeader()
+   {
+      getLog().debug("\n---- Testing method " + getName() +
+            " for bean " + beanJNDI);
+   }
+
+   /**
+    * #Description of the Method
+    */
+   protected void printOK()
+   {
+      getLog().debug("---- Test OK\n");
+   }
+
+   /**
+    * Flush the destiniation so we know that it contains no messages which might
+    * mess up the test.
+    *
+    * @exception Exception  Description of Exception
+    */
+   protected void flush() throws Exception
+   {
+      // getLog().debug(" > Flushing Destination");
+
+      int nr = 0;
+      do
+      {
+         try
+         {
+            nr = getJmsMessage(FLUSH_TIMEOUT);
+         }
+         catch (Exception ignore)
+         {
+         }
+      } while (nr != -1);
+      // getLog().debug(" > Flushed");
+   }
+
+   public static junit.framework.Test suite() throws Exception
+   {
+       ClassLoader loader = Thread.currentThread().getContextClassLoader();
+       String resourceName = getJMSResourceRelativePathname("test-destinations-service.xml") ;
+       return getDeploySetup(RaTest.class, loader.getResource(resourceName).toString());
+   }
+
+
+}

Added: trunk/testsuite/src/main/org/jboss/test/jbossmessaging/ra/RaTopicUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/jbossmessaging/ra/RaTopicUnitTestCase.java	2006-11-15 22:11:09 UTC (rev 58422)
+++ trunk/testsuite/src/main/org/jboss/test/jbossmessaging/ra/RaTopicUnitTestCase.java	2006-11-15 22:27:23 UTC (rev 58423)
@@ -0,0 +1,120 @@
+/*
+  * 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.jbossmessaging.ra;
+
+import javax.jms.MessageConsumer;
+import javax.jms.Session;
+import javax.jms.Topic;
+import javax.jms.TopicConnection;
+
+import javax.jms.TopicConnectionFactory;
+import javax.jms.TopicSession;
+
+import javax.management.ObjectName;
+
+import javax.naming.Context;
+
+import junit.framework.Test;
+
+import org.jboss.test.JBossTestSetup;
+
+/**
+ * Test cases for JMS Resource Adapter using a <em>Topic</em> . <p>
+ *
+ * Created: Mon Apr 23 21:35:25 2001
+ *
+ * @author    <a href="mailto:peter.antman at tim.se">Peter Antman</a>
+ * @author    <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ * @version   $Revision: 37406 $
+ */
+public class RaTopicUnitTestCase
+       extends RaTest
+{
+   private final static String TOPIC_FACTORY = "ConnectionFactory";
+   private final static String TOPIC = "topic/testTopic";
+   private final static String JNDI = "TxTopicPublisher";
+
+   /**
+    * Constructor for the RaTopicUnitTestCase object
+    *
+    * @param name           Description of Parameter
+    * @exception Exception  Description of Exception
+    */
+   public RaTopicUnitTestCase(String name) throws Exception
+   {
+      super(name, JNDI);
+   }
+
+   /**
+    * #Description of the Method
+    *
+    * @param context        Description of Parameter
+    * @exception Exception  Description of Exception
+    */
+   protected void init(final Context context) throws Exception
+   {
+      TopicConnectionFactory factory =
+            (TopicConnectionFactory)context.lookup(TOPIC_FACTORY);
+
+      connection = factory.createTopicConnection();
+
+      session = ((TopicConnection)connection).createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
+
+      Topic topic = (Topic)context.lookup(TOPIC);
+
+      consumer = ((TopicSession)session).createSubscriber(topic);
+   }
+
+   public static Test suite() throws Exception
+   {
+      return new JBossTestSetup(getDeploySetup(RaQueueUnitTestCase.class, "jmsra.jar"))
+         {
+            protected void setUp() throws Exception
+            {
+               super.setUp();
+               ClassLoader loader = Thread.currentThread().getContextClassLoader();
+	       String resourceName = getJMSResourceRelativePathname("test-destinations-service.xml") ;
+               deploy (loader.getResource(resourceName).toString());
+            }
+
+             protected void tearDown() throws Exception
+             {
+                super.tearDown();
+
+                // Remove the messages
+		// richard.achmatowicz: remove this seemingly unnecessary task
+                //getServer().invoke
+                //(
+                //   new ObjectName("jboss.mq.destination:service=Queue,name=testQueue"),
+                //   "removeAllMessages",
+                //   new Object[0],
+                //   new String[0]
+                //);
+                ClassLoader loader = Thread.currentThread().getContextClassLoader();
+	        String resourceName = getJMSResourceRelativePathname("test-destinations-service.xml") ;
+                undeploy (loader.getResource(resourceName).toString());
+             }
+          };
+   }
+
+
+}




More information about the jboss-cvs-commits mailing list