From 06cc8eff2d2e267691d36f3078aadc085dc87fe8 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 1 Jun 2015 22:30:10 -0700 Subject: [PATCH] Modify #792 test, to be solved via #813 --- .../ImplicitNameMatch792Test.java} | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) rename src/test/java/com/fasterxml/jackson/{databind/introspect/ImplicitNameMatchTest.java => failing/ImplicitNameMatch792Test.java} (75%) diff --git a/src/test/java/com/fasterxml/jackson/databind/introspect/ImplicitNameMatchTest.java b/src/test/java/com/fasterxml/jackson/failing/ImplicitNameMatch792Test.java similarity index 75% rename from src/test/java/com/fasterxml/jackson/databind/introspect/ImplicitNameMatchTest.java rename to src/test/java/com/fasterxml/jackson/failing/ImplicitNameMatch792Test.java index 8ab1a05aba..5fb73c012f 100644 --- a/src/test/java/com/fasterxml/jackson/databind/introspect/ImplicitNameMatchTest.java +++ b/src/test/java/com/fasterxml/jackson/failing/ImplicitNameMatch792Test.java @@ -1,4 +1,4 @@ -package com.fasterxml.jackson.databind.introspect; +package com.fasterxml.jackson.failing; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @@ -7,7 +7,7 @@ import com.fasterxml.jackson.databind.introspect.AnnotatedParameter; import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector; -public class ImplicitNameMatchTest extends BaseMapTest +public class ImplicitNameMatch792Test extends BaseMapTest { // Simple introspector that gives generated "ctorN" names for constructor // parameters @@ -49,6 +49,18 @@ static class Bean2 public int getValue() { return x; } } + + static class ReadWriteBean + { + private int value; + + private ReadWriteBean(@JsonProperty(value="value", + access=JsonProperty.Access.READ_WRITE) int v) { + value = v; + } + + public int testValue() { return value; } + } /* /********************************************************** @@ -56,6 +68,8 @@ static class Bean2 /********************************************************** */ + private final ObjectMapper MAPPER = objectMapper(); + public void testBindingOfImplicitCreatorNames() throws Exception { ObjectMapper m = new ObjectMapper(); @@ -66,8 +80,13 @@ public void testBindingOfImplicitCreatorNames() throws Exception public void testImplicitWithSetterGetter() throws Exception { - ObjectMapper m = new ObjectMapper(); - String json = m.writeValueAsString(new Bean2()); + String json = MAPPER.writeValueAsString(new Bean2()); assertEquals(aposToQuotes("{'stuff':3}"), json); } + + public void testReadWriteWithPrivateField() throws Exception + { + String json = MAPPER.writeValueAsString(new ReadWriteBean(3)); + assertEquals("{\"value\":3}", json); + } }