Mercurial > hg > Members > shoshi > TreeCMS > TreeCMSPrototype1
diff src/treecms/proto/test/SimpleEditorTest1.java @ 28:64359341c04a
merge added
author | ShoshiTAMAKI |
---|---|
date | Mon, 08 Nov 2010 17:34:44 +0900 |
parents | src/treecms/proto/test/EditableTreeBuilderTest1.java@45881237e777 |
children | 8d733b98c5de |
line wrap: on
line diff
--- /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); + } + } +}