Skip to content

Commit da88512

Browse files
committed
Migrate remaining
1 parent 4c245fa commit da88512

File tree

9 files changed

+49
-40
lines changed

9 files changed

+49
-40
lines changed

cbor/src/test/java/com/fasterxml/jackson/dataformat/cbor/gen/GeneratorBinaryTest.java

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,39 @@
44
import java.security.NoSuchAlgorithmException;
55
import java.security.SecureRandom;
66

7-
import org.junit.*;
7+
import org.junit.jupiter.api.BeforeEach;
88
import org.junit.jupiter.api.Test;
9-
import org.junit.rules.TemporaryFolder;
9+
import org.junit.jupiter.api.io.TempDir;
1010

1111
import com.fasterxml.jackson.core.JsonGenerator;
1212
import com.fasterxml.jackson.dataformat.cbor.CBORFactory;
1313
import com.fasterxml.jackson.dataformat.cbor.CBORParser;
1414

15+
import static org.junit.jupiter.api.Assertions.assertEquals;
16+
1517
public class GeneratorBinaryTest //extends CBORTestBase
1618
{
1719
final static int SMALL_LENGTH = 100;
1820
final static int LARGE_LENGTH = /*CBORGenerator.BYTE_BUFFER_FOR_OUTPUT*/ 16000 + 500;
1921

20-
@Rule
21-
public TemporaryFolder tempFolder = new TemporaryFolder();
22+
@TempDir
23+
public File tempFolder;
2224

2325
private File binaryInputFile;
2426
private File cborFile;
2527
private File binaryOutputFile;
2628

27-
@Before
29+
@BeforeEach
2830
public void before() throws IOException
2931
{
30-
binaryInputFile = tempFolder.newFile("sourceData.bin");
31-
cborFile = tempFolder.newFile("cbor.bin");
32-
binaryOutputFile = tempFolder.newFile("outputData.bin");
32+
binaryInputFile = new File(tempFolder, "sourceData.bin");
33+
binaryInputFile.createNewFile();
34+
35+
cborFile = new File(tempFolder, "cbor.bin");
36+
cborFile.createNewFile();
37+
38+
binaryOutputFile = new File(tempFolder, "outputData.bin");
39+
binaryOutputFile.createNewFile();
3340
}
3441

3542
@Test
@@ -100,12 +107,12 @@ private void assertFileEquals(File file1, File file2) throws IOException
100107
FileInputStream fis1 = new FileInputStream(file1);
101108
FileInputStream fis2 = new FileInputStream(file2);
102109

103-
Assert.assertEquals(file1.length(), file2.length());
110+
assertEquals(file1.length(), file2.length());
104111

105112
int ch;
106113

107114
while ((ch = fis1.read()) >= 0) {
108-
Assert.assertEquals(ch, fis2.read());
115+
assertEquals(ch, fis2.read());
109116
}
110117
fis1.close();
111118
fis2.close();

cbor/src/test/java/com/fasterxml/jackson/dataformat/cbor/gen/GeneratorSimpleTest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import java.util.LinkedHashMap;
77
import java.util.Map;
88

9-
import org.junit.Assert;
109
import org.junit.jupiter.api.Test;
1110

1211
import com.fasterxml.jackson.core.JsonGenerationException;
@@ -257,7 +256,7 @@ public void testBigDecimalValues() throws Exception
257256
0x19, 0x6a, (byte) 0xb3 // int 27315
258257
};
259258
assertEquals(spec.length, b.length);
260-
Assert.assertArrayEquals(spec, b);
259+
assertArrayEquals(spec, b);
261260
}
262261

263262
@Test
@@ -444,7 +443,7 @@ public void testCopyCurrentEventWithTag() throws Exception {
444443

445444
// copyCurrentEvent doesn't preserve fixed arrays, so we can't
446445
// compare with the source bytes.
447-
Assert.assertArrayEquals(new byte[] {
446+
assertArrayEquals(new byte[] {
448447
CBORConstants.BYTE_TAG_DECIMAL_FRACTION,
449448
CBORConstants.BYTE_ARRAY_2_ELEMENTS,
450449
0,
@@ -470,7 +469,7 @@ public void testCopyCurrentStructureWithTaggedArray() throws Exception {
470469

471470
// copyCurrentEvent doesn't preserve fixed arrays, so we can't
472471
// compare with the source bytes.
473-
Assert.assertArrayEquals(new byte[] {
472+
assertArrayEquals(new byte[] {
474473
CBORConstants.BYTE_TAG_DECIMAL_FRACTION,
475474
CBORConstants.BYTE_ARRAY_2_ELEMENTS,
476475
0,
@@ -495,7 +494,7 @@ public void testCopyCurrentStructureWithTaggedBinary() throws Exception {
495494
gen.close();
496495
cborParser.close();
497496

498-
Assert.assertArrayEquals(
497+
assertArrayEquals(
499498
sourceBytes.toByteArray(),
500499
targetBytes.toByteArray());
501500
}

cbor/src/test/java/com/fasterxml/jackson/dataformat/cbor/mapper/BiggerDataTest.java

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

33
import java.util.*;
44

5+
import org.junit.jupiter.api.Test;
6+
57
import com.fasterxml.jackson.databind.ObjectMapper;
68
import com.fasterxml.jackson.dataformat.cbor.CBORGenerator;
79
import com.fasterxml.jackson.dataformat.cbor.CBORTestBase;
@@ -85,6 +87,7 @@ static class Area {
8587

8688
final ObjectMapper MAPPER = new ObjectMapper();
8789

90+
@Test
8891
public void testReading() throws Exception
8992
{
9093
Citm citm0 = MAPPER.readValue(getClass().getResourceAsStream("/data/citm_catalog.json"),
@@ -115,6 +118,7 @@ public void testReading() throws Exception
115118
assertEquals(1, citm.venueNames.size());
116119
}
117120

121+
@Test
118122
public void testRoundTrip() throws Exception
119123
{
120124
Citm citm0 = MAPPER.readValue(getClass().getResourceAsStream("/data/citm_catalog.json"),
@@ -143,6 +147,7 @@ public void testRoundTrip() throws Exception
143147
assertEquals(citm.venueNames.size(), citm2.venueNames.size());
144148
}
145149

150+
@Test
146151
public void testRoundTripStringref() throws Exception
147152
{
148153
Citm citm0 = MAPPER.readValue(getClass().getResourceAsStream("/data/citm_catalog.json"),

cbor/src/test/java/com/fasterxml/jackson/dataformat/cbor/mapper/BinaryReadTest.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import java.io.ByteArrayOutputStream;
44
import java.io.InputStream;
55

6-
import org.junit.Assert;
76
import org.junit.jupiter.api.Test;
87

98
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
@@ -72,9 +71,9 @@ public void testMultipleBinaryFields() throws Exception
7271
byte[] raw = MAPPER.writeValueAsBytes(input);
7372

7473
Bytes3 result = MAPPER.readValue(raw, Bytes3.class);
75-
Assert.assertArrayEquals(input.bytes1, result.bytes1);
76-
Assert.assertArrayEquals(input.bytes2, result.bytes2);
77-
Assert.assertArrayEquals(input.bytes3, result.bytes3);
74+
assertArrayEquals(input.bytes1, result.bytes1);
75+
assertArrayEquals(input.bytes2, result.bytes2);
76+
assertArrayEquals(input.bytes3, result.bytes3);
7877
}
7978

8079
public void _testBinary(int size) throws Exception
@@ -88,14 +87,14 @@ public void _testBinary(int size) throws Exception
8887
byte[] raw = MAPPER.writeValueAsBytes(input);
8988
byte[] b2 = MAPPER.readValue(raw, byte[].class);
9089
assertNotNull(b2);
91-
Assert.assertArrayEquals(input, b2);
90+
assertArrayEquals(input, b2);
9291

9392
// then as POJO member
9493
raw = MAPPER.writeValueAsBytes(new Bytes(input));
9594
Bytes bytes = MAPPER.readValue(raw, Bytes.class);
9695
assertNotNull(bytes);
9796
assertNotNull(bytes.bytes);
98-
Assert.assertArrayEquals(input, bytes.bytes);
97+
assertArrayEquals(input, bytes.bytes);
9998

10099
// then using incremental access method
101100
raw = MAPPER.writeValueAsBytes(input);
@@ -107,7 +106,7 @@ public void _testBinary(int size) throws Exception
107106
assertEquals(input.length, p.readBinaryValue(bout));
108107
assertEquals(input.length, bout.size());
109108
b2 = bout.toByteArray();
110-
Assert.assertArrayEquals(input, b2);
109+
assertArrayEquals(input, b2);
111110
assertNull(p.nextToken());
112111
p.close();
113112
in.close();

cbor/src/test/java/com/fasterxml/jackson/dataformat/cbor/mapper/CBORMapperTest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.fasterxml.jackson.dataformat.cbor.mapper;
22

3-
import org.junit.Assert;
43
import org.junit.jupiter.api.Test;
54

65
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -37,10 +36,10 @@ public void testStreamingFeaturesViaMapper() throws Exception
3736
assertEquals(29, encodedNotMinimal.length);
3837

3938
// And then verify we can read it back, either way
40-
Assert.assertArrayEquals(minimalValues, mapperWithMinimal.readValue(encodedMinimal, Object[].class));
41-
Assert.assertArrayEquals(values, mapperWithMinimal.readValue(encodedNotMinimal, Object[].class));
42-
Assert.assertArrayEquals(minimalValues, mapperFull.readValue(encodedMinimal, Object[].class));
43-
Assert.assertArrayEquals(values, mapperFull.readValue(encodedNotMinimal, Object[].class));
39+
assertArrayEquals(minimalValues, mapperWithMinimal.readValue(encodedMinimal, Object[].class));
40+
assertArrayEquals(values, mapperWithMinimal.readValue(encodedNotMinimal, Object[].class));
41+
assertArrayEquals(minimalValues, mapperFull.readValue(encodedMinimal, Object[].class));
42+
assertArrayEquals(values, mapperFull.readValue(encodedNotMinimal, Object[].class));
4443
}
4544

4645
// [databind#3212]

cbor/src/test/java/com/fasterxml/jackson/dataformat/cbor/mapper/TreeNodesTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.fasterxml.jackson.dataformat.cbor.mapper;
22

3-
import org.junit.Assert;
43
import org.junit.jupiter.api.Test;
54

65
import com.fasterxml.jackson.databind.JsonNode;
@@ -37,7 +36,7 @@ public void testSimple() throws Exception
3736
fail("Expected binary node; got "+datNode.getClass().getName());
3837
}
3938
byte[] bytes = datNode.binaryValue();
40-
Assert.assertArrayEquals(TEXT_BYTES, bytes);
39+
assertArrayEquals(TEXT_BYTES, bytes);
4140
}
4241

4342
@Test

cbor/src/test/java/com/fasterxml/jackson/dataformat/cbor/parse/CBORNumberParseTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55
import java.math.BigDecimal;
66
import java.math.BigInteger;
77

8+
import org.junit.jupiter.api.Test;
9+
810
import com.fasterxml.jackson.core.*;
911
import com.fasterxml.jackson.core.JsonParser.NumberType;
1012
import com.fasterxml.jackson.core.JsonParser.NumberTypeFP;
1113
import com.fasterxml.jackson.core.exc.StreamConstraintsException;
1214
import com.fasterxml.jackson.dataformat.cbor.*;
1315
import com.fasterxml.jackson.dataformat.cbor.testutil.ThrottledInputStream;
1416

15-
@SuppressWarnings("resource")
1617
import static org.junit.jupiter.api.Assertions.*;
1718

18-
import org.junit.jupiter.api.Test;
19-
19+
@SuppressWarnings("resource")
2020
public class CBORNumberParseTest extends CBORTestBase
2121
{
2222
private final CBORFactory CBOR_F = cborFactory();
@@ -400,8 +400,8 @@ public void testVeryBigDecimalType() throws IOException {
400400
parser.nextToken();
401401
fail("expected StreamConstraintsException");
402402
} catch (StreamConstraintsException e) {
403-
assertTrue("unexpected exception message: " + e.getMessage(),
404-
e.getMessage().startsWith("Number value length (4153) exceeds the maximum allowed"));
403+
assertTrue(e.getMessage().startsWith("Number value length (4153) exceeds the maximum allowed"),
404+
"unexpected exception message: " + e.getMessage());
405405
}
406406
}
407407
}

cbor/src/test/java/com/fasterxml/jackson/dataformat/cbor/parse/dos/DeepNestingCBORParserTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.fasterxml.jackson.dataformat.cbor.CBORFactory;
1111
import com.fasterxml.jackson.dataformat.cbor.CBORTestBase;
1212

13+
import static org.junit.jupiter.api.Assertions.assertTrue;
1314
import static org.junit.jupiter.api.Assertions.fail;
1415

1516
/**
@@ -31,8 +32,8 @@ public void testDeeplyNestedObjects() throws Exception
3132
} catch (StreamConstraintsException e) {
3233
String exceptionPrefix = String.format("Document nesting depth (%d) exceeds the maximum allowed",
3334
StreamReadConstraints.DEFAULT_MAX_DEPTH + 1);
34-
assertTrue("JsonMappingException message is as expected?",
35-
e.getMessage().startsWith(exceptionPrefix));
35+
assertTrue(e.getMessage().startsWith(exceptionPrefix),
36+
"JsonMappingException message is as expected?");
3637
}
3738
}
3839

@@ -66,8 +67,8 @@ public void testDeeplyNestedArrays() throws Exception
6667
} catch (StreamConstraintsException e) {
6768
String exceptionPrefix = String.format("Document nesting depth (%d) exceeds the maximum allowed",
6869
StreamReadConstraints.DEFAULT_MAX_DEPTH + 1);
69-
assertTrue("JsonMappingException message is as expected?",
70-
e.getMessage().startsWith(exceptionPrefix));
70+
assertTrue(e.getMessage().startsWith(exceptionPrefix),
71+
"JsonMappingException message is as expected?");
7172
}
7273
}
7374

cbor/src/test/java/com/fasterxml/jackson/dataformat/cbor/seq/ReadTreesTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ public void testReadTreeSequenceLowStringLimit() throws Exception
8989
it.nextValue();
9090
fail("expected IllegalStateException");
9191
} catch (StreamConstraintsException ise) {
92-
assertTrue("unexpected exception message: " + ise.getMessage(),
93-
ise.getMessage().startsWith("String value length (2) exceeds the maximum allowed"));
92+
assertTrue(ise.getMessage().startsWith("String value length (2) exceeds the maximum allowed"),
93+
"unexpected exception message: " + ise.getMessage());
9494
}
9595
}
9696
}

0 commit comments

Comments
 (0)