use of org.springframework.http.converter.protobuf.ProtobufHttpMessageConverter in project tutorials by eugenp.
the class WebConfig method configureMessageConverters.
//
@Override
public void configureMessageConverters(final List<HttpMessageConverter<?>> messageConverters) {
final Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
builder.indentOutput(true).dateFormat(new SimpleDateFormat("dd-MM-yyyy hh:mm"));
messageConverters.add(new MappingJackson2HttpMessageConverter(builder.build()));
messageConverters.add(new MappingJackson2XmlHttpMessageConverter(builder.createXmlMapper(true).build()));
messageConverters.add(createXmlHttpMessageConverter());
// messageConverters.add(new MappingJackson2HttpMessageConverter());
messageConverters.add(new ProtobufHttpMessageConverter());
messageConverters.add(new KryoHttpMessageConverter());
messageConverters.add(new StringHttpMessageConverter());
super.configureMessageConverters(messageConverters);
}
use of org.springframework.http.converter.protobuf.ProtobufHttpMessageConverter in project tutorials by eugenp.
the class SpringHttpMessageConvertersLiveTest method givenConsumingProtobuf_whenReadingTheFoo_thenCorrect.
@Test
public void givenConsumingProtobuf_whenReadingTheFoo_thenCorrect() {
final String URI = BASE_URI + "foos/{id}";
final RestTemplate restTemplate = new RestTemplate();
restTemplate.setMessageConverters(Arrays.asList(new ProtobufHttpMessageConverter()));
final HttpHeaders headers = new HttpHeaders();
headers.setAccept(Arrays.asList(ProtobufHttpMessageConverter.PROTOBUF));
final HttpEntity<String> entity = new HttpEntity<String>(headers);
final ResponseEntity<FooProtos.Foo> response = restTemplate.exchange(URI, HttpMethod.GET, entity, FooProtos.Foo.class, "1");
final FooProtos.Foo resource = response.getBody();
assertThat(resource, notNullValue());
}
Aggregations