Test illustrating handleUnknownTypeId problem (#2222)

diff --git a/pom.xml b/pom.xml
index 5e0c0af..d7e882c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -86,6 +86,18 @@
       <version>1.0.0</version>
       <scope>test</scope>
     </dependency>
+        <dependency>
+    	<groupId>commons-io</groupId>
+    	<artifactId>commons-io</artifactId>
+    	<version>2.4</version>
+    	<scope>test</scope>
+    </dependency>
+	<dependency>
+	    <groupId>org.assertj</groupId>
+	    <artifactId>assertj-core</artifactId>
+	    <version>3.11.1</version>
+	    <scope>test</scope>
+	</dependency>
   </dependencies>
 
   <!-- Alas, need to include snapshot reference since otherwise can not find
diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/GenericContent.java b/src/test/java/com/fasterxml/jackson/databind/deser/GenericContent.java
new file mode 100644
index 0000000..3ff6497
--- /dev/null
+++ b/src/test/java/com/fasterxml/jackson/databind/deser/GenericContent.java
@@ -0,0 +1,23 @@
+package com.fasterxml.jackson.databind.deser;
+
+import java.util.Collection;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+
+@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "_class")
+@JsonInclude(Include.NON_EMPTY)
+public class GenericContent {
+
+    private Collection innerObjects;
+
+    public Collection getInnerObjects() {
+        return innerObjects;
+    }
+
+    public void setInnerObjects(Collection innerObjects) {
+        this.innerObjects = innerObjects;
+    }
+
+}
\ No newline at end of file
diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/HandleUnknowTypeIdTest.java b/src/test/java/com/fasterxml/jackson/databind/deser/HandleUnknowTypeIdTest.java
new file mode 100644
index 0000000..5e97e58
--- /dev/null
+++ b/src/test/java/com/fasterxml/jackson/databind/deser/HandleUnknowTypeIdTest.java
@@ -0,0 +1,78 @@
+package com.fasterxml.jackson.databind.deser;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+
+import org.apache.commons.io.IOUtils;
+import org.assertj.core.api.Assertions;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.JavaType;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.jsontype.TypeIdResolver;
+
+public class HandleUnknowTypeIdTest {
+
+    public static class DummyContent {
+        private String aField;
+
+        public DummyContent() {
+            super();
+        }
+
+        public DummyContent(String aField) {
+            super();
+            this.aField = aField;
+        }
+
+        public String getaField() {
+            return aField;
+        }
+
+        public void setaField(String aField) {
+            this.aField = aField;
+        }
+
+        @Override
+        public String toString() {
+            return "DummyContent [aField=" + aField + "]";
+        }
+    }
+
+    private ObjectMapper objectMapper;
+
+    @Before
+    public void setUp() {
+        objectMapper = new ObjectMapper();
+        objectMapper.enableDefaultTyping();
+    }
+
+    @Test
+    public void testDeserializationWithDeserializationProblemHandler() throws JsonParseException, JsonMappingException, IOException {
+        String dummyJson = IOUtils.toString(HandleUnknowTypeIdTest.class.getResourceAsStream("/com/fasterxml/jackson/databind/deser/DummyProcessableContent.json"),
+                StandardCharsets.UTF_8);
+        objectMapper.addHandler(new DeserializationProblemHandler() {
+            @Override
+            public JavaType handleUnknownTypeId(DeserializationContext ctxt, JavaType baseType, String subTypeId, TypeIdResolver idResolver, String failureMsg) throws IOException {
+                System.out.println("Print out a warning here");
+                return ctxt.constructType(Void.class);
+            }
+        });
+        GenericContent processableContent = objectMapper.readValue(dummyJson, GenericContent.class);
+        Assertions.assertThat(processableContent.getInnerObjects()).hasSize(2).usingFieldByFieldElementComparator().contains(new DummyContent("some value"));
+    }
+
+    @Test
+    public void testDeserializationWithFAIL_ON_INVALID_SUBTYPE_false() throws JsonParseException, JsonMappingException, IOException {
+        String dummyJson = IOUtils.toString(HandleUnknowTypeIdTest.class.getResourceAsStream("/com/fasterxml/jackson/databind/deser/DummyProcessableContent.json"),
+                StandardCharsets.UTF_8);
+        objectMapper.disable(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE);
+        GenericContent processableContent = objectMapper.readValue(dummyJson, GenericContent.class);
+        Assertions.assertThat(processableContent.getInnerObjects()).hasSize(2).usingFieldByFieldElementComparator().contains(new DummyContent("some value"));
+    }
+}
diff --git a/src/test/resources/com/fasterxml/jackson/databind/deser/DummyProcessableContent.json b/src/test/resources/com/fasterxml/jackson/databind/deser/DummyProcessableContent.json
new file mode 100644
index 0000000..8972151
--- /dev/null
+++ b/src/test/resources/com/fasterxml/jackson/databind/deser/DummyProcessableContent.json
@@ -0,0 +1,21 @@
+{
+	"_class":"com.fasterxml.jackson.databind.deser.GenericContent",
+	"innerObjects":
+		[
+			"java.util.ArrayList",
+			[
+				[
+					"com.fasterxml.jackson.databind.deser.HandleUnknowTypeIdTest$DummyContent",
+					{
+						"aField":"some value"
+					}
+				],
+				[
+					"com.fasterxml.jackson.databind.deser.HandleUnknowTypeIdTest$AnInventedClassBeingNotOnTheClasspath",
+					{
+						"aField":"some value"
+					}
+				]
+			]
+		]
+}
\ No newline at end of file