[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/options ...
Manik Surtani
msurtani at jboss.com
Tue Jan 30 17:23:50 EST 2007
User: msurtani
Date: 07/01/30 17:23:50
Modified: tests/functional/org/jboss/cache/options Tag:
Branch_JBossCache_1_4_0 ExplicitVersionsTest.java
ExplicitVersionsReplTest.java
Log:
JBCACHE-953
Revision Changes Path
No revision
No revision
1.3.4.4 +30 -4 JBossCache/tests/functional/org/jboss/cache/options/ExplicitVersionsTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ExplicitVersionsTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/options/ExplicitVersionsTest.java,v
retrieving revision 1.3.4.3
retrieving revision 1.3.4.4
diff -u -b -r1.3.4.3 -r1.3.4.4
--- ExplicitVersionsTest.java 10 Jan 2007 18:42:05 -0000 1.3.4.3
+++ ExplicitVersionsTest.java 30 Jan 2007 22:23:50 -0000 1.3.4.4
@@ -137,10 +137,38 @@
assertEquals(1, ((DefaultDataVersion)((OptimisticTreeNode)cache.get("/org/domain/Entity")).getVersion()).getRawVersion());
assertEquals(v, ((OptimisticTreeNode)cache.get("/org/domain/Entity/EntityInstance#1")).getVersion());
}
-}
+ public void testExplicitVersionOnParentAndChild() throws Exception
+ {
+ TestVersion vParent = new TestVersion("Parent-Version");
+ Option o = new Option();
+ o.setDataVersion(vParent);
+
+ cache.getTransactionManager().begin();
+ cache.put(Fqn.fromString("/parent"), "k", "v", o);
+ cache.getTransactionManager().commit();
+
+ assertEquals(0, ((DefaultDataVersion)((OptimisticTreeNode)cache.get("/")).getVersion()).getRawVersion());
+ assertEquals(vParent, ((OptimisticTreeNode)cache.get("/parent")).getVersion());
+
+ TestVersion vChild = new TestVersion("Child-Version");
+ o = new Option();
+ o.setDataVersion(vChild);
+
+ cache.getTransactionManager().begin();
+ cache.put(Fqn.fromString("/parent/child"), "k", "v", o);
+ cache.getTransactionManager().commit();
+
+ assertEquals(0, ((DefaultDataVersion)((OptimisticTreeNode)cache.get("/")).getVersion()).getRawVersion());
+ assertEquals(vParent, ((OptimisticTreeNode)cache.get("/parent")).getVersion());
+ assertEquals(vChild, ((OptimisticTreeNode)cache.get("/parent/child")).getVersion());
+ }
+}
+/**
+ * Note that this uses STRING comparisons!!
+ */
class TestVersion implements DataVersion
{
private String myVersion;
@@ -164,9 +192,7 @@
{
if (other instanceof TestVersion)
{
- int myInt = Integer.parseInt( myVersion );
- int otherInt = Integer.parseInt( ((TestVersion) other).getInternalVersion() );
- return myInt > otherInt;
+ return myVersion.compareTo(((TestVersion) other).getInternalVersion()) > 0;
}
else throw new IllegalArgumentException("version type mismatch");
}
1.1.2.5 +33 -0 JBossCache/tests/functional/org/jboss/cache/options/ExplicitVersionsReplTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ExplicitVersionsReplTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/options/ExplicitVersionsReplTest.java,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -b -r1.1.2.4 -r1.1.2.5
--- ExplicitVersionsReplTest.java 10 Jan 2007 18:42:05 -0000 1.1.2.4
+++ ExplicitVersionsReplTest.java 30 Jan 2007 22:23:50 -0000 1.1.2.5
@@ -335,4 +335,37 @@
}
+ public void testExplicitVersionOnParentAndChild() throws Exception
+ {
+ TestVersion vParent = new TestVersion("Parent-Version");
+ Option o = new Option();
+ o.setDataVersion(vParent);
+
+ cache[0].getTransactionManager().begin();
+ cache[0].put(Fqn.fromString("/parent"), "k", "v", o);
+ cache[0].getTransactionManager().commit();
+
+ assertEquals(0, ((DefaultDataVersion)((OptimisticTreeNode)cache[0].get("/")).getVersion()).getRawVersion());
+ assertEquals(vParent, ((OptimisticTreeNode)cache[0].get("/parent")).getVersion());
+ assertEquals(0, ((DefaultDataVersion)((OptimisticTreeNode)cache[1].get("/")).getVersion()).getRawVersion());
+ assertEquals(vParent, ((OptimisticTreeNode)cache[1].get("/parent")).getVersion());
+
+
+ TestVersion vChild = new TestVersion("Child-Version");
+ o = new Option();
+ o.setDataVersion(vChild);
+
+ cache[0].getTransactionManager().begin();
+ cache[0].put(Fqn.fromString("/parent/child"), "k", "v", o);
+ cache[0].getTransactionManager().commit();
+
+ assertEquals(0, ((DefaultDataVersion)((OptimisticTreeNode)cache[0].get("/")).getVersion()).getRawVersion());
+ assertEquals(vParent, ((OptimisticTreeNode)cache[0].get("/parent")).getVersion());
+ assertEquals(vChild, ((OptimisticTreeNode)cache[0].get("/parent/child")).getVersion());
+ assertEquals(0, ((DefaultDataVersion)((OptimisticTreeNode)cache[1].get("/")).getVersion()).getRawVersion());
+ assertEquals(vParent, ((OptimisticTreeNode)cache[1].get("/parent")).getVersion());
+ assertEquals(vChild, ((OptimisticTreeNode)cache[1].get("/parent/child")).getVersion());
+
+ }
+
}
More information about the jboss-cvs-commits
mailing list