[jboss-cvs] JBoss Messaging SVN: r2089 - in trunk/tests/src/org/jboss/test: thirdparty/remoting and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Jan 29 09:01:29 EST 2007


Author: timfox
Date: 2007-01-29 09:01:29 -0500 (Mon, 29 Jan 2007)
New Revision: 2089

Added:
   trunk/tests/src/org/jboss/test/thirdparty/remoting/SocketTransportCausalityTest.java
Modified:
   trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java
   trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystem.java
   trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemService.java
   trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemServiceMBean.java
Log:
http://jira.jboss.com/jira/browse/JBMESSAGING-789



Modified: trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java	2007-01-29 13:11:20 UTC (rev 2088)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java	2007-01-29 14:01:29 UTC (rev 2089)
@@ -1271,7 +1271,8 @@
                       "serverSocketClass=org.jboss.jms.server.remoting.ServerSocketWrapper&" +
                       "NumberOfRetries=1&" +
                       "NumberOfCallRetries=2&" +
-                      "callbackErrorsAllowed=1";
+                      "callbackErrorsAllowed=1&" +
+                      "onewayThreadPool=org.jboss.jms.server.remoting.DirectThreadPool";
 
       // specific parameters per transport
 

Added: trunk/tests/src/org/jboss/test/thirdparty/remoting/SocketTransportCausalityTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/thirdparty/remoting/SocketTransportCausalityTest.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/test/thirdparty/remoting/SocketTransportCausalityTest.java	2007-01-29 14:01:29 UTC (rev 2089)
@@ -0,0 +1,221 @@
+/**
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.thirdparty.remoting;
+
+import java.io.Serializable;
+
+import javax.management.ObjectName;
+
+import org.jboss.logging.Logger;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvokerLocator;
+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.thirdparty.remoting.util.RemotingTestSubsystemService;
+
+/**
+ * 
+ * A SocketTransportCausalityTest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class SocketTransportCausalityTest extends MessagingTestCase
+{
+   // Constants ------------------------------------------------------------------------------------
+
+   private static final Logger log = Logger.getLogger(SocketTransportCausalityTest.class);
+
+   // Static ---------------------------------------------------------------------------------------
+
+   // Attributes -----------------------------------------------------------------------------------
+
+   private InvokerLocator serverLocator;
+
+   // Constructors ---------------------------------------------------------------------------------
+
+   public SocketTransportCausalityTest(String name)
+   {
+      super(name);
+   }
+
+   // Public ---------------------------------------------------------------------------------------
+
+   //Note!!! before this test is really valid we need to configure the server side to
+   //use the DirectThreadPool!!
+   public void testOneWayCallsOutOfSequence() throws Throwable
+   {
+      if (!isRemote())
+      {
+         fail("This test should be run in a remote configuration!");
+      }
+ 
+      final int NUM_THREADS = 4;
+      
+      final int NUM_INVOCATIONS = 1000;
+      
+      Sender[] threads = new Sender[NUM_THREADS];
+      
+      ObjectName subsystemService = null;
+      
+      try
+      {
+         subsystemService = RemotingTestSubsystemService.deployService();
+
+         for (int i = 0; i < NUM_THREADS; i++)
+         {
+            Client client = new Client(serverLocator, RemotingTestSubsystemService.SUBSYSTEM_LABEL);
+
+            client.connect();
+            
+            Sender sender = new Sender(NUM_INVOCATIONS, client, i);
+            
+            threads[i] = sender;
+         }
+         
+         for (int i = 0; i < NUM_THREADS; i++)
+         {            
+            threads[i].start();
+         }
+         
+         for (int i = 0; i < NUM_THREADS; i++)
+         {            
+            threads[i].join();
+         }
+         
+         for (int i = 0; i < NUM_THREADS; i++)
+         {            
+            if (threads[i].err != null)
+            {
+               throw threads[i].err;
+            }
+         }
+         
+         boolean failed = 
+            RemotingTestSubsystemService.isFailed(subsystemService);
+         
+         if (failed)
+         {
+            fail("Invocations received out of sequence");
+         }
+          
+      }
+      finally
+      {
+         for (int i = 0; i < NUM_THREADS; i++)
+         {
+            threads[i].join(10000);
+         }
+
+         RemotingTestSubsystemService.undeployService(subsystemService);
+      }
+   }
+
+   private static class Sender extends Thread
+   {
+      int numInvocations;
+      
+      Client client;
+      
+      Throwable err;
+      
+      int num;
+      
+      int clientNumber;
+      
+      Sender(int numInvocations, Client client, int clientNumber)
+      {
+         this.numInvocations = numInvocations;
+         
+         this.client = client;
+         
+         this.clientNumber = clientNumber;
+      }
+      
+      public void run()
+      {
+         try
+         {
+            for (int i = 0; i < this.numInvocations; i++)
+            {
+               SimpleInvocation inv = new SimpleInvocation();
+               
+               inv.clientNumber = clientNumber;
+               
+               inv.num = ++num;
+               
+               client.invokeOneway(inv);
+            }
+         }
+         catch (Throwable t)
+         {
+            err = t;
+         }
+         finally
+         {
+            try
+            {
+               client.disconnect();
+            }
+            catch (Throwable ignore)
+            {               
+            }
+         }
+      }
+      
+   }
+   
+   public static class SimpleInvocation implements Serializable
+   {
+      public int clientNumber;
+      
+      public int num;
+   }
+
+
+   // 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");
+      
+      s += "&onewayThreadPool=org.jboss.jms.server.remoting.DirectThreadPool";
+
+      log.info("Locator is " + s);
+      
+      serverLocator = new InvokerLocator(s);
+      
+      log.debug("setup done");
+   }
+
+   protected void tearDown() throws Exception
+   {
+      serverLocator = null;
+
+      ServerManagement.stop();
+
+      super.tearDown();
+   }
+
+   // Private --------------------------------------------------------------------------------------
+
+   // Inner classes --------------------------------------------------------------------------------
+
+
+}
+

Modified: trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystem.java
===================================================================
--- trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystem.java	2007-01-29 13:11:20 UTC (rev 2088)
+++ trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystem.java	2007-01-29 14:01:29 UTC (rev 2089)
@@ -12,6 +12,7 @@
 import org.jboss.remoting.callback.InvokerCallbackHandler;
 import org.jboss.remoting.callback.Callback;
 import org.jboss.remoting.callback.ServerInvokerCallbackHandler;
+import org.jboss.test.thirdparty.remoting.SocketTransportCausalityTest;
 import org.jboss.logging.Logger;
 
 import javax.management.MBeanServer;
@@ -58,6 +59,10 @@
 
    private Channel invocationHistory;
    private List callbackListeners;
+   
+   private int[] counters = new int[10];
+   
+   private boolean failed;
 
    // Constructors ---------------------------------------------------------------------------------
 
@@ -90,6 +95,35 @@
          log.debug(this + " ignoring invocation");
          return null;
       }
+      
+      if (parameter instanceof SocketTransportCausalityTest.SimpleInvocation)
+      {
+         SocketTransportCausalityTest.SimpleInvocation inv = (SocketTransportCausalityTest.SimpleInvocation)parameter;
+         
+         synchronized (this)
+         {            
+            int clientNum = inv.clientNumber;
+            
+            int lastCount = this.counters[clientNum];
+            
+            if (inv.num != lastCount + 1)
+            {
+               //Failed - out of sequence
+               failed = true;
+               
+               log.info("Failed!!!! out of sequence");
+            }
+            else
+            {
+               log.info("Ok");
+            }
+            
+            counters[clientNum] = inv.num;
+            
+            return null;
+         }
+         
+      }
 
       invocationHistory.put(dirtyCopy(invocation));
 
@@ -155,6 +189,14 @@
    {
       return (InvocationRequest)invocationHistory.poll(timeout);
    }
+   
+   public boolean isFailed()
+   {
+      synchronized (this)
+      {
+         return failed;
+      }
+   }
 
    // Package protected ----------------------------------------------------------------------------
 

Modified: trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemService.java
===================================================================
--- trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemService.java	2007-01-29 13:11:20 UTC (rev 2088)
+++ trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemService.java	2007-01-29 14:01:29 UTC (rev 2089)
@@ -61,6 +61,13 @@
                 new Object[] { new Long(timeout) },
                 new String[] { "java.lang.Long" });
    }
+   
+   public static boolean isFailed(ObjectName on)
+      throws Exception
+   {
+      return ((Boolean)ServerManagement.
+         invoke(on, "isFailed", null, null)).booleanValue();
+   }
 
    // Attributes -----------------------------------------------------------------------------------
 
@@ -143,6 +150,11 @@
       return delegate.getNextInvocation(timeout.longValue());
 
    }
+   
+   public boolean isFailed() throws Exception
+   {
+      return delegate.isFailed();
+   }
 
    // Public ---------------------------------------------------------------------------------------
 

Modified: trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemServiceMBean.java
===================================================================
--- trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemServiceMBean.java	2007-01-29 13:11:20 UTC (rev 2088)
+++ trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemServiceMBean.java	2007-01-29 14:01:29 UTC (rev 2089)
@@ -19,4 +19,6 @@
    void stop();
 
    InvocationRequest nextInvocation(Long timeout) throws Exception;
+   
+   boolean isFailed() throws Exception;
 }




More information about the jboss-cvs-commits mailing list