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 fitnesse.wiki.*;
06:
07: public class EmbedWidgetTest extends AbstractWidget {
08:
09: private static final String SRC_URL = "http://localhost:9999/~FrameworkTests";
10:
11: protected WikiPage root;
12:
13: protected WikiPage page1;
14:
15: protected PageCrawler crawler;
16:
17: public void setUp() throws Exception {
18: root = InMemoryPage.makeRoot("RooT");
19: crawler = root.getPageCrawler();
20: crawler.setDeadEndStrategy(new VirtualEnabledPageCrawler());
21: page1 = crawler.addPage(root, PathParser.parse("PageOne"),
22: "page one");
23: crawler.addPage(root, PathParser.parse("PageTwo"),
24: "page '''two'''");
25: crawler.addPage(root, PathParser.parse("PageTwo.ChildOne"),
26: "child page");
27: }
28:
29: public void tearDown() throws Exception {
30: }
31:
32: private EmbedWidget createEmbedWidget(WikiPage wikiPage,
33: String includedPageName) throws Exception {
34: return createEmbedWidget(new WidgetRoot(wikiPage),
35: includedPageName);
36: }
37:
38: private EmbedWidget createEmbedWidget(WidgetRoot widgetRoot,
39: String includedPageName) throws Exception {
40: return new EmbedWidget(widgetRoot, "!embed " + includedPageName);
41: }
42:
43: protected String getRegexp() {
44: return EmbedWidget.REGEXP;
45: }
46:
47: public void testIsCollapsable() throws Exception {
48: EmbedWidget widget = createEmbedWidget(page1, SRC_URL);
49: final String result = widget.render();
50: assertSubString("class=\"collapsable\"", result);
51: }
52:
53: public void testSeamlessIsNotCollapsable() throws Exception {
54: EmbedWidget widget = createEmbedWidget(page1, "-seamless "
55: + SRC_URL);
56: final String result = widget.render();
57: assertNotSubString("class=\"collapsable\"", result);
58: }
59:
60: public void testRegexp() throws Exception {
61: assertMatchEquals("!embed " + SRC_URL, "!embed " + SRC_URL);
62: assertMatchEquals("!embed " + SRC_URL + "\n", "!embed "
63: + SRC_URL + "\n");
64: //assertMatchEquals("abc\n" + "!embed SomePage\nxyz", "!embed SomePage\n");
65: assertMatchEquals("!embed .SomePage.ChildPage",
66: "!embed .SomePage.ChildPage");
67: assertNoMatch("!embed");
68: assertNoMatch(" " + "!embed " + SRC_URL);
69: }
70:
71: }
|