[jboss-cvs] JBossAS SVN: r61819 - in branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/consumer: unit and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Mar 28 20:53:22 EDT 2007


Author: bdecoste
Date: 2007-03-28 20:53:22 -0400 (Wed, 28 Mar 2007)
New Revision: 61819

Modified:
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/consumer/DeploymentDescriptorQueueTest.java
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/consumer/DeploymentDescriptorQueueTestConsumer.java
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/consumer/DeploymentDescriptorQueueTestRemote.java
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/consumer/unit/ConsumerUnitTestCase.java
Log:
closed connection leak in test

Modified: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/consumer/DeploymentDescriptorQueueTest.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/consumer/DeploymentDescriptorQueueTest.java	2007-03-28 23:50:14 UTC (rev 61818)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/consumer/DeploymentDescriptorQueueTest.java	2007-03-29 00:53:22 UTC (rev 61819)
@@ -21,9 +21,6 @@
  */
 package org.jboss.ejb3.test.consumer;
 
-import org.jboss.annotation.ejb.MessageProperties;
-import org.jboss.annotation.ejb.DeliveryMode;
-
 /**
  * @version <tt>$Revision$</tt>
  * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>

Modified: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/consumer/DeploymentDescriptorQueueTestConsumer.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/consumer/DeploymentDescriptorQueueTestConsumer.java	2007-03-28 23:50:14 UTC (rev 61818)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/consumer/DeploymentDescriptorQueueTestConsumer.java	2007-03-29 00:53:22 UTC (rev 61819)
@@ -64,7 +64,8 @@
    {
       stateless.test();
       statelessLocal.testLocal();
-      testDatasource.getConnection();
+      java.sql.Connection connection = testDatasource.getConnection();
+      connection.close();
       
       Context initCtx = new InitialContext();
       Context myEnv = (Context) initCtx.lookup(Container.ENC_CTX_NAME + "/env");
@@ -86,6 +87,13 @@
 
    public void method2(String msg, float num)
    {
+ /*     try 
+      {
+         Thread.sleep(1000);
+      } 
+      catch (Exception e)
+      {
+      }*/
       TestStatusBean.queueRan = "method2";
 
       TestStatusBean.fieldMessage = currentMessage != null;

Modified: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/consumer/DeploymentDescriptorQueueTestRemote.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/consumer/DeploymentDescriptorQueueTestRemote.java	2007-03-28 23:50:14 UTC (rev 61818)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/consumer/DeploymentDescriptorQueueTestRemote.java	2007-03-29 00:53:22 UTC (rev 61819)
@@ -21,17 +21,11 @@
  */
 package org.jboss.ejb3.test.consumer;
 
-import org.jboss.annotation.ejb.DeliveryMode;
-import org.jboss.annotation.ejb.MessageProperties;
-import org.jboss.annotation.ejb.Producer;
-
 /**
  * @version <tt>$Revision$</tt>
  * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
  */
-public interface DeploymentDescriptorQueueTestRemote
+public interface DeploymentDescriptorQueueTestRemote extends DeploymentDescriptorQueueTest
 {
-   void method1(String msg, int num) throws Exception;
-
-   void method2(String msg, float num);
+ 
 }

Modified: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/consumer/unit/ConsumerUnitTestCase.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/consumer/unit/ConsumerUnitTestCase.java	2007-03-28 23:50:14 UTC (rev 61818)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/consumer/unit/ConsumerUnitTestCase.java	2007-03-29 00:53:22 UTC (rev 61819)
@@ -21,6 +21,11 @@
  */
 package org.jboss.ejb3.test.consumer.unit;
 
+import java.util.Map;
+
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+
 import org.jboss.ejb3.mdb.ProducerManager;
 import org.jboss.ejb3.mdb.ProducerObject;
 import org.jboss.ejb3.test.consumer.QueueTestRemote;
@@ -83,6 +88,8 @@
 
       //TODO: Figure out how to test preDestroy gets invoked
       //assertTrue(status.preDestroy());
+      
+      checkForConnectionLeaks();
    }
 
    public void testQueueXA() throws Exception
@@ -94,6 +101,8 @@
       Thread.sleep(1000);
       assertEquals(status.queueFired(), "method2");
       assertEquals(status.interceptedQueue(), "method2");
+      
+      checkForConnectionLeaks();
    }
 
    public void testQueueLocal() throws Exception
@@ -105,6 +114,8 @@
       Thread.sleep(1000);
       assertEquals(status.queueFired(), "method2");
       assertEquals(status.interceptedQueue(), "method2");
+      
+      checkForConnectionLeaks();
    }
    
    public void testDeploymentDescriptorQueue() throws Exception
@@ -139,6 +150,8 @@
 
       //TODO: Figure out how to test preDestroy gets invoked
       //assertTrue(status.preDestroy());
+      
+      checkForConnectionLeaks();
    }
    
    public void testDeploymentDescriptorQueueXA() throws Exception
@@ -150,6 +163,8 @@
       Thread.sleep(1000);
       assertEquals(status.queueFired(), "method2");
       assertEquals(status.interceptedQueue(), "method2");
+      
+      checkForConnectionLeaks();
    }
 
    public void testDeploymentDescriptorQueueLocal() throws Exception
@@ -161,7 +176,40 @@
       Thread.sleep(1000);
       assertEquals(status.queueFired(), "method2");
       assertEquals(status.interceptedQueue(), "method2");
+      
+      checkForConnectionLeaks();
    }
+   
+   protected void checkForConnectionLeaks() throws Exception
+   {
+      MBeanServerConnection server = getServer();
+      ObjectName objectName = new ObjectName("jboss.jca:service=CachedConnectionManager");
+      int inUseConnections = (Integer)server.getAttribute(objectName, "InUseConnections");
+      System.out.println("inUseConnections \n" + inUseConnections);
+      if(inUseConnections != 0)
+         printStats(server);
+      assertEquals("CachedConnectionManager.InUseConnections", 0, inUseConnections);
+   }
+   
+   protected void printStats(MBeanServerConnection server) throws Exception
+   {
+      ObjectName objectName = new ObjectName("jboss.jca:service=CachedConnectionManager");
+      Object[] params = {};
+      String[] sig = {};
+      Map result = (Map)server.invoke(objectName, "listInUseConnections", params, sig);
+      System.out.println(result);
+      
+      objectName = new ObjectName("jboss:service=TransactionManager");
+      long activeTransactions = (Long)server.getAttribute(objectName, "TransactionCount");
+      System.out.println("activeTransactions \n" + activeTransactions);
+      
+      objectName = new ObjectName("jboss.jca:service=ManagedConnectionPool,name=DefaultDS");
+      long inUseConnectionCount = (Long)server.getAttribute(objectName, "InUseConnectionCount");
+      System.out.println("inUseConnectionCount \n" + inUseConnectionCount);
+      
+      long maxConnectionsInUseCount = (Long)server.getAttribute(objectName, "MaxConnectionsInUseCount");
+      System.out.println("maxConnectionsInUseCount \n" + maxConnectionsInUseCount); 
+   }
 
    public static Test suite() throws Exception
    {




More information about the jboss-cvs-commits mailing list