KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > taskdefs > optional > junit > JUnitTaskMirror


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * 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
19 package org.apache.tools.ant.taskdefs.optional.junit;
20
21 import java.io.IOException JavaDoc;
22 import java.io.OutputStream JavaDoc;
23 import org.apache.tools.ant.AntClassLoader;
24 import org.apache.tools.ant.types.Permissions;
25
26 /**
27  * Handles the portions of {@link JUnitTask} which need to directly access
28  * actual JUnit classes, so that junit.jar need not be on Ant's startup classpath.
29  * Neither JUnitTask.java nor JUnitTaskMirror.java nor their transitive static
30  * deps may import any junit.** classes!
31  * Specifically, need to not refer to
32  * - JUnitResultFormatter or its subclasses
33  * - JUnitVersionHelper
34  * - JUnitTestRunner
35  * Cf. JUnitTask.SplitLoader#isSplit(String)
36  * Public only to permit access from classes in this package; do not use directly.
37  *
38  * @since 1.7
39  * @see "bug #38799"
40  */

41 public interface JUnitTaskMirror {
42
43     /**
44      * Add the formatter to be called when the jvm exits before
45      * the test suite finishs.
46      * @param test the test.
47      * @param formatter the fomatter to use.
48      * @param out the output stream to use.
49      * @param message the message to write out.
50      * @param testCase the name of the test.
51      */

52     void addVmExit(JUnitTest test, JUnitResultFormatterMirror formatter,
53             OutputStream JavaDoc out, String JavaDoc message, String JavaDoc testCase);
54
55     /**
56      * Create a new test runner for a test.
57      * @param test the test to run.
58      * @param haltOnError if true halt the tests if an error occurs.
59      * @param filterTrace if true filter the stack traces.
60      * @param haltOnFailure if true halt the test if a failure occurs.
61      * @param showOutput if true show output.
62      * @param logTestListenerEvents if true log test listener events.
63      * @param classLoader the classloader to use to create the runner.
64      * @return the test runner.
65      */

66     JUnitTestRunnerMirror newJUnitTestRunner(JUnitTest test, boolean haltOnError,
67             boolean filterTrace, boolean haltOnFailure, boolean showOutput,
68             boolean logTestListenerEvents, AntClassLoader classLoader);
69
70     /**
71      * Create a summary result formatter.
72      * @return the created formatter.
73      */

74     SummaryJUnitResultFormatterMirror newSummaryJUnitResultFormatter();
75
76
77     /** The interface that JUnitResultFormatter extends. */
78     public interface JUnitResultFormatterMirror {
79         /**
80          * Set the output stream.
81          * @param outputStream the stream to use.
82          */

83         void setOutput(OutputStream JavaDoc outputStream);
84     }
85
86     /** The interface that SummaryJUnitResultFormatter extends. */
87     public interface SummaryJUnitResultFormatterMirror
88         extends JUnitResultFormatterMirror {
89
90         /**
91          * Set where standard out and standard error should be included.
92          * @param value if true include the outputs in the summary.
93          */

94         void setWithOutAndErr(boolean value);
95     }
96
97     /** Interface that test runners implement. */
98     public interface JUnitTestRunnerMirror {
99
100         /**
101          * Used in formatter arguments as a placeholder for the basename
102          * of the output file (which gets replaced by a test specific
103          * output file name later).
104          *
105          * @since Ant 1.6.3
106          */

107         String JavaDoc IGNORED_FILE_NAME = "IGNORETHIS";
108
109         /**
110          * No problems with this test.
111          */

112         int SUCCESS = 0;
113
114         /**
115          * Some tests failed.
116          */

117         int FAILURES = 1;
118
119         /**
120          * An error occurred.
121          */

122         int ERRORS = 2;
123
124         /**
125          * Permissions for the test run.
126          * @param perm the permissions to use.
127          */

128         void setPermissions(Permissions perm);
129
130         /** Run the test. */
131         void run();
132
133         /**
134          * Add a formatter to the test.
135          * @param formatter the formatter to use.
136          */

137         void addFormatter(JUnitResultFormatterMirror formatter);
138
139         /**
140          * Returns what System.exit() would return in the standalone version.
141          *
142          * @return 2 if errors occurred, 1 if tests failed else 0.
143          */

144         int getRetCode();
145
146         /**
147          * Handle output sent to System.err.
148          *
149          * @param output coming from System.err
150          */

151         void handleErrorFlush(String JavaDoc output);
152
153         /**
154          * Handle output sent to System.err.
155          *
156          * @param output output for System.err
157          */

158         void handleErrorOutput(String JavaDoc output);
159
160         /**
161          * Handle output sent to System.out.
162          *
163          * @param output output for System.out.
164          */

165         void handleOutput(String JavaDoc output);
166
167         /**
168          * Handle an input request.
169          *
170          * @param buffer the buffer into which data is to be read.
171          * @param offset the offset into the buffer at which data is stored.
172          * @param length the amount of data to read.
173          *
174          * @return the number of bytes read.
175          *
176          * @exception IOException if the data cannot be read.
177          */

178         int handleInput(byte[] buffer, int offset, int length) throws IOException JavaDoc;
179
180         /**
181          * Handle output sent to System.out.
182          *
183          * @param output output for System.out.
184          */

185        void handleFlush(String JavaDoc output);
186
187     }
188 }
189
Popular Tags