[jboss-cvs] JBossAS SVN: r58783 - branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/unit
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Nov 30 18:13:34 EST 2006
Author: bstansberry at jboss.com
Date: 2006-11-30 18:13:34 -0500 (Thu, 30 Nov 2006)
New Revision: 58783
Modified:
branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/unit/EntityUnitTestCase.java
Log:
Add a db cleanup method so test can be repeated multiple times without restarting cluster
Add a pause following an async repl to avoid spurious timing failures
Modified: branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/unit/EntityUnitTestCase.java
===================================================================
--- branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/unit/EntityUnitTestCase.java 2006-11-30 23:12:21 UTC (rev 58782)
+++ branches/Branch_4_0/ejb3/src/test/org/jboss/ejb3/test/clusteredentity/unit/EntityUnitTestCase.java 2006-11-30 23:13:34 UTC (rev 58783)
@@ -40,6 +40,8 @@
{
org.apache.log4j.Category log = getLog();
+ protected static final long SLEEP_TIME = 300L;
+
static boolean deployed = false;
static int test = 0;
@@ -77,31 +79,43 @@
System.out.println("Create node 0");
EntityTest tester0 = (EntityTest)ctx0.lookup("EntityTestBean/remote");
- Customer customer = tester0.createCustomer();
- //Call finder twice since Hibernate seems to not actually save collections
- //into cache on persist(), so make sure it is put into cache on find.
- System.out.println("Find node 0");
- customer = tester0.findByCustomerId(customer.getId());
- System.out.println("Find(2) node 0");
- customer = tester0.findByCustomerId(customer.getId());
-
- //Check everything was in cache
- System.out.println("Check cache 0");
- tester0.loadedFromCache();
-
- //Now connect to cache on node2 and make sure it is all there
- System.out.println("Lookup node 1");
- InitialContext ctx1 = new InitialContext(prop1);
-
- EntityTest tester1 = (EntityTest)ctx1.lookup("EntityTestBean/remote");
- System.out.println("Find node 1");
- customer = tester1.findByCustomerId(customer.getId());
-
- //Check everything was in cache
- System.out.println("Check cache 1");
- tester1.loadedFromCache();
-
+ try
+ {
+ Customer customer = tester0.createCustomer();
+
+ //Call finder twice since Hibernate seems to not actually save collections
+ //into cache on persist(), so make sure it is put into cache on find.
+ System.out.println("Find node 0");
+ customer = tester0.findByCustomerId(customer.getId());
+ System.out.println("Find(2) node 0");
+ customer = tester0.findByCustomerId(customer.getId());
+
+ //Check everything was in cache
+ System.out.println("Check cache 0");
+ tester0.loadedFromCache();
+
+ // The above placement of the collection in the cache is replicated async
+ // so pause a bit before checking node 1
+ sleep(SLEEP_TIME);
+
+ //Now connect to cache on node2 and make sure it is all there
+ System.out.println("Lookup node 1");
+ InitialContext ctx1 = new InitialContext(prop1);
+
+ EntityTest tester1 = (EntityTest)ctx1.lookup("EntityTestBean/remote");
+ System.out.println("Find node 1");
+ customer = tester1.findByCustomerId(customer.getId());
+
+ //Check everything was in cache
+ System.out.println("Check cache 1");
+ tester1.loadedFromCache();
+ }
+ finally
+ {
+ // cleanup the db so we can run this test multiple times w/o restarting the cluster
+ tester0.cleanup();
+ }
}
public static Test suite() throws Exception
More information about the jboss-cvs-commits
mailing list