[jboss-cvs] JBossAS SVN: r111377 - projects/jboss-jca/trunk/rhq/src/test/java/org/jboss/jca/rhq/test.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon May 16 01:03:53 EDT 2011
Author: gaol
Date: 2011-05-16 01:03:52 -0400 (Mon, 16 May 2011)
New Revision: 111377
Modified:
projects/jboss-jca/trunk/rhq/src/test/java/org/jboss/jca/rhq/test/DsTestCase.java
Log:
[JBJCA-561] improve test case on Pool.flush(boolean kill)
Modified: projects/jboss-jca/trunk/rhq/src/test/java/org/jboss/jca/rhq/test/DsTestCase.java
===================================================================
--- projects/jboss-jca/trunk/rhq/src/test/java/org/jboss/jca/rhq/test/DsTestCase.java 2011-05-13 15:46:34 UTC (rev 111376)
+++ projects/jboss-jca/trunk/rhq/src/test/java/org/jboss/jca/rhq/test/DsTestCase.java 2011-05-16 05:03:52 UTC (rev 111377)
@@ -41,7 +41,6 @@
import org.junit.AfterClass;
import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Test;
import org.rhq.core.domain.configuration.Configuration;
@@ -249,9 +248,9 @@
Configuration config = result.getComplexResults();
assertEquals("true", config.getSimpleValue("result", null));
}
-
+
/**
- * test DataSource Pool.flush()
+ * test DataSource Pool.flush(boolean kill)
*
* @throws Throwable exception
*/
@@ -260,22 +259,9 @@
{
DataSource ds = getDataSource();
Pool pool = ds.getPool();
- pool.flush();
- // just not thrown exception for now.
- }
-
- /**
- * test DataSource Pool.flush(true)
- *
- * @throws Throwable exception
- */
- @Test
- public void testDsPoolFlushKill() throws Throwable
- {
- DataSource ds = getDataSource();
- Pool pool = ds.getPool();
// set prefill to false
+ boolean oldPrefill = ds.getPoolConfiguration().isPrefill();
ds.getPoolConfiguration().setPrefill(false);
PoolStatistics poolStatistics = pool.getStatistics();
@@ -283,14 +269,27 @@
javax.sql.DataSource sqlDS = (javax.sql.DataSource)context.lookup(ds.getJndiName());
Connection conn = sqlDS.getConnection();
- assertEquals(1, poolStatistics.getActiveCount());
+ assertTrue(poolStatistics.getActiveCount() >= 1);
pool.flush(true); // it flushes all connections from the pool.
assertEquals(0, poolStatistics.getActiveCount());
+ assertEquals(0, poolStatistics.getCreatedCount());
+ assertEquals(ds.getPoolConfiguration().getMaxSize(), poolStatistics.getAvailableCount());
conn.close();
- // just not thrown exception for now.
+
+ conn = sqlDS.getConnection();
+ pool.flush(); // only flushes idle connections
+ assertTrue(poolStatistics.getActiveCount() >= 1);
+ assertTrue(poolStatistics.getCreatedCount() >= 1);
+
+ conn.close();
+ pool.flush(); // conn is closed, so it will be released.
+ assertTrue(poolStatistics.getActiveCount() >= 0);
+ assertTrue(poolStatistics.getCreatedCount() >= 0);
+
+ ds.getPoolConfiguration().setPrefill(oldPrefill);
}
More information about the jboss-cvs-commits
mailing list