Skip to content

Commit

Permalink
Optional patches for Databind.
Browse files Browse the repository at this point in the history
  • Loading branch information
rjust committed Sep 8, 2024
1 parent bf6e118 commit 5ff0e19
Show file tree
Hide file tree
Showing 10 changed files with 160 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/JDKStringLikeTypesTest.java b/src/test/java/com/fasterxml/jackson/databind/deser/JDKStringLikeTypesTest.java
index cef00c19b..61eca23a1 100644
--- a/src/test/java/com/fasterxml/jackson/databind/deser/JDKStringLikeTypesTest.java
+++ b/src/test/java/com/fasterxml/jackson/databind/deser/JDKStringLikeTypesTest.java
@@ -64,7 +64,7 @@ public class JDKStringLikeTypesTest extends BaseMapTest
/**********************************************************
*/

- private final ObjectMapper MAPPER = objectMapper();
+ private final ObjectMapper MAPPER = objectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

// [databind#239]
public void testByteBuffer() throws Exception
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/TestExceptionDeserialization.java b/src/test/java/com/fasterxml/jackson/databind/deser/TestExceptionDeserialization.java
index 391ee8386..ab2f03415 100644
--- a/src/test/java/com/fasterxml/jackson/databind/deser/TestExceptionDeserialization.java
+++ b/src/test/java/com/fasterxml/jackson/databind/deser/TestExceptionDeserialization.java
@@ -51,7 +51,7 @@ public class TestExceptionDeserialization
/**********************************************************
*/

- final ObjectMapper MAPPER = new ObjectMapper();
+ final ObjectMapper MAPPER = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

public void testIOException() throws IOException
{
@@ -78,6 +78,7 @@ public class TestExceptionDeserialization
public void testWithNullMessage() throws IOException
{
final ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
String json = mapper.writeValueAsString(new IOException((String) null));
IOException result = mapper.readValue(json, IOException.class);
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/TestExceptionDeserialization.java b/src/test/java/com/fasterxml/jackson/databind/deser/TestExceptionDeserialization.java
index 255bffe38..51d980959 100644
--- a/src/test/java/com/fasterxml/jackson/databind/deser/TestExceptionDeserialization.java
+++ b/src/test/java/com/fasterxml/jackson/databind/deser/TestExceptionDeserialization.java
@@ -51,7 +51,7 @@ public class TestExceptionDeserialization
/**********************************************************
*/

- private final ObjectMapper MAPPER = new ObjectMapper();
+ private final ObjectMapper MAPPER = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

public void testIOException() throws IOException
{
@@ -76,6 +76,7 @@ public class TestExceptionDeserialization
public void testWithNullMessage() throws IOException
{
final ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
String json = mapper.writeValueAsString(new IOException((String) null));
IOException result = mapper.readValue(json, IOException.class);
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/exc/TestExceptionDeserialization.java b/src/test/java/com/fasterxml/jackson/databind/deser/exc/TestExceptionDeserialization.java
index 43084c960..a7850ba51 100644
--- a/src/test/java/com/fasterxml/jackson/databind/deser/exc/TestExceptionDeserialization.java
+++ b/src/test/java/com/fasterxml/jackson/databind/deser/exc/TestExceptionDeserialization.java
@@ -51,7 +51,7 @@ public class TestExceptionDeserialization
/**********************************************************
*/

- private final ObjectMapper MAPPER = new ObjectMapper();
+ private final ObjectMapper MAPPER = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

public void testIOException() throws IOException
{
@@ -76,6 +76,7 @@ public class TestExceptionDeserialization
public void testWithNullMessage() throws IOException
{
final ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
String json = mapper.writeValueAsString(new IOException((String) null));
IOException result = mapper.readValue(json, IOException.class);
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/src/test/java/com/fasterxml/jackson/databind/ser/TestExceptionSerialization.java b/src/test/java/com/fasterxml/jackson/databind/ser/TestExceptionSerialization.java
index 111c67159..cc6785984 100644
--- a/src/test/java/com/fasterxml/jackson/databind/ser/TestExceptionSerialization.java
+++ b/src/test/java/com/fasterxml/jackson/databind/ser/TestExceptionSerialization.java
@@ -87,6 +87,7 @@ public class TestExceptionSerialization
assertNull(result2.get("bogus2"));

// and try to deserialize as well
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
ExceptionWithIgnoral output = mapper.readValue(json2, ExceptionWithIgnoral.class);
assertNotNull(output);
assertEquals("foobar", output.getMessage());
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/exc/TestExceptionSerialization.java b/src/test/java/com/fasterxml/jackson/databind/deser/exc/TestExceptionSerialization.java
index 07fc70a6b..31cf96894 100644
--- a/src/test/java/com/fasterxml/jackson/databind/deser/exc/TestExceptionSerialization.java
+++ b/src/test/java/com/fasterxml/jackson/databind/deser/exc/TestExceptionSerialization.java
@@ -96,6 +96,7 @@ public class TestExceptionSerialization
assertNull(result2.get("bogus2"));

// and try to deserialize as well
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
ExceptionWithIgnoral output = mapper.readValue(json2, ExceptionWithIgnoral.class);
assertNotNull(output);
assertEquals("foobar", output.getMessage());
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/src/test/java/com/fasterxml/jackson/databind/interop/IllegalTypesCheckTest.java b/src/test/java/com/fasterxml/jackson/databind/interop/IllegalTypesCheckTest.java
index f7d1517ed..0fc5e357d 100644
--- a/src/test/java/com/fasterxml/jackson/databind/interop/IllegalTypesCheckTest.java
+++ b/src/test/java/com/fasterxml/jackson/databind/interop/IllegalTypesCheckTest.java
@@ -80,7 +80,7 @@ public class IllegalTypesCheckTest extends BaseMapTest
public void testJDKTypes1855() throws Exception
{
// apparently included by JDK?
- _testIllegalType("com.sun.org.apache.bcel.internal.util.ClassLoader");
+// _testIllegalType("com.sun.org.apache.bcel.internal.util.ClassLoader");

// also: we can try some form of testing, even if bit contrived...
_testIllegalType(BogusPointcutAdvisor.class);
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/TestJdkTypes.java b/src/test/java/com/fasterxml/jackson/databind/deser/TestJdkTypes.java
index d9c442a84..d2ceaf65d 100644
--- a/src/test/java/com/fasterxml/jackson/databind/deser/TestJdkTypes.java
+++ b/src/test/java/com/fasterxml/jackson/databind/deser/TestJdkTypes.java
@@ -70,7 +70,7 @@ public class TestJdkTypes extends BaseMapTest
/**********************************************************
*/

- private final ObjectMapper mapper = new ObjectMapper();
+ private final ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

/**
* Related to issues [JACKSON-155], [#170].
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/TestJdkTypes.java b/src/test/java/com/fasterxml/jackson/databind/deser/TestJdkTypes.java
index ad3305de9..6a551cb67 100644
--- a/src/test/java/com/fasterxml/jackson/databind/deser/TestJdkTypes.java
+++ b/src/test/java/com/fasterxml/jackson/databind/deser/TestJdkTypes.java
@@ -99,7 +99,7 @@ public class TestJdkTypes extends BaseMapTest
/**********************************************************
*/

- private final ObjectMapper MAPPER = objectMapper();
+ private final ObjectMapper MAPPER = objectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

/**
* Related to issues [JACKSON-155], [#170].
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
diff --git a/src/test/java/com/fasterxml/jackson/databind/type/TestTypeFactoryWithClassLoader.java b/src/test/java/com/fasterxml/jackson/databind/type/TestTypeFactoryWithClassLoader.java
index e9a8070f4..0cfa40b97 100644
--- a/src/test/java/com/fasterxml/jackson/databind/type/TestTypeFactoryWithClassLoader.java
+++ b/src/test/java/com/fasterxml/jackson/databind/type/TestTypeFactoryWithClassLoader.java
@@ -6,6 +6,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.modules.junit4.PowerMockRunner;

import com.fasterxml.jackson.databind.ObjectMapper;
@@ -17,7 +18,7 @@ import org.junit.BeforeClass;

@RunWith(PowerMockRunner.class)
@PrepareForTest(TypeFactory.class)
-
+@PowerMockIgnore("jdk.internal.reflect.*")
public class TestTypeFactoryWithClassLoader {
@Mock
private TypeModifier typeModifier;

0 comments on commit 5ff0e19

Please sign in to comment.