org.springframework.mock.http.MockHttpOutputMessage Java Examples
The following examples show how to use
org.springframework.mock.http.MockHttpOutputMessage.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FastJsonHttpMessageConverterTest.java From swagger-dubbo with Apache License 2.0 | 5 votes |
@Test public void testSwagger() throws HttpMessageNotWritableException, IOException{ Json value = new Json("{\"swagger\":\"2.0\""); HttpOutputMessage outMessage = new MockHttpOutputMessage(){ @Override public HttpHeaders getHeaders() { HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.setContentType(MediaType.APPLICATION_JSON); return httpHeaders; } }; new FastJsonHttpMessageConverter().write(value, null, outMessage); Assert.assertTrue((outMessage.getBody().toString().startsWith("{\"swagger\":\"2.0\""))); }
Example #2
Source File: AbstractSpringMVCTest.java From SMSC with Apache License 2.0 | 5 votes |
protected String json(Object o) throws IOException { MockHttpOutputMessage mockHttpOutputMessage = new MockHttpOutputMessage(); this.mappingJackson2HttpMessageConverter.write( o, MediaType.APPLICATION_JSON, mockHttpOutputMessage); return mockHttpOutputMessage.getBodyAsString(); }
Example #3
Source File: TestSupport.java From exchange-gateway-rest with Apache License 2.0 | 4 votes |
protected String json(Object object) throws IOException { MockHttpOutputMessage mockHttpOutputMessage = new MockHttpOutputMessage(); //noinspection unchecked mappingJackson2HttpMessageConverter.write(object, MediaType.APPLICATION_JSON, mockHttpOutputMessage); return mockHttpOutputMessage.getBodyAsString(); }
Example #4
Source File: TestDataGenerator.java From springrestdoc with MIT License | 4 votes |
@SneakyThrows public String asJsonString(Object o) { MockHttpOutputMessage mockHttpOutputMessage = new MockHttpOutputMessage(); messageConverter.write(o, MediaType.APPLICATION_JSON, mockHttpOutputMessage); return mockHttpOutputMessage.getBodyAsString(); }
Example #5
Source File: TestDataGenerator.java From springrestdoc with MIT License | 4 votes |
@SneakyThrows public String asJsonString(Object o) { MockHttpOutputMessage mockHttpOutputMessage = new MockHttpOutputMessage(); messageConverter.write(o, MediaType.APPLICATION_JSON, mockHttpOutputMessage); return mockHttpOutputMessage.getBodyAsString(); }
Example #6
Source File: SprintBootWebApplicationTests.java From pro-spring-boot with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") protected String toJsonString(Object obj) throws IOException { MockHttpOutputMessage mockHttpOutputMessage = new MockHttpOutputMessage(); this.mappingJackson2HttpMessageConverter.write(obj, MediaType.APPLICATION_JSON, mockHttpOutputMessage); return mockHttpOutputMessage.getBodyAsString(); }
Example #7
Source File: SOAPFaultHttpMessageConverterTest.java From riptide with MIT License | 4 votes |
@Test void write() { assertThrows(UnsupportedOperationException.class, () -> unit.write(new Object(), null, new MockHttpOutputMessage())); }
Example #8
Source File: Util.java From fiware-cepheus with GNU General Public License v2.0 | 4 votes |
static public String json(MappingJackson2HttpMessageConverter mapping, Object o) throws IOException { MockHttpOutputMessage mockHttpOutputMessage = new MockHttpOutputMessage(); mapping.write(o, MediaType.APPLICATION_JSON, mockHttpOutputMessage); return mockHttpOutputMessage.getBodyAsString(); }
Example #9
Source File: Util.java From fiware-cepheus with GNU General Public License v2.0 | 4 votes |
static public String json(MappingJackson2HttpMessageConverter mapping, Object o) throws IOException { MockHttpOutputMessage mockHttpOutputMessage = new MockHttpOutputMessage(); mapping.write(o, MediaType.APPLICATION_JSON, mockHttpOutputMessage); return mockHttpOutputMessage.getBodyAsString(); }
Example #10
Source File: SprintBootWebApplicationTests.java From pro-spring-boot with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") protected String toJsonString(Object obj) throws IOException { MockHttpOutputMessage mockHttpOutputMessage = new MockHttpOutputMessage(); this.mappingJackson2HttpMessageConverter.write(obj, MediaType.APPLICATION_JSON, mockHttpOutputMessage); return mockHttpOutputMessage.getBodyAsString(); }
Example #11
Source File: SimulatorHttpMessageConverterTest.java From citrus-simulator with Apache License 2.0 | 4 votes |
@Test(expectedExceptions = IllegalStateException.class) public void testUnsupportedWrite() { converter.write("Hello", MediaType.TEXT_PLAIN, new MockHttpOutputMessage()); }
Example #12
Source File: SimulatorHttpMessageConverterTest.java From citrus-simulator with Apache License 2.0 | 4 votes |
@Test(expectedExceptions = IllegalStateException.class) public void testUnsupportedGenericWrite() { converter.write("Hello", String.class, MediaType.TEXT_PLAIN, new MockHttpOutputMessage()); }