Skip to content

Commit 4a6a7b4

Browse files
committed
Merge branch '2.19'
2 parents 5ad4e50 + 697797b commit 4a6a7b4

File tree

77 files changed

+653
-162
lines changed

Some content is hidden

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

77 files changed

+653
-162
lines changed

cbor/src/main/java/tools/jackson/dataformat/cbor/CBORParser.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
import java.math.BigInteger;
88
import java.nio.charset.Charset;
99
import java.nio.charset.StandardCharsets;
10-
import java.util.ArrayList;
11-
import java.util.Arrays;
12-
import java.util.Stack;
10+
import java.util.*;
1311

1412
import tools.jackson.core.*;
1513
import tools.jackson.core.base.ParserBase;

cbor/src/test/java/tools/jackson/dataformat/cbor/BrokenLongBinary186Test.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@
22

33
import java.io.ByteArrayOutputStream;
44

5+
import org.junit.jupiter.api.Test;
6+
57
import tools.jackson.core.JsonParser;
68
import tools.jackson.core.JsonToken;
79
import tools.jackson.core.exc.StreamReadException;
810

911
import tools.jackson.databind.ObjectMapper;
1012

13+
import static org.junit.jupiter.api.Assertions.assertEquals;
14+
import static org.junit.jupiter.api.Assertions.fail;
15+
1116
// Mostly for [dataformats-binary#186]: corrupt encoding indicating humongous payload
1217
public class BrokenLongBinary186Test extends CBORTestBase
1318
{
@@ -20,12 +25,14 @@ public class BrokenLongBinary186Test extends CBORTestBase
2025
*/
2126

2227
// [dataformats-binary#186]
28+
@Test
2329
public void testCorruptVeryLongBinary() throws Exception {
2430
// Let's do about 2 GB to likely trigger failure
2531
_testCorruptLong(1_999_999_999, 95000);
2632
}
2733

2834
// [dataformats-binary#186]
35+
@Test
2936
public void testCorruptQuiteLongBinary() throws Exception {
3037
// Value below limit for chunked handling
3138
_testCorruptLong(CBORParser.LONGEST_NON_CHUNKED_BINARY >> 1, 37);
@@ -51,6 +58,7 @@ private void _testCorruptLong(int allegedLength, int actualIncluded)
5158
*/
5259

5360
// [dataformats-binary#186]
61+
@Test
5462
public void testQuiteLongStreaming() throws Exception
5563
{
5664
// Can try bit shorter here, like 500 megs

cbor/src/test/java/tools/jackson/dataformat/cbor/CBORFactoryPropertiesTest.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
import java.io.*;
44

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

79
import tools.jackson.databind.ObjectMapper;
810

9-
import static org.junit.Assert.assertArrayEquals;
11+
import static org.junit.jupiter.api.Assertions.*;
1012

1113
/**
1214
* Miscellaneous tests for {@link CBORFactory}, and for some aspects
@@ -18,6 +20,7 @@ public class CBORFactoryPropertiesTest extends CBORTestBase
1820

1921
private final static CBORFactory CBOR_F = new CBORFactory();
2022

23+
@Test
2124
public void testCBORFactorySerializable() throws Exception
2225
{
2326
CBORFactory f = new CBORFactory();
@@ -32,6 +35,7 @@ public void testCBORFactorySerializable() throws Exception
3235
assertArrayEquals(doc, docOut);
3336
}
3437

38+
@Test
3539
public void testCBORFactoryCopy() throws Exception
3640
{
3741
CBORFactory f2 = CBOR_F.copy();
@@ -52,6 +56,7 @@ private byte[] cborDoc(TokenStreamFactory f, String json) throws IOException
5256
}
5357
}
5458

59+
@Test
5560
public void testVersions() throws Exception
5661
{
5762
ObjectMapper mapper = sharedMapper();
@@ -69,13 +74,15 @@ public void testVersions() throws Exception
6974
p.close();
7075
}
7176

77+
@Test
7278
public void testCapabilities() throws Exception
7379
{
7480
assertTrue(CBOR_F.canHandleBinaryNatively());
7581
assertEquals(null, CBOR_F.getFormatReadFeatureType());
7682
assertEquals(CBORWriteFeature.class, CBOR_F.getFormatWriteFeatureType());
7783
}
7884

85+
@Test
7986
public void testInabilityToReadChars() throws Exception
8087
{
8188
final String EXP = "Cannot create parser for character-based (not byte-based)";
@@ -99,6 +106,7 @@ public void testInabilityToReadChars() throws Exception
99106
}
100107
}
101108

109+
@Test
102110
public void testInabilityToWriteChars() throws Exception
103111
{
104112
try {

cbor/src/test/java/tools/jackson/dataformat/cbor/CBORTestBase.java

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
package tools.jackson.dataformat.cbor;
22

3-
import java.io.ByteArrayOutputStream;
4-
import java.io.IOException;
5-
import java.io.InputStream;
6-
import java.io.OutputStream;
3+
import java.io.*;
74
import java.nio.charset.StandardCharsets;
85
import java.util.Arrays;
96
import java.util.Random;
107

11-
import org.junit.Assert;
12-
138
import tools.jackson.core.*;
149

1510
import tools.jackson.databind.ObjectMapper;
@@ -18,8 +13,9 @@
1813

1914
import tools.jackson.dataformat.cbor.databind.CBORMapper;
2015

16+
import static org.junit.jupiter.api.Assertions.*;
17+
2118
public abstract class CBORTestBase
22-
extends junit.framework.TestCase
2319
{
2420
// From JSON specification, sample doc...
2521
protected final static int SAMPLE_SPEC_VALUE_WIDTH = 800;
@@ -228,22 +224,22 @@ protected void verifyException(Throwable e, String... matches)
228224
}
229225

230226
protected void _verifyBytes(byte[] actBytes, byte... expBytes) {
231-
Assert.assertArrayEquals(expBytes, actBytes);
227+
assertArrayEquals(expBytes, actBytes);
232228
}
233229

234230
protected void _verifyBytes(byte[] actBytes, byte exp1, byte[] expRest) {
235231
byte[] expBytes = new byte[expRest.length+1];
236232
System.arraycopy(expRest, 0, expBytes, 1, expRest.length);
237233
expBytes[0] = exp1;
238-
Assert.assertArrayEquals(expBytes, actBytes);
234+
assertArrayEquals(expBytes, actBytes);
239235
}
240236

241237
protected void _verifyBytes(byte[] actBytes, byte exp1, byte exp2, byte[] expRest) {
242238
byte[] expBytes = new byte[expRest.length+2];
243239
System.arraycopy(expRest, 0, expBytes, 2, expRest.length);
244240
expBytes[0] = exp1;
245241
expBytes[1] = exp2;
246-
Assert.assertArrayEquals(expBytes, actBytes);
242+
assertArrayEquals(expBytes, actBytes);
247243
}
248244

249245
protected void _verifyBytes(byte[] actBytes, byte exp1, byte exp2, byte exp3, byte[] expRest) {
@@ -252,7 +248,7 @@ protected void _verifyBytes(byte[] actBytes, byte exp1, byte exp2, byte exp3, by
252248
expBytes[0] = exp1;
253249
expBytes[1] = exp2;
254250
expBytes[2] = exp3;
255-
Assert.assertArrayEquals(expBytes, actBytes);
251+
assertArrayEquals(expBytes, actBytes);
256252
}
257253

258254
/**
@@ -271,7 +267,7 @@ protected String getAndVerifyText(JsonParser p) throws IOException
271267
if (str.length() != actLen) {
272268
fail("Internal problem (p.token == "+p.currentToken()+"): p.getText().length() ['"+str+"'] == "+str.length()+"; p.getTextLength() == "+actLen);
273269
}
274-
assertEquals("String access via getText(), getTextXxx() must be the same", str, str2);
270+
assertEquals(str, str2, "String access via getText(), getTextXxx() must be the same");
275271

276272
return str;
277273
}

cbor/src/test/java/tools/jackson/dataformat/cbor/FloatPrecisionTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
import java.io.ByteArrayOutputStream;
44
import java.math.BigDecimal;
55

6-
import static org.junit.Assert.assertArrayEquals;
6+
import org.junit.jupiter.api.Test;
7+
8+
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
79

810
// for [jackson-core#730]
911
public class FloatPrecisionTest extends CBORTestBase
1012
{
1113
// for [jackson-core#730]
14+
@Test
1215
public void testFloatRoundtrips() throws Exception
1316
{
1417
ByteArrayOutputStream out = new ByteArrayOutputStream();

cbor/src/test/java/tools/jackson/dataformat/cbor/FormatDefaultsTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
package tools.jackson.dataformat.cbor;
22

3+
import org.junit.jupiter.api.Test;
4+
35
import tools.jackson.core.JsonParser;
46
import tools.jackson.core.StreamReadCapability;
57
import tools.jackson.databind.ObjectMapper;
68

9+
import static org.junit.jupiter.api.Assertions.assertTrue;
10+
711
public class FormatDefaultsTest extends CBORTestBase
812
{
913
private final ObjectMapper MAPPER = cborMapper();
1014

15+
@Test
1116
public void testParserDefaults() throws Exception
1217
{
1318
try (JsonParser p = MAPPER.createParser(new byte[4])) {

cbor/src/test/java/tools/jackson/dataformat/cbor/GeneratorDeepNestingTest.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
package tools.jackson.dataformat.cbor;
22

33
import java.io.ByteArrayOutputStream;
4-
import java.util.*;
4+
import java.util.List;
5+
import java.util.Map;
6+
7+
import org.junit.jupiter.api.Test;
58

69
import tools.jackson.core.JsonGenerator;
710

811
import tools.jackson.databind.ObjectMapper;
912

1013
import tools.jackson.dataformat.cbor.databind.CBORMapper;
1114

15+
import static org.junit.jupiter.api.Assertions.assertEquals;
16+
1217
public class GeneratorDeepNestingTest extends CBORTestBase
1318
{
1419
private final ObjectMapper MAPPER = CBORMapper.shared();
1520

1621
// for [dataformats-binary#62]
1722
@SuppressWarnings("unchecked")
23+
@Test
1824
public void testDeeplyNestedMap() throws Exception
1925
{
2026
ByteArrayOutputStream out = new ByteArrayOutputStream();
@@ -62,6 +68,7 @@ private void _verifyNestedMap(Map<String,?> map, int level) {
6268
}
6369
}
6470

71+
@Test
6572
public void testDeeplyNestedArray() throws Exception
6673
{
6774
ByteArrayOutputStream out = new ByteArrayOutputStream();

cbor/src/test/java/tools/jackson/dataformat/cbor/GeneratorDupHandlingTest.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
package tools.jackson.dataformat.cbor;
22

3-
import java.io.*;
3+
import java.io.ByteArrayOutputStream;
4+
import java.io.IOException;
5+
6+
import org.junit.jupiter.api.Test;
47

58
import tools.jackson.core.*;
69
import tools.jackson.core.exc.StreamWriteException;
710

11+
import static org.junit.jupiter.api.Assertions.assertFalse;
12+
import static org.junit.jupiter.api.Assertions.fail;
13+
814
public class GeneratorDupHandlingTest extends CBORTestBase
915
{
16+
@Test
1017
public void testSimpleDupsEagerlyBytes() throws Exception {
1118
_testSimpleDups(false, new CBORFactory());
1219
}

cbor/src/test/java/tools/jackson/dataformat/cbor/GeneratorInteropTest.java

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

33
import java.io.ByteArrayOutputStream;
44

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

9+
import static org.junit.jupiter.api.Assertions.assertFalse;
10+
711
/**
812
* Unit tests geared at testing issues that were raised due to
913
* inter-operability with other CBOR codec implementations
@@ -18,6 +22,7 @@ public class GeneratorInteropTest extends CBORTestBase
1822
};
1923

2024
// Test for [Issue#6], for optional writing of CBOR Type Description Tag
25+
@Test
2126
public void testTypeDescriptionTag() throws Exception
2227
{
2328
ByteArrayOutputStream out = new ByteArrayOutputStream();
@@ -30,6 +35,7 @@ public void testTypeDescriptionTag() throws Exception
3035
_verifyBytes(out.toByteArray(), TYPE_DESC_AND_TRUE);
3136
}
3237

38+
@Test
3339
public void testAutoTypeDescription() throws Exception
3440
{
3541
ByteArrayOutputStream out = new ByteArrayOutputStream();

cbor/src/test/java/tools/jackson/dataformat/cbor/GeneratorInvalidCallsTest.java

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

55
import tools.jackson.core.exc.StreamWriteException;
66

7+
import static org.junit.jupiter.api.Assertions.fail;
8+
79
public class GeneratorInvalidCallsTest extends CBORTestBase
810
{
911
public void testInvalidFieldNameInRoot()

0 commit comments

Comments
 (0)