diff --git a/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilderTests.java b/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilderTests.java index 09c1b65729..cc38beb839 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilderTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -352,7 +352,7 @@ public class Jackson2ObjectMapperBuilderTests { @Test public void propertyNamingStrategy() { - PropertyNamingStrategy strategy = new PropertyNamingStrategy.LowerCaseWithUnderscoresStrategy(); + PropertyNamingStrategy strategy = new PropertyNamingStrategy.SnakeCaseStrategy(); ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().propertyNamingStrategy(strategy).build(); assertSame(strategy, objectMapper.getSerializationConfig().getPropertyNamingStrategy()); assertSame(strategy, objectMapper.getDeserializationConfig().getPropertyNamingStrategy()); @@ -440,7 +440,7 @@ public class Jackson2ObjectMapperBuilderTests { JsonSerializer serializer2 = new NumberSerializer(Integer.class); Jackson2ObjectMapperBuilder builder = Jackson2ObjectMapperBuilder.json() - .modules(new ArrayList<>()) // Disable well-known modules detection + .modules(new ArrayList<>()) // Disable well-known modules detection .serializers(serializer1) .serializersByType(Collections.singletonMap(Boolean.class, serializer2)) .deserializersByType(deserializerMap) @@ -542,7 +542,6 @@ public class Jackson2ObjectMapperBuilderTests { assertEquals(SmileFactory.class, objectMapper.getFactory().getClass()); } - @Test public void visibility() throws JsonProcessingException { ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json() @@ -556,6 +555,7 @@ public class Jackson2ObjectMapperBuilderTests { assertThat(json, not(containsString("property3"))); } + public static class CustomIntegerModule extends Module { @Override @@ -642,6 +642,7 @@ public class Jackson2ObjectMapperBuilderTests { } } + public static class JacksonVisibilityBean { private String property1; @@ -651,9 +652,9 @@ public class Jackson2ObjectMapperBuilderTests { public String getProperty3() { return null; } - } + static class OffsetDateTimeDeserializer extends JsonDeserializer { private static final String CURRENT_ZONE_OFFSET = OffsetDateTime.now().getOffset().toString(); @@ -673,6 +674,7 @@ public class Jackson2ObjectMapperBuilderTests { } } + @JsonDeserialize static class DemoPojo { @@ -685,13 +687,14 @@ public class Jackson2ObjectMapperBuilderTests { public void setOffsetDateTime(OffsetDateTime offsetDateTime) { this.offsetDateTime = offsetDateTime; } - } + @SuppressWarnings("serial") public static class MyXmlFactory extends XmlFactory { } + static class Foo {} static class Bar {} diff --git a/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperFactoryBeanTests.java b/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperFactoryBeanTests.java index cb047610a4..6e391cc7cb 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperFactoryBeanTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperFactoryBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2020 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. @@ -213,8 +213,7 @@ public class Jackson2ObjectMapperFactoryBeanTests { assertEquals(timestamp.toString(), new String(objectMapper.writeValueAsBytes(dateTime), "UTF-8")); } - @Test // SPR-12634 - @SuppressWarnings("unchecked") + @Test // SPR-12634 public void customizeDefaultModulesWithModuleClass() throws JsonProcessingException, UnsupportedEncodingException { this.factory.setModulesToInstall(CustomIntegerModule.class); this.factory.afterPropertiesSet(); @@ -225,7 +224,7 @@ public class Jackson2ObjectMapperFactoryBeanTests { assertThat(new String(objectMapper.writeValueAsBytes(new Integer(4)), "UTF-8"), containsString("customid")); } - @Test // SPR-12634 + @Test // SPR-12634 public void customizeDefaultModulesWithSerializer() throws JsonProcessingException, UnsupportedEncodingException { Map, JsonSerializer> serializers = new HashMap<>(); serializers.put(Integer.class, new CustomIntegerSerializer()); @@ -263,7 +262,7 @@ public class Jackson2ObjectMapperFactoryBeanTests { @Test public void propertyNamingStrategy() { - PropertyNamingStrategy strategy = new PropertyNamingStrategy.LowerCaseWithUnderscoresStrategy(); + PropertyNamingStrategy strategy = new PropertyNamingStrategy.SnakeCaseStrategy(); this.factory.setPropertyNamingStrategy(strategy); this.factory.afterPropertiesSet(); diff --git a/spring-web/src/test/java/org/springframework/http/converter/json/SpringHandlerInstantiatorTests.java b/spring-web/src/test/java/org/springframework/http/converter/json/SpringHandlerInstantiatorTests.java index 97c8501252..8cadcdd09f 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/json/SpringHandlerInstantiatorTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/json/SpringHandlerInstantiatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2020 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,6 @@ import com.fasterxml.jackson.databind.jsontype.TypeDeserializer; import com.fasterxml.jackson.databind.jsontype.TypeIdResolver; import com.fasterxml.jackson.databind.jsontype.TypeSerializer; import com.fasterxml.jackson.databind.jsontype.impl.StdTypeResolverBuilder; -import com.fasterxml.jackson.databind.type.TypeFactory; import org.junit.Before; import org.junit.Test; @@ -202,11 +201,6 @@ public class SpringHandlerInstantiatorTests { return JsonTypeInfo.Id.CUSTOM; } - // Only needed when compiling against Jackson 2.7; gone in 2.8 - public JavaType typeFromId(String s) { - return TypeFactory.defaultInstance().constructFromCanonical(s); - } - @Override public String idFromValue(Object value) { isAutowiredFiledInitialized = (this.capitalizer != null); @@ -227,7 +221,7 @@ public class SpringHandlerInstantiatorTests { return null; } - // New in Jackson 2.7 + @Override public String getDescForKnownTypeIds() { return null; }