Consistent use of JDK 7 AssertionError with root cause
Issue: SPR-13188
This commit is contained in:
		
							parent
							
								
									655097a343
								
							
						
					
					
						commit
						728a548199
					
				|  | @ -237,22 +237,22 @@ public class JsonPathExpectationsHelper { | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	private Object evaluateJsonPath(String content) { | 	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 { | 		try { | ||||||
| 			return this.jsonPath.read(content); | 			return this.jsonPath.read(content); | ||||||
| 		} | 		} | ||||||
| 		catch (Throwable ex) { | 		catch (Throwable ex) { | ||||||
| 			throw new AssertionError(message + ex.getMessage()); | 			throw new AssertionError(message, ex); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	private Object evaluateJsonPath(String content, Class<?> targetType) { | 	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 { | 		try { | ||||||
| 			return JsonPath.parse(content).read(this.expression, targetType); | 			return JsonPath.parse(content).read(this.expression, targetType); | ||||||
| 		} | 		} | ||||||
| 		catch (Throwable ex) { | 		catch (Throwable ex) { | ||||||
| 			throw new AssertionError(message + ex.getMessage()); | 			throw new AssertionError(message, ex); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -223,7 +223,7 @@ public class ContentRequestMatchers { | ||||||
| 				matchInternal(mockRequest); | 				matchInternal(mockRequest); | ||||||
| 			} | 			} | ||||||
| 			catch (Exception ex) { | 			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); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -252,7 +252,7 @@ public class JsonPathRequestMatchers { | ||||||
| 				matchInternal(mockRequest); | 				matchInternal(mockRequest); | ||||||
| 			} | 			} | ||||||
| 			catch (ParseException ex) { | 			catch (ParseException ex) { | ||||||
| 				throw new AssertionError("Failed to parse JSON request content: " + ex.getMessage()); | 				throw new AssertionError("Failed to parse JSON request content", ex); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -194,7 +194,7 @@ public class XpathRequestMatchers { | ||||||
| 				matchInternal(mockRequest); | 				matchInternal(mockRequest); | ||||||
| 			} | 			} | ||||||
| 			catch (Exception ex) { | 			catch (Exception ex) { | ||||||
| 				throw new AssertionError("Failed to parse XML request content: " + ex.getMessage()); | 				throw new AssertionError("Failed to parse XML request content", ex); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -258,9 +258,8 @@ public class JsonPathResultMatchers { | ||||||
| 				MatcherAssert.assertThat(reason, content, StringStartsWith.startsWith(this.prefix)); | 				MatcherAssert.assertThat(reason, content, StringStartsWith.startsWith(this.prefix)); | ||||||
| 				return content.substring(this.prefix.length()); | 				return content.substring(this.prefix.length()); | ||||||
| 			} | 			} | ||||||
| 			catch (StringIndexOutOfBoundsException oobe) { | 			catch (StringIndexOutOfBoundsException ex) { | ||||||
| 				throw new AssertionError( | 				throw new AssertionError("JSON prefix \"" + this.prefix + "\" not found", ex); | ||||||
| 						"JSON prefix \"" + this.prefix + "\" not found, exception: " + oobe.getMessage()); |  | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 		else { | 		else { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue