예제 #1
0
  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"));
    }
  }
예제 #2
0
  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"));
  }
예제 #3
0
 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();
   }
 }
예제 #4
0
  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"));
  }
예제 #5
0
  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"));
  }
예제 #6
0
 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"));
 }
예제 #7
0
 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"));
   }
 }
예제 #8
0
  public void testGetTransaction() {
    Cloud cloud = getCloud();

    {
      Transaction t = cloud.getTransaction("gettransactiontest");
      Node node = t.getNode(newNode);
      node.setStringValue("title", "xxxxx");
    }
    {
      Transaction t = cloud.getTransaction("gettransactiontest");
      Node node = t.getNode(newNode);
      assertEquals("xxxxx", node.getStringValue("title"));
      t.cancel();
    }
  }
예제 #9
0
  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"));
  }
예제 #10
0
  // 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"));
  }
예제 #11
0
  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));
    }

    try {
      t.commit();
    } catch (Exception e) {
      // should not give exception. MMB-1680
      log.error(e.getMessage(), e);
      fail(e.getMessage());
    }

    assertTrue(cloud.hasNode(newNode2));
  }