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.Pattern;
06: import fitnesse.wikitext.WikiWidget;
07:
08: public class EmailWidgetTest extends AbstractWidget {
09: protected String getRegexp() {
10: return EmailWidget.REGEXP;
11: }
12:
13: public void testEmailRegularExpression() throws Exception {
14: assertTrue("Match 1", Pattern.matches(EmailWidget.REGEXP,
15: "ppagel@objectmentor.com"));
16: assertTrue("Match 2", Pattern.matches(EmailWidget.REGEXP,
17: "ppagel123@objectmentor.com"));
18: assertTrue("Match 3", Pattern.matches(EmailWidget.REGEXP,
19: "1@2.com"));
20: assertTrue("Match 4", Pattern.matches(EmailWidget.REGEXP,
21: "1342534532@2.3.com"));
22: assertFalse("Match 5", Pattern.matches(EmailWidget.REGEXP,
23: "#!^@@@.()"));
24: assertFalse("Match 6", Pattern.matches(EmailWidget.REGEXP,
25: "abc@@@.()"));
26: assertFalse("Match 7", Pattern.matches(EmailWidget.REGEXP,
27: "abc@efg.()"));
28: }
29:
30: public void testEmailRendering() throws Exception {
31: WikiWidget email = new EmailWidget(null,
32: "ppagel@objectmentor.com");
33: assertEquals(
34: "<a href=\"mailto:ppagel@objectmentor.com\">ppagel@objectmentor.com</a>",
35: email.render());
36: }
37:
38: }
|