opwvhk commented on code in PR #2445:
URL: https://github.com/apache/avro/pull/2445#discussion_r1295684509


##########
lang/java/trevni/core/src/test/java/org/apache/trevni/TestColumnFile.java:
##########
@@ -19,140 +19,137 @@
 
 import java.io.File;
 import java.util.Random;
-import java.util.Collection;
 import java.util.Arrays;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.HashMap;
+import java.util.stream.Stream;
 
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
 import org.junit.runners.Parameterized.Parameters;
 
-@RunWith(value = Parameterized.class)
 public class TestColumnFile {
 
   private static final File FILE = new File("target", "test.trv");
   private static final int COUNT = 1024 * 64;
 
-  private String codec;
-  private String checksum;
-
-  public TestColumnFile(String codec, String checksum) {
-    this.codec = codec;
-    this.checksum = checksum;
-  }
-
   @Parameters
-  public static Collection<Object[]> codecs() {
-    Object[][] data = new Object[][] { { "null", "null" }, { "snappy", "crc32" 
}, { "deflate", "crc32" } };
-    return Arrays.asList(data);
+  public static Stream<Arguments> codecs() {
+    return Stream.of(Arguments.of(createFileMeta("null", "null")), 
Arguments.of(createFileMeta("snappy", "crc32")),
+        Arguments.of(createFileMeta("deflate", "crc32")));
   }
 
-  private ColumnFileMetaData createFileMeta() {
+  private static ColumnFileMetaData createFileMeta(String codec, String 
checksum) {
     return new ColumnFileMetaData().setCodec(codec).setChecksum(checksum);
   }
 
-  @Test
-  public void testEmptyFile() throws Exception {
+  @ParameterizedTest
+  @MethodSource("codecs")
+  void emptyFile(ColumnFileMetaData fileMeta) throws Exception {
     FILE.delete();
-    ColumnFileWriter out = new ColumnFileWriter(createFileMeta());
+    ColumnFileWriter out = new ColumnFileWriter(fileMeta);
     out.writeTo(FILE);
     ColumnFileReader in = new ColumnFileReader(FILE);
-    Assert.assertEquals(0, in.getRowCount());
-    Assert.assertEquals(0, in.getColumnCount());
+    Assertions.assertEquals(0, in.getRowCount());
+    Assertions.assertEquals(0, in.getColumnCount());
     in.close();
   }
 
-  @Test
-  public void testEmptyColumn() throws Exception {
+  @ParameterizedTest
+  @MethodSource("codecs")
+  void emptyColumn(ColumnFileMetaData fileMeta) throws Exception {
     FILE.delete();
-    ColumnFileWriter out = new ColumnFileWriter(createFileMeta(), new 
ColumnMetaData("test", ValueType.INT));
+    ColumnFileWriter out = new ColumnFileWriter(fileMeta, new 
ColumnMetaData("test", ValueType.INT));
     out.writeTo(FILE);
     ColumnFileReader in = new ColumnFileReader(FILE);
-    Assert.assertEquals(0, in.getRowCount());
-    Assert.assertEquals(1, in.getColumnCount());
+    Assertions.assertEquals(0, in.getRowCount());
+    Assertions.assertEquals(1, in.getColumnCount());
     ColumnValues<Integer> values = in.getValues("test");
     for (int i : values)
       throw new Exception("no value should be found");
     in.close();
   }
 
-  @Test
-  public void testInts() throws Exception {
+  @ParameterizedTest
+  @MethodSource("codecs")
+  void ints(ColumnFileMetaData fileMeta) throws Exception {
     FILE.delete();
 
-    ColumnFileWriter out = new ColumnFileWriter(createFileMeta(), new 
ColumnMetaData("test", ValueType.INT));
+    ColumnFileWriter out = new ColumnFileWriter(fileMeta, new 
ColumnMetaData("test", ValueType.INT));
     Random random = TestUtil.createRandom();
     for (int i = 0; i < COUNT; i++)
       out.writeRow(TestUtil.randomLength(random));
     out.writeTo(FILE);
 
     random = TestUtil.createRandom();
     ColumnFileReader in = new ColumnFileReader(FILE);
-    Assert.assertEquals(COUNT, in.getRowCount());
-    Assert.assertEquals(1, in.getColumnCount());
+    Assertions.assertEquals(COUNT, in.getRowCount());
+    Assertions.assertEquals(1, in.getColumnCount());
     Iterator<Integer> i = in.getValues("test");
     int count = 0;
     while (i.hasNext()) {
-      Assert.assertEquals(TestUtil.randomLength(random), (int) i.next());
+      Assertions.assertEquals(TestUtil.randomLength(random), (int) i.next());
       count++;
     }
-    Assert.assertEquals(COUNT, count);
+    Assertions.assertEquals(COUNT, count);
   }
 
-  @Test
-  public void testLongs() throws Exception {
+  @ParameterizedTest
+  @MethodSource("codecs")
+  void longs(ColumnFileMetaData fileMeta) throws Exception {
     FILE.delete();
 
-    ColumnFileWriter out = new ColumnFileWriter(createFileMeta(), new 
ColumnMetaData("test", ValueType.LONG));
+    ColumnFileWriter out = new ColumnFileWriter(fileMeta, new 
ColumnMetaData("test", ValueType.LONG));
     Random random = TestUtil.createRandom();
     for (int i = 0; i < COUNT; i++)
       out.writeRow(random.nextLong());
     out.writeTo(FILE);
 
     random = TestUtil.createRandom();
     ColumnFileReader in = new ColumnFileReader(FILE);
-    Assert.assertEquals(COUNT, in.getRowCount());
-    Assert.assertEquals(1, in.getColumnCount());
+    Assertions.assertEquals(COUNT, in.getRowCount());
+    Assertions.assertEquals(1, in.getColumnCount());
     Iterator<Long> i = in.getValues("test");
     int count = 0;
     while (i.hasNext()) {
-      Assert.assertEquals(random.nextLong(), (long) i.next());
+      Assertions.assertEquals(random.nextLong(), (long) i.next());
       count++;
     }
-    Assert.assertEquals(COUNT, count);
+    Assertions.assertEquals(COUNT, count);
   }
 
-  @Test
-  public void testStrings() throws Exception {
+  @ParameterizedTest
+  @MethodSource("codecs")
+  void strings(ColumnFileMetaData fileMeta) throws Exception {

Review Comment:
   Nice!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to