You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by pd...@apache.org on 2023/09/11 11:09:14 UTC

[zeppelin] branch master updated: [ZEPPELIN-5949] Update testcontainers and migrate neo4j to Junit5 (#4643)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 0a48d9944c [ZEPPELIN-5949] Update testcontainers and migrate neo4j to Junit5 (#4643)
0a48d9944c is described below

commit 0a48d9944cb2ab9644e93bffaa21e8a17f0b57c8
Author: Philipp Dallig <ph...@gmail.com>
AuthorDate: Mon Sep 11 13:09:08 2023 +0200

    [ZEPPELIN-5949] Update testcontainers and migrate neo4j to Junit5 (#4643)
---
 neo4j/pom.xml                                      |  7 +++
 .../graph/neo4j/Neo4jCypherInterpreterTest.java    | 58 +++++++++++-----------
 pom.xml                                            |  9 +++-
 3 files changed, 45 insertions(+), 29 deletions(-)

diff --git a/neo4j/pom.xml b/neo4j/pom.xml
index eae8331651..075f369408 100644
--- a/neo4j/pom.xml
+++ b/neo4j/pom.xml
@@ -63,6 +63,13 @@
     <dependency>
       <groupId>org.testcontainers</groupId>
       <artifactId>neo4j</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.testcontainers</groupId>
+      <artifactId>junit-jupiter</artifactId>
+      <scope>test</scope>
     </dependency>
   </dependencies>
 
diff --git a/neo4j/src/test/java/org/apache/zeppelin/graph/neo4j/Neo4jCypherInterpreterTest.java b/neo4j/src/test/java/org/apache/zeppelin/graph/neo4j/Neo4jCypherInterpreterTest.java
index 9f363f053a..a9a567e372 100644
--- a/neo4j/src/test/java/org/apache/zeppelin/graph/neo4j/Neo4jCypherInterpreterTest.java
+++ b/neo4j/src/test/java/org/apache/zeppelin/graph/neo4j/Neo4jCypherInterpreterTest.java
@@ -16,6 +16,7 @@
  */
 package org.apache.zeppelin.graph.neo4j;
 
+import com.fasterxml.jackson.databind.ObjectMapper;
 import com.google.gson.Gson;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.zeppelin.graph.neo4j.Neo4jConnectionManager.Neo4jAuthType;
@@ -25,37 +26,38 @@ import org.apache.zeppelin.interpreter.InterpreterResult;
 import org.apache.zeppelin.interpreter.InterpreterResult.Code;
 import org.apache.zeppelin.interpreter.graph.GraphResult;
 import org.apache.zeppelin.tabledata.Node;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
-import org.junit.runners.MethodSorters;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestMethodOrder;
+import org.junit.jupiter.api.MethodOrderer;
 import org.neo4j.driver.Driver;
 import org.neo4j.driver.GraphDatabase;
 import org.neo4j.driver.Session;
 import org.testcontainers.containers.Neo4jContainer;
-import org.testcontainers.shaded.com.fasterxml.jackson.core.JsonProcessingException;
-import org.testcontainers.shaded.com.fasterxml.jackson.databind.ObjectMapper;
+import org.testcontainers.junit.jupiter.Container;
+import org.testcontainers.junit.jupiter.Testcontainers;
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.io.IOException;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+@Testcontainers
+@TestMethodOrder(MethodOrderer.MethodName.class)
 public class Neo4jCypherInterpreterTest {
 
   private Neo4jCypherInterpreter interpreter;
 
   private InterpreterContext context;
 
-  @ClassRule
+  @Container
   public static Neo4jContainer<?> neo4jContainer = new Neo4jContainer<>("neo4j:4.1.1")
           .withoutAuthentication();
 
@@ -75,7 +77,7 @@ public class Neo4jCypherInterpreterTest {
   private static final String TABLE_RESULT_PREFIX = "%table ";
   private static final String NETWORK_RESULT_PREFIX = "%network ";
 
-  @BeforeClass
+  @BeforeAll
   public static void setUpNeo4jServer() {
     try (Driver driver = GraphDatabase.driver(neo4jContainer.getBoltUrl());
          Session session = driver.session()) {
@@ -84,7 +86,7 @@ public class Neo4jCypherInterpreterTest {
     }
   }
 
-  @Before
+  @BeforeEach
   public void setUpZeppelin() {
     Properties p = new Properties();
     p.setProperty(Neo4jConnectionManager.NEO4J_SERVER_URL, neo4jContainer.getBoltUrl());
@@ -97,13 +99,13 @@ public class Neo4jCypherInterpreterTest {
         .build();
   }
 
-  @After
+  @AfterEach
   public void tearDownZeppelin() throws Exception {
     interpreter.close();
   }
 
   @Test
-  public void testTableWithArray() {
+  void testTableWithArray() {
     interpreter.open();
     InterpreterResult result = interpreter.interpret(
             "return 'a' as colA, 'b' as colB, [1, 2, 3] as colC", context);
@@ -121,7 +123,7 @@ public class Neo4jCypherInterpreterTest {
   }
 
   @Test
-  public void testCreateIndex() {
+  void testCreateIndex() {
     interpreter.open();
     InterpreterResult result = interpreter.interpret("CREATE INDEX ON :Person(name)", context);
     assertEquals(Code.SUCCESS, result.code());
@@ -129,7 +131,7 @@ public class Neo4jCypherInterpreterTest {
   }
 
   @Test
-  public void testRenderTable() {
+  void testRenderTable() {
     interpreter.open();
     InterpreterResult result = interpreter.interpret("MATCH (n:Person) "
             + "WHERE n.name IN ['name1', 'name2', 'name3'] "
@@ -144,7 +146,7 @@ public class Neo4jCypherInterpreterTest {
   }
 
   @Test
-  public void testRenderMap() {
+  void testRenderMap() {
     interpreter.open();
     final String jsonQuery =
             "RETURN {key: \"value\", listKey: [{inner: \"Map1\"}, {inner: \"Map2\"}]} as object";
@@ -231,7 +233,7 @@ public class Neo4jCypherInterpreterTest {
   }
 
   @Test
-  public void testRenderNetwork() {
+  void testRenderNetwork() {
     interpreter.open();
     InterpreterResult result = interpreter.interpret(
             "MATCH (n)-[r:KNOWS]-(m) RETURN n, r, m LIMIT 1", context);
@@ -249,7 +251,7 @@ public class Neo4jCypherInterpreterTest {
   }
 
   @Test
-  public void testFallingQuery() {
+  void testFallingQuery() {
     interpreter.open();
     final String errorMsgEmpty = "";
     InterpreterResult result = interpreter.interpret(StringUtils.EMPTY, context);
@@ -266,7 +268,7 @@ public class Neo4jCypherInterpreterTest {
   }
 
   @Test
-  public void testDates() {
+  void testDates() {
     InterpreterResult result = interpreter.interpret(
             "RETURN datetime('2015-06-24T12:50:35.556+0100') AS theDateTime", context);
     assertEquals(Code.SUCCESS, result.code());
@@ -296,7 +298,7 @@ public class Neo4jCypherInterpreterTest {
   }
 
   @Test
-  public void testDuration() {
+  void testDuration() {
     InterpreterResult result = interpreter.interpret(
             "RETURN duration('P14DT16H12M') AS theDuration", context);
     assertEquals(Code.SUCCESS, result.code());
@@ -305,7 +307,7 @@ public class Neo4jCypherInterpreterTest {
   }
 
   @Test
-  public void testPoint() {
+  void testPoint() {
     InterpreterResult result = interpreter.interpret("RETURN point({ x:3, y:0 }) AS cartesian_2d,"
             + "point({ x:0, y:4, z:1 }) AS cartesian_3d,"
             + "point({ latitude: 12, longitude: 56 }) AS geo_2d,"
@@ -327,7 +329,7 @@ public class Neo4jCypherInterpreterTest {
   }
 
   @Test
-  public void testMultiLineInterpreter() {
+  void testMultiLineInterpreter() {
     Properties p = new Properties();
     p.setProperty(Neo4jConnectionManager.NEO4J_SERVER_URL, neo4jContainer.getBoltUrl());
     p.setProperty(Neo4jConnectionManager.NEO4J_AUTH_TYPE, Neo4jAuthType.NONE.toString());
@@ -358,7 +360,7 @@ public class Neo4jCypherInterpreterTest {
   }
 
   @Test
-  public void testNodeDataTypes() throws JsonProcessingException {
+  void testNodeDataTypes() throws IOException {
     InterpreterResult result = interpreter.interpret(
             "CREATE (n:NodeTypes{" +
                     "dateTime: datetime('2015-06-24T12:50:35.556+0100')," +
diff --git a/pom.xml b/pom.xml
index 302d2d730d..3a76967068 100644
--- a/pom.xml
+++ b/pom.xml
@@ -199,7 +199,7 @@
     <plugin.surefire.version>2.22.2</plugin.surefire.version>
     <plugin.os.version>1.4.1.Final</plugin.os.version>
 
-    <testcontainers.version>1.15.1</testcontainers.version>
+    <testcontainers.version>1.19.0</testcontainers.version>
 
     <MaxMetaspace>512m</MaxMetaspace>
 
@@ -1177,6 +1177,13 @@
         <scope>test</scope>
       </dependency>
 
+      <dependency>
+        <groupId>org.testcontainers</groupId>
+        <artifactId>junit-jupiter</artifactId>
+        <version>${testcontainers.version}</version>
+        <scope>test</scope>
+      </dependency>
+
       <dependency>
         <groupId>org.apache.hadoop</groupId>
         <artifactId>hadoop-hdfs</artifactId>