[jboss-cvs] JBossAS SVN: r60106 - trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/unit.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jan 29 13:52:28 EST 2007
Author: bstansberry at jboss.com
Date: 2007-01-29 13:52:28 -0500 (Mon, 29 Jan 2007)
New Revision: 60106
Modified:
trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/NestedBeanUnitTestCase.java
Log:
Add a test for EJBTHREE-854
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-01-29 17:52:09 UTC (rev 60105)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/NestedBeanUnitTestCase.java 2007-01-29 18:52:28 UTC (rev 60106)
@@ -73,48 +73,53 @@
public void testBasic()
throws Exception
{
- getLog().debug(++NestedBeanUnitTestCase.test +"- "
- +"Trying the context...");
-
- // Connect to the server0 JNDI
- InitialContext ctx = getInitialContext();
-
- getLog().debug("Test Stateful Bean");
- getLog().debug("==================================");
- getLog().debug(++NestedBeanUnitTestCase.test +"- "
- +"Looking up testBasic...");
- ParentStatefulRemote stateful = (ParentStatefulRemote) ctx.lookup("testParentStateful/remote");
- removables.add(stateful);
+ ParentStatefulRemote stateful = getParentSFSB();
+ stateful.reset();
assertEquals("Counter: ", 1, stateful.increment());
assertEquals("Counter: ", 2, stateful.increment());
+ assertEquals("Counter: ", 1, stateful.incrementLocal());
+ assertEquals("Counter: ", 2, stateful.incrementLocal());
+ removeBean(stateful);
+
+ getLog().debug("ok");
+ }
+
+ public void testDependentLifecycle()
+ throws Exception
+ {
+ ParentStatefulRemote stateful = getParentSFSB();
+ stateful.reset();
+
+ assertEquals("Counter: ", 1, stateful.increment());
+
NestedStateful nested = stateful.getNested();
removables.add(nested);
-
+
removeBean(stateful);
-
- // Confirm nested still works following parent remove
- assertEquals("Counter: ", 3, nested.increment());
-
+
+ // Confirm nested no longer works following parent remove
+ try
+ {
+ nested.increment();
+ fail("Nested bean still exists following destruction of parent");
+ }
+ catch (Exception good)
+ {
+ // this is what we want -- nested has no independent lifecycle
+ }
+
removeBean(nested);
+
+ getLog().debug("ok");
- getLog().debug("ok");
}
public void testStatefulPassivation()
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 stateful = getParentSFSB();
stateful.reset();
assertEquals("Counter: ", 1, stateful.increment());
@@ -151,16 +156,7 @@
public void testStatefulRepeatedPassivation()
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 stateful = getParentSFSB();
stateful.reset();
assertEquals("Counter: ", 1, stateful.increment());
@@ -171,7 +167,7 @@
NestedStateful nested = stateful.getNested();
removables.add(nested);
- _sleep(10000); // should passivated
+ _sleep(10000); // should passivate
assertEquals(1, stateful.getPrePassivate());
assertEquals(1, stateful.getPostActivate());
@@ -185,7 +181,7 @@
assertEquals("Counter: ", 4, stateful.incrementLocal());
- _sleep(10000); // should passivated
+ _sleep(10000); // should passivate
assertEquals(2, stateful.getPrePassivate());
assertEquals(2, stateful.getPostActivate());
@@ -214,7 +210,24 @@
getLog().debug("ok");
}
+
+ protected ParentStatefulRemote getParentSFSB()
+ 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);
+
+ return stateful;
+ }
+
protected void _sleep(long time)
{
try {
More information about the jboss-cvs-commits
mailing list