1 package test.wiki;
2
3 import javax.servlet.http.HttpServletRequest;
4
5 import junit.extensions.TestSetup;
6 import junit.framework.Test;
7 import junit.framework.TestCase;
8 import junit.framework.TestSuite;
9
10 import org.seasar.framework.container.S2Container;
11 import org.seasar.framework.container.factory.SingletonS2ContainerFactory;
12 import org.seasar.tuigwaa.cms.core.CmsConstants;
13 import org.seasar.tuigwaa.cms.core.CmsContainer;
14 import org.seasar.tuigwaa.cms.core.CmsRequest;
15 import org.seasar.tuigwaa.cms.core.CmsResponse;
16 import org.seasar.tuigwaa.cms.core.Page;
17 import org.seasar.tuigwaa.system.TgwSystemService;
18 import org.seasar.tuigwaa.util.TgwContext;
19
20
21 /***
22 * @author someda
23 */
24 public class HTMLWikiVisitorTest extends TestCase {
25
26 private static TestPageFactory factory_;
27 private static TgwSystemService systemService;
28 private static HttpServletRequest httpRequest;
29
30 private CmsRequest request_;
31 private CmsResponse response_;
32 private boolean display_ = true;
33
34 private String fileName;
35
36
37 public static Test suite() throws Exception{
38
39 TestSuite suite = new TestSuite(HTMLWikiVisitorTest.class);
40 TestSetup setup = new TestSetup(suite){
41
42
43
44 public void setUp() throws Exception{
45 SingletonS2ContainerFactory.init();
46 S2Container container = SingletonS2ContainerFactory.getContainer();
47
48 TgwContext.setAdmin();
49 systemService = (TgwSystemService) container.getComponent(TgwSystemService.class);
50 factory_ = TestPageFactory.getInstance();
51 httpRequest = container.getRequest();
52
53
54
55
56
57
58
59 }
60
61 public void tearDown() throws Exception{
62
63 systemService.destroy();
64 }
65 };
66 return setup;
67 }
68
69 protected void setUp() throws Exception {
70
71 request_ = new CmsRequest(httpRequest);
72 request_.setSiteName("test");
73 response_ = new CmsResponse();
74 request_.setType(CmsConstants.OUTPUTTYPE_HTML);
75 }
76
77
78
79
80
81
82
83
84
85
86
87
88
89 public void testInlineElement(){
90 doTest("inline.txt");
91 }
92
93 public void testExcerpt(){
94 doTest("excerpt.txt");
95 }
96
97 public void testList(){
98 doTest("list.txt");
99 }
100
101 public void testDList(){
102 doTest("dlist.txt");
103 }
104
105 public void testTable(){
106 doTest("table.txt");
107 }
108
109 public void testHeading(){
110 doTest("heading.txt");
111 }
112
113 public void testPlugin(){
114 doTest("plugin.txt");
115 }
116
117 public void testSentence(){
118 doTest("sentence.txt");
119 }
120
121 public void testError(){
122 doTest("error.txt");
123 }
124
125 private void doTest(String filename){
126 this.fileName = filename;
127 Page page = factory_.getPage(filename);
128 request_.setPage(page);
129 CmsContainer.INSTANCE.service(request_,response_);
130 assertEquals(response_.getTotalError(),0);
131 }
132
133 protected void tearDown() throws Exception {
134 System.out.println("==================== " + fileName + " result ====================");
135 if(display_){
136 System.out.println(response_.getString());
137 }
138 System.out.println("Syntax Error : " + response_.getNParseError());
139 System.out.println("Lexical Error : " + response_.getNLexicalError());
140 System.out.println();
141 }
142
143 }