Ejemplo n.º 1
0
  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);
  }
Ejemplo n.º 2
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"));
 }
Ejemplo n.º 3
0
  public void testSetContext() {
    Cloud cloud = getCloud();
    Transaction t = cloud.getTransaction("bar7");
    Node n = t.getNodeManager("news").createNode();

    assertEquals(1, t.getNodes().size());

    n.setContext("non_default");

    assertEquals(1, t.getNodes().size());

    assertEquals("non_default", n.getStringValue("owner"));
    assertEquals("non_default", n.getContext());

    assertEquals(1, t.getNodes().size());

    t.commit();

    Node n2 = cloud.getNode(n.getNumber());
    assertEquals("non_default", n2.getStringValue("owner"));
    assertEquals("non_default", n2.getContext());
  }
Ejemplo n.º 4
0
  // 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();
  }
Ejemplo n.º 5
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"));
  }