[jboss-cvs] JBoss Messaging SVN: r2402 - in trunk/tests: src/org/jboss/test/messaging/jms and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Feb 23 08:06:09 EST 2007
Author: timfox
Date: 2007-02-23 08:06:09 -0500 (Fri, 23 Feb 2007)
New Revision: 2402
Added:
trunk/tests/src/org/jboss/test/messaging/jms/LongRunningInvocationTest.java
Modified:
trunk/tests/build.xml
trunk/tests/src/org/jboss/test/messaging/tools/aop/PoisonInterceptor.java
Log:
http://jira.jboss.org/jira/browse/JBMESSAGING-785
Modified: trunk/tests/build.xml
===================================================================
--- trunk/tests/build.xml 2007-02-23 12:00:21 UTC (rev 2401)
+++ trunk/tests/build.xml 2007-02-23 13:06:09 UTC (rev 2402)
@@ -441,6 +441,7 @@
<exclude name="**/*LeakTest.class"/>
<exclude name="**/jms/bridge/**/*Test.class"/>
<exclude name="**/jms/manual/**/*Test.class"/>
+ <exclude name="**/jms/LongRunningInvocationTest.class"/>
<exclude name="**/jms/clustering/*Test.class"/>
<exclude name="**/jms/RemotingConnectionConfigurationTest.class"/>
<exclude name="**/thirdparty/remoting/ManualConnectionValidatorTest.class"/>
@@ -491,6 +492,7 @@
<fileset dir="${build.tests.classes}">
<include name="**/messaging/jms/**/*Test.class"/>
<exclude name="**/messaging/graveyard/**/*Test.class"/>
+ <exclude name="**/jms/LongRunningInvocationTest.class"/>
<exclude name="**/jms/stress/**"/>
<exclude name="**/jms/crash/*Test.class"/>
<exclude name="**/*LeakTest.class"/>
Added: trunk/tests/src/org/jboss/test/messaging/jms/LongRunningInvocationTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/LongRunningInvocationTest.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/jms/LongRunningInvocationTest.java 2007-02-23 13:06:09 UTC (rev 2402)
@@ -0,0 +1,193 @@
+/*
+ * 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;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.DeliveryMode;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.naming.InitialContext;
+
+import org.jboss.test.messaging.MessagingTestCase;
+import org.jboss.test.messaging.tools.ServerManagement;
+import org.jboss.test.messaging.tools.aop.PoisonInterceptor;
+
+/**
+ *
+ * A LongRunningInvocationTest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class LongRunningInvocationTest extends MessagingTestCase
+{
+ // Constants -----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ InitialContext ic;
+
+ // Constructors --------------------------------------------------
+
+ public LongRunningInvocationTest(String name)
+ {
+ super(name);
+ }
+
+ // Public --------------------------------------------------------
+
+ public void setUp() throws Exception
+ {
+ if (!ServerManagement.isRemote())
+ {
+ throw new IllegalStateException("Test should only be run in remote mode");
+ }
+
+ super.setUp();
+
+ ServerManagement.start("all");
+
+ ic = new InitialContext(ServerManagement.getJNDIEnvironment());
+
+ ServerManagement.undeployQueue("JMSTestQueue");
+ ServerManagement.deployQueue("JMSTestQueue");
+
+ log.debug("setup done");
+ }
+
+ public void tearDown() throws Exception
+ {
+ if (ServerManagement.isStarted(0))
+ {
+ ServerManagement.undeployQueue("JMSTestQueue");
+ }
+
+ ic.close();
+
+ super.tearDown();
+ }
+
+ public void testLongRunningInvocationPingFirst() throws Exception
+ {
+ ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
+
+ Queue queue = (Queue)ic.lookup("/queue/JMSTestQueue");
+
+ Connection conn = null;
+
+ try
+ {
+ conn = cf.createConnection();
+
+ Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageProducer prod = session.createProducer(queue);
+ prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+
+ MessageConsumer cons = session.createConsumer(queue);
+
+ TextMessage m = session.createTextMessage("message one");
+
+ // Pause a bit to let a least one ping through
+ Thread.sleep(5000);
+
+ //Poison the server so the invocation takes 2 minutes - longer than the ping period
+
+
+ // log.info("server is " + ServerManagement.getServer(0));
+ ServerManagement.poisonTheServer(0, PoisonInterceptor.LONG_SEND);
+
+ log.info("This will pause for 2 minutes on send");
+ prod.send(m);
+
+ conn.start();
+
+ TextMessage m2 = (TextMessage)cons.receive(1000);
+
+ assertEquals(m.getText(), m2.getText());
+ }
+ finally
+ {
+ conn.close();
+ }
+
+ }
+
+ public void testLongRunningInvocation() throws Exception
+ {
+ ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
+
+ Queue queue = (Queue)ic.lookup("/queue/JMSTestQueue");
+
+ Connection conn = null;
+
+ try
+ {
+ conn = cf.createConnection();
+
+ Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageProducer prod = session.createProducer(queue);
+ prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+
+ MessageConsumer cons = session.createConsumer(queue);
+
+ TextMessage m = session.createTextMessage("message one");
+
+ //Poison the server so the invocation takes 2 minutes - longer than the ping period
+
+ //ServerManagement.poisonTheServer(0, PoisonInterceptor.LONG_SEND);
+
+ log.info("This will pause for 2 minutes on send");
+ prod.send(m);
+
+ conn.start();
+
+ TextMessage m2 = (TextMessage)cons.receive(1000);
+
+ assertEquals(m.getText(), m2.getText());
+ }
+ finally
+ {
+ conn.close();
+ }
+
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Modified: trunk/tests/src/org/jboss/test/messaging/tools/aop/PoisonInterceptor.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/aop/PoisonInterceptor.java 2007-02-23 12:00:21 UTC (rev 2401)
+++ trunk/tests/src/org/jboss/test/messaging/tools/aop/PoisonInterceptor.java 2007-02-23 13:06:09 UTC (rev 2402)
@@ -49,6 +49,8 @@
public static final int FAIL_SYNCHRONIZED_SEND_RECEIVE = 6;
public static final int FAIL_AFTER_SENDTRANSACTION = 7;
+
+ public static final int LONG_SEND = 8;
// Static ---------------------------------------------------------------------------------------
@@ -172,6 +174,17 @@
Thread.sleep(60000);
}
}
+ else if (type == LONG_SEND)
+ {
+ if ("send".equals(methodName))
+ {
+ //Pause for 2 mins before processing send
+ log.info("Sleeping for 2 minutes before sending....");
+ Thread.sleep(120000);
+
+ invocation.invokeNext();
+ }
+ }
return invocation.invokeNext();
}
More information about the jboss-cvs-commits
mailing list