[jboss-cvs] JBoss Messaging SVN: r8203 - in branches/JBM1842: tests/src/org/jboss/test/messaging/jms/clustering and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sun Jan 30 09:21:41 EST 2011


Author: gaohoward
Date: 2011-01-30 09:21:40 -0500 (Sun, 30 Jan 2011)
New Revision: 8203

Added:
   branches/JBM1842/tests/src/org/jboss/test/messaging/jms/clustering/ServerFailoverTest2.java
Modified:
   branches/JBM1842/integration/EAP4/tests-src/org/jboss/test/messaging/tools/container/ServiceContainer.java
Log:
test


Modified: branches/JBM1842/integration/EAP4/tests-src/org/jboss/test/messaging/tools/container/ServiceContainer.java
===================================================================
--- branches/JBM1842/integration/EAP4/tests-src/org/jboss/test/messaging/tools/container/ServiceContainer.java	2011-01-30 13:44:12 UTC (rev 8202)
+++ branches/JBM1842/integration/EAP4/tests-src/org/jboss/test/messaging/tools/container/ServiceContainer.java	2011-01-30 14:21:40 UTC (rev 8203)
@@ -134,6 +134,7 @@
    public static ObjectName HTTP_REMOTING_OBJECT_NAME;
    
    public static ObjectName SERVER_PEER_OBJECT_NAME;
+   public static ObjectName POSTOFFICE_OBJECT_NAME;
    
    public static String DATA_SOURCE_JNDI_NAME = "java:/DefaultDS";
    public static String TRANSACTION_MANAGER_JNDI_NAME = "java:/TransactionManager";
@@ -185,6 +186,9 @@
          
          SERVER_PEER_OBJECT_NAME = new ObjectName(
                "jboss.messaging:service=ServerPeer");
+         
+         POSTOFFICE_OBJECT_NAME = new ObjectName(
+               "jboss.messaging:service=PostOffice");
       }
       catch (Exception e)
       {

Added: branches/JBM1842/tests/src/org/jboss/test/messaging/jms/clustering/ServerFailoverTest2.java
===================================================================
--- branches/JBM1842/tests/src/org/jboss/test/messaging/jms/clustering/ServerFailoverTest2.java	                        (rev 0)
+++ branches/JBM1842/tests/src/org/jboss/test/messaging/jms/clustering/ServerFailoverTest2.java	2011-01-30 14:21:40 UTC (rev 8203)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
+ * 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 javax.jms.Connection;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import org.jboss.test.messaging.tools.ServerManagement;
+import org.jboss.test.messaging.tools.container.ServiceAttributeOverrides;
+import org.jboss.test.messaging.tools.container.ServiceContainer;
+
+/**
+ * A ServerFailoverTest
+ *
+ * @author <a href="mailto:hgao at redhat.com">Howard Gao</a>
+ * 
+ * Created Jun 19, 2009 2:02:15 PM
+ *
+ *
+ */
+public class ServerFailoverTest2 extends ClusteringTestBase
+{
+   
+   private static final long REFRESH_INTERVAL = 10000;
+   
+   public ServerFailoverTest2(String name)
+   {
+      super(name);
+   }
+
+
+   public void setUp() throws Exception
+   {
+      nodeCount = 2;
+      
+      //make the failover follow new behavior
+      //https://issues.jboss.org/browse/JBMESSAGING-1842
+      overrides = new ServiceAttributeOverrides();
+      overrides.put(ServiceContainer.POSTOFFICE_OBJECT_NAME, "KeepOldFailoverModel", Boolean.FALSE);
+      overrides.put(ServiceContainer.POSTOFFICE_OBJECT_NAME, "NodeStateRefreshInterval", new Long(REFRESH_INTERVAL));
+      
+      super.setUp();
+   }
+
+   //start two nodes, send a message to node1, kill node1,
+   //receive from node0, the receive time should be greater than NodeStateRefreshInterval
+   public void testNewFailover() throws Exception
+   {
+      Connection conn = createConnectionOnServer(cf, 1);
+      
+      Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      MessageProducer prod = session.createProducer(queue[1]);
+      TextMessage message = session.createTextMessage("Message_testNewFailover");
+
+      prod.send(message);
+
+      conn.close();
+      
+      long start = System.currentTimeMillis();
+      
+      ServerManagement.kill(1);
+
+      conn = createConnectionOnServer(cf, 0);
+      
+      session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      
+      MessageConsumer consumer = session.createConsumer(queue[0]);
+      
+      conn.start();
+      
+      message = (TextMessage)consumer.receive(30000);
+      
+      assertNotNull(message);
+      
+      long stop = System.currentTimeMillis();
+      
+      assertEquals("Message_testNewFailover", message.getText());
+      
+      long duration = stop - start;
+      
+      assertTrue(duration > REFRESH_INTERVAL);
+      
+      conn.close();
+   }
+}
+
+
+
+
+



More information about the jboss-cvs-commits mailing list