public void testAlias() { Cloud cloud = getCloud(); { Node node = cloud.getNode(newNode2); node.setStringValue("title", "abcdef"); node.commit(); assertEquals("abcdef", node.getStringValue("title")); node = cloud.getNode("test.news." + seq); assertEquals("abcdef", node.getStringValue("title")); } { Transaction t = cloud.getTransaction("bar12"); Node node = t.getNode(newNode2); node.setStringValue("title", "abcdefg"); node.commit(); assertEquals("abcdefg", node.getStringValue("title")); t.commit(); assertEquals("abcdefg", node.getStringValue("title")); node = cloud.getNode("test.news." + seq); assertEquals("abcdefg", node.getStringValue("title")); node = cloud.getNode(newNode2); assertEquals("abcdefg", node.getStringValue("title")); } }
// MMB-1893 public void testDeleteNodeWitRelationsAndCancel() { Cloud cloud = getCloud(); int urlCount0 = Queries.count(cloud.getNodeManager("urls").createQuery()); int relCount0 = Queries.count(cloud.getNodeManager("insrel").createQuery()); Node url = cloud.getNodeManager("urls").createNode(); url.commit(); Node news = cloud.getNode(newNode); RelationManager rm = cloud.getRelationManager("urls", "news", "posrel"); Relation r = url.createRelation(news, rm); r.commit(); int urlCount = Queries.count(cloud.getNodeManager("urls").createQuery()); int relCount = Queries.count(cloud.getNodeManager("insrel").createQuery()); assertEquals(urlCount0 + 1, urlCount); assertEquals(relCount0 + 1, relCount); Transaction t = cloud.getTransaction("deletewithrelationsandcancel"); Node turl = t.getNode(url.getNumber()); turl.delete(true); t.cancel(); int urlCountAfter = Queries.count(cloud.getNodeManager("urls").createQuery()); assertEquals(urlCount, urlCountAfter); int relCountAfter = Queries.count(cloud.getNodeManager("insrel").createQuery()); assertEquals(relCount, relCountAfter); // MMB-1893 }
// MMB-1889 public void testCreateRelationAndDeleteNode() { // Make a relation to an existing node. Then delete that node with the 'delete relations' // option'. Commit the transaction. // The new relations should not exist, since the node was deleted. // No errors. Cloud cloud = getCloud(); int urlCount = Queries.count(cloud.getNodeManager("urls").createQuery()); int relCount = Queries.count(cloud.getNodeManager("insrel").createQuery()); Node url = cloud.getNodeManager("urls").createNode(); url.commit(); Transaction t = cloud.getTransaction("relatedandelete"); Node turl = t.getNode(url.getNumber()); Node news = t.getNode(newNode); RelationManager rm = t.getRelationManager("urls", "news", "posrel"); Relation r = turl.createRelation(news, rm); r.commit(); turl.delete(true); t.commit(); int urlCountAfter = Queries.count(cloud.getNodeManager("urls").createQuery()); assertEquals(urlCount, urlCountAfter); int relCountAfter = Queries.count(cloud.getNodeManager("insrel").createQuery()); assertEquals(relCount, relCountAfter); }
// MMB-1860 (4) public void testRelateAndDeleteRelation() { // Make a relation between two nodes. Delete the relation again. Commit the transaction. // Te relation shouldn't exist Cloud cloud = getCloud(); int urlCount = Queries.count(cloud.getNodeManager("urls").createQuery()); int relCount = Queries.count(cloud.getNodeManager("insrel").createQuery()); Node newUrl = cloud.getNodeManager("urls").createNode(); newUrl.commit(); Transaction t = cloud.getTransaction("testrelateandeleterelation"); Node news = t.getNode(newNode); Node url = t.getNode(newUrl.getNumber()); RelationManager rm = t.getRelationManager("urls", "news", "posrel"); Relation r = url.createRelation(news, rm); r.commit(); r.delete(); t.commit(); int urlCountAfter = Queries.count(cloud.getNodeManager("urls").createQuery()); assertEquals(urlCount + 1, urlCountAfter); // But the relation should not exist, because it was deleted angain int relCountAfter = Queries.count(cloud.getNodeManager("insrel").createQuery()); assertEquals(relCount, relCountAfter); }
public void testCreateAndDelete2() { // Create new node. Request the node again. Delete that. Commit the transaction. // The new node must not exist. Cloud cloud = getCloud(); int urlCount = Queries.count(cloud.getNodeManager("urls").createQuery()); Transaction t = cloud.getTransaction("testcreateandelete"); Node url = t.getNodeManager("urls").createNode(); url.commit(); assertEquals(1, t.getNodes().size()); Node reurl = t.getNode(url.getNumber()); reurl.delete(); assertEquals( 1, t.getNodes() .size()); // 0 would also be an option, but the node remaisn in the transaction as // 'NOLONGER' t.commit(); int urlCountAfter = Queries.count(cloud.getNodeManager("urls").createQuery()); assertEquals(urlCount, urlCountAfter); }
public void setUp() { seq++; // 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.createAlias("test.news." + seq); node.setContext("default"); node.commit(); newNode2 = node.getNumber(); } }
public void testCancel() { Cloud cloud = getCloud(); Transaction t = cloud.getTransaction("cancel1"); Node node = t.getNode(newNode); node.setStringValue("title", "xxxxx"); node.commit(); t.cancel(); node = cloud.getNode(newNode); assertEquals("foo", node.getStringValue("title")); }
public void testCommit() { Cloud cloud = getCloud(); Transaction t = cloud.getTransaction("bar3"); Node node = t.getNode(newNode); node.setStringValue("title", "yyyyy"); node.commit(); t.commit(); node = cloud.getNode(newNode); assertEquals("yyyyy", node.getStringValue("title")); }
public void testReuseTransaction() { Cloud cloud = getCloud(); { Node node = cloud.getNode(newNode); node.setStringValue("title", "zzyyxx"); node.commit(); assertEquals("zzyyxx", cloud.getNode(newNode).getStringValue("title")); } { Transaction t = cloud.getTransaction("bar4"); assertEquals(0, t.getNodes().size()); Node node = t.getNode(newNode); assertEquals("zzyyxx", node.getStringValue("title")); assertEquals(1, t.getNodes().size()); node.setStringValue("title", "wwwwww"); node.commit(); assertEquals("wwwwww", node.getStringValue("title")); t.cancel(); assertEquals("zzyyxx", cloud.getNode(newNode).getStringValue("title")); } assertEquals("zzyyxx", cloud.getNode(newNode).getStringValue("title")); }
// MMB-1857 public void testGetNodes() { Cloud cloud = getCloud(); Transaction t = cloud.getTransaction("testgetnodes"); Node n = t.getNode(newNode); Node url = t.getNodeManager("urls").createNode(); RelationManager rm = t.getRelationManager("urls", "news", "posrel"); Relation r = url.createRelation(n, rm); { // should not give NPE's or so n.commit(); url.commit(); r.commit(); } assertEquals(3, t.getNodes().size()); // 2 nodes and one relation for (Node rn : t.getNodes()) { // should occur no exceptions rn.commit(); // should have little effect in trans } t.cancel(); }
public void testMMB1546() { Cloud cloud = getCloud(); Transaction t = cloud.getTransaction("test0"); Node nt = t.getNode(newNode); nt.setValue("title", "bla"); // t.cancel(); _DONT_ cancel Node nc = cloud.getNode(newNode); nc.setValue("title", "bloe"); nc.commit(); assertEquals("bloe", nc.getStringValue("title")); assertEquals("bloe", cloud.getNode(newNode).getStringValue("title")); t.cancel(); assertEquals("bloe", cloud.getNode(newNode).getStringValue("title")); }
public void testGetNode() { // Create new node. Request the node again. // Should work Cloud cloud = getCloud(); int urlCount = Queries.count(cloud.getNodeManager("urls").createQuery()); Transaction t = cloud.getTransaction("testgetnode"); Node url = t.getNodeManager("urls").createNode(); url.setStringValue("url", "http://bla"); url.commit(); Node reurl = t.getNode(url.getNumber()); assertEquals("http://bla", reurl.getStringValue("url")); }
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")); }
// Test for http://www.mmbase.org/jira/browse/MMB-1621 public void testGetValue() { Cloud cloud = getCloud(); String value = cloud.getNode(newNode).getStringValue("title"); assertFalse("zzzzz".equals(value)); Transaction t = cloud.getTransaction("bar4"); System.out.println("Transaction now " + t); Node node = t.getNode(newNode); assertEquals(1, t.getNodes().size()); node.setStringValue("title", "zzzzz"); assertEquals("zzzzz", node.getStringValue("title")); node.commit(); // committing inside transaction assertEquals("zzzzz", node.getStringValue("title")); assertEquals(value, cloud.getNode(newNode).getStringValue("title")); t.commit(); assertEquals("zzzzz", cloud.getNode(newNode).getStringValue("title")); }
public void testGetNodeTwiceWhileChanged() { Cloud cloud1 = getCloud(); String originalTitleValue = cloud1.getNode(newNode2).getStringValue("title"); { Node node = cloud1.getNode(newNode2); String title1 = node.getStringValue("title"); node.setStringValue("title", "bla bla"); // don't commit } // now change something by someone else { Cloud cloud2 = getCloud("foo"); assertTrue(cloud1 != cloud2); Node node = cloud2.getNode(newNode2); node.setStringValue("title", "new title value"); node.commit(); } // now look to the original cloud { Node node = cloud1.getNode(newNode2); assertEquals("new title value", node.getStringValue("title")); } }