Add unit test for [JACKSON-756]
diff --git a/src/test/org/codehaus/jackson/failing/TestGenericsBounded.java b/src/test/org/codehaus/jackson/failing/TestGenericsBounded.java new file mode 100644 index 0000000..5337568 --- /dev/null +++ b/src/test/org/codehaus/jackson/failing/TestGenericsBounded.java
@@ -0,0 +1,38 @@ +package org.codehaus.jackson.failing; + +import java.util.*; + +import org.codehaus.jackson.map.*; + +public class TestGenericsBounded + extends BaseMapTest +{ + protected static abstract class Base<T> { + public T inconsequential = null; + } + + protected static abstract class BaseData<T> { + public T dataObj; + } + + protected static class Child extends Base<Long> { + public static class ChildData extends BaseData<List<String>> { } + } + + /* + /******************************************************* + /* Unit tests + /******************************************************* + */ + + // Reproducing issue 743 + public void testIssue743() throws Exception + { + String s3 = "{\"dataObj\" : [ \"one\", \"two\", \"three\" ] }"; + ObjectMapper m = new ObjectMapper(); + + Child.ChildData d = m.readValue(s3, Child.ChildData.class); + assertNotNull(d.dataObj); + assertEquals(3, d.dataObj.size()); + } +}
diff --git a/src/test/org/codehaus/jackson/map/deser/TestGenericsBounded.java b/src/test/org/codehaus/jackson/map/deser/TestGenericsBounded.java index 394574b..5dc81aa 100644 --- a/src/test/org/codehaus/jackson/map/deser/TestGenericsBounded.java +++ b/src/test/org/codehaus/jackson/map/deser/TestGenericsBounded.java
@@ -57,20 +57,6 @@ public T wrapped; } - // Helper types for [JACKSON-743] - - public static abstract class Base<T> { - public T inconsequential = null; - } - - public static abstract class BaseData<T> { - public T dataObj; - } - - public static class Child extends Base<Long> { - public static class ChildData extends BaseData<List<String>> { } - } - /* /******************************************************* /* Unit tests @@ -109,15 +95,4 @@ assertEquals(-0.5, out.start); assertEquals(0.5, out.end); } - - // Reproducing issue 743 - public void testResolution743() throws Exception - { - String s3 = "{\"dataObj\" : [ \"one\", \"two\", \"three\" ] }"; - ObjectMapper m = new ObjectMapper(); - - Child.ChildData d = m.readValue(s3, Child.ChildData.class); - assertNotNull(d.dataObj); - assertEquals(3, d.dataObj.size()); - } }
diff --git a/src/test/org/codehaus/jackson/map/ser/TestEnumSerialization.java b/src/test/org/codehaus/jackson/map/ser/TestEnumSerialization.java index e2e8a06..a0c02ce 100644 --- a/src/test/org/codehaus/jackson/map/ser/TestEnumSerialization.java +++ b/src/test/org/codehaus/jackson/map/ser/TestEnumSerialization.java
@@ -5,6 +5,7 @@ import org.codehaus.jackson.JsonGenerator; import org.codehaus.jackson.JsonProcessingException; +import org.codehaus.jackson.annotate.JsonProperty; import org.codehaus.jackson.annotate.JsonValue; import org.codehaus.jackson.map.*; import org.codehaus.jackson.map.annotate.JsonSerialize; @@ -73,7 +74,6 @@ serialize(jgen, provider); } - @SuppressWarnings("deprecation") @Override public void serialize(JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { @@ -95,6 +95,28 @@ map.put(key, Integer.valueOf(value)); } } + + // [JACKSON-757] + static enum NOK { + V1("v1"); + protected String key; + // any runtime-persistent annotation is fine + NOK(@JsonProperty String key) { this.key = key; } + } + + static enum OK { + V1("v1"); + protected String key; + OK(String key) { this.key = key; } + } + + // problems with annotations on enum value constructors + public void testIssue757() throws Exception + { + ObjectMapper mapper = new ObjectMapper(); + mapper.writeValueAsString(OK.V1); + mapper.writeValueAsString(NOK.V1); + } /* /**********************************************************