Mercurial > hg > Members > shoshi > TreeCMSv2
diff src/treecms/test/AbstractForestTest.java @ 9:17ed97ca9960
commit
author | shoshi |
---|---|
date | Mon, 18 Apr 2011 01:07:27 +0900 |
parents | src/treecms/test/ForestTest.java@12604eb6b615 |
children | bb9760760744 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/treecms/test/AbstractForestTest.java Mon Apr 18 01:07:27 2011 +0900 @@ -0,0 +1,80 @@ +package treecms.test; + +import junit.framework.Assert; + +import org.junit.Test; + +import treecms.api.Forest; +import treecms.api.Node; +import treecms.api.NodeID; +import treecms.api.Tree; + +/** + * Forest実装の基本的なテスト + * @author shoshi + */ +public abstract class AbstractForestTest +{ + /** + * 基本的なテストを実装するためにはこのメソッドでインスタンスを返す。 + * @return Forest + */ + public abstract Forest getInstance(); + + /** + * Node作成テスト + * 新しく作成されたNodeがnullでなければOK + */ + @Test + public void testCreateNode() + { + Forest forest = getInstance(); + Node newNode = forest.create(); + Assert.assertNotNull(newNode); + } + + /** + * Node取得テスト + * 新しく作成されたNodeからNodeIDを取得し、ForestよりNodeを再取得する + */ + @Test + public void testGetNode() + { + Forest forest = getInstance(); + Node newNode = forest.create(); + NodeID newID = newNode.getID(); + + Node node = forest.get(newID); + + Assert.assertEquals(newNode,node); + } + + /** + * NodeのTip(最新版)の取得テスト + * 新しく作成されたNodeのUUIDを抜き出し、Forestよりtipを取得する + */ + @Test + public void testGetTip() + { + Forest forest = getInstance(); + Node newNode = forest.create(); + NodeID newID = newNode.getID(); + + Node tip = forest.getTip(newID.getUUID()); + + Assert.assertEquals(newNode,tip); + } + + /** + * MainTreeが取得できるかテストします。 + * MainTreeとは、コンテンツ全体を含むツリーです + */ + @Test + public void testGetMainTree() + { + Forest forest = getInstance(); + Tree contents = forest.getMainTree(); + + Assert.assertNotNull(contents); + } +}