[jboss-cvs] JBossAS SVN: r85699 - in trunk/testsuite/src/main/org/jboss/test/jca: test and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Mar 10 15:28:03 EDT 2009


Author: jesper.pedersen
Date: 2009-03-10 15:28:03 -0400 (Tue, 10 Mar 2009)
New Revision: 85699

Added:
   trunk/testsuite/src/main/org/jboss/test/jca/test/RetryableResourceUnitTestCase.java
Modified:
   trunk/testsuite/src/main/org/jboss/test/jca/support/PoolHelper.java
   trunk/testsuite/src/main/org/jboss/test/jca/test/StatisticsReporterUnitTestCase.java
Log:
[JBAS-5929] Sub Pooling in JBossManagedConnectionPool MemoryLeak for sparse CRI coverage

Modified: trunk/testsuite/src/main/org/jboss/test/jca/support/PoolHelper.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/jca/support/PoolHelper.java	2009-03-10 19:27:41 UTC (rev 85698)
+++ trunk/testsuite/src/main/org/jboss/test/jca/support/PoolHelper.java	2009-03-10 19:28:03 UTC (rev 85699)
@@ -295,25 +295,25 @@
       if (type.equals(PoolType.ONE_POOL))
       {
 
-         mcp = new JBossManagedConnectionPool.OnePool(mcf, pp, noTxnSeperatePool, log);
+         mcp = new JBossManagedConnectionPool.OnePool(mcf, pp, noTxnSeperatePool, null, log);
 
       }
       else if (type.equals(PoolType.CRI_POOL))
       {
 
-         mcp = new JBossManagedConnectionPool.PoolByCri(mcf, pp, noTxnSeperatePool, log);
+         mcp = new JBossManagedConnectionPool.PoolByCri(mcf, pp, noTxnSeperatePool, null, log);
 
       }
       else if (type.equals(PoolType.SUB_POOL))
       {
 
-         mcp = new JBossManagedConnectionPool.PoolBySubject(mcf, pp, noTxnSeperatePool, log);
+         mcp = new JBossManagedConnectionPool.PoolBySubject(mcf, pp, noTxnSeperatePool, null, log);
 
       }
       else if (type.equals(PoolType.SUB_CRI_POOL))
       {
 
-         mcp = new JBossManagedConnectionPool.PoolBySubjectAndCri(mcf, pp, noTxnSeperatePool, log);
+         mcp = new JBossManagedConnectionPool.PoolBySubjectAndCri(mcf, pp, noTxnSeperatePool, null, log);
 
       }
 

Added: trunk/testsuite/src/main/org/jboss/test/jca/test/RetryableResourceUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/jca/test/RetryableResourceUnitTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/jca/test/RetryableResourceUnitTestCase.java	2009-03-10 19:28:03 UTC (rev 85699)
@@ -0,0 +1,123 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jca.test;
+
+import javax.resource.spi.ManagedConnectionFactory;
+
+import junit.framework.TestCase;
+
+import org.jboss.logging.Logger;
+import org.jboss.resource.connectionmanager.BaseConnectionManager2;
+import org.jboss.resource.connectionmanager.CachedConnectionManager;
+import org.jboss.resource.connectionmanager.ConnectionListener;
+import org.jboss.resource.connectionmanager.InternalManagedConnectionPool;
+import org.jboss.resource.connectionmanager.JBossManagedConnectionPool;
+import org.jboss.resource.connectionmanager.ManagedConnectionPool;
+import org.jboss.resource.connectionmanager.NoTxConnectionManager;
+import org.jboss.resource.connectionmanager.JBossManagedConnectionPool.BasePool;
+import org.jboss.test.jca.adapter.TestManagedConnectionFactory;
+
+/**
+ * Unit test for the RetryableResourceException
+ *
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class RetryableResourceUnitTestCase extends TestCase
+{
+   private Logger log = Logger.getLogger(getClass());
+
+   private CachedConnectionManager ccm = new CachedConnectionManager();
+
+   /**
+    * Creates a new <code>RetryableResourceUnitTestCase</code> instance.
+    * @param name test name
+    */
+   public RetryableResourceUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   /**
+    * Get a BaseConnectionManager2 object with an OnePool connection pool
+    * @param pp The pool parameters
+    * @return BaseConnectionManager2 instance
+    * @exception Exception Thrown if an error occurs
+    */
+   private BaseConnectionManager2 getCM(InternalManagedConnectionPool.PoolParams pp) throws Exception
+   {
+      ManagedConnectionFactory mcf = new TestManagedConnectionFactory();
+      ManagedConnectionPool poolingStrategy = new JBossManagedConnectionPool.OnePool(mcf, pp, false, log);
+      BaseConnectionManager2 cm = new NoTxConnectionManager(ccm, poolingStrategy);
+      poolingStrategy.setConnectionListenerFactory(cm);
+      
+      if (pp.prefill)
+      {
+         BasePool bp = (BasePool)poolingStrategy;
+         bp.prefill(null, null, false);
+      }
+      
+      return cm;
+   }
+
+   /**
+    * Shutdown the BaseConnectionManager2
+    * @param cm The instance
+    */
+   private void shutdown(BaseConnectionManager2 cm)
+   {
+      ManagedConnectionPool pool = cm.getPoolingStrategy();
+      pool.shutdown();
+   }
+
+   
+   public void testHashCodes() throws Exception
+   {
+      InternalManagedConnectionPool.PoolParams pp = new InternalManagedConnectionPool.PoolParams();
+      pp.minSize = 0;
+      pp.maxSize = 5;
+      pp.blockingTimeout = 100;
+      pp.idleTimeout = 500;
+
+      BaseConnectionManager2 cm = getCM(pp);
+      try
+      {
+         // Get a connection
+         ConnectionListener cl = cm.getManagedConnection(null, null);
+         assertTrue("1: Got a null connection!", cl.getManagedConnection() != null);
+         assertTrue("1: InternalManagedConnectionPool", cl.getContext() instanceof InternalManagedConnectionPool);
+         InternalManagedConnectionPool imcp = (InternalManagedConnectionPool)cl.getContext();
+         cm.returnManagedConnection(cl, true);
+
+         // Shutdown the pool in order to trigger the RetryableResourceException
+         imcp.shutdown();
+
+         // Get a connection - new internal managed pool is created
+         cl = cm.getManagedConnection(null, null);
+         assertTrue("2: Got a null connection!", cl.getManagedConnection() != null);
+         cm.returnManagedConnection(cl, true);
+      }
+      finally
+      {
+         shutdown(cm);
+      }
+   }
+}

Modified: trunk/testsuite/src/main/org/jboss/test/jca/test/StatisticsReporterUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/jca/test/StatisticsReporterUnitTestCase.java	2009-03-10 19:27:41 UTC (rev 85698)
+++ trunk/testsuite/src/main/org/jboss/test/jca/test/StatisticsReporterUnitTestCase.java	2009-03-10 19:28:03 UTC (rev 85699)
@@ -73,7 +73,7 @@
    private BaseConnectionManager2 getCriCM(InternalManagedConnectionPool.PoolParams pp){
       
       ManagedConnectionFactory mcf = new TestManagedConnectionFactory();
-      ManagedConnectionPool poolingStrategy = new JBossManagedConnectionPool.PoolByCri(mcf, pp, true, log);
+      ManagedConnectionPool poolingStrategy = new JBossManagedConnectionPool.PoolByCri(mcf, pp, true, null, log);
       BaseConnectionManager2 cm = new NoTxConnectionManager(ccm, poolingStrategy);
       poolingStrategy.setConnectionListenerFactory(cm);
       return cm;




More information about the jboss-cvs-commits mailing list