[jboss-cvs] JBoss Messaging SVN: r2010 - trunk/tests/src/org/jboss/test/thirdparty/remoting.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sat Jan 20 21:59:50 EST 2007
Author: ovidiu.feodorov at jboss.com
Date: 2007-01-20 21:59:49 -0500 (Sat, 20 Jan 2007)
New Revision: 2010
Added:
trunk/tests/src/org/jboss/test/thirdparty/remoting/RemotingConnectionFailureTest.java
Modified:
trunk/tests/src/org/jboss/test/thirdparty/remoting/PureAsynchronousCallTest.java
trunk/tests/src/org/jboss/test/thirdparty/remoting/RemotingTestSubsystemService.java
Log:
Extra remoting tests while investigating http://jira.jboss.org/jira/browse/JBMESSAGING-762
Modified: trunk/tests/src/org/jboss/test/thirdparty/remoting/PureAsynchronousCallTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/thirdparty/remoting/PureAsynchronousCallTest.java 2007-01-21 02:58:56 UTC (rev 2009)
+++ trunk/tests/src/org/jboss/test/thirdparty/remoting/PureAsynchronousCallTest.java 2007-01-21 02:59:49 UTC (rev 2010)
@@ -74,7 +74,8 @@
// make sure invocation reached the target subsystem
- InvocationRequest i = getNextInvocationFromServer(subsystemService, 2000);
+ InvocationRequest i =
+ RemotingTestSubsystemService.getNextInvocationFromServer(subsystemService, 2000);
assertNotNull(i);
assertEquals("blip", i.getParameter());
@@ -163,16 +164,6 @@
// Private --------------------------------------------------------------------------------------
- private InvocationRequest getNextInvocationFromServer(ObjectName on, long timeout)
- throws Exception
- {
- return (InvocationRequest)ServerManagement.
- invoke(on, "nextInvocation",
- new Object[] { new Long(timeout) },
- new String[] { "java.lang.Long" });
- }
-
-
// Inner classes --------------------------------------------------------------------------------
private class SimpleCallbackHandler implements InvokerCallbackHandler
Added: trunk/tests/src/org/jboss/test/thirdparty/remoting/RemotingConnectionFailureTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/thirdparty/remoting/RemotingConnectionFailureTest.java (rev 0)
+++ trunk/tests/src/org/jboss/test/thirdparty/remoting/RemotingConnectionFailureTest.java 2007-01-21 02:59:49 UTC (rev 2010)
@@ -0,0 +1,216 @@
+/**
+ * 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.remoting.InvokerLocator;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.CannotConnectException;
+import org.jboss.remoting.ConnectionListener;
+
+import javax.management.ObjectName;
+import java.io.IOException;
+
+import EDU.oswego.cs.dl.util.concurrent.Channel;
+import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
+
+/**
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public class RemotingConnectionFailureTest extends MessagingTestCase
+{
+ // Constants ------------------------------------------------------------------------------------
+
+ // Static ---------------------------------------------------------------------------------------
+
+ // Attributes -----------------------------------------------------------------------------------
+
+ private InvokerLocator serverLocator;
+ private ObjectName subsystemService;
+
+ // Constructors ---------------------------------------------------------------------------------
+
+ public RemotingConnectionFailureTest(String name)
+ {
+ super(name);
+ }
+
+ // Public ---------------------------------------------------------------------------------------
+
+ public void testDeadServerAfterPreviousInvocation() throws Throwable
+ {
+ if (!isRemote())
+ {
+ fail("This test should be run in a remote configuration!");
+ }
+
+ Client client = new Client(serverLocator, RemotingTestSubsystemService.SUBSYSTEM_LABEL);
+
+ client.connect();
+
+ client.invoke("blah");
+
+ assertEquals("blah", RemotingTestSubsystemService.
+ getNextInvocationFromServer(subsystemService, 2000).getParameter());
+
+ ServerManagement.kill(0);
+
+ // wait a bit for the server to go down
+
+ Thread.sleep(3000);
+
+ // send another invocation
+
+ try
+ {
+ client.invoke("bloh");
+ fail("This should have failed!");
+ }
+ catch(IOException e)
+ {
+ // if the client throws IOException, we're fine, this is our FailoverValveInteceptor is
+ // looking after
+ }
+ }
+
+ public void testDeadServerNoPreviousInvocation() throws Throwable
+ {
+ if (!isRemote())
+ {
+ fail("This test should be run in a remote configuration!");
+ }
+
+ Client client = new Client(serverLocator, RemotingTestSubsystemService.SUBSYSTEM_LABEL);
+
+ client.connect();
+
+ ServerManagement.kill(0);
+
+ // wait a bit for the server to go down
+
+ Thread.sleep(3000);
+
+ // send the first invocation
+
+ try
+ {
+ client.invoke("bleh");
+ fail("This should have failed!");
+ }
+ catch(CannotConnectException e)
+ {
+ // if the client throws CannotConnectException, we're fine, this is our
+ // FailoverValveInteceptor is looking after
+ }
+ }
+
+ public void testInvocationAfterDeathDetectedByPinger() throws Throwable
+ {
+ if (!isRemote())
+ {
+ fail("This test should be run in a remote configuration!");
+ }
+
+ Client client = new Client(serverLocator, RemotingTestSubsystemService.SUBSYSTEM_LABEL);
+
+ client.connect();
+
+ SimpleConnectionListener connListener = new SimpleConnectionListener();
+ client.addConnectionListener(connListener);
+
+ ServerManagement.kill(0);
+
+ long pingPeriod = client.getPingPeriod();
+
+ // wait for the failure to be detected
+
+ Throwable failure = connListener.getNextFailure(2 * pingPeriod);
+ assertNotNull(failure);
+
+ // the client is in a "broken" state, an invocation on it should fail
+
+ try
+ {
+ client.invoke("bluh");
+ fail("this should've failed!");
+ }
+ catch(CannotConnectException e)
+ {
+ // this is what a broken client is supposed to throw.
+ }
+ }
+
+ // Package protected ----------------------------------------------------------------------------
+
+ // Protected ------------------------------------------------------------------------------------
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ ServerManagement.start(0, "remoting", null, true, false);
+
+ String s = (String)ServerManagement.
+ getAttribute(ServiceContainer.REMOTING_OBJECT_NAME, "InvokerLocator");
+
+ serverLocator = new InvokerLocator(s);
+
+ // remote a server invocation handler
+
+ subsystemService = RemotingTestSubsystemService.deployService();
+
+ }
+
+ protected void tearDown() throws Exception
+ {
+ serverLocator = null;
+
+ if (ServerManagement.isStarted(0))
+ {
+ RemotingTestSubsystemService.undeployService(subsystemService);
+ ServerManagement.stop(0);
+ }
+
+ super.tearDown();
+ }
+
+ // Private --------------------------------------------------------------------------------------
+
+ // Inner classes --------------------------------------------------------------------------------
+
+ private class SimpleConnectionListener implements ConnectionListener
+ {
+ private Channel failures;
+
+ public SimpleConnectionListener()
+ {
+ failures = new LinkedQueue();
+ }
+
+ public void handleConnectionException(Throwable throwable, Client client)
+ {
+ try
+ {
+ failures.put(throwable);
+ }
+ catch(InterruptedException e)
+ {
+ throw new RuntimeException("Failed to record failure", e);
+ }
+ }
+
+ public Throwable getNextFailure(long timeout) throws InterruptedException
+ {
+ return (Throwable)failures.poll(timeout);
+ }
+ }
+}
Property changes on: trunk/tests/src/org/jboss/test/thirdparty/remoting/RemotingConnectionFailureTest.java
___________________________________________________________________
Name: svn:keywords
+ Id LastChangedDate Author Revision
Modified: trunk/tests/src/org/jboss/test/thirdparty/remoting/RemotingTestSubsystemService.java
===================================================================
--- trunk/tests/src/org/jboss/test/thirdparty/remoting/RemotingTestSubsystemService.java 2007-01-21 02:58:56 UTC (rev 2009)
+++ trunk/tests/src/org/jboss/test/thirdparty/remoting/RemotingTestSubsystemService.java 2007-01-21 02:59:49 UTC (rev 2010)
@@ -53,6 +53,15 @@
ServerManagement.undeploy(on);
}
+ public static InvocationRequest getNextInvocationFromServer(ObjectName on, long timeout)
+ throws Exception
+ {
+ return (InvocationRequest)ServerManagement.
+ invoke(on, "nextInvocation",
+ new Object[] { new Long(timeout) },
+ new String[] { "java.lang.Long" });
+ }
+
// Attributes -----------------------------------------------------------------------------------
private MBeanServer mbeanServer;
More information about the jboss-cvs-commits
mailing list