Yet more test consolidation
diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/AnySetter349Test.java b/src/test/java/com/fasterxml/jackson/databind/deser/AnySetter349Test.java
deleted file mode 100644
index 7cfa4d4..0000000
--- a/src/test/java/com/fasterxml/jackson/databind/deser/AnySetter349Test.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package com.fasterxml.jackson.databind.deser;
-
-import java.util.*;
-
-import com.fasterxml.jackson.annotation.*;
-
-import com.fasterxml.jackson.databind.*;
-
-// test(s) for [databind#349]
-public class AnySetter349Test extends BaseMapTest
-{
- static class Bean349
- {
- public String type;
- public int x, y;
-
- private Map<String, Object> props = new HashMap<>();
-
- @JsonAnySetter
- public void addProperty(String key, Object value) {
- props.put(key, value);
- }
-
- @JsonAnyGetter
- public Map<String, Object> getProperties() {
- return props;
- }
-
- @JsonUnwrapped
- public IdentityDTO349 identity;
- }
-
- static class IdentityDTO349 {
- public int x, y;
- }
-
- final static String UNWRAPPED_JSON_349 = aposToQuotes(
-"{ 'type' : 'IST',\n"
-+" 'x' : 3,\n"
-//+" 'name' : 'BLAH-New',\n"
-//+" 'description' : 'namespace.name: X THIN FIR.DR-WD12-New',\n"
-+" 'ZoomLinks': [ 'foofoofoofoo', 'barbarbarbar' ],\n"
-+" 'y' : 4, 'z' : 8 }"
- );
-
- public void testUnwrappedWithAny() throws Exception
- {
- final ObjectMapper mapper = objectMapper();
- Bean349 value = mapper.readValue(UNWRAPPED_JSON_349, Bean349.class);
- assertNotNull(value);
- assertEquals(3, value.x);
- assertEquals(4, value.y);
- assertEquals(2, value.props.size());
- }
-
- public void testUnwrappedWithAnyAsUpdate() throws Exception
- {
- final ObjectMapper mapper = objectMapper();
- Bean349 bean = mapper.readerFor(Bean349.class)
- .withValueToUpdate(new Bean349())
- .readValue(UNWRAPPED_JSON_349);
- assertEquals(3, bean.x);
- assertEquals(4, bean.y);
- assertEquals(2, bean.props.size());
- }
-}
diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/AnySetterTest.java b/src/test/java/com/fasterxml/jackson/databind/deser/AnySetterTest.java
index 7e5dc85..5608e4d 100644
--- a/src/test/java/com/fasterxml/jackson/databind/deser/AnySetterTest.java
+++ b/src/test/java/com/fasterxml/jackson/databind/deser/AnySetterTest.java
@@ -215,7 +215,33 @@
}
}
- /*
+ // [databind#349]
+ static class Bean349
+ {
+ public String type;
+ public int x, y;
+
+ private Map<String, Object> props = new HashMap<>();
+
+ @JsonAnySetter
+ public void addProperty(String key, Object value) {
+ props.put(key, value);
+ }
+
+ @JsonAnyGetter
+ public Map<String, Object> getProperties() {
+ return props;
+ }
+
+ @JsonUnwrapped
+ public IdentityDTO349 identity;
+ }
+
+ static class IdentityDTO349 {
+ public int x, y;
+ }
+
+ /*
/**********************************************************
/* Test methods
/**********************************************************
@@ -332,6 +358,38 @@
assertNull(result.other);
}
+ final static String UNWRAPPED_JSON_349 = aposToQuotes(
+ "{ 'type' : 'IST',\n"
+ +" 'x' : 3,\n"
+ //+" 'name' : 'BLAH-New',\n"
+ //+" 'description' : 'namespace.name: X THIN FIR.DR-WD12-New',\n"
+ +" 'ZoomLinks': [ 'foofoofoofoo', 'barbarbarbar' ],\n"
+ +" 'y' : 4, 'z' : 8 }"
+ );
+
+ // [databind#349]
+ public void testUnwrappedWithAny() throws Exception
+ {
+ final ObjectMapper mapper = objectMapper();
+ Bean349 value = mapper.readValue(UNWRAPPED_JSON_349, Bean349.class);
+ assertNotNull(value);
+ assertEquals(3, value.x);
+ assertEquals(4, value.y);
+ assertEquals(2, value.props.size());
+ }
+
+ // [databind#349]
+ public void testUnwrappedWithAnyAsUpdate() throws Exception
+ {
+ final ObjectMapper mapper = objectMapper();
+ Bean349 bean = mapper.readerFor(Bean349.class)
+ .withValueToUpdate(new Bean349())
+ .readValue(UNWRAPPED_JSON_349);
+ assertEquals(3, bean.x);
+ assertEquals(4, bean.y);
+ assertEquals(2, bean.props.size());
+ }
+
// [databind#1035]
public void testGenericAnySetter() throws Exception
{
diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/TestCustomFactory.java b/src/test/java/com/fasterxml/jackson/databind/deser/TestCustomFactory.java
deleted file mode 100644
index bda0e14..0000000
--- a/src/test/java/com/fasterxml/jackson/databind/deser/TestCustomFactory.java
+++ /dev/null
@@ -1,140 +0,0 @@
-package com.fasterxml.jackson.databind.deser;
-
-import java.io.*;
-import java.util.*;
-
-
-import com.fasterxml.jackson.core.*;
-import com.fasterxml.jackson.databind.*;
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
-
-/**
- * Test to check that customizations work as expected.
- */
-@SuppressWarnings("serial")
-public class TestCustomFactory
- extends BaseMapTest
-{
- /*
- /**********************************************************
- /* Helper classes
- /**********************************************************
- */
-
- static class DummyDeserializer<T>
- extends StdDeserializer<T>
- {
- final T value;
-
- public DummyDeserializer(T v, Class<T> cls) {
- super(cls);
- value = v;
- }
-
- @Override
- public T deserialize(JsonParser jp, DeserializationContext ctxt)
- throws IOException, JsonProcessingException
- {
- // need to skip, if structured...
- jp.skipChildren();
- return value;
- }
- }
-
- static class TestBeans {
- public List<TestBean> beans;
- }
- static class TestBean {
- public CustomBean c;
- public String d;
- }
- @JsonDeserialize(using=CustomBeanDeserializer.class)
- static class CustomBean {
- protected final int a, b;
- public CustomBean(int a, int b) {
- this.a = a;
- this.b = b;
- }
- }
-
- static class CustomBeanDeserializer extends JsonDeserializer<CustomBean>
- {
- @Override
- public CustomBean deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException
- {
- int a = 0, b = 0;
- JsonToken t = jp.getCurrentToken();
- if (t == JsonToken.START_OBJECT) {
- t = jp.nextToken();
- } else if (t != JsonToken.FIELD_NAME) {
- throw new Error();
- }
- while(t == JsonToken.FIELD_NAME) {
- final String fieldName = jp.getCurrentName();
- t = jp.nextToken();
- if (t != JsonToken.VALUE_NUMBER_INT) {
- throw new JsonParseException(jp, "expecting number got "+ t);
- }
- if (fieldName.equals("a")) {
- a = jp.getIntValue();
- } else if (fieldName.equals("b")) {
- b = jp.getIntValue();
- } else {
- throw new Error();
- }
- t = jp.nextToken();
- }
- return new CustomBean(a, b);
- }
- }
-
-
- /*
- /**********************************************************
- /* Unit tests
- /**********************************************************
- */
-
- public void testCustomBeanDeserializer() throws Exception
- {
-
- final ObjectMapper map = new ObjectMapper();
- String json = "{\"beans\":[{\"c\":{\"a\":10,\"b\":20},\"d\":\"hello, tatu\"}]}";
- TestBeans beans = map.readValue(json, TestBeans.class);
-
- assertNotNull(beans);
- List<TestBean> results = beans.beans;
- assertNotNull(results);
- assertEquals(1, results.size());
- TestBean bean = results.get(0);
- assertEquals("hello, tatu", bean.d);
- CustomBean c = bean.c;
- assertNotNull(c);
- assertEquals(10, c.a);
- assertEquals(20, c.b);
-
- json = "{\"beans\":[{\"c\":{\"b\":3,\"a\":-4},\"d\":\"\"},"
- +"{\"d\":\"abc\", \"c\":{\"b\":15}}]}";
- beans = map.readValue(json, TestBeans.class);
-
- assertNotNull(beans);
- results = beans.beans;
- assertNotNull(results);
- assertEquals(2, results.size());
-
- bean = results.get(0);
- assertEquals("", bean.d);
- c = bean.c;
- assertNotNull(c);
- assertEquals(-4, c.a);
- assertEquals(3, c.b);
-
- bean = results.get(1);
- assertEquals("abc", bean.d);
- c = bean.c;
- assertNotNull(c);
- assertEquals(0, c.a);
- assertEquals(15, c.b);
- }
-}