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: [email protected]

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

Reply via email to