01: /*
02: * ========================================================================
03: *
04: * Copyright 2004 The Apache Software Foundation.
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
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: */
20: package org.apache.cactus.internal.server.runner;
21:
22: import junit.framework.TestCase;
23: import junit.framework.TestResult;
24:
25: /**
26: * Unit tests for {@link XMLFormatter}.
27: *
28: * @version $Id: TestXMLFormatter.java 238991 2004-05-22 11:34:50Z vmassol $
29: */
30: public final class TestXMLFormatter extends TestCase {
31: /**
32: * Instance to unit test
33: */
34: private XMLFormatter formatter;
35:
36: /**
37: * TestResult object used for testing
38: */
39: private TestResult testResult;
40:
41: /**
42: * Set up common mock behaviors.
43: */
44: public void setUp() {
45: formatter = new XMLFormatter();
46: testResult = new TestResult();
47: }
48:
49: /**
50: * Verify that calling {@link XMLFormatter#toXML(TestResult)} works
51: * when using the default encoding.
52: */
53: public void testToXmlEmptyWithDefaultEncoding() {
54: String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
55: + "<testsuites><testsuite name=\"null\" tests=\"0\" failures=\"0\""
56: + " errors=\"0\" time=\"0\"></testsuite></testsuites>";
57:
58: String result = formatter.toXML(testResult);
59: assertEquals(expected, result);
60: }
61:
62: /**
63: * Verify that calling {@link XMLFormatter#toXML(TestResult)} works
64: * when using a custom encoding of ISO-8859-1.
65: */
66: public void testToXmlEmptyWithCustomEncoding() {
67: String expected = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"
68: + "<testsuites><testsuite name=\"null\" tests=\"0\" failures=\"0\""
69: + " errors=\"0\" time=\"0\"></testsuite></testsuites>";
70:
71: formatter.setEncoding("ISO-8859-1");
72: String result = formatter.toXML(testResult);
73: assertEquals(expected, result);
74: }
75: }
|