[jboss-cvs] JBossAS SVN: r92484 - in branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test: ejb3 and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Aug 18 04:03:20 EDT 2009
Author: ALRubinger
Date: 2009-08-18 04:03:19 -0400 (Tue, 18 Aug 2009)
New Revision: 92484
Added:
branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/LocalExpositionBean.java
branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/LocalExpositionRemoteBusiness.java
branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/TestCommonBusiness.java
branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/TestRemoteBusiness.java
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/ejb3/TestLocalBusiness.java
branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/TestStatefulBean.java
branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/TestStatelessBean.java
Log:
[EJBTHREE-1885] Test local invocations for EJB3 metrics
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-08-18 08:02:42 UTC (rev 92483)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/Ejb3MetricsUnitTestCase.java 2009-08-18 08:03:19 UTC (rev 92484)
@@ -47,8 +47,10 @@
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.LocalExpositionBean;
+import org.jboss.test.profileservice.test.ejb3.LocalExpositionRemoteBusiness;
import org.jboss.test.profileservice.test.ejb3.TestLoggingMDB;
+import org.jboss.test.profileservice.test.ejb3.TestRemoteBusiness;
import org.jboss.test.profileservice.test.ejb3.TestStatefulBean;
import org.jboss.test.profileservice.test.ejb3.TestStatelessBean;
@@ -155,7 +157,6 @@
*/
private static final String JNDI_NAME_CONNECTION_FACTORY = "ConnectionFactory";
-
// ---------------------------------------------------------------------------------------||
// Instance Members ----------------------------------------------------------------------||
// ---------------------------------------------------------------------------------------||
@@ -249,15 +250,16 @@
this.deployTestJar();
// Ensure component exists.
- final String ejbName = TestStatelessBean.class.getSimpleName();
+ final String ejbName = TestStatelessBean.EJB_NAME;
final String componentName = NAME_TEST_JAR + '/' + ejbName;
- final ManagedComponent component = this.getAndTestManagedComponent(COMPONENT_SUBTYPE_STATELESS_SESSION, componentName);
+ 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);
- validateInvocationSessionStats(component,ejbName);
+ validateInvocationSessionStats(component, ejbName);
}
/**
@@ -274,17 +276,35 @@
this.deployTestJar();
// Ensure component exists.
- final String ejbName = TestStatefulBean.class.getSimpleName();
+ final String ejbName = TestStatefulBean.EJB_NAME;
final String componentName = NAME_TEST_JAR + '/' + ejbName;
- final ManagedComponent component = this.getAndTestManagedComponent(COMPONENT_SUBTYPE_STATEFUL_SESSION, componentName);
+ final ManagedComponent component = this.getAndTestManagedComponent(COMPONENT_SUBTYPE_STATEFUL_SESSION,
+ componentName);
// Check component has expected props and ops.
this.ensureManagementPropertiesExposed(component, PROPERTY_NAMES_SFSB);
this.ensureManagementOperationsExposed(component, OPERATION_NAMES_SFSB);
- validateInvocationSessionStats(component,ejbName);
+ validateInvocationSessionStats(component, ejbName);
}
+
+ /**
+ * Ensures that SLSB local invocations are recorded
+ *
+ * @throws Exception
+ */
+ public void testSlsbLocal() throws Exception
+ {
+ // Log
+ this.getLog().info("testSlsbLocal");
+ // Deploy
+ this.deployTestJar();
+
+ // Check component has expected props and ops
+ validateLocalInvocationSlsbStats();
+ }
+
/**
* Ensures that the managed component names of
* EJB3 deployments in an EAR have form:
@@ -306,8 +326,8 @@
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 slsbComponentName = componentPrefix + TestStatelessBean.EJB_NAME;
+ final String sfsbComponentName = componentPrefix + TestStatefulBean.EJB_NAME;
final String mdbComponentName = componentPrefix + TestLoggingMDB.class.getSimpleName();
// Test
@@ -332,7 +352,8 @@
// Ensure component exists.
final String ejbName = TestLoggingMDB.class.getSimpleName();
final String componentName = NAME_TEST_JAR + '/' + ejbName;
- final ManagedComponent component = this.getAndTestManagedComponent(COMPONENT_SUBTYPE_MESSAGE_DRIVEN, componentName);
+ final ManagedComponent component = this.getAndTestManagedComponent(COMPONENT_SUBTYPE_MESSAGE_DRIVEN,
+ componentName);
// Check component has expected props and ops.
this.ensureManagementPropertiesExposed(component, PROPERTY_NAMES_MDB);
@@ -550,8 +571,8 @@
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");
+ TestRemoteBusiness remoteBusiness = (TestRemoteBusiness) getInitialContext().lookup(ejbName + "/remote");
+ remoteBusiness.echo("Some test String");
// Ensure the stats reflect the invocation
invocationStats = getInvocationStats(component);
@@ -567,18 +588,64 @@
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());
+ Assert.assertTrue("Method stats should be empty, was instead of size: " + methodStats.size(), methodStats
+ .isEmpty());
}
/**
+ * Validates that the invocation statistics are in place
+ * for local invocations upon a SLSB
+ *
+ * @throws IllegalArgumentException If either argument is not specified
+ */
+ protected void validateLocalInvocationSlsbStats()
+ throws IllegalArgumentException, Exception
+ {
+ // Ensure component exists
+ final String ejbName = TestStatelessBean.EJB_NAME;
+ final String slsbComponentName = NAME_TEST_JAR + '/' + ejbName;
+ final ManagedComponent slsbComponent = this.getAndTestManagedComponent(COMPONENT_SUBTYPE_STATELESS_SESSION,
+ slsbComponentName);
+
+ // Obtain invocation stats
+ InvocationStats invocationStats = getInvocationStats(slsbComponent);
+
+ // 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 locally via the Remote access delegate
+ LocalExpositionRemoteBusiness remoteBusiness = (LocalExpositionRemoteBusiness) getInitialContext().lookup(LocalExpositionBean.class.getSimpleName() + "/remote");
+ remoteBusiness.echoViaLocal("Some test String");
+
+ // Ensure the stats reflect the invocation in the SLSB
+ invocationStats = getInvocationStats(slsbComponent);
+ methodStats = invocationStats.methodStats;
+ log.info("Method stats after invocation: " + methodStats);
+ Assert.assertEquals("One invocation (made locally) should be represented in stats", 1, methodStats.size());
+
+ // Reset the stats
+ resetInvocationStats(slsbComponent);
+ invocationStats = getInvocationStats(slsbComponent);
+
+ // Ensure the stats were reset
+ invocationStats = getInvocationStats(slsbComponent);
+ 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
+ protected void validateInvocationMdbStats(final ManagedComponent component) throws IllegalArgumentException,
+ Exception
{
// Precondition checks
if (component == null)
@@ -597,8 +664,7 @@
final Queue queue = (Queue) naimgContext.lookup(TestLoggingMDB.QUEUE_NAME);
// Get the ConnectionFactory from JNDI
- final QueueConnectionFactory factory = (QueueConnectionFactory) naimgContext
- .lookup(JNDI_NAME_CONNECTION_FACTORY);
+ final QueueConnectionFactory factory = (QueueConnectionFactory) naimgContext.lookup(JNDI_NAME_CONNECTION_FACTORY);
// Make a Connection
final QueueConnection connection = factory.createQueueConnection();
@@ -685,8 +751,8 @@
}
// If we've reached here, fail
- Assert.fail("No operation named \"" + resetMethodName + "\" exists in "
- + opNames + " for " + component.getName());
+ Assert
+ .fail("No operation named \"" + resetMethodName + "\" exists in " + opNames + " for " + component.getName());
}
Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/LocalExpositionBean.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/LocalExpositionBean.java (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/LocalExpositionBean.java 2009-08-18 08:03:19 UTC (rev 92484)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.profileservice.test.ejb3;
+
+import javax.ejb.EJB;
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+
+/**
+ * LocalExpositionBean
+ *
+ * A bean with a remote view which exposes an operation
+ * to be delegated to a local view
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+ at Stateless
+ at Remote(LocalExpositionRemoteBusiness.class)
+public class LocalExpositionBean implements LocalExpositionRemoteBusiness
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Instance Members -------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ @EJB(name = TestStatelessBean.EJB_NAME)
+ private TestLocalBusiness local;
+
+ //-------------------------------------------------------------------------------------||
+ // Required Implementations -----------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * @see org.jboss.test.profileservice.test.ejb3.LocalExpositionRemoteBusiness#echoViaLocal(java.lang.String)
+ */
+ public String echoViaLocal(final String echo)
+ {
+ return local.echo(echo);
+ }
+
+}
Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/LocalExpositionRemoteBusiness.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/LocalExpositionRemoteBusiness.java (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/LocalExpositionRemoteBusiness.java 2009-08-18 08:03:19 UTC (rev 92484)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.profileservice.test.ejb3;
+
+/**
+ * LocalExpositionRemoteBusiness
+ *
+ * A remote business interface which exposes an EJB's local
+ * view to the outside world.
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface LocalExpositionRemoteBusiness
+{
+ /**
+ * Returns a String equal by value to that specified,
+ * delegating through a local view
+ *
+ * @param echo
+ * @return
+ */
+ String echoViaLocal(String echo);
+}
Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/TestCommonBusiness.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/TestCommonBusiness.java (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/TestCommonBusiness.java 2009-08-18 08:03:19 UTC (rev 92484)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.profileservice.test.ejb3;
+
+/**
+ * TestCommonBusiness
+ *
+ * Business Interface of a test EJB
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface TestCommonBusiness
+{
+ /**
+ * Returns a String equal by value to the argument
+ *
+ * @param echo
+ * @return
+ */
+ String echo(String echo);
+}
Property changes on: branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/TestCommonBusiness.java
___________________________________________________________________
Name: svn:executable
+ *
Modified: branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/TestLocalBusiness.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/TestLocalBusiness.java 2009-08-18 08:02:42 UTC (rev 92483)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/TestLocalBusiness.java 2009-08-18 08:03:19 UTC (rev 92484)
@@ -29,13 +29,6 @@
* @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
* @version $Revision: $
*/
-public interface TestLocalBusiness
+public interface TestLocalBusiness extends TestCommonBusiness
{
- /**
- * Returns a String equal by value to the argument
- *
- * @param echo
- * @return
- */
- String echo(String echo);
}
Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/TestRemoteBusiness.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/TestRemoteBusiness.java (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/TestRemoteBusiness.java 2009-08-18 08:03:19 UTC (rev 92484)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.profileservice.test.ejb3;
+
+/**
+ * TestRemoteBusiness
+ *
+ * Remote Business Interface of a test EJB
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface TestRemoteBusiness extends TestCommonBusiness
+{
+
+}
Modified: branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/TestStatefulBean.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/TestStatefulBean.java 2009-08-18 08:02:42 UTC (rev 92483)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/TestStatefulBean.java 2009-08-18 08:03:19 UTC (rev 92484)
@@ -21,26 +21,32 @@
*/
package org.jboss.test.profileservice.test.ejb3;
+import javax.ejb.Local;
import javax.ejb.Remote;
import javax.ejb.Stateful;
/**
* TestStatefulBean
*
- * A test SFSB with no business methods
+ * A Test SFSB
*
* @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
* @version $Revision: $
*/
- at Stateful
- at Remote(TestLocalBusiness.class)
-public class TestStatefulBean implements TestLocalBusiness
+ at Stateful(name = TestStatefulBean.EJB_NAME)
+ at Remote(TestRemoteBusiness.class)
+ at Local(TestLocalBusiness.class)
+public class TestStatefulBean implements TestLocalBusiness, TestRemoteBusiness
{
- /*
- * (non-Javadoc)
- * @see org.jboss.test.profileservice.test.ejb3.TestLocalBusiness#echo(java.lang.String)
+ /**
+ * Name of the EJB
*/
- public String echo(String echo)
+ public static final String EJB_NAME = "SFSB";
+
+ /**
+ * @see org.jboss.test.profileservice.test.ejb3.TestCommonBusiness#echo(java.lang.String)
+ */
+ public String echo(final String echo)
{
return echo;
}
Modified: branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/TestStatelessBean.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/TestStatelessBean.java 2009-08-18 08:02:42 UTC (rev 92483)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/ejb3/TestStatelessBean.java 2009-08-18 08:03:19 UTC (rev 92484)
@@ -21,26 +21,32 @@
*/
package org.jboss.test.profileservice.test.ejb3;
+import javax.ejb.Local;
import javax.ejb.Remote;
import javax.ejb.Stateless;
/**
* TestStatelessBean
*
- * A test SLSB with no business methods
+ * A test SLSB
*
* @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
* @version $Revision: $
*/
- at Stateless
- at Remote(TestLocalBusiness.class)
-public class TestStatelessBean implements TestLocalBusiness
+ at Stateless(name = TestStatelessBean.EJB_NAME)
+ at Remote(TestRemoteBusiness.class)
+ at Local(TestLocalBusiness.class)
+public class TestStatelessBean implements TestLocalBusiness, TestRemoteBusiness
{
- /*
- * (non-Javadoc)
- * @see org.jboss.test.profileservice.test.ejb3.TestLocalBusiness#echo(java.lang.String)
+ /**
+ * Name of the EJB
*/
- public String echo(String echo)
+ public static final String EJB_NAME = "SLSB";
+
+ /**
+ * @see org.jboss.test.profileservice.test.ejb3.TestCommonBusiness#echo(java.lang.String)
+ */
+ public String echo(final String echo)
{
return echo;
}
More information about the jboss-cvs-commits
mailing list