[jboss-remoting-commits] JBoss Remoting SVN: r4977 - remoting2/branches/2.x/src/tests/org/jboss/test/remoting/invoker.

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Sun Apr 12 21:49:39 EDT 2009


Author: ron.sigal at jboss.com
Date: 2009-04-12 21:49:38 -0400 (Sun, 12 Apr 2009)
New Revision: 4977

Modified:
   remoting2/branches/2.x/src/tests/org/jboss/test/remoting/invoker/ClientInvokerDelayedDestructionTestCase.java
Log:
JBREM-1083: Added testStaticTimer().

Modified: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/invoker/ClientInvokerDelayedDestructionTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/invoker/ClientInvokerDelayedDestructionTestCase.java	2009-04-13 01:39:51 UTC (rev 4976)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/invoker/ClientInvokerDelayedDestructionTestCase.java	2009-04-13 01:49:38 UTC (rev 4977)
@@ -21,9 +21,11 @@
 */
 package org.jboss.test.remoting.invoker;
 
+import java.lang.reflect.Field;
 import java.net.InetAddress;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Timer;
 
 import javax.management.MBeanServer;
 
@@ -33,7 +35,6 @@
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
 import org.apache.log4j.PatternLayout;
-import org.jboss.logging.XLevel;
 import org.jboss.remoting.Client;
 import org.jboss.remoting.InvocationRequest;
 import org.jboss.remoting.InvokerLocator;
@@ -76,7 +77,7 @@
       if (firstTime)
       {
          firstTime = false;
-         Logger.getLogger("org.jboss.remoting").setLevel(XLevel.INFO);
+         Logger.getLogger("org.jboss.remoting").setLevel(Level.INFO);
          Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
          String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
          PatternLayout layout = new PatternLayout(pattern);
@@ -262,6 +263,49 @@
    }
    
    
+   public void testStaticTimer() throws Throwable
+   {
+      log.info("entering " + getName());
+      
+      // Start server.
+      setupServer();
+      
+      
+      // Get static Timer.
+      Field field = Client.class.getDeclaredField("invokerDestructionTimer");
+      field.setAccessible(true);
+      Timer invokerDestructionTimer = (Timer) field.get(null);
+      
+      // Create client.
+      InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+      HashMap clientConfig = new HashMap();
+      clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+      clientConfig.put(Client.INVOKER_DESTRUCTION_DELAY, "5000");
+      addExtraClientConfig(clientConfig);
+      Client[] clients = new Client[50];
+
+      for (int i = 0; i < 50; i++)
+      {
+         clients[i] = new Client(clientLocator, clientConfig);
+         clients[i].connect();
+         assertEquals("abc", clients[i].invoke("abc"));
+         clients[i].disconnect();
+      }
+      
+      // Verify all Clients are using the same Timer.
+      for (int i = 0; i < 50; i++)
+      {
+         assertEquals("Should be the same Timer", invokerDestructionTimer, field.get(clients[i]));
+      }
+      
+      Thread.sleep(10000);
+      assertEquals(0, InvokerRegistry.getClientInvokers().length);
+
+      shutdownServer();
+      log.info(getName() + " PASSES");
+   }
+   
+   
    protected String getTransport()
    {
       return "socket";




More information about the jboss-remoting-commits mailing list