01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18: package org.apache.tools.ant.taskdefs.optional.junit;
19:
20: import java.io.File;
21: import java.io.FileReader;
22: import java.io.IOException;
23: import org.apache.tools.ant.BuildFileTest;
24: import org.apache.tools.ant.util.FileUtils;
25:
26: public class XMLFormatterWithCDATAOnSystemOut extends BuildFileTest {
27:
28: private static String DIR = "src/etc/testcases/taskdefs/optional/junit";
29: private static String REPORT = "TEST-"
30: + XMLFormatterWithCDATAOnSystemOut.class.getName() + ".xml";
31:
32: private static String TESTDATA = "<ERROR>"
33: + "<![CDATA[<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
34: + " <RESPONSE>" + " <GDS/>" + " <ERROR>"
35: + " <ID/>" + " <MESSAGE/>"
36: + " <REQUEST_TYPE/>" + " <RESEND/>"
37: + " <RAW_RESPONSE/>" + " </ERROR>"
38: + " </RESPONSE>" + "]]>" + "</ERROR>";
39:
40: public XMLFormatterWithCDATAOnSystemOut(String name) {
41: super (name);
42: }
43:
44: public void testOutput() {
45: System.out.println(TESTDATA);
46: }
47:
48: public void testBuildfile() throws IOException {
49: configureProject(DIR + "/cdataoutput.xml");
50: if (getProject().getProperty("cdata.inner") == null) {
51: // avoid endless loop
52: executeTarget("run-junit");
53: File f = getProject().resolveFile(REPORT);
54: FileReader reader = null;
55: try {
56: reader = new FileReader(f);
57: String content = FileUtils.readFully(reader);
58: assertTrue(content
59: .indexOf("</RESPONSE>]]>"
60: + "</ERROR>") > 0);
61: } finally {
62: if (reader != null) {
63: reader.close();
64: }
65: f.delete();
66: }
67: }
68: }
69:
70: }
|