Skip to content

Commit 57dd2d2

Browse files
committed
Merge branch '2.19'
2 parents f60d992 + 1b7a759 commit 57dd2d2

File tree

85 files changed

+795
-147
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+795
-147
lines changed

afterburner/pom.xml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,15 @@ field access and method calls
5555
<artifactId>byte-buddy</artifactId>
5656
</dependency>
5757

58-
<!-- 20-Apr-2024, tatu: JUnit4 no longer from jackson-base -->
58+
<!-- Test dependencies -->
5959
<dependency>
60-
<groupId>junit</groupId>
61-
<artifactId>junit</artifactId>
60+
<groupId>org.junit.jupiter</groupId>
61+
<artifactId>junit-jupiter</artifactId>
62+
<scope>test</scope>
63+
</dependency>
64+
<dependency>
65+
<groupId>org.junit.jupiter</groupId>
66+
<artifactId>junit-jupiter-api</artifactId>
6267
<scope>test</scope>
6368
</dependency>
6469

afterburner/src/test/java/module-info.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212

1313
// Additional test lib/framework dependencies
1414

15-
requires junit; // JUnit4 To Be Removed in future
15+
requires org.junit.jupiter.api;
16+
requires org.junit.jupiter.params;
1617

1718
// Other test dependencies
1819
requires java.xml;

afterburner/src/test/java/tools/jackson/module/afterburner/AfterburnerModuleJDKSerializabilityTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
import tools.jackson.databind.ObjectMapper;
66

7+
import static org.junit.jupiter.api.Assertions.*;
8+
79
public class AfterburnerModuleJDKSerializabilityTest extends AfterburnerTestBase
810
{
911
static class Point {

afterburner/src/test/java/tools/jackson/module/afterburner/AfterburnerTestBase.java

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111
import tools.jackson.databind.json.JsonMapper;
1212
import tools.jackson.module.afterburner.testutil.NoCheckSubTypeValidator;
1313

14-
public abstract class AfterburnerTestBase extends junit.framework.TestCase
14+
import static org.junit.jupiter.api.Assertions.fail;
15+
import static org.junit.jupiter.api.Assertions.assertEquals;
16+
17+
public abstract class AfterburnerTestBase
1518
{
1619
// // // First some "shared" classes from databind's `BaseMapTest`
1720

@@ -213,16 +216,6 @@ protected static JsonMapper newVanillaJSONMapper() {
213216
return new JsonMapper();
214217
}
215218

216-
// to deprecate
217-
protected static JsonMapper newObjectMapper() {
218-
return mapperBuilder().build();
219-
}
220-
221-
// to deprecate
222-
protected static JsonMapper.Builder mapperBuilder() {
223-
return afterburnerMapperBuilder();
224-
}
225-
226219
/*
227220
/**********************************************************
228221
/* Helper methods; assertions
@@ -257,7 +250,7 @@ protected void assertType(Object ob, Class<?> expType)
257250
* available methods, and ensures results are consistent, before
258251
* returning them
259252
*/
260-
protected String getAndVerifyText(JsonParser p) throws IOException
253+
protected String getAndVerifyText(JsonParser p)
261254
{
262255
// Ok, let's verify other accessors
263256
int actLen = p.getStringLength();

afterburner/src/test/java/tools/jackson/module/afterburner/TestAccessFallback.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
package tools.jackson.module.afterburner;
22

3+
import org.junit.jupiter.api.Test;
4+
35
import tools.jackson.databind.ObjectMapper;
46

7+
import static org.junit.jupiter.api.Assertions.*;
8+
59
public class TestAccessFallback extends AfterburnerTestBase
610
{
711
@SuppressWarnings("serial")
@@ -50,6 +54,7 @@ public String getE()
5054

5155
private static final String BEAN_JSON = "{\"e\":\"a\"}";
5256

57+
@Test
5358
public void testSerializeAccess() throws Exception
5459
{
5560
ObjectMapper abMapper = newAfterburnerMapper();
@@ -59,6 +64,7 @@ public void testSerializeAccess() throws Exception
5964
assertEquals(BEAN_JSON, abMapper.writeValueAsString(new MyBean("a")));
6065
}
6166

67+
@Test
6268
public void testDeserializeAccess() throws Exception
6369
{
6470
ObjectMapper abMapper = newAfterburnerMapper();

afterburner/src/test/java/tools/jackson/module/afterburner/TestSealedPackages.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
11
package tools.jackson.module.afterburner;
22

3+
import org.junit.jupiter.api.Test;
4+
35
import tools.jackson.databind.ObjectMapper;
46

7+
import static org.junit.jupiter.api.Assertions.assertNotNull;
8+
59
/**
610
* Tests for [Issue#21]
711
*/
812
public class TestSealedPackages extends AfterburnerTestBase
913
{
1014
private final ObjectMapper MAPPER = newAfterburnerMapper();
1115

16+
@Test
1217
public void testJavaStdDeserialization() throws Exception
1318
{
1419
String json = "{}";
1520
Exception e = MAPPER.readValue(json, Exception.class);
1621
assertNotNull(e);
1722
}
1823

24+
@Test
1925
public void testJavaStdSerialization() throws Exception
2026
{
2127
String json = MAPPER.writeValueAsString(Thread.currentThread().getThreadGroup());

afterburner/src/test/java/tools/jackson/module/afterburner/TestUnwrapped.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
package tools.jackson.module.afterburner;
22

3+
import org.junit.jupiter.api.Test;
4+
35
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
46
import com.fasterxml.jackson.annotation.JsonUnwrapped;
7+
58
import tools.jackson.databind.ObjectMapper;
69

10+
import static org.junit.jupiter.api.Assertions.assertEquals;
11+
import static org.junit.jupiter.api.Assertions.assertNotNull;
12+
713
public class TestUnwrapped extends AfterburnerTestBase
814
{
915
@JsonPropertyOrder({ "a", "b" })
@@ -34,6 +40,7 @@ public Unwrapped() { }
3440
/**********************************************************
3541
*/
3642

43+
@Test
3744
public void testSimpleSerialize() throws Exception
3845
{
3946
final ObjectMapper VANILLA = new ObjectMapper();
@@ -43,6 +50,7 @@ public void testSimpleSerialize() throws Exception
4350
assertEquals(json, BURNER.writeValueAsString(input));
4451
}
4552

53+
@Test
4654
public void testUnwrappedDeserialize() throws Exception
4755
{
4856
final ObjectMapper VANILLA = new ObjectMapper();
@@ -53,5 +61,4 @@ public void testUnwrappedDeserialize() throws Exception
5361
assertNotNull(out.b);
5462
assertEquals(9, out.b.value);
5563
}
56-
5764
}

afterburner/src/test/java/tools/jackson/module/afterburner/TestVersions.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,31 @@
22

33
import java.io.*;
44

5+
import org.junit.jupiter.api.Test;
6+
57
import tools.jackson.core.Version;
68
import tools.jackson.core.Versioned;
79

10+
import static org.junit.jupiter.api.Assertions.assertEquals;
11+
import static org.junit.jupiter.api.Assertions.assertFalse;
12+
813
/**
914
* Tests to verify that version information is properly accessible
1015
*/
1116
public class TestVersions extends AfterburnerTestBase
1217
{
18+
@Test
1319
public void testMapperVersions() throws IOException
1420
{
1521
AfterburnerModule module = new AfterburnerModule();
1622
assertVersion(module);
1723
}
1824

19-
/*
20-
/**********************************************************
21-
/* Helper methods
22-
/**********************************************************
23-
*/
24-
2525
private void assertVersion(Versioned vers)
2626
{
2727
Version v = vers.version();
28-
assertFalse("Should find version information (got "+v+")", v.isUnknownVersion());
28+
assertFalse(v.isUnknownVersion(),
29+
"Should find version information (got "+v+")");
2930
Version exp = PackageVersion.VERSION;
3031
assertEquals(exp.toFullString(), v.toFullString());
3132
assertEquals(exp, v);

afterburner/src/test/java/tools/jackson/module/afterburner/codegen/GenerateWithMixinsTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
package tools.jackson.module.afterburner.codegen;
22

3+
import org.junit.jupiter.api.Test;
4+
35
import com.fasterxml.jackson.annotation.JsonIgnore;
46
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
57

68
import tools.jackson.databind.ObjectMapper;
79
import tools.jackson.databind.cfg.MapperBuilder;
810
import tools.jackson.module.afterburner.AfterburnerTestBase;
911

12+
import static org.junit.jupiter.api.Assertions.assertEquals;
13+
1014
// for [afterburner#51], where re-generation of classes does not work
1115
// as expected
1216
public class GenerateWithMixinsTest extends AfterburnerTestBase
@@ -48,11 +52,12 @@ public void setField3(byte[] field3) {
4852
}
4953
}
5054

51-
public abstract class IgnoreField3MixIn {
55+
public abstract static class IgnoreField3MixIn {
5256
@JsonIgnore
5357
public abstract byte[] getField3();
5458
}
5559

60+
@Test
5661
public void testIssue51() throws Exception
5762
{
5863
_testIssue51(afterburnerMapperBuilder());

afterburner/src/test/java/tools/jackson/module/afterburner/deser/BasicDeserializeTest.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@
22

33
import java.util.List;
44

5+
import org.junit.jupiter.api.Test;
6+
57
import com.fasterxml.jackson.annotation.JsonProperty;
68
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
79

810
import tools.jackson.databind.ObjectMapper;
911
import tools.jackson.module.afterburner.AfterburnerTestBase;
1012

13+
import static org.junit.jupiter.api.Assertions.*;
14+
1115
public class BasicDeserializeTest extends AfterburnerTestBase
1216
{
1317
public enum MyEnum {
@@ -168,12 +172,14 @@ public Model123 setValue(int value) {
168172
*/
169173

170174
private final ObjectMapper MAPPER = newAfterburnerMapper();
171-
175+
176+
@Test
172177
public void testIntMethod() throws Exception {
173178
IntBean bean = MAPPER.readValue("{\"x\":13}", IntBean.class);
174179
assertEquals(13, bean._x);
175180
}
176181

182+
@Test
177183
public void testMultiIntMethod() throws Exception {
178184
IntsBean bean = MAPPER.readValue("{\"c\":3,\"a\":9,\"b\":111,\"e\":-9999,\"d\":1}", IntsBean.class);
179185
assertEquals(9, bean._a);
@@ -183,16 +189,19 @@ public void testMultiIntMethod() throws Exception {
183189
assertEquals(-9999, bean._e);
184190
}
185191

192+
@Test
186193
public void testLongMethod() throws Exception {
187194
LongBean bean = MAPPER.readValue("{\"x\":-1}", LongBean.class);
188195
assertEquals(-1, bean._x);
189196
}
190197

198+
@Test
191199
public void testStringMethod() throws Exception {
192200
StringBean bean = MAPPER.readValue("{\"x\":\"zoobar\"}", StringBean.class);
193201
assertEquals("zoobar", bean._x);
194202
}
195203

204+
@Test
196205
public void testObjectMethod() throws Exception {
197206
EnumBean bean = MAPPER.readValue("{\"x\":\"A\"}", EnumBean.class);
198207
assertEquals(MyEnum.A, bean._x);
@@ -204,16 +213,19 @@ public void testObjectMethod() throws Exception {
204213
/**********************************************************************
205214
*/
206215

216+
@Test
207217
public void testIntField() throws Exception {
208218
IntFieldBean bean = MAPPER.readValue("{\"value\":-92}", IntFieldBean.class);
209219
assertEquals(-92, bean.x);
210220
}
211221

222+
@Test
212223
public void testLongField() throws Exception {
213224
LongFieldBean bean = MAPPER.readValue("{\"value\":-92}", LongFieldBean.class);
214225
assertEquals(-92, bean.value);
215226
}
216227

228+
@Test
217229
public void testStringField() throws Exception {
218230
StringFieldBean bean = MAPPER.readValue("{\"x\":\"\"}", StringFieldBean.class);
219231
assertEquals("", bean.x);
@@ -223,12 +235,14 @@ public void testStringField() throws Exception {
223235
assertNull(bean.x);
224236
}
225237

238+
@Test
226239
public void testEnumField() throws Exception {
227240
EnumFieldBean bean = MAPPER.readValue("{\"x\":\"C\"}", EnumFieldBean.class);
228241
assertEquals(MyEnum.C, bean.x);
229242
}
230243

231244
// Verify [Issue#10], so that nulls do not get coerced to String "null"
245+
@Test
232246
public void testStringAsObjectField() throws Exception {
233247
StringAsObject bean = MAPPER.readValue("{\"value\":null}", StringAsObject.class);
234248
assertNotNull(bean);
@@ -241,6 +255,7 @@ public void testStringAsObjectField() throws Exception {
241255
/**********************************************************************
242256
*/
243257

258+
@Test
244259
public void testFiveMinuteDoc() throws Exception
245260
{
246261
FiveMinuteUser input = new FiveMinuteUser("First", "Name", true,
@@ -253,6 +268,7 @@ public void testFiveMinuteDoc() throws Exception
253268
}
254269
}
255270

271+
@Test
256272
public void testMixed() throws Exception
257273
{
258274
MixedBean bean = MAPPER.readValue("{"
@@ -277,6 +293,7 @@ public void testMixed() throws Exception
277293
}
278294

279295
// Test for [Issue-5]
296+
@Test
280297
public void testNonVoidProperty() throws Exception
281298
{
282299
final String json = "{ \"stringField\" : \"zoobar\", \"stringField2\" : \"barzoo\" }";
@@ -292,6 +309,7 @@ public void testNonVoidProperty() throws Exception
292309
}
293310

294311
// Test for [module-afterburner#16]
312+
@Test
295313
public void testBigNonVoidProperty() throws Exception
296314
{
297315
final String json = "{ \"stringField\" : \"zoobar\" }";
@@ -306,12 +324,14 @@ public void testBigNonVoidProperty() throws Exception
306324
}
307325

308326
// NOTE: failed with databind-2.5.0; fixed for 2.5.1
327+
@Test
309328
public void testStringBuilder() throws Exception
310329
{
311330
StringBuilder sb = MAPPER.readValue(quote("foobar"), StringBuilder.class);
312331
assertEquals("foobar", sb.toString());
313332
}
314333

334+
@Test
315335
public void testBooleans() throws Exception
316336
{
317337
BooleansBean bean = MAPPER.readValue(aposToQuotes("{'a':true, 'b':true}"),
@@ -322,6 +342,7 @@ public void testBooleans() throws Exception
322342
}
323343

324344
// for [module-afterburner#60] (caused by a bug in jackson-core up to 2.6.2, fixed in 2.6.3)
345+
@Test
325346
public void testProblemWithIndentation() throws Exception {
326347
final String JSON = "{\n"
327348
+" \"foos\" :\n"
@@ -344,6 +365,7 @@ public void testProblemWithIndentation() throws Exception {
344365
}
345366

346367
// [modules-base#123]
368+
@Test
347369
public void testFluentMethod() throws Exception
348370
{
349371
String json = MAPPER.writeValueAsString(new Model123(28));

0 commit comments

Comments
 (0)