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.utils;
019:
020: import java.io.File;
021: import java.sql.Timestamp;
022: import junit.framework.TestCase;
023:
024: /**
025: *
026: */
027: public class XMLUtilTest extends TestCase {
028:
029: /**
030: *
031: */
032: public void testBuildTag() throws Throwable {
033: String result = XMLUtil.buildTag("testXMLUtilTagName", 100L);
034: assertEquals("result",
035: "<testXMLUtilTagName>100</testXMLUtilTagName>", result);
036: }
037:
038: /**
039: *
040: */
041: public void testBuildTag1() throws Throwable {
042: String result = XMLUtil.buildTag("testXMLUtilTagName", true);
043: assertEquals("result",
044: "<testXMLUtilTagName>true</testXMLUtilTagName>", result);
045: }
046:
047: /**
048: *
049: */
050: public void testBuildTag2() throws Throwable {
051: String result = XMLUtil.buildTag("testXMLUtilTagName",
052: new Integer(0));
053: assertEquals("result",
054: "<testXMLUtilTagName>0</testXMLUtilTagName>", result);
055: }
056:
057: /**
058: *
059: */
060: public void testBuildTag3() throws Throwable {
061: String result = XMLUtil.buildTag("testXMLUtilTagName",
062: new Timestamp(0));
063: // FIXME
064: // assertEquals("result", "<testXMLUtilTagName>1970-01-01 00:00:00.1</testXMLUtilTagName>", result);
065: }
066:
067: /**
068: *
069: */
070: public void testBuildTag4() throws Throwable {
071: String result = XMLUtil.buildTag("testXMLUtilTagName",
072: (Timestamp) null);
073: assertEquals("result", "", result);
074: }
075:
076: /**
077: *
078: */
079: public void testBuildTag5() throws Throwable {
080: String result = XMLUtil.buildTag("testXMLUtilTagName", 100);
081: assertEquals("result",
082: "<testXMLUtilTagName>100</testXMLUtilTagName>", result);
083: }
084:
085: /**
086: *
087: */
088: public void testBuildTag6() throws Throwable {
089: String result = XMLUtil.buildTag("testXMLUtilTagName",
090: "testXMLUtilTagValue", true);
091: assertEquals(
092: "result",
093: "<testXMLUtilTagName>testXMLUtilTagValue</testXMLUtilTagName>",
094: result);
095: }
096:
097: /**
098: *
099: */
100: public void testBuildTag7() throws Throwable {
101: String result = XMLUtil.buildTag("testXMLUtilTagName",
102: "testXMLUtilTagValue", false);
103: assertEquals(
104: "result",
105: "<testXMLUtilTagName>testXMLUtilTagValue</testXMLUtilTagName>",
106: result);
107: }
108:
109: /**
110: *
111: */
112: public void testBuildTag8() throws Throwable {
113: String result = XMLUtil.buildTag("testXMLUtilTagName", null,
114: true);
115: assertEquals("result", "", result);
116: }
117:
118: /**
119: *
120: */
121: public void testGetTextContent() throws Throwable {
122: // FIXME - implement this
123: }
124:
125: /**
126: *
127: */
128: public void testGetTextContentThrowsNullPointerException()
129: throws Throwable {
130: try {
131: XMLUtil.getTextContent(null);
132: fail("Expected NullPointerException to be thrown");
133: } catch (NullPointerException ex) {
134: assertNull("ex.getMessage()", ex.getMessage());
135: }
136: }
137:
138: /**
139: *
140: */
141: public void testParseXMLThrowsNullPointerException()
142: throws Throwable {
143: try {
144: XMLUtil.parseXML((File) null, true);
145: fail("Expected NullPointerException to be thrown");
146: } catch (NullPointerException ex) {
147: assertNull("ex.getMessage()", ex.getMessage());
148: assertNotNull("XMLUtil.logger", XMLUtil.logger);
149: }
150: }
151: }
|