Skip to content

Commit c702930

Browse files
authored
[ JSTEP-10 ] Migrate csv module tests to JUnit 5 (#525)
1 parent 9359af8 commit c702930

File tree

76 files changed

+669
-240
lines changed

Some content is hidden

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

76 files changed

+669
-240
lines changed

csv/src/test/java/com/fasterxml/jackson/dataformat/csv/CSVFactoryFeaturesTest.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
package com.fasterxml.jackson.dataformat.csv;
22

3+
import java.io.StringReader;
4+
import java.io.StringWriter;
5+
6+
import org.junit.jupiter.api.Test;
7+
38
import com.fasterxml.jackson.core.StreamReadFeature;
49
import com.fasterxml.jackson.core.StreamWriteFeature;
510

6-
import java.io.StringReader;
7-
import java.io.StringWriter;
11+
import static org.junit.jupiter.api.Assertions.assertFalse;
12+
import static org.junit.jupiter.api.Assertions.assertTrue;
13+
814

915
public class CSVFactoryFeaturesTest extends ModuleTestBase
1016
{
17+
@Test
1118
public void testFactoryFeatures() throws Exception
1219
{
1320
CsvFactory f = new CsvFactory();
@@ -31,6 +38,7 @@ public void testFactoryFeatures() throws Exception
3138
g.close();
3239
}
3340

41+
@Test
3442
public void testFactoryFastFeatures() throws Exception
3543
{
3644
CsvFactory f = new CsvFactory();
@@ -46,6 +54,7 @@ public void testFactoryFastFeatures() throws Exception
4654
assertTrue(generator.isEnabled(StreamWriteFeature.USE_FAST_DOUBLE_WRITER));
4755
}
4856

57+
@Test
4958
public void testFactoryFastBigNumberFeature() throws Exception
5059
{
5160
CsvFactory f = new CsvFactory();
@@ -57,6 +66,7 @@ public void testFactoryFastBigNumberFeature() throws Exception
5766
assertTrue(parser.isEnabled(StreamReadFeature.USE_FAST_BIG_NUMBER_PARSER));
5867
}
5968

69+
@Test
6070
public void testFactoryBuilderFastFeatures() throws Exception
6171
{
6272
CsvFactory f = CsvFactory.builder()
@@ -73,6 +83,7 @@ public void testFactoryBuilderFastFeatures() throws Exception
7383
assertTrue(generator.isEnabled(StreamWriteFeature.USE_FAST_DOUBLE_WRITER));
7484
}
7585

86+
@Test
7687
public void testFactoryBuilderFastBigNumberFeature() throws Exception
7788
{
7889
CsvFactory f = CsvFactory.builder()

csv/src/test/java/com/fasterxml/jackson/dataformat/csv/ModuleTestBase.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
package com.fasterxml.jackson.dataformat.csv;
22

3-
import java.io.ByteArrayOutputStream;
4-
import java.io.IOException;
5-
import java.io.InputStream;
3+
import java.io.*;
64
import java.nio.charset.StandardCharsets;
7-
import java.util.Arrays;
8-
import java.util.LinkedHashMap;
9-
import java.util.List;
10-
import java.util.Locale;
11-
import java.util.Map;
5+
import java.util.*;
126

13-
import com.fasterxml.jackson.core.*;
147
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
8+
import com.fasterxml.jackson.core.*;
159

16-
public abstract class ModuleTestBase extends junit.framework.TestCase
10+
import static org.junit.jupiter.api.Assertions.assertEquals;
11+
import static org.junit.jupiter.api.Assertions.fail;
12+
13+
public abstract class ModuleTestBase
1714
{
1815
public enum Gender { MALE, FEMALE };
1916

@@ -332,4 +329,5 @@ protected byte[] readResource(String ref)
332329
}
333330
return bytes.toByteArray();
334331
}
332+
335333
}

csv/src/test/java/com/fasterxml/jackson/dataformat/csv/NullReader122Test.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
package com.fasterxml.jackson.dataformat.csv;
22

3-
import java.io.*;
3+
import java.io.Reader;
44
import java.util.Map;
55

6+
import org.junit.jupiter.api.Test;
7+
68
import com.fasterxml.jackson.databind.ObjectReader;
79

10+
import static org.junit.jupiter.api.Assertions.fail;
11+
12+
813
public class NullReader122Test extends ModuleTestBase
914
{
1015
private final CsvMapper MAPPER = mapperForCsv();
1116

1217
// for [dataformats-text#122]: passing `null` Reader leads to infinite loop
18+
@Test
1319
public void testEmptyStream() throws Exception {
1420
CsvSchema columns = CsvSchema.emptySchema().withHeader().withColumnSeparator(';');
1521
ObjectReader r = MAPPER.readerFor(Map.class).with(columns);

csv/src/test/java/com/fasterxml/jackson/dataformat/csv/SchemaCaching288Test.java

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

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

8+
import static org.junit.jupiter.api.Assertions.assertEquals;
9+
10+
611
public class SchemaCaching288Test extends ModuleTestBase
712
{
813
static class ViewA { }
@@ -28,6 +33,7 @@ static class Bean288
2833
*/
2934

3035
// [dataformats-text#288]: caching should not overlap with View
36+
@Test
3137
public void testCachingNoViewFirst() throws Exception
3238
{
3339
CsvMapper mapper1 = mapperForCsv();
@@ -52,6 +58,7 @@ public void testCachingNoViewFirst() throws Exception
5258
}
5359

5460
// [dataformats-text#288]: caching should not overlap with View
61+
@Test
5562
public void testCachingWithViewFirst() throws Exception
5663
{
5764
CsvMapper mapper1 = mapperForCsv();

csv/src/test/java/com/fasterxml/jackson/dataformat/csv/TestVersions.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
package com.fasterxml.jackson.dataformat.csv;
22

3-
import java.io.*;
3+
import java.io.ByteArrayOutputStream;
4+
import java.io.IOException;
45

5-
import com.fasterxml.jackson.core.*;
6+
import org.junit.jupiter.api.Test;
7+
8+
import com.fasterxml.jackson.core.Versioned;
69
import com.fasterxml.jackson.databind.MapperFeature;
710

11+
import static org.junit.jupiter.api.Assertions.*;
12+
813
public class TestVersions extends ModuleTestBase
914
{
15+
@Test
1016
public void testMapperVersions() throws IOException
1117
{
1218
CsvFactory f = new CsvFactory();
@@ -20,6 +26,7 @@ public void testMapperVersions() throws IOException
2026
}
2127

2228
// Mostly to verify #11
29+
@Test
2330
public void testMapperDefaults()
2431
{
2532
CsvMapper mapper = new CsvMapper();
@@ -28,6 +35,7 @@ public void testMapperDefaults()
2835

2936
// Also, not strictly related to version but...
3037

38+
@Test
3139
public void testMapperCopy()
3240
{
3341
CsvMapper mapper = new CsvMapper();

csv/src/test/java/com/fasterxml/jackson/dataformat/csv/deser/AnySetterTest.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
package com.fasterxml.jackson.dataformat.csv.deser;
22

3-
import java.util.*;
3+
import java.util.LinkedHashMap;
4+
import java.util.Map;
5+
6+
import org.junit.jupiter.api.Test;
47

58
import com.fasterxml.jackson.annotation.JsonAnySetter;
69
import com.fasterxml.jackson.dataformat.csv.*;
710

11+
import static org.junit.jupiter.api.Assertions.assertEquals;
12+
813
public class AnySetterTest extends ModuleTestBase
914
{
1015
static class Entry {
@@ -29,6 +34,7 @@ public void set(String key, Object value) {
2934
/**********************************************************************
3035
*/
3136

37+
@Test
3238
public void testSimpleHeader() throws Exception
3339
{
3440
CsvMapper mapper = mapperForCsv();
@@ -42,6 +48,7 @@ public void testSimpleHeader() throws Exception
4248
}
4349

4450
// [dataformat-csv@109]: allow "any-setter-like"
51+
@Test
4552
public void testWithMapToAny() throws Exception
4653
{
4754
CsvMapper mapper = mapperForCsv();

csv/src/test/java/com/fasterxml/jackson/dataformat/csv/deser/ArrayReadTest.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package com.fasterxml.jackson.dataformat.csv.deser;
22

3-
import com.fasterxml.jackson.annotation.JsonCreator;
4-
import com.fasterxml.jackson.annotation.JsonProperty;
5-
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
3+
import org.junit.jupiter.api.Test;
64

5+
import com.fasterxml.jackson.annotation.*;
76
import com.fasterxml.jackson.dataformat.csv.*;
87

8+
import static org.junit.jupiter.api.Assertions.assertEquals;
9+
import static org.junit.jupiter.api.Assertions.assertNotNull;
10+
911
// for [dataformat-csv#57]
1012
public class ArrayReadTest extends ModuleTestBase
1113
{
@@ -32,6 +34,7 @@ public ValueEntry(@JsonProperty("id") String id,
3234

3335
private final CsvMapper MAPPER = mapperForCsv();
3436

37+
@Test
3538
public void testSimpleExplicitLooseTyping() throws Exception
3639
{
3740
ValueEntry value = MAPPER.readerWithSchemaFor(ValueEntry.class)
@@ -48,6 +51,7 @@ public void testSimpleExplicitLooseTyping() throws Exception
4851
}
4952

5053
// Same as above, but Array value in double-quotes:
54+
@Test
5155
public void testSimpleExplicitLooseTypingWithQuotes() throws Exception
5256
{
5357
ValueEntry value = MAPPER.readerWithSchemaFor(ValueEntry.class)
@@ -63,6 +67,7 @@ public void testSimpleExplicitLooseTypingWithQuotes() throws Exception
6367
assertEquals(3, v[2]);
6468
}
6569

70+
@Test
6671
public void testSimpleExplicitStrictTyping() throws Exception
6772
{
6873
ValueEntry value = MAPPER.readerWithTypedSchemaFor(ValueEntry.class)
@@ -88,6 +93,7 @@ public void testSimpleExplicitStrictTyping() throws Exception
8893
assertEquals(0, v.length);
8994
}
9095

96+
@Test
9197
public void testSeparatorOverrideSpace() throws Exception
9298
{
9399
ValueEntry input = new ValueEntry("foo", "stuff", new int[] {1, 2, 3});
@@ -113,6 +119,7 @@ public void testSeparatorOverrideSpace() throws Exception
113119
assertEquals(3, v[2]);
114120
}
115121

122+
@Test
116123
public void testSeparatorOverrideMulti() throws Exception
117124
{
118125
ValueEntry input = new ValueEntry("foo", "stuff", new int[] {1, 2, 3});

0 commit comments

Comments
 (0)