Update of /var/cvs/tests/bridge/org/mmbase/bridge
In directory james.mmbase.org:/tmp/cvs-serv7530
Modified Files:
TransactionTest.java
Log Message:
test-case to prove MMB-1680 (plus some other test-cases, which are succeeding
See also: http://cvs.mmbase.org/viewcvs/tests/bridge/org/mmbase/bridge
See also: http://www.mmbase.org/jira/browse/MMB-1680
Index: TransactionTest.java
===================================================================
RCS file: /var/cvs/tests/bridge/org/mmbase/bridge/TransactionTest.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- TransactionTest.java 7 Jul 2008 15:16:37 -0000 1.7
+++ TransactionTest.java 15 Jul 2008 11:44:22 -0000 1.8
@@ -16,7 +16,7 @@
* Test class <code>Transaction</code> from the bridge package.
*
* @author Michiel Meeuwissen
- * @version $Id: TransactionTest.java,v 1.7 2008/07/07 15:16:37 michiel Exp $
+ * @version $Id: TransactionTest.java,v 1.8 2008/07/15 11:44:22 michiel Exp $
* @since MMBase-1.8.6
*/
public class TransactionTest extends BridgeTest {
@@ -26,16 +26,25 @@
}
int newNode;
+ int newNode2;
public void setUp() {
// Create some test nodes
Cloud cloud = getCloud();
+ {
Node node = cloud.getNodeManager("news").createNode();
node.setStringValue("title", "foo");
node.commit();
newNode = node.getNumber();
}
+ {
+ Node node = cloud.getNodeManager("news").createNode();
+ node.setStringValue("title", "foo");
+ node.commit();
+ newNode2 = node.getNumber();
+ }
+ }
public void testCancel() {
Cloud cloud = getCloud();
@@ -140,6 +149,78 @@
Node n2 = cloud.getNode(n.getNumber());
assertEquals("non_default", n2.getContext());
}
+ public void testSetContextSubTransaction() {
+ Cloud cloud = getCloud();
+
+ Transaction ot = cloud.getTransaction("bar8");
+ Transaction t = ot.getTransaction("bar9");
+ Node n = t.getNodeManager("news").createNode();
+ n.setContext("non_default");
+ assertEquals("non_default", n.getContext());
+ t.commit();
+
+ Node n2 = ot.getNode(n.getNumber());
+ assertEquals("non_default", n2.getContext());
+
+ ot.commit();
+ Node n3 = cloud.getNode(n.getNumber());
+ assertEquals("non_default", n3.getContext());
+ }
+
+ public void testEditNodeOutsideTransaction() {
+ Cloud cloud = getCloud();
+ Transaction t = cloud.getTransaction("bar10");
+ Node nodeInTransaction = t.getNode(newNode2);
+ nodeInTransaction.setStringValue("title", "foo2");
+ Node nodeOutTransaction = cloud.getNode(newNode2);
+ nodeOutTransaction.setStringValue("title", "bar2");
+
+ nodeOutTransaction.commit();
+ t.commit();
+
+ // transaction was committed _later_ so its commit of the node must
have won
+ assertEquals("foo2", cloud.getNode(newNode2).getStringValue("title"));
+ assertEquals("foo2", nodeInTransaction.getStringValue("title"));
+ //assertEquals("foo2", nodeOutTransaction.getStringValue("title")); //
not sure what this should have done, but anyhow, it now fails
+
+ }
+ public void testEditNodeOutsideTransaction2() {
+ Cloud cloud = getCloud();
+ Transaction t = cloud.getTransaction("bar10");
+ Node nodeInTransaction = t.getNode(newNode2);
+ nodeInTransaction.setStringValue("title", "foo2");
+ Node nodeOutTransaction = cloud.getNode(newNode2);
+ nodeOutTransaction.setStringValue("title", "bar2");
+
+ t.commit();
+ nodeOutTransaction.commit();
+
+ // transaction was committed _earlier_ so the commit of the node must
have won
+ assertEquals("bar2", cloud.getNode(newNode2).getStringValue("title"));
+ //assertEquals("bar2", nodeInTransaction.getStringValue("title"));//
not sure what this should have done, but anyhow, it now fails
+ assertEquals("bar2", nodeOutTransaction.getStringValue("title"));
+
+ }
+
+ public void testDeleteNodeOutsideTransaction() {
+ Cloud cloud = getCloud();
+ Transaction t = cloud.getTransaction("bar11");
+ Node nodeInTransaction = t.getNode(newNode2);
+ nodeInTransaction.setStringValue("title", "foo2");
+ {
+ // now delete the node
+ Node nodeOutTransaction = cloud.getNode(newNode2);
+ nodeOutTransaction.delete();
+ assertFalse(cloud.hasNode(newNode2));
+ }
+
+
+ t.commit();
+
+ assertFalse(cloud.hasNode(newNode2));
+ }
+
+
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs