public void testAbsolutePaths() { TreeNode<String> root = new TreeNode<String>(""); TreeNode<String> foo = root.createChild("foo"); TreeNode<String> bar = foo.createChild("bar"); TreeNode<String> grunt = bar.createChild("grunt"); assertSame(grunt, grunt.getChild("/foo/bar/grunt")); assertSame(grunt, foo.getChild("/foo/bar/grunt")); assertSame(grunt, bar.getChild("/foo/bar/grunt")); assertSame(grunt, grunt.getChild("/foo/bar/grunt")); TreeNode<String> baz = grunt.createChild("/foo/bar/baz"); assertSame(baz, grunt.getChild("/foo/bar/baz")); assertSame(baz, foo.getChild("/foo/bar/baz")); assertSame(baz, bar.getChild("/foo/bar/baz")); assertSame(baz, grunt.getChild("/foo/bar/baz")); assertSame(baz, baz.getChild("/foo/bar/baz")); } }
public void testRoot() { TreeNode<String> root = new TreeNode<String>(""); TreeNode<String> grunt = root.createChild("foo/bar/grunt"); assertSame(root, grunt.getRoot()); }
assertNotNull(grunt); Assert.assertEquals("grunt", grunt.getId()); assertSame(grunt, subChild); assertNotNull(baz); Assert.assertEquals("baz", baz.getId()); assertSame(baz, subChild2); assertSame(baz, root.getChild("foo/bar/baz")); assertSame(grunt, root.getChild("foo/bar/grunt")); assertSame(bar, root.getChild("foo/bar")); assertSame(foo, root.getChild("foo")); assertSame(root, root.getChild("")); assertSame(baz, baz.getChild("")); assertSame(grunt, grunt.getChild("")); assertSame(bar, bar.getChild("")); assertSame(foo, foo.getChild("")); assertSame(root, root.getChild(".")); assertSame(baz, baz.getChild(".")); assertSame(grunt, grunt.getChild(".")); assertSame(bar, bar.getChild(".")); assertSame(foo, foo.getChild(".")); assertSame(null, root.getChild("..")); assertSame(bar, baz.getChild("..")); assertSame(bar, grunt.getChild("..")); assertSame(foo, bar.getChild(".."));