[jboss-cvs] JBoss Messaging SVN: r3870 - branches/Branch_Stable/tests/src/org/jboss/test/messaging/jms/clustering.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Mar 11 23:05:48 EDT 2008


Author: clebert.suconic at jboss.com
Date: 2008-03-11 23:05:48 -0400 (Tue, 11 Mar 2008)
New Revision: 3870

Added:
   branches/Branch_Stable/tests/src/org/jboss/test/messaging/jms/clustering/DistributedQueueTwoServers.java
Log:
Adding temporary testcase for JBMESSAGING-1089

Added: branches/Branch_Stable/tests/src/org/jboss/test/messaging/jms/clustering/DistributedQueueTwoServers.java
===================================================================
--- branches/Branch_Stable/tests/src/org/jboss/test/messaging/jms/clustering/DistributedQueueTwoServers.java	                        (rev 0)
+++ branches/Branch_Stable/tests/src/org/jboss/test/messaging/jms/clustering/DistributedQueueTwoServers.java	2008-03-12 03:05:48 UTC (rev 3870)
@@ -0,0 +1,260 @@
+/*
+ * 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.jms.clustering;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.jms.Connection;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import org.jboss.jms.client.FailoverEvent;
+import org.jboss.jms.client.JBossConnection;
+import org.jboss.jms.client.JBossConnectionFactory;
+import org.jboss.jms.tx.ResourceManagerFactory;
+import org.jboss.test.messaging.tools.ServerManagement;
+
+/**
+ * 
+ * This test was created to validate the new JGroups.
+ * We had one specific bug on ChangeFailoverNodeTest, and this test produces the minimal condition for that test.
+ * This test basically duplicates ChangeFailoverNodeTest and it will be deleted as soon as ChangeFailoverNodeTest is passing without a problem, and JGroups is fixed.
+ * 
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:clebert.suconic at jboss.com">Clebert Suconic</a>
+ * @version <tt>$Revision: $</tt>8 Jul 2007
+ * 
+ * $Id: $
+ * 
+ */
+public class DistributedQueueTwoServers extends ClusteringTestBase
+{
+
+   // Constants -----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   private String queueName = "testDistributedQueue";
+
+   // Constructors --------------------------------------------------
+
+   public DistributedQueueTwoServers(String name)
+   {
+      super(name);
+   }
+   
+   protected void setUp() throws Exception
+   {
+      this.nodeCount=2;
+      super.setUp();
+   }
+
+   protected void tearDown() throws Exception
+   {
+      log.info("************* TEARING DOWN");
+
+      String failString = null;
+
+      try
+      {
+
+         if (ResourceManagerFactory.instance.size() != 0)
+         {
+            ResourceManagerFactory.instance.dump();
+
+            failString  = "Connection(s) have been left open";
+         }
+
+         for (int i = 0; i < nodeCount; i++)
+         {
+            if (ServerManagement.isStarted(i))
+            {
+               if (!isEmpty(queue[i], i))
+               {
+                  failString = "Queue " + queue[i].getQueueName() + " is not empty on node" + i;
+
+                  break;
+               }
+
+               // Check no subscriptions left lying around
+
+               Integer messageCount = getNoSubscriptions(topic[i], i);
+
+               if (messageCount.intValue() != 0)
+               {
+                  failString = "Topic " + topic[i].getTopicName() + " has subscriptions";
+
+                  break;
+               }
+            }
+         }
+      }
+      catch (Throwable ignore)
+      {
+      }
+
+      for (int i = 9 ; i >= 0; i--)
+      {
+         try
+         {
+            ic[i].close();
+         }
+         catch (Throwable ignore)
+         {
+         }
+
+      }
+
+      ic = null;
+
+      queue = null;
+
+      topic = null;
+
+      if (failString != null)
+      {
+         fail(failString);
+      }
+   }
+
+   
+
+   // Public --------------------------------------------------------
+
+  /* public void testKillFailoverNodeTransactional() throws Exception
+   {
+      this.killFailoverNode(true);
+   } */
+
+   public void testKillFailoverNodeNonTransactional() throws Exception
+   {
+      this.killFailoverNode(true);
+   }
+
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   private static int counter;
+
+   private void killFailoverNode(boolean transactional) throws Exception
+   {
+      JBossConnectionFactory factory = (JBossConnectionFactory) ic[0]
+            .lookup("/ClusteredConnectionFactory");
+
+      Connection conn1 = createConnectionOnServer(factory, 1);
+
+      try
+      {
+         SimpleFailoverListener failoverListener = new SimpleFailoverListener();
+         ((JBossConnection) conn1).registerFailoverListener(failoverListener);
+
+         Session sessSend = conn1
+               .createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+         MessageProducer prod1 = sessSend.createProducer(queue[1]);
+
+         final int numMessages = 10;
+
+         String msg = "***** Sending messages now"; 
+         log.info(msg);
+         ServerManagement.getServer(0).log(ServerManagement.INFO, msg);
+         ServerManagement.getServer(1).log(ServerManagement.INFO, msg);
+         for (int i = 0; i < numMessages; i++)
+         {
+            TextMessage tm = sessSend.createTextMessage("message" + i);
+
+            tm.setIntProperty("counter", counter++);
+
+            prod1.send(tm);
+
+            log.info("Sent " + tm.getJMSMessageID() + " tm=" + tm);
+         }
+
+         msg = "***** Creating session now"; 
+         log.info(msg);
+         ServerManagement.getServer(0).log(ServerManagement.INFO, msg);
+         ServerManagement.getServer(1).log(ServerManagement.INFO, msg);
+         Session sess1 = conn1.createSession(transactional,
+               transactional ? Session.SESSION_TRANSACTED
+                     : Session.CLIENT_ACKNOWLEDGE);
+
+         msg = "***** Connection.start now"; 
+         log.info(msg);
+         ServerManagement.getServer(0).log(ServerManagement.INFO, msg);
+         ServerManagement.getServer(1).log(ServerManagement.INFO, msg);
+         conn1.start();
+
+         
+         msg = "***** Creating Consumer now"; 
+         log.info(msg);
+         ServerManagement.getServer(0).log(ServerManagement.INFO, msg);
+         ServerManagement.getServer(1).log(ServerManagement.INFO, msg);
+
+         MessageConsumer cons1 = sess1.createConsumer(queue[1]);
+
+
+         TextMessage tm = null;
+
+         for (int i = 0; i < numMessages; i++)
+         {
+            msg = "***** Receiving a message now"; 
+            log.info(msg);
+            ServerManagement.getServer(0).log(ServerManagement.INFO, msg);
+            ServerManagement.getServer(1).log(ServerManagement.INFO, msg);
+
+            tm = (TextMessage) cons1.receive(0);
+            
+            log.info("Received message = " + tm);
+
+            assertNotNull(tm);
+            
+            //tm.acknowledge();
+
+            assertEquals("message" + i, tm.getText());
+         }
+         
+         tm.acknowledge();
+         
+         sess1.commit();
+
+      } finally
+      {
+         if (conn1 != null)
+         {
+            conn1.close();
+         }
+      }
+   }
+
+   // Inner classes -------------------------------------------------
+
+}


Property changes on: branches/Branch_Stable/tests/src/org/jboss/test/messaging/jms/clustering/DistributedQueueTwoServers.java
___________________________________________________________________
Name: svn:keywords
   + "Id LastChangedDate Author Revision"




More information about the jboss-cvs-commits mailing list