[jboss-cvs] JBossAS SVN: r60409 - trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/unit.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Feb 7 17:23:13 EST 2007
Author: bstansberry at jboss.com
Date: 2007-02-07 17:23:13 -0500 (Wed, 07 Feb 2007)
New Revision: 60409
Modified:
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/NestedBeanUnitTestCase.java
Log:
Tighten bean management
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/NestedBeanUnitTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/NestedBeanUnitTestCase.java 2007-02-07 22:21:49 UTC (rev 60408)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/NestedBeanUnitTestCase.java 2007-02-07 22:23:13 UTC (rev 60409)
@@ -73,9 +73,12 @@
public void testBasic()
throws Exception
{
- ParentStatefulRemote stateful = getParentSFSB();
- stateful.reset();
+ getLog().debug("Running testBasic()");
+ getLog().debug("==================================");
+ NestedBeanSet beanSet = getNestedBeanSet();
+ ParentStatefulRemote stateful = beanSet.parent;
+
assertEquals("Counter: ", 1, stateful.increment());
assertEquals("Counter: ", 2, stateful.increment());
assertEquals("Counter: ", 1, stateful.incrementLocal());
@@ -89,13 +92,15 @@
public void testDependentLifecycle()
throws Exception
{
- ParentStatefulRemote stateful = getParentSFSB();
- stateful.reset();
+ getLog().debug("Running testDependentLifecycle()");
+ getLog().debug("==================================");
+ NestedBeanSet beanSet = getNestedBeanSet();
+ ParentStatefulRemote stateful = beanSet.parent;
+
assertEquals("Counter: ", 1, stateful.increment());
- NestedStateful nested = stateful.getNested();
- removables.add(nested);
+ NestedStateful nested = beanSet.nested;
removeBean(stateful);
@@ -111,16 +116,18 @@
public void testStatefulPassivation()
throws Exception
{
- ParentStatefulRemote stateful = getParentSFSB();
- stateful.reset();
+ getLog().debug("Running testStatefulPassivation()");
+ getLog().debug("==================================");
+ NestedBeanSet beanSet = getNestedBeanSet();
+ ParentStatefulRemote stateful = beanSet.parent;
+
assertEquals("Counter: ", 1, stateful.increment());
assertEquals("Counter: ", 2, stateful.increment());
assertEquals("Counter: ", 1, stateful.incrementLocal());
assertEquals("Counter: ", 2, stateful.incrementLocal());
- NestedStateful nested = stateful.getNested();
- removables.add(nested);
+ NestedStateful nested = beanSet.nested;
_sleep(2500); // should passivate
@@ -148,17 +155,18 @@
public void testStatefulRepeatedPassivation()
throws Exception
{
- ParentStatefulRemote stateful = getParentSFSB();
- stateful.reset();
+ getLog().debug("Running testStatefulRepeatedPassivation()");
+ getLog().debug("=========================================");
+
+ NestedBeanSet beanSet = getNestedBeanSet();
+ ParentStatefulRemote stateful = beanSet.parent;
+ NestedStateful nested = beanSet.nested;
assertEquals("Counter: ", 1, stateful.increment());
assertEquals("Counter: ", 2, stateful.increment());
assertEquals("Counter: ", 1, stateful.incrementLocal());
assertEquals("Counter: ", 2, stateful.incrementLocal());
- NestedStateful nested = stateful.getNested();
- removables.add(nested);
-
_sleep(10000); // should passivate
assertEquals(1, stateful.getPrePassivate());
@@ -170,9 +178,8 @@
assertEquals("Counter: ", 3, stateful.increment());
assertEquals("Counter: ", 4, stateful.increment());
assertEquals("Counter: ", 3, stateful.incrementLocal());
- assertEquals("Counter: ", 4, stateful.incrementLocal());
+ assertEquals("Counter: ", 4, stateful.incrementLocal());
-
_sleep(10000); // should passivate
assertEquals(2, stateful.getPrePassivate());
@@ -203,21 +210,29 @@
getLog().debug("ok");
}
- protected ParentStatefulRemote getParentSFSB()
+ protected NestedBeanSet getNestedBeanSet()
throws Exception
{
getLog().debug(++NestedBeanUnitTestCase.test +"- "+"Trying the context...");
InitialContext ctx = getInitialContext();
- getLog().debug("Test Stateful Bean passivation");
- getLog().debug("==================================");
getLog().debug(++NestedBeanUnitTestCase.test +"- "
+"Looking up testParentStateful...");
- ParentStatefulRemote stateful = (ParentStatefulRemote) ctx.lookup("testParentStateful/remote");
- removables.add(stateful);
+ ParentStatefulRemote parent = (ParentStatefulRemote) ctx.lookup("testParentStateful/remote");
+ removables.add(parent);
- return stateful;
+ // Reset the parent to clean things up
+ parent.reset();
+
+ NestedStateful nested = parent.getNested();
+ removables.add(nested);
+
+ NestedBeanSet result = new NestedBeanSet();
+ result.parent = parent;
+ result.nested = nested;
+
+ return result;
}
protected void _sleep(long time)
@@ -234,4 +249,10 @@
bean.remove();
removables.remove(bean);
}
+
+ protected static class NestedBeanSet
+ {
+ ParentStatefulRemote parent;
+ NestedStateful nested;
+ }
}
More information about the jboss-cvs-commits
mailing list