01: package com.sun.portal.samples.asc.tests;
02:
03: import java.io.*;
04: import junit.framework.*;
05:
06: public class TestUtils {
07: public static String getString(InputStream is) throws IOException {
08: StringBuffer sb = new StringBuffer();
09: InputStreamReader reader = new InputStreamReader(is);
10: char[] cbuf = new char[256];
11: int count = 0;
12: while ((count = reader.read(cbuf, 0, 256)) != -1) {
13: sb.append(cbuf, 0, count);
14: }
15:
16: return (sb.toString());
17: }
18:
19: public static void fail(TestCase test, Exception e) {
20: StringWriter stsw = new StringWriter();
21: PrintWriter stpw = new PrintWriter(stsw);
22: e.printStackTrace(stpw);
23:
24: StringBuffer msg = new StringBuffer();
25: msg.append("\n");
26: msg.append("----- message:\n");
27: msg.append(e.getMessage());
28: msg.append("\n");
29: msg.append("----- stacktrace:\n");
30: msg.append(stsw.toString());
31: msg.append("\n");
32: msg.append("\n");
33:
34: TestCase.fail(msg.toString());
35: }
36:
37: }
|