KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > htmlparser > tests > AssertXmlEqualsTest


1 // HTMLParser Library $Name: v1_5_20050313 $ - A java-based parser for HTML
2
// http://sourceforge.org/projects/htmlparser
3
// Copyright (C) 2004 Somik Raha
4
//
5
// Revision Control Information
6
//
7
// $Source: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/AssertXmlEqualsTest.java,v $
8
// $Author: derrickoswald $
9
// $Date: 2004/01/02 16:24:55 $
10
// $Revision: 1.18 $
11
//
12
// This library is free software; you can redistribute it and/or
13
// modify it under the terms of the GNU Lesser General Public
14
// License as published by the Free Software Foundation; either
15
// version 2.1 of the License, or (at your option) any later version.
16
//
17
// This library is distributed in the hope that it will be useful,
18
// but WITHOUT ANY WARRANTY; without even the implied warranty of
19
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20
// Lesser General Public License for more details.
21
//
22
// You should have received a copy of the GNU Lesser General Public
23
// License along with this library; if not, write to the Free Software
24
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
//
26

27 package org.htmlparser.tests;
28
29 import junit.framework.TestSuite;
30
31
32 public class AssertXmlEqualsTest extends ParserTestCase {
33
34     static
35     {
36         System.setProperty ("org.htmlparser.tests.AssertXmlEqualsTest", "AssertXmlEqualsTest");
37     }
38
39     public AssertXmlEqualsTest(String JavaDoc name) {
40         super(name);
41     }
42
43     public void testNestedTagWithText() throws Exception JavaDoc {
44         assertXmlEquals("nested with text","<hello> <hi>My name is Nothing</hi></hello>","<hello><hi>My name is Nothing</hi> </hello>");
45     }
46
47     public void testThreeTagsDifferent() throws Exception JavaDoc {
48         assertXmlEquals("two tags different","<someTag></someTag><someOtherTag>","<someTag/><someOtherTag>");
49     }
50
51     public void testOneTag() throws Exception JavaDoc {
52         assertXmlEquals("one tag","<someTag>","<someTag>");
53     }
54
55     public void testTwoTags() throws Exception JavaDoc {
56         assertXmlEquals("two tags","<someTag></someTag>","<someTag></someTag>");
57     }
58
59     public void testTwoTagsDifferent() throws Exception JavaDoc {
60         assertXmlEquals("two tags different","<someTag></someTag>","<someTag/>");
61     }
62
63     public void testTwoTagsDifferent2() throws Exception JavaDoc {
64         assertXmlEquals("two tags different","<someTag/>","<someTag></someTag>");
65     }
66
67     public void testTwoTagsWithSameAttributes() throws Exception JavaDoc {
68         assertXmlEquals("attributes","<tag name=\"John\" age=\"22\" sex=\"M\"/>","<tag sex=\"M\" name=\"John\" age=\"22\"/>");
69     }
70
71     public void testTagWithText() throws Exception JavaDoc {
72         assertXmlEquals("text","<hello> My name is Nothing</hello>","<hello>My name is Nothing </hello>");
73     }
74
75     public void testStringWithLineBreaks() throws Exception JavaDoc {
76         assertXmlEquals("string with line breaks","testing & refactoring","testing &\nrefactoring");
77     }
78
79     public static TestSuite suite() {
80         TestSuite suite = new TestSuite("XML Tests");
81         suite.addTestSuite(AssertXmlEqualsTest.class);
82         return (suite);
83     }
84 }
85
Popular Tags