Mercurial > hg > Members > shoshi > TreeCMSv2
comparison 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 |
comparison
equal
deleted
inserted
replaced
8:f96193babac0 | 9:17ed97ca9960 |
---|---|
1 package treecms.test; | |
2 | |
3 import junit.framework.Assert; | |
4 | |
5 import org.junit.Test; | |
6 | |
7 import treecms.api.Forest; | |
8 import treecms.api.Node; | |
9 import treecms.api.NodeID; | |
10 import treecms.api.Tree; | |
11 | |
12 /** | |
13 * Forest実装の基本的なテスト | |
14 * @author shoshi | |
15 */ | |
16 public abstract class AbstractForestTest | |
17 { | |
18 /** | |
19 * 基本的なテストを実装するためにはこのメソッドでインスタンスを返す。 | |
20 * @return Forest | |
21 */ | |
22 public abstract Forest getInstance(); | |
23 | |
24 /** | |
25 * Node作成テスト | |
26 * 新しく作成されたNodeがnullでなければOK | |
27 */ | |
28 @Test | |
29 public void testCreateNode() | |
30 { | |
31 Forest forest = getInstance(); | |
32 Node newNode = forest.create(); | |
33 Assert.assertNotNull(newNode); | |
34 } | |
35 | |
36 /** | |
37 * Node取得テスト | |
38 * 新しく作成されたNodeからNodeIDを取得し、ForestよりNodeを再取得する | |
39 */ | |
40 @Test | |
41 public void testGetNode() | |
42 { | |
43 Forest forest = getInstance(); | |
44 Node newNode = forest.create(); | |
45 NodeID newID = newNode.getID(); | |
46 | |
47 Node node = forest.get(newID); | |
48 | |
49 Assert.assertEquals(newNode,node); | |
50 } | |
51 | |
52 /** | |
53 * NodeのTip(最新版)の取得テスト | |
54 * 新しく作成されたNodeのUUIDを抜き出し、Forestよりtipを取得する | |
55 */ | |
56 @Test | |
57 public void testGetTip() | |
58 { | |
59 Forest forest = getInstance(); | |
60 Node newNode = forest.create(); | |
61 NodeID newID = newNode.getID(); | |
62 | |
63 Node tip = forest.getTip(newID.getUUID()); | |
64 | |
65 Assert.assertEquals(newNode,tip); | |
66 } | |
67 | |
68 /** | |
69 * MainTreeが取得できるかテストします。 | |
70 * MainTreeとは、コンテンツ全体を含むツリーです | |
71 */ | |
72 @Test | |
73 public void testGetMainTree() | |
74 { | |
75 Forest forest = getInstance(); | |
76 Tree contents = forest.getMainTree(); | |
77 | |
78 Assert.assertNotNull(contents); | |
79 } | |
80 } |