use of org.springframework.oxm.MarshallingFailureException in project spring-framework by spring-projects.
the class MarshallingHttpMessageConverterTests method writeWithMarshallingFailureException.
@Test
public void writeWithMarshallingFailureException() throws Exception {
String body = "<root>Hello World</root>";
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
MarshallingFailureException ex = new MarshallingFailureException("forced");
Marshaller marshaller = mock(Marshaller.class);
willThrow(ex).given(marshaller).marshal(eq(body), isA(Result.class));
MarshallingHttpMessageConverter converter = new MarshallingHttpMessageConverter(marshaller);
assertThatExceptionOfType(HttpMessageNotWritableException.class).isThrownBy(() -> converter.write(body, null, outputMessage)).withCause(ex);
}
Aggregations