Switch to Jackson 2 in unit tests
Prior to this commit, some unit tests were using Spring's Jackson 1.x implementations. Now Jackson 2.x implementations are the default ones used in unit tests. Even if Jackson 1.x support is deprecated, Jackson 1.x unit tests are kept. Issue: SPR-11121
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,7 +28,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.http.converter.StringHttpMessageConverter;
|
||||
import org.springframework.http.converter.json.MappingJacksonHttpMessageConverter;
|
||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||
import org.springframework.test.web.Person;
|
||||
import org.springframework.test.web.client.MockRestServiceServer;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
@@ -52,7 +52,7 @@ public class ContentRequestMatcherTests {
|
||||
public void setup() {
|
||||
List<HttpMessageConverter<?>> converters = new ArrayList<HttpMessageConverter<?>>();
|
||||
converters.add(new StringHttpMessageConverter());
|
||||
converters.add(new MappingJacksonHttpMessageConverter());
|
||||
converters.add(new MappingJackson2HttpMessageConverter());
|
||||
|
||||
this.restTemplate = new RestTemplate();
|
||||
this.restTemplate.setMessageConverters(converters);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,7 +29,7 @@ import org.junit.Test;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.http.converter.StringHttpMessageConverter;
|
||||
import org.springframework.http.converter.json.MappingJacksonHttpMessageConverter;
|
||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||
import org.springframework.test.web.Person;
|
||||
import org.springframework.test.web.client.MockRestServiceServer;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
@@ -51,7 +51,7 @@ public class HeaderRequestMatcherTests {
|
||||
public void setup() {
|
||||
List<HttpMessageConverter<?>> converters = new ArrayList<HttpMessageConverter<?>>();
|
||||
converters.add(new StringHttpMessageConverter());
|
||||
converters.add(new MappingJacksonHttpMessageConverter());
|
||||
converters.add(new MappingJackson2HttpMessageConverter());
|
||||
|
||||
this.restTemplate = new RestTemplate();
|
||||
this.restTemplate.setMessageConverters(converters);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -34,7 +34,7 @@ import java.util.List;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.http.converter.json.MappingJacksonHttpMessageConverter;
|
||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||
import org.springframework.test.web.Person;
|
||||
import org.springframework.test.web.client.MockRestServiceServer;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
@@ -67,7 +67,7 @@ public class JsonPathRequestMatcherTests {
|
||||
this.people.add("performers", new Person("Yehudi Menuhin"));
|
||||
|
||||
List<HttpMessageConverter<?>> converters = new ArrayList<HttpMessageConverter<?>>();
|
||||
converters.add(new MappingJacksonHttpMessageConverter());
|
||||
converters.add(new MappingJackson2HttpMessageConverter());
|
||||
|
||||
this.restTemplate = new RestTemplate();
|
||||
this.restTemplate.setMessageConverters(converters);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -46,7 +46,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.servlet.View;
|
||||
import org.springframework.web.servlet.view.ContentNegotiatingViewResolver;
|
||||
import org.springframework.web.servlet.view.InternalResourceViewResolver;
|
||||
import org.springframework.web.servlet.view.json.MappingJacksonJsonView;
|
||||
import org.springframework.web.servlet.view.json.MappingJackson2JsonView;
|
||||
import org.springframework.web.servlet.view.xml.MarshallingView;
|
||||
|
||||
/**
|
||||
@@ -74,7 +74,7 @@ public class ViewResolutionTests {
|
||||
@Test
|
||||
public void testJsonOnly() throws Exception {
|
||||
|
||||
standaloneSetup(new PersonController()).setSingleView(new MappingJacksonJsonView()).build()
|
||||
standaloneSetup(new PersonController()).setSingleView(new MappingJackson2JsonView()).build()
|
||||
.perform(get("/person/Corea"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
|
||||
@@ -101,7 +101,7 @@ public class ViewResolutionTests {
|
||||
marshaller.setClassesToBeBound(Person.class);
|
||||
|
||||
List<View> viewList = new ArrayList<View>();
|
||||
viewList.add(new MappingJacksonJsonView());
|
||||
viewList.add(new MappingJackson2JsonView());
|
||||
viewList.add(new MarshallingView(marshaller));
|
||||
|
||||
ContentNegotiationManager manager = new ContentNegotiationManager(
|
||||
|
||||
Reference in New Issue
Block a user