01: // Copyright (C) 2003,2004,2005 by Object Mentor, Inc. All rights reserved.
02: // Released under the terms of the GNU General Public License version 2 or later.
03: package fitnesse.wikitext.widgets;
04:
05: import junit.framework.*;
06: import fitnesse.wikitext.*;
07: import fitnesse.wiki.*;
08: import java.util.*;
09:
10: public class WidgetVisitorTest extends TestCase implements
11: WidgetVisitor {
12: List visits = new ArrayList();
13:
14: private WikiPage root;
15:
16: public void visit(WikiWidget widget) {
17: visits.add(widget);
18: }
19:
20: public void visit(WikiWordWidget widget) {
21: visits.add(widget);
22: }
23:
24: public void visit(AliasLinkWidget widget) throws Exception {
25: }
26:
27: public void setUp() throws Exception {
28: visits.clear();
29: root = InMemoryPage.makeRoot("RooT");
30: }
31:
32: public void testSimpleVisitorVisitsAllWidgets() throws Exception {
33: WidgetRoot root = new WidgetRoot("''hello''", this .root);
34: root.acceptVisitor(this );
35: assertEquals(3, visits.size());
36: assertEquals(WidgetRoot.class, visits.get(0).getClass());
37: assertEquals(ItalicWidget.class, visits.get(1).getClass());
38: assertEquals(TextWidget.class, visits.get(2).getClass());
39: }
40:
41: public void testComplexVisitorVisitsAllWidgets() throws Exception {
42: WidgetRoot root = new WidgetRoot(
43: "|CellOne|CellTwo|\n|''hello''|'''hello'''|\n",
44: this .root);
45: root.acceptVisitor(this );
46: assertEquals(14, visits.size());
47: }
48: }
|