001: /**
002: * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, version 2.1, dated February 1999.
003: *
004: * This program is free software; you can redistribute it and/or modify
005: * it under the terms of the latest version of the GNU Lesser General
006: * Public License as published by the Free Software Foundation;
007: *
008: * This program is distributed in the hope that it will be useful,
009: * but WITHOUT ANY WARRANTY; without even the implied warranty of
010: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
011: * GNU Lesser General Public License for more details.
012: *
013: * You should have received a copy of the GNU Lesser General Public License
014: * along with this program (LICENSE.txt); if not, write to the Free Software
015: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
016: *
017: * Based on code generated by Agitar build: Agitator Version 1.0.2.000071 (Build date: Jan 12, 2007) [1.0.2.000071]
018: */package org.jamwiki.parser;
019:
020: import junit.framework.TestCase;
021:
022: public class ParserUtilTest extends TestCase {
023:
024: /**
025: *
026: */
027: public void testParse() throws Throwable {
028: ParserInput parserInput = getParserInput();
029: String result = ParserUtil.parse(parserInput, null,
030: "testParserUtilContent");
031: //FIXME assertEquals(null,result); //What is the expected behaviour?
032: }
033:
034: public void testParse1() throws Throwable {
035: ParserInput parserInput = getParserInput();
036: String result = ParserUtil.parse(parserInput, null,
037: "testParserUtilContent");
038: assertEquals("paragraph", "<p>testParserUtilContent\n</p>",
039: result);
040: }
041:
042: public void testParse2() throws Throwable {
043: ParserInput parserInput = getParserInput();
044: String result = ParserUtil.parse(parserInput, null, "''it''");
045: assertEquals("italics", "<p><i>it</i>\n</p>", result);
046: }
047:
048: public void testParse3() throws Throwable {
049: ParserInput parserInput = getParserInput();
050: String result = ParserUtil.parse(parserInput, null,
051: "'''bold'''");
052: assertEquals("embolden", "<p><b>bold</b>\n</p>", result);
053: }
054:
055: public void testParse4() throws Throwable {
056: ParserInput parserInput = getParserInput();
057: String result = ParserUtil.parse(parserInput, null,
058: "'''''bold it'''''");
059: assertEquals("bold+it", "<p><b><i>bold it</i></b>\n</p>",
060: result);
061: }
062:
063: public void testParse5() throws Throwable {
064: ParserInput parserInput = getParserInput();
065: String result = ParserUtil.parse(parserInput, null,
066: "testParserUtilContent");
067: assertEquals("result.getContent()",
068: "<p>testParserUtilContent\n</p>", result);
069: }
070:
071: private ParserInput getParserInput() {
072: ParserInput parserInput = new ParserInput();
073: parserInput.setTopicName("testParserUtilTopicName");
074: parserInput.setVirtualWiki("testParserUtilVirtualWiki");
075: parserInput.setContext("testParserUtilContext");
076: return parserInput;
077: }
078:
079: /**
080: *
081: */
082: public void testParseMinimal() throws Throwable {
083: ParserInput parserInput = new ParserInput();
084: parserInput.setVirtualWiki("testParserUtilVirtualWiki");
085: parserInput.setTopicName("testParserUtilTopicName");
086: String result = ParserUtil.parseMinimal(parserInput,
087: "testParserUtilContent");
088: assertEquals("result.getContent()", "testParserUtilContent",
089: result);
090: }
091:
092: /**
093: *
094: */
095: public void testParserRedirectContent() throws Throwable {
096: String result = ParserUtil
097: .parserRedirectContent("testParserUtilTopicName");
098: assertEquals("result", "#REDIRECT [[testParserUtilTopicName]]",
099: result);
100: }
101:
102: /**
103: *
104: */
105: public void testParseMetadataThrowsException() throws Throwable {
106: try {
107: ParserUtil.parseMetadata(new ParserInput(),
108: "testParserUtilContent");
109: fail("Expected Exception to be thrown");
110: } catch (Exception ex) {
111: assertEquals("ex.getMessage()",
112: "Parser info not properly initialized", ex
113: .getMessage());
114: }
115: }
116:
117: /**
118: *
119: */
120: public void testParseMetadataThrowsNullPointerException()
121: throws Throwable {
122: try {
123: ParserUtil.parseMetadata(null, "testParserUtilContent");
124: fail("Expected NullPointerException to be thrown");
125: } catch (NullPointerException ex) {
126: assertNull("ex.getMessage()", ex.getMessage());
127: }
128: }
129:
130: /**
131: *
132: */
133: public void testParseThrowsException() throws Throwable {
134: try {
135: ParserUtil.parse(new ParserInput(), null,
136: "testParserUtilContent");
137: fail("Expected Exception to be thrown");
138: } catch (Exception ex) {
139: assertEquals("ex.getMessage()",
140: "Parser info not properly initialized", ex
141: .getMessage());
142: }
143: }
144:
145: /**
146: *
147: */
148: public void testParseThrowsNullPointerException() throws Throwable {
149: try {
150: ParserUtil.parse(null, null, "testParserUtilContent");
151: fail("Expected NullPointerException to be thrown");
152: } catch (NullPointerException ex) {
153: assertNull("ex.getMessage()", ex.getMessage());
154: }
155: }
156:
157: /**
158: *
159: */
160: public void testParserOutputThrowsException() throws Throwable {
161: try {
162: ParserUtil.parserOutput("testParserUtilContent", null,
163: "testParserUtilTopicName");
164: fail("Expected Exception to be thrown");
165: } catch (Exception ex) {
166: assertEquals("ex.getMessage()",
167: "Parser info not properly initialized", ex
168: .getMessage());
169: }
170: }
171: }
|