use of org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter in project spring-framework by spring-projects.
the class XpathRequestMatchersIntegrationTests method setup.
@BeforeEach
public void setup() {
List<Person> composers = Arrays.asList(new Person("Johann Sebastian Bach").setSomeDouble(21), new Person("Johannes Brahms").setSomeDouble(.0025), new Person("Edvard Grieg").setSomeDouble(1.6035), new Person("Robert Schumann").setSomeDouble(Double.NaN));
List<Person> performers = Arrays.asList(new Person("Vladimir Ashkenazy").setSomeBoolean(false), new Person("Yehudi Menuhin").setSomeBoolean(true));
this.people = new PeopleWrapper(composers, performers);
List<HttpMessageConverter<?>> converters = new ArrayList<>();
converters.add(new Jaxb2RootElementHttpMessageConverter());
this.restTemplate = new RestTemplate();
this.restTemplate.setMessageConverters(converters);
this.mockServer = MockRestServiceServer.createServer(this.restTemplate);
}
use of org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter in project littlefisher-system by littlefishercoder.
the class WebSpringMvcConfig method configureMessageConverters.
/**
* Description: 消息转换器配置
*
* @param converters converters
*/
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
MappingJackson2HttpMessageConverter jacksonConverter = new MappingJackson2HttpMessageConverter();
ObjectMapper om = jacksonConverter.getObjectMapper();
om.setDateFormat(new SimpleDateFormat(DateUtil.DATETIME_FORMAT_1));
om.setLocale(Locale.CHINA);
om.setTimeZone(TimeZone.getTimeZone("GMT+8"));
List<MediaType> mediaTypeList = Lists.newArrayList();
mediaTypeList.add(new MediaType(MediaType.APPLICATION_JSON, Charsets.UTF_8));
mediaTypeList.add(new MediaType(MediaType.TEXT_HTML, Charsets.UTF_8));
jacksonConverter.setSupportedMediaTypes(mediaTypeList);
StringHttpMessageConverter stringConverter = new StringHttpMessageConverter(Charsets.UTF_8);
stringConverter.setWriteAcceptCharset(false);
// 保持以下顺序
// "application/json" "application/*+json"
converters.add(jacksonConverter);
// "application/xml" "text/xml" "application/*+xml"
converters.add(new Jaxb2RootElementHttpMessageConverter());
// "application/xml" "text/xml" "application/*+xml"
converters.add(new SourceHttpMessageConverter<>());
// "application/x-www-form-urlencoded" "multipart/form-data"
converters.add(new AllEncompassingFormHttpMessageConverter());
// "application/octet-stream" "*/*"
converters.add(new ByteArrayHttpMessageConverter());
// "text/plain" "*/*"
converters.add(stringConverter);
// "*/*"
converters.add(new ResourceHttpMessageConverter());
}
use of org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter in project spring-framework by spring-projects.
the class XmlContentRequestMatchersIntegrationTests method setup.
@BeforeEach
public void setup() {
List<Person> composers = Arrays.asList(new Person("Johann Sebastian Bach").setSomeDouble(21), new Person("Johannes Brahms").setSomeDouble(.0025), new Person("Edvard Grieg").setSomeDouble(1.6035), new Person("Robert Schumann").setSomeDouble(Double.NaN));
this.people = new PeopleWrapper(composers);
List<HttpMessageConverter<?>> converters = new ArrayList<>();
converters.add(new Jaxb2RootElementHttpMessageConverter());
this.restTemplate = new RestTemplate();
this.restTemplate.setMessageConverters(converters);
this.mockServer = MockRestServiceServer.createServer(this.restTemplate);
}
Aggregations