You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by GitBox <gi...@apache.org> on 2022/07/22 10:10:30 UTC

[GitHub] [avro] clesaec opened a new pull request, #1777: Avro-3579 junit5 step2

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

   [AVRO-3579](https://issues.apache.org/jira/browse/AVRO-3579) : migration to JUnit5 using command : 
   ```
   mvn org.openrewrite.maven:rewrite-maven-plugin:4.27.0:run \
       -Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-testing-frameworks:1.24.0 \
       -DactiveRecipes=org.openrewrite.java.testing.junit5.JUnit5BestPractices
   ```
   plus fix bugs generated by it.
   Some unit test are still in JUnit4, and will be changed in another PR.
   
   Some test, like TestSchemaValidation.testSchemaCompatibilityFailures were fixed, this one, currently in JUnit4 run only first step of the for loop (So, most of them are ignored)


-- 
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] timtebeek commented on pull request #1777: AVRO-3579: Migrate to JUnit 5

Posted by GitBox <gi...@apache.org>.
timtebeek commented on PR #1777:
URL: https://github.com/apache/avro/pull/1777#issuecomment-1230081035

   You might also want to consider running this [additional recipe to strip `test` prefix](https://docs.openrewrite.org/reference/recipes/java/testing/cleanup/removetestprefix) from test method names.
   ```
   mvn org.openrewrite.maven:rewrite-maven-plugin:4.32.0:run \
     -Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-testing-frameworks:1.26.1 \
     -DactiveRecipes=org.openrewrite.java.testing.cleanup.RemoveTestPrefix
   ```


-- 
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] timtebeek commented on pull request #1777: AVRO-3579: Migrate to JUnit 5

Posted by GitBox <gi...@apache.org>.
timtebeek commented on PR #1777:
URL: https://github.com/apache/avro/pull/1777#issuecomment-1230179647

   > Done, but with manual fixes because some tests named testHashCode, or testToString can't be renamed without "test", some tests have "extends" classes or other have explicit calls, and testStaticMethode can't be renamed to staticMethod.
   
   You're absolutely right; sorry for the inconvenience; these issues [have already been solved](https://github.com/openrewrite/rewrite-testing-frameworks/compare/v1.26.1...main#diff-50f885df1af8631f3832a02c68c3bfc51af5e903df381da9863afdf1e6009cc4R44), but we're still waiting on a new release. I expect one soon though :crossed_fingers:.


-- 
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 #1777: AVRO-3579: Migrate to JUnit 5

Posted by GitBox <gi...@apache.org>.
clesaec commented on PR #1777:
URL: https://github.com/apache/avro/pull/1777#issuecomment-1230173430

   > rewrite-maven-plugin
   Done, but with manual fixes because some tests named testHashCode, or testToString can't be renamed without "test", some tests have "extends" classes or other have explicit calls, and testStaticMethode can't be renamed to staticMethod.


-- 
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 #1777: Avro-3579 junit5 step2

Posted by GitBox <gi...@apache.org>.
github-code-scanning[bot] commented on code in PR #1777:
URL: https://github.com/apache/avro/pull/1777#discussion_r930754148


##########
lang/java/ipc-netty/src/test/java/org/apache/avro/ipc/netty/TestNettyServerWithSSL.java:
##########
@@ -27,15 +27,15 @@
 import javax.net.ssl.TrustManager;
 import javax.net.ssl.X509TrustManager;
 
-import org.junit.BeforeClass;
-
 import io.netty.handler.ssl.SslHandler;
 
+import org.junit.jupiter.api.BeforeAll;
+
 public class TestNettyServerWithSSL extends TestNettyServer {
-  public static final String TEST_CERTIFICATE = "servercert.p12";
-  public static final String TEST_CERTIFICATE_PASSWORD = "s3cret";
+  private static final String TEST_CERTIFICATE = "servercert.p12";
+  private static final String TEST_CERTIFICATE_PASSWORD = "s3cret";

Review Comment:
   ## Hard-coded credential in API call
   
   Hard-coded value flows to [sensitive API call](1).
   Hard-coded value flows to [sensitive API call](2).
   
   [Show more details](https://github.com/apache/avro/security/code-scanning/2821)



-- 
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 #1777: Avro-3579 junit5 step2

Posted by GitBox <gi...@apache.org>.
github-code-scanning[bot] commented on code in PR #1777:
URL: https://github.com/apache/avro/pull/1777#discussion_r927521168


##########
lang/java/avro/src/test/java/org/apache/avro/TestDataFileReader.java:
##########
@@ -212,23 +213,27 @@
     }
   }
 
-  @Test(expected = InvalidAvroMagicException.class)
-  public void testInvalidMagicLength() throws IOException {
-    File f = Files.createTempFile("testInvalidMagicLength", ".avro").toFile();
-    try (FileWriter w = new FileWriter(f)) {
-      w.write("-");
-    }
+  @Test
+  void testInvalidMagicLength() throws IOException {
+    assertThrows(InvalidAvroMagicException.class, () -> {
+      File f = Files.createTempFile("testInvalidMagicLength", ".avro").toFile();
+      try (FileWriter w = new FileWriter(f)) {
+        w.write("-");
+      }
 
-    DataFileReader.openReader(new SeekableFileInput(f), new GenericDatumReader<>());
+      DataFileReader.openReader(new SeekableFileInput(f), new GenericDatumReader<>());
+    });
   }
 
-  @Test(expected = InvalidAvroMagicException.class)
-  public void testInvalidMagicBytes() throws IOException {
-    File f = Files.createTempFile("testInvalidMagicBytes", ".avro").toFile();
-    try (FileWriter w = new FileWriter(f)) {
-      w.write("invalid");
-    }
+  @Test
+  void testInvalidMagicBytes() throws IOException {
+    assertThrows(InvalidAvroMagicException.class, () -> {
+      File f = Files.createTempFile("testInvalidMagicBytes", ".avro").toFile();
+      try (FileWriter w = new FileWriter(f)) {
+        w.write("invalid");
+      }
 
-    DataFileReader.openReader(new SeekableFileInput(f), new GenericDatumReader<>());
+      DataFileReader.openReader(new SeekableFileInput(f), new GenericDatumReader<>());

Review Comment:
   ## Potential input resource leak
   
   This SeekableFileInput is not always closed on method exit.
   
   [Show more details](https://github.com/apache/avro/security/code-scanning/2805)



##########
lang/java/avro/src/test/java/org/apache/avro/TestDataFileReader.java:
##########
@@ -212,23 +213,27 @@
     }
   }
 
-  @Test(expected = InvalidAvroMagicException.class)
-  public void testInvalidMagicLength() throws IOException {
-    File f = Files.createTempFile("testInvalidMagicLength", ".avro").toFile();
-    try (FileWriter w = new FileWriter(f)) {
-      w.write("-");
-    }
+  @Test
+  void testInvalidMagicLength() throws IOException {
+    assertThrows(InvalidAvroMagicException.class, () -> {
+      File f = Files.createTempFile("testInvalidMagicLength", ".avro").toFile();
+      try (FileWriter w = new FileWriter(f)) {
+        w.write("-");
+      }
 
-    DataFileReader.openReader(new SeekableFileInput(f), new GenericDatumReader<>());
+      DataFileReader.openReader(new SeekableFileInput(f), new GenericDatumReader<>());

Review Comment:
   ## Potential input resource leak
   
   This SeekableFileInput is not always closed on method exit.
   
   [Show more details](https://github.com/apache/avro/security/code-scanning/2804)



##########
lang/java/compiler/src/test/java/org/apache/avro/compiler/schema/TestSchemas.java:
##########
@@ -150,103 +160,107 @@
~      }
~    }
~
~    public String get() {
~      return sb.toString();
~    }
   }
 
   @Test
-  public void testVisit1() {
+  void testVisit1() {
     String s1 = "{\"type\": \"record\", \"name\": \"t1\", \"fields\": [" + "{\"name\": \"f1\", \"type\": \"int\"}"
         + "]}";
-    Assert.assertEquals("t1.", Schemas.visit(new Schema.Parser().parse(s1), new TestVisitor()));
+    assertEquals("t1.", Schemas.visit(new Schema.Parser().parse(s1), new TestVisitor()));
   }
 
   @Test
-  public void testVisit2() {
+  void testVisit2() {
     String s2 = "{\"type\": \"record\", \"name\": \"c1\", \"fields\": [" + "{\"name\": \"f1\", \"type\": \"int\"}"
         + "]}";
-    Assert.assertEquals("c1.\"int\"!", Schemas.visit(new Schema.Parser().parse(s2), new TestVisitor()));
+    assertEquals("c1.\"int\"!", Schemas.visit(new Schema.Parser().parse(s2), new TestVisitor()));
 
   }
 
   @Test
-  public void testVisit3() {
+  void testVisit3() {
     String s3 = "{\"type\": \"record\", \"name\": \"ss1\", \"fields\": [" + "{\"name\": \"f1\", \"type\": \"int\"}"
         + "]}";
-    Assert.assertEquals("ss1.", Schemas.visit(new Schema.Parser().parse(s3), new TestVisitor()));
+    assertEquals("ss1.", Schemas.visit(new Schema.Parser().parse(s3), new TestVisitor()));
 
   }
 
   @Test
-  public void testVisit4() {
+  void testVisit4() {
     String s4 = "{\"type\": \"record\", \"name\": \"st1\", \"fields\": [" + "{\"name\": \"f1\", \"type\": \"int\"}"
         + "]}";
-    Assert.assertEquals("st1.!", Schemas.visit(new Schema.Parser().parse(s4), new TestVisitor()));
+    assertEquals("st1.!", Schemas.visit(new Schema.Parser().parse(s4), new TestVisitor()));
 
   }
 
   @Test
-  public void testVisit5() {
+  void testVisit5() {
     String s5 = "{\"type\": \"record\", \"name\": \"c1\", \"fields\": ["
         + "{\"name\": \"f1\", \"type\": {\"type\": \"record\", \"name\": \"c2\", \"fields\": "
         + "[{\"name\": \"f11\", \"type\": \"int\"}]}}," + "{\"name\": \"f2\", \"type\": \"long\"}" + "]}";
-    Assert.assertEquals("c1.c2.\"int\"!\"long\"!", Schemas.visit(new Schema.Parser().parse(s5), new TestVisitor()));
+    assertEquals("c1.c2.\"int\"!\"long\"!", Schemas.visit(new Schema.Parser().parse(s5), new TestVisitor()));
 
   }
 
   @Test
-  public void testVisit6() {
+  void testVisit6() {
     String s6 = "{\"type\": \"record\", \"name\": \"c1\", \"fields\": ["
         + "{\"name\": \"f1\", \"type\": {\"type\": \"record\", \"name\": \"ss2\", \"fields\": "
         + "[{\"name\": \"f11\", \"type\": \"int\"}]}}," + "{\"name\": \"f2\", \"type\": \"long\"}" + "]}";
-    Assert.assertEquals("c1.ss2.!", Schemas.visit(new Schema.Parser().parse(s6), new TestVisitor()));
+    assertEquals("c1.ss2.!", Schemas.visit(new Schema.Parser().parse(s6), new TestVisitor()));
 
   }
 
   @Test
-  public void testVisit7() {
+  void testVisit7() {
     String s7 = "{\"type\": \"record\", \"name\": \"c1\", \"fields\": ["
         + "{\"name\": \"f1\", \"type\": {\"type\": \"record\", \"name\": \"css2\", \"fields\": "
         + "[{\"name\": \"f11\", \"type\": \"int\"}]}}," + "{\"name\": \"f2\", \"type\": \"long\"}" + "]}";
-    Assert.assertEquals("c1.css2.\"int\"!!", Schemas.visit(new Schema.Parser().parse(s7), new TestVisitor()));
+    assertEquals("c1.css2.\"int\"!!", Schemas.visit(new Schema.Parser().parse(s7), new TestVisitor()));
   }
 
-  @Test(expected = UnsupportedOperationException.class)
-  public void testVisit8() {
-    String s8 = "{\"type\": \"record\", \"name\": \"c1\", \"fields\": ["
-        + "{\"name\": \"f1\", \"type\": {\"type\": \"record\", \"name\": \"cst2\", \"fields\": "
-        + "[{\"name\": \"f11\", \"type\": \"int\"}]}}," + "{\"name\": \"f2\", \"type\": \"int\"}" + "]}";
-    Schemas.visit(new Schema.Parser().parse(s8), new TestVisitor());
+  @Test
+  void testVisit8() {
+    assertThrows(UnsupportedOperationException.class, () -> {
+      String s8 = "{\"type\": \"record\", \"name\": \"c1\", \"fields\": ["
+          + "{\"name\": \"f1\", \"type\": {\"type\": \"record\", \"name\": \"cst2\", \"fields\": "
+          + "[{\"name\": \"f11\", \"type\": \"int\"}]}}," + "{\"name\": \"f2\", \"type\": \"int\"}" + "]}";
+      Schemas.visit(new Schema.Parser().parse(s8), new TestVisitor());
+    });
   }
 
   @Test
-  public void testVisit9() {
+  void testVisit9() {
     String s9 = "{\"type\": \"record\", \"name\": \"c1\", \"fields\": ["
         + "{\"name\": \"f1\", \"type\": {\"type\": \"record\", \"name\": \"ct2\", \"fields\": "
         + "[{\"name\": \"f11\", \"type\": \"int\"}]}}," + "{\"name\": \"f2\", \"type\": \"long\"}" + "]}";
-    Assert.assertEquals("c1.ct2.\"int\"!", Schemas.visit(new Schema.Parser().parse(s9), new TestVisitor()));
+    assertEquals("c1.ct2.\"int\"!", Schemas.visit(new Schema.Parser().parse(s9), new TestVisitor()));
   }
 
-  @Test(expected = UnsupportedOperationException.class)
-  public void testVisit10() {
-    String s10 = "{\"type\": \"record\", \"name\": \"c1\", \"fields\": ["
-        + "{\"name\": \"f1\", \"type\": {\"type\": \"record\", \"name\": \"ct2\", \"fields\": "
-        + "[{\"name\": \"f11\", \"type\": \"int\"}]}}," + "{\"name\": \"f2\", \"type\": \"int\"}" + "]}";
-    Schemas.visit(new Schema.Parser().parse(s10), new TestVisitor() {
-      public SchemaVisitorAction visitTerminal(Schema terminal) {
-        return SchemaVisitorAction.SKIP_SUBTREE;
-      }
+  @Test
+  void testVisit10() {
+    assertThrows(UnsupportedOperationException.class, () -> {
+      String s10 = "{\"type\": \"record\", \"name\": \"c1\", \"fields\": ["
+          + "{\"name\": \"f1\", \"type\": {\"type\": \"record\", \"name\": \"ct2\", \"fields\": "
+          + "[{\"name\": \"f11\", \"type\": \"int\"}]}}," + "{\"name\": \"f2\", \"type\": \"int\"}" + "]}";
+      Schemas.visit(new Schema.Parser().parse(s10), new TestVisitor() {
+        public SchemaVisitorAction visitTerminal(Schema terminal) {

Review Comment:
   ## Missing Override annotation
   
   This method overrides [TestVisitor.visitTerminal](1); it is advisable to add an Override annotation.
   
   [Show more details](https://github.com/apache/avro/security/code-scanning/2794)



-- 
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] dkulp merged pull request #1777: AVRO-3579: Migrate to JUnit 5

Posted by GitBox <gi...@apache.org>.
dkulp merged PR #1777:
URL: https://github.com/apache/avro/pull/1777


-- 
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