From 6161ecdc3268fb146cf2c3268a295ad6fdc21063 Mon Sep 17 00:00:00 2001 From: Phil Steitz Date: Sun, 26 Jun 2005 03:26:42 +0000 Subject: [PATCH] Emasculated MathException secalization test to work under jdk 1.3. git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/math/trunk@201820 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/commons/math/MathExceptionTest.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/test/org/apache/commons/math/MathExceptionTest.java b/src/test/org/apache/commons/math/MathExceptionTest.java index f1edeb98d..0d7696e28 100644 --- a/src/test/org/apache/commons/math/MathExceptionTest.java +++ b/src/test/org/apache/commons/math/MathExceptionTest.java @@ -113,6 +113,22 @@ public class MathExceptionTest extends TestCase { PrintWriter pw2 = new PrintWriter(ps2, true); image.printStackTrace(ps2); String stack2 = baos2.toString(); - assertEquals(stack, stack2); + + // See if JDK supports nested exceptions. If not, stack trace of + // inner exception will not be serialized + boolean jdkSupportsNesting = false; + try { + Throwable.class.getDeclaredMethod("getCause", new Class[0]); + jdkSupportsNesting = true; + } catch (NoSuchMethodException e) { + jdkSupportsNesting = false; + } + + if (jdkSupportsNesting) { + assertEquals(stack, stack2); + } else { + assertTrue(stack2.indexOf(inMsg) != -1); + assertTrue(stack2.indexOf("MathConfigurationException") != -1); + } } }