aboutsummaryrefslogtreecommitdiffstats
path: root/runtime/testsrc
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/testsrc')
-rw-r--r--runtime/testsrc/RuntimeModuleTests.java55
1 files changed, 48 insertions, 7 deletions
diff --git a/runtime/testsrc/RuntimeModuleTests.java b/runtime/testsrc/RuntimeModuleTests.java
index a426025c5..ff7560c8e 100644
--- a/runtime/testsrc/RuntimeModuleTests.java
+++ b/runtime/testsrc/RuntimeModuleTests.java
@@ -11,10 +11,11 @@
* Xerox/PARC initial implementation
* ******************************************************************/
-
// default package
-import org.aspectj.lang.NoAspectBoundException;
+import java.io.*;
+
+import org.aspectj.lang.*;
import junit.framework.*;
@@ -27,12 +28,52 @@ public class RuntimeModuleTests extends TestCase {
}
public RuntimeModuleTests(String name) { super(name); }
-
- public void testNothing() {}
public void testNoAspectBoundException() {
- RuntimeException fun = new RuntimeException("fun");
- NoAspectBoundException nab = new NoAspectBoundException("Foo", fun);
- assertEquals(fun,nab.getCause());
+ RuntimeException fun = new RuntimeException("fun");
+ NoAspectBoundException nab = new NoAspectBoundException("Foo", fun);
+ assertEquals(fun,nab.getCause());
+ }
+
+ public void testSoftExceptionPrintStackTrace() {
+ // let's see
+// Throwable t = new Error("xyz");
+// new SoftException(t).printStackTrace();
+
+ // save to specified PrintStream
+ ByteArrayOutputStream sink = new ByteArrayOutputStream();
+ PrintStream out = new PrintStream(sink);
+ new SoftException(new Error("xyz")).printStackTrace(out);
+ String s = new String(sink.toByteArray());
+ out.flush();
+ checkSoftExceptionString(s);
+
+ // save to specified PrintWriter
+ sink = new ByteArrayOutputStream();
+ PrintWriter pout = new PrintWriter(sink);
+ new SoftException(new Error("xyz")).printStackTrace(pout);
+ pout.flush();
+ s = new String(sink.toByteArray());
+ checkSoftExceptionString(s);
+
+ // check System.err redirect
+ PrintStream systemErr = System.err;
+ try {
+ sink = new ByteArrayOutputStream();
+ out = new PrintStream(sink);
+ System.setErr(out);
+ new SoftException(new Error("xyz")).printStackTrace();
+ out.flush();
+ s = new String(sink.toByteArray());
+ checkSoftExceptionString(s);
+ } finally {
+ System.setErr(systemErr);
+ }
+ }
+ static void checkSoftExceptionString(String s) {
+ assertTrue(-1 != s.indexOf("SoftException"));
+ assertTrue(-1 != s.indexOf("Caused by: java.lang.Error"));
+ assertTrue(-1 != s.indexOf("xyz"));
+ assertTrue(-1 != s.indexOf("testSoftExceptionPrintStackTrace"));
}
}