[jboss-cvs] JBossAS SVN: r61174 - in branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test: stateful/unit and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Mar 6 22:35:57 EST 2007
Author: bdecoste
Date: 2007-03-06 22:35:57 -0500 (Tue, 06 Mar 2007)
New Revision: 61174
Added:
branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdb/unit/MetricsUnitTestCase.java
branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/stateless/unit/MetricsUnitTestCase.java
Modified:
branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/MetricsUnitTestCase.java
Log:
[EJBTHREE-825] added stateless and mdb metrics tests
Added: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdb/unit/MetricsUnitTestCase.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdb/unit/MetricsUnitTestCase.java (rev 0)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdb/unit/MetricsUnitTestCase.java 2007-03-07 03:35:57 UTC (rev 61174)
@@ -0,0 +1,119 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.ejb3.test.mdb.unit;
+
+import javax.management.MBeanServerConnection;
+
+import org.jboss.logging.Logger;
+import org.jboss.test.JBossTestCase;
+import junit.framework.Test;
+
+import javax.management.MBeanServerConnection;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public class MetricsUnitTestCase
+extends JBossTestCase
+{
+ private static final Logger log = Logger.getLogger(MetricsUnitTestCase.class);
+
+
+ public MetricsUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testJmxMetrics() throws Exception
+ {
+ MBeanServerConnection server = getServer();
+
+// testJmxMetrics(server, "Stateful", "jboss.j2ee:jar=stateful-test.jar,name=StatefulBean,service=EJB3");
+// testJmxMetrics(server, "TreeCacheStateful", "jboss.j2ee:jar=stateful-test.jar,name=TreeCacheStatefulBean,service=EJB3");
+ }
+
+ protected void testJmxMetrics(MBeanServerConnection server, String jndiBinding, String objectName) throws Exception
+ {
+ /* ObjectName testerName = new ObjectName(objectName);
+
+ System.out.println("testPassivation");
+ Stateful stateful = (Stateful)getInitialContext().lookup(jndiBinding);
+ assertNotNull(stateful);
+ stateful.setState("state");
+
+ int count = (Integer)server.getAttribute(testerName, "CreateCount");
+ assertEquals(1, count);
+
+ int size = (Integer)server.getAttribute(testerName, "CacheSize");
+ assertEquals(1, size);
+
+ assertEquals("state", stateful.getState());
+ stateful.testSerializedState("state");
+ stateful.clearPassivated();
+ assertEquals(null, stateful.getInterceptorState());
+ stateful.setInterceptorState("hello world");
+ assertFalse(stateful.testSessionContext());
+ Thread.sleep(10 * 1000);
+
+ size = (Integer)server.getAttribute(testerName, "CacheSize");
+ assertEquals(0, size);
+
+ count = (Integer)server.getAttribute(testerName, "PassivatedCount");
+ assertEquals(1, count);
+ assertTrue(stateful.wasPassivated());
+
+ assertEquals("state", stateful.getState());
+ assertEquals("hello world", stateful.getInterceptorState());
+
+ Stateful another = (Stateful)getInitialContext().lookup(jndiBinding);
+ assertEquals(null, another.getInterceptorState());
+ another.setInterceptorState("foo");
+ assertEquals("foo", another.getInterceptorState());
+ assertEquals("hello world", stateful.getInterceptorState());
+
+ assertFalse(stateful.testSessionContext());
+
+ // Wolf: transient re-injection is broken (EJBTHREE-883)
+ //stateful.testResources();
+
+ count = (Integer)server.getAttribute(testerName, "CreateCount");
+ assertEquals(2, count);
+
+ size = (Integer)server.getAttribute(testerName, "CacheSize");
+ assertEquals(2, size);
+
+ another.removeBean();
+ size = (Integer)server.getAttribute(testerName, "CacheSize");
+ assertEquals(1, size);
+
+ stateful.removeBean();
+ size = (Integer)server.getAttribute(testerName, "CacheSize");
+ assertEquals(0, size);*/
+
+ }
+
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(MetricsUnitTestCase.class, "mdbtest-service.xml, mdb-test.jar");
+ }
+
+}
Modified: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/MetricsUnitTestCase.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/MetricsUnitTestCase.java 2007-03-07 03:32:38 UTC (rev 61173)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/MetricsUnitTestCase.java 2007-03-07 03:35:57 UTC (rev 61174)
@@ -54,9 +54,6 @@
{
private static final Logger log = Logger.getLogger(MetricsUnitTestCase.class);
- static boolean deployed = false;
- static int test = 0;
-
public MetricsUnitTestCase(String name)
{
Added: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/stateless/unit/MetricsUnitTestCase.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/stateless/unit/MetricsUnitTestCase.java (rev 0)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/stateless/unit/MetricsUnitTestCase.java 2007-03-07 03:35:57 UTC (rev 61174)
@@ -0,0 +1,101 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.ejb3.test.stateless.unit;
+
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+
+import org.jboss.ejb3.test.stateless.StatelessRemote;
+import org.jboss.logging.Logger;
+import org.jboss.test.JBossTestCase;
+import junit.framework.Test;
+
+import javax.management.MBeanServerConnection;
+
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public class MetricsUnitTestCase
+extends JBossTestCase
+{
+ private static final Logger log = Logger.getLogger(MetricsUnitTestCase.class);
+
+ public MetricsUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testDefaultJmxMetrics() throws Exception
+ {
+ MBeanServerConnection server = getServer();
+ ObjectName testerName = new ObjectName("jboss.j2ee:jar=stateless-test.jar,name=DefaultPoolStatelessBean,service=EJB3");
+
+ int size = 0;
+
+ size = (Integer)server.getAttribute(testerName, "CurrentSize");
+ assertEquals(-1, size);
+
+ StatelessRemote stateless = (StatelessRemote)getInitialContext().lookup("DefaultPoolStatelessBean/remote");
+ assertNotNull(stateless);
+ stateless.test();
+
+ size = (Integer)server.getAttribute(testerName, "CurrentSize");
+ assertEquals(-1, size);
+
+ size = (Integer)server.getAttribute(testerName, "AvailableCount");
+ assertEquals(-1, size);
+
+ size = (Integer)server.getAttribute(testerName, "MaxSize");
+ assertEquals(-1, size);
+
+ }
+
+ public void testStrictMaxPoolJmxMetrics() throws Exception
+ {
+ MBeanServerConnection server = getServer();
+ ObjectName testerName = new ObjectName("jboss.j2ee:jar=stateless-test.jar,name=StrictMaxPoolStatelessBean,service=EJB3");
+ int size = 0;
+
+ size = (Integer)server.getAttribute(testerName, "CurrentSize");
+ assertEquals(0, size);
+
+ StatelessRemote stateless = (StatelessRemote)getInitialContext().lookup("StrictMaxPoolStatelessBean/remote");
+ assertNotNull(stateless);
+ stateless.test();
+
+ size = (Integer)server.getAttribute(testerName, "CurrentSize");
+ assertEquals(1, size);
+
+ size = (Integer)server.getAttribute(testerName, "AvailableCount");
+ assertEquals(123, size);
+
+ size = (Integer)server.getAttribute(testerName, "MaxSize");
+ assertEquals(123, size);
+ }
+
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(MetricsUnitTestCase.class, "stateless-test.jar");
+ }
+
+}
More information about the jboss-cvs-commits
mailing list