view src/treecms/test/AbstractForestTest.java @ 11:85061e874775

commit
author shoshi
date Fri, 06 May 2011 00:42:57 +0900
parents 17ed97ca9960
children bb9760760744
line wrap: on
line source

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);
	}
}