Package org.infinispan.tree

Examples of org.infinispan.tree.Fqn


      assert map.size() == 1;
      assert map.get(fqn1).equals(34);
   }

   public void testEquals() {
      Fqn fqn1 = Fqn.fromElements("person/test");

      Fqn f1, f2, f3;

      f1 = Fqn.fromRelativeElements(fqn1, "0");
      f2 = Fqn.fromRelativeElements(fqn1, "1");
      f3 = Fqn.fromRelativeElements(fqn1, "2");


      assert map.get(Fqn.fromRelativeElements(fqn1, "2")) != null;

   }

   public void testEquals2() {
      Fqn f1;
      Fqn f2;
      f1 = Fqn.fromString("/a/b/c");
      f2 = Fqn.fromString("/a/b/c");
      assert f1.equals(f2);

      f2 = Fqn.fromString("/a/b");

      f2 = Fqn.fromString("/a/b/c/d");
      assert !f1.equals(f2);
   }

   public void testEquals3() {
      Fqn f1;
      Fqn f2;
      f1 = Fqn.fromElements("a", 322649, Boolean.TRUE);
      f2 = Fqn.ROOT;
      assert !f1.equals(f2);
      assert !f2.equals(f1);

      f2 = Fqn.fromString("a/322649/TRUE");
      assert !f1.equals(f2);

      f2 = Fqn.fromElements("a", 322649, Boolean.FALSE);

      f2 = Fqn.fromElements("a", 322649, Boolean.TRUE);
      assert f1.equals(f2);
   }

   public void testEquals4() {
      Fqn fqn = Fqn.fromString("X");
      // Check casting
      assert !fqn.equals("X");
      // Check null
      assert !fqn.equals(null);
   }

      // Check null
      assert !fqn.equals(null);
   }

   public void testNullElements() throws CloneNotSupportedException {
      Fqn fqn0 = Fqn.fromElements((Object) null);
      assert 1 == fqn0.size();

      Fqn fqn1 = Fqn.fromElements("NULL", null, 0);
      assert 3 == fqn1.size();

      Fqn fqn2 = Fqn.fromElements("NULL", null, 0);
      assert fqn1.hashCode() == fqn2.hashCode();
      assert fqn1.equals(fqn2);
   }

      // /x
      // /y

      // N threads constantly move /x and /y around to hang off either /a ~ /e randomly.

      final Fqn FQN_A = A, FQN_B = B, FQN_C = C, FQN_D = D, FQN_E = E, FQN_X = Fqn.fromString("/x"), FQN_Y = Fqn.fromString("/y");

      // set up the initial structure.
      final Node[] NODES = {
            rootNode.addChild(FQN_A), rootNode.addChild(FQN_B),
            rootNode.addChild(FQN_C), rootNode.addChild(FQN_D), rootNode.addChild(FQN_E)

      assert fqn1.hashCode() == fqn2.hashCode();
      assert fqn1.equals(fqn2);
   }

   public void testIteration() {
      Fqn fqn = Fqn.fromString("/a/b/c");
      assert 3 == fqn.size();
      Fqn tmp_fqn = Fqn.ROOT;
      assert 0 == tmp_fqn.size();
      for (int i = 0; i < fqn.size(); i++) {
         String s = (String) fqn.get(i);
         tmp_fqn = Fqn.fromRelativeElements(tmp_fqn, s);
         assert tmp_fqn.size() == i + 1;
      }
      assert 3 == tmp_fqn.size();
      assert fqn.equals(tmp_fqn);
   }

      // set up the initial structure
      // /a
      // /b
      // /c
      Node<Object, Object> rootNode = treeCache.getRoot();
      final Fqn FQN_A = A, FQN_B = B, FQN_C = C;
      Node nodeA = rootNode.addChild(FQN_A);
      Node nodeB = rootNode.addChild(FQN_B);
      rootNode.addChild(FQN_C);

      final CountDownLatch latch1 = new CountDownLatch(1);

      assertEquals("Should have found C only once", 1, foundC);
   }

   public void testMoveInSamePlace() {
      Node<Object, Object> rootNode = treeCache.getRoot();
      final Fqn FQN_X = Fqn.fromString("/x");
      // set up the initial structure.
      Node aNode = rootNode.addChild(A);
      Node xNode = aNode.addChild(FQN_X);
      assertEquals(aNode.getChildren().size(), 1);

      assert 3 == tmp_fqn.size();
      assert fqn.equals(tmp_fqn);
   }

   public void testIsChildOf() {
      Fqn child = Fqn.fromString("/a/b");
      Fqn parent = Fqn.fromString("/a");
      assert child.isChildOf(parent);
      assert !parent.isChildOf(child);
      assert child.isChildOrEquals(child);

      parent = Fqn.fromString("/a/b/c");
      child = Fqn.fromString("/a/b/c/d/e/f/g/h/e/r/e/r/t/tt/");
      assert child.isChildOf(parent);

TOP

Related Classes of org.infinispan.tree.Fqn

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.