From 1c83e8653a8079381fd2579919b8fd16a90fdd44 Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Thu, 2 Jan 2014 16:19:34 +0100 Subject: [PATCH] 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 --- .../samples/matchers/ContentRequestMatcherTests.java | 6 +++--- .../samples/matchers/HeaderRequestMatcherTests.java | 6 +++--- .../samples/matchers/JsonPathRequestMatcherTests.java | 6 +++--- .../servlet/samples/standalone/ViewResolutionTests.java | 8 ++++---- .../method/annotation/RequestPartIntegrationTests.java | 6 +++--- .../servlet/view/json/MappingJackson2JsonViewTests.java | 4 ++-- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/ContentRequestMatcherTests.java b/spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/ContentRequestMatcherTests.java index 7155be9b0cf..3fa38879481 100644 --- a/spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/ContentRequestMatcherTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/ContentRequestMatcherTests.java @@ -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> converters = new ArrayList>(); converters.add(new StringHttpMessageConverter()); - converters.add(new MappingJacksonHttpMessageConverter()); + converters.add(new MappingJackson2HttpMessageConverter()); this.restTemplate = new RestTemplate(); this.restTemplate.setMessageConverters(converters); diff --git a/spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/HeaderRequestMatcherTests.java b/spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/HeaderRequestMatcherTests.java index 339d59918bf..26d0676186f 100644 --- a/spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/HeaderRequestMatcherTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/HeaderRequestMatcherTests.java @@ -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> converters = new ArrayList>(); converters.add(new StringHttpMessageConverter()); - converters.add(new MappingJacksonHttpMessageConverter()); + converters.add(new MappingJackson2HttpMessageConverter()); this.restTemplate = new RestTemplate(); this.restTemplate.setMessageConverters(converters); diff --git a/spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/JsonPathRequestMatcherTests.java b/spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/JsonPathRequestMatcherTests.java index 9dd693931e0..74f559c51ff 100644 --- a/spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/JsonPathRequestMatcherTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/JsonPathRequestMatcherTests.java @@ -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> converters = new ArrayList>(); - converters.add(new MappingJacksonHttpMessageConverter()); + converters.add(new MappingJackson2HttpMessageConverter()); this.restTemplate = new RestTemplate(); this.restTemplate.setMessageConverters(converters); diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/ViewResolutionTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/ViewResolutionTests.java index 4545ff3e053..14a79beb4ee 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/ViewResolutionTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/ViewResolutionTests.java @@ -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 viewList = new ArrayList(); - viewList.add(new MappingJacksonJsonView()); + viewList.add(new MappingJackson2JsonView()); viewList.add(new MarshallingView(marshaller)); ContentNegotiationManager manager = new ContentNegotiationManager( diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestPartIntegrationTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestPartIntegrationTests.java index f23e76a9281..6b8d8830719 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestPartIntegrationTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestPartIntegrationTests.java @@ -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. @@ -38,7 +38,7 @@ import org.springframework.http.ResponseEntity; import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.ResourceHttpMessageConverter; -import org.springframework.http.converter.json.MappingJacksonHttpMessageConverter; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter; import org.springframework.stereotype.Controller; import org.springframework.util.LinkedMultiValueMap; @@ -104,7 +104,7 @@ public class RequestPartIntegrationTests { public void setUp() { AllEncompassingFormHttpMessageConverter converter = new AllEncompassingFormHttpMessageConverter(); converter.setPartConverters(Arrays.>asList( - new ResourceHttpMessageConverter(), new MappingJacksonHttpMessageConverter())); + new ResourceHttpMessageConverter(), new MappingJackson2HttpMessageConverter())); restTemplate = new RestTemplate(new HttpComponentsClientHttpRequestFactory()); restTemplate.setMessageConverters(Arrays.>asList(converter)); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/json/MappingJackson2JsonViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/json/MappingJackson2JsonViewTests.java index 45d8338fbd5..eb3bfbb8208 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/json/MappingJackson2JsonViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/json/MappingJackson2JsonViewTests.java @@ -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. @@ -97,7 +97,7 @@ public class MappingJackson2JsonViewTests { assertEquals("no-cache, no-store, max-age=0", response.getHeader("Cache-Control")); assertNotNull(response.getHeader("Expires")); - assertEquals(MappingJacksonJsonView.DEFAULT_CONTENT_TYPE, response.getContentType()); + assertEquals(MappingJackson2JsonView.DEFAULT_CONTENT_TYPE, response.getContentType()); String jsonResult = response.getContentAsString(); assertTrue(jsonResult.length() > 0);