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.FileNotFoundException;
040: import java.io.FileReader;
041: import java.io.StringReader;
042: import java.util.HashMap;
043:
044: import junit.framework.AssertionFailedError;
045: import junit.framework.TestSuite;
046:
047: import org.w3c.dom.Document;
048: import org.w3c.dom.Node;
049:
050: /**
051: * Test case used to test the XMLTestCase
052: */
053: public class test_XMLTestCase extends XMLTestCase {
054: private static final String PREFIX = "foo";
055: private static final String TEST_NS = "urn:org.example";
056: private static final NamespaceContext NS_CONTEXT;
057: static {
058: HashMap m = new HashMap();
059: m.put(PREFIX, TEST_NS);
060: NS_CONTEXT = new SimpleNamespaceContext(m);
061: }
062:
063: private final String[] control = new String[] {
064: "<root/>",
065: "<root></root>",
066: "<root>test</root>",
067: "<root attr=\"test\">test</root>",
068: "<test/>",
069: "<root>test</root>",
070: "<root attr=\"test\"/>",
071: "<root><outer><inner></inner></outer></root>",
072: "<root attr=\"test\"><outer>test<inner>test</inner></outer></root>",
073: "<root attr=\"test\"><outer>test<inner>test</inner></outer></root>" };
074: private final String[] test = new String[] {
075: "<fail/>",
076: "<fail/>",
077: "<fail>test</fail>",
078: "<root>test</root>",
079: "<fail/>",
080: "<root>fail</root>",
081: "<root attr=\"fail\"/>",
082: "<root><outer><inner>test</inner></outer></root>",
083: "<root attr=\"test\"><outer>fail<inner>test</inner></outer></root>",
084: "<root attr=\"fail\"><outer>test<inner>test</inner></outer></root>" };
085:
086: /**
087: * Test for the compareXML method.
088: */
089: public void testCompareXMLStrings() throws Exception {
090: for (int i = 0; i < control.length; i++) {
091: assertEquals("compareXML case " + i + " failed", true,
092: compareXML(control[i], control[i]).similar());
093: assertEquals("!compareXML case " + i + " failed", false,
094: compareXML(control[i], test[i]).similar());
095: }
096: }
097:
098: /**
099: * Test the comparision of two files
100: */
101: public void testXMLEqualsFiles() throws Exception {
102: assertXMLEqual(new FileReader(test_Constants.BASEDIR
103: + "/tests/etc/test1.xml"), new FileReader(
104: test_Constants.BASEDIR + "/tests/etc/test1.xml"));
105: assertXMLNotEqual(new FileReader(test_Constants.BASEDIR
106: + "/tests/etc/test1.xml"), new FileReader(
107: test_Constants.BASEDIR + "/tests/etc/test2.xml"));
108:
109: // Bug 956372
110: assertXMLEqual("equal message", new FileReader(
111: test_Constants.BASEDIR + "/tests/etc/test1.xml"),
112: new FileReader(test_Constants.BASEDIR
113: + "/tests/etc/test1.xml"));
114: assertXMLNotEqual("notEqual message", new FileReader(
115: test_Constants.BASEDIR + "/tests/etc/test1.xml"),
116: new FileReader(test_Constants.BASEDIR
117: + "/tests/etc/test2.xml"));
118:
119: try {
120: assertXMLNotEqual(new FileReader("nosuchfile.xml"),
121: new FileReader("nosuchfile.xml"));
122: fail("Expecting FileNotFoundException");
123: } catch (FileNotFoundException e) {
124: }
125: }
126:
127: /**
128: * Test for the assertXMLEquals method.
129: */
130: public void testXMLEqualsStrings() throws Exception {
131: for (int i = 0; i < control.length; i++) {
132: assertXMLEqual(
133: "assertXMLEquals test case " + i + " failed",
134: control[i], control[i]);
135: assertXMLNotEqual("assertXMLNotEquals test case" + i
136: + " failed", control[i], test[i]);
137: }
138: }
139:
140: /**
141: * Test for the assertXMLEquals method.
142: */
143: public void testXMLEqualsDocuments() throws Exception {
144: Document controlDocument, testDocument;
145: for (int i = 0; i < control.length; i++) {
146: controlDocument = XMLUnit.buildControlDocument(control[i]);
147: assertXMLEqual(
148: "assertXMLEquals test case " + i + " failed",
149: controlDocument, controlDocument);
150: testDocument = XMLUnit.buildTestDocument(test[i]);
151: assertXMLNotEqual("assertXMLNotEquals test case" + i
152: + " failed", controlDocument, testDocument);
153: }
154: }
155:
156: private static final String xpathValuesControlXML = "<root><outer attr=\"urk\"><inner attr=\"urk\">"
157: + "controlDocument</inner></outer></root>";
158: private static final String xpathValuesTestXML = "<root><outer attr=\"urk\"><inner attr=\"ugh\">"
159: + "testDocument</inner></outer></root>";
160: private static final String xpathValuesControlXMLNS = addNamespaceToDocument(xpathValuesControlXML);
161: private static final String xpathValuesTestXMLNS = addNamespaceToDocument(xpathValuesTestXML);
162:
163: public void testXpathValuesEqualUsingDocument() throws Exception {
164: Document controlDocument = XMLUnit
165: .buildControlDocument(xpathValuesControlXML);
166: Document testDocument = XMLUnit
167: .buildTestDocument(xpathValuesTestXML);
168:
169: assertXpathValuesEqual("//text()", "//inner/text()",
170: controlDocument);
171: assertXpathValuesEqual("//inner/@attr", controlDocument,
172: "//outer/@attr", testDocument);
173:
174: assertXpathValuesNotEqual("//inner/text()", "//outer/@attr",
175: controlDocument);
176: assertXpathValuesNotEqual("//inner/text()", controlDocument,
177: "//text()", testDocument);
178: }
179:
180: public void testXpathValuesEqualUsingDocumentNS() throws Exception {
181: Document controlDocument = XMLUnit
182: .buildControlDocument(xpathValuesControlXMLNS);
183: Document testDocument = XMLUnit
184: .buildTestDocument(xpathValuesTestXMLNS);
185:
186: assertXpathValuesNotEqual("//text()", "//inner/text()",
187: controlDocument);
188: XMLUnit.setXpathNamespaceContext(NS_CONTEXT);
189: assertXpathValuesEqual("//text()", "//" + PREFIX
190: + ":inner/text()", controlDocument);
191: assertXpathValuesEqual("//" + PREFIX + ":inner/@attr",
192: controlDocument, "//" + PREFIX + ":outer/@attr",
193: testDocument);
194:
195: assertXpathValuesNotEqual("//" + PREFIX + ":inner/text()", "//"
196: + PREFIX + ":outer/@attr", controlDocument);
197: assertXpathValuesNotEqual("//" + PREFIX + ":inner/text()",
198: controlDocument, "//text()", testDocument);
199: }
200:
201: public void testXpathValuesEqualUsingString() throws Exception {
202: assertXpathValuesEqual("//text()", "//inner/text()",
203: xpathValuesControlXML);
204: assertXpathValuesEqual("//inner/@attr", xpathValuesControlXML,
205: "//outer/@attr", xpathValuesTestXML);
206:
207: assertXpathValuesNotEqual("//inner/text()", "//outer/@attr",
208: xpathValuesControlXML);
209: assertXpathValuesNotEqual("//inner/text()",
210: xpathValuesControlXML, "//text()", xpathValuesTestXML);
211: }
212:
213: public void testXpathValuesEqualUsingStringNS() throws Exception {
214: assertXpathValuesNotEqual("//text()", "//inner/text()",
215: xpathValuesControlXMLNS);
216: XMLUnit.setXpathNamespaceContext(NS_CONTEXT);
217: assertXpathValuesEqual("//text()", "//" + PREFIX
218: + ":inner/text()", xpathValuesControlXMLNS);
219: assertXpathValuesEqual("//" + PREFIX + ":inner/@attr",
220: xpathValuesControlXMLNS,
221: "//" + PREFIX + ":outer/@attr", xpathValuesTestXMLNS);
222:
223: assertXpathValuesNotEqual("//" + PREFIX + ":inner/text()", "//"
224: + PREFIX + ":outer/@attr", xpathValuesControlXMLNS);
225: assertXpathValuesNotEqual("//" + PREFIX + ":inner/text()",
226: xpathValuesControlXMLNS, "//text()",
227: xpathValuesTestXMLNS);
228: }
229:
230: public void testXpathEvaluatesTo() throws Exception {
231: assertXpathEvaluatesTo("urk", "//outer/@attr",
232: xpathValuesControlXML);
233: try {
234: assertXpathEvaluatesTo("yum", "//inner/@attr",
235: xpathValuesControlXML);
236: fail("Expected assertion to fail #1");
237: } catch (AssertionFailedError e) {
238: }
239: assertXpathEvaluatesTo("2", "count(//@attr)",
240: xpathValuesControlXML);
241:
242: Document testDocument = XMLUnit
243: .buildTestDocument(xpathValuesTestXML);
244: assertXpathEvaluatesTo("ugh", "//inner/@attr", testDocument);
245: try {
246: assertXpathEvaluatesTo("yeah", "//outer/@attr",
247: testDocument);
248: fail("Expected assertion to fail #2");
249: } catch (AssertionFailedError e) {
250: }
251:
252: }
253:
254: public void testXpathEvaluatesToNS() throws Exception {
255: try {
256: assertXpathEvaluatesTo("urk", "//outer/@attr",
257: xpathValuesControlXMLNS);
258: fail("Expected assertion to fail #1");
259: } catch (AssertionFailedError e) {
260: }
261:
262: XMLUnit.setXpathNamespaceContext(NS_CONTEXT);
263: assertXpathEvaluatesTo("urk", "//" + PREFIX + ":outer/@attr",
264: xpathValuesControlXMLNS);
265: try {
266: assertXpathEvaluatesTo("yum", "//" + PREFIX
267: + ":inner/@attr", xpathValuesControlXMLNS);
268: fail("Expected assertion to fail #2");
269: } catch (AssertionFailedError e) {
270: }
271: assertXpathEvaluatesTo("2", "count(//@attr)",
272: xpathValuesControlXMLNS);
273:
274: Document testDocument = XMLUnit
275: .buildTestDocument(xpathValuesTestXMLNS);
276: assertXpathEvaluatesTo("ugh", "//" + PREFIX + ":inner/@attr",
277: testDocument);
278: try {
279: assertXpathEvaluatesTo("yeah", "//" + PREFIX
280: + ":outer/@attr", testDocument);
281: fail("Expected assertion to fail #3");
282: } catch (AssertionFailedError e) {
283: }
284:
285: }
286:
287: public void testNodeTest() throws Exception {
288: NodeTester tester = new CountingNodeTester(1);
289: assertNodeTestPasses(xpathValuesControlXML, tester,
290: Node.TEXT_NODE);
291: try {
292: assertNodeTestPasses(xpathValuesControlXML, tester,
293: Node.ELEMENT_NODE);
294: fail("Expected node test failure #1!");
295: } catch (AssertionFailedError e) {
296: }
297:
298: NodeTest test = new NodeTest(new StringReader(
299: xpathValuesTestXML));
300: tester = new CountingNodeTester(4);
301: assertNodeTestPasses(test, tester, new short[] {
302: Node.TEXT_NODE, Node.ELEMENT_NODE }, true);
303: assertNodeTestPasses(test, tester, new short[] {
304: Node.TEXT_NODE, Node.COMMENT_NODE }, false);
305:
306: try {
307: assertNodeTestPasses(test, tester, new short[] {
308: Node.TEXT_NODE, Node.ELEMENT_NODE }, false);
309: fail("Expected node test failure #2!");
310: assertNodeTestPasses(test, tester, new short[] {
311: Node.TEXT_NODE, Node.COMMENT_NODE }, true);
312: fail("Expected node test failure #3!");
313: } catch (AssertionFailedError e) {
314: }
315: }
316:
317: public void testXMLValid() {
318: // see test_Validator class
319: }
320:
321: private static final String TREES_OPEN = "<trees>";
322: private static final String TREES_CLOSE = "</trees>";
323: private static final String xpathNodesControlXML = TREES_OPEN
324: + "<tree evergreen=\"false\">oak</tree>"
325: + "<tree evergreen=\"false\">ash</tree>"
326: + "<tree evergreen=\"true\">scots pine</tree>"
327: + "<tree evergreen=\"true\">spruce</tree>"
328: + "<favourite><!-- is this a tree or a bush?! -->"
329: + "<tree evergreen=\"false\">magnolia</tree>"
330: + "</favourite>"
331: + "<fruit>"
332: + "<apples><crunchy/><yum/><tree evergreen=\"false\">apple</tree></apples>"
333: + "</fruit>" + TREES_CLOSE;
334: private static final String xpathNodesTestXML = TREES_OPEN
335: + "<tree evergreen=\"false\">oak</tree>"
336: + "<tree evergreen=\"false\">ash</tree>"
337: + "<tree evergreen=\"true\">scots pine</tree>"
338: + "<tree evergreen=\"true\">spruce</tree>"
339: + "<tree flowering=\"true\">cherry</tree>"
340: + "<tree flowering=\"true\">apple</tree>"
341: + "<favourite><!-- is this a tree or a bush?! -->"
342: + "<tree evergreen=\"false\">magnolia</tree>"
343: + "</favourite>"
344: + "<apples><crunchy/><yum/><tree evergreen=\"false\">apple</tree></apples>"
345: + TREES_CLOSE;
346:
347: public void testXpathsEqual() throws Exception {
348: Document controlDoc = XMLUnit
349: .buildControlDocument(xpathNodesControlXML);
350: Document testDoc = XMLUnit.buildTestDocument(xpathNodesTestXML);
351:
352: String[] controlXpath = new String[] {
353: "/trees/tree[@evergreen]",
354: "//tree[@evergreen='false']", "/trees/favourite",
355: "//fruit/apples" };
356: String[] testXpath = { controlXpath[0], controlXpath[1],
357: "//favourite", "//apples" };
358:
359: // test positive passes
360: for (int i = 0; i < controlXpath.length; ++i) {
361: assertXpathsEqual(controlXpath[i], controlDoc,
362: testXpath[i], testDoc);
363: assertXpathsEqual(controlXpath[i], xpathNodesControlXML,
364: testXpath[i], xpathNodesTestXML);
365: assertXpathsEqual(controlXpath[i], testXpath[i], controlDoc);
366: assertXpathsEqual(controlXpath[i], testXpath[i],
367: xpathNodesControlXML);
368: }
369: // test negative fails
370: for (int i = 0; i < controlXpath.length; ++i) {
371: try {
372: assertXpathsNotEqual(controlXpath[i], controlDoc,
373: testXpath[i], testDoc);
374: fail("should not be notEqual!");
375: } catch (AssertionFailedError e) {
376: }
377: try {
378: assertXpathsNotEqual(controlXpath[i],
379: xpathNodesControlXML, testXpath[i],
380: xpathNodesTestXML);
381: fail("should not be notEqual!");
382: } catch (AssertionFailedError e) {
383: }
384: try {
385: assertXpathsNotEqual(controlXpath[i], testXpath[i],
386: controlDoc);
387: fail("should not be notEqual!");
388: } catch (AssertionFailedError e) {
389: }
390: try {
391: assertXpathsNotEqual(controlXpath[i], testXpath[i],
392: xpathNodesControlXML);
393: fail("should not be notEqual!");
394: } catch (AssertionFailedError e) {
395: }
396: }
397: }
398:
399: public void testXpathsNotEqual() throws Exception {
400: Document controlDoc = XMLUnit
401: .buildControlDocument(xpathNodesControlXML);
402: Document testDoc = XMLUnit.buildTestDocument(xpathNodesTestXML);
403:
404: String[] controlXpath = new String[] {
405: "/trees/tree[@evergreen]",
406: "//tree[@evergreen='false']", "/trees/favourite",
407: "//fruit/apples" };
408: String[] testXpath = { "//tree", "//tree[@evergreen='true']",
409: "//favourite/apples", "//apples/tree" };
410:
411: // test positive passes
412: for (int i = 0; i < controlXpath.length; ++i) {
413: assertXpathsNotEqual(controlXpath[i], controlDoc,
414: testXpath[i], testDoc);
415: assertXpathsNotEqual(controlXpath[i], xpathNodesControlXML,
416: testXpath[i], xpathNodesTestXML);
417: assertXpathsNotEqual(controlXpath[i], testXpath[i],
418: controlDoc);
419: assertXpathsNotEqual(controlXpath[i], testXpath[i],
420: xpathNodesControlXML);
421: }
422: // test negative fails
423: for (int i = 0; i < controlXpath.length; ++i) {
424: try {
425: assertXpathsEqual(controlXpath[i], controlDoc,
426: testXpath[i], testDoc);
427: fail("should not be Equal!");
428: } catch (AssertionFailedError e) {
429: }
430: try {
431: assertXpathsEqual(controlXpath[i],
432: xpathNodesControlXML, testXpath[i],
433: xpathNodesTestXML);
434: fail("should not be Equal!");
435: } catch (AssertionFailedError e) {
436: }
437: try {
438: assertXpathsEqual(controlXpath[i], testXpath[i],
439: controlDoc);
440: fail("should not be Equal!");
441: } catch (AssertionFailedError e) {
442: }
443: try {
444: assertXpathsEqual(controlXpath[i], testXpath[i],
445: xpathNodesControlXML);
446: fail("should not be Equal!");
447: } catch (AssertionFailedError e) {
448: }
449: }
450: }
451:
452: public void testDocumentAssertXpathExists() throws Exception {
453: Document controlDoc = XMLUnit
454: .buildControlDocument(xpathNodesControlXML);
455: assertXpathExists("/trees/fruit/apples/yum", controlDoc);
456: assertXpathExists("//tree[@evergreen='false']", controlDoc);
457: try {
458: assertXpathExists("//tree[@evergreen='idunno']", controlDoc);
459: fail("Xpath does not exist");
460: } catch (AssertionFailedError e) {
461: // expected
462: }
463: }
464:
465: public void testStringAssertXpathExists() throws Exception {
466: assertXpathExists("/trees/fruit/apples/yum",
467: xpathNodesControlXML);
468: assertXpathExists("//tree[@evergreen='false']",
469: xpathNodesControlXML);
470: try {
471: assertXpathExists("//tree[@evergreen='idunno']",
472: xpathNodesControlXML);
473: fail("Xpath does not exist");
474: } catch (AssertionFailedError e) {
475: // expected
476: }
477: }
478:
479: public void testDocumentAssertNotXpathExists() throws Exception {
480: Document controlDoc = XMLUnit
481: .buildControlDocument(xpathNodesControlXML);
482: assertXpathNotExists("//tree[@evergreen='idunno']", controlDoc);
483: try {
484: assertXpathNotExists("/trees/fruit/apples/yum", controlDoc);
485: fail("Xpath does exist, once");
486: } catch (AssertionFailedError e) {
487: // expected
488: }
489: try {
490: assertXpathNotExists("//tree[@evergreen='false']",
491: controlDoc);
492: fail("Xpath does exist many times");
493: } catch (AssertionFailedError e) {
494: // expected
495: }
496: }
497:
498: public void testStringAssertNotXpathExists() throws Exception {
499: assertXpathNotExists("//tree[@evergreen='idunno']",
500: xpathNodesControlXML);
501: try {
502: assertXpathNotExists("/trees/fruit/apples/yum",
503: xpathNodesControlXML);
504: fail("Xpath does exist, once");
505: } catch (AssertionFailedError e) {
506: // expected
507: }
508: try {
509: assertXpathNotExists("//tree[@evergreen='false']",
510: xpathNodesControlXML);
511: fail("Xpath does exist many times");
512: } catch (AssertionFailedError e) {
513: // expected
514: }
515: }
516:
517: // Bug 585555
518: public void testUnusedNamespacesDontMatter() throws Exception {
519: boolean startValueIgnoreWhitespace = XMLUnit
520: .getIgnoreWhitespace();
521: try {
522: XMLUnit.setIgnoreWhitespace(true);
523: String a = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
524: + "<outer xmlns:NS2=\"http://namespace2/foo\">\n"
525: + " <inner xmlns:NS2=\"http://namespace2/\">5</inner>\n"
526: + "</outer>\n";
527:
528: String b = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
529: + "<outer xmlns:NS2=\"http://namespace2\">\n"
530: + " <inner xmlns:NS2=\"http://namespace2/\">5</inner>\n"
531: + "</outer>\n";
532:
533: assertXMLEqual(a, b);
534: } finally {
535: XMLUnit.setIgnoreWhitespace(startValueIgnoreWhitespace);
536: }
537: }
538:
539: // Bug 585555
540: public void testNamespaceMatters() throws Exception {
541: boolean startValueIgnoreWhitespace = XMLUnit
542: .getIgnoreWhitespace();
543: try {
544: XMLUnit.setIgnoreWhitespace(true);
545: String a = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
546: + "<outer xmlns=\"http://namespace2/\">\n"
547: + "</outer>";
548:
549: String b = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
550: + "<outer xmlns=\"http://namespace2\">\n"
551: + "</outer>\n";
552:
553: assertXMLNotEqual(a, b);
554: } finally {
555: XMLUnit.setIgnoreWhitespace(startValueIgnoreWhitespace);
556: }
557: }
558:
559: // Bug 741636
560: public void testXpathCount() throws Exception {
561: assertXpathEvaluatesTo("25", "count(//td)", "<div><p>"
562: + "</p><table><tr><td><p>" + "</p></td><td><p>"
563: + "</p></td><td><p>" + "</p></td><td><p>"
564: + "</p></td><td><p>" + "</p></td></tr><tr><td><p>"
565: + "</p></td><td><p>" + "</p></td><td><p>"
566: + "</p></td><td><p>" + "</p></td><td><p>"
567: + "</p></td></tr><tr><td><p>" + "</p></td><td><p>"
568: + "</p></td><td><p>" + "</p></td><td><p>"
569: + "</p></td><td><p>" + "</p></td></tr><tr><td><p>"
570: + "</p></td><td><p>" + "</p></td><td><p>"
571: + "</p></td><td><p>" + "</p></td><td><p>"
572: + "</p></td></tr><tr><td><p>" + "</p></td><td><p>"
573: + "</p></td><td><p>" + "</p></td><td><p>"
574: + "</p></td><td><p>" + "</p></td></tr></table></div>");
575: }
576:
577: // bug 1418497
578: public void testAssertXpathExistsFails() throws Exception {
579: String xmlDocument = "<axrtable> <schema name=\"emptySchema\"><relation name=\"\"></relation></schema></axrtable>";
580: assertXpathExists("/axrtable/schema", xmlDocument);
581: }
582:
583: public test_XMLTestCase(String name) {
584: super (name);
585: }
586:
587: private static String addNamespaceToDocument(String original) {
588: int pos = original.indexOf(">");
589: return original.substring(0, pos) + " xmlns='" + TEST_NS + "'"
590: + original.substring(pos);
591: }
592:
593: public void tearDown() {
594: XMLUnit.setXpathNamespaceContext(null);
595: }
596:
597: /**
598: * returns the TestSuite containing this test
599: */
600: public static TestSuite suite() {
601: return new TestSuite(test_XMLTestCase.class);
602: }
603: }
|