[jboss-cvs] JBoss Messaging SVN: r1722 - in branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering: . base
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Dec 7 19:49:17 EST 2006
Author: ovidiu.feodorov at jboss.com
Date: 2006-12-07 19:49:15 -0500 (Thu, 07 Dec 2006)
New Revision: 1722
Added:
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/SimpleClusteringTest.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/base/
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/base/ClusteringTestBase.java
Removed:
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/ClusteringBase.java
Modified:
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/HATest.java
branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/ManualClusteringTest.java
Log:
minor clustering test refactoring; placing the base in 'base' and adding some simple tests
Deleted: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/ClusteringBase.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/ClusteringBase.java 2006-12-07 22:55:59 UTC (rev 1721)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/ClusteringBase.java 2006-12-08 00:49:15 UTC (rev 1722)
@@ -1,226 +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.jms.clustering;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.Topic;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import org.jboss.test.messaging.MessagingTestCase;
-import org.jboss.test.messaging.tools.ServerManagement;
-
-/**
- * @author <a href="mailto:tim.fox at jboss.org">Tim Fox</a>
- * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
- * @version <tt>$Revision:$</tt>
- * $Id:$
- */
-public class ClusteringBase extends MessagingTestCase
-{
- // Constants -----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- protected Context ic;
- protected Context ic1;
- protected Context ic2;
-
- protected Queue queue;
- protected Queue queue1;
- protected Queue queue2;
-
- protected Topic topic;
- protected Topic topic1;
- protected Topic topic2;
-
- protected ConnectionFactory cf;
- protected ConnectionFactory cf1;
- protected ConnectionFactory cf2;
-
- // Constructors --------------------------------------------------
-
- public ClusteringBase(String name)
- {
- super(name);
- }
-
- // Public --------------------------------------------------------
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- protected void setUp() throws Exception
- {
- super.setUp();
-
- String banner =
- "####################################################### Start " +
- (isRemote() ? "REMOTE" : "IN-VM") + " test: " + getName();
-
- ServerManagement.log(ServerManagement.INFO,banner);
-
- try
- {
- startServer(0);
- startServer(1);
- startServer(2);
-
- log.info("Deployed destinations ok");
-
- ic = new InitialContext(ServerManagement.getJNDIEnvironment(0));
- ic1 = new InitialContext(ServerManagement.getJNDIEnvironment(1));
- ic2 = new InitialContext(ServerManagement.getJNDIEnvironment(2));
-
- cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
- cf1 = (ConnectionFactory)ic1.lookup("/ConnectionFactory");
- cf2 = (ConnectionFactory)ic2.lookup("/ConnectionFactory");
-
- queue = (Queue)ic.lookup("queue/testDistributedQueue");
- queue1 = (Queue)ic1.lookup("queue/testDistributedQueue");
- queue2 = (Queue)ic2.lookup("queue/testDistributedQueue");
-
- topic = (Topic)ic.lookup("topic/testDistributedTopic");
- topic1 = (Topic)ic1.lookup("topic/testDistributedTopic");
- topic2 = (Topic)ic2.lookup("topic/testDistributedTopic");
-
- drainQueues();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- throw e;
- }
- }
-
- private void startServer(int serverIndex) throws Exception
- {
- ServerManagement.start("all", serverIndex);
- ServerManagement.deployClusteredQueue("testDistributedQueue", serverIndex);
- ServerManagement.deployClusteredTopic("testDistributedTopic", serverIndex);
- }
-
- protected void tearDown() throws Exception
- {
- try
- {
- ServerManagement.log(ServerManagement.INFO,"Undeploying Server 0");
- ServerManagement.undeployQueue("testDistributedQueue", 0);
- ServerManagement.undeployTopic("testDistributedTopic", 0);
-
- ServerManagement.log(ServerManagement.INFO,"Undeploying Server 1");
- ServerManagement.undeployQueue("testDistributedQueue", 1);
- ServerManagement.undeployTopic("testDistributedTopic", 1);
-
- ServerManagement.log(ServerManagement.INFO,"Undeploying Server 2");
- ServerManagement.undeployQueue("testDistributedQueue", 2);
- ServerManagement.undeployTopic("testDistributedTopic", 2);
-
- ic.close();
- ic1.close();
- ic2.close();
-
- super.tearDown();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- throw e;
- }
- }
-
- protected void drainQueues() throws Exception
- {
- Connection conn = null;
- Connection conn1 = null;
- Connection conn2 = null;
-
- try
- {
- conn = cf.createConnection();
- conn1 = cf1.createConnection();
- conn2 = cf2.createConnection();
-
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer cons = sess.createConsumer(queue);
- MessageConsumer cons1 = sess1.createConsumer(queue1);
- MessageConsumer cons2 = sess2.createConsumer(queue2);
-
- conn.start();
- conn1.start();
- conn2.start();
-
- Message msg = null;
-
- do
- {
- msg = cons.receive(1000);
- }
- while (msg != null);
-
- do
- {
- msg = cons1.receive(1000);
- }
- while (msg != null);
-
- do
- {
- msg = cons2.receive(1000);
- }
- while (msg != null);
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
-
- if (conn1 != null)
- {
- conn1.close();
- }
-
- if (conn2 != null)
- {
- conn2.close();
- }
- }
- }
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
-}
Modified: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/HATest.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/HATest.java 2006-12-07 22:55:59 UTC (rev 1721)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/HATest.java 2006-12-08 00:49:15 UTC (rev 1722)
@@ -40,6 +40,7 @@
import org.jboss.jms.client.state.SessionState;
import org.jboss.jms.message.MessageProxy;
import org.jboss.test.messaging.tools.ServerManagement;
+import org.jboss.test.messaging.jms.clustering.base.ClusteringTestBase;
/**
* @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
@@ -47,7 +48,7 @@
*
* $Id:$
*/
-public class HATest extends ClusteringBase
+public class HATest extends ClusteringTestBase
{
// Constants -----------------------------------------------------
Modified: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/ManualClusteringTest.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/ManualClusteringTest.java 2006-12-07 22:55:59 UTC (rev 1721)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/ManualClusteringTest.java 2006-12-08 00:49:15 UTC (rev 1722)
@@ -21,6 +21,8 @@
*/
package org.jboss.test.messaging.jms.clustering;
+import org.jboss.test.messaging.jms.clustering.base.ClusteringTestBase;
+
import javax.jms.*;
/**
@@ -35,7 +37,7 @@
* $Id$
*
*/
-public class ManualClusteringTest extends ClusteringBase
+public class ManualClusteringTest extends ClusteringTestBase
{
// Constants -----------------------------------------------------
Added: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/SimpleClusteringTest.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/SimpleClusteringTest.java 2006-12-07 22:55:59 UTC (rev 1721)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/SimpleClusteringTest.java 2006-12-08 00:49:15 UTC (rev 1722)
@@ -0,0 +1,152 @@
+/**
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.messaging.jms.clustering;
+
+import org.jboss.test.messaging.jms.clustering.base.ClusteringTestBase;
+
+import javax.jms.Connection;
+import javax.jms.Session;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.Message;
+import javax.jms.TextMessage;
+
+import EDU.oswego.cs.dl.util.concurrent.Slot;
+
+/**
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public class SimpleClusteringTest extends ClusteringTestBase
+{
+ // Constants -----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ public SimpleClusteringTest(String name)
+ {
+ super(name);
+ }
+
+ // Public --------------------------------------------------------
+
+ public void testDistributedTopic() throws Exception
+ {
+ Connection conn = null;
+ Connection conn1 = null;
+ Connection conn2 = null;
+
+ try
+ {
+ conn = cf.createConnection();
+ conn1 = cf.createConnection();
+ conn2 = cf.createConnection();
+
+ Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ Session s1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ Session s2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ SimpleMessageListener ml = new SimpleMessageListener();
+ SimpleMessageListener ml1 = new SimpleMessageListener();
+ SimpleMessageListener ml2 = new SimpleMessageListener();
+
+ s.createConsumer(topic).setMessageListener(ml);
+ s1.createConsumer(topic).setMessageListener(ml1);
+ s2.createConsumer(topic).setMessageListener(ml2);
+
+ conn.start();
+ conn1.start();
+ conn2.start();
+
+ s.createProducer(topic).send(s.createTextMessage("boom"));
+
+ TextMessage rm = null;
+
+ rm = ml.poll(5000);
+ assertEquals("boom", rm.getText());
+
+ rm = ml1.poll(5000);
+ assertEquals("boom", rm.getText());
+
+ rm = ml2.poll(5000);
+ assertEquals("boom", rm.getText());
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+
+ if (conn1 != null)
+ {
+ conn1.close();
+ }
+
+ if (conn2 != null)
+ {
+ conn2.close();
+ }
+
+ }
+
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ log.debug("setup done");
+ }
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+ private class SimpleMessageListener implements MessageListener
+ {
+ private Slot slot;
+
+ SimpleMessageListener()
+ {
+ slot = new Slot();
+ }
+
+ public void onMessage(Message message)
+ {
+ try
+ {
+ slot.put(message);
+ }
+ catch(InterruptedException e)
+ {
+ log.error(e);
+ }
+ }
+
+ public TextMessage poll(long timeout) throws InterruptedException
+ {
+ return (TextMessage)slot.poll(timeout);
+ }
+ }
+}
Added: branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/base/ClusteringTestBase.java
===================================================================
--- branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/base/ClusteringTestBase.java 2006-12-07 22:55:59 UTC (rev 1721)
+++ branches/Branch_Client_Failover_Experiment/tests/src/org/jboss/test/messaging/jms/clustering/base/ClusteringTestBase.java 2006-12-08 00:49:15 UTC (rev 1722)
@@ -0,0 +1,226 @@
+/*
+ * 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.base;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.Topic;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import org.jboss.test.messaging.MessagingTestCase;
+import org.jboss.test.messaging.tools.ServerManagement;
+
+/**
+ * @author <a href="mailto:tim.fox at jboss.org">Tim Fox</a>
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ * @version <tt>$Revision:$</tt>
+ * $Id:$
+ */
+public class ClusteringTestBase extends MessagingTestCase
+{
+ // Constants -----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ protected Context ic;
+ protected Context ic1;
+ protected Context ic2;
+
+ protected Queue queue;
+ protected Queue queue1;
+ protected Queue queue2;
+
+ protected Topic topic;
+ protected Topic topic1;
+ protected Topic topic2;
+
+ protected ConnectionFactory cf;
+ protected ConnectionFactory cf1;
+ protected ConnectionFactory cf2;
+
+ // Constructors --------------------------------------------------
+
+ public ClusteringTestBase(String name)
+ {
+ super(name);
+ }
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ String banner =
+ "####################################################### Start " +
+ (isRemote() ? "REMOTE" : "IN-VM") + " test: " + getName();
+
+ ServerManagement.log(ServerManagement.INFO,banner);
+
+ try
+ {
+ startServer(0);
+ startServer(1);
+ startServer(2);
+
+ log.info("Deployed destinations ok");
+
+ ic = new InitialContext(ServerManagement.getJNDIEnvironment(0));
+ ic1 = new InitialContext(ServerManagement.getJNDIEnvironment(1));
+ ic2 = new InitialContext(ServerManagement.getJNDIEnvironment(2));
+
+ cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
+ cf1 = (ConnectionFactory)ic1.lookup("/ConnectionFactory");
+ cf2 = (ConnectionFactory)ic2.lookup("/ConnectionFactory");
+
+ queue = (Queue)ic.lookup("queue/testDistributedQueue");
+ queue1 = (Queue)ic1.lookup("queue/testDistributedQueue");
+ queue2 = (Queue)ic2.lookup("queue/testDistributedQueue");
+
+ topic = (Topic)ic.lookup("topic/testDistributedTopic");
+ topic1 = (Topic)ic1.lookup("topic/testDistributedTopic");
+ topic2 = (Topic)ic2.lookup("topic/testDistributedTopic");
+
+ drainQueues();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ protected void tearDown() throws Exception
+ {
+ try
+ {
+ ServerManagement.log(ServerManagement.INFO,"Undeploying Server 0");
+ ServerManagement.undeployQueue("testDistributedQueue", 0);
+ ServerManagement.undeployTopic("testDistributedTopic", 0);
+
+ ServerManagement.log(ServerManagement.INFO,"Undeploying Server 1");
+ ServerManagement.undeployQueue("testDistributedQueue", 1);
+ ServerManagement.undeployTopic("testDistributedTopic", 1);
+
+ ServerManagement.log(ServerManagement.INFO,"Undeploying Server 2");
+ ServerManagement.undeployQueue("testDistributedQueue", 2);
+ ServerManagement.undeployTopic("testDistributedTopic", 2);
+
+ ic.close();
+ ic1.close();
+ ic2.close();
+
+ super.tearDown();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ protected void drainQueues() throws Exception
+ {
+ Connection conn = null;
+ Connection conn1 = null;
+ Connection conn2 = null;
+
+ try
+ {
+ conn = cf.createConnection();
+ conn1 = cf1.createConnection();
+ conn2 = cf2.createConnection();
+
+ Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageConsumer cons = sess.createConsumer(queue);
+ MessageConsumer cons1 = sess1.createConsumer(queue1);
+ MessageConsumer cons2 = sess2.createConsumer(queue2);
+
+ conn.start();
+ conn1.start();
+ conn2.start();
+
+ Message msg = null;
+
+ do
+ {
+ msg = cons.receive(1000);
+ }
+ while (msg != null);
+
+ do
+ {
+ msg = cons1.receive(1000);
+ }
+ while (msg != null);
+
+ do
+ {
+ msg = cons2.receive(1000);
+ }
+ while (msg != null);
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+
+ if (conn1 != null)
+ {
+ conn1.close();
+ }
+
+ if (conn2 != null)
+ {
+ conn2.close();
+ }
+ }
+ }
+
+ // Private -------------------------------------------------------
+
+ private void startServer(int serverIndex) throws Exception
+ {
+ ServerManagement.start("all", serverIndex);
+ ServerManagement.deployClusteredQueue("testDistributedQueue", serverIndex);
+ ServerManagement.deployClusteredTopic("testDistributedTopic", serverIndex);
+ }
+
+ // Inner classes -------------------------------------------------
+
+}
More information about the jboss-cvs-commits
mailing list