[jboss-cvs] JBoss Messaging SVN: r2104 - trunk/tests/src/org/jboss/test/thirdparty/remoting.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jan 30 02:35:13 EST 2007
Author: ovidiu.feodorov at jboss.com
Date: 2007-01-30 02:35:13 -0500 (Tue, 30 Jan 2007)
New Revision: 2104
Added:
trunk/tests/src/org/jboss/test/thirdparty/remoting/ClientInvokerTimeoutTest.java
trunk/tests/src/org/jboss/test/thirdparty/remoting/LazySubsystem.java
Log:
test cases for http://jira.jboss.org/jira/browse/JBMESSAGING-787, http://jira.jboss.org/jira/browse/JBREM-691
Added: trunk/tests/src/org/jboss/test/thirdparty/remoting/ClientInvokerTimeoutTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/thirdparty/remoting/ClientInvokerTimeoutTest.java (rev 0)
+++ trunk/tests/src/org/jboss/test/thirdparty/remoting/ClientInvokerTimeoutTest.java 2007-01-30 07:35:13 UTC (rev 2104)
@@ -0,0 +1,231 @@
+/**
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.thirdparty.remoting;
+
+import org.jboss.test.messaging.MessagingTestCase;
+import org.jboss.test.messaging.tools.ServerManagement;
+import org.jboss.test.messaging.tools.jmx.ServiceContainer;
+import org.jboss.test.messaging.tools.jmx.ServiceAttributeOverrides;
+import org.jboss.test.thirdparty.remoting.util.RemotingTestSubsystemService;
+import org.jboss.test.thirdparty.remoting.util.SimpleConnectionListener;
+import org.jboss.logging.Logger;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.transport.PortUtil;
+
+/**
+ * Tests for http://jira.jboss.org/jira/browse/JBMESSAGING-787,
+ * http://jira.jboss.org/jira/browse/JBREM-691. Test written entirely at the Remoting level. If
+ * fails with Remoting 2.2.0.Alpha6.
+ *
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ *
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public class ClientInvokerTimeoutTest extends MessagingTestCase
+{
+ // Constants ------------------------------------------------------------------------------------
+
+ private static final Logger log = Logger.getLogger(ClientInvokerTimeoutTest.class);
+
+ // Static ---------------------------------------------------------------------------------------
+
+ // Attributes -----------------------------------------------------------------------------------
+
+ private InvokerLocator serverLocator;
+
+ // Constructors ---------------------------------------------------------------------------------
+
+ public ClientInvokerTimeoutTest(String name)
+ {
+ super(name);
+ }
+
+ // Public ---------------------------------------------------------------------------------------
+
+ /**
+ * A remoting client created for "business use" will throw an unexpected SocketTimeoutException
+ * after 1000 ms during a long invocation, even if it's not supposed to. If fails with Remoting
+ * 2.2.0.Alpha6.
+ */
+ public void testUnexpectedSocketTimeoutException() throws Throwable
+ {
+ // This test doesn't make sense for HTTP, so shortcut it
+
+ if (!"socket".equals(ServerManagement.getRemotingTransport(0)))
+ {
+ return;
+ }
+
+ Client client = null;
+
+ try
+ {
+ client = new Client(serverLocator, RemotingTestSubsystemService.SUBSYSTEM_LABEL);
+
+ client.connect();
+
+ SimpleConnectionListener connListener = new SimpleConnectionListener();
+ client.addConnectionListener(connListener, 3333);
+
+ log.info("connection listener added, pinging will start in 3.3 secs");
+
+ Thread.sleep(5000);
+
+ log.info("first ping is done, send a long running invocation");
+
+ // in 2.2.0.Alpha6 the client will send the invocation over a socket configured to time
+ // out after 1000 ms, so this will throw java.net.SocketTimeoutException
+
+ client.invoke(new Long(5000));
+
+ Thread.sleep(7000);
+ }
+ finally
+ {
+ if (client != null)
+ {
+ client.disconnect();
+ }
+ }
+ }
+
+ /**
+ * Same as testUnexpectedSocketTimeoutException(), slightly different setup.
+ */
+ public void testUnexpectedSocketTimeoutException2() throws Throwable
+ {
+ // This test doesn't make sense for HTTP, so shortcut it
+
+ if (!"socket".equals(ServerManagement.getRemotingTransport(0)))
+ {
+ return;
+ }
+
+ Client client = null;
+
+ try
+ {
+ // create a "business" client
+
+ client = new Client(serverLocator, RemotingTestSubsystemService.SUBSYSTEM_LABEL);
+
+ client.connect();
+
+ final Client clientCopy = client;
+
+ // send a "long running" invocation first on a separate thread, so we can setup the
+ // connection validator at the same time
+
+ new Thread(new Runnable()
+ {
+ public void run()
+ {
+ try
+ {
+ // this invocation will take 5 secs to complete
+ clientCopy.invoke(new Long(5000));
+ }
+ catch(Throwable t)
+ {
+ log.error("invocation failed", t);
+ }
+
+ }
+ }, "Lazy Invocation Thread").start();
+
+ Thread.sleep(1000);
+
+ SimpleConnectionListener connListener = new SimpleConnectionListener();
+ client.addConnectionListener(connListener, 3333);
+
+ log.info("connection listener added, pinging will start in 3.3 secs");
+
+ Thread.sleep(4000);
+
+ log.info("first ping is done, the answer to the first invocation should be back already");
+
+ // in 2.2.0.Alpha6 the client will send the invocation over a socket configured to time
+ // out after 1000 ms, so this will throw java.net.SocketTimeoutException
+
+ client.invoke(new Long(5000));
+
+ Thread.sleep(7000);
+
+ }
+ finally
+ {
+ if (client != null)
+ {
+ client.disconnect();
+ }
+ }
+ }
+
+ // Package protected ----------------------------------------------------------------------------
+
+ // Protected ------------------------------------------------------------------------------------
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ if (!isRemote())
+ {
+ fail("This test should be run in a remote configuration!");
+ }
+
+ // Start the Remoting service in a configuration similar to the one in which the bug shows up
+
+ String addr = ServiceContainer.getCurrentAddress();
+ int port = PortUtil.findFreePort(addr);
+
+ String serviceLocatorString =
+ "socket://" + addr + ":" + port + "/?" +
+ "clientSocketClass=org.jboss.jms.client.remoting.ClientSocketWrapper&" +
+ "dataType=jms&" +
+ "marshaller=org.jboss.jms.server.remoting.JMSWireFormat&" +
+ "serializationtype=jboss&" +
+ "socket.check_connection=false&" +
+ "unmarshaller=org.jboss.jms.server.remoting.JMSWireFormat";
+
+ ServiceAttributeOverrides sao = new ServiceAttributeOverrides();
+ sao.put(ServiceContainer.REMOTING_OBJECT_NAME, "LocatorURI", serviceLocatorString);
+
+ ServerManagement.start(0, "remoting", sao, true, false);
+
+ // obtain the server locator from the service itself, so we won't have any doubts we use
+ // the right one
+
+ serverLocator = new InvokerLocator((String)ServerManagement.
+ getAttribute(ServiceContainer.REMOTING_OBJECT_NAME, "InvokerLocator"));
+
+ // deploy a "lazy subsystem", that will delay invocations as long is it told to; used to
+ // simulate long running invocations
+
+ RemotingTestSubsystemService.
+ deployService("org.jboss.test.thirdparty.remoting.LazySubsystem");
+
+ log.debug("setup done");
+ }
+
+ protected void tearDown() throws Exception
+ {
+ serverLocator = null;
+
+ ServerManagement.stop();
+
+ super.tearDown();
+ }
+
+ // Private --------------------------------------------------------------------------------------
+
+ // Inner classes --------------------------------------------------------------------------------
+
+}
Property changes on: trunk/tests/src/org/jboss/test/thirdparty/remoting/ClientInvokerTimeoutTest.java
___________________________________________________________________
Name: svn:keywords
+ Id LastChangedDate Author Revision
Added: trunk/tests/src/org/jboss/test/thirdparty/remoting/LazySubsystem.java
===================================================================
--- trunk/tests/src/org/jboss/test/thirdparty/remoting/LazySubsystem.java (rev 0)
+++ trunk/tests/src/org/jboss/test/thirdparty/remoting/LazySubsystem.java 2007-01-30 07:35:13 UTC (rev 2104)
@@ -0,0 +1,88 @@
+/**
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.thirdparty.remoting;
+
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.test.thirdparty.remoting.util.TestableSubsystem;
+import org.jboss.logging.Logger;
+
+import javax.management.MBeanServer;
+
+/**
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public class LazySubsystem implements ServerInvocationHandler, TestableSubsystem
+{
+ // Constants ------------------------------------------------------------------------------------
+
+ private static final Logger log = Logger.getLogger(LazySubsystem.class);
+
+ // Static ---------------------------------------------------------------------------------------
+
+ // Attributes -----------------------------------------------------------------------------------
+
+ // Constructors ---------------------------------------------------------------------------------
+
+ public LazySubsystem()
+ {
+ }
+
+ // ServerInvocationHandler implementation -------------------------------------------------------
+
+ public void setMBeanServer(MBeanServer server)
+ {
+ }
+
+ public void setInvoker(ServerInvoker invoker)
+ {
+ }
+
+ public Object invoke(InvocationRequest invocation) throws Throwable
+ {
+ long sleepTime = ((Long)invocation.getParameter()).longValue();
+
+ log.debug("sleeping for " + (sleepTime / 1000) + " seconds ...");
+
+ Thread.sleep(sleepTime);
+
+ log.debug("woke up");
+
+ return null;
+ }
+
+ public void addListener(InvokerCallbackHandler callbackHandler)
+ {
+ }
+
+ public void removeListener(InvokerCallbackHandler callbackHandler)
+ {
+ }
+
+ // TestableSubsystem implementation ----------------------------------------------------------
+
+ public InvocationRequest getNextInvocation(long timeout) throws InterruptedException
+ {
+ return null;
+ }
+
+ // Public ---------------------------------------------------------------------------------------
+
+ // Package protected ----------------------------------------------------------------------------
+
+ // Protected ------------------------------------------------------------------------------------
+
+ // Private --------------------------------------------------------------------------------------
+
+ // Inner classes --------------------------------------------------------------------------------
+}
+
Property changes on: trunk/tests/src/org/jboss/test/thirdparty/remoting/LazySubsystem.java
___________________________________________________________________
Name: svn:keywords
+ Id LastChangedDate Author Revision
More information about the jboss-cvs-commits
mailing list