parent
							
								
									cd7e5f61f0
								
							
						
					
					
						commit
						7b6293fa05
					
				| 
						 | 
				
			
			@ -355,7 +355,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();
 | 
			
		||||
		assertThat(objectMapper.getSerializationConfig().getPropertyNamingStrategy()).isSameAs(strategy);
 | 
			
		||||
		assertThat(objectMapper.getDeserializationConfig().getPropertyNamingStrategy()).isSameAs(strategy);
 | 
			
		||||
| 
						 | 
				
			
			@ -443,7 +443,7 @@ public class Jackson2ObjectMapperBuilderTests {
 | 
			
		|||
		JsonSerializer<Number> 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)
 | 
			
		||||
| 
						 | 
				
			
			@ -551,7 +551,6 @@ public class Jackson2ObjectMapperBuilderTests {
 | 
			
		|||
		assertThat(objectMapper.getFactory().getClass()).isEqualTo(SmileFactory.class);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	@Test
 | 
			
		||||
	public void visibility() throws JsonProcessingException {
 | 
			
		||||
		ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json()
 | 
			
		||||
| 
						 | 
				
			
			@ -565,6 +564,7 @@ public class Jackson2ObjectMapperBuilderTests {
 | 
			
		|||
		assertThat(json).doesNotContain("property3");
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	public static class CustomIntegerModule extends Module {
 | 
			
		||||
 | 
			
		||||
		@Override
 | 
			
		||||
| 
						 | 
				
			
			@ -651,6 +651,7 @@ public class Jackson2ObjectMapperBuilderTests {
 | 
			
		|||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	public static class JacksonVisibilityBean {
 | 
			
		||||
 | 
			
		||||
		@SuppressWarnings("unused")
 | 
			
		||||
| 
						 | 
				
			
			@ -661,9 +662,9 @@ public class Jackson2ObjectMapperBuilderTests {
 | 
			
		|||
		public String getProperty3() {
 | 
			
		||||
			return null;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	static class OffsetDateTimeDeserializer extends JsonDeserializer<OffsetDateTime> {
 | 
			
		||||
 | 
			
		||||
		private static final String CURRENT_ZONE_OFFSET = OffsetDateTime.now().getOffset().toString();
 | 
			
		||||
| 
						 | 
				
			
			@ -684,6 +685,7 @@ public class Jackson2ObjectMapperBuilderTests {
 | 
			
		|||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	@JsonDeserialize
 | 
			
		||||
	static class DemoPojo {
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -696,13 +698,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 {}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -212,8 +212,7 @@ public class Jackson2ObjectMapperFactoryBeanTests {
 | 
			
		|||
		assertThat(new String(objectMapper.writeValueAsBytes(dateTime), "UTF-8")).isEqualTo(timestamp.toString());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Test // SPR-12634
 | 
			
		||||
	@SuppressWarnings("unchecked")
 | 
			
		||||
	@Test  // SPR-12634
 | 
			
		||||
	public void customizeDefaultModulesWithModuleClass() throws JsonProcessingException, UnsupportedEncodingException {
 | 
			
		||||
		this.factory.setModulesToInstall(CustomIntegerModule.class);
 | 
			
		||||
		this.factory.afterPropertiesSet();
 | 
			
		||||
| 
						 | 
				
			
			@ -224,7 +223,7 @@ public class Jackson2ObjectMapperFactoryBeanTests {
 | 
			
		|||
		assertThat(new String(objectMapper.writeValueAsBytes(4), "UTF-8")).contains("customid");
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Test // SPR-12634
 | 
			
		||||
	@Test  // SPR-12634
 | 
			
		||||
	public void customizeDefaultModulesWithSerializer() throws JsonProcessingException, UnsupportedEncodingException {
 | 
			
		||||
		Map<Class<?>, JsonSerializer<?>> serializers = new HashMap<>();
 | 
			
		||||
		serializers.put(Integer.class, new CustomIntegerSerializer());
 | 
			
		||||
| 
						 | 
				
			
			@ -262,7 +261,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();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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.
 | 
			
		||||
| 
						 | 
				
			
			@ -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.jupiter.api.BeforeEach;
 | 
			
		||||
import org.junit.jupiter.api.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,6 @@ public class SpringHandlerInstantiatorTests {
 | 
			
		|||
			return null;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// New in Jackson 2.7
 | 
			
		||||
		@Override
 | 
			
		||||
		public String getDescForKnownTypeIds() {
 | 
			
		||||
			return null;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue