1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package javax.jdo.util;
18
19 import java.io.PrintStream;
20
21 import junit.framework.TestCase;
22
23 /*** */
24 public class AbstractTest extends TestCase {
25
26 /*** */
27 protected static PrintStream out = System.out;
28
29 /*** If true, print extra messages. */
30 protected boolean verbose;
31
32 /***
33 * Construct and initialize from properties.
34 */
35 protected AbstractTest() {
36 super(null);
37 verbose = Boolean.getBoolean("verbose");
38 }
39
40 /***
41 */
42 protected void println(String s) {
43 if (verbose)
44 out.println(s);
45 }
46
47 /*** New line.
48 */
49 public static final String NL = System.getProperty("line.separator");
50
51 /*** A buffer of of error messages.
52 */
53 protected static StringBuffer messages;
54
55 /*** Appends to error messages.
56 */
57 protected static synchronized void appendMessage(String message) {
58 if (messages == null) {
59 messages = new StringBuffer();
60 }
61 messages.append(message);
62 messages.append(NL);
63 }
64
65 /***
66 * Returns collected error messages, or <code>null</code> if there
67 * are none, and clears the buffer.
68 */
69 protected static synchronized String retrieveMessages() {
70 if (messages == null) {
71 return null;
72 }
73 final String msg = messages.toString();
74 messages = null;
75 return msg;
76 }
77
78 }
79