本文整理汇总了Java中org.springframework.mock.http.MockHttpOutputMessage.getBodyAsString方法的典型用法代码示例。如果您正苦于以下问题:Java MockHttpOutputMessage.getBodyAsString方法的具体用法?Java MockHttpOutputMessage.getBodyAsString怎么用?Java MockHttpOutputMessage.getBodyAsString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.mock.http.MockHttpOutputMessage
的用法示例。
在下文中一共展示了MockHttpOutputMessage.getBodyAsString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: json
import org.springframework.mock.http.MockHttpOutputMessage; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
protected <T extends Object> String json(T entity) throws IOException {
MockHttpOutputMessage mockHttpOutputMessage = new MockHttpOutputMessage();
jsonConverter.write(
entity, MediaType.APPLICATION_JSON, mockHttpOutputMessage);
return mockHttpOutputMessage.getBodyAsString();
}
示例2: toJson
import org.springframework.mock.http.MockHttpOutputMessage; //导入方法依赖的package包/类
/**
* Map an object to JSON
*
* @param o object to map
* @return JSON result
*/
protected String toJson(Object o) throws IOException {
MockHttpOutputMessage mockHttpOutputMessage = new MockHttpOutputMessage();
//noinspection unchecked
mappingJackson2HttpMessageConverter.write(
o, MediaType.APPLICATION_JSON, mockHttpOutputMessage);
return mockHttpOutputMessage.getBodyAsString();
}
示例3: json
import org.springframework.mock.http.MockHttpOutputMessage; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
protected String json(Object o) throws IOException {
MockHttpOutputMessage mockHttpOutputMessage = new MockHttpOutputMessage();
this.mappingJackson2HttpMessageConverter.write(
o, MediaType.APPLICATION_JSON, mockHttpOutputMessage);
return mockHttpOutputMessage.getBodyAsString();
}
示例4: json
import org.springframework.mock.http.MockHttpOutputMessage; //导入方法依赖的package包/类
protected String json(Object o) throws IOException {
MockHttpOutputMessage mockHttpOutputMessage = new MockHttpOutputMessage();
this.mappingJackson2HttpMessageConverter.write(
o, MediaType.APPLICATION_JSON, mockHttpOutputMessage);
return mockHttpOutputMessage.getBodyAsString();
}
示例5: json
import org.springframework.mock.http.MockHttpOutputMessage; //导入方法依赖的package包/类
@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();
}
示例6: writeToTextNoFilter
import org.springframework.mock.http.MockHttpOutputMessage; //导入方法依赖的package包/类
@Test
public void writeToTextNoFilter() throws Exception {
List<EntrezGene> genes = EntrezGene.createDummyData();
ResponseEnvelope envelope = new ResponseEnvelope(genes);
Assert.isTrue(textConverter.canWrite(envelope.getClass(), textMediaType));
MockHttpOutputMessage message = new MockHttpOutputMessage();
textConverter.write(envelope, textMediaType, message);
String text = message.getBodyAsString();
Assert.notNull(text);
System.out.println(text);
// TODO
}
示例7: json
import org.springframework.mock.http.MockHttpOutputMessage; //导入方法依赖的package包/类
protected String json(Object o) throws IOException {
MockHttpOutputMessage mockHttpOutputMessage = new MockHttpOutputMessage();
this.mappingJackson2HttpMessageConverter.write(
o, MediaType.APPLICATION_JSON, mockHttpOutputMessage);
return mockHttpOutputMessage.getBodyAsString();
}
示例8: json
import org.springframework.mock.http.MockHttpOutputMessage; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
protected String json(Object o) throws IOException {
MockHttpOutputMessage mockHttpOutputMessage = new MockHttpOutputMessage();
this.mappingJackson2HttpMessageConverter.write(o, MediaType.APPLICATION_JSON, mockHttpOutputMessage);
return mockHttpOutputMessage.getBodyAsString();
}
示例9: jsonify
import org.springframework.mock.http.MockHttpOutputMessage; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
protected String jsonify(Object objectToJsonify) throws IOException {
final MockHttpOutputMessage mockHttpOutputMessage = new MockHttpOutputMessage();
mappingJackson2HttpMessageConverter.write(objectToJsonify, MediaType.APPLICATION_JSON, mockHttpOutputMessage);
return mockHttpOutputMessage.getBodyAsString();
}
示例10: asJsonString
import org.springframework.mock.http.MockHttpOutputMessage; //导入方法依赖的package包/类
@SneakyThrows
public String asJsonString(Object o) {
MockHttpOutputMessage mockHttpOutputMessage = new MockHttpOutputMessage();
messageConverter.write(o, MediaType.APPLICATION_JSON, mockHttpOutputMessage);
return mockHttpOutputMessage.getBodyAsString();
}
示例11: json
import org.springframework.mock.http.MockHttpOutputMessage; //导入方法依赖的package包/类
static public String json(MappingJackson2HttpMessageConverter mapping, Object o) throws IOException {
MockHttpOutputMessage mockHttpOutputMessage = new MockHttpOutputMessage();
mapping.write(o, MediaType.APPLICATION_JSON, mockHttpOutputMessage);
return mockHttpOutputMessage.getBodyAsString();
}
示例12: toJsonString
import org.springframework.mock.http.MockHttpOutputMessage; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
protected String toJsonString(Object obj) throws IOException {
MockHttpOutputMessage mockHttpOutputMessage = new MockHttpOutputMessage();
this.mappingJackson2HttpMessageConverter.write(obj, MediaType.APPLICATION_JSON, mockHttpOutputMessage);
return mockHttpOutputMessage.getBodyAsString();
}
示例13: xml
import org.springframework.mock.http.MockHttpOutputMessage; //导入方法依赖的package包/类
static public String xml(MappingJackson2XmlHttpMessageConverter mapping, Object o) throws IOException {
MockHttpOutputMessage mockHttpOutputMessage = new MockHttpOutputMessage();
mapping.write(o, MediaType.APPLICATION_XML, mockHttpOutputMessage);
return mockHttpOutputMessage.getBodyAsString();
}
示例14: json
import org.springframework.mock.http.MockHttpOutputMessage; //导入方法依赖的package包/类
protected String json(Object o) throws IOException
{
MockHttpOutputMessage mockHttpOutputMessage = new MockHttpOutputMessage();
this.mappingJackson2HttpMessageConverter.write(o, MediaType.APPLICATION_JSON, mockHttpOutputMessage);
return mockHttpOutputMessage.getBodyAsString();
}
示例15: json
import org.springframework.mock.http.MockHttpOutputMessage; //导入方法依赖的package包/类
protected String json(Object o) throws IOException {
MockHttpOutputMessage mockHttpOutputMessage = new MockHttpOutputMessage();
this.mappingJackson2HttpMessageConverter.write(o, MediaType.APPLICATION_JSON, mockHttpOutputMessage);
return mockHttpOutputMessage.getBodyAsString();
}