Mercurial > hg > Members > shoshi > TreeCMSv2
view src/treecms/test/AbstractNodeTest.java @ 25:c1e7ec6b3d44
commit
author | Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 12 Jul 2011 14:39:35 +0900 |
parents | 77a894c0b919 |
children |
line wrap: on
line source
package treecms.test; import java.nio.ByteBuffer; import java.util.List; import junit.framework.Assert; import org.junit.Test; import treecms.api.NodeChildren; import treecms.api.NodeID; import treecms.tree.util.NodeChildrenImpl; public abstract class AbstractNodeTest { public abstract Node getInstance(); @Test public void testGetID() { Node n = getInstance(); Assert.assertNotNull(getInstance().getID()); } @Test public void testGetData() { Assert.assertNotNull(getInstance().getList()); Assert.assertNotNull(getInstance().getAll()); } @Test public void testGetForest() { Assert.assertNotNull(getInstance().getForest()); } @Test public void testAddChildren() { SingleNode node = getInstance(); SingleNode ch1 = node.getForest().create(); SingleNode ch2 = node.getForest().create(); SingleNode ch3 = node.getForest().create(); NodeChildren<SingleNode> list = new NodeChildrenImpl<SingleNode>(ch1,ch2,ch3); node.addAll(list); List<SingleNode> children = node.getList(); int size = list.getList().size(); for(int i = 0;i < size;i ++){ NodeID id1 = children.get(i).getID(); NodeID id2 = list.get(i).getID(); Assert.assertEquals(true,id1.equals(id2)); } } @Test public void testSetAndGetAttribute() { SingleNode node = getInstance(); byte[] name = "test".getBytes(); byte[] value = "test".getBytes(); node.put(ByteBuffer.wrap(name),ByteBuffer.wrap(value)); Assert.assertEquals(true,node.get(ByteBuffer.wrap(name)).equals(ByteBuffer.wrap(value))); } }