[jboss-cvs] JBossAS SVN: r91641 - in branches/JBPAPP_5_0: testsuite/src/main/org/jboss/test/profileservice/test and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Jul 24 12:17:02 EDT 2009
Author: ALRubinger
Date: 2009-07-24 12:17:02 -0400 (Fri, 24 Jul 2009)
New Revision: 91641
Modified:
branches/JBPAPP_5_0/component-matrix/pom.xml
branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/profileservice/test/Ejb3MetricsUnitTestCase.java
branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/TestLocalBusiness.java
branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/TestLoggingMDB.java
branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/TestStatefulBean.java
branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/TestStatelessBean.java
branches/JBPAPP_5_0/thirdparty/pom.xml
Log:
[JBPAPP-2288] Component upgrades to EJB3 1.1.10 and EJB3 Metrics
Modified: branches/JBPAPP_5_0/component-matrix/pom.xml
===================================================================
--- branches/JBPAPP_5_0/component-matrix/pom.xml 2009-07-24 16:05:17 UTC (rev 91640)
+++ branches/JBPAPP_5_0/component-matrix/pom.xml 2009-07-24 16:17:02 UTC (rev 91641)
@@ -66,13 +66,12 @@
<version.org.jboss.common.core>2.2.14.GA</version.org.jboss.common.core>
<version.org.jboss.deployers>2.0.8.GA</version.org.jboss.deployers>
<version.org.jboss.ejb3.common.client>1.0.0</version.org.jboss.ejb3.common.client>
- <version.org.jboss.ejb3.core.client>1.1.8</version.org.jboss.ejb3.core.client>
- <version.org.jboss.ejb3.proxy.impl.client>1.0.2</version.org.jboss.ejb3.proxy.impl.client>
+ <version.org.jboss.ejb3.core.client>1.1.10</version.org.jboss.ejb3.core.client>
+ <version.org.jboss.ejb3.proxy.impl.client>1.0.3</version.org.jboss.ejb3.proxy.impl.client>
<version.org.jboss.ejb3.proxy.spi.client>1.0.0</version.org.jboss.ejb3.proxy.spi.client>
<version.org.jboss.ejb3.proxy.clustered.client>1.0.1</version.org.jboss.ejb3.proxy.clustered.client>
<version.org.jboss.ejb3.security.client>1.0.0</version.org.jboss.ejb3.security.client>
- <version.org.jboss.ejb3>1.1.8</version.org.jboss.ejb3>
- <version.org.jboss.ejb3.metrics.deployer>1.0.0</version.org.jboss.ejb3.metrics.deployer>
+ <version.org.jboss.ejb3>1.1.10</version.org.jboss.ejb3>
<version.org.jboss.ejb3.endpoint.deployer>0.1.4</version.org.jboss.ejb3.endpoint.deployer>
<version.org.jboss.integration>5.1.0.SP1</version.org.jboss.integration>
<version.org.jboss.jbossxb>2.0.1.GA</version.org.jboss.jbossxb>
@@ -1697,19 +1696,6 @@
<dependency>
<groupId>org.jboss.ejb3</groupId>
- <artifactId>jboss-ejb3-metrics-deployer</artifactId>
- <version>${version.org.jboss.ejb3.metrics.deployer}</version>
- <exclusions>
- <!-- EJB3 artifacts come in via jboss-ejb3-as-int -->
- <exclusion>
- <groupId>org.jboss.ejb3</groupId>
- <artifactId>jboss-ejb3-core</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.ejb3</groupId>
<artifactId>jboss-ejb3-proxy-impl</artifactId>
<version>${version.org.jboss.ejb3.proxy.impl.client}</version>
<classifier>client</classifier>
Modified: branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/profileservice/test/Ejb3MetricsUnitTestCase.java
===================================================================
--- branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/profileservice/test/Ejb3MetricsUnitTestCase.java 2009-07-24 16:05:17 UTC (rev 91640)
+++ branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/profileservice/test/Ejb3MetricsUnitTestCase.java 2009-07-24 16:17:02 UTC (rev 91641)
@@ -27,6 +27,15 @@
import java.util.List;
import java.util.Set;
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueSender;
+import javax.jms.QueueSession;
+import javax.jms.TextMessage;
+import javax.naming.Context;
+
+import junit.framework.Assert;
import junit.framework.TestCase;
import org.jboss.deployers.spi.management.ManagementView;
@@ -38,17 +47,18 @@
import org.jboss.managed.api.ManagedProperty;
import org.jboss.metatype.api.values.CompositeValue;
import org.jboss.metatype.api.values.SimpleValue;
+import org.jboss.test.profileservice.test.ejb3.TestLocalBusiness;
import org.jboss.test.profileservice.test.ejb3.TestLoggingMDB;
import org.jboss.test.profileservice.test.ejb3.TestStatefulBean;
import org.jboss.test.profileservice.test.ejb3.TestStatelessBean;
/**
* 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$
@@ -58,7 +68,7 @@
// ---------------------------------------------------------------------------------------||
// Class Members -------------------------------------------------------------------------||
- // ---------------------------------------------------------------------------------------||
+ // ---------------------------------------------------------------------------------------||
/**
* Component type for the EJB3 namespace
@@ -99,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"};
/**
@@ -134,12 +144,18 @@
* 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
+ */
+ private static final String JNDI_NAME_CONNECTION_FACTORY = "ConnectionFactory";
+
+
// ---------------------------------------------------------------------------------------||
// Instance Members ----------------------------------------------------------------------||
// ---------------------------------------------------------------------------------------||
@@ -165,7 +181,7 @@
/**
* Constructor
- *
+ *
* @param name
*/
public Ejb3MetricsUnitTestCase(String name)
@@ -214,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();
@@ -241,19 +257,19 @@
this.ensureManagementPropertiesExposed(component, PROPERTY_NAMES_SLSB);
this.ensureManagementOperationsExposed(component, OPERATION_NAMES_SLSB);
- validateInvocationStats(component);
+ validateInvocationSessionStats(component,ejbName);
}
/**
* 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();
@@ -266,20 +282,20 @@
this.ensureManagementPropertiesExposed(component, PROPERTY_NAMES_SFSB);
this.ensureManagementOperationsExposed(component, OPERATION_NAMES_SFSB);
- validateInvocationStats(component);
+ 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);
@@ -293,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);
@@ -302,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();
@@ -322,18 +338,18 @@
this.ensureManagementPropertiesExposed(component, PROPERTY_NAMES_MDB);
this.ensureManagementOperationsExposed(component, OPERATION_NAMES_MDB);
- validateInvocationStats(component);
+ validateInvocationMdbStats(component);
}
// ---------------------------------------------------------------------------------------||
// 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
@@ -347,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
@@ -367,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
@@ -423,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
@@ -458,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
@@ -504,16 +520,123 @@
}
}
- protected void validateInvocationStats(ManagedComponent component)
+ /**
+ * 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
+ */
+ protected void validateInvocationSessionStats(final ManagedComponent component, final String ejbName)
+ throws IllegalArgumentException, Exception
{
- // TODO: Invoke some methods on the EJB to populate some stats.
+ // Precondition checks
+ if (component == null)
+ {
+ throw new IllegalArgumentException("component must be specified");
+ }
+ if (ejbName == null || ejbName.length() == 0)
+ {
+ throw new IllegalArgumentException("ejbName must be specified");
+ }
+
+ // Obtain invocation stats
InvocationStats invocationStats = getInvocationStats(component);
- // TODO: Check that the stats have the expected values.
+
+ // Ensure the stats are expected (empty)
+ List<MethodStats> methodStats = invocationStats.methodStats;
+ log.info("Method stats before invocation: " + methodStats);
+ Assert.assertTrue("Method stats should be empty", methodStats.isEmpty());
+
+ // Invoke upon the EJB
+ TestLocalBusiness localBusiness = (TestLocalBusiness) getInitialContext().lookup(ejbName + "/remote");
+ localBusiness.echo("Some test String");
+
+ // Ensure the stats reflect the invocation
+ invocationStats = getInvocationStats(component);
+ methodStats = invocationStats.methodStats;
+ log.info("Method stats after invocation: " + methodStats);
+ Assert.assertEquals("One invocation should be represented in stats", 1, methodStats.size());
+
+ // Reset the stats
resetInvocationStats(component);
invocationStats = getInvocationStats(component);
- // TODO: Check that the stats were reset.
+
+ // Ensure the stats were reset
+ invocationStats = getInvocationStats(component);
+ methodStats = invocationStats.methodStats;
+ 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
+ * EJB3 MDB ManagedComponent with specified EJB Name
+ *
+ * @param component
+ * @throws IllegalArgumentException If the component is not specified
+ */
+ protected void validateInvocationMdbStats(final ManagedComponent component)
+ throws IllegalArgumentException, Exception
+ {
+ // Precondition checks
+ if (component == null)
+ {
+ throw new IllegalArgumentException("component must be specified");
+ }
+ // Obtain invocation stats
+ InvocationStats invocationStats = getInvocationStats(component);
+
+ // Ensure the stats are expected (empty)
+ List<MethodStats> methodStats = invocationStats.methodStats;
+ Assert.assertTrue("Method stats should be empty", methodStats.isEmpty());
+
+ // Get the queue from JNDI
+ final Context naimgContext = getInitialContext();
+ final Queue queue = (Queue) naimgContext.lookup(TestLoggingMDB.QUEUE_NAME);
+
+ // Get the ConnectionFactory from JNDI
+ final QueueConnectionFactory factory = (QueueConnectionFactory) naimgContext
+ .lookup(JNDI_NAME_CONNECTION_FACTORY);
+
+ // Make a Connection
+ final QueueConnection connection = factory.createQueueConnection();
+ final QueueSession sendSession = connection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
+
+ // Make the message
+ final String contents = "Test Message Contents";
+ final TextMessage message = sendSession.createTextMessage(contents);
+
+ // Send the message
+ final QueueSender sender = sendSession.createSender(queue);
+ sender.send(message);
+ log.info("Sent message " + message + " with contents: " + contents);
+
+ // Clean up
+ sendSession.close();
+ connection.close();
+
+ // Wait, this is async
+ Thread.sleep(3000);
+
+ // Ensure the stats reflect the invocation
+ invocationStats = getInvocationStats(component);
+ methodStats = invocationStats.methodStats;
+ log.info("Method stats after invocation: " + methodStats);
+ Assert.assertEquals("One invocation should be represented in stats", 1, methodStats.size());
+
+ // Reset the stats
+ resetInvocationStats(component);
+ invocationStats = getInvocationStats(component);
+
+ // Ensure the stats were reset
+ invocationStats = getInvocationStats(component);
+ methodStats = invocationStats.methodStats;
+ log.info("Method stats after reset: " + methodStats);
+ Assert.assertTrue("Method stats should be empty", methodStats.isEmpty());
+ }
+
private InvocationStats getInvocationStats(ManagedComponent component)
{
InvocationStats invocationStats = new InvocationStats();
@@ -548,14 +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)
{
- if (operation.getName().equals("resetInvocationStats"))
+ final String opName = operation.getName();
+ opNames.add(opName);
+ if (opName.equals(resetMethodName))
{
operation.invoke();
- break;
+ return;
}
}
+
+ // If we've reached here, fail
+ Assert.fail("No operation named \"" + resetMethodName + "\" exists in "
+ + opNames + " for " + component.getName());
+
}
class InvocationStats
@@ -565,6 +697,13 @@
long beginTime;
long endTime;
+
+ @Override
+ public String toString()
+ {
+ return "InvocationStats [beginTime=" + beginTime + ", endTime=" + endTime + ", methodStats=" + methodStats
+ + "]";
+ }
}
class MethodStats
@@ -578,5 +717,12 @@
long maxTime;
long totalTime;
+
+ @Override
+ public String toString()
+ {
+ return "MethodStats [count=" + count + ", maxTime=" + maxTime + ", minTime=" + minTime + ", name=" + name
+ + ", totalTime=" + totalTime + "]";
+ }
}
}
Modified: branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/TestLocalBusiness.java
===================================================================
--- branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/TestLocalBusiness.java 2009-07-24 16:05:17 UTC (rev 91640)
+++ branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/TestLocalBusiness.java 2009-07-24 16:17:02 UTC (rev 91641)
@@ -31,5 +31,11 @@
*/
public interface TestLocalBusiness
{
- // No business methods required
+ /**
+ * Returns a String equal by value to the argument
+ *
+ * @param echo
+ * @return
+ */
+ String echo(String echo);
}
Modified: branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/TestLoggingMDB.java
===================================================================
--- branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/TestLoggingMDB.java 2009-07-24 16:05:17 UTC (rev 91640)
+++ branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/TestLoggingMDB.java 2009-07-24 16:17:02 UTC (rev 91641)
@@ -40,7 +40,7 @@
*/
@MessageDriven(activationConfig =
{@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
- @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/ejb3MetricsTestQueue")})
+ @ActivationConfigProperty(propertyName = "destination", propertyValue = TestLoggingMDB.QUEUE_NAME)})
@Depends("jboss.mq.destination:service=Queue,name=ejb3MetricsTestQueue")
public class TestLoggingMDB implements MessageListener
{
@@ -53,6 +53,11 @@
* Logger
*/
private static final Logger log = Logger.getLogger(TestLoggingMDB.class);
+
+ /**
+ * Name of the queue
+ */
+ public static final String QUEUE_NAME = "queue/ejb3MetricsTestQueue";
//-------------------------------------------------------------------------------------||
// Required Implementations -----------------------------------------------------------||
Modified: branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/TestStatefulBean.java
===================================================================
--- branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/TestStatefulBean.java 2009-07-24 16:05:17 UTC (rev 91640)
+++ branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/TestStatefulBean.java 2009-07-24 16:17:02 UTC (rev 91641)
@@ -21,7 +21,7 @@
*/
package org.jboss.test.profileservice.test.ejb3;
-import javax.ejb.Local;
+import javax.ejb.Remote;
import javax.ejb.Stateful;
/**
@@ -33,8 +33,16 @@
* @version $Revision: $
*/
@Stateful
- at Local(TestLocalBusiness.class)
+ at Remote(TestLocalBusiness.class)
public class TestStatefulBean implements TestLocalBusiness
{
- // No business methods required
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.test.profileservice.test.ejb3.TestLocalBusiness#echo(java.lang.String)
+ */
+ public String echo(String echo)
+ {
+ return echo;
+ }
+
}
Modified: branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/TestStatelessBean.java
===================================================================
--- branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/TestStatelessBean.java 2009-07-24 16:05:17 UTC (rev 91640)
+++ branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/TestStatelessBean.java 2009-07-24 16:17:02 UTC (rev 91641)
@@ -21,7 +21,7 @@
*/
package org.jboss.test.profileservice.test.ejb3;
-import javax.ejb.Local;
+import javax.ejb.Remote;
import javax.ejb.Stateless;
/**
@@ -33,8 +33,15 @@
* @version $Revision: $
*/
@Stateless
- at Local(TestLocalBusiness.class)
+ at Remote(TestLocalBusiness.class)
public class TestStatelessBean implements TestLocalBusiness
{
- // No business methods required
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.test.profileservice.test.ejb3.TestLocalBusiness#echo(java.lang.String)
+ */
+ public String echo(String echo)
+ {
+ return echo;
+ }
}
Modified: branches/JBPAPP_5_0/thirdparty/pom.xml
===================================================================
--- branches/JBPAPP_5_0/thirdparty/pom.xml 2009-07-24 16:05:17 UTC (rev 91640)
+++ branches/JBPAPP_5_0/thirdparty/pom.xml 2009-07-24 16:17:02 UTC (rev 91641)
@@ -1457,10 +1457,6 @@
</dependency>
<dependency>
<groupId>org.jboss.ejb3</groupId>
- <artifactId>jboss-ejb3-metrics-deployer</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.ejb3</groupId>
<artifactId>jboss-ejb3-proxy-impl</artifactId>
<classifier>client</classifier>
</dependency>
More information about the jboss-cvs-commits
mailing list