Mercurial > hg > Members > shoshi > TreeCMS > TreeCMSPrototype1
changeset 28:64359341c04a
merge added
author | ShoshiTAMAKI |
---|---|
date | Mon, 08 Nov 2010 17:34:44 +0900 |
parents | 45881237e777 |
children | 174bc0d21712 |
files | src/treecms/proto/api/Editor.java src/treecms/proto/api/Node.java src/treecms/proto/api/NodeParameters.java src/treecms/proto/api/TreeBuilder.java src/treecms/proto/edit/EditableNode.java src/treecms/proto/simple/SimpleEditor.java src/treecms/proto/simple/SimpleNode.java src/treecms/proto/test/EditableTreeBuilderTest1.java src/treecms/proto/test/PreOrderTreeWalkerTest1.java src/treecms/proto/test/RandomUUIDTest.java src/treecms/proto/test/SimpleEditorTest1.java src/treecms/proto/test/SimpleEditorTest2.java src/treecms/proto/test/SimpleNodeTest1.java |
diffstat | 13 files changed, 403 insertions(+), 368 deletions(-) [+] |
line wrap: on
line diff
--- a/src/treecms/proto/api/Editor.java Sun Nov 07 14:07:03 2010 +0900 +++ b/src/treecms/proto/api/Editor.java Mon Nov 08 17:34:44 2010 +0900 @@ -2,6 +2,12 @@ public interface Editor extends Browser { - void login(String user,String pass); - void logout(); + public void login(String user,String pass); + public void logout(); + + public Node edit(Node _target); + public boolean commit(boolean _force); + public boolean update(); + public boolean check(); + public Node getUncommited(); }
--- a/src/treecms/proto/api/Node.java Sun Nov 07 14:07:03 2010 +0900 +++ b/src/treecms/proto/api/Node.java Mon Nov 08 17:34:44 2010 +0900 @@ -10,17 +10,18 @@ public List<Node> getChildren(); public boolean isChild(Node _child); - public Node addChild(NodeParameters _child); - public void removeChild(Node _child); + public Node addChild(Node _child); + public boolean removeChild(Node _child); public void up(Node _child); public void down(Node _child); - public NodeParameters getParameters(); - public void setParameters(NodeParameters _params); - public String getParameter(NodeParameters.Types _type); - public void setParameter(NodeParameters.Types _type,String _value); + public String getTitle(); + public void setTitle(String _title); + + public String getClassName(); + public void setClassName(String _class); public NodeID getID(); public Node cloneNode();
--- a/src/treecms/proto/api/NodeParameters.java Sun Nov 07 14:07:03 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -package treecms.proto.api; - -import java.util.Collections; -import java.util.Hashtable; -import java.util.Map; - -public class NodeParameters -{ - public enum Types{ - TITLE, - CLASS - } - - private Map<NodeParameters.Types,String> m_params; - - public NodeParameters() - { - m_params = new Hashtable<NodeParameters.Types,String>(); - } - - public NodeParameters(NodeParameters _params) - { - //copy constructor. - m_params = null; - m_params = new Hashtable<NodeParameters.Types,String>(_params.getParameters()); - } - - public Map<NodeParameters.Types,String> getParameters() - { - return Collections.unmodifiableMap(m_params); - } - - public String getParameter(NodeParameters.Types _type) - { - return m_params.get(_type); - } - - public void setParameter(NodeParameters.Types _type,String _value) - { - m_params.put(_type,_value); - } - - public Object clone() - { - return new NodeParameters(this); - } -}
--- a/src/treecms/proto/api/TreeBuilder.java Sun Nov 07 14:07:03 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -package treecms.proto.api; - -public interface TreeBuilder -{ - public Node getContents(); - public Node createNode(); - public Node cloneNode(Node _node); -}
--- a/src/treecms/proto/edit/EditableNode.java Sun Nov 07 14:07:03 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,74 +0,0 @@ -package treecms.proto.edit; - -import java.util.LinkedList; - - -import java.util.List; -import treecms.proto.api.Node; - -public class EditableNode extends SimpleNode -{ - private Node m_newRoot; - private Node m_target; //node that wanted to edit. - - public EditableTreeBuilder(Node _root,Node _target) - { - //search path - LinkedList<Node> path = findPath(_root,_target); - - //clone root node. - m_newRoot = cloneNode(path.poll()); - - cloneTree(path,m_newRoot); - } - - public Node getTargetNode() - { - return m_target; - } - - private void cloneTree(LinkedList<Node> _path,Node _parent) - { - List<Node> children = _parent.getChildren(); - Node target = _path.poll(); - for(int i = 0;i < children.size();i ++){ - Node _child = children.get(i); - if(_child == target){ - //clone node - Node newNode = cloneNode(target); - m_target = newNode; // look out!! - - //remove old node from clonedTree - _parent.addChild(newNode); - _parent.removeChild(target); - - cloneTree(_path,newNode); - - break; - } - } - } - - private LinkedList<Node> findPath(Node _root,Node _child) - { - LinkedList<Node> list = new LinkedList<Node>(); - findPath(_root,_child,list); - list.addFirst(_root); - return list; - } - - private boolean findPath(Node _root,Node _child,LinkedList<Node> _list) - { - if(_root == _child){ - return true; - } - - for(Node child : _root.getChildren()){ - if(findPath(child,_child,_list)){ - _list.addFirst(child); - return true; - } - } - return false; - } -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/treecms/proto/simple/SimpleEditor.java Mon Nov 08 17:34:44 2010 +0900 @@ -0,0 +1,154 @@ +package treecms.proto.simple; + +import java.util.List; +import java.util.concurrent.atomic.AtomicReference; +import java.util.LinkedList; +import treecms.proto.api.Editor; +import treecms.proto.api.Node; + +public class SimpleEditor implements Editor +{ + private AtomicReference<Node> m_contents; + private Node m_tip,m_modified; + + private LinkedList<Node> m_log; + + public SimpleEditor(AtomicReference<Node> _contents) + { + m_contents = _contents; + m_tip = m_contents.get(); + m_modified = null; + m_log = new LinkedList<Node>(); + } + + public boolean checkUpdate() + { + return m_contents.equals(m_modified); + } + + public boolean commit(boolean _force) + { + m_contents.set(m_tip); + update(); + return true; + + // need to merge. + } + + public void discard() + { + m_modified = null; + m_log.clear(); + } + + @Override + public Node useContents() + { + // TODO Auto-generated method stub + return m_contents.get(); + } + + @Override + public void login(String user, String pass) + { + // TODO Auto-generated method stub + } + + @Override + public void logout() + { + // TODO Auto-generated method stub + } + + @Override + public Node edit(Node _target) + { + // TODO Auto-generated method stub + LinkedList<Node> path = findPath(m_tip,_target); + if(path.isEmpty()){ + return null; + } + + LinkedList<Node> change = new LinkedList<Node>(); + Node root = path.poll().cloneNode(); + change.add(root); + cloneTree(path,root,change); + + if(m_modified == null){ + m_modified = m_tip; + } + m_tip = root; + m_log.add(change.peekLast()); + return change.peekLast(); + } + + private void cloneTree(LinkedList<Node> _path,Node _parent,LinkedList<Node> _change) + { + List<Node> children = _parent.getChildren(); + Node target = _path.poll(); + if(target == null){ + return; + } + for(int i = 0;i < children.size();i ++){ + Node _child = children.get(i); + if(_child.getID().compare(target.getID()) != -2){ + //clone node + Node clone = _child.cloneNode(); + _change.add(clone); + + //remove old node from clonedTree + _parent.addChild(clone); + _parent.removeChild(_child); + + cloneTree(_path,clone,_change); + break; + } + } + } + + private LinkedList<Node> findPath(Node _root,Node _child) + { + LinkedList<Node> list = new LinkedList<Node>(); + findPath(_root,_child,list); + list.addFirst(_root); + return list; + } + + private boolean findPath(Node _root,Node _child,LinkedList<Node> _list) + { + if(_root == _child){ + return true; + } + + for(Node child : _root.getChildren()){ + if(findPath(child,_child,_list)){ + _list.addFirst(child); + return true; + } + } + return false; + } + + @Override + public Node getUncommited() + { + // TODO Auto-generated method stub + return this.m_tip; + } + + @Override + public boolean update() + { + // TODO Auto-generated method stub + discard(); + m_modified = m_contents.get(); + return false; + } + + @Override + public boolean check() + { + // TODO Auto-generated method stub + return m_contents.equals(m_modified); + } +}
--- a/src/treecms/proto/simple/SimpleNode.java Sun Nov 07 14:07:03 2010 +0900 +++ b/src/treecms/proto/simple/SimpleNode.java Mon Nov 08 17:34:44 2010 +0900 @@ -1,13 +1,12 @@ package treecms.proto.simple; import java.util.Iterator; + import java.util.Collections; import java.util.LinkedList; import java.util.List; import treecms.proto.api.Node; import treecms.proto.api.NodeID; -import treecms.proto.api.NodeParameters; -import treecms.proto.api.NodeParameters.Types; import treecms.proto.id.IncrementalNodeID; public class SimpleNode implements Node @@ -15,14 +14,15 @@ private LinkedList<Node> m_children; private NodeID m_id; - private NodeParameters m_params; + private String m_title,m_class; public SimpleNode() { m_children = new LinkedList<Node>(); m_id = new IncrementalNodeID(); - m_params = new NodeParameters(); + m_title = ""; + m_class = ""; } private SimpleNode(NodeID _id) @@ -30,7 +30,8 @@ m_children = new LinkedList<Node>(); m_id = _id; - m_params = new NodeParameters(); + m_title = ""; + m_class = ""; } @Override @@ -42,28 +43,33 @@ } @Override - public boolean isChild(Node _child) { + public boolean isChild(Node _child) + { // TODO Auto-generated method stub return m_children.contains(_child); } @Override - public Node addChild(NodeParameters _params) { + public Node addChild(Node _child) + { // TODO Auto-generated method stub - SimpleNode child = new SimpleNode(); - child.setParameters(_params); - m_children.add(child); - return child; + if(m_children.contains(_child)){ + throw new IllegalArgumentException("the node already contains "+_child.getTitle()+":"+_child.getID()); + } + m_children.add(_child); + return _child; } @Override - public void removeChild(Node _child) { + public boolean removeChild(Node _child) + { // TODO Auto-generated method stub - m_children.remove(_child); + return m_children.remove(_child); } @Override - public void up(Node _child) { + public void up(Node _child) + { // TODO Auto-generated method stub int curPos = m_children.indexOf(_child); if(curPos - 1 > 0){ @@ -72,7 +78,8 @@ } @Override - public void down(Node _child) { + public void down(Node _child) + { // TODO Auto-generated method stub int curPos = m_children.indexOf(_child); if(curPos + 1 < m_children.size()){ @@ -81,7 +88,8 @@ } @Override - public Iterator<Node> iterator() { + public Iterator<Node> iterator() + { // TODO Auto-generated method stub // return unmodifiable iterator return Collections.unmodifiableList(m_children).iterator(); @@ -93,46 +101,49 @@ return this.m_id; } - public void addChildren(List<Node> _children) { + public void addChildren(List<Node> _children) + { // TODO Auto-generated method stub this.m_children.addAll(_children); } - @Override - public NodeParameters getParameters() - { - // TODO Auto-generated method stub - return new NodeParameters(m_params); - } - - @Override - public void setParameters(NodeParameters _params) - { - // TODO Auto-generated method stub - m_params = new NodeParameters(_params); - } @Override public Node cloneNode() { // TODO Auto-generated method stub SimpleNode clone = new SimpleNode(m_id.update()); - clone.setParameters(m_params); - clone.addChildren(getChildren()); + clone.setTitle(getTitle()); + clone.setClassName(getClassName()); + clone.addChildren(m_children); return clone; } @Override - public String getParameter(Types _type) + public String getTitle() { // TODO Auto-generated method stub - return m_params.getParameter(_type); + return m_title; + } + + @Override + public void setTitle(String _title) + { + // TODO Auto-generated method stub + m_title = _title; } @Override - public void setParameter(Types _type, String _value) + public String getClassName() { // TODO Auto-generated method stub - m_params.setParameter(_type,_value); + return m_class; + } + + @Override + public void setClassName(String _class) + { + // TODO Auto-generated method stub + m_class = _class; } }
--- a/src/treecms/proto/test/EditableTreeBuilderTest1.java Sun Nov 07 14:07:03 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,95 +0,0 @@ -package treecms.proto.test; - - - -import org.junit.Test; -import org.junit.runner.JUnitCore; - -import treecms.proto.api.*; -import treecms.proto.edit.EditableTreeBuilder; -import treecms.proto.simple.*; - -public class EditableTreeBuilderTest1 -{ - public static void main(String _args[]) - { - JUnitCore.main(EditableTreeBuilderTest1.class.getName()); - } - - private Node m_root; - private Node m_target1; - private Node m_target2; - - public EditableTreeBuilderTest1() - { - - TreeBuilder builder = new SimpleTreeBuilder(); - Node root = builder.getContents(); - root.setTitle("root"); - - Node child1 = builder.createNode(); - child1.setTitle("child1"); - Node child2 = builder.createNode(); - child2.setTitle("child2"); - - root.addChild(child1); - root.addChild(child2); - - Node child11 = builder.createNode(); - child11.setTitle("child11"); - Node child12 = builder.createNode(); - child12.setTitle("child12"); - Node child13 = builder.createNode(); - child13.setTitle("child13"); - - child1.addChild(child11); - child1.addChild(child12); - child1.addChild(child13); - - Node child21 = builder.createNode(); - child21.setTitle("child21"); - - child2.addChild(child21); - - Node child211 = builder.createNode(); - child211.setTitle("child211"); - Node child212 = builder.createNode(); - child212.setTitle("child212"); - - child21.addChild(child211); - child21.addChild(child212); - - m_root = root; - m_target1 = child212; - m_target2 = child211; - } - - @Test - public void testClone() - { - Node target; - EditableTreeBuilder builder; - builder = new EditableTreeBuilder(m_root,m_target1); - target = builder.getTargetNode(); - target.setTitle("*"+m_target1.getTitle()); - System.out.println("-----------------------------------------------"); - print(builder.getContents(),0); - - builder = new EditableTreeBuilder(builder.getContents(),m_target2); - target = builder.getTargetNode(); - target.setTitle("*"+m_target2.getTitle()); - System.out.println("-----------------------------------------------"); - print(builder.getContents(),0); - } - - private void print(Node _root,int _indent) - { - for(int i = 0;i < _indent;i ++){ - System.out.print("\t"); - } - System.out.println(_root.getTitle()+"["+_root.getID()+"]"); - for(Node child : _root.getChildren()){ - print(child,_indent+1); - } - } -}
--- a/src/treecms/proto/test/PreOrderTreeWalkerTest1.java Sun Nov 07 14:07:03 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -package treecms.proto.test; - - -import treecms.proto.api.*; -import treecms.proto.api.NodeParameters.Types; -import treecms.proto.simple.*; -import treecms.proto.util.PreOrderTreeWalker; - -public class PreOrderTreeWalkerTest1 -{ - public static void main(String _arg[]) - { - //create test tree. - Node root = new SimpleNode(); - root.setParameter(Types.TITLE,"root"); - - Node child1 = root.addChild(new NodeParameters()); - child1.setParameter(Types.TITLE,"child1"); - Node child2 = root.addChild(new NodeParameters()); - child2.setParameter(Types.TITLE,"child2"); - - Node child11 = child1.addChild(new NodeParameters()); - child11.setParameter(Types.TITLE,"child11"); - Node child12 = child1.addChild(new NodeParameters()); - child12.setParameter(Types.TITLE,"child12"); - Node child13 = child1.addChild(new NodeParameters()); - child13.setParameter(Types.TITLE,"child13"); - - Node child21 = child2.addChild(new NodeParameters()); - child21.setParameter(Types.TITLE,"child21"); - - Node child211 = child21.addChild(new NodeParameters()); - child211.setParameter(Types.TITLE,"child211"); - Node child212 = child21.addChild(new NodeParameters()); - child212.setParameter(Types.TITLE,"child212"); - - PreOrderTreeWalker walker = new PreOrderTreeWalker(root); - - for(Node node : walker){ - System.out.println(node.getParameter(Types.TITLE) + "\t\tID:" + node.getID()); - } - } -}
--- a/src/treecms/proto/test/RandomUUIDTest.java Sun Nov 07 14:07:03 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -package treecms.proto.test; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - -import org.junit.Test; -import org.junit.runner.JUnitCore; -import java.util.UUID; - -public class RandomUUIDTest -{ - public static void main(String _args[]) - { - JUnitCore.main(RandomUUIDTest.class.getName()); - } - - @Test - public void testUUIDGenerateMultiThread() - { - final int threads = 10; - final int count = 100000; - ExecutorService service = Executors.newFixedThreadPool(threads); - - for(int i = 0;i < threads;i ++){ - service.execute(new Runnable(){ - @Override - public void run() { - // TODO Auto-generated method stub - for(int i = 0;i < count;i ++){ - UUID.randomUUID(); - } - } - }); - } - - service.shutdown(); - - try { - service.awaitTermination(Long.MAX_VALUE,TimeUnit.DAYS); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/treecms/proto/test/SimpleEditorTest1.java Mon Nov 08 17:34:44 2010 +0900 @@ -0,0 +1,66 @@ +package treecms.proto.test; + +import org.junit.Test; +import java.util.concurrent.atomic.AtomicReference; +import org.junit.runner.JUnitCore; +import treecms.proto.api.*; +import treecms.proto.simple.*; + +public class SimpleEditorTest1 +{ + public static void main(String _args[]) + { + JUnitCore.main(SimpleEditorTest1.class.getName()); + } + + private AtomicReference<Node> m_root; + private Node m_target1; + private Node m_target2; + + public SimpleEditorTest1() + { + + Node root = new SimpleNode(); + root.setTitle("root"); + + Node child1 = root.addChild(new SimpleNode()); + child1.setTitle("child1"); + Node child2 = root.addChild(new SimpleNode()); + child2.setTitle("child2"); + + Node child11 = child1.addChild(new SimpleNode()); + child11.setTitle("child11"); + Node child12 = child1.addChild(new SimpleNode()); + child12.setTitle("child12"); + + m_root = new AtomicReference<Node>(root); + m_target1 = child2; + m_target2 = child11; + } + + @Test + public void testClone() + { + SimpleEditor editor = new SimpleEditor(m_root); + Node node = editor.edit(m_target1); + node.setTitle("*"+node.getTitle()); + System.out.println("-----------------------------------------------"); + print(editor.getUncommited(),0); + + node = editor.edit(m_target2); + node.setTitle("*"+node.getTitle()); + System.out.println("-----------------------------------------------"); + print(editor.getUncommited(),0); + } + + private void print(Node _root,int _indent) + { + for(int i = 0;i < _indent;i ++){ + System.out.print("\t"); + } + System.out.println(_root.getTitle()+"["+_root.getID()+"]"); + for(Node child : _root.getChildren()){ + print(child,_indent+1); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/treecms/proto/test/SimpleEditorTest2.java Mon Nov 08 17:34:44 2010 +0900 @@ -0,0 +1,108 @@ +package treecms.proto.test; + +import java.util.LinkedList; +import java.util.List; +import java.util.Random; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicReference; + +import org.junit.Test; + +import treecms.proto.api.Node; +import treecms.proto.simple.SimpleEditor; +import treecms.proto.simple.SimpleNode; +import treecms.proto.util.PreOrderTreeWalker; + +public class SimpleEditorTest2 +{ + public static void main(String _args[]) + { + new SimpleEditorTest2(); + } + + private AtomicReference<Node> m_contents; + + public SimpleEditorTest2() + { + Node root = new SimpleNode(); + root.setTitle("root"); + Node c1 = root.addChild(new SimpleNode()); + c1.setTitle("c1"); + Node c2 = root.addChild(new SimpleNode()); + c2.setTitle("c2"); + + + Node c11 = c1.addChild(new SimpleNode()); + c11.setTitle("c11"); + Node c12 = c1.addChild(new SimpleNode()); + c12.setTitle("c12"); + + Node c121 = c12.addChild(new SimpleNode()); + c121.setTitle("c121"); + + m_contents = new AtomicReference<Node>(root); + + testMultiThread(); + } + + @Test + public void testMultiThread() + { + int threads = 10; + final int modifyCount = 100; + ExecutorService service = Executors.newFixedThreadPool(threads); + + for(int i = 0;i < threads;i ++){ + service.execute(new Runnable(){ + + @Override + public void run() + { + // TODO Auto-generated method stub + SimpleEditor editor = new SimpleEditor(m_contents); + Random random = new Random(); + + for(int i = 0;i < modifyCount;i ++){ + List<Node> nodeList = transform(new PreOrderTreeWalker(m_contents.get())); + Node target = nodeList.get(Math.abs(random.nextInt(nodeList.size()))); + editor.edit(target); + editor.commit(false); + } + } + + public List<Node> transform(PreOrderTreeWalker _walker) + { + LinkedList<Node> nodeList = new LinkedList<Node>(); + for(Node node : _walker){ + nodeList.add(node); + } + return nodeList; + } + }); + } + + service.shutdown(); + + try { + service.awaitTermination(Long.MAX_VALUE,TimeUnit.DAYS); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + print(m_contents.get(),0); + } + + private void print(Node _root,int _indent) + { + for(int i = 0;i < _indent;i ++){ + System.out.print("\t"); + } + System.out.println(_root.getTitle()+"["+_root.getID()+"]"); + for(Node child : _root.getChildren()){ + print(child,_indent+1); + } + } +}
--- a/src/treecms/proto/test/SimpleNodeTest1.java Sun Nov 07 14:07:03 2010 +0900 +++ b/src/treecms/proto/test/SimpleNodeTest1.java Mon Nov 08 17:34:44 2010 +0900 @@ -26,12 +26,12 @@ Assert.assertThat(node,notNullValue()); String clsName = "test1"; - node.setParameter(NodeParameters.Types.CLASS,clsName); - Assert.assertEquals(node.getParameter(NodeParameters.Types.CLASS),clsName); + node.setClassName(clsName); + Assert.assertEquals(node.getClassName(),clsName); String title = "test2"; - node.setParameter(NodeParameters.Types.TITLE,title); - Assert.assertEquals(node.getParameter(NodeParameters.Types.TITLE),title); + node.setTitle(title); + Assert.assertEquals(node.getTitle(),title); } @Test @@ -40,24 +40,24 @@ Node node = new SimpleNode(); String clsName = "test1"; - node.setParameter(NodeParameters.Types.CLASS,clsName); + node.setClassName(clsName); String title = "test2"; - node.setParameter(NodeParameters.Types.TITLE,title); + node.setTitle(title); Node clone = node.cloneNode(); Assert.assertThat(clone.getID(),not(node.getID())); - Assert.assertEquals(clone.getParameter(NodeParameters.Types.CLASS),node.getParameter(NodeParameters.Types.CLASS)); - Assert.assertEquals(clone.getParameter(NodeParameters.Types.TITLE),node.getParameter(NodeParameters.Types.TITLE)); + Assert.assertEquals(node.getClassName(),clone.getClassName()); + Assert.assertEquals(node.getTitle(),clone.getTitle()); } @Test public void testChildOperation() { Node node = new SimpleNode(); - Node child1 = node.addChild(new NodeParameters()); - Node child2 = node.addChild(new NodeParameters()); - Node child3 = node.addChild(new NodeParameters()); + Node child1 = node.addChild(new SimpleNode()); + Node child2 = node.addChild(new SimpleNode()); + Node child3 = node.addChild(new SimpleNode()); //check that correctly added. List<Node> children = node.getChildren(); @@ -70,6 +70,7 @@ node.down(child1); node.up(child3); + children = node.getChildren(); Assert.assertEquals(children.get(0),child2); Assert.assertEquals(children.get(1),child3); Assert.assertEquals(children.get(2),child1); @@ -77,6 +78,7 @@ //remove node.removeChild(child3); + children = node.getChildren(); Assert.assertEquals(children.get(0),child2); Assert.assertEquals(children.get(1),child1); }