You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "clesaec (via GitHub)" <gi...@apache.org> on 2023/08/16 08:19:02 UTC

[GitHub] [avro] clesaec opened a new pull request, #2445: AVRO-3829: [Java] Junit5

clesaec opened a new pull request, #2445:
URL: https://github.com/apache/avro/pull/2445

   <!--
   
   *Thank you very much for contributing to Apache Avro - we are happy that you want to help us improve Avro. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
   
   *Please understand that we do not do this to make contributions to Avro a hassle. In order to uphold a high standard of quality for code contributions, while at the same time managing a large number of contributions, we need contributors to prepare the contributions well, and give reviewers enough contextual information for the review. Please also understand that contributions that do not follow this guide will take longer to review and thus typically be picked up with lower priority by the community.*
   
   ## Contribution Checklist
   
     - Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/AVRO/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
     
     - Name the pull request in the form "AVRO-XXXX: [component] Title of the pull request", where *AVRO-XXXX* should be replaced by the actual issue number. 
       The *component* is optional, but can help identify the correct reviewers faster: either the language ("java", "python") or subsystem such as "build" or "doc" are good candidates.  
   
     - Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
     
     - Make sure that the change passes the automated tests. You can [build the entire project](https://github.com/apache/avro/blob/master/BUILD.md) or just the [language-specific SDK](https://avro.apache.org/project/how-to-contribute/#unit-tests).
   
     - Each pull request should address only one issue, not mix up code from multiple issues.
     
     - Each commit in the pull request has a meaningful commit message (including the JIRA id)
   
     - Every commit message references Jira issues in their subject lines. In addition, commits follow the guidelines from [How to write a good git commit message](https://chris.beams.io/posts/git-commit/)
       1. Subject is separated from body by a blank line
       1. Subject is limited to 50 characters (not including Jira issue reference)
       1. Subject does not end with a period
       1. Subject uses the imperative mood ("add", not "adding")
       1. Body wraps at 72 characters
       1. Body explains "what" and "why", not "how"
   
   -->
   
   ## What is the purpose of the change
   
   [AVRO-3829](https://issues.apache.org/jira/browse/AVRO-3829) : Finalise conversion from JUnit4 to JUnit5.
   The only tests that stay in JUnit4 are for Mojo as the harness maven plugin still use JUnit4.
   
   ## Verifying this change
   
   Same unit test should be OK
   
   
   ## Documentation
   
   - Does this pull request introduce a new feature? (no)
   - If yes, how is the feature documented? (not applicable)
   


-- 
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: dev-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [avro] opwvhk commented on a diff in pull request #2445: AVRO-3829: [Java] Junit5

Posted by "opwvhk (via GitHub)" <gi...@apache.org>.
opwvhk commented on code in PR #2445:
URL: https://github.com/apache/avro/pull/2445#discussion_r1295682727


##########
lang/java/avro/src/test/java/org/apache/avro/specific/TestSpecificRecordWithUnion.java:
##########
@@ -29,7 +29,8 @@
 import org.apache.avro.io.DatumWriter;
 import org.apache.avro.io.BinaryEncoder;
 import org.apache.avro.io.Decoder;
-import org.junit.Test;
+
+import org.junit.jupiter.api.Test;

Review Comment:
   Usually, you also rename the test methods (and remove the `public` keyword). Why not here?



-- 
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: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [avro] clesaec commented on pull request #2445: AVRO-3829: [Java] Junit5

Posted by "clesaec (via GitHub)" <gi...@apache.org>.
clesaec commented on PR #2445:
URL: https://github.com/apache/avro/pull/2445#issuecomment-1680511774

   Comments fix
   _unused parameters_: i think it's unavoidable with 
   _some about if checks on expressions that are effectively constant._ I couln't find it ?


-- 
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: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [avro] github-code-scanning[bot] commented on a diff in pull request #2445: AVRO-3829: [Java] Junit5

Posted by "github-code-scanning[bot] (via GitHub)" <gi...@apache.org>.
github-code-scanning[bot] commented on code in PR #2445:
URL: https://github.com/apache/avro/pull/2445#discussion_r1295558864


##########
lang/java/avro/src/test/java/org/apache/avro/file/TestAllCodecs.java:
##########
@@ -18,68 +18,53 @@
 
 package org.apache.avro.file;
 
-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 java.io.IOException;
 import java.nio.ByteBuffer;
-import java.util.Arrays;
-import java.util.Collection;
+import java.util.stream.Stream;
 
-import static org.junit.Assert.assertTrue;
-
-@RunWith(Parameterized.class)
 public class TestAllCodecs {
 
-  @Parameterized.Parameters(name = "{index}: codec={0}")
-  public static Collection<Object[]> data() {
-    return Arrays.asList(new Object[][] { { "bzip2", BZip2Codec.class }, { "zstandard", ZstandardCodec.class },
-        { "null", NullCodec.class }, { "xz", XZCodec.class }, { "snappy", SnappyCodec.class },
-        { "deflate", DeflateCodec.class }, });
-  }
-
-  @Parameterized.Parameter(0)
-  public String codec;
-
-  @Parameterized.Parameter(1)
-  public Class<? extends Codec> codecClass;
-
-  @Test
-  public void testCodec() throws IOException {
+  @ParameterizedTest
+  @MethodSource("codecTypes")
+  void codec(String codec, Class<? extends Codec> codecClass) throws IOException {
     int inputSize = 500_000;
 
     byte[] input = generateTestData(inputSize);
 
     Codec codecInstance = CodecFactory.fromString(codec).createInstance();
-    assertTrue(codecClass.isInstance(codecInstance));
-    assertTrue(codecInstance.getName().equals(codec));
+    Assertions.assertTrue(codecClass.isInstance(codecInstance));
+    Assertions.assertTrue(codecInstance.getName().equals(codec));
 
     ByteBuffer inputByteBuffer = ByteBuffer.wrap(input);
     ByteBuffer compressedBuffer = codecInstance.compress(inputByteBuffer);
 
     int compressedSize = compressedBuffer.remaining();
 
     // Make sure something returned
-    assertTrue(compressedSize > 0);
+    Assertions.assertTrue(compressedSize > 0);
 
     // While the compressed size could in many real cases
     // *increase* compared to the input size, our input data
     // is extremely easy to compress and all Avro's compression algorithms
     // should have a compression ratio greater than 1 (except 'null').
-    assertTrue(compressedSize < inputSize || codec.equals("null"));
+    Assertions.assertTrue(compressedSize < inputSize || codec.equals("null"));
 
     // Decompress the data
     ByteBuffer decompressedBuffer = codecInstance.decompress(compressedBuffer);
 
     // Validate the the input and output are equal.
     inputByteBuffer.rewind();
-    Assert.assertEquals(decompressedBuffer, inputByteBuffer);
+    Assertions.assertEquals(inputByteBuffer, decompressedBuffer);
   }
 
-  @Test
-  public void testCodecSlice() throws IOException {
+  @ParameterizedTest
+  @MethodSource("codecTypes")
+  void codecSlice(String codec, Class<? extends Codec> codecClass) throws IOException {

Review Comment:
   ## Useless parameter
   
   The parameter 'codecClass' is never used.
   
   [Show more details](https://github.com/apache/avro/security/code-scanning/3109)



##########
lang/java/tools/src/test/java/org/apache/avro/tool/TestRpcProtocolTool.java:
##########
@@ -86,8 +60,10 @@
 
     p2.flush();
 
-    assertEquals("Expected the simple.avpr protocol to be echoed to standout", simpleProtocol,
-        Protocol.parse(baos2.toString("UTF-8")));
+    Assertions.assertEquals(simpleProtocol, Protocol.parse(baos2.toString("UTF-8")),
+        "Expected the simple.avpr protocol to be echoed to standout");
 
+    if (receive != null)

Review Comment:
   ## Useless null check
   
   This check is useless. [receive](1) cannot be null at this check, since [new RpcReceiveTool(...)](2) always is non-null.
   
   [Show more details](https://github.com/apache/avro/security/code-scanning/3108)



##########
lang/java/avro/src/test/java/org/apache/avro/io/TestResolvingIO.java:
##########
@@ -17,47 +17,33 @@
  */
 package org.apache.avro.io;
 
+import org.apache.avro.Schema;
+import org.apache.avro.io.TestValidatingIO.Encoding;
+
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.util.Arrays;
-import java.util.Collection;
+import java.util.stream.Stream;
 
-import org.apache.avro.Schema;
-import org.apache.avro.io.TestValidatingIO.Encoding;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-
-@RunWith(Parameterized.class)
 public class TestResolvingIO {
 
-  protected final Encoding eEnc;
-  protected final int iSkipL;
-  protected final String sJsWrtSchm;
-  protected final String sWrtCls;
-  protected final String sJsRdrSchm;
-  protected final String sRdrCls;
-
-  public TestResolvingIO(Encoding encoding, int skipLevel, String jsonWriterSchema, String writerCalls,
-      String jsonReaderSchema, String readerCalls) {
-    this.eEnc = encoding;
-    this.iSkipL = skipLevel;
-    this.sJsWrtSchm = jsonWriterSchema;
-    this.sWrtCls = writerCalls;
-    this.sJsRdrSchm = jsonReaderSchema;
-    this.sRdrCls = readerCalls;
-  }
-
-  @Test
-  public void testIdentical() throws IOException {
+  @ParameterizedTest
+  @MethodSource("data2")
+  public void testIdentical(Encoding eEnc, int iSkipL, String sJsWrtSchm, String sWrtCls, String sJsRdrSchm,
+      String sRdrCls) throws IOException {

Review Comment:
   ## Useless parameter
   
   The parameter 'sRdrCls' is never used.
   
   [Show more details](https://github.com/apache/avro/security/code-scanning/3111)



##########
lang/java/avro/src/test/java/org/apache/avro/io/TestResolvingIO.java:
##########
@@ -17,47 +17,33 @@
  */
 package org.apache.avro.io;
 
+import org.apache.avro.Schema;
+import org.apache.avro.io.TestValidatingIO.Encoding;
+
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.util.Arrays;
-import java.util.Collection;
+import java.util.stream.Stream;
 
-import org.apache.avro.Schema;
-import org.apache.avro.io.TestValidatingIO.Encoding;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-
-@RunWith(Parameterized.class)
 public class TestResolvingIO {
 
-  protected final Encoding eEnc;
-  protected final int iSkipL;
-  protected final String sJsWrtSchm;
-  protected final String sWrtCls;
-  protected final String sJsRdrSchm;
-  protected final String sRdrCls;
-
-  public TestResolvingIO(Encoding encoding, int skipLevel, String jsonWriterSchema, String writerCalls,
-      String jsonReaderSchema, String readerCalls) {
-    this.eEnc = encoding;
-    this.iSkipL = skipLevel;
-    this.sJsWrtSchm = jsonWriterSchema;
-    this.sWrtCls = writerCalls;
-    this.sJsRdrSchm = jsonReaderSchema;
-    this.sRdrCls = readerCalls;
-  }
-
-  @Test
-  public void testIdentical() throws IOException {
+  @ParameterizedTest
+  @MethodSource("data2")
+  public void testIdentical(Encoding eEnc, int iSkipL, String sJsWrtSchm, String sWrtCls, String sJsRdrSchm,

Review Comment:
   ## Useless parameter
   
   The parameter 'sJsRdrSchm' is never used.
   
   [Show more details](https://github.com/apache/avro/security/code-scanning/3110)



-- 
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: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [avro] opwvhk commented on a diff in pull request #2445: AVRO-3829: [Java] Junit5

Posted by "opwvhk (via GitHub)" <gi...@apache.org>.
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: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [avro] opwvhk commented on a diff in pull request #2445: AVRO-3829: [Java] Junit5

Posted by "opwvhk (via GitHub)" <gi...@apache.org>.
opwvhk commented on code in PR #2445:
URL: https://github.com/apache/avro/pull/2445#discussion_r1295677588


##########
lang/java/avro/src/test/java/org/apache/avro/io/TestBlockingIO2.java:
##########
@@ -99,6 +89,6 @@ public static Collection<Object[]> data() {
 
         { 100, 1, "{c1sK5e10}" }, { 100, 1, "{c1sK5U1S10}" }, { 100, 1, "{c1sK5f10S10}" }, { 100, 1, "{c1sK5NS10}" },
         { 100, 1, "{c1sK5BS10}" }, { 100, 1, "{c1sK5IS10}" }, { 100, 1, "{c1sK5LS10}" }, { 100, 1, "{c1sK5FS10}" },
-        { 100, 1, "{c1sK5DS10}" }, });
+        { 100, 1, "{c1sK5DS10}" }, }).map(Arguments::of);

Review Comment:
   You're using a different strategy here than above. Both are good, but I usually prefer just one. Let's keep this however, given the number of lines that would change otherwise.



-- 
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: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [avro] clesaec merged pull request #2445: AVRO-3829: [Java] Junit5

Posted by "clesaec (via GitHub)" <gi...@apache.org>.
clesaec merged PR #2445:
URL: https://github.com/apache/avro/pull/2445


-- 
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: dev-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [avro] github-code-scanning[bot] commented on a diff in pull request #2445: AVRO-3829: [Java] Junit5

Posted by "github-code-scanning[bot] (via GitHub)" <gi...@apache.org>.
github-code-scanning[bot] commented on code in PR #2445:
URL: https://github.com/apache/avro/pull/2445#discussion_r1295820065


##########
lang/java/avro/src/test/java/org/apache/avro/io/TestResolvingIO.java:
##########
@@ -17,48 +17,34 @@
  */
 package org.apache.avro.io;
 
+import org.apache.avro.Schema;
+import org.apache.avro.io.TestValidatingIO.Encoding;
+
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.util.Arrays;
-import java.util.Collection;
+import java.util.stream.Stream;
 
-import org.apache.avro.Schema;
-import org.apache.avro.io.TestValidatingIO.Encoding;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-
-@RunWith(Parameterized.class)
 public class TestResolvingIO {
 
-  protected final Encoding eEnc;
-  protected final int iSkipL;
-  protected final String sJsWrtSchm;
-  protected final String sWrtCls;
-  protected final String sJsRdrSchm;
-  protected final String sRdrCls;
-
-  public TestResolvingIO(Encoding encoding, int skipLevel, String jsonWriterSchema, String writerCalls,
-      String jsonReaderSchema, String readerCalls) {
-    this.eEnc = encoding;
-    this.iSkipL = skipLevel;
-    this.sJsWrtSchm = jsonWriterSchema;
-    this.sWrtCls = writerCalls;
-    this.sJsRdrSchm = jsonReaderSchema;
-    this.sRdrCls = readerCalls;
-  }
-
-  @Test
-  public void testIdentical() throws IOException {
-    performTest(eEnc, iSkipL, sJsWrtSchm, sWrtCls, sJsWrtSchm, sWrtCls);
+  @ParameterizedTest
+  @MethodSource("data2")
+  public void testIdentical(Encoding encoding, int skip, String jsonWriterSchema, String writerCalls,
+      String jsonReaderSchema, String readerCalls) throws IOException {

Review Comment:
   ## Useless parameter
   
   The parameter 'jsonReaderSchema' is never used.
   
   [Show more details](https://github.com/apache/avro/security/code-scanning/3113)



##########
lang/java/avro/src/test/java/org/apache/avro/io/TestResolvingIO.java:
##########
@@ -17,48 +17,34 @@
  */
 package org.apache.avro.io;
 
+import org.apache.avro.Schema;
+import org.apache.avro.io.TestValidatingIO.Encoding;
+
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.util.Arrays;
-import java.util.Collection;
+import java.util.stream.Stream;
 
-import org.apache.avro.Schema;
-import org.apache.avro.io.TestValidatingIO.Encoding;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-
-@RunWith(Parameterized.class)
 public class TestResolvingIO {
 
-  protected final Encoding eEnc;
-  protected final int iSkipL;
-  protected final String sJsWrtSchm;
-  protected final String sWrtCls;
-  protected final String sJsRdrSchm;
-  protected final String sRdrCls;
-
-  public TestResolvingIO(Encoding encoding, int skipLevel, String jsonWriterSchema, String writerCalls,
-      String jsonReaderSchema, String readerCalls) {
-    this.eEnc = encoding;
-    this.iSkipL = skipLevel;
-    this.sJsWrtSchm = jsonWriterSchema;
-    this.sWrtCls = writerCalls;
-    this.sJsRdrSchm = jsonReaderSchema;
-    this.sRdrCls = readerCalls;
-  }
-
-  @Test
-  public void testIdentical() throws IOException {
-    performTest(eEnc, iSkipL, sJsWrtSchm, sWrtCls, sJsWrtSchm, sWrtCls);
+  @ParameterizedTest
+  @MethodSource("data2")
+  public void testIdentical(Encoding encoding, int skip, String jsonWriterSchema, String writerCalls,
+      String jsonReaderSchema, String readerCalls) throws IOException {

Review Comment:
   ## Useless parameter
   
   The parameter 'readerCalls' is never used.
   
   [Show more details](https://github.com/apache/avro/security/code-scanning/3114)



-- 
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: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [avro] opwvhk commented on a diff in pull request #2445: AVRO-3829: [Java] Junit5

Posted by "opwvhk (via GitHub)" <gi...@apache.org>.
opwvhk commented on code in PR #2445:
URL: https://github.com/apache/avro/pull/2445#discussion_r1295681133


##########
lang/java/avro/src/test/java/org/apache/avro/io/TestValidatingIO.java:
##########
@@ -507,29 +496,27 @@ private static int skip(String msg, InputScanner cs, Decoder vi, boolean isArray
     throw new RuntimeException("Don't know how to skip");
   }
 
-  @Parameterized.Parameters
-  public static Collection<Object[]> data() {
-    return Arrays.asList(convertTo2dArray(encodings, skipLevels, testSchemas()));
+  public static Stream<Arguments> data() {
+    return convertTo2dArray(encodings, skipLevels, testSchemas());
   }
 
   private static Object[][] encodings = new Object[][] { { Encoding.BINARY }, { Encoding.BLOCKING_BINARY },
       { Encoding.JSON } };
 
   private static Object[][] skipLevels = new Object[][] { { -1 }, { 0 }, { 1 }, { 2 }, };
 
-  public static Object[][] convertTo2dArray(final Object[][]... values) {
-    ArrayList<Object[]> ret = new ArrayList<>();
+  public static Stream<Arguments> convertTo2dArray(final Object[][]... values) {

Review Comment:
   Please rename (this method no longer creates an array), and remove the commented code (it's there in git, on the off chance anyone would want to look).



-- 
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: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org