001: /*
002: ******************************************************************
003: Copyright (c) 200, Jeff Martin, Tim Bacon
004: All rights reserved.
005:
006: Redistribution and use in source and binary forms, with or without
007: modification, are permitted provided that the following conditions
008: are met:
009:
010: * Redistributions of source code must retain the above copyright
011: notice, this list of conditions and the following disclaimer.
012: * Redistributions in binary form must reproduce the above
013: copyright notice, this list of conditions and the following
014: disclaimer in the documentation and/or other materials provided
015: with the distribution.
016: * Neither the name of the xmlunit.sourceforge.net nor the names
017: of its contributors may be used to endorse or promote products
018: derived from this software without specific prior written
019: permission.
020:
021: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
022: "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
023: LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
024: FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
025: COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
026: INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
027: BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
028: LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
029: CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
030: LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
031: ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
032: POSSIBILITY OF SUCH DAMAGE.
033:
034: ******************************************************************
035: */
036:
037: package org.custommonkey.xmlunit;
038:
039: import java.io.IOException;
040:
041: import junit.framework.TestCase;
042:
043: /**
044: * JUnit test for DoctypeReader and DoctypeInputStream
045: */
046: public abstract class AbstractDoctypeTests extends TestCase {
047:
048: private static final String COMMENT = "<!-- comment -->";
049: protected static final String NO_DTD = "<document><element>one</element></document>";
050:
051: public abstract void testGetContent() throws IOException;
052:
053: protected abstract void assertEquals(String expected, String input,
054: String docType, String systemId) throws IOException;
055:
056: public void testRead() throws IOException {
057: String oz = "Chirurgische Verbesserungen sind g\u00fcnstig";
058: assertEquals("<!DOCTYPE Kylie SYSTEM \"bumJob\">" + oz, oz,
059: "Kylie", "bumJob");
060: }
061:
062: public void testInternalDTD() throws IOException {
063: assertEquals("<!DOCTYPE ni SYSTEM \"shrubbery\">",
064: test_Constants.CHUCK_JONES_RIP_DTD_DECL, "ni",
065: "shrubbery");
066: }
067:
068: public void testExternalDTD() throws IOException {
069: assertEquals("<!DOCTYPE ni SYSTEM \"shrubbery\">",
070: "<! DOCTYPE PUBLIC \"yak\" SYSTEM \"llama\">", "ni",
071: "shrubbery");
072: }
073:
074: public void testNoDTD() throws IOException {
075: assertEquals("<!DOCTYPE ni SYSTEM \"shrubbery\">" + NO_DTD,
076: NO_DTD, "ni", "shrubbery");
077: }
078:
079: public void testNoDTDButXMLDecl() throws IOException {
080: assertEquals(test_Constants.XML_DECLARATION
081: + "<!DOCTYPE ni SYSTEM \"shrubbery\">" + NO_DTD,
082: test_Constants.XML_DECLARATION + NO_DTD, "ni",
083: "shrubbery");
084: }
085:
086: public void testInternalDTDWithComment() throws IOException {
087: assertEquals(test_Constants.XML_DECLARATION
088: + "<!DOCTYPE ni SYSTEM \"shrubbery\">" + COMMENT,
089: test_Constants.XML_DECLARATION + COMMENT
090: + test_Constants.CHUCK_JONES_RIP_DTD_DECL,
091: "ni", "shrubbery");
092: }
093:
094: public void testExternalDTDWithComment() throws IOException {
095: assertEquals(
096: "<!DOCTYPE ni SYSTEM \"shrubbery\">" + COMMENT,
097: COMMENT + "<! DOCTYPE PUBLIC \"yak\" SYSTEM \"llama\">",
098: "ni", "shrubbery");
099: }
100:
101: public void testNoDTDWithComment() throws IOException {
102: assertEquals("<!DOCTYPE ni SYSTEM \"shrubbery\">" + COMMENT
103: + NO_DTD, COMMENT + NO_DTD, "ni", "shrubbery");
104: }
105:
106: public void testNoDTDButXMLDeclWithComment() throws IOException {
107: assertEquals(test_Constants.XML_DECLARATION
108: + "<!DOCTYPE ni SYSTEM \"shrubbery\">" + COMMENT
109: + NO_DTD, test_Constants.XML_DECLARATION + COMMENT
110: + NO_DTD, "ni", "shrubbery");
111: }
112:
113: public AbstractDoctypeTests(String name) {
114: super(name);
115: }
116: }
|