[jboss-cvs] JBossAS SVN: r86977 - branches/Branch_5_x/testsuite/src/main/org/jboss/test/jca/test.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Apr 8 13:37:06 EDT 2009


Author: jesper.pedersen
Date: 2009-04-08 13:37:05 -0400 (Wed, 08 Apr 2009)
New Revision: 86977

Modified:
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/jca/test/StatisticsFormatterUnitTestCase.java
Log:
[JBAS-6717] Connection stats using flush

Modified: branches/Branch_5_x/testsuite/src/main/org/jboss/test/jca/test/StatisticsFormatterUnitTestCase.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/jca/test/StatisticsFormatterUnitTestCase.java	2009-04-08 17:24:49 UTC (rev 86976)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/jca/test/StatisticsFormatterUnitTestCase.java	2009-04-08 17:37:05 UTC (rev 86977)
@@ -69,6 +69,7 @@
    private static final String ATTRIBUTE_NAME = "StatisticsFormatter";
    private static final String RAW_STATS_METHOD = "listStatistics";
    private static final String FORMATTED_STATS_METHOD = "listFormattedSubPoolStatistics";
+   private static final String FLUSH_METHOD = "flush";
    
    public StatisticsFormatterUnitTestCase(String name){
     
@@ -110,7 +111,7 @@
       Connection conn = ds.getConnection("sa", "");
       
       Object formattedStats = StatisticsHelper.listFormattedStatistics(getServer());
-      
+
       assertTrue(formattedStats instanceof String);
       
       //Do a diff
@@ -125,10 +126,101 @@
       assertEquals(formattedStats, rawFormat);
       
       conn.close();
+   }
+
+   public void testConnectionInUse() throws Exception
+   {
+      String POOL_SEPERATOR = "------------------------------------------------------";
+
+      StringBuffer expectedBeforeBuffer = new StringBuffer();
+      expectedBeforeBuffer.append("Sub Pool Statistics: \n");
+      expectedBeforeBuffer.append("Sub Pool Count: 0\n");
+      expectedBeforeBuffer.append(POOL_SEPERATOR);
+      expectedBeforeBuffer.append("\n\n");
+
+      StringBuffer expectedAfterBuffer = new StringBuffer();
+      expectedAfterBuffer.append("Sub Pool Statistics: \n");
+      expectedAfterBuffer.append("Sub Pool Count: 0\n");
+      expectedAfterBuffer.append(POOL_SEPERATOR);
+      expectedAfterBuffer.append("\n\n");
+
+      StringBuffer expectedConn1Buffer = new StringBuffer();
+      expectedConn1Buffer.append("Sub Pool Statistics: \n");
+      expectedConn1Buffer.append("Sub Pool Count: 1\n");
+      expectedConn1Buffer.append(POOL_SEPERATOR);
+      expectedConn1Buffer.append("\n\n");
+      expectedConn1Buffer.append("Track By Transaction: true\n");
+      expectedConn1Buffer.append("Available Connections Count: 9\n");
+      expectedConn1Buffer.append("Max Connections In Use Count:1\n");
+      expectedConn1Buffer.append("Connections Destroyed Count:0\n");
+      expectedConn1Buffer.append("Connections In Use Count:1\n");
+      expectedConn1Buffer.append("Total Block Time:0\n");
+      expectedConn1Buffer.append("Average Block Time For Sub Pool:0\n");
+      expectedConn1Buffer.append("Maximum Wait Time For Sub Pool:0\n");
+      expectedConn1Buffer.append("Total Timed Out:0\n");
+      expectedConn1Buffer.append("\n");
+      expectedConn1Buffer.append(POOL_SEPERATOR);
+      expectedConn1Buffer.append("\n\n");
+
+      StringBuffer expectedConn2Buffer = new StringBuffer();
+      expectedConn2Buffer.append("Sub Pool Statistics: \n");
+      expectedConn2Buffer.append("Sub Pool Count: 1\n");
+      expectedConn2Buffer.append(POOL_SEPERATOR);
+      expectedConn2Buffer.append("\n\n");
+      expectedConn2Buffer.append("Track By Transaction: true\n");
+      expectedConn2Buffer.append("Available Connections Count: 8\n");
+      expectedConn2Buffer.append("Max Connections In Use Count:2\n");
+      expectedConn2Buffer.append("Connections Destroyed Count:0\n");
+      expectedConn2Buffer.append("Connections In Use Count:2\n");
+      expectedConn2Buffer.append("Total Block Time:0\n");
+      expectedConn2Buffer.append("Average Block Time For Sub Pool:0\n");
+      expectedConn2Buffer.append("Maximum Wait Time For Sub Pool:0\n");
+      expectedConn2Buffer.append("Total Timed Out:0\n");
+      expectedConn2Buffer.append("\n");
+      expectedConn2Buffer.append(POOL_SEPERATOR);
+      expectedConn2Buffer.append("\n\n");
+
+      InitialContext initCtx = super.getInitialContext();
+
+      // Flush
+      Object o = getServer().invoke(POOL_NAME, FLUSH_METHOD, new Object[0], new String[0]);
+
+      // Before obtaining connections
+      Object beforeStats = StatisticsHelper.listFormattedStatistics(getServer());
+
+      assertTrue(beforeStats instanceof String);
+      assertEquals(beforeStats, expectedBeforeBuffer.toString());
+
+      // Obtaining connections
+      DataSource ds = (DataSource)initCtx.lookup("StatsDS");
+      Connection conn1 = ds.getConnection("sa", "");
       
+      Object conn1Stats = StatisticsHelper.listFormattedStatistics(getServer());
+
+      assertTrue(conn1Stats instanceof String);
+      assertEquals(conn1Stats, expectedConn1Buffer.toString());
+
+      Connection conn2 = ds.getConnection("sa", "");
       
+      Object conn2Stats = StatisticsHelper.listFormattedStatistics(getServer());
+
+      assertTrue(conn2Stats instanceof String);
+      assertEquals(conn2Stats, expectedConn2Buffer.toString());
+
+      conn1.close();
+      conn2.close();
+
+      // Flush
+      o = getServer().invoke(POOL_NAME, FLUSH_METHOD, new Object[0], new String[0]);
+
+      // After obtaining connections
+      Object afterStats = StatisticsHelper.listFormattedStatistics(getServer());
+
+      assertTrue(afterStats instanceof String);
+      assertEquals(afterStats, expectedAfterBuffer.toString());
    }
    
+
    public void testXmlFormatterStatistics() throws Exception{
 
       InitialContext initCtx = super.getInitialContext();
@@ -195,7 +287,6 @@
       assertEquals(formattedStats, rawFormat);
       
    }
-   
   
    
    private Object listRawStatistics() throws Exception{




More information about the jboss-cvs-commits mailing list