Mercurial > hg > Members > shoshi > TreeCMS > TreeCMSPrototype1
view src/treecms/proto/test/SimpleNodeTest1.java @ 27:45881237e777
commit
author | ShoshiTAMAKI |
---|---|
date | Sun, 07 Nov 2010 14:07:03 +0900 |
parents | 9b91329e8a04 |
children | 64359341c04a |
line wrap: on
line source
package treecms.proto.test; import static org.hamcrest.core.IsNull.notNullValue; import static org.hamcrest.core.IsNot.not; import org.junit.Test; import org.junit.Assert; import org.junit.runner.JUnitCore; import treecms.proto.api.*; import treecms.proto.simple.*; import java.util.List; public class SimpleNodeTest1 { public static void main(String _arg[]) { JUnitCore.main(SimpleNodeTest1.class.getName()); } @Test public void testCreateNode() { Node node = new SimpleNode(); Assert.assertThat(node,notNullValue()); String clsName = "test1"; node.setParameter(NodeParameters.Types.CLASS,clsName); Assert.assertEquals(node.getParameter(NodeParameters.Types.CLASS),clsName); String title = "test2"; node.setParameter(NodeParameters.Types.TITLE,title); Assert.assertEquals(node.getParameter(NodeParameters.Types.TITLE),title); } @Test public void testClone() { Node node = new SimpleNode(); String clsName = "test1"; node.setParameter(NodeParameters.Types.CLASS,clsName); String title = "test2"; node.setParameter(NodeParameters.Types.TITLE,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)); } @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()); //check that correctly added. List<Node> children = node.getChildren(); Assert.assertEquals(children.size(),3); Assert.assertEquals(children.get(0),child1); Assert.assertEquals(children.get(1),child2); Assert.assertEquals(children.get(2),child3); //1,2,3 -> 2,3,1 node.down(child1); node.up(child3); Assert.assertEquals(children.get(0),child2); Assert.assertEquals(children.get(1),child3); Assert.assertEquals(children.get(2),child1); //remove node.removeChild(child3); Assert.assertEquals(children.get(0),child2); Assert.assertEquals(children.get(1),child1); } }