01: package org.objectweb.celtix.tools.common;
02:
03: import java.io.ByteArrayOutputStream;
04: import java.io.PrintStream;
05: import java.net.URL;
06:
07: import junit.framework.TestCase;
08:
09: public abstract class ToolTestBase extends TestCase {
10:
11: protected PrintStream oldStdErr;
12: protected PrintStream oldStdOut;
13: protected URL wsdlLocation;
14:
15: protected ByteArrayOutputStream errOut = new ByteArrayOutputStream();
16: protected ByteArrayOutputStream stdOut = new ByteArrayOutputStream();
17:
18: public void setUp() {
19:
20: oldStdErr = System.err;
21: oldStdOut = System.out;
22:
23: System.setErr(new PrintStream(errOut));
24: System.setOut(new PrintStream(stdOut));
25:
26: wsdlLocation = ToolTestBase.class
27: .getResource("/wsdl/hello_world.wsdl");
28: }
29:
30: public void tearDown() {
31:
32: System.setErr(oldStdErr);
33: System.setOut(oldStdOut);
34: }
35:
36: protected String getStdOut() {
37: return new String(stdOut.toByteArray());
38: }
39:
40: protected String getStdErr() {
41: return new String(errOut.toByteArray());
42: }
43:
44: }
|