Author: fjuma
Date: 2009-05-25 11:43:11 -0400 (Mon, 25 May 2009)
New Revision: 480
Added:
trunk/jsfunit/testdata/datasources/testFiles/ListStatisticsClosingConnectionsExistingFile-ds.xml
trunk/jsfunit/testdata/datasources/testFiles/ListStatisticsMultipleConnectionsExistingFile-ds.xml
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DatasourceTestBase.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/datasources/DatasourceOperationsTest.java
Log:
Adding tests for the "List Statistics" operation for datasources.
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DatasourceTestBase.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DatasourceTestBase.java 2009-05-22
19:37:42 UTC (rev 479)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DatasourceTestBase.java 2009-05-25
15:43:11 UTC (rev 480)
@@ -419,6 +419,7 @@
propertiesMap.put("min-pool-size", "5");
propertiesMap.put("user-name", "sa");
propertiesMap.put("password", "");
+ propertiesMap.put("securityDeploymentType", "DOMAIN");
propertiesMap.put("domain", "HsqlDbRealm");
propertiesMap.put("blocking-timeout-millis", "35000");
propertiesMap.put("idle-timeout-minutes", "20");
@@ -444,13 +445,14 @@
Map<String, String> propertiesMap = new HashMap<String, String>();
propertiesMap.put("jndi-name", datasourceName);
propertiesMap.put("prefill", "true");
- propertiesMap.put("track-connection-by-tx", "true");
+ propertiesMap.put("track-connection-by-tx", "false");
propertiesMap.put("max-pool-size", "20");
propertiesMap.put("min-pool-size", "5");
propertiesMap.put("blocking-timeout-millis", "55000");
propertiesMap.put("idle-timeout-minutes", "60");
propertiesMap.put("user-name", "sa");
propertiesMap.put("password", "");
+ propertiesMap.put("securityDeploymentType", "DOMAIN");
propertiesMap.put("domain", "HsqlDbRealm");
propertiesMap.put("driver-class", "org.hsqldb.jdbcDriver");
propertiesMap.put("connection-url",
"jdbc:hsqldb:${jboss.server.data.dir}${/}hypersonic${/}localDB");
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/datasources/DatasourceOperationsTest.java
===================================================================
---
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/datasources/DatasourceOperationsTest.java 2009-05-22
19:37:42 UTC (rev 479)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/datasources/DatasourceOperationsTest.java 2009-05-25
15:43:11 UTC (rev 480)
@@ -31,6 +31,7 @@
import java.sql.Connection;
import org.jboss.jopr.jsfunit.exceptions.EmbJoprTestException;
import java.io.IOException;
+import org.jboss.managed.api.ComponentType;
/**
* This class contains operations tests for datasources.
@@ -40,6 +41,8 @@
*/
public class DatasourceOperationsTest extends DatasourceTest {
+ /* FLUSH OPERATION */
+
/**
* Test the "Flush" operation after creating a new datasource.
*/
@@ -128,6 +131,8 @@
deleteDatasource(propertiesMap.get("jndi-name"),
DatasourceType.LOCAL_TX_DATASOURCE);
}
+ /* LIST FORMATTED SUB POOL STATISTICS OPERATION */
+
/**
* Test the "List Formatted Sub Pool Statistics" after creating a new
* datasource.
@@ -301,7 +306,195 @@
}
}
+ /* LIST STATISTICS OPERATION */
+
/**
+ * Test Name: testListStatisticsAfterCreation
+ * Assertion: Verify that the results are correct after executing
+ * the "List Statistics" operation on a newly created datasource.
+ */
+ public void testDatasourceListStatisticsAfterCreation() throws Exception {
+ String jndiName = "ListStatisticsAfterDatasourceCreationDS";
+
+ // Min pool size will be 5, max pool size will be 20
+ createNoTXDatasource(jndiName);
+
+ // Set up the expectedStatistics
+ Map<String, String> expectedStatistics =
formatListStatisticsResults(jndiName,
+
NO_TX_COMPONENT_TYPE,
+
listStatisticsProps);
+
+ // Additional statistics that need to be checked
+ expectedStatistics.put("criteria", "ByContainer");
+ expectedStatistics.put("name",
"jboss.jca:service=ManagedConnectionFactory,name="
+ + jndiName);
+ expectedStatistics.put("subPoolCount", "0");
+ expectedStatistics.put("totalConnectionsInUseCount", "0");
+ expectedStatistics.put("totalMaxConnectionsInUseCount",
"0");
+
+ performResourceOperationAndCheckTable(DS_NAV_LABEL,
DatasourceType.NO_TX_DATASOURCE.getLabel(),
+ jndiName, LIST_STATISTICS, Boolean.FALSE,
+ expectedStatistics);
+
+ deleteDatasource(jndiName, DatasourceType.NO_TX_DATASOURCE);
+ }
+
+ /**
+ * Test Name: testListStatisticsAfterMultipleConnections
+ * Assertion: Verify that the results are correct after executing
+ * the "List Statistics" operation for a datasource when there are
+ * multiple connections.
+ */
+ public void testDatasourceListStatisticsAfterMultipleConnections() throws Exception
{
+ String jndiName = "ListStatisticsAfterMultipleConnectionsDS";
+
+ // Min pool size will be 5, max pool size will be 20
+ Map<String, String> propertiesMap = createLocalTXDatasource(jndiName);
+
+ performListStatisticsAfterMultipleConnections(jndiName,
DatasourceType.LOCAL_TX_DATASOURCE,
+ LOCAL_TX_COMPONENT_TYPE,
propertiesMap);
+ }
+
+ /**
+ * Test Name: testListStatisticsAfterMultipleConnectionsUsingExistingDSFile
+ * Assertion: Verify that the results are correct after executing
+ * the "List Statistics" operation for a datasource when there are
+ * multiple connections. Use an existing -ds.xml file.
+ */
+ public void testDatasourceListStatisticsAfterMultipleConnectionsUsingExistingDSFile()
throws Exception {
+ String jndiName = "ListStatisticsMultipleConnectionsExistingFile";
+
+ // Use an existing datasource
+ Map<String, String> propertiesMap = getPropertyValuesMap(jndiName,
+
DatasourceType.LOCAL_TX_DATASOURCE);
+
+ expandNavTreeArrow(DS_NAV_LABEL);
+
+ performListStatisticsAfterMultipleConnections(jndiName,
DatasourceType.LOCAL_TX_DATASOURCE,
+ LOCAL_TX_COMPONENT_TYPE,
propertiesMap);
+ }
+
+ /**
+ * Common code for the
+ * testListStatisticsAfterMultipleConnections* tests.
+ */
+ private void performListStatisticsAfterMultipleConnections(String jndiName,
+ DatasourceType
datasourceType,
+ ComponentType
componentType,
+ Map<String, String>
propertiesMap) throws Exception {
+
+ // Create some connections
+ ArrayList<Connection> connections = createConnections(6,
propertiesMap.get("jndi-name"),
+
propertiesMap.get("user-name"),
+
propertiesMap.get("password"));
+
+ try {
+
+ // Set up the expected statistics
+ Map<String, String> expectedStatistics =
formatListStatisticsResults(jndiName,
+
componentType,
+
listStatisticsProps);
+
+ // Additional statistics that need to be checked
+ expectedStatistics.put("criteria", "ByContainer");
+ expectedStatistics.put("name",
"jboss.jca:service=ManagedConnectionFactory,name="
+ + jndiName);
+ expectedStatistics.put("subPoolCount", "1");
+ expectedStatistics.put("totalConnectionsInUseCount",
"6");
+ expectedStatistics.put("totalMaxConnectionsInUseCount",
"6");
+
+ performResourceOperationAndCheckTable(DS_NAV_LABEL,
datasourceType.getLabel(), jndiName,
+ LIST_STATISTICS, Boolean.FALSE,
expectedStatistics);
+ } finally {
+
+ // Clean up
+ closeConnections(connections);
+ deleteDatasource(jndiName, DatasourceType.LOCAL_TX_DATASOURCE);
+ }
+ }
+
+ /**
+ * Test Name: testListStatisticsAfterClosingConnections
+ * Assertion: Verify that the results are correct after executing
+ * the "List Statistics" operation for a datasource after
+ * requesting multiple connections and then closing some of them.
+ */
+ public void testDatasourceListStatisticsAfterClosingConnections() throws Exception {
+ String jndiName = "ListStatisticsAfterClosingConnectionsDS";
+
+ // Min pool size will be 5, max pool size will be 20
+ Map<String, String> propertiesMap = createNoTXDatasource(jndiName);
+
+ performListStatisticsAfterClosingConnections(jndiName,
DatasourceType.NO_TX_DATASOURCE,
+ NO_TX_COMPONENT_TYPE,
propertiesMap);
+ }
+
+ /**
+ * Test Name: testListStatisticsAfterClosingConnectionsUsingExistingDSFile
+ * Assertion: Verify that the results are correct after executing
+ * the "List Statistics" operation for a datasource after
+ * requesting multiple connections and then closing some of them. Use an
+ * existing -ds.xml file.
+ */
+ public void testDatasourceListStatisticsAfterClosingConnectionsUsingExistingDSFile()
throws Exception {
+ String jndiName = "ListStatisticsClosingConnectionsExistingFile";
+
+ // Use an existing datasource
+ Map<String, String> propertiesMap = getPropertyValuesMap(jndiName,
+
DatasourceType.NO_TX_DATASOURCE);
+
+ expandNavTreeArrow(DS_NAV_LABEL);
+
+ performListStatisticsAfterClosingConnections(jndiName,
DatasourceType.NO_TX_DATASOURCE,
+ NO_TX_COMPONENT_TYPE,
propertiesMap);
+ }
+
+ /**
+ * Common code for the
+ * testListStatisticsAfterClosingConnections* tests.
+ */
+ private void performListStatisticsAfterClosingConnections(String jndiName,
+ DatasourceType
datasourceType,
+ ComponentType
componentType,
+ Map<String, String>
propertiesMap) throws Exception {
+
+ // Create some connections
+ ArrayList<Connection> connections = createConnections(10,
propertiesMap.get("jndi-name"),
+
propertiesMap.get("user-name"),
+
propertiesMap.get("password"));
+
+ try {
+
+ // Close some connections
+ for(int i = 0; i < 2; i++) {
+ disconnectDB(connections.get(i));
+ connections.set(i, null);
+ }
+
+ // Set up the expectedStatistics
+ Map<String, String> expectedStatistics =
formatListStatisticsResults(jndiName,
+
componentType,
+
listStatisticsProps);
+
+ // Additional statistics that need to be checked
+ expectedStatistics.put("criteria", "ByContainer");
+ expectedStatistics.put("name",
"jboss.jca:service=ManagedConnectionFactory,name="
+ + jndiName);
+ expectedStatistics.put("subPoolCount", "1");
+ expectedStatistics.put("totalConnectionsInUseCount",
"8");
+ expectedStatistics.put("totalMaxConnectionsInUseCount",
"10");
+
+ performResourceOperationAndCheckTable(DS_NAV_LABEL,
datasourceType.getLabel(), jndiName,
+ LIST_STATISTICS, Boolean.FALSE,
expectedStatistics);
+ } finally {
+
+ // Clean up
+ closeConnections(connections);
+ deleteDatasource(propertiesMap.get("jndi-name"),
DatasourceType.NO_TX_DATASOURCE);
+ }
+ }
+
+ /**
* @return the suite of tests being tested
*/
public static Test suite() {
Added:
trunk/jsfunit/testdata/datasources/testFiles/ListStatisticsClosingConnectionsExistingFile-ds.xml
===================================================================
---
trunk/jsfunit/testdata/datasources/testFiles/ListStatisticsClosingConnectionsExistingFile-ds.xml
(rev 0)
+++
trunk/jsfunit/testdata/datasources/testFiles/ListStatisticsClosingConnectionsExistingFile-ds.xml 2009-05-25
15:43:11 UTC (rev 480)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
+<datasources>
+ <no-tx-datasource>
+ <jndi-name>ListStatisticsClosingConnectionsExistingFile</jndi-name>
+ <rar-name>jboss-local-jdbc.rar</rar-name>
+ <use-java-context>true</use-java-context>
+ <connection-definition>javax.sql.DataSource</connection-definition>
+ <jmx-invoker-name>jboss:service=invoker,type=jrmp</jmx-invoker-name>
+ <min-pool-size>5</min-pool-size>
+ <max-pool-size>20</max-pool-size>
+ <blocking-timeout-millis>55000</blocking-timeout-millis>
+ <idle-timeout-minutes>60</idle-timeout-minutes>
+ <prefill>true</prefill>
+ <background-validation>false</background-validation>
+ <background-validation-millis>0</background-validation-millis>
+ <validate-on-match>true</validate-on-match>
+
<statistics-formatter>org.jboss.resource.statistic.pool.JBossDefaultSubPoolStatisticFormatter</statistics-formatter>
+ <isSameRM-override-value>false</isSameRM-override-value>
+ <interleaving/>
+ <allocation-retry>0</allocation-retry>
+ <allocation-retry-wait-millis>5000</allocation-retry-wait-millis>
+ <security-domain xsi:type="securityMetaData"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">HsqlDb...
+ <metadata>
+ <type-mapping>FirstSQL/J</type-mapping>
+ </metadata>
+ <user-name>sa</user-name>
+ <password></password>
+ <prepared-statement-cache-size>0</prepared-statement-cache-size>
+ <share-prepared-statements>false</share-prepared-statements>
+ <set-tx-query-timeout>false</set-tx-query-timeout>
+ <query-timeout>0</query-timeout>
+ <use-try-lock>60000</use-try-lock>
+ <driver-class>org.hsqldb.jdbcDriver</driver-class>
+
<connection-url>jdbc:hsqldb:${jboss.server.data.dir}${/}hypersonic${/}localDB</connection-url>
+ </no-tx-datasource>
+</datasources>
Added:
trunk/jsfunit/testdata/datasources/testFiles/ListStatisticsMultipleConnectionsExistingFile-ds.xml
===================================================================
---
trunk/jsfunit/testdata/datasources/testFiles/ListStatisticsMultipleConnectionsExistingFile-ds.xml
(rev 0)
+++
trunk/jsfunit/testdata/datasources/testFiles/ListStatisticsMultipleConnectionsExistingFile-ds.xml 2009-05-25
15:43:11 UTC (rev 480)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
+<datasources>
+ <local-tx-datasource>
+ <jndi-name>ListStatisticsMultipleConnectionsExistingFile</jndi-name>
+ <rar-name>jboss-local-jdbc.rar</rar-name>
+ <use-java-context>true</use-java-context>
+ <connection-definition>javax.sql.DataSource</connection-definition>
+ <jmx-invoker-name>jboss:service=invoker,type=jrmp</jmx-invoker-name>
+ <min-pool-size>5</min-pool-size>
+ <max-pool-size>20</max-pool-size>
+ <blocking-timeout-millis>35000</blocking-timeout-millis>
+ <idle-timeout-minutes>20</idle-timeout-minutes>
+ <prefill>false</prefill>
+ <background-validation>false</background-validation>
+ <background-validation-millis>0</background-validation-millis>
+ <validate-on-match>true</validate-on-match>
+
<statistics-formatter>org.jboss.resource.statistic.pool.JBossDefaultSubPoolStatisticFormatter</statistics-formatter>
+ <isSameRM-override-value>false</isSameRM-override-value>
+ <allocation-retry>0</allocation-retry>
+ <allocation-retry-wait-millis>5000</allocation-retry-wait-millis>
+ <security-domain xsi:type="securityMetaData"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">HsqlDb...
+ <metadata>
+ <type-mapping>FirstSQL/J</type-mapping>
+ </metadata>
+ <local-transaction/>
+ <user-name>sa</user-name>
+ <password></password>
+ <prepared-statement-cache-size>0</prepared-statement-cache-size>
+ <share-prepared-statements>false</share-prepared-statements>
+ <set-tx-query-timeout>false</set-tx-query-timeout>
+ <query-timeout>0</query-timeout>
+ <use-try-lock>60000</use-try-lock>
+ <driver-class>org.hsqldb.jdbcDriver</driver-class>
+
<connection-url>jdbc:hsqldb:${jboss.server.data.dir}${/}hypersonic${/}localDB</connection-url>
+ </local-tx-datasource>
+</datasources>