1   package org.apache.commons.betwixt.xmlunit;
2   
3   /*
4    * Copyright 2001-2004 The Apache Software Foundation.
5    * 
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    * 
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   * 
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */ 
18  
19  import junit.framework.AssertionFailedError;
20  
21  /***
22   * Test harness which test xml unit
23   *
24   * @author Robert Burrell Donkin
25   * @version $Id: TestXmlTestCase.java,v 1.5 2004/02/28 13:38:37 yoavs Exp $
26   */
27   public class TestXmlTestCase extends XmlTestCase {
28   
29      public TestXmlTestCase(String name) {
30          super(name);
31      }
32   
33      public void testXMLUnit() throws Exception {
34          xmlAssertIsomorphicContent(
35                      parseFile("src/test/org/apache/commons/betwixt/xmlunit/rss-example.xml"),
36                      parseFile("src/test/org/apache/commons/betwixt/xmlunit/rss-example.xml"));
37      }
38      
39      public void testXMLUnit2() throws Exception {
40          boolean failed = false;
41          try {
42              xmlAssertIsomorphicContent(
43                      parseFile("src/test/org/apache/commons/betwixt/xmlunit/rss-example.xml"),
44                      parseFile("src/test/org/apache/commons/betwixt/xmlunit/rss-example-morphed.xml"),
45                      false);
46              failed = true;
47          } catch (AssertionFailedError er) {
48              // this is expected
49          }
50          if (failed) {
51              fail("Expected unit test to fail!");
52          }
53      }
54      
55      public void testXMLUnit3() throws Exception {
56          boolean failed = false;
57          try {
58              xmlAssertIsomorphicContent(
59                      parseFile("src/test/org/apache/commons/betwixt/xmlunit/rss-example.xml"),
60                      parseFile("src/test/org/apache/commons/betwixt/xmlunit/rss-example-not.xml"));
61              failed = true;
62          } catch (AssertionFailedError er) {
63              // this is expected
64          }
65          if (failed) {
66              fail("Expected unit test to fail!");
67          }
68      }
69  
70      
71      public void testXMLUnit4() throws Exception {
72          xmlAssertIsomorphicContent(
73                      parseFile("src/test/org/apache/commons/betwixt/xmlunit/rss-example.xml"),
74                      parseFile("src/test/org/apache/commons/betwixt/xmlunit/rss-example-morphed.xml"),
75                      true);
76      }
77      
78      
79      public void testXMLUnit5() throws Exception {
80          boolean failed = false;
81          try {
82              xmlAssertIsomorphicContent(
83                      parseFile("src/test/org/apache/commons/betwixt/xmlunit/rss-example.xml"),
84                      parseFile("src/test/org/apache/commons/betwixt/xmlunit/rss-example-not.xml"),
85                      true);
86              failed = true;
87          } catch (AssertionFailedError er) {
88              // this is expected
89          }
90          if (failed) {
91              fail("Expected unit test to fail!");
92          }
93      }
94      
95      
96      public void testXMLUnit6() throws Exception {
97          boolean failed = false;
98          try {
99              xmlAssertIsomorphicContent(
100                     parseFile("src/test/org/apache/commons/betwixt/xmlunit/scarab-one.xml"),
101                     parseFile("src/test/org/apache/commons/betwixt/xmlunit/scarab-two.xml"),
102                     true);
103             failed = true;
104         } catch (AssertionFailedError er) {
105             // this is expected
106         }
107         if (failed) {
108             fail("Expected unit test to fail!");
109         }
110     }
111 }