Consistent use of JDK 7 AssertionError with root cause

Issue: SPR-13188
This commit is contained in:
Juergen Hoeller 2016-08-29 11:53:00 +02:00
parent 655097a343
commit 728a548199
5 changed files with 9 additions and 10 deletions

View File

@ -237,22 +237,22 @@ public class JsonPathExpectationsHelper {
}
private Object evaluateJsonPath(String content) {
String message = "No value at JSON path \"" + this.expression + "\", exception: ";
String message = "No value at JSON path \"" + this.expression + "\"";
try {
return this.jsonPath.read(content);
}
catch (Throwable ex) {
throw new AssertionError(message + ex.getMessage());
throw new AssertionError(message, ex);
}
}
private Object evaluateJsonPath(String content, Class<?> targetType) {
String message = "No value at JSON path \"" + this.expression + "\", exception: ";
String message = "No value at JSON path \"" + this.expression + "\"";
try {
return JsonPath.parse(content).read(this.expression, targetType);
}
catch (Throwable ex) {
throw new AssertionError(message + ex.getMessage());
throw new AssertionError(message, ex);
}
}

View File

@ -223,7 +223,7 @@ public class ContentRequestMatchers {
matchInternal(mockRequest);
}
catch (Exception ex) {
throw new AssertionError("Failed to parse expected or actual XML request content: " + ex.getMessage());
throw new AssertionError("Failed to parse expected or actual XML request content", ex);
}
}

View File

@ -252,7 +252,7 @@ public class JsonPathRequestMatchers {
matchInternal(mockRequest);
}
catch (ParseException ex) {
throw new AssertionError("Failed to parse JSON request content: " + ex.getMessage());
throw new AssertionError("Failed to parse JSON request content", ex);
}
}

View File

@ -194,7 +194,7 @@ public class XpathRequestMatchers {
matchInternal(mockRequest);
}
catch (Exception ex) {
throw new AssertionError("Failed to parse XML request content: " + ex.getMessage());
throw new AssertionError("Failed to parse XML request content", ex);
}
}

View File

@ -258,9 +258,8 @@ public class JsonPathResultMatchers {
MatcherAssert.assertThat(reason, content, StringStartsWith.startsWith(this.prefix));
return content.substring(this.prefix.length());
}
catch (StringIndexOutOfBoundsException oobe) {
throw new AssertionError(
"JSON prefix \"" + this.prefix + "\" not found, exception: " + oobe.getMessage());
catch (StringIndexOutOfBoundsException ex) {
throw new AssertionError("JSON prefix \"" + this.prefix + "\" not found", ex);
}
}
else {