[jboss-cvs] JBoss Messaging SVN: r3094 - in trunk: tests/src/org/jboss/test/messaging/jms/clustering and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Sep 10 22:16:32 EDT 2007


Author: clebert.suconic at jboss.com
Date: 2007-09-10 22:16:32 -0400 (Mon, 10 Sep 2007)
New Revision: 3094

Added:
   trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteredClientCrashTest.java
Modified:
   trunk/src/main/org/jboss/jms/client/delegate/ClientClusteredConnectionFactoryDelegate.java
   trunk/tests/src/org/jboss/test/messaging/jms/crash/CreateClientOnServerCommand.java
   trunk/tests/src/org/jboss/test/messaging/jms/crash/CreateHangingConsumerCommand.java
   trunk/tests/src/org/jboss/test/messaging/jms/crash/CreateTwoClientOnServerCommand.java
   trunk/tests/src/org/jboss/test/messaging/tools/container/Command.java
   trunk/tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java
Log:
http://jira.jboss.org/jira/browse/JBMESSAGING-1054

Modified: trunk/src/main/org/jboss/jms/client/delegate/ClientClusteredConnectionFactoryDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/ClientClusteredConnectionFactoryDelegate.java	2007-09-10 22:36:25 UTC (rev 3093)
+++ trunk/src/main/org/jboss/jms/client/delegate/ClientClusteredConnectionFactoryDelegate.java	2007-09-11 02:16:32 UTC (rev 3094)
@@ -153,7 +153,7 @@
       remoting.getRemotingClient().invoke(request, null);
    }
 
-   protected void finalize() throws Throwable
+   public void finalize() throws Throwable
    {
       super.finalize();
       closeCallback();

Added: trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteredClientCrashTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteredClientCrashTest.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteredClientCrashTest.java	2007-09-11 02:16:32 UTC (rev 3094)
@@ -0,0 +1,179 @@
+/*
+   * 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.clustering;
+
+import org.jboss.logging.Logger;
+import org.jboss.test.messaging.tools.container.Server;
+import org.jboss.test.messaging.tools.container.LocalTestServer;
+import org.jboss.test.messaging.tools.container.InVMInitialContextFactory;
+import org.jboss.test.messaging.tools.container.ServiceContainer;
+import org.jboss.test.messaging.tools.container.Command;
+import org.jboss.test.messaging.tools.ServerManagement;
+import org.jboss.test.messaging.jms.crash.CreateClientOnServerCommand;
+import org.jboss.test.messaging.jms.crash.CreateTwoClientOnServerCommand;
+import org.jboss.test.messaging.MessagingTestCase;
+import org.jboss.jms.server.ConnectionManager;
+import org.jboss.jms.server.connectionmanager.SimpleConnectionManager;
+import org.jboss.jms.client.delegate.ClientClusteredConnectionFactoryDelegate;
+import javax.naming.InitialContext;
+import javax.jms.ConnectionFactory;
+import javax.jms.Queue;
+import javax.jms.Topic;
+import javax.jms.Connection;
+import javax.jms.Message;
+import java.lang.ref.WeakReference;
+
+/**
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ * @version <tt>$Revision$</tt>
+ *          $Id$
+ */
+public class ClusteredClientCrashTest extends ClusteringTestBase
+{
+   // Constants -----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   private static final Logger log = Logger.getLogger(ClusteredClientCrashTest.class);
+
+   // Attributes ----------------------------------------------------
+
+   protected Server localServer;
+
+   //protected Server remoteServer;
+
+   // Constructors --------------------------------------------------
+
+   public ClusteredClientCrashTest(String name)
+   {
+      super(name);
+   }
+
+   // Public --------------------------------------------------------
+
+   public void setUp() throws Exception
+   {
+      nodeCount = 2;
+      super.setUp();
+
+   }
+
+   public void tearDown() throws Exception
+   {
+      super.tearDown();
+   }
+
+   /**
+    * Test that when a remote jms client crashes, server side resources for connections are
+    * cleaned-up.
+    */
+   public void testClientCrash() throws Exception
+   {
+      ServerManagement.create(2);
+      Server remoteServer = ServerManagement.getServer(2);
+
+      // We need to make sure that any previously downloaded CF should be released
+      WeakReference ref = new WeakReference(ic[0].lookup("/ClusteredConnectionFactory"));
+      int count=0;
+      while (ref.get() != null)
+      {
+         System.gc();
+         Thread.sleep(1000);
+         if ((count++>10) && ref.get() != null)
+         {
+            fail("Thre is a leak on ClusteredConnectionFactory");
+         }
+      }
+
+
+      ClientClusteredConnectionFactoryDelegate cfDelegate =  (ClientClusteredConnectionFactoryDelegate)cf.getDelegate();
+
+      cfDelegate.closeCallback();
+
+      ClusterClientCrash command = new ClusterClientCrash(cf);
+
+      assertEquals("OK", remoteServer.executeCommand(command));
+
+      assertEquals("1",ServerManagement.getServer(1).executeCommand(new VerifySizeOfCFClients(cfDelegate.getUniqueName())));
+
+      ServerManagement.kill(2);
+      Thread.sleep(30000);
+
+      assertEquals("0",ServerManagement.getServer(0).executeCommand(new VerifySizeOfCFClients(cfDelegate.getUniqueName())));
+      assertEquals("0",ServerManagement.getServer(1).executeCommand(new VerifySizeOfCFClients(cfDelegate.getUniqueName())));
+
+
+      //localServer.setAttribute(ServiceContainer.REMOTING_OBJECT_NAME, "LeasePeriod", "2000");
+
+      //performCrash(8000, false);
+   }
+
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+
+   // Inner classes -------------------------------------------------
+
+   public static class ClusterClientCrash implements Command
+   {
+
+      ConnectionFactory cf = null;
+
+      public ClusterClientCrash(ConnectionFactory cf)
+      {
+         this.cf = cf;
+      }
+
+      public Object execute(Server server) throws Exception
+      {
+         Connection conn = cf.createConnection();
+         conn.start();
+
+         return "OK";
+      }
+   }
+
+   public static class VerifySizeOfCFClients implements Command
+   {
+
+      String uniqueName;
+
+      public VerifySizeOfCFClients(String uniqueName)
+      {
+         this.uniqueName = uniqueName;
+      }
+
+      public Object execute(Server server) throws Exception
+      {
+
+         int size = server.getServerPeer().getConnectionManager().getConnectionFactoryCallback(uniqueName).length;
+
+         return Integer.toString(size);
+      }
+   }
+
+}


Property changes on: trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteredClientCrashTest.java
___________________________________________________________________
Name: svn:keywords
   + Id LastChangedDate Author Revision

Modified: trunk/tests/src/org/jboss/test/messaging/jms/crash/CreateClientOnServerCommand.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/crash/CreateClientOnServerCommand.java	2007-09-10 22:36:25 UTC (rev 3093)
+++ trunk/tests/src/org/jboss/test/messaging/jms/crash/CreateClientOnServerCommand.java	2007-09-11 02:16:32 UTC (rev 3094)
@@ -33,6 +33,7 @@
 
 import org.jboss.jms.client.JBossConnection;
 import org.jboss.test.messaging.tools.container.Command;
+import org.jboss.test.messaging.tools.container.Server;
 
 /**
  * 
@@ -67,7 +68,7 @@
    /*
     * Just create a connection, send and receive a message and leave the connection open.
     */
-   public Object execute() throws Exception
+   public Object execute(Server server) throws Exception
    {
       if (retainReference)
       {

Modified: trunk/tests/src/org/jboss/test/messaging/jms/crash/CreateHangingConsumerCommand.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/crash/CreateHangingConsumerCommand.java	2007-09-10 22:36:25 UTC (rev 3093)
+++ trunk/tests/src/org/jboss/test/messaging/jms/crash/CreateHangingConsumerCommand.java	2007-09-11 02:16:32 UTC (rev 3094)
@@ -31,6 +31,7 @@
 
 import org.jboss.jms.client.JBossConnection;
 import org.jboss.test.messaging.tools.container.Command;
+import org.jboss.test.messaging.tools.container.Server;
 
 /**
  * @author <a href="tim.fox at jboss.com">Tim Fox</a>
@@ -51,7 +52,7 @@
       this.queue = queue;
    }
    
-   public Object execute() throws Exception
+   public Object execute(Server server) throws Exception
    {
       Connection conn = cf.createConnection();
           

Modified: trunk/tests/src/org/jboss/test/messaging/jms/crash/CreateTwoClientOnServerCommand.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/crash/CreateTwoClientOnServerCommand.java	2007-09-10 22:36:25 UTC (rev 3093)
+++ trunk/tests/src/org/jboss/test/messaging/jms/crash/CreateTwoClientOnServerCommand.java	2007-09-11 02:16:32 UTC (rev 3094)
@@ -30,6 +30,7 @@
 
 import org.jboss.jms.client.JBossConnection;
 import org.jboss.test.messaging.tools.container.Command;
+import org.jboss.test.messaging.tools.container.Server;
 
 /**
  * 
@@ -66,7 +67,7 @@
    /*
     * Just create a connection, send and receive a message and leave the connection open.
     */
-   public Object execute() throws Exception
+   public Object execute(Server server) throws Exception
    {
       if (retainReference)
       {

Modified: trunk/tests/src/org/jboss/test/messaging/tools/container/Command.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/Command.java	2007-09-10 22:36:25 UTC (rev 3093)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/Command.java	2007-09-11 02:16:32 UTC (rev 3094)
@@ -36,5 +36,11 @@
  */
 public interface Command extends Serializable
 {
-   public Object execute() throws Exception;
+   /**
+    *
+    * @param server The server where this command is being executed at
+    * @return
+    * @throws Exception
+    */
+   public Object execute(Server server) throws Exception;
 }

Modified: trunk/tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java	2007-09-10 22:36:25 UTC (rev 3093)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java	2007-09-11 02:16:32 UTC (rev 3094)
@@ -837,7 +837,7 @@
 
    public Object executeCommand(Command command) throws Exception
    {
-      return command.execute();
+      return command.execute(this);
    }
 
    public UserTransaction getUserTransaction() throws Exception




More information about the jboss-cvs-commits mailing list