Author: fjuma
Date: 2009-03-10 16:08:00 -0400 (Tue, 10 Mar 2009)
New Revision: 200
Added:
trunk/jsfunit/testdata/datasources/testFiles/MetricsCloseConnectionsExistingFile-ds.xml
trunk/jsfunit/testdata/datasources/testFiles/MetricsInitialConnectionExistingFile-ds.xml
trunk/jsfunit/testdata/datasources/testFiles/MetricsMultipleConnectionsExistingFile-ds.xml
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DatasourceTestBase.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/DatasourceTest.java
Log:
Moved the datasource metrics tests from DatasourceTestBase.java to
as5/DatasourceTest.java.
Added datasource metrics tests that use an existing -ds.xml file.
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DatasourceTestBase.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DatasourceTestBase.java 2009-03-10
19:09:32 UTC (rev 199)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DatasourceTestBase.java 2009-03-10
20:08:00 UTC (rev 200)
@@ -792,138 +792,5 @@
+ "'DefaultDS' already exists";
checkClientAndServerMessages(expectedMessage, expectedMessage, true);
}
-
- /*
- * METRICS TESTS
- */
-
- /**
- * Check that the metrics are correct after creating a new datasource.
- */
- public void testMetricsAfterDatasourceCreation() throws IOException,
EmbJoprTestException {
-
- // Min pool size will be 5, max pool size will be 20
- Map<String, String> propertiesMap =
createLocalTXDatasource("MetricsCreateDS");
-
- // Set up the expected values
- Map<String, String> expectedMetrics = new HashMap<String, String>();
- expectedMetrics.put("Available Connection Count", "20.0");
- expectedMetrics.put("Connection Count", "0.0");
- expectedMetrics.put("Connection Created Count", "0.0");
- expectedMetrics.put("Connection Destroyed Count", "0.0");
- expectedMetrics.put("In Use Connection Count", "0.0");
- expectedMetrics.put("Max Connections In Use Count", "0.0");
- expectedMetrics.put("Max Size", "20.0");
- expectedMetrics.put("Min Size", "5.0");
-
- checkMetrics(propertiesMap.get("jndi-name"),
DatasourceType.LOCAL_TX_DATASOURCE, expectedMetrics);
-
- // Clean up
- deleteDatasource(propertiesMap.get("jndi-name"));
- }
-
- /**
- * Make an initial request for a connection to a database. Make
- * sure the metrics are updated accordingly.
- */
- public void testMetricsAfterInitialDBConnection() throws Exception {
-
- // Min pool size will be 5, max pool size will be 20
- Map<String, String> propertiesMap =
createLocalTXDatasource("MetricsInitalConnectionDS");
-
- // Create the first connection
- Connection con = connectDB(propertiesMap.get("jndi-name"),
- propertiesMap.get("user-name"),
- propertiesMap.get("password"));
- assertNotNull(con);
-
- // Set up the expected values
- Map<String, String> expectedMetrics = new HashMap<String, String>();
- expectedMetrics.put("Available Connection Count", "19.0");
- expectedMetrics.put("Connection Count", "5.0");
- expectedMetrics.put("Connection Created Count", "5.0");
- expectedMetrics.put("Connection Destroyed Count", "0.0");
- expectedMetrics.put("In Use Connection Count", "1.0");
- expectedMetrics.put("Max Connections In Use Count", "1.0");
- expectedMetrics.put("Max Size", "20.0");
- expectedMetrics.put("Min Size", "5.0");
-
- checkMetrics(propertiesMap.get("jndi-name"),
DatasourceType.LOCAL_TX_DATASOURCE, expectedMetrics);
-
- // Clean up
- disconnectDB(con);
- deleteDatasource(propertiesMap.get("jndi-name"));
- }
-
- /**
- * Establish multiple connections to a database. Make sure
- * the metrics are updated accordingly.
- */
- public void testMetricsAfterMultipleDBConnections() throws Exception {
-
- // Min pool size will be 5, max pool size will be 20
- Map<String, String> propertiesMap =
createNoTXDatasource("MetricsMultipleConnectionDS");
-
- // Establish multiple connections
- ArrayList<Connection> connections = createConnections(6,
propertiesMap.get("jndi-name"),
-
propertiesMap.get("user-name"),
-
propertiesMap.get("password"));
-
- // Set up the expected values
- Map<String, String> expectedMetrics = new HashMap<String, String>();
- expectedMetrics.put("Available Connection Count", "14.0");
- expectedMetrics.put("Connection Count", "6.0");
- expectedMetrics.put("Connection Created Count", "6.0");
- expectedMetrics.put("Connection Destroyed Count", "0.0");
- expectedMetrics.put("In Use Connection Count", "6.0");
- expectedMetrics.put("Max Connections In Use Count", "6.0");
- expectedMetrics.put("Max Size", "20.0");
- expectedMetrics.put("Min Size", "5.0");
-
- checkMetrics(propertiesMap.get("jndi-name"),
DatasourceType.NO_TX_DATASOURCE, expectedMetrics);
-
- // Clean up
- closeConnections(connections);
- deleteDatasource(propertiesMap.get("jndi-name"));
- }
-
- /**
- * Make sure the metrics are updated appropriately after
- * closing some connections.
- */
- public void testMetricsAfterClosingConnections() throws Exception {
-
- // Min pool size will be 5, max pool size will be 20
- Map<String, String> propertiesMap =
createNoTXDatasource("MetricsCloseConnectionsDS");
-
- // Establish some connections
- ArrayList<Connection> connections = createConnections(5,
propertiesMap.get("jndi-name"),
-
propertiesMap.get("user-name"),
-
propertiesMap.get("password"));
-
- // Close some connections
- disconnectDB(connections.get(0));
- disconnectDB(connections.get(1));
-
- // Set up the expected values
- Map<String, String> expectedMetrics = new HashMap<String, String>();
- expectedMetrics.put("Available Connection Count", "17.0");
- expectedMetrics.put("Connection Count", "3.0");
- expectedMetrics.put("Connection Created Count", "5.0");
- expectedMetrics.put("Connection Destroyed Count", "0.0");
- expectedMetrics.put("In Use Connection Count", "3.0");
- expectedMetrics.put("Max Connections In Use Count", "5.0");
- expectedMetrics.put("Max Size", "20.0");
- expectedMetrics.put("Min Size", "5.0");
-
- checkMetrics(propertiesMap.get("jndi-name"),
DatasourceType.NO_TX_DATASOURCE, expectedMetrics);
-
- // Clean up
- for(int i = 2; i <= 4; i++) {
- disconnectDB(connections.get(i));
- }
-
- deleteDatasource(propertiesMap.get("jndi-name"));
- }
}
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/DatasourceTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/DatasourceTest.java 2009-03-10
19:09:32 UTC (rev 199)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/DatasourceTest.java 2009-03-10
20:08:00 UTC (rev 200)
@@ -711,5 +711,213 @@
deleteDatasource(propertiesMap.get("jndi-name"));
}
+
+ /*
+ * METRICS TESTS
+ */
+
+ /**
+ * Check that the metrics are correct after creating a new datasource.
+ */
+ public void testMetricsAfterDatasourceCreation() throws IOException,
EmbJoprTestException {
+
+ // Min pool size will be 5, max pool size will be 20
+ Map<String, String> propertiesMap =
createLocalTXDatasource("MetricsCreateDS");
+
+ // Set up the expected values
+ Map<String, String> expectedMetrics = new HashMap<String, String>();
+ expectedMetrics.put("Available Connection Count", "20.0");
+ expectedMetrics.put("Connection Count", "0.0");
+ expectedMetrics.put("Connection Created Count", "0.0");
+ expectedMetrics.put("Connection Destroyed Count", "0.0");
+ expectedMetrics.put("In Use Connection Count", "0.0");
+ expectedMetrics.put("Max Connections In Use Count", "0.0");
+ expectedMetrics.put("Max Size", "20.0");
+ expectedMetrics.put("Min Size", "5.0");
+
+ checkMetrics(propertiesMap.get("jndi-name"),
DatasourceType.LOCAL_TX_DATASOURCE, expectedMetrics);
+
+ // Clean up
+ deleteDatasource(propertiesMap.get("jndi-name"));
+ }
+
+ /**
+ * Make an initial request for a connection to a database. Make
+ * sure the metrics are updated accordingly.
+ */
+ public void testMetricsAfterInitialDBConnection() throws Exception {
+
+ // Create the datasource
+ Map<String, String> propertiesMap =
createLocalTXDatasource("MetricsInitalConnectionDS");
+
+ // Min pool size will be 5, max pool size will be 20
+ checkMetricsAfterInitialDBConnection(propertiesMap);
+ }
+
+ /**
+ * Make an initial request for a connection to a database. Use an
+ * existing datasource. Make sure the metrics are updated accordingly.
+ */
+ public void testMetricsAfterInitialDBConnectionUsingExistingDSFile() throws Exception
{
+
+ // Use an existing datasource
+ Map<String, String> propertiesMap =
getPropertyValuesMap("MetricsInitialConnectionExistingFile",
+
DatasourceType.LOCAL_TX_DATASOURCE);
+
+ expandNavTreeArrow("Datasources");
+
+ // Min pool size will be 5, max pool size will be 20
+ checkMetricsAfterInitialDBConnection(propertiesMap);
+ }
+
+ /**
+ * Common code for the testMetricsAfterInitialDBConnection* tests.
+ */
+ public void checkMetricsAfterInitialDBConnection(Map<String, String>
propertiesMap) throws Exception {
+
+ // Create the first connection
+ Connection con = connectDB(propertiesMap.get("jndi-name"),
+ propertiesMap.get("user-name"),
+ propertiesMap.get("password"));
+ assertNotNull(con);
+
+ // Set up the expected values
+ Map<String, String> expectedMetrics = new HashMap<String, String>();
+ expectedMetrics.put("Available Connection Count", "19.0");
+ expectedMetrics.put("Connection Count", "5.0");
+ expectedMetrics.put("Connection Created Count", "5.0");
+ expectedMetrics.put("Connection Destroyed Count", "0.0");
+ expectedMetrics.put("In Use Connection Count", "1.0");
+ expectedMetrics.put("Max Connections In Use Count", "1.0");
+ expectedMetrics.put("Max Size", "20.0");
+ expectedMetrics.put("Min Size", "5.0");
+
+ checkMetrics(propertiesMap.get("jndi-name"),
DatasourceType.LOCAL_TX_DATASOURCE, expectedMetrics);
+
+ // Clean up
+ disconnectDB(con);
+ deleteDatasource(propertiesMap.get("jndi-name"));
+ }
+
+ /**
+ * Establish multiple connections to a database. Make sure
+ * the metrics are updated accordingly.
+ */
+ public void testMetricsAfterMultipleDBConnections() throws Exception {
+
+ // Create the datasource
+ Map<String, String> propertiesMap =
createNoTXDatasource("MetricsMultipleConnectionDS");
+
+ // Min pool size will be 5, max pool size will be 20
+ checkMetricsAfterMultipleDBConnections(propertiesMap);
+ }
+
+ /**
+ * Establish multiple connections to a database. Use an existing
+ * datasource. Make sure the metrics are updated accordingly.
+ */
+ public void testMetricsAfterMultipleDBConnectionsUsingExistingDSFile() throws
Exception {
+
+ // Use an existing datasource
+ Map<String, String> propertiesMap =
getPropertyValuesMap("MetricsMultipleConnectionsExistingFile",
+
DatasourceType.NO_TX_DATASOURCE);
+
+ expandNavTreeArrow("Datasources");
+
+ // Min pool size will be 5, max pool size will be 20
+ checkMetricsAfterMultipleDBConnections(propertiesMap);
+ }
+
+ /**
+ * Common code for the testMetricsAfterMultipleDBConnections* tests.
+ */
+ public void checkMetricsAfterMultipleDBConnections(Map<String, String>
propertiesMap) throws Exception {
+
+ // Establish multiple connections
+ ArrayList<Connection> connections = createConnections(6,
propertiesMap.get("jndi-name"),
+
propertiesMap.get("user-name"),
+
propertiesMap.get("password"));
+
+ // Set up the expected values
+ Map<String, String> expectedMetrics = new HashMap<String, String>();
+ expectedMetrics.put("Available Connection Count", "14.0");
+ expectedMetrics.put("Connection Count", "6.0");
+ expectedMetrics.put("Connection Created Count", "6.0");
+ expectedMetrics.put("Connection Destroyed Count", "0.0");
+ expectedMetrics.put("In Use Connection Count", "6.0");
+ expectedMetrics.put("Max Connections In Use Count", "6.0");
+ expectedMetrics.put("Max Size", "20.0");
+ expectedMetrics.put("Min Size", "5.0");
+
+ checkMetrics(propertiesMap.get("jndi-name"),
DatasourceType.NO_TX_DATASOURCE, expectedMetrics);
+
+ // Clean up
+ closeConnections(connections);
+ deleteDatasource(propertiesMap.get("jndi-name"));
+ }
+
+ /**
+ * Make sure the metrics are updated appropriately after
+ * closing some connections.
+ */
+ public void testMetricsAfterClosingConnections() throws Exception {
+
+ // Create the datasource
+ Map<String, String> propertiesMap =
createNoTXDatasource("MetricsCloseConnectionsDS");
+
+ // Min pool size will be 5, max pool size will be 20
+ checkMetricsAfterClosingConnections(propertiesMap);
+ }
+
+ /**
+ * Make sure the metrics are updated appropriately after
+ * closing some connections. Use an existing datasource.
+ */
+ public void testMetricsAfterClosingConnectionsUsingExistingDSFile() throws Exception
{
+
+ // Use an existing datasource
+ Map<String, String> propertiesMap =
getPropertyValuesMap("MetricsCloseConnectionsExistingFile",
+
DatasourceType.NO_TX_DATASOURCE);
+
+ expandNavTreeArrow("Datasources");
+
+ // Min pool size will be 5, max pool size will be 20
+ checkMetricsAfterClosingConnections(propertiesMap);
+ }
+
+ /**
+ * Common code for the testMetricsAfterClosingConnections* tests.
+ */
+ public void checkMetricsAfterClosingConnections(Map<String, String>
propertiesMap) throws Exception {
+
+ // Establish some connections
+ ArrayList<Connection> connections = createConnections(5,
propertiesMap.get("jndi-name"),
+
propertiesMap.get("user-name"),
+
propertiesMap.get("password"));
+
+ // Close some connections
+ disconnectDB(connections.get(0));
+ disconnectDB(connections.get(1));
+
+ // Set up the expected values
+ Map<String, String> expectedMetrics = new HashMap<String, String>();
+ expectedMetrics.put("Available Connection Count", "17.0");
+ expectedMetrics.put("Connection Count", "3.0");
+ expectedMetrics.put("Connection Created Count", "5.0");
+ expectedMetrics.put("Connection Destroyed Count", "0.0");
+ expectedMetrics.put("In Use Connection Count", "3.0");
+ expectedMetrics.put("Max Connections In Use Count", "5.0");
+ expectedMetrics.put("Max Size", "20.0");
+ expectedMetrics.put("Min Size", "5.0");
+
+ checkMetrics(propertiesMap.get("jndi-name"),
DatasourceType.NO_TX_DATASOURCE, expectedMetrics);
+
+ // Clean up
+ for(int i = 2; i <= 4; i++) {
+ disconnectDB(connections.get(i));
+ }
+
+ deleteDatasource(propertiesMap.get("jndi-name"));
+ }
}
Added:
trunk/jsfunit/testdata/datasources/testFiles/MetricsCloseConnectionsExistingFile-ds.xml
===================================================================
---
trunk/jsfunit/testdata/datasources/testFiles/MetricsCloseConnectionsExistingFile-ds.xml
(rev 0)
+++
trunk/jsfunit/testdata/datasources/testFiles/MetricsCloseConnectionsExistingFile-ds.xml 2009-03-10
20:08:00 UTC (rev 200)
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
+<datasources>
+ <no-tx-datasource>
+ <jndi-name>MetricsCloseConnectionsExistingFile</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>
+ <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/MetricsInitialConnectionExistingFile-ds.xml
===================================================================
---
trunk/jsfunit/testdata/datasources/testFiles/MetricsInitialConnectionExistingFile-ds.xml
(rev 0)
+++
trunk/jsfunit/testdata/datasources/testFiles/MetricsInitialConnectionExistingFile-ds.xml 2009-03-10
20:08:00 UTC (rev 200)
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
+<datasources>
+ <local-tx-datasource>
+ <jndi-name>MetricsInitialConnectionExistingFile</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>
+ <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>
Added:
trunk/jsfunit/testdata/datasources/testFiles/MetricsMultipleConnectionsExistingFile-ds.xml
===================================================================
---
trunk/jsfunit/testdata/datasources/testFiles/MetricsMultipleConnectionsExistingFile-ds.xml
(rev 0)
+++
trunk/jsfunit/testdata/datasources/testFiles/MetricsMultipleConnectionsExistingFile-ds.xml 2009-03-10
20:08:00 UTC (rev 200)
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
+<datasources>
+ <no-tx-datasource>
+ <jndi-name>MetricsMultipleConnectionsExistingFile</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>
+ <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>