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 XRefWidgetTest extends AbstractWidget {
08: private WikiPage root;
09:
10: private WikiPage page;
11:
12: private WidgetRoot wroot;
13:
14: public void testRegexp() throws Exception {
15: assertMatchEquals("!xref SomePage", "!xref SomePage");
16: assertMatchEquals("!xref SomePage.SubPage",
17: "!xref SomePage.SubPage");
18: assertMatchEquals("!xref SomePage.SubPage junk",
19: "!xref SomePage.SubPage");
20: }
21:
22: protected void setUp() throws Exception {
23: root = InMemoryPage.makeRoot("RooT");
24: page = root.getPageCrawler().addPage(root,
25: PathParser.parse("SomePage"));
26: wroot = new WidgetRoot(page);
27: }
28:
29: public void testHtml() throws Exception {
30: XRefWidget widget = new XRefWidget(wroot, "!xref SomePage");
31: assertHasRegexp(
32: "<span class=\"xref\"><a href=.*SomePage</a></span>",
33: widget.render());
34:
35: widget = new XRefWidget(wroot, "!xref NoPage");
36: assertHasRegexp(
37: "<span class=\"xref\">NoPage<a href=.*>?</a></span>",
38: widget.render());
39: }
40:
41: public void testAsWikiText() throws Exception {
42: final String TEST_WIDGET = "!xref SomePage";
43: XRefWidget w = new XRefWidget(wroot, TEST_WIDGET);
44: assertEquals(TEST_WIDGET, w.asWikiText());
45: }
46:
47: protected String getRegexp() {
48: return XRefWidget.REGEXP;
49: }
50: }
|