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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jul 22 14:11:47 EDT 2009


Author: ALRubinger
Date: 2009-07-22 14:11:46 -0400 (Wed, 22 Jul 2009)
New Revision: 91568

Modified:
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/Ejb3MetricsUnitTestCase.java
Log:
[JBAS-7108] Fix transient nature of the test

Modified: branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/Ejb3MetricsUnitTestCase.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/Ejb3MetricsUnitTestCase.java	2009-07-22 18:05:48 UTC (rev 91567)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/Ejb3MetricsUnitTestCase.java	2009-07-22 18:11:46 UTC (rev 91568)
@@ -54,11 +54,11 @@
 
 /**
  * Ejb3MetricsUnitTestCase
- * 
- * Asserts that ManagementObjects and corresponding 
+ *
+ * Asserts that ManagementObjects and corresponding
  * properties/operations are exposed in expected form for
- * EJB3 SLSBs, SFSBs, and MDBs.  
- * 
+ * EJB3 SLSBs, SFSBs, and MDBs.
+ *
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @author <a href="mailto:andrew.rubinger at redhat.com">ALR</a>
  * @version $Revision$
@@ -68,7 +68,7 @@
 
    // ---------------------------------------------------------------------------------------||
    // Class Members -------------------------------------------------------------------------||
-   // ---------------------------------------------------------------------------------------||   
+   // ---------------------------------------------------------------------------------------||
 
    /**
     * Component type for the EJB3 namespace
@@ -109,7 +109,7 @@
          "name", "invocationStats",
          // session bean specific metrics
          "availableCount", "createCount", "currentSize", "maxSize", "removeCount",
-         // stateful session bean specific metrics      
+         // stateful session bean specific metrics
          "cacheSize", "passivatedCount", "totalSize"};
 
    /**
@@ -144,12 +144,12 @@
     * The name of the test EAR to deploy
     */
    private static final String NAME_TEST_EAR = "testEjb3xMetrics.ear";
-   
+
    /**
     * The name of the test JAR to deploy
     */
    private static final String NAME_TEST_JAR = "testEjb3xMetrics.jar";
-   
+
    /**
     * Name of the Queue Connection Factory in JNDI
     */
@@ -181,7 +181,7 @@
 
    /**
     * Constructor
-    * 
+    *
     * @param name
     */
    public Ejb3MetricsUnitTestCase(String name)
@@ -230,21 +230,21 @@
       // Call super
       super.tearDown();
    }
-   
+
    // ---------------------------------------------------------------------------------------||
    // Tests ---------------------------------------------------------------------------------||
    // ---------------------------------------------------------------------------------------||
 
    /**
     * Ensures that MOs with the correct metrics and operations are exposed for SLSBs.
-    * 
+    *
     * @throws Exception
     */
    public void testSlsb() throws Exception
    {
       // Log
       this.getLog().info("testSlsb");
-      
+
       // Deploy
       this.deployTestJar();
 
@@ -262,14 +262,14 @@
 
    /**
     * Ensures that MOs with the correct metrics and operations are exposed for SFSBs.
-    * 
+    *
     * @throws Exception
     */
    public void testSfsb() throws Exception
    {
       // Log
       this.getLog().info("testSfsb");
-      
+
       // Deploy
       this.deployTestJar();
 
@@ -284,18 +284,18 @@
 
       validateInvocationSessionStats(component,ejbName);
    }
-   
+
    /**
     * Ensures that the managed component names of
     * EJB3 deployments in an EAR have form:
-    * 
+    *
     * "EARName/JARName/EJBName"
     */
    public void testEarManagedComponentNames() throws Exception
    {
       // Log
       this.getLog().info("testEarManagedComponentNames");
-      
+
       // Deploy the EAR (it will be undeployed and cleaned up as part of test lifecycle)
       final String deployName = NAME_TEST_EAR;
       final URL contentURL = super.getDeployURL(deployName);
@@ -309,7 +309,7 @@
       final String slsbComponentName = componentPrefix + TestStatelessBean.class.getSimpleName();
       final String sfsbComponentName = componentPrefix + TestStatefulBean.class.getSimpleName();
       final String mdbComponentName = componentPrefix + TestLoggingMDB.class.getSimpleName();
-    
+
       // Test
       this.getAndTestManagedComponent(COMPONENT_SUBTYPE_STATELESS_SESSION, slsbComponentName);
       this.getAndTestManagedComponent(COMPONENT_SUBTYPE_STATEFUL_SESSION, sfsbComponentName);
@@ -318,14 +318,14 @@
 
    /**
     * Ensures that MOs with the correct metrics and operations are exposed for MDBs.
-    * 
+    *
     * @throws Exception
     */
    public void testMdb() throws Exception
    {
       // Log
       this.getLog().info("testMdb");
-      
+
       // Deploy
       this.deployTestJar();
 
@@ -344,12 +344,12 @@
    // ---------------------------------------------------------------------------------------||
    // Internal Helper Methods ---------------------------------------------------------------||
    // ---------------------------------------------------------------------------------------||
-   
+
    /**
-    * Deploys the specified URL under the specified deployment name 
+    * Deploys the specified URL under the specified deployment name
     * using the profile service; this is required such that ManagedObjects will
     * be found (which is not the case using traditional JMX deployment)
-    * 
+    *
     * @param deployName
     * @param url
     * @throws Exception
@@ -363,14 +363,14 @@
       final DeploymentProgress startProgress = deploymentManager.start(repositoryNames);
       log.info("Deploying: " + repositoryNames);
       startProgress.run();
-      
+
       // Reset the Management View
       managementView = this.getManagementView();
    }
-   
+
    /**
     * Deploys the test JAR
-    * 
+    *
     * @throws Exception
     */
    protected void deployTestJar() throws Exception
@@ -383,8 +383,8 @@
 
    /**
     * Obtains the component of the specified subtype and name, failing the test if not found
-    * 
-    * @param componentSubType 
+    *
+    * @param componentSubType
     * @param componentName
     * @throws IllegalArgumentException If any of the arguments were not specified
     * @throws Exception If a general error occured
@@ -439,11 +439,11 @@
    /**
     * Ensures that the specified management properties are exposed for
     * the specified component
-    * 
+    *
     * @param The component
     * @param expectedProperties Properties expected to be exposed by the specified component
     * @throws IllegalArgumentException If any of the arguments are blank or null
-    * @throws Exception 
+    * @throws Exception
     */
    protected void ensureManagementPropertiesExposed(final ManagedComponent component, final String[] expectedProperties)
          throws IllegalArgumentException, Exception
@@ -474,11 +474,11 @@
    /**
     * Ensures that the specified management operations are exposed for
     * the specified component
-    * 
+    *
     * @param The component
     * @param expectedOperationNames Operation names expected to be exposed by the specified component
     * @throws IllegalArgumentException If any of the arguments are blank or null
-    * @throws Exception 
+    * @throws Exception
     */
    protected void ensureManagementOperationsExposed(final ManagedComponent component,
          final String[] expectedOperationNames) throws IllegalArgumentException, Exception
@@ -521,9 +521,9 @@
    }
 
    /**
-    * Validates that the invocation statistics are in place for the specified 
+    * Validates that the invocation statistics are in place for the specified
     * EJB3 Session Bean ManagedComponent with specified EJB Name
-    * 
+    *
     * @param component
     * @param ejbName
     * @throws IllegalArgumentException If either argument is not specified
@@ -569,11 +569,11 @@
       log.info("Method stats after reset: " + methodStats);
       Assert.assertTrue("Method stats should be empty, was instead of size: " + methodStats.size(), methodStats.isEmpty());
    }
-   
+
    /**
-    * Validates that the invocation statistics are in place for the specified 
+    * Validates that the invocation statistics are in place for the specified
     * EJB3 MDB ManagedComponent with specified EJB Name
-    * 
+    *
     * @param component
     * @throws IllegalArgumentException If the component is not specified
     */
@@ -616,7 +616,7 @@
       // Clean up
       sendSession.close();
       connection.close();
-      
+
       // Wait, this is async
       Thread.sleep(3000);
 
@@ -671,22 +671,23 @@
    private void resetInvocationStats(ManagedComponent component)
    {
       Set<ManagedOperation> operations = component.getOperations();
+      final List<String> opNames = new ArrayList<String>();
+      final String resetMethodName = "resetInvocationStats";
       for (ManagedOperation operation : operations)
       {
-         final String resetMethodName = "resetInvocationStats";
-         boolean invoked = false;
-         if (operation.getName().equals(resetMethodName))
+         final String opName = operation.getName();
+         opNames.add(opName);
+         if (opName.equals(resetMethodName))
          {
             operation.invoke();
-            invoked = true;
-            break;
+            return;
          }
-         
-         if (!invoked)
-         {
-            Assert.fail("No operation named \"" + resetMethodName + "\" exists in " + component);
-         }
       }
+
+      // If we've reached here, fail
+      Assert.fail("No operation named \"" + resetMethodName + "\" exists in "
+				+ opNames + " for " + component.getName());
+
    }
 
    class InvocationStats




More information about the jboss-cvs-commits mailing list