[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/transaction ...
Manik Surtani
msurtani at jboss.com
Tue Nov 28 22:20:53 EST 2006
User: msurtani
Date: 06/11/28 22:20:53
Modified: tests/functional/org/jboss/cache/transaction Tag:
Branch_JBossCache_1_3_0 TransactionTest.java
Log:
fixed more bugs
Revision Changes Path
No revision
No revision
1.9.2.6 +60 -6 JBossCache/tests/functional/org/jboss/cache/transaction/TransactionTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: TransactionTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/transaction/TransactionTest.java,v
retrieving revision 1.9.2.5
retrieving revision 1.9.2.6
diff -u -b -r1.9.2.5 -r1.9.2.6
--- TransactionTest.java 27 Nov 2006 17:41:01 -0000 1.9.2.5
+++ TransactionTest.java 29 Nov 2006 03:20:53 -0000 1.9.2.6
@@ -27,7 +27,7 @@
* Tests transactional access to a local TreeCache.
* Note: we use DummpyTranasctionManager to replace jta
*
- * @version $Id: TransactionTest.java,v 1.9.2.5 2006/11/27 17:41:01 msurtani Exp $
+ * @version $Id: TransactionTest.java,v 1.9.2.6 2006/11/29 03:20:53 msurtani Exp $
*/
public class TransactionTest extends TestCase {
TreeCache cache=null;
@@ -381,6 +381,59 @@
}
}
+ public void testIntermediateNodeCreationOnWrite() throws Exception
+ {
+ cache.put("/a", null);
+ tx.begin();
+ cache.put("/a/b/c", null);
+ // expecting WLs on /a, /a/b and /a/b/c.
+ GlobalTransaction gtx=cache.getCurrentTransaction();
+ assertLocked(gtx, "/a", true);
+ assertLocked(gtx, "/a/b", true);
+ assertLocked(gtx, "/a/b/c", true);
+ tx.rollback();
+
+ }
+
+ public void testIntermediateNodeCreationOnRead() throws Exception
+ {
+ cache.put("/a", null);
+ tx.begin();
+ cache.get("/a/b/c");
+
+ // expecting RLs on /, /a
+ // /a/b, /a/b/c should NOT be created!
+ GlobalTransaction gtx=cache.getCurrentTransaction();
+ assertLocked(gtx, "/", false);
+ assertLocked(gtx, "/a", false);
+ assertNull("/a/b should not exist", cache.peek(Fqn.fromString("/a/b")));
+ assertNull("/a/b/c should not exist", cache.peek(Fqn.fromString("/a/b/c")));
+ tx.rollback();
+ assertNull("/a/b should not exist", cache.peek(Fqn.fromString("/a/b")));
+ assertNull("/a/b/c should not exist", cache.peek(Fqn.fromString("/a/b/c")));
+
+ }
+
+
+ public void testIntermediateNodeCreationOnRemove() throws Exception
+ {
+ cache.put("/a", null);
+ tx.begin();
+ cache.remove("/a/b/c");
+
+ // expecting RLs on /, /a
+ // /a/b, /a/b/c should NOT be created!
+ GlobalTransaction gtx=cache.getCurrentTransaction();
+ assertLocked(gtx, "/", false);
+ assertLocked(gtx, "/a", false);
+ assertNull("/a/b should not exist", cache.peek(Fqn.fromString("/a/b")));
+ assertNull("/a/b/c should not exist", cache.peek(Fqn.fromString("/a/b/c")));
+ tx.rollback();
+ assertNull("/a/b should not exist", cache.peek(Fqn.fromString("/a/b")));
+ assertNull("/a/b/c should not exist", cache.peek(Fqn.fromString("/a/b/c")));
+
+ }
+
public void testNodeDeletionRollback3() throws Exception{
GlobalTransaction gtx;
@@ -463,10 +516,10 @@
owner=Thread.currentThread();
assertTrue("node " + fqn + " is not locked", lock.isLocked());
if(write_locked) {
- assertTrue("node " + fqn + " is not write-locked", lock.isWriteLocked());
+ assertTrue("node " + fqn + " is not write-locked" + (lock.isReadLocked() ? " but is read-locked instead!" : "!"), lock.isWriteLocked());
}
else {
- assertTrue("node " + fqn + " is not read-locked", lock.isReadLocked());
+ assertTrue("node " + fqn + " is not read-locked" + (lock.isWriteLocked() ? " but is write-locked instead!" : "!"), lock.isReadLocked());
}
assertTrue("owner " + owner + "is not owner", lock.isOwner(owner));
}
@@ -551,7 +604,8 @@
cache.remove("/a/b/c");
System.out.println("locks held (after removing /a/b/c): \n" + cache.printLockInfo());
// this used to test for 2 locks held. After the fixes for JBCACHE-875 however, 2 more locks are acquired - for the root node as well as the deleted node.
- assertEquals(4, cache.getNumberOfLocksHeld());
+ // and since we would lock all children of the deleted node as well, we have 10 locks here.
+ assertEquals(10, cache.getNumberOfLocksHeld());
tx.commit();
System.out.println("locks held (after committing /a/b/c): \n" + cache.printLockInfo());
assertEquals(0, cache.getNumberOfLocksHeld());
@@ -572,7 +626,7 @@
System.out.println("locks held (before removing /a/b/c): \n" + cache.printLockInfo());
cache.remove("/a/b/c");
System.out.println("locks held (after removing /a/b/c): \n" + cache.printLockInfo());
- assertEquals(4, cache.getNumberOfLocksHeld());
+ assertEquals(10, cache.getNumberOfLocksHeld());
tx.rollback();
System.out.println("locks held (after rollback): \n" + cache.printLockInfo());
assertEquals(0, cache.getNumberOfLocksHeld());
@@ -760,7 +814,7 @@
cache.remove(FQN);
cache.put(FQN, "entry", "rollback");
tx.rollback();
- assertEquals("Node should keep the commited value", "commit", cache.get(FQN).get("entry")); // THIS FAILS
+ assertEquals("Node should keep the commited value", "commit", cache.get(FQN).get("entry"));
}
More information about the jboss-cvs-commits
mailing list