001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: */
018:
019: package org.apache.tools.ant.taskdefs.optional.junit;
020:
021: import java.io.IOException;
022: import java.io.OutputStream;
023:
024: import junit.framework.AssertionFailedError;
025: import junit.framework.Test;
026:
027: import org.apache.tools.ant.BuildException;
028:
029: public class TestFormatter implements JUnitResultFormatter {
030:
031: private static final byte[] grafitto = new byte[] { (byte) 'T',
032: (byte) 'e', (byte) 's', (byte) 't', (byte) 'F', (byte) 'o',
033: (byte) 'r', (byte) 'm', (byte) 'a', (byte) 't', (byte) 't',
034: (byte) 'e', (byte) 'r', (byte) ' ', (byte) 'w', (byte) 'a',
035: (byte) 's', (byte) ' ', (byte) 'h', (byte) 'e', (byte) 'r',
036: (byte) 'e', 10 };
037:
038: /**
039: * Where to write the log to.
040: */
041: private OutputStream out;
042:
043: /**
044: * Empty
045: */
046: public TestFormatter() {
047: }
048:
049: /**
050: * Empty
051: */
052: public void startTestSuite(JUnitTest suite) {
053: }
054:
055: /**
056: * Empty
057: */
058: public void startTest(Test t) {
059: }
060:
061: /**
062: * Empty
063: */
064: public void endTest(Test test) {
065: }
066:
067: /**
068: * Empty
069: */
070: public void addFailure(Test test, Throwable t) {
071: }
072:
073: /**
074: * Empty
075: */
076: public void addFailure(Test test, AssertionFailedError t) {
077: }
078:
079: /**
080: * Empty
081: */
082: public void addError(Test test, Throwable t) {
083: }
084:
085: /**
086: * Empty
087: */
088: public void setSystemOutput(String out) {
089: }
090:
091: /**
092: * Empty
093: */
094: public void setSystemError(String err) {
095: }
096:
097: public void setOutput(OutputStream out) {
098: this .out = out;
099: }
100:
101: public void endTestSuite(JUnitTest suite) throws BuildException {
102: if (out != null) {
103: try {
104: out.write(grafitto);
105: out.flush();
106: } catch (IOException ioex) {
107: throw new BuildException("Unable to write output", ioex);
108: } finally {
109: if (out != System.out && out != System.err) {
110: try {
111: out.close();
112: } catch (IOException e) {
113: // ignore
114: }
115: }
116: }
117: }
118: }
119: }
|