use of org.springframework.mock.http.MockHttpOutputMessage in project cas by apereo.
the class CasYamlHttpMessageConverterTests method verifyOperation.
@Test
public void verifyOperation() throws Exception {
val input = new CasYamlHttpMessageConverter();
val outputMessage = new MockHttpOutputMessage();
input.write(getService(), MediaType.APPLICATION_JSON, outputMessage);
assertNotNull(outputMessage.getBodyAsString());
input.write(List.of(getService()), MediaType.APPLICATION_JSON, outputMessage);
assertNotNull(outputMessage.getBodyAsString());
}
use of org.springframework.mock.http.MockHttpOutputMessage in project thingsboard by thingsboard.
the class AbstractWebTest method json.
@SuppressWarnings("unchecked")
protected String json(Object o) throws IOException {
MockHttpOutputMessage mockHttpOutputMessage = new MockHttpOutputMessage();
HttpMessageConverter converter = o instanceof String ? stringHttpMessageConverter : mappingJackson2HttpMessageConverter;
converter.write(o, MediaType.APPLICATION_JSON, mockHttpOutputMessage);
return mockHttpOutputMessage.getBodyAsString();
}
use of org.springframework.mock.http.MockHttpOutputMessage in project springdatacouchbase by carlosCharz.
the class UserControllerTest method json.
@SuppressWarnings("unchecked")
protected String json(Object o) throws IOException {
MockHttpOutputMessage mockHttpOutputMessage = new MockHttpOutputMessage();
mappingJackson2HttpMessageConverter.write(o, MediaType.APPLICATION_JSON, mockHttpOutputMessage);
return mockHttpOutputMessage.getBodyAsString();
}
use of org.springframework.mock.http.MockHttpOutputMessage in project modesti by jlsalmon.
the class TaskControllerTest method json.
protected String json(Object o) throws IOException {
MockHttpOutputMessage mockHttpOutputMessage = new MockHttpOutputMessage();
this.mappingJackson2HttpMessageConverter.write(o, MediaType.APPLICATION_JSON, mockHttpOutputMessage);
return mockHttpOutputMessage.getBodyAsString();
}
use of org.springframework.mock.http.MockHttpOutputMessage in project spring-security by spring-projects.
the class OAuth2ErrorHttpMessageConverterTests method writeInternalWhenOAuth2ErrorThenWriteErrorResponse.
@Test
public void writeInternalWhenOAuth2ErrorThenWriteErrorResponse() throws Exception {
OAuth2Error oauth2Error = new OAuth2Error("unauthorized_client", "The client is not authorized", "https://tools.ietf.org/html/rfc6749#section-5.2");
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
this.messageConverter.writeInternal(oauth2Error, outputMessage);
String errorResponse = outputMessage.getBodyAsString();
assertThat(errorResponse).contains("\"error\":\"unauthorized_client\"");
assertThat(errorResponse).contains("\"error_description\":\"The client is not authorized\"");
assertThat(errorResponse).contains("\"error_uri\":\"https://tools.ietf.org/html/rfc6749#section-5.2\"");
}
Aggregations