HttpMessageNotReadableException provides access to HttpInputMessage

Issue: SPR-15588
This commit is contained in:
Juergen Hoeller
2018-07-04 22:46:09 +02:00
parent fc699b2b37
commit 83faee67d5
16 changed files with 141 additions and 82 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -87,7 +87,7 @@ public class MarshallingHttpMessageConverterTests {
assertEquals("Invalid result", body, result);
}
@Test(expected = TypeMismatchException.class)
@Test
public void readWithTypeMismatchException() throws Exception {
MockHttpInputMessage inputMessage = new MockHttpInputMessage(new byte[0]);
@@ -96,7 +96,13 @@ public class MarshallingHttpMessageConverterTests {
given(unmarshaller.unmarshal(isA(StreamSource.class))).willReturn(Integer.valueOf(3));
MarshallingHttpMessageConverter converter = new MarshallingHttpMessageConverter(marshaller, unmarshaller);
converter.read(String.class, inputMessage);
try {
converter.read(String.class, inputMessage);
fail("Should have thrown HttpMessageNotReadableException");
}
catch (HttpMessageNotReadableException ex) {
assertTrue(ex.getCause() instanceof TypeMismatchException);
}
}
@Test