This is an automated email from the ASF dual-hosted git repository.

cgivre pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/drill.git


The following commit(s) were added to refs/heads/master by this push:
     new 196f5a5  DRILL-7941 Update JUnit from 4.13.2 to 5.7.2 (#2244)
196f5a5 is described below

commit 196f5a50a286f99463f7352f1a89d3b215b53afc
Author: Martin Grigorov <[email protected]>
AuthorDate: Sun Jul 11 21:15:52 2021 +0300

    DRILL-7941 Update JUnit from 4.13.2 to 5.7.2 (#2244)
    
    * DRILL-7941 Update JUnit from 4.13.2 to 5.7.2
    
    * DRILL-7941 Add dependency management for JUnit 4.x
    
    This way we can control the version used by junit-vintage-engine and most 
importantly its scope (test).
    
    Now the dependency:tree looks like:
    
    [INFO] +- org.junit.vintage:junit-vintage-engine:jar:5.7.2:test
    [INFO] |  +- org.apiguardian:apiguardian-api:jar:1.1.0:test
    [INFO] |  +- org.junit.platform:junit-platform-engine:jar:1.7.2:test
    [INFO] |  |  +- org.opentest4j:opentest4j:jar:1.2.0:test
    [INFO] |  |  \- org.junit.platform:junit-platform-commons:jar:1.7.2:test
    [INFO] |  \- junit:junit:jar:4.13.2:test
    
    Before this change the scope of junit:junit was 'compile' and its version - 
4.13
    The compile scope added to the total size of java-exec-all.jar and 
maven-enforcer rule failed
    
    * DRILL-7941 Add junit:junit with 'provided' scope to drill-common for 
RepeatTestRule
    
    Remove an obsolete comment from drill-logical/pom.xml
    
    * DRILL-7941 Migrate few unit tests from JUnit 4.x APIs to 5.x APIs
    
    * DRILL-7941 Move RepeatTestRule to drill-common/src/test
    
    This way there is no need to have dependency to junit:junit in the main 
sources
    
    suggested-by: vvysotskyi
    
    * DRILL-7941 Use junit-bom to manage the dependencies
    
    Use junit-jupiter library. It brings -api, -engine and -params as 
transitive dependencies, so the full power of JUnit 5.x could be easily used.
    
    * DRILL-7941 Add junit-jupiter and junit-vintage-engine as dependencies in 
the root module
    
    This way both are available for all sub-modules.
    Update surefire-junit dependency
---
 common/pom.xml                                     |  6 ---
 .../apache/drill/common/util/RepeatTestRule.java   |  0
 .../Drill2130CommonHamcrestConfigurationTest.java  | 12 +++---
 exec/jdbc-all/pom.xml                              |  2 +-
 logical/pom.xml                                    |  7 ----
 .../drill/common/expression/PathSegmentTests.java  |  6 +--
 .../drill/common/expression/SchemaPathTest.java    | 28 ++++++-------
 .../drill/common/expression/parser/TreeTest.java   | 47 +++++++++++-----------
 pom.xml                                            | 31 +++++++++++---
 9 files changed, 73 insertions(+), 66 deletions(-)

diff --git a/common/pom.xml b/common/pom.xml
index 729e8e5..246c196 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -38,12 +38,6 @@
       <version>${project.version}</version>
     </dependency>
     <dependency>
-      <!-- add as provided scope so that we can compile TestTools.  Should 
only be ever used in a test scenario where someone else is bringing JUnit in. 
-->
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>${junit.version}</version>
-    </dependency>
-    <dependency>
       <groupId>com.typesafe</groupId>
       <artifactId>config</artifactId>
     </dependency>
diff --git 
a/common/src/main/java/org/apache/drill/common/util/RepeatTestRule.java 
b/common/src/test/java/org/apache/drill/common/util/RepeatTestRule.java
similarity index 100%
rename from 
common/src/main/java/org/apache/drill/common/util/RepeatTestRule.java
rename to common/src/test/java/org/apache/drill/common/util/RepeatTestRule.java
diff --git 
a/common/src/test/java/org/apache/drill/test/Drill2130CommonHamcrestConfigurationTest.java
 
b/common/src/test/java/org/apache/drill/test/Drill2130CommonHamcrestConfigurationTest.java
index a8481fe..ae0e148 100644
--- 
a/common/src/test/java/org/apache/drill/test/Drill2130CommonHamcrestConfigurationTest.java
+++ 
b/common/src/test/java/org/apache/drill/test/Drill2130CommonHamcrestConfigurationTest.java
@@ -17,20 +17,20 @@
  */
 package org.apache.drill.test;
 
-import org.junit.Test;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.fail;
 import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.fail;
+
+import org.junit.jupiter.api.Test;
 
-public class Drill2130CommonHamcrestConfigurationTest extends BaseTest {
+class Drill2130CommonHamcrestConfigurationTest extends BaseTest {
   private static final org.slf4j.Logger logger = 
org.slf4j.LoggerFactory.getLogger(Drill2130CommonHamcrestConfigurationTest.class);
 
   @SuppressWarnings("unused")
   private org.hamcrest.MatcherAssert forCompileTimeCheckForNewEnoughHamcrest;
 
   @Test
-  public void testJUnitHamcrestMatcherFailureWorks() {
+  void testJUnitHamcrestMatcherFailureWorks() {
     try {
       assertThat( 1, equalTo( 2 ) );
     }
diff --git a/exec/jdbc-all/pom.xml b/exec/jdbc-all/pom.xml
index 4364879..cf5614e 100644
--- a/exec/jdbc-all/pom.xml
+++ b/exec/jdbc-all/pom.xml
@@ -262,7 +262,7 @@
             -XX:MaxDirectMemorySize=3072M
             -XX:+CMSClassUnloadingEnabled -ea</argLine>
           <additionalClasspathElements>
-            
<additionalClasspathElements>${settings.localRepository}/junit/junit/${junit.version}/junit-${junit.version}.jar</additionalClasspathElements>
+            
<additionalClasspathElements>${settings.localRepository}/org/junit/vintage/junit-vintage-engine/${junit.version}/junit-vintage-engine-${junit.version}.jar</additionalClasspathElements>
             
<additionalClasspathElements>${settings.localRepository}/org/hamcrest/hamcrest/${hamcrest.version}/hamcrest-${hamcrest.version}.jar</additionalClasspathElements>
             
<additionalClasspathElements>${project.build.directory}/test-classes/</additionalClasspathElements>
           </additionalClasspathElements>
diff --git a/logical/pom.xml b/logical/pom.xml
index 9492626..9460926 100644
--- a/logical/pom.xml
+++ b/logical/pom.xml
@@ -52,13 +52,6 @@
     </dependency>
 
     <dependency>
-      <!-- add as provided scope so that we can compile TestTools.  Should 
only be ever used in a test scenario where someone else is bringing JUnit in. 
-->
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>${junit.version}</version>
-    </dependency>
-
-    <dependency>
       <groupId>${calcite.groupId}</groupId>
       <artifactId>calcite-core</artifactId>
     </dependency>
diff --git 
a/logical/src/test/java/org/apache/drill/common/expression/PathSegmentTests.java
 
b/logical/src/test/java/org/apache/drill/common/expression/PathSegmentTests.java
index fe9ce0d..438f599 100644
--- 
a/logical/src/test/java/org/apache/drill/common/expression/PathSegmentTests.java
+++ 
b/logical/src/test/java/org/apache/drill/common/expression/PathSegmentTests.java
@@ -20,9 +20,9 @@ package org.apache.drill.common.expression;
 import static org.junit.Assert.assertEquals;
 
 import org.apache.drill.test.DrillTest;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-public class PathSegmentTests extends DrillTest {
+class PathSegmentTests extends DrillTest {
   protected PathSegment makeArraySegment(final int len, final PathSegment 
tail) {
     PathSegment node = tail;
     for (int i = 0; i < len; i++) {
@@ -32,7 +32,7 @@ public class PathSegmentTests extends DrillTest {
   }
 
   @Test
-  public void testIfMultiLevelCloneWorks() {
+  void testIfMultiLevelCloneWorks() {
     final int levels = 10;
     final PathSegment segment = new PathSegment.NameSegment("test", 
makeArraySegment(levels, null));
     final PathSegment clone = segment.clone();
diff --git 
a/logical/src/test/java/org/apache/drill/common/expression/SchemaPathTest.java 
b/logical/src/test/java/org/apache/drill/common/expression/SchemaPathTest.java
index 3bc5ec5..bc3751d 100644
--- 
a/logical/src/test/java/org/apache/drill/common/expression/SchemaPathTest.java
+++ 
b/logical/src/test/java/org/apache/drill/common/expression/SchemaPathTest.java
@@ -18,43 +18,43 @@
 package org.apache.drill.common.expression;
 
 import org.apache.drill.test.BaseTest;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
-public class SchemaPathTest extends BaseTest {
+class SchemaPathTest extends BaseTest {
 
   @Test
-  public void testUnIndexedWithOutArray() {
+  void testUnIndexedWithOutArray() {
     SchemaPath oneElementSchema = SchemaPath.parseFromString("`a`");
-    assertEquals("Schema path should match", oneElementSchema, 
oneElementSchema.getUnIndexed());
+    assertEquals(oneElementSchema, oneElementSchema.getUnIndexed(), "Schema 
path should match");
 
     SchemaPath severalElementsSchema = 
SchemaPath.parseFromString("`a`.`b`.`c`");
-    assertEquals("Schema path should match", severalElementsSchema, 
severalElementsSchema.getUnIndexed());
+    assertEquals(severalElementsSchema, severalElementsSchema.getUnIndexed(), 
"Schema path should match");
   }
 
   @Test
-  public void testUnIndexedEndingWithArray() {
+  void testUnIndexedEndingWithArray() {
     SchemaPath schemaPath = SchemaPath.parseFromString("`a`.`b`[0]");
-    assertEquals("Schema path should match", 
SchemaPath.parseFromString("`a`.`b`"), schemaPath.getUnIndexed());
+    assertEquals(SchemaPath.parseFromString("`a`.`b`"), 
schemaPath.getUnIndexed(), "Schema path should match");
   }
 
   @Test
-  public void testUnIndexedArrayInTheMiddle() {
+  void testUnIndexedArrayInTheMiddle() {
     SchemaPath schemaPath = SchemaPath.parseFromString("`a`.`b`[0].`c`.`d`");
-    assertEquals("Schema path should match", 
SchemaPath.parseFromString("`a`.`b`.`c`.`d`"), schemaPath.getUnIndexed());
+    assertEquals(SchemaPath.parseFromString("`a`.`b`.`c`.`d`"), 
schemaPath.getUnIndexed(), "Schema path should match");
   }
 
   @Test
-  public void testUnIndexedMultipleArrays() {
+  void testUnIndexedMultipleArrays() {
     SchemaPath schemaPath = 
SchemaPath.parseFromString("`a`.`b`[0][1].`c`.`d`[2][0]");
-    assertEquals("Schema path should match", 
SchemaPath.parseFromString("`a`.`b`.`c`.`d`"), schemaPath.getUnIndexed());
+    assertEquals(SchemaPath.parseFromString("`a`.`b`.`c`.`d`"), 
schemaPath.getUnIndexed(), "Schema path should match");
   }
 
   @Test
-  public void testCompoundPathN() {
+  void testCompoundPathN() {
     SchemaPath schemaPath = SchemaPath.getCompoundPath(3, "a", "b", "c", "d", 
"e");
-    assertEquals("Schema path should match", SchemaPath.getCompoundPath("a", 
"b", "c"), schemaPath);
+    assertEquals(SchemaPath.getCompoundPath("a", "b", "c"), schemaPath, 
"Schema path should match");
   }
 }
 
diff --git 
a/logical/src/test/java/org/apache/drill/common/expression/parser/TreeTest.java 
b/logical/src/test/java/org/apache/drill/common/expression/parser/TreeTest.java
index 0d34716..5f5ee0f 100644
--- 
a/logical/src/test/java/org/apache/drill/common/expression/parser/TreeTest.java
+++ 
b/logical/src/test/java/org/apache/drill/common/expression/parser/TreeTest.java
@@ -22,89 +22,88 @@ import 
org.apache.drill.common.expression.ExpressionStringBuilder;
 import org.apache.drill.common.expression.LogicalExpression;
 import org.apache.drill.common.parser.LogicalExpressionParser;
 import org.apache.drill.test.DrillTest;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
 
 import static org.hamcrest.CoreMatchers.containsString;
-import static org.junit.Assert.assertEquals;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
-public class TreeTest extends DrillTest {
-
-  @Rule
-  public ExpectedException thrown = ExpectedException.none();
+class TreeTest extends DrillTest {
 
   @Test
-  public void escapeStringLiteral() {
+  void escapeStringLiteral() {
     String expr = "func(`identifier`, '\\\\d+', 0, 'fjds')";
     testExpressionParsing(expr, expr);
   }
 
   @Test
-  public void escapeQuotedIdentifier() {
+  void escapeQuotedIdentifier() {
     String expr = "`a\\\\b` + `c'd`";
     testExpressionParsing(expr, "add(`a\\\\b`, `c'd`)");
   }
 
   @Test
-  public void testIfWithCase() {
+  void testIfWithCase() {
     testExpressionParsing("if ($F1) then case when (_MAP.R_NAME = 'AFRICA') 
then 2 else 4 end else if(4==3) then 1 else if(x==3) then 7 else (if(2==1) then 
6 else 4 end) end",
       "( if (equal(`x`, 3)  ) then (7 )  else ( ( if (equal(2, 1)  ) then (6 ) 
 else (4 )  end  )  )  end  )");
   }
 
   @Test
-  public void testAdd() {
+  void testAdd() {
     testExpressionParsing("2+2", "add(2, 2)");
   }
 
   @Test
-  public void testIf() {
+  void testIf() {
     testExpressionParsing("if ('blue.red') then 'orange' else if (false) then 
1 else 0 end",
       "( if (false ) then (1 )  else (0 )  end  )");
   }
 
   @Test
-  public void testQuotedIdentifier() {
+  void testQuotedIdentifier() {
     String expr = "`hello friend`.`goodbye`";
     testExpressionParsing(expr, expr);
   }
 
   @Test
-  public void testSpecialQuoted() {
+  void testSpecialQuoted() {
     testExpressionParsing("`*0` + `*` ", "add(`*0`, `*`)");
   }
 
   @Test
-  public void testQuotedIdentifier2() {
+  void testQuotedIdentifier2() {
     testExpressionParsing("`hello friend`.goodbye", "`hello 
friend`.`goodbye`");
   }
 
   @Test
-  public void testComplexIdentifier() {
+  void testComplexIdentifier() {
     testExpressionParsing("goodbye[4].`hello`", "`goodbye`[4].`hello`");
   }
 
   @Test // DRILL-2606
-  public void testCastToBooleanExpr() {
+  void testCastToBooleanExpr() {
     String expr = "cast( (cast( (`bool_col` ) as VARCHAR(100) ) ) as BIT )";
     testExpressionParsing(expr, expr);
   }
 
   @Test
-  public void testComments() {
+  void testComments() {
     testExpressionParsing("cast /* block comment */ ( // single comment\n" +
       "1 as int)", "cast( (1 ) as INT )");
   }
 
   @Test
-  public void testParsingException() {
-    thrown.expect(ExpressionParsingException.class);
-    thrown.expectMessage(containsString("mismatched input 'i' expecting"));
-    testExpressionParsing("cast(1 as i)", "");
+  void testParsingException() {
+
+    ExpressionParsingException exception = 
assertThrows(ExpressionParsingException.class, () ->
+      testExpressionParsing("cast(1 as i)", "")
+    );
+    assertThat(exception.getMessage(), containsString("mismatched input 'i' 
expecting"));
   }
 
   @Test
-  public void testFunctionCallWithoutParams() {
+  void testFunctionCallWithoutParams() {
     String expr = "now()";
     testExpressionParsing(expr, expr);
   }
diff --git a/pom.xml b/pom.xml
index c6a737e..fea724b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -44,7 +44,8 @@
 
     
<target.gen.source.path>${project.basedir}/target/generated-sources</target.gen.source.path>
     <proto.cas.path>${project.basedir}/src/main/protobuf/</proto.cas.path>
-    <junit.version>4.13.2</junit.version>
+    <junit.version>5.7.2</junit.version>
+    <junit4.version>4.13.2</junit4.version>
     <slf4j.version>1.7.26</slf4j.version>
     <shaded.guava.version>28.2-jre</shaded.guava.version>
     <guava.version>30.1.1-jre</guava.version>
@@ -858,7 +859,7 @@
           <dependencies>
             <dependency>
               <groupId>org.apache.maven.surefire</groupId>
-              <artifactId>surefire-junit47</artifactId>
+              <artifactId>surefire-junit-platform</artifactId>
               <version>${surefire.version}</version>
             </dependency>
           </dependencies>
@@ -1099,12 +1100,18 @@
       <version>${jmockit.version}</version>
       <scope>test</scope>
     </dependency>
+
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter</artifactId>
+      <scope>test</scope>
+    </dependency>
     <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>${junit.version}</version>
+      <groupId>org.junit.vintage</groupId>
+      <artifactId>junit-vintage-engine</artifactId>
       <scope>test</scope>
     </dependency>
+
     <dependency>
       <!-- Mockito needs to be on the class path after JUnit (or Hamcrest) as
            long as Mockito _contains_ older Hamcrest classes.  See DRILL-2130. 
-->
@@ -1283,6 +1290,13 @@
         <scope>test</scope>
       </dependency>
       <dependency>
+        <groupId>org.junit</groupId>
+        <artifactId>junit-bom</artifactId>
+        <version>${junit.version}</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
+      <dependency>
         <groupId>org.freemarker</groupId>
         <artifactId>freemarker</artifactId>
         <version>${freemarker.version}</version>
@@ -2033,6 +2047,13 @@
           </exclusion>
         </exclusions>
       </dependency>
+
+      <dependency>
+        <groupId>junit</groupId>
+        <artifactId>junit</artifactId>
+        <version>${junit4.version}</version>
+        <scope>test</scope>
+      </dependency>
     </dependencies>
   </dependencyManagement>
 

Reply via email to