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
This commit is contained in:
Phil Steitz 2005-06-26 03:26:42 +00:00
parent a5c011a640
commit 6161ecdc32
1 changed files with 17 additions and 1 deletions

View File

@ -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);
}
}
}