Skip to content

Commit 55970d8

Browse files
committed
Migrate smile module tests to JUnit 5
1 parent 26b5e2a commit 55970d8

File tree

84 files changed

+682
-296
lines changed

Some content is hidden

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

84 files changed

+682
-296
lines changed

smile/src/test/java/com/fasterxml/jackson/dataformat/smile/BaseTestForSmile.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
package com.fasterxml.jackson.dataformat.smile;
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.util.Arrays;
85

9-
import org.junit.Assert;
10-
116
import com.fasterxml.jackson.core.*;
127
import com.fasterxml.jackson.core.io.ContentReference;
138
import com.fasterxml.jackson.core.io.IOContext;
149
import com.fasterxml.jackson.core.util.BufferRecycler;
1510
import com.fasterxml.jackson.dataformat.smile.databind.SmileMapper;
1611

12+
import static org.junit.jupiter.api.Assertions.*;
13+
1714
public abstract class BaseTestForSmile
18-
extends junit.framework.TestCase
1915
{
2016
// From JSON specification, sample doc...
2117
protected final static int SAMPLE_SPEC_VALUE_WIDTH = 800;
@@ -210,7 +206,7 @@ protected void verifyException(Throwable e, String... matches)
210206

211207
protected void _verifyBytes(byte[] actBytes, byte... expBytes)
212208
{
213-
Assert.assertArrayEquals(expBytes, actBytes);
209+
assertArrayEquals(expBytes, actBytes);
214210
}
215211

216212
/**

smile/src/test/java/com/fasterxml/jackson/dataformat/smile/FloatPrecisionTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
package com.fasterxml.jackson.dataformat.smile;
2+
23
import java.io.ByteArrayOutputStream;
34
import java.math.BigDecimal;
45

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

710
// for [jackson-core#730]
811
public class FloatPrecisionTest extends BaseTestForSmile
912
{
1013
// for [jackson-core#730]
14+
@Test
1115
public void testFloatRoundtrips() throws Exception
1216
{
1317
ByteArrayOutputStream out = new ByteArrayOutputStream();

smile/src/test/java/com/fasterxml/jackson/dataformat/smile/FormatDefaultsTest.java

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

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

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

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

smile/src/test/java/com/fasterxml/jackson/dataformat/smile/ParserInternalsTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,20 @@
22

33
import java.io.InputStream;
44

5+
import org.junit.jupiter.api.Test;
6+
57
import com.fasterxml.jackson.core.exc.StreamReadException;
68
import com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer;
79
import com.fasterxml.jackson.dataformat.smile.testutil.ThrottledInputStream;
810

11+
import static org.junit.jupiter.api.Assertions.assertEquals;
12+
import static org.junit.jupiter.api.Assertions.fail;
13+
914
public class ParserInternalsTest extends BaseTestForSmile
1015
{
1116
private final ByteQuadsCanonicalizer ROOT_SYMBOLS = ByteQuadsCanonicalizer.createRoot();
1217

18+
@Test
1319
public void testPositiveVIntGoodCases() throws Exception
1420
{
1521
// First, couple of known good cases
@@ -20,6 +26,7 @@ public void testPositiveVIntGoodCases() throws Exception
2026
});
2127
}
2228

29+
@Test
2330
public void testPositiveVIntOverflows() throws Exception
2431
{
2532
// Bad: ends at 5th, but overflows

smile/src/test/java/com/fasterxml/jackson/dataformat/smile/SmileFactoryPropertiesTest.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@
22

33
import java.io.*;
44

5+
import org.junit.jupiter.api.Test;
6+
57
import com.fasterxml.jackson.core.*;
68
import com.fasterxml.jackson.dataformat.smile.async.NonBlockingByteArrayParser;
79

8-
import static org.junit.Assert.assertArrayEquals;
10+
import static org.junit.jupiter.api.Assertions.*;
911

10-
/**
11-
* Miscellaneous tests for {@link SmileFactory}, and for some aspects
12-
* of generators and parsers it creates.
13-
*/
1412
public class SmileFactoryPropertiesTest extends BaseTestForSmile
1513
{
1614
private final static String SIMPLE_DOC_AS_JSON = "{\"simple\":[1,true,{}]}";
1715

1816
private final static SmileFactory SMILE_F = new SmileFactory();
17+
@Test
1918
public void testFactoryDefaults() {
2019
SmileFactory f = new SmileFactory();
2120

@@ -30,6 +29,7 @@ public void testFactoryDefaults() {
3029
f.isEnabled(SmileGenerator.Feature.CHECK_SHARED_STRING_VALUES));
3130
}
3231

32+
@Test
3333
public void testFactorySerializable() throws Exception
3434
{
3535
SmileFactory f = new SmileFactory();
@@ -44,6 +44,7 @@ public void testFactorySerializable() throws Exception
4444
assertArrayEquals(doc, docOut);
4545
}
4646

47+
@Test
4748
public void testFactoryCopy() throws Exception
4849
{
4950
SmileFactory f2 = SMILE_F.copy();
@@ -53,6 +54,7 @@ public void testFactoryCopy() throws Exception
5354
assertNotNull(doc);
5455
}
5556

57+
@Test
5658
public void testVersions() throws Exception
5759
{
5860
SmileFactory f = SMILE_F;
@@ -69,6 +71,7 @@ public void testVersions() throws Exception
6971
p.close();
7072
}
7173

74+
@Test
7275
public void testCapabilities() throws Exception
7376
{
7477
assertTrue(SMILE_F.canHandleBinaryNatively());
@@ -77,6 +80,7 @@ public void testCapabilities() throws Exception
7780
assertEquals(SmileGenerator.Feature.class, SMILE_F.getFormatWriteFeatureType());
7881
}
7982

83+
@Test
8084
public void testInabilityToReadChars() throws Exception
8185
{
8286
final String EXP = "for character-based";
@@ -100,6 +104,7 @@ public void testInabilityToReadChars() throws Exception
100104
}
101105
}
102106

107+
@Test
103108
public void testInabilityToWriteChars() throws Exception
104109
{
105110
try {
@@ -112,6 +117,7 @@ public void testInabilityToWriteChars() throws Exception
112117
}
113118

114119
// One lesser known feature is the ability to fall back to using JSON...
120+
@Test
115121
public void testFallbackReadFromJson() throws Exception
116122
{
117123
SmileFactory f = new SmileFactory();
@@ -122,6 +128,7 @@ public void testFallbackReadFromJson() throws Exception
122128
}
123129

124130
// One lesser known feature is the ability to fall back to using JSON...
131+
@Test
125132
public void testFallbackWriteAsJson() throws Exception
126133
{
127134
SmileFactory f = new SmileFactory();
@@ -135,6 +142,7 @@ public void testFallbackWriteAsJson() throws Exception
135142
assertEquals("[]", w.toString());
136143
}
137144

145+
@Test
138146
public void testCanonicalization() throws Exception
139147
{
140148
try (NonBlockingByteArrayParser parser = new SmileFactory()

smile/src/test/java/com/fasterxml/jackson/dataformat/smile/SmileUtilTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
package com.fasterxml.jackson.dataformat.smile;
22

3+
import org.junit.jupiter.api.Test;
4+
5+
import static org.junit.jupiter.api.Assertions.assertEquals;
6+
37
public class SmileUtilTest extends BaseTestForSmile
48
{
59
/**
610
* Verification of helper methods used to handle with zigzag encoding
711
*/
12+
@Test
813
public void testZigZagInt()
914
{
1015
// simple encode
@@ -26,6 +31,7 @@ public void testZigZagInt()
2631
assertEquals(Integer.MAX_VALUE, SmileUtil.zigzagDecode(SmileUtil.zigzagEncode(Integer.MAX_VALUE)));
2732
}
2833

34+
@Test
2935
public void testZigZagLong()
3036
{
3137
assertEquals(0L, SmileUtil.zigzagEncode(0L));

smile/src/test/java/com/fasterxml/jackson/dataformat/smile/SymbolHandlingTest.java

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

33
import java.io.IOException;
44

5+
import org.junit.jupiter.api.Test;
6+
57
import com.fasterxml.jackson.core.JsonToken;
68
import com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer;
79

8-
// Tests that have to reside in this package, due to access restrictions
10+
import static org.junit.jupiter.api.Assertions.*;
11+
912
public class SymbolHandlingTest extends BaseTestForSmile
1013
{
14+
@Test
1115
public void testSymbolTable() throws IOException
1216
{
1317
final String STR1 = "a";

smile/src/test/java/com/fasterxml/jackson/dataformat/smile/VersionsTest.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
package com.fasterxml.jackson.dataformat.smile;
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 com.fasterxml.jackson.core.Versioned;
69

7-
/**
8-
* Tests to verify [JACKSON-278]
9-
*/
10+
import static org.junit.jupiter.api.Assertions.assertEquals;
11+
1012
public class VersionsTest extends BaseTestForSmile
1113
{
14+
@Test
1215
public void testMapperVersions() throws IOException
1316
{
1417
SmileFactory f = new SmileFactory();

smile/src/test/java/com/fasterxml/jackson/dataformat/smile/async/AsyncParserNamesTest.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
package com.fasterxml.jackson.dataformat.smile.async;
22

3-
import java.io.*;
3+
import java.io.IOException;
44
import java.util.Random;
55

6-
import com.fasterxml.jackson.core.*;
6+
import org.junit.jupiter.api.Test;
7+
8+
import com.fasterxml.jackson.core.JsonToken;
79
import com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer;
810
import com.fasterxml.jackson.dataformat.smile.SmileFactory;
911

12+
import static org.junit.jupiter.api.Assertions.*;
13+
1014
public class AsyncParserNamesTest extends AsyncTestBase
1115
{
16+
@Test
1217
public void testLongNames() throws IOException
1318
{
1419
_testWithName(generateName(5000));
1520
}
1621

22+
@Test
1723
public void testEvenLongerName() throws Exception
1824
{
1925
StringBuilder nameBuf = new StringBuilder("longString");
@@ -25,6 +31,7 @@ public void testEvenLongerName() throws Exception
2531
_testWithName(name);
2632
}
2733

34+
@Test
2835
public void testSymbolTable() throws IOException
2936
{
3037
final String STR1 = "a";

smile/src/test/java/com/fasterxml/jackson/dataformat/smile/async/AsyncReaderWrapperForByteArray.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
import com.fasterxml.jackson.core.JsonToken;
77
import com.fasterxml.jackson.core.async.ByteArrayFeeder;
88

9-
/**
10-
* Helper class used with async parser
11-
*/
129
public class AsyncReaderWrapperForByteArray extends AsyncReaderWrapper
1310
{
1411
private final byte[] _doc;

0 commit comments

Comments
 (0)