[jboss-cvs] JBossAS SVN: r90549 - in branches/Branch_5_x/testsuite: src/main/org/jboss/test/profileservice/test and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jun 24 00:35:16 EDT 2009


Author: ALRubinger
Date: 2009-06-24 00:35:16 -0400 (Wed, 24 Jun 2009)
New Revision: 90549

Added:
   branches/Branch_5_x/testsuite/src/resources/profileservice/testEjb3Metrics-application.xml
Modified:
   branches/Branch_5_x/testsuite/imports/sections/profileservice.xml
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/Ejb3MetricsUnitTestCase.java
Log:
[JBAS-6624] Update EJB3 Metrics test to use "/" delimiter, assert expected form for EAR deployments

Modified: branches/Branch_5_x/testsuite/imports/sections/profileservice.xml
===================================================================
--- branches/Branch_5_x/testsuite/imports/sections/profileservice.xml	2009-06-24 04:33:13 UTC (rev 90548)
+++ branches/Branch_5_x/testsuite/imports/sections/profileservice.xml	2009-06-24 04:35:16 UTC (rev 90549)
@@ -36,6 +36,13 @@
           <include name="testEjb3MetricsQueue-service.xml"/>
         </fileset>
        </jar>
+      <!-- build testEjb3Metrics.ear -->
+      <ear destfile="${build.lib}/testEjb3xMetrics.ear" 
+        appxml="${build.resources}/profileservice/testEjb3Metrics-application.xml">
+        <fileset dir="${build.lib}">
+          <include name="testEjb3xMetrics.jar"/>
+        </fileset>
+       </ear>
       <!-- build testSarDeployment.sar -->
       <jar destfile="${build.lib}/testSarDeployment.sar">
          <fileset dir="${build.classes}">

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-06-24 04:33:13 UTC (rev 90548)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/Ejb3MetricsUnitTestCase.java	2009-06-24 04:35:16 UTC (rev 90549)
@@ -79,41 +79,38 @@
     * Component subtype for Message-Driven Beans
     */
    private static final String COMPONENT_SUBTYPE_MESSAGE_DRIVEN = "MessageDriven";
-   
+
    /**
     * Properties which should be exposed by SLSB MOs.
     */
    private static final String[] PROPERTY_NAMES_SLSB = new String[]
    {
-      // general EJB metrics
-      "name", "invocationStats",
-      // session bean specific metrics
-      "availableCount", "createCount", "currentSize", "maxSize", "removeCount"
-    };
+   // general EJB metrics
+         "name", "invocationStats",
+         // session bean specific metrics
+         "availableCount", "createCount", "currentSize", "maxSize", "removeCount"};
 
    /**
     * Properties which should be exposed by SFSB MOs.
     */
    private static final String[] PROPERTY_NAMES_SFSB = new String[]
    {
-      // general EJB metrics
-      "name", "invocationStats",
-      // session bean specific metrics
-      "availableCount", "createCount", "currentSize", "maxSize", "removeCount",
-      // stateful session bean specific metrics      
-      "cacheSize", "passivatedCount", "totalSize"
-   };
+   // general EJB metrics
+         "name", "invocationStats",
+         // session bean specific metrics
+         "availableCount", "createCount", "currentSize", "maxSize", "removeCount",
+         // stateful session bean specific metrics      
+         "cacheSize", "passivatedCount", "totalSize"};
 
    /**
     * Properties which should be exposed by MDB MOs.
     */
    private static final String[] PROPERTY_NAMES_MDB = new String[]
    {
-      // general EJB metrics
-      "name", "invocationStats",
-      // message-driven bean specific metrics
-      "deliveryActive", "keepAliveMillis", "maxMessages", "maxPoolSize", "minPoolSize"
-   };
+   // general EJB metrics
+         "name", "invocationStats",
+         // message-driven bean specific metrics
+         "deliveryActive", "keepAliveMillis", "maxMessages", "maxPoolSize", "minPoolSize"};
 
    /**
     * Operations which should be exposed by SLSB MOs
@@ -134,6 +131,11 @@
    {"resetInvocationStats", "startDelivery", "stopDelivery"};
 
    /**
+    * 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";
@@ -187,16 +189,6 @@
       // Get the Deployment Manager
       deploymentManager = this.getDeploymentManager();
 
-      // Deploy the test JAR
-      final String deployName = NAME_TEST_JAR;
-      final URL contentURL = super.getDeployURL(deployName);
-      final DeploymentProgress distributeProgress = deploymentManager.distribute(deployName, contentURL, true);
-      distributeProgress.run();
-      repositoryNames = distributeProgress.getDeploymentID().getRepositoryNames();
-      final DeploymentProgress startProgress = deploymentManager.start(repositoryNames);
-      log.info("Deploying: " + repositoryNames);
-      startProgress.run();
-
       // Set the Management View
       managementView = this.getManagementView();
    }
@@ -222,7 +214,7 @@
       // Call super
       super.tearDown();
    }
-
+   
    // ---------------------------------------------------------------------------------------||
    // Tests ---------------------------------------------------------------------------------||
    // ---------------------------------------------------------------------------------------||
@@ -236,26 +228,20 @@
    {
       // Log
       this.getLog().info("testSlsb");
+      
+      // Deploy
+      this.deployTestJar();
 
       // Ensure component exists.
-      final String ejbName = TestStatelessBean.class.getSimpleName();      
-      final String componentName = ejbName;
-      final ManagedComponent component = this.getManagedComponent(COMPONENT_SUBTYPE_STATELESS_SESSION, componentName);
-      
+      final String ejbName = TestStatelessBean.class.getSimpleName();
+      final String componentName = NAME_TEST_JAR + '/' + ejbName;
+      final ManagedComponent component = this.getAndTestManagedComponent(COMPONENT_SUBTYPE_STATELESS_SESSION, componentName);
+
       // Check component has expected props and ops.
       this.ensureManagementPropertiesExposed(component, PROPERTY_NAMES_SLSB);
       this.ensureManagementOperationsExposed(component, OPERATION_NAMES_SLSB);
-      
+
       validateInvocationStats(component);
-                  
-      //     ComponentType slsbType = new ComponentType("EJB3", "SLSB");
-      //     Set<ManagedComponent> slsbs = mgtView.getComponentsForType(slsbType);          
-      //     ManagedComponent slsb = slsbs.iterator().next();
-      //     ManagedProperty currentSize = slsb.getProperty("currentSize");
-      //     assertNotNull(currentSize);
-      //     SimpleValue simple = (SimpleValue ) currentSize.getValue();
-      //     assertNotNull(simple);
-      //     getLog().debug(simple);
    }
 
    /**
@@ -267,19 +253,53 @@
    {
       // Log
       this.getLog().info("testSfsb");
+      
+      // Deploy
+      this.deployTestJar();
 
       // Ensure component exists.
       final String ejbName = TestStatefulBean.class.getSimpleName();
-      final String componentName = ejbName;
-      final ManagedComponent component = this.getManagedComponent(COMPONENT_SUBTYPE_STATEFUL_SESSION, componentName);
-      
+      final String componentName = NAME_TEST_JAR + '/' + ejbName;
+      final ManagedComponent component = this.getAndTestManagedComponent(COMPONENT_SUBTYPE_STATEFUL_SESSION, componentName);
+
       // Check component has expected props and ops.
-      this.ensureManagementPropertiesExposed(component, PROPERTY_NAMES_SFSB);      
+      this.ensureManagementPropertiesExposed(component, PROPERTY_NAMES_SFSB);
       this.ensureManagementOperationsExposed(component, OPERATION_NAMES_SFSB);
-      
+
       validateInvocationStats(component);
    }
+   
+   /**
+    * 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);
+      this.deploy(deployName, contentURL);
 
+      // Generate expected names
+      final String earName = NAME_TEST_EAR;
+      final char delimiter = '/';
+      final String jarName = NAME_TEST_JAR;
+      final String componentPrefix = earName + delimiter + jarName + delimiter;
+      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);
+      this.getAndTestManagedComponent(COMPONENT_SUBTYPE_MESSAGE_DRIVEN, mdbComponentName);
+   }
+
    /**
     * Ensures that MOs with the correct metrics and operations are exposed for MDBs.
     * 
@@ -289,22 +309,61 @@
    {
       // Log
       this.getLog().info("testMdb");
+      
+      // Deploy
+      this.deployTestJar();
 
       // Ensure component exists.
       final String ejbName = TestLoggingMDB.class.getSimpleName();
-      final String componentName = ejbName;
-      final ManagedComponent component = this.getManagedComponent(COMPONENT_SUBTYPE_MESSAGE_DRIVEN, componentName);
-      
+      final String componentName = NAME_TEST_JAR + '/' + ejbName;
+      final ManagedComponent component = this.getAndTestManagedComponent(COMPONENT_SUBTYPE_MESSAGE_DRIVEN, componentName);
+
       // Check component has expected props and ops.
-      this.ensureManagementPropertiesExposed(component, PROPERTY_NAMES_MDB);      
+      this.ensureManagementPropertiesExposed(component, PROPERTY_NAMES_MDB);
       this.ensureManagementOperationsExposed(component, OPERATION_NAMES_MDB);
-      
+
       validateInvocationStats(component);
    }
-   
+
    // ---------------------------------------------------------------------------------------||
    // Internal Helper Methods ---------------------------------------------------------------||
    // ---------------------------------------------------------------------------------------||
+   
+   /**
+    * 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
+    */
+   protected void deploy(final String deployName, final URL url) throws Exception
+   {
+      // Deploy
+      final DeploymentProgress distributeProgress = deploymentManager.distribute(deployName, url, true);
+      distributeProgress.run();
+      repositoryNames = distributeProgress.getDeploymentID().getRepositoryNames();
+      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
+   {
+      // Deploy the test JAR
+      final String deployName = NAME_TEST_JAR;
+      final URL contentURL = super.getDeployURL(deployName);
+      this.deploy(deployName, contentURL);
+   }
 
    /**
     * Obtains the component of the specified subtype and name, failing the test if not found
@@ -314,11 +373,11 @@
     * @throws IllegalArgumentException If any of the arguments were not specified
     * @throws Exception If a general error occured
     */
-   protected ManagedComponent getManagedComponent(final String componentSubType, final String componentName)
+   protected ManagedComponent getAndTestManagedComponent(final String componentSubType, final String componentName)
          throws Exception
    {
       // Log
-      this.getLog().info("getManagedComponent");
+      this.getLog().info("getAndTestManagedComponent");
 
       // Precondition checks
       if (componentSubType == null || componentSubType.length() == 0)
@@ -445,62 +504,79 @@
       }
    }
 
-    protected void validateInvocationStats(ManagedComponent component) {
-        // TODO: Invoke some methods on the EJB to populate some stats.
-        InvocationStats invocationStats = getInvocationStats(component);
-        // TODO: Check that the stats have the expected values.
-        resetInvocationStats(component);
-        invocationStats = getInvocationStats(component);
-        // TODO: Check that the stats were reset.      
-    }
-           
-    private InvocationStats getInvocationStats(ManagedComponent component) {
-        InvocationStats invocationStats = new InvocationStats();
-        List<MethodStats> allMethodStats = new ArrayList<MethodStats>();
-        ManagedProperty invocationStatsProp = component.getProperty("invocationStats");
-        invocationStats.endTime = System.currentTimeMillis();
-        CompositeValue invocationStatsMetaValue = (CompositeValue)invocationStatsProp.getValue();
-        CompositeValue allMethodStatsMetaValue = (CompositeValue) invocationStatsMetaValue.get("methodStats");
-        Set<String> methodNames = allMethodStatsMetaValue.getMetaType().keySet();
-        for (String methodName : methodNames) {
-            CompositeValue methodStatsMetaValue = (CompositeValue)allMethodStatsMetaValue.get(methodName);
-            MethodStats methodStats = new MethodStats();
-            methodStats.name = methodName;
-            methodStats.count = Long.parseLong(((SimpleValue)methodStatsMetaValue.get("count")).getValue().toString());
-            methodStats.totalTime = Long.parseLong(((SimpleValue)methodStatsMetaValue.get("totalTime")).getValue().toString());
-            methodStats.minTime = Long.parseLong(((SimpleValue)methodStatsMetaValue.get("minTime")).getValue().toString());
-            methodStats.maxTime = Long.parseLong(((SimpleValue)methodStatsMetaValue.get("maxTime")).getValue().toString());
-            allMethodStats.add(methodStats);
-        }
-        invocationStats.methodStats = allMethodStats;
+   protected void validateInvocationStats(ManagedComponent component)
+   {
+      // TODO: Invoke some methods on the EJB to populate some stats.
+      InvocationStats invocationStats = getInvocationStats(component);
+      // TODO: Check that the stats have the expected values.
+      resetInvocationStats(component);
+      invocationStats = getInvocationStats(component);
+      // TODO: Check that the stats were reset.      
+   }
 
-        SimpleValue lastResetTimeMetaValue = (SimpleValue)invocationStatsMetaValue.get("lastResetTime");
-        invocationStats.beginTime = Long.valueOf(lastResetTimeMetaValue.getValue().toString()); // TODO: handle null value?
+   private InvocationStats getInvocationStats(ManagedComponent component)
+   {
+      InvocationStats invocationStats = new InvocationStats();
+      List<MethodStats> allMethodStats = new ArrayList<MethodStats>();
+      ManagedProperty invocationStatsProp = component.getProperty("invocationStats");
+      invocationStats.endTime = System.currentTimeMillis();
+      CompositeValue invocationStatsMetaValue = (CompositeValue) invocationStatsProp.getValue();
+      CompositeValue allMethodStatsMetaValue = (CompositeValue) invocationStatsMetaValue.get("methodStats");
+      Set<String> methodNames = allMethodStatsMetaValue.getMetaType().keySet();
+      for (String methodName : methodNames)
+      {
+         CompositeValue methodStatsMetaValue = (CompositeValue) allMethodStatsMetaValue.get(methodName);
+         MethodStats methodStats = new MethodStats();
+         methodStats.name = methodName;
+         methodStats.count = Long.parseLong(((SimpleValue) methodStatsMetaValue.get("count")).getValue().toString());
+         methodStats.totalTime = Long.parseLong(((SimpleValue) methodStatsMetaValue.get("totalTime")).getValue()
+               .toString());
+         methodStats.minTime = Long
+               .parseLong(((SimpleValue) methodStatsMetaValue.get("minTime")).getValue().toString());
+         methodStats.maxTime = Long
+               .parseLong(((SimpleValue) methodStatsMetaValue.get("maxTime")).getValue().toString());
+         allMethodStats.add(methodStats);
+      }
+      invocationStats.methodStats = allMethodStats;
 
-        return invocationStats;
-    }
-   
-    private void resetInvocationStats(ManagedComponent component) {
-        Set<ManagedOperation> operations = component.getOperations();
-        for (ManagedOperation operation : operations) {
-            if (operation.getName().equals("resetInvocationStats")) {
-                operation.invoke();
-                break;
-            }
-        }
-    }
-   
-    class InvocationStats {
-        List<MethodStats> methodStats;
-        long beginTime;
-        long endTime;
-    }
+      SimpleValue lastResetTimeMetaValue = (SimpleValue) invocationStatsMetaValue.get("lastResetTime");
+      invocationStats.beginTime = Long.valueOf(lastResetTimeMetaValue.getValue().toString()); // TODO: handle null value?
 
-    class MethodStats {
-        String name;
-        long count;
-        long minTime;
-        long maxTime;
-        long totalTime;
-    }   
+      return invocationStats;
+   }
+
+   private void resetInvocationStats(ManagedComponent component)
+   {
+      Set<ManagedOperation> operations = component.getOperations();
+      for (ManagedOperation operation : operations)
+      {
+         if (operation.getName().equals("resetInvocationStats"))
+         {
+            operation.invoke();
+            break;
+         }
+      }
+   }
+
+   class InvocationStats
+   {
+      List<MethodStats> methodStats;
+
+      long beginTime;
+
+      long endTime;
+   }
+
+   class MethodStats
+   {
+      String name;
+
+      long count;
+
+      long minTime;
+
+      long maxTime;
+
+      long totalTime;
+   }
 }

Added: branches/Branch_5_x/testsuite/src/resources/profileservice/testEjb3Metrics-application.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/profileservice/testEjb3Metrics-application.xml	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/profileservice/testEjb3Metrics-application.xml	2009-06-24 04:35:16 UTC (rev 90549)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<application xmlns="http://java.sun.com/xml/ns/javaee"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+    http://java.sun.com/xml/ns/javaee/application_5.xsd"
+  version="5">
+  <description>EJB3 Metrics EAR Test</description>
+  <display-name>testEjb3Metrics</display-name>
+  <module>
+    <ejb>testEjb3xMetrics.jar</ejb>
+  </module>
+</application>


Property changes on: branches/Branch_5_x/testsuite/src/resources/profileservice/testEjb3Metrics-application.xml
___________________________________________________________________
Name: svn:executable
   + *




More information about the jboss-cvs-commits mailing list