diff options
author | Tatu Saloranta <tatu.saloranta@iki.fi> | 2020-07-11 10:50:51 -0700 |
---|---|---|
committer | Tatu Saloranta <tatu.saloranta@iki.fi> | 2020-07-11 10:50:51 -0700 |
commit | bc1227e8edbc92cd74055689ae51447ec17529d5 (patch) | |
tree | c05ce2d66b1d3737b604ec375b6787330328f514 /src | |
parent | ef628ca32f107c6e6dd774f64d8a255ef02fe347 (diff) | |
download | jackson-databind-bc1227e8edbc92cd74055689ae51447ec17529d5.tar.gz |
Minor test refactoring to show #426 is now fixed
Diffstat (limited to 'src')
-rw-r--r-- | src/test/java/com/fasterxml/jackson/databind/deser/filter/IgnorePropertyOnDeserTest.java | 37 | ||||
-rw-r--r-- | src/test/java/com/fasterxml/jackson/failing/TestUnknownProperty426.java | 50 |
2 files changed, 37 insertions, 50 deletions
diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/filter/IgnorePropertyOnDeserTest.java b/src/test/java/com/fasterxml/jackson/databind/deser/filter/IgnorePropertyOnDeserTest.java index 953ea8678..a9589daf7 100644 --- a/src/test/java/com/fasterxml/jackson/databind/deser/filter/IgnorePropertyOnDeserTest.java +++ b/src/test/java/com/fasterxml/jackson/databind/deser/filter/IgnorePropertyOnDeserTest.java @@ -10,6 +10,33 @@ import com.fasterxml.jackson.databind.ObjectMapper; public class IgnorePropertyOnDeserTest extends BaseMapTest { + // [databind#426] + @JsonIgnoreProperties({ "userId" }) + static class User { + public String firstName; + Integer userId; + + public Integer getUserId() { + return userId; + } + + public void setUserId(CharSequence id) { + userId = Integer.valueOf(id.toString()); + } + + public void setUserId(Integer v) { + this.userId = v; + } + + public void setUserId(User u) { + // bogus + } + + public void setUserId(boolean b) { + // bogus + } + } + // [databind#1217] static class IgnoreObject { public int x = 1; @@ -62,6 +89,16 @@ public class IgnorePropertyOnDeserTest extends BaseMapTest private final ObjectMapper MAPPER = newJsonMapper(); + // [databind#426] + public void testIssue426() throws Exception + { + final String JSON = aposToQuotes("{'userId': 9, 'firstName': 'Mike' }"); + User result = MAPPER.readerFor(User.class).readValue(JSON); + assertNotNull(result); + assertEquals("Mike", result.firstName); + assertNull(result.userId); + } + // [databind#1217] public void testIgnoreOnProperty1217() throws Exception { diff --git a/src/test/java/com/fasterxml/jackson/failing/TestUnknownProperty426.java b/src/test/java/com/fasterxml/jackson/failing/TestUnknownProperty426.java deleted file mode 100644 index 09b3226b7..000000000 --- a/src/test/java/com/fasterxml/jackson/failing/TestUnknownProperty426.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.fasterxml.jackson.failing; - -import com.fasterxml.jackson.annotation.*; - -import com.fasterxml.jackson.databind.*; - -/** - * Unit tests for checking handling of unknown properties - */ -public class TestUnknownProperty426 extends BaseMapTest -{ - // For [databind#426] - @JsonIgnoreProperties({ "userId" }) - static class User { - public String firstName; - Integer userId; - - public void setUserId(CharSequence id) { - // 21-Dec-2015, tatu: With a fix in 2.7, use of String would not - // trigger the problem, so use CharSequence... - setUserId(Integer.valueOf(id.toString())); - } - - public Integer getUserId() { - return userId; - } - - public void setUserId(Integer v) { - this.userId = v; - } - } - - /* - /********************************************************** - /* Test methods - /********************************************************** - */ - - private final ObjectMapper MAPPER = new ObjectMapper(); - - // Aside from [databind#426], also relevant: [databind#1044]? - public void testIssue426() throws Exception - { - final String JSON = aposToQuotes("{'userId': 9, 'firstName': 'Mike' }"); - User result = MAPPER.readerFor(User.class).readValue(JSON); - assertNotNull(result); - assertEquals("Mike", result.firstName); - } -} - |