aboutsummaryrefslogtreecommitdiffstats
path: root/runtime/testsrc
diff options
context:
space:
mode:
authorwisberg <wisberg>2004-01-15 05:21:33 +0000
committerwisberg <wisberg>2004-01-15 05:21:33 +0000
commitad2fb7a583f7451f3101f8101b090999d6a43341 (patch)
tree9992a19e70f68b6c9a084322ad0f69b6e5449978 /runtime/testsrc
parent9122ff2963909f54608b43cdb454a1282cbd9e16 (diff)
downloadaspectj-ad2fb7a583f7451f3101f8101b090999d6a43341.tar.gz
aspectj-ad2fb7a583f7451f3101f8101b090999d6a43341.zip
47952 fix: SoftException.printStackTrace(..) prints wrapped throwable (if not >= 1.4)
tested in 1.1, 1.3, 1.4 (but not in 1.1 release tests)
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"));
}
}