Skip to content

Commit

Permalink
Merge branch '2.18'
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Apr 20, 2024
2 parents 06c59d0 + a2a7db7 commit 51502c2
Show file tree
Hide file tree
Showing 45 changed files with 111 additions and 102 deletions.
11 changes: 6 additions & 5 deletions src/test/java/tools/jackson/databind/MapperFootprintTest.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package tools.jackson.databind;

import com.google.common.testing.GcFinalization;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.openjdk.jol.info.GraphLayout;

import static org.junit.jupiter.api.Assertions.assertTrue;

public class MapperFootprintTest {
/*
* Note: this class is run in an isolated execution in surefire. The test is too flaky with all the other tests
Expand All @@ -28,10 +29,10 @@ public void testMapperFootprint() throws InterruptedException {

// 29-Nov-2022, tatu: Should be under 10k, but... flakiness.
final int maxByteSize = 20_000;
Assert.assertTrue(
assertTrue(
mapperLayout.totalSize() < maxByteSize,
"ObjectMapper memory footprint ("+mapperLayout.totalSize()
+") exceeded limit ("+maxByteSize
+"). Footprint details: " + mapperLayout.toFootprint(),
mapperLayout.totalSize() < maxByteSize);
+"). Footprint details: " + mapperLayout.toFootprint());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public void testReading() throws Exception
assertEquals(1, citm.venueNames.size());
}

@Test
public void testRoundTrip() throws Exception
{
Citm citm = MAPPER.readValue(getClass().getResourceAsStream("/data/citm_catalog.json"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ public void testAnySetterWithJsonNode() throws Exception
}

// [databind#4316]
@Test
public void testWithAnySetter() throws Exception
{
Problem4316 problem = new Problem4316();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package tools.jackson.databind.deser.bean;

import java.util.concurrent.atomic.AtomicInteger;

import org.junit.jupiter.api.Test;

import tools.jackson.databind.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import java.util.Objects;

import org.junit.Test;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

Expand All @@ -13,6 +11,8 @@
import tools.jackson.databind.json.JsonMapper;
import tools.jackson.databind.testutil.DatabindTestUtil;

import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

import static com.fasterxml.jackson.annotation.JsonCreator.Mode.DELEGATING;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class LocaleDeser4009Test
{
private final ObjectMapper MAPPER = newJsonMapper();

@Test
public void testLocaleWithFeatureDisabled() throws Exception
{
assertEquals(Locale.ROOT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import tools.jackson.databind.*;
import tools.jackson.databind.exc.InvalidFormatException;

import org.junit.Assert;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;
Expand Down Expand Up @@ -120,11 +119,11 @@ public void testBooleanMapKeyDeserialization() throws Exception
TypeReference<MapWrapper<Boolean, String>> type = new TypeReference<MapWrapper<Boolean, String>>() { };
MapWrapper<?,?> result = MAPPER.readValue(a2q("{'map':{'true':'foobar'}}"), type);
assertEquals(1, result.map.size());
Assert.assertEquals(Boolean.TRUE, result.map.entrySet().iterator().next().getKey());
assertEquals(Boolean.TRUE, result.map.entrySet().iterator().next().getKey());

result = MAPPER.readValue(a2q("{'map':{'false':'foobar'}}"), type);
assertEquals(1, result.map.size());
Assert.assertEquals(Boolean.FALSE, result.map.entrySet().iterator().next().getKey());
assertEquals(Boolean.FALSE, result.map.entrySet().iterator().next().getKey());
}

@Test
Expand All @@ -133,7 +132,7 @@ public void testByteMapKeyDeserialization() throws Exception
TypeReference<MapWrapper<Byte, String>> type = new TypeReference<MapWrapper<Byte, String>>() { };
MapWrapper<?,?> result = MAPPER.readValue(a2q("{'map':{'13':'foobar'}}"), type);
assertEquals(1, result.map.size());
Assert.assertEquals(Byte.valueOf((byte) 13), result.map.entrySet().iterator().next().getKey());
assertEquals(Byte.valueOf((byte) 13), result.map.entrySet().iterator().next().getKey());
}

@Test
Expand All @@ -142,7 +141,7 @@ public void testShortMapKeyDeserialization() throws Exception
TypeReference<MapWrapper<Short, String>> type = new TypeReference<MapWrapper<Short, String>>() { };
MapWrapper<?,?> result = MAPPER.readValue(a2q("{'map':{'13':'foobar'}}"), type);
assertEquals(1, result.map.size());
Assert.assertEquals(Short.valueOf((short) 13), result.map.entrySet().iterator().next().getKey());
assertEquals(Short.valueOf((short) 13), result.map.entrySet().iterator().next().getKey());
}

@Test
Expand All @@ -151,7 +150,7 @@ public void testIntegerMapKeyDeserialization() throws Exception
TypeReference<MapWrapper<Integer, String>> type = new TypeReference<MapWrapper<Integer, String>>() { };
MapWrapper<?,?> result = MAPPER.readValue(a2q("{'map':{'-3':'foobar'}}"), type);
assertEquals(1, result.map.size());
Assert.assertEquals(Integer.valueOf(-3), result.map.entrySet().iterator().next().getKey());
assertEquals(Integer.valueOf(-3), result.map.entrySet().iterator().next().getKey());
}

@Test
Expand All @@ -160,7 +159,7 @@ public void testLongMapKeyDeserialization() throws Exception
TypeReference<MapWrapper<Long, String>> type = new TypeReference<MapWrapper<Long, String>>() { };
MapWrapper<?,?> result = MAPPER.readValue(a2q("{'map':{'42':'foobar'}}"), type);
assertEquals(1, result.map.size());
Assert.assertEquals(Long.valueOf(42), result.map.entrySet().iterator().next().getKey());
assertEquals(Long.valueOf(42), result.map.entrySet().iterator().next().getKey());
}

@Test
Expand All @@ -169,7 +168,7 @@ public void testFloatMapKeyDeserialization() throws Exception
TypeReference<MapWrapper<Float, String>> type = new TypeReference<MapWrapper<Float, String>>() { };
MapWrapper<?,?> result = MAPPER.readValue(a2q("{'map':{'3.5':'foobar'}}"), type);
assertEquals(1, result.map.size());
Assert.assertEquals(Float.valueOf(3.5f), result.map.entrySet().iterator().next().getKey());
assertEquals(Float.valueOf(3.5f), result.map.entrySet().iterator().next().getKey());
}

@Test
Expand All @@ -178,7 +177,7 @@ public void testDoubleMapKeyDeserialization() throws Exception
TypeReference<MapWrapper<Double, String>> type = new TypeReference<MapWrapper<Double, String>>() { };
MapWrapper<?,?> result = MAPPER.readValue(a2q("{'map':{'0.25':'foobar'}}"), type);
assertEquals(1, result.map.size());
Assert.assertEquals(Double.valueOf(0.25), result.map.entrySet().iterator().next().getKey());
assertEquals(Double.valueOf(0.25), result.map.entrySet().iterator().next().getKey());
}

/*
Expand Down Expand Up @@ -213,7 +212,7 @@ public void testByteArrayMapKeyDeserialization() throws Exception
Map.Entry<byte[],String> entry = result.map.entrySet().iterator().next();
assertEquals("foobar", entry.getValue());
byte[] key = entry.getKey();
Assert.assertArrayEquals(binary, key);
assertArrayEquals(binary, key);
}

// [databind#2725]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ private JsonNode _updateTreeWithArray(ObjectMapper mapper) throws Exception
return mapper.readerForUpdating(mergeTarget).readValue(updateNode);
}

@Test
public void testEnabledObjectNodeMerge() throws Exception {
final ObjectMapper mapperWithMerge = sharedMapper();

Expand All @@ -91,6 +92,7 @@ public void testEnabledObjectNodeMerge() throws Exception {
assertEquals(expected, merged);
}

@Test
public void testDisabledObjectNodeMerge() throws Exception {
ObjectMapper mapperNoObjectMerge = jsonMapperBuilder()
.withConfigOverride(ObjectNode.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public void testDeserAsThrowable() throws Exception
_testDeserAsThrowable(MAPPER.writeValueAsString(new CustomThrowable4071()));
}

@Test
private void _testDeserAsThrowable(String exStr) throws Exception
{
assertNotNull(MAPPER.readValue(exStr, Throwable.class));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import java.util.List;
import java.util.Objects;

import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
Expand All @@ -14,9 +16,7 @@
import tools.jackson.databind.annotation.JsonDeserialize;
import tools.jackson.databind.annotation.JsonSerialize;

import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

/**
* Tests for serialization and deserialization of objects based on
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package tools.jackson.databind.jsontype.deftyping;

import org.junit.Assert;
import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.annotation.*;
Expand Down Expand Up @@ -103,6 +102,6 @@ public void testWithCreatorAndJsonValue() throws Exception
assertNotNull(result.value);
assertEquals(Bean1385.class, result.value.getClass());
Bean1385 b = (Bean1385) result.value;
Assert.assertArrayEquals(BYTES, b.raw);
assertArrayEquals(BYTES, b.raw);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package tools.jackson.databind.jsontype.ext;

import org.junit.Test;

import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.annotation.JsonSubTypes.Type;
import com.fasterxml.jackson.annotation.JsonTypeInfo.As;
Expand All @@ -11,6 +9,8 @@
import tools.jackson.databind.exc.MismatchedInputException;
import tools.jackson.databind.testutil.DatabindTestUtil;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

// for [databind#2404]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.util.*;

import org.junit.Assert;
import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.annotation.*;
Expand Down Expand Up @@ -116,13 +115,13 @@ public void testPolymorphicWithContainer() throws Exception
Container1 c1 = new Container1();
c1.setAnimal(dog);
String s1 = mapper.writeValueAsString(c1);
Assert.assertTrue("polymorphic type info is kept (1)", s1
.indexOf("\"object-type\":\"doggy\"") >= 0);
assertTrue(s1.indexOf("\"object-type\":\"doggy\"") >= 0,
"polymorphic type info is kept (1)");
Container2<Animal> c2 = new Container2<Animal>();
c2.setAnimal(dog);
String s2 = mapper.writeValueAsString(c2);
Assert.assertTrue("polymorphic type info is kept (2)", s2
.indexOf("\"object-type\":\"doggy\"") >= 0);
assertTrue(s2.indexOf("\"object-type\":\"doggy\"") >= 0,
"polymorphic type info is kept (2)");
}

@Test
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/tools/jackson/databind/node/ArrayNodeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
import tools.jackson.databind.testutil.DatabindTestUtil;

import static java.util.Arrays.asList;
import static org.junit.Assert.*;

import static org.junit.jupiter.api.Assertions.*;

/**
* Additional tests for {@link ArrayNode} container class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import tools.jackson.databind.*;
import tools.jackson.databind.testutil.DatabindTestUtil;

import static org.junit.Assert.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.fail;

/**
Expand Down Expand Up @@ -135,7 +135,7 @@ private void _assertNullTree(TreeNode n) {
}

private void _assertMissing(JsonNode n) {
assertNotNull("Should not get `null` but `MissingNode`", n);
assertNotNull(n, "Should not get `null` but `MissingNode`");
if (!n.isMissingNode()) {
fail("Should get `MissingNode` but got: "+n.getClass().getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,8 @@ public void testConversionOfTrees() throws Exception

// then via conversions: should become JSON Object
JsonNode tree = MAPPER.valueToTree(input);
assertTrue(tree.isBoolean(), "Expected Object, got "+tree.getNodeType());
assertTrue(tree.isBoolean(),
"Expected Object, got "+tree.getNodeType());
assertEquals(EXP, MAPPER.writeValueAsString(tree));

JsonNode tree2 = MAPPER.writer().valueToTree(tree);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.junit.jupiter.api.Test;

import static org.junit.Assert.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;

import static org.junit.jupiter.api.Assertions.*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ public void testSimpleNonArrayNoSeparator() throws Exception
// will not work in 2.x.
}

@Test
public void testSimpleArray() throws Exception
{
StringWriter strw = new StringWriter();
Expand Down Expand Up @@ -171,6 +172,7 @@ public void testSimpleArray() throws Exception
*/

@SuppressWarnings("resource")
@Test
public void testPolymorphicNonArrayWithoutType() throws Exception
{
StringWriter strw = new StringWriter();
Expand All @@ -184,6 +186,7 @@ public void testPolymorphicNonArrayWithoutType() throws Exception
}

@SuppressWarnings("resource")
@Test
public void testPolymorphicArrayWithoutType() throws Exception
{
StringWriter strw = new StringWriter();
Expand All @@ -196,6 +199,7 @@ public void testPolymorphicArrayWithoutType() throws Exception
strw.toString());
}

@Test
public void testPolymorphicArrayWithType() throws Exception
{
StringWriter strw = new StringWriter();
Expand All @@ -212,6 +216,7 @@ public void testPolymorphicArrayWithType() throws Exception
}

@SuppressWarnings("resource")
@Test
public void testSimpleCloseable() throws Exception
{
JsonMapper mapper = JsonMapper.builder().enable(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import tools.jackson.databind.JavaType;

import static org.junit.Assert.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.*;

import static tools.jackson.databind.testutil.DatabindTestUtil.verifyException;
Expand Down
12 changes: 6 additions & 6 deletions src/test/java/tools/jackson/databind/type/TypeFactoryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

import tools.jackson.databind.*;

import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertThrows;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.*;

import static tools.jackson.databind.testutil.DatabindTestUtil.newTypeFactory;
Expand Down Expand Up @@ -477,9 +477,9 @@ public void testMapsHashCode()
JavaType mapIntString = tf.constructType(new TypeReference<Map<Integer,String>>() {});
assertNotEquals(mapStringInt, mapIntString);
assertNotEquals(
"hashCode should depend on parameter order",
mapStringInt.hashCode(),
mapIntString.hashCode());
mapIntString.hashCode(),
"hashCode should depend on parameter order");

JavaType mapStringString = tf.constructType(new TypeReference<Map<String,String>>() {});
JavaType mapIntInt = tf.constructType(new TypeReference<Map<Integer,Integer>>() {});
Expand Down Expand Up @@ -793,8 +793,8 @@ public void testParameterizedSimpleType() {

assertNotEquals(charSequenceClass, numberClass);
assertNotEquals(
"hash values should be distributed",
charSequenceClass.hashCode(), numberClass.hashCode());
charSequenceClass.hashCode(), numberClass.hashCode(),
"hash values should be distributed");
}

private void assertEqualsAndHash(JavaType t1, JavaType t2) {
Expand Down
Loading

0 comments on commit 51502c2

Please sign in to comment.