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 java.util.regex.Matcher;
06: import java.util.regex.Pattern;
07: import fitnesse.wiki.MockWikiPage;
08:
09: public class ClasspathWidgetTest extends AbstractWidget {
10: public void testRegexp() throws Exception {
11: assertMatchEquals("!path somePath", "!path somePath");
12: }
13:
14: public void testHtml() throws Exception {
15: ClasspathWidget widget = new ClasspathWidget(
16: new MockWidgetRoot(), "!path some.path");
17: Pattern p = Pattern.compile("classpath: some.path");
18: Matcher match = p.matcher(widget.render());
19: assertTrue("pattern not found", match.find());
20: }
21:
22: public void testAsWikiText() throws Exception {
23: final String PATH_WIDGET = "!path some.path";
24: ClasspathWidget w = new ClasspathWidget(new MockWidgetRoot(),
25: PATH_WIDGET);
26: assertEquals(PATH_WIDGET, w.asWikiText());
27: }
28:
29: public void testPathWithVariable() throws Exception {
30: String text = "!define BASE {/my/base/}\n!path ${BASE}*.jar\n";
31: WidgetRoot root = new WidgetRoot(text, new MockWikiPage());
32: String html = root.render();
33: assertSubString("/my/base/*.jar", html);
34: }
35:
36: public void testPathWikiTextWithVariable() throws Exception {
37: String text = "!define BASE {/my/base/}\n!path ${BASE}*.jar\n";
38: WidgetRoot root = new WidgetRoot(text, new MockWikiPage());
39: String text2 = root.asWikiText();
40: assertSubString("!path ${BASE}*.jar", text2);
41: }
42:
43: public void testIsWidgetWithTextArgument() throws Exception {
44: ClasspathWidget widget = new ClasspathWidget(
45: new MockWidgetRoot(), "!path some.path");
46: assertTrue(widget instanceof WidgetWithTextArgument);
47: }
48:
49: protected String getRegexp() {
50: return ClasspathWidget.REGEXP;
51: }
52: }
|