[jboss-cvs] JBossAS SVN: r65850 - branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/unit.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Oct 4 12:34:42 EDT 2007
Author: bstansberry at jboss.com
Date: 2007-10-04 12:34:41 -0400 (Thu, 04 Oct 2007)
New Revision: 65850
Modified:
branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/unit/NestedBeanUnitTestCase.java
Log:
[EJBTHREE-1053] Add test specifically for EJBTHREE-1053; remove convoluted stuff in testStatefulPassivation that leads to EJBTHREE-1053
Modified: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/unit/NestedBeanUnitTestCase.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/unit/NestedBeanUnitTestCase.java 2007-10-04 16:30:36 UTC (rev 65849)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/unit/NestedBeanUnitTestCase.java 2007-10-04 16:34:41 UTC (rev 65850)
@@ -13,8 +13,12 @@
import javax.naming.Context;
import javax.naming.InitialContext;
+import junit.framework.Assert;
import junit.framework.Test;
+import org.jboss.ejb3.test.JBossWithKnownIssuesTestCase;
+import org.jboss.ejb3.test.stateful.nested.base.std.NestedBeanMonitor;
+import org.jboss.ejb3.test.stateful.nested.base.std.NestedStateful;
import org.jboss.ejb3.test.stateful.nested.base.std.ParentStatefulRemote;
import org.jboss.ejb3.test.stateful.unit.NestedBeanTestRunner;
import org.jboss.ejb3.test.stateful.unit.NestedBeanTestRunner.NestedBeanSet;
@@ -167,4 +171,75 @@
getLog().debug("ok");
}
+ /**
+ * FIXME This is a very weak test for EJBTHREE-1053;
+ * replace with something better when EJBTHREE-1053 is fixed
+ *
+ * @throws Exception
+ */
+ public void testConsistentPassivatedState()
+ throws Exception
+ {
+ getLog().debug("Running testConsistentPassivatedState()");
+ getLog().debug("=======================================");
+
+ NestedBeanSet beanSet = runner.getNestedBeanSet();
+ NestedBeanMonitor monitor = beanSet.monitor;
+ ParentStatefulRemote parent = beanSet.parent;
+ NestedStateful nested = beanSet.nested;
+
+ int parentInv = beanSet.parentInvocations;
+ int nestedInv = beanSet.nestedInvocations;
+
+ Assert.assertEquals("Remote counter: ", 1, parent.increment());
+ parentInv++;
+ nestedInv++;
+ Assert.assertEquals("Remote counter: ", 2, parent.increment());
+ parentInv++;
+ nestedInv++;
+ Assert.assertEquals("Local counter: ", 1, parent.incrementLocal());
+ parentInv++;
+ Assert.assertEquals("Local counter: ", 2, parent.incrementLocal());
+ parentInv++;
+
+ sleep(runner.getSleepTime()); // should passivate
+
+ // Invoke on nested bean using *our* proxy.
+ // NOTE: these calls do not trigger replication due to how
+ // they implement Optimized
+ Assert.assertEquals("Parent passivate count: ",
+ runner.getExpectedPassivations(1, parentInv),
+ parent.getPrePassivate());
+ parentInv++;
+ Assert.assertEquals("Parent activate count: ",
+ runner.getExpectedPassivations(1, parentInv),
+ parent.getPostActivate());
+ parentInv++;
+ Assert.assertEquals("Remote nested passivate count: ",
+ runner.getExpectedPassivations(1, nestedInv),
+ nested.getPrePassivate());
+ Assert.assertEquals("Remote nested activate count: ",
+ runner.getExpectedPassivations(1, nestedInv),
+ nested.getPostActivate());
+
+ // Use the monitor to check the deep nested beans. In a cluster these
+ // are marked not to treat replication as passivation, so we ignore
+ // the number of invocations
+
+ // NOTE: here the invocation goes through the monitor, which has never
+ // used its proxy before. It may pick a different target server than that
+ // used by our 'nested' variable's proxy. If so, we then test if the
+ // state is as expected on the 2nd server.
+ // If by chance it picks the same target as 'nested', this test is meaningless
+ // So, any failures will be transient
+ // TODO if JBCACHE-1190 is fixed this test may need some re-work
+ int dnp = monitor.getDeepNestedPassivations();
+ if (monitor.getDeepNestedPassivations() != 1)
+ {
+ JBossWithKnownIssuesTestCase.showKnownIssue("EJBTHREE-1053", "Deep nested passivate count incorrect: expected 1, was " + dnp);
+ }
+
+ getLog().debug("ok");
+ }
+
}
More information about the jboss-cvs-commits
mailing list