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 aeb40a5907 [ZEPPELIN-5879] Migrate Zeppelin Plugins to JUnit5 (#4559) aeb40a5907 is described below commit aeb40a5907b42da7d64f22ff1ceb288cc86fa922 Author: Philipp Dallig <philipp.dal...@gmail.com> AuthorDate: Tue Mar 7 11:45:16 2023 +0100 [ZEPPELIN-5879] Migrate Zeppelin Plugins to JUnit5 (#4559) * use junit5 in k8s plugin * junit for other plugins * Remove juint4 in zeppelin plugins * Remove visibility modifier in test classes * Apply suggestions from code review Co-authored-by: Guanhua Li <guanhua...@foxmail.com> --------- Co-authored-by: Guanhua Li <guanhua...@foxmail.com> --- pom.xml | 7 + .../launcher/ClusterInterpreterLauncherTest.java | 50 +++-- .../interpreter/launcher/ClusterMockTest.java | 10 +- zeppelin-plugins/launcher/k8s-standard/pom.xml | 6 - .../launcher/K8sRemoteInterpreterProcessTest.java | 78 ++++---- .../interpreter/launcher/K8sSpecTemplateTest.java | 23 +-- .../K8sStandardInterpreterLauncherTest.java | 20 +- .../interpreter/launcher/K8sUtilsTest.java | 29 +-- .../interpreter/launcher/PodPhaseWatcherTest.java | 28 +-- .../notebook/repo/FileSystemNotebookRepoTest.java | 22 +-- zeppelin-plugins/notebookrepo/gcs/pom.xml | 5 + .../notebook/repo/GCSNotebookRepoTest.java | 218 +++++++++++---------- .../notebook/repo/GitHubNotebookRepoTest.java | 25 +-- zeppelin-plugins/notebookrepo/mongo/pom.xml | 5 + .../notebook/repo/MongoNotebookRepoTest.java | 22 +-- .../zeppelin/notebook/repo/ToPathArrayTest.java | 108 +++++----- .../notebook/repo/OSSNotebookRepoTest.java | 29 +-- zeppelin-plugins/notebookrepo/s3/pom.xml | 38 +++- .../zeppelin/notebook/repo/S3NotebookRepoTest.java | 40 ++-- zeppelin-plugins/pom.xml | 6 - 20 files changed, 406 insertions(+), 363 deletions(-) diff --git a/pom.xml b/pom.xml index b972a2d6b6..2715fab79c 100644 --- a/pom.xml +++ b/pom.xml @@ -1135,6 +1135,13 @@ <scope>test</scope> </dependency> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-params</artifactId> + <version>${junit.jupiter.version}</version> + <scope>test</scope> + </dependency> + <dependency> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> diff --git a/zeppelin-plugins/launcher/cluster/src/test/java/org/apache/zeppelin/interpreter/launcher/ClusterInterpreterLauncherTest.java b/zeppelin-plugins/launcher/cluster/src/test/java/org/apache/zeppelin/interpreter/launcher/ClusterInterpreterLauncherTest.java index 743f800ce9..f41d4d879e 100644 --- a/zeppelin-plugins/launcher/cluster/src/test/java/org/apache/zeppelin/interpreter/launcher/ClusterInterpreterLauncherTest.java +++ b/zeppelin-plugins/launcher/cluster/src/test/java/org/apache/zeppelin/interpreter/launcher/ClusterInterpreterLauncherTest.java @@ -19,35 +19,35 @@ package org.apache.zeppelin.interpreter.launcher; import org.apache.zeppelin.conf.ZeppelinConfiguration; import org.apache.zeppelin.interpreter.InterpreterOption; import org.apache.zeppelin.interpreter.remote.RemoteInterpreterRunningProcess; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.IOException; import java.util.Properties; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - public class ClusterInterpreterLauncherTest extends ClusterMockTest { private static final Logger LOGGER = - LoggerFactory.getLogger(ClusterInterpreterLauncherTest.class); + LoggerFactory.getLogger(ClusterInterpreterLauncherTest.class); - @BeforeClass - public static void startTest() throws IOException, InterruptedException { + @BeforeAll + static void startTest() throws IOException, InterruptedException { ClusterMockTest.startCluster(); } - @AfterClass - public static void stopTest() throws IOException, InterruptedException { + @AfterAll + static void stopTest() throws IOException, InterruptedException { ClusterMockTest.stopCluster(); } - @Before - public void setUp() { + @BeforeEach + void setUp() { for (final ZeppelinConfiguration.ConfVars confVar : ZeppelinConfiguration.ConfVars.values()) { System.clearProperty(confVar.getVarName()); } @@ -56,11 +56,11 @@ public class ClusterInterpreterLauncherTest extends ClusterMockTest { // TODO(zjffdu) disable this test because this is not a correct unit test, // Actually the interpreter process here never start before ZEPPELIN-5300. // @Test - public void testConnectExistOnlineIntpProcess() throws IOException { + void testConnectExistOnlineIntpProcess() throws IOException { mockIntpProcessMeta("intpGroupId", true); - ClusterInterpreterLauncher launcher - = new ClusterInterpreterLauncher(ClusterMockTest.zconf, null); + ClusterInterpreterLauncher launcher = + new ClusterInterpreterLauncher(ClusterMockTest.zconf, null); Properties properties = new Properties(); properties.setProperty( ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_CONNECT_TIMEOUT.getVarName(), "5000"); @@ -80,11 +80,11 @@ public class ClusterInterpreterLauncherTest extends ClusterMockTest { } @Test - public void testConnectExistOfflineIntpProcess() throws IOException { + void testConnectExistOfflineIntpProcess() throws IOException { mockIntpProcessMeta("intpGroupId2", false); - ClusterInterpreterLauncher launcher - = new ClusterInterpreterLauncher(ClusterMockTest.zconf, null); + ClusterInterpreterLauncher launcher = + new ClusterInterpreterLauncher(ClusterMockTest.zconf, null); Properties properties = new Properties(); properties.setProperty( ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_CONNECT_TIMEOUT.getVarName(), "5000"); @@ -107,11 +107,10 @@ public class ClusterInterpreterLauncherTest extends ClusterMockTest { } @Test - public void testCreateIntpProcessDockerMode() throws IOException { + void testCreateIntpProcessDockerMode() throws IOException { zconf.setRunMode(ZeppelinConfiguration.RUN_MODE.DOCKER); - ClusterInterpreterLauncher launcher - = new ClusterInterpreterLauncher(zconf, null); + ClusterInterpreterLauncher launcher = new ClusterInterpreterLauncher(zconf, null); Properties properties = new Properties(); properties.setProperty( ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_CONNECT_TIMEOUT.getVarName(), "1000"); @@ -126,11 +125,10 @@ public class ClusterInterpreterLauncherTest extends ClusterMockTest { } @Test - public void testCreateIntpProcessLocalMode() throws IOException { + void testCreateIntpProcessLocalMode() throws IOException { zconf.setRunMode(ZeppelinConfiguration.RUN_MODE.LOCAL); - ClusterInterpreterLauncher launcher - = new ClusterInterpreterLauncher(zconf, null); + ClusterInterpreterLauncher launcher = new ClusterInterpreterLauncher(zconf, null); Properties properties = new Properties(); properties.setProperty( ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_CONNECT_TIMEOUT.getVarName(), "1000"); diff --git a/zeppelin-plugins/launcher/cluster/src/test/java/org/apache/zeppelin/interpreter/launcher/ClusterMockTest.java b/zeppelin-plugins/launcher/cluster/src/test/java/org/apache/zeppelin/interpreter/launcher/ClusterMockTest.java index a6be913257..e66abcedf5 100644 --- a/zeppelin-plugins/launcher/cluster/src/test/java/org/apache/zeppelin/interpreter/launcher/ClusterMockTest.java +++ b/zeppelin-plugins/launcher/cluster/src/test/java/org/apache/zeppelin/interpreter/launcher/ClusterMockTest.java @@ -34,8 +34,8 @@ import java.util.Map; import static org.apache.zeppelin.cluster.meta.ClusterMeta.OFFLINE_STATUS; import static org.apache.zeppelin.cluster.meta.ClusterMeta.ONLINE_STATUS; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; public class ClusterMockTest { private static Logger LOGGER = LoggerFactory.getLogger(ClusterMockTest.class); @@ -114,7 +114,7 @@ public class ClusterMockTest { // Get metadata for all services Map<String, Map<String, Object>> meta = - clusterClient.getClusterMeta(ClusterMetaType.SERVER_META, ""); + clusterClient.getClusterMeta(ClusterMetaType.SERVER_META, ""); LOGGER.info(meta.toString()); @@ -152,8 +152,8 @@ public class ClusterMockTest { clusterClient.putClusterMeta(ClusterMetaType.INTP_PROCESS_META, metaKey, meta); // get IntpProcess Meta - Map<String, Map<String, Object>> check - = clusterClient.getClusterMeta(ClusterMetaType.INTP_PROCESS_META, metaKey); + Map<String, Map<String, Object>> check = + clusterClient.getClusterMeta(ClusterMetaType.INTP_PROCESS_META, metaKey); LOGGER.info(check.toString()); diff --git a/zeppelin-plugins/launcher/k8s-standard/pom.xml b/zeppelin-plugins/launcher/k8s-standard/pom.xml index 3ff0093be6..f3469b132b 100644 --- a/zeppelin-plugins/launcher/k8s-standard/pom.xml +++ b/zeppelin-plugins/launcher/k8s-standard/pom.xml @@ -73,12 +73,6 @@ <artifactId>kubernetes-server-mock</artifactId> <version>${kubernetes.client.version}</version> <scope>test</scope> - <exclusions> - <exclusion> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - </exclusion> - </exclusions> </dependency> </dependencies> diff --git a/zeppelin-plugins/launcher/k8s-standard/src/test/java/org/apache/zeppelin/interpreter/launcher/K8sRemoteInterpreterProcessTest.java b/zeppelin-plugins/launcher/k8s-standard/src/test/java/org/apache/zeppelin/interpreter/launcher/K8sRemoteInterpreterProcessTest.java index 82e56efcd8..17a8b89027 100644 --- a/zeppelin-plugins/launcher/k8s-standard/src/test/java/org/apache/zeppelin/interpreter/launcher/K8sRemoteInterpreterProcessTest.java +++ b/zeppelin-plugins/launcher/k8s-standard/src/test/java/org/apache/zeppelin/interpreter/launcher/K8sRemoteInterpreterProcessTest.java @@ -17,12 +17,12 @@ package org.apache.zeppelin.interpreter.launcher; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.io.File; import java.io.IOException; @@ -36,26 +36,26 @@ import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import org.apache.zeppelin.interpreter.remote.RemoteInterpreterManagedProcess; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; + import io.fabric8.kubernetes.api.model.Pod; import io.fabric8.kubernetes.api.model.PodStatus; import io.fabric8.kubernetes.client.KubernetesClient; -import io.fabric8.kubernetes.client.server.mock.KubernetesServer; +import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient; -public class K8sRemoteInterpreterProcessTest { +@EnableKubernetesMockClient(https = false, crud = true) +class K8sRemoteInterpreterProcessTest { - @Rule - public KubernetesServer server = new KubernetesServer(false, true); + KubernetesClient client; @Test - public void testPredefinedPortNumbers() { + void testPredefinedPortNumbers() { // given Properties properties = new Properties(); Map<String, String> envs = new HashMap<>(); K8sRemoteInterpreterProcess intp = new K8sRemoteInterpreterProcess( - server.getClient(), + client, "default", new File(".skip"), "interpreter-container:1.0", @@ -82,7 +82,7 @@ public class K8sRemoteInterpreterProcessTest { } @Test - public void testGetTemplateBindings() { + void testGetTemplateBindings() { // given Properties properties = new Properties(); properties.put("my.key1", "v1"); @@ -90,7 +90,7 @@ public class K8sRemoteInterpreterProcessTest { envs.put("MY_ENV1", "V1"); K8sRemoteInterpreterProcess intp = new K8sRemoteInterpreterProcess( - server.getClient(), + client, "default", new File(".skip"), "interpreter-container:1.0", @@ -133,7 +133,7 @@ public class K8sRemoteInterpreterProcessTest { } @Test - public void testGetTemplateBindingsForSpark() { + void testGetTemplateBindingsForSpark() { // given Properties properties = new Properties(); properties.put("my.key1", "v1"); @@ -146,7 +146,7 @@ public class K8sRemoteInterpreterProcessTest { envs.put("SERVICE_DOMAIN", "mydomain"); K8sRemoteInterpreterProcess intp = new K8sRemoteInterpreterProcess( - server.getClient(), + client, "default", new File(".skip"), "interpreter-container:1.0", @@ -192,7 +192,7 @@ public class K8sRemoteInterpreterProcessTest { } @Test - public void testGetTemplateBindingsForSparkWithProxyUser() { + void testGetTemplateBindingsForSparkWithProxyUser() { // given Properties properties = new Properties(); properties.put("my.key1", "v1"); @@ -203,7 +203,7 @@ public class K8sRemoteInterpreterProcessTest { envs.put("SERVICE_DOMAIN", "mydomain"); K8sRemoteInterpreterProcess intp = new K8sRemoteInterpreterProcess( - server.getClient(), + client, "default", new File(".skip"), "interpreter-container:1.0", @@ -245,7 +245,7 @@ public class K8sRemoteInterpreterProcessTest { } @Test - public void testGetTemplateBindingsForSparkWithProxyUserAnonymous() { + void testGetTemplateBindingsForSparkWithProxyUserAnonymous() { // given Properties properties = new Properties(); properties.put("my.key1", "v1"); @@ -256,7 +256,7 @@ public class K8sRemoteInterpreterProcessTest { envs.put("SERVICE_DOMAIN", "mydomain"); K8sRemoteInterpreterProcess intp = new K8sRemoteInterpreterProcess( - server.getClient(), + client, "default", new File(".skip"), "interpreter-container:1.0", @@ -289,14 +289,14 @@ public class K8sRemoteInterpreterProcessTest { } @Test - public void testSparkUiWebUrlTemplate() { + void testSparkUiWebUrlTemplate() { // given Properties properties = new Properties(); Map<String, String> envs = new HashMap<>(); envs.put("SERVICE_DOMAIN", "mydomain"); K8sRemoteInterpreterProcess intp = new K8sRemoteInterpreterProcess( - server.getClient(), + client, "default", new File(".skip"), "interpreter-container:1.0", @@ -332,7 +332,7 @@ public class K8sRemoteInterpreterProcessTest { } @Test - public void testSparkPodResources() { + void testSparkPodResources() { // given Properties properties = new Properties(); properties.put("spark.driver.memory", "1g"); @@ -341,7 +341,7 @@ public class K8sRemoteInterpreterProcessTest { envs.put("SERVICE_DOMAIN", "mydomain"); K8sRemoteInterpreterProcess intp = new K8sRemoteInterpreterProcess( - server.getClient(), + client, "default", new File(".skip"), "interpreter-container:1.0", @@ -368,7 +368,7 @@ public class K8sRemoteInterpreterProcessTest { } @Test - public void testSparkPodResourcesMemoryOverhead() { + void testSparkPodResourcesMemoryOverhead() { // given Properties properties = new Properties(); properties.put("spark.driver.memory", "1g"); @@ -378,7 +378,7 @@ public class K8sRemoteInterpreterProcessTest { envs.put("SERVICE_DOMAIN", "mydomain"); K8sRemoteInterpreterProcess intp = new K8sRemoteInterpreterProcess( - server.getClient(), + client, "default", new File(".skip"), "interpreter-container:1.0", @@ -405,7 +405,7 @@ public class K8sRemoteInterpreterProcessTest { } @Test - public void testK8sStartSuccessful() throws IOException { + void testK8sStartSuccessful() throws IOException { // given Properties properties = new Properties(); Map<String, String> envs = new HashMap<>(); @@ -415,7 +415,7 @@ public class K8sRemoteInterpreterProcessTest { File file = new File(url.getPath()); K8sRemoteInterpreterProcess intp = new K8sRemoteInterpreterProcess( - server.getClient(), + client, "default", file, "interpreter-container:1.0", @@ -434,14 +434,14 @@ public class K8sRemoteInterpreterProcessTest { true); ExecutorService service = Executors.newFixedThreadPool(1); service - .submit(new PodStatusSimulator(server.getClient(), intp.getInterpreterNamespace(), intp.getPodName(), intp)); + .submit(new PodStatusSimulator(client, intp.getInterpreterNamespace(), intp.getPodName(), intp)); intp.start("TestUser"); // then assertEquals("Running", intp.getPodPhase()); } @Test - public void testK8sStartFailed() { + void testK8sStartFailed() { // given Properties properties = new Properties(); Map<String, String> envs = new HashMap<>(); @@ -451,7 +451,7 @@ public class K8sRemoteInterpreterProcessTest { File file = new File(url.getPath()); K8sRemoteInterpreterProcess intp = new K8sRemoteInterpreterProcess( - server.getClient(), + client, "default", file, "interpreter-container:1.0", @@ -468,7 +468,7 @@ public class K8sRemoteInterpreterProcessTest { 10, false, true); - PodStatusSimulator podStatusSimulator = new PodStatusSimulator(server.getClient(), intp.getInterpreterNamespace(), intp.getPodName(), intp); + PodStatusSimulator podStatusSimulator = new PodStatusSimulator(client, intp.getInterpreterNamespace(), intp.getPodName(), intp); podStatusSimulator.setSecondPhase("Failed"); podStatusSimulator.setSuccessfulStart(false); ExecutorService service = Executors.newFixedThreadPool(1); @@ -482,13 +482,13 @@ public class K8sRemoteInterpreterProcessTest { assertNotNull(e); // Check that the Pod is deleted assertNull( - server.getClient().pods().inNamespace(intp.getInterpreterNamespace()).withName(intp.getPodName()) + client.pods().inNamespace(intp.getInterpreterNamespace()).withName(intp.getPodName()) .get()); } } @Test - public void testK8sStartTimeoutPending() throws InterruptedException { + void testK8sStartTimeoutPending() throws InterruptedException { // given Properties properties = new Properties(); Map<String, String> envs = new HashMap<>(); @@ -498,7 +498,7 @@ public class K8sRemoteInterpreterProcessTest { File file = new File(url.getPath()); K8sRemoteInterpreterProcess intp = new K8sRemoteInterpreterProcess( - server.getClient(), + client, "default", file, "interpreter-container:1.0", @@ -515,7 +515,7 @@ public class K8sRemoteInterpreterProcessTest { 10, false, false); - PodStatusSimulator podStatusSimulator = new PodStatusSimulator(server.getClient(), intp.getInterpreterNamespace(), intp.getPodName(), intp); + PodStatusSimulator podStatusSimulator = new PodStatusSimulator(client, intp.getInterpreterNamespace(), intp.getPodName(), intp); podStatusSimulator.setFirstPhase("Pending"); podStatusSimulator.setSecondPhase("Pending"); podStatusSimulator.setSuccessfulStart(false); @@ -536,7 +536,7 @@ public class K8sRemoteInterpreterProcessTest { // wait for a shutdown service.awaitTermination(10, TimeUnit.SECONDS); // Check that the Pod is deleted - assertNull(server.getClient().pods().inNamespace(intp.getInterpreterNamespace()) + assertNull(client.pods().inNamespace(intp.getInterpreterNamespace()) .withName(intp.getPodName()).get()); } diff --git a/zeppelin-plugins/launcher/k8s-standard/src/test/java/org/apache/zeppelin/interpreter/launcher/K8sSpecTemplateTest.java b/zeppelin-plugins/launcher/k8s-standard/src/test/java/org/apache/zeppelin/interpreter/launcher/K8sSpecTemplateTest.java index f859cab466..f58b950d00 100644 --- a/zeppelin-plugins/launcher/k8s-standard/src/test/java/org/apache/zeppelin/interpreter/launcher/K8sSpecTemplateTest.java +++ b/zeppelin-plugins/launcher/k8s-standard/src/test/java/org/apache/zeppelin/interpreter/launcher/K8sSpecTemplateTest.java @@ -17,16 +17,17 @@ package org.apache.zeppelin.interpreter.launcher; import com.google.common.collect.ImmutableMap; -import org.junit.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Map; import java.util.Properties; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; -public class K8sSpecTemplateTest { +class K8sSpecTemplateTest { @Test - public void testRender() { + void testRender() { // given template variables K8sSpecTemplate template = new K8sSpecTemplate(); template.put("name", "world"); @@ -39,7 +40,7 @@ public class K8sSpecTemplateTest { } @Test - public void testObject() { + void testObject() { K8sSpecTemplate template = new K8sSpecTemplate(); template.put("k8s", ImmutableMap.of("key", "world")); @@ -51,7 +52,7 @@ public class K8sSpecTemplateTest { } @Test - public void testRenderWithStrip() { + void testRenderWithStrip() { // given K8sSpecTemplate template = new K8sSpecTemplate(); template.put("test", "test"); @@ -66,7 +67,7 @@ public class K8sSpecTemplateTest { } @Test - public void testIterate() { + void testIterate() { // given K8sSpecTemplate template = new K8sSpecTemplate(); template.put("dict", ImmutableMap.of( @@ -88,7 +89,7 @@ public class K8sSpecTemplateTest { } @Test - public void testLoadProperties() { + void testLoadProperties() { // given K8sSpecTemplate template = new K8sSpecTemplate(); Properties p = new Properties(); @@ -108,7 +109,7 @@ public class K8sSpecTemplateTest { } @Test - public void testLoadPropertyOverrideString() { + void testLoadPropertyOverrideString() { // given K8sSpecTemplate template = new K8sSpecTemplate(); Properties p = new Properties(); @@ -124,7 +125,7 @@ public class K8sSpecTemplateTest { } @Test - public void testLoadPropertyOverrideDict() { + void testLoadPropertyOverrideDict() { // given K8sSpecTemplate template = new K8sSpecTemplate(); Properties p = new Properties(); @@ -140,7 +141,7 @@ public class K8sSpecTemplateTest { } @Test - public void testLoadPropertyWithMap() { + void testLoadPropertyWithMap() { // given K8sSpecTemplate template = new K8sSpecTemplate(); Properties p = new Properties(); diff --git a/zeppelin-plugins/launcher/k8s-standard/src/test/java/org/apache/zeppelin/interpreter/launcher/K8sStandardInterpreterLauncherTest.java b/zeppelin-plugins/launcher/k8s-standard/src/test/java/org/apache/zeppelin/interpreter/launcher/K8sStandardInterpreterLauncherTest.java index 8433f23701..cf9849c035 100644 --- a/zeppelin-plugins/launcher/k8s-standard/src/test/java/org/apache/zeppelin/interpreter/launcher/K8sStandardInterpreterLauncherTest.java +++ b/zeppelin-plugins/launcher/k8s-standard/src/test/java/org/apache/zeppelin/interpreter/launcher/K8sStandardInterpreterLauncherTest.java @@ -17,30 +17,30 @@ package org.apache.zeppelin.interpreter.launcher; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; import java.util.Properties; import org.apache.zeppelin.conf.ZeppelinConfiguration; import org.apache.zeppelin.interpreter.InterpreterOption; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * In the future, test may use minikube for end-to-end test */ -public class K8sStandardInterpreterLauncherTest { - @Before - public void setUp() { +class K8sStandardInterpreterLauncherTest { + @BeforeEach + void setUp() { for (final ZeppelinConfiguration.ConfVars confVar : ZeppelinConfiguration.ConfVars.values()) { System.clearProperty(confVar.getVarName()); } } @Test - public void testK8sLauncher() throws IOException { + void testK8sLauncher() throws IOException { // given ZeppelinConfiguration zConf = ZeppelinConfiguration.create(); K8sStandardInterpreterLauncher launcher = new K8sStandardInterpreterLauncher(zConf, null); @@ -69,7 +69,7 @@ public class K8sStandardInterpreterLauncherTest { } @Test - public void testK8sLauncherWithSparkAndUserImpersonate() throws IOException { + void testK8sLauncherWithSparkAndUserImpersonate() throws IOException { // given ZeppelinConfiguration zConf = ZeppelinConfiguration.create(); K8sStandardInterpreterLauncher launcher = new K8sStandardInterpreterLauncher(zConf, null); @@ -102,7 +102,7 @@ public class K8sStandardInterpreterLauncherTest { } @Test - public void testK8sLauncherWithSparkAndWithoutUserImpersonate() throws IOException { + void testK8sLauncherWithSparkAndWithoutUserImpersonate() throws IOException { // given ZeppelinConfiguration zConf = ZeppelinConfiguration.create(); K8sStandardInterpreterLauncher launcher = new K8sStandardInterpreterLauncher(zConf, null); diff --git a/zeppelin-plugins/launcher/k8s-standard/src/test/java/org/apache/zeppelin/interpreter/launcher/K8sUtilsTest.java b/zeppelin-plugins/launcher/k8s-standard/src/test/java/org/apache/zeppelin/interpreter/launcher/K8sUtilsTest.java index 0d495e9bdc..70cad8b9be 100644 --- a/zeppelin-plugins/launcher/k8s-standard/src/test/java/org/apache/zeppelin/interpreter/launcher/K8sUtilsTest.java +++ b/zeppelin-plugins/launcher/k8s-standard/src/test/java/org/apache/zeppelin/interpreter/launcher/K8sUtilsTest.java @@ -18,15 +18,17 @@ package org.apache.zeppelin.interpreter.launcher; -import static org.junit.Assert.assertEquals; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import org.apache.commons.lang3.RandomStringUtils; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class K8sUtilsTest { +class K8sUtilsTest { @Test - public void testConvert() { + void testConvert() { assertEquals("484Mi", K8sUtils.calculateMemoryWithDefaultOverhead("100m")); assertEquals("1408Mi", K8sUtils.calculateMemoryWithDefaultOverhead("1Gb")); assertEquals("4505Mi", K8sUtils.calculateMemoryWithDefaultOverhead("4Gb")); @@ -37,18 +39,23 @@ public class K8sUtilsTest { assertEquals("115343360Mi", K8sUtils.calculateMemoryWithDefaultOverhead("100Tb")); } - @Test(expected = NumberFormatException.class) - public void testExceptionMaxLong() { - K8sUtils.calculateMemoryWithDefaultOverhead("10000000Tb"); + @Test + void testExceptionMaxLong() { + assertThrows(NumberFormatException.class, () -> { + K8sUtils.calculateMemoryWithDefaultOverhead("10000000Tb"); + }); + } - @Test(expected = NumberFormatException.class) - public void testExceptionNoValidNumber() { - K8sUtils.calculateMemoryWithDefaultOverhead("NoValidNumber10000000Tb"); + @Test + void testExceptionNoValidNumber() { + assertThrows(NumberFormatException.class, () -> { + K8sUtils.calculateMemoryWithDefaultOverhead("NoValidNumber10000000Tb"); + }); } @Test - public void testGenerateK8sName() { + void testGenerateK8sName() { assertEquals("zeppelin", K8sUtils.generateK8sName("", false)); assertEquals("zeppelin", K8sUtils.generateK8sName(null, false)); assertEquals("test", K8sUtils.generateK8sName("test", false)); diff --git a/zeppelin-plugins/launcher/k8s-standard/src/test/java/org/apache/zeppelin/interpreter/launcher/PodPhaseWatcherTest.java b/zeppelin-plugins/launcher/k8s-standard/src/test/java/org/apache/zeppelin/interpreter/launcher/PodPhaseWatcherTest.java index 735800bba2..0a708d6633 100644 --- a/zeppelin-plugins/launcher/k8s-standard/src/test/java/org/apache/zeppelin/interpreter/launcher/PodPhaseWatcherTest.java +++ b/zeppelin-plugins/launcher/k8s-standard/src/test/java/org/apache/zeppelin/interpreter/launcher/PodPhaseWatcherTest.java @@ -18,14 +18,16 @@ package org.apache.zeppelin.interpreter.launcher; -import static org.junit.Assert.*; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.concurrent.TimeUnit; import org.apache.commons.lang3.StringUtils; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import io.fabric8.kubernetes.api.model.Pod; import io.fabric8.kubernetes.api.model.PodBuilder; @@ -34,17 +36,16 @@ import io.fabric8.kubernetes.api.model.PodStatus; import io.fabric8.kubernetes.api.model.PodStatusBuilder; import io.fabric8.kubernetes.client.KubernetesClient; import io.fabric8.kubernetes.client.Watch; -import io.fabric8.kubernetes.client.server.mock.KubernetesServer; +import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient; -public class PodPhaseWatcherTest { +@EnableKubernetesMockClient(https = false, crud = true) +class PodPhaseWatcherTest { - @Rule - public KubernetesServer server = new KubernetesServer(false, true); + KubernetesClient client; @Test - @Ignore("Reamer - ZEPPELIN-5403") - public void testPhase() throws InterruptedException { - KubernetesClient client = server.getClient(); + @Disabled("Reamer - ZEPPELIN-5403") + void testPhase() throws InterruptedException { // CREATE client.pods().inNamespace("ns1") .create(new PodBuilder().withNewMetadata().withName("pod1").endMetadata().build()); @@ -73,9 +74,8 @@ public class PodPhaseWatcherTest { } @Test - @Ignore("Reamer - ZEPPELIN-5403") - public void testPhaseWithError() throws InterruptedException { - KubernetesClient client = server.getClient(); + @Disabled("Reamer - ZEPPELIN-5403") + void testPhaseWithError() throws InterruptedException { // CREATE client.pods().inNamespace("ns1") .create(new PodBuilder().withNewMetadata().withName("pod1").endMetadata().build()); diff --git a/zeppelin-plugins/notebookrepo/filesystem/src/test/java/org/apache/zeppelin/notebook/repo/FileSystemNotebookRepoTest.java b/zeppelin-plugins/notebookrepo/filesystem/src/test/java/org/apache/zeppelin/notebook/repo/FileSystemNotebookRepoTest.java index ad72a48d68..26cfcf874a 100644 --- a/zeppelin-plugins/notebookrepo/filesystem/src/test/java/org/apache/zeppelin/notebook/repo/FileSystemNotebookRepoTest.java +++ b/zeppelin-plugins/notebookrepo/filesystem/src/test/java/org/apache/zeppelin/notebook/repo/FileSystemNotebookRepoTest.java @@ -26,9 +26,9 @@ import org.apache.zeppelin.conf.ZeppelinConfiguration; import org.apache.zeppelin.notebook.Note; import org.apache.zeppelin.notebook.NoteInfo; import org.apache.zeppelin.user.AuthenticationInfo; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.File; import java.io.IOException; @@ -37,9 +37,9 @@ import java.nio.file.Files; import java.util.HashMap; import java.util.Map; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; -public class FileSystemNotebookRepoTest { +class FileSystemNotebookRepoTest { private ZeppelinConfiguration zConf; private Configuration hadoopConf; @@ -48,8 +48,8 @@ public class FileSystemNotebookRepoTest { private String notebookDir; private AuthenticationInfo authInfo = AuthenticationInfo.ANONYMOUS; - @Before - public void setUp() throws IOException { + @BeforeEach + void setUp() throws IOException { notebookDir = Files.createTempDirectory("FileSystemNotebookRepoTest").toFile().getAbsolutePath(); zConf = ZeppelinConfiguration.create(); System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_DIR.getVarName(), notebookDir); @@ -59,13 +59,13 @@ public class FileSystemNotebookRepoTest { hdfsNotebookRepo.init(zConf); } - @After - public void tearDown() throws IOException { + @AfterEach + void tearDown() throws IOException { FileUtils.deleteDirectory(new File(notebookDir)); } @Test - public void testBasics() throws IOException { + void testBasics() throws IOException { assertEquals(0, hdfsNotebookRepo.list(authInfo).size()); // create a new note @@ -121,7 +121,7 @@ public class FileSystemNotebookRepoTest { } @Test - public void testComplicatedScenarios() throws IOException { + void testComplicatedScenarios() throws IOException { // scenario_1: notebook_dir is not clean. There're some unrecognized dir and file under notebook_dir fs.mkdirs(new Path(notebookDir, "1/2")); OutputStream out = fs.create(new Path(notebookDir, "1/a.json")); diff --git a/zeppelin-plugins/notebookrepo/gcs/pom.xml b/zeppelin-plugins/notebookrepo/gcs/pom.xml index 16e2cbebf7..6f14e94f10 100644 --- a/zeppelin-plugins/notebookrepo/gcs/pom.xml +++ b/zeppelin-plugins/notebookrepo/gcs/pom.xml @@ -139,6 +139,11 @@ </exclusion> </exclusions> </dependency> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-params</artifactId> + <scope>test</scope> + </dependency> </dependencies> diff --git a/zeppelin-plugins/notebookrepo/gcs/src/test/java/org/apache/zeppelin/notebook/repo/GCSNotebookRepoTest.java b/zeppelin-plugins/notebookrepo/gcs/src/test/java/org/apache/zeppelin/notebook/repo/GCSNotebookRepoTest.java index 86c603490d..58d3b88813 100644 --- a/zeppelin-plugins/notebookrepo/gcs/src/test/java/org/apache/zeppelin/notebook/repo/GCSNotebookRepoTest.java +++ b/zeppelin-plugins/notebookrepo/gcs/src/test/java/org/apache/zeppelin/notebook/repo/GCSNotebookRepoTest.java @@ -18,7 +18,8 @@ package org.apache.zeppelin.notebook.repo; import static com.google.common.truth.Truth.assertThat; -import static junit.framework.TestCase.fail; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.fail; import com.google.cloud.storage.BlobId; import com.google.cloud.storage.BlobInfo; @@ -28,10 +29,10 @@ import com.google.common.collect.ImmutableMap; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.stream.Stream; import org.apache.zeppelin.conf.ZeppelinConfiguration; import org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars; @@ -40,52 +41,36 @@ import org.apache.zeppelin.notebook.NoteInfo; import org.apache.zeppelin.notebook.Paragraph; import org.apache.zeppelin.scheduler.Job.Status; import org.apache.zeppelin.user.AuthenticationInfo; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; //TODO(zjffdu) This test fails due to some changes in google, need to fix -@Ignore -@RunWith(Parameterized.class) -public class GCSNotebookRepoTest { +@Disabled +class GCSNotebookRepoTest { private static final AuthenticationInfo AUTH_INFO = AuthenticationInfo.ANONYMOUS; private GCSNotebookRepo notebookRepo; private Storage storage; - @Parameters - public static Collection<Object[]> data() { - return Arrays.asList(new Object[][] { - { "bucketname", Optional.empty(), "gs://bucketname" }, - { "bucketname-with-slash", Optional.empty(), "gs://bucketname-with-slash/" }, - { "bucketname", Optional.of("path/to/dir"), "gs://bucketname/path/to/dir" }, - { "bucketname", Optional.of("trailing/slash"), "gs://bucketname/trailing/slash/" } - }); + private static Stream<Arguments> buckets() { + return Stream.of( + Arguments.of("bucketname", Optional.empty(), "gs://bucketname"), + Arguments.of("bucketname-with-slash", Optional.empty(), "gs://bucketname-with-slash/"), + Arguments.of("bucketname", Optional.of("path/to/dir"), "gs://bucketname/path/to/dir"), + Arguments.of("bucketname", Optional.of("trailing/slash"), "gs://bucketname/trailing/slash/")); } - @Parameter(0) - public String bucketName; - - @Parameter(1) - public Optional<String> basePath; - - @Parameter(2) - public String uriPath; private Note runningNote; - @Before - public void setUp() throws Exception { + @BeforeEach + void setUp() throws Exception { this.runningNote = makeRunningNote(); - this.storage = LocalStorageHelper.getOptions().getService(); - - System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_GCS_STORAGE_DIR.getVarName(), uriPath); - this.notebookRepo = new GCSNotebookRepo(ZeppelinConfiguration.create(), storage); } private static Note makeRunningNote() { @@ -101,19 +86,25 @@ public class GCSNotebookRepoTest { return note; } - @Test - public void testList_nonexistent() throws Exception { + @ParameterizedTest + @MethodSource("buckets") + void testList_nonexistent(String bucketName, Optional<String> basePath, String uriPath) throws Exception { + System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_GCS_STORAGE_DIR.getVarName(), uriPath); + this.notebookRepo = new GCSNotebookRepo(ZeppelinConfiguration.create(), storage); assertThat(notebookRepo.list(AUTH_INFO)).isEmpty(); } - @Test - public void testList() throws Exception { - createAt(runningNote, "note.zpln"); - createAt(runningNote, "/note.zpln"); - createAt(runningNote, "validid/my_12.zpln"); - createAt(runningNote, "validid-2/my_123.zpln"); - createAt(runningNote, "cannot-be-dir/note.json/foo"); - createAt(runningNote, "cannot/be/nested/note.json"); + @ParameterizedTest + @MethodSource("buckets") + void testList(String bucketName, Optional<String> basePath, String uriPath) throws Exception { + System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_GCS_STORAGE_DIR.getVarName(), uriPath); + this.notebookRepo = new GCSNotebookRepo(ZeppelinConfiguration.create(), storage); + createAt(runningNote, "note.zpln", bucketName, basePath); + createAt(runningNote, "/note.zpln", bucketName, basePath); + createAt(runningNote, "validid/my_12.zpln", bucketName, basePath); + createAt(runningNote, "validid-2/my_123.zpln", bucketName, basePath); + createAt(runningNote, "cannot-be-dir/note.json/foo", bucketName, basePath); + createAt(runningNote, "cannot/be/nested/note.json", bucketName, basePath); Map<String, NoteInfo> infos = notebookRepo.list(AUTH_INFO); List<String> noteIds = new ArrayList<>(); @@ -125,16 +116,19 @@ public class GCSNotebookRepoTest { } @Test - public void testGet_nonexistent() throws Exception { + void testGet_nonexistent() throws Exception { try { notebookRepo.get("id", "", AUTH_INFO); fail(); } catch (IOException e) {} } - @Test - public void testGet() throws Exception { - create(runningNote); + @ParameterizedTest + @MethodSource("buckets") + void testGet(String bucketName, Optional<String> basePath, String uriPath) throws Exception { + System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_GCS_STORAGE_DIR.getVarName(), uriPath); + this.notebookRepo = new GCSNotebookRepo(ZeppelinConfiguration.create(), storage); + create(runningNote, bucketName, basePath); // Status of saved running note is removed in get() Note got = notebookRepo.get(runningNote.getId(), runningNote.getPath(), AUTH_INFO); @@ -145,105 +139,131 @@ public class GCSNotebookRepoTest { assertThat(got).isEqualTo(runningNote); } - @Test - public void testGet_malformed() throws Exception { - createMalformed("id", "/name"); + @ParameterizedTest + @MethodSource("buckets") + void testGet_malformed(String bucketName, Optional<String> basePath, String uriPath) throws Exception { + System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_GCS_STORAGE_DIR.getVarName(), uriPath); + this.notebookRepo = new GCSNotebookRepo(ZeppelinConfiguration.create(), storage); + createMalformed("id", "/name", bucketName, basePath); try { notebookRepo.get("id", "/name", AUTH_INFO); fail(); } catch (IOException e) {} } - @Test - public void testSave_create() throws Exception { + @ParameterizedTest + @MethodSource("buckets") + void testSave_create(String bucketName, Optional<String> basePath, String uriPath) throws Exception { + System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_GCS_STORAGE_DIR.getVarName(), uriPath); + this.notebookRepo = new GCSNotebookRepo(ZeppelinConfiguration.create(), storage); notebookRepo.save(runningNote, AUTH_INFO); // Output is saved - assertThat(storage.readAllBytes(makeBlobId(runningNote.getId(), runningNote.getPath()))) + assertThat(storage.readAllBytes(makeBlobId(runningNote.getId(), runningNote.getPath(), bucketName, basePath))) .isEqualTo(runningNote.toJson().getBytes("UTF-8")); } - @Test - public void testSave_update() throws Exception { + @ParameterizedTest + @MethodSource("buckets") + void testSave_update(String bucketName, Optional<String> basePath, String uriPath) throws Exception { + System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_GCS_STORAGE_DIR.getVarName(), uriPath); + this.notebookRepo = new GCSNotebookRepo(ZeppelinConfiguration.create(), storage); notebookRepo.save(runningNote, AUTH_INFO); // Change name of runningNote runningNote.setPath("/new-name"); notebookRepo.save(runningNote, AUTH_INFO); - assertThat(storage.readAllBytes(makeBlobId(runningNote.getId(), runningNote.getPath()))) + assertThat(storage.readAllBytes(makeBlobId(runningNote.getId(), runningNote.getPath(), bucketName, basePath))) .isEqualTo(runningNote.toJson().getBytes("UTF-8")); } @Test - public void testRemove_nonexistent() throws Exception { + void testRemove_nonexistent() throws Exception { try { notebookRepo.remove("id", "/name", AUTH_INFO); fail(); } catch (IOException e) {} } - @Test - public void testRemove() throws Exception { - create(runningNote); + @ParameterizedTest + @MethodSource("buckets") + void testRemove(String bucketName, Optional<String> basePath, String uriPath) throws Exception { + System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_GCS_STORAGE_DIR.getVarName(), uriPath); + this.notebookRepo = new GCSNotebookRepo(ZeppelinConfiguration.create(), storage); + create(runningNote, bucketName, basePath); notebookRepo.remove(runningNote.getId(), runningNote.getPath(), AUTH_INFO); - assertThat(storage.get(makeBlobId(runningNote.getId(), runningNote.getPath()))).isNull(); + assertThat(storage.get(makeBlobId(runningNote.getId(), runningNote.getPath(), bucketName, basePath))).isNull(); } - @Test(expected = IOException.class) - public void testRemoveFolder_nonexistent() throws Exception { - notebookRepo.remove("id", "/name", AUTH_INFO); - fail(); + @Test + void testRemoveFolder_nonexistent() throws Exception { + assertThrows(IOException.class, () -> { + notebookRepo.remove("id", "/name", AUTH_INFO); + fail(); + }); + } - @Test - public void testRemoveFolder() throws Exception { + @ParameterizedTest + @MethodSource("buckets") + void testRemoveFolder(String bucketName, Optional<String> basePath, String uriPath) throws Exception { + System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_GCS_STORAGE_DIR.getVarName(), uriPath); + this.notebookRepo = new GCSNotebookRepo(ZeppelinConfiguration.create(), storage); Note firstNote = makeRunningNote(); firstNote.setPath("/folder/test_note"); - create(firstNote); + create(firstNote, bucketName, basePath); Note secondNote = makeRunningNote(); secondNote.setPath("/folder/sub_folder/test_note_second"); - create(secondNote); + create(secondNote, bucketName, basePath); notebookRepo.remove("/folder", AUTH_INFO); - assertThat(storage.get(makeBlobId(firstNote.getId(), firstNote.getPath()))).isNull(); - assertThat(storage.get(makeBlobId(secondNote.getId(), secondNote.getPath()))).isNull(); + assertThat(storage.get(makeBlobId(firstNote.getId(), firstNote.getPath(), bucketName, basePath))).isNull(); + assertThat(storage.get(makeBlobId(secondNote.getId(), secondNote.getPath(), bucketName, basePath))).isNull(); } @Test - public void testMove_nonexistent() { + void testMove_nonexistent() { try { notebookRepo.move("id", "/name", "/name_new", AUTH_INFO); fail(); } catch (IOException e) {} } - @Test - public void testMove() throws Exception { - create(runningNote); + @ParameterizedTest + @MethodSource("buckets") + void testMove(String bucketName, Optional<String> basePath, String uriPath) throws Exception { + System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_GCS_STORAGE_DIR.getVarName(), uriPath); + this.notebookRepo = new GCSNotebookRepo(ZeppelinConfiguration.create(), storage); + create(runningNote, bucketName, basePath); notebookRepo.move(runningNote.getId(), runningNote.getPath(), runningNote.getPath() + "_new", AUTH_INFO); - assertThat(storage.get(makeBlobId(runningNote.getId(), runningNote.getPath()))).isNull(); + assertThat(storage.get(makeBlobId(runningNote.getId(), runningNote.getPath(), bucketName, basePath))).isNull(); } - @Test(expected = IOException.class) - public void testMoveFolder_nonexistent() throws Exception { - notebookRepo.move("/name", "/name_new", AUTH_INFO); - fail(); + @Test + void testMoveFolder_nonexistent() throws Exception { + assertThrows(IOException.class, () -> { + notebookRepo.move("/name", "/name_new", AUTH_INFO); + fail(); + }); } - @Test - public void testMoveFolder() throws Exception { + @ParameterizedTest + @MethodSource("buckets") + void testMoveFolder(String bucketName, Optional<String> basePath, String uriPath) throws Exception { + System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_GCS_STORAGE_DIR.getVarName(), uriPath); + this.notebookRepo = new GCSNotebookRepo(ZeppelinConfiguration.create(), storage); Note firstNote = makeRunningNote(); firstNote.setPath("/folder/test_note"); - create(firstNote); + create(firstNote, bucketName, basePath); Note secondNote = makeRunningNote(); secondNote.setPath("/folder/sub_folder/test_note_second"); - create(secondNote); + create(secondNote, bucketName, basePath); notebookRepo.move("/folder", "/folder_new", AUTH_INFO); - assertThat(storage.get(makeBlobId(firstNote.getId(), firstNote.getPath()))).isNull(); - assertThat(storage.get(makeBlobId(firstNote.getId(), "/folder_new/test_note"))).isNotNull(); - assertThat(storage.get(makeBlobId(secondNote.getId(), secondNote.getPath()))).isNull(); - assertThat(storage.get(makeBlobId(secondNote.getId(), "/folder_new/sub_folder/test_note_second"))).isNotNull(); + assertThat(storage.get(makeBlobId(firstNote.getId(), firstNote.getPath(), bucketName, basePath))).isNull(); + assertThat(storage.get(makeBlobId(firstNote.getId(), "/folder_new/test_note", bucketName, basePath))).isNotNull(); + assertThat(storage.get(makeBlobId(secondNote.getId(), secondNote.getPath(), bucketName, basePath))).isNull(); + assertThat(storage.get(makeBlobId(secondNote.getId(), "/folder_new/sub_folder/test_note_second", bucketName, basePath))).isNotNull(); } - private String makeName(String relativePath) { + private String makeName(String relativePath, Optional<String> basePath) { if (basePath.isPresent()) { return basePath.get() + "/" + relativePath; } else { @@ -251,7 +271,7 @@ public class GCSNotebookRepoTest { } } - private BlobId makeBlobId(String noteId, String notePath) { + private BlobId makeBlobId(String noteId, String notePath, String bucketName, Optional<String> basePath) { if (basePath.isPresent()) { return BlobId.of(bucketName, basePath.get() + notePath + "_" + noteId +".zpln"); } else { @@ -259,21 +279,21 @@ public class GCSNotebookRepoTest { } } - private void createAt(Note note, String relativePath) throws IOException { - BlobId id = BlobId.of(bucketName, makeName(relativePath)); + private void createAt(Note note, String relativePath, String bucketName, Optional<String> basePath) throws IOException { + BlobId id = BlobId.of(bucketName, makeName(relativePath, basePath)); BlobInfo info = BlobInfo.newBuilder(id).setContentType("application/json").build(); storage.create(info, note.toJson().getBytes("UTF-8")); } - private void create(Note note) throws IOException { - BlobInfo info = BlobInfo.newBuilder(makeBlobId(note.getId(), note.getPath())) + private void create(Note note, String bucketName, Optional<String> basePath) throws IOException { + BlobInfo info = BlobInfo.newBuilder(makeBlobId(note.getId(), note.getPath(), bucketName, basePath)) .setContentType("application/json") .build(); storage.create(info, note.toJson().getBytes("UTF-8")); } - private void createMalformed(String noteId, String notePath) throws IOException { - BlobInfo info = BlobInfo.newBuilder(makeBlobId(noteId, notePath)) + private void createMalformed(String noteId, String notePath, String bucketName, Optional<String> basePath) throws IOException { + BlobInfo info = BlobInfo.newBuilder(makeBlobId(noteId, notePath, bucketName, basePath)) .setContentType("application/json") .build(); storage.create(info, "{ invalid-json }".getBytes("UTF-8")); @@ -282,7 +302,7 @@ public class GCSNotebookRepoTest { /* These tests test path parsing for illegal paths, and do not use the parameterized vars */ @Test - public void testInitialization_pathNotSet() throws Exception { + void testInitialization_pathNotSet() throws Exception { try { System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_GCS_STORAGE_DIR.getVarName(), ""); new GCSNotebookRepo(ZeppelinConfiguration.create(), storage); @@ -291,7 +311,7 @@ public class GCSNotebookRepoTest { } @Test - public void testInitialization_malformedPath() throws Exception { + void testInitialization_malformedPath() throws Exception { try { System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_GCS_STORAGE_DIR.getVarName(), "foo"); new GCSNotebookRepo(ZeppelinConfiguration.create(), storage); diff --git a/zeppelin-plugins/notebookrepo/github/src/test/java/org/apache/zeppelin/notebook/repo/GitHubNotebookRepoTest.java b/zeppelin-plugins/notebookrepo/github/src/test/java/org/apache/zeppelin/notebook/repo/GitHubNotebookRepoTest.java index 953dcdadb2..dd19e902dc 100644 --- a/zeppelin-plugins/notebookrepo/github/src/test/java/org/apache/zeppelin/notebook/repo/GitHubNotebookRepoTest.java +++ b/zeppelin-plugins/notebookrepo/github/src/test/java/org/apache/zeppelin/notebook/repo/GitHubNotebookRepoTest.java @@ -30,9 +30,9 @@ import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.internal.storage.file.FileRepository; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.revwalk.RevCommit; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -40,6 +40,7 @@ import java.io.File; import java.io.IOException; import java.util.Iterator; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; /** @@ -48,7 +49,7 @@ import static org.mockito.Mockito.mock; * 1. The first repository is considered as a remote that mimics a remote GitHub directory * 2. The second repository is considered as the local notebook repository */ -public class GitHubNotebookRepoTest { +class GitHubNotebookRepoTest { private static final Logger LOG = LoggerFactory.getLogger(GitHubNotebookRepoTest.class); private static final String TEST_NOTE_ID = "2A94M5J1Z"; @@ -63,8 +64,8 @@ public class GitHubNotebookRepoTest { private RevCommit firstCommitRevision; private Git remoteGit; - @Before - public void setUp() throws Exception { + @BeforeEach + void setUp() throws Exception { conf = ZeppelinConfiguration.create(); String remoteRepositoryPath = System.getProperty("java.io.tmpdir") + "/ZeppelinTestRemote_" + @@ -118,8 +119,8 @@ public class GitHubNotebookRepoTest { gitHubNotebookRepo.init(conf); } - @After - public void tearDown() throws Exception { + @AfterEach + void tearDown() throws Exception { // Cleanup the temporary folders uses as Git repositories File[] temporaryFolders = { remoteZeppelinDir, localZeppelinDir }; @@ -133,10 +134,10 @@ public class GitHubNotebookRepoTest { /** * Test the case when the Notebook repository is created, it pulls the latest changes from the remote repository */ - public void pullChangesFromRemoteRepositoryOnLoadingNotebook() throws IOException, GitAPIException { + void pullChangesFromRemoteRepositoryOnLoadingNotebook() throws IOException, GitAPIException { NotebookRepoWithVersionControl.Revision firstHistoryRevision = gitHubNotebookRepo.revisionHistory(TEST_NOTE_ID, TEST_NOTE_PATH, null).get(0); - assert(this.firstCommitRevision.getName().equals(firstHistoryRevision.id)); + assertEquals(this.firstCommitRevision.getName(), firstHistoryRevision.id); } @Test @@ -144,7 +145,7 @@ public class GitHubNotebookRepoTest { * Test the case when the check-pointing (add new files and commit) it also pulls the latest changes from the * remote repository */ - public void pullChangesFromRemoteRepositoryOnCheckpointing() throws GitAPIException, IOException { + void pullChangesFromRemoteRepositoryOnCheckpointing() throws GitAPIException, IOException { // Create a new commit in the remote repository RevCommit secondCommitRevision = remoteGit.commit().setMessage("Second commit from remote repository").call(); @@ -175,7 +176,7 @@ public class GitHubNotebookRepoTest { * Test the case when the check-pointing (add new files and commit) it pushes the local commits to the remote * repository */ - public void pushLocalChangesToRemoteRepositoryOnCheckpointing() throws IOException, GitAPIException { + void pushLocalChangesToRemoteRepositoryOnCheckpointing() throws IOException, GitAPIException { // Add a new paragraph to the local repository addParagraphToNotebook(); diff --git a/zeppelin-plugins/notebookrepo/mongo/pom.xml b/zeppelin-plugins/notebookrepo/mongo/pom.xml index 988348b78f..d428e35072 100644 --- a/zeppelin-plugins/notebookrepo/mongo/pom.xml +++ b/zeppelin-plugins/notebookrepo/mongo/pom.xml @@ -61,6 +61,11 @@ </exclusion> </exclusions> </dependency> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-params</artifactId> + <scope>test</scope> + </dependency> </dependencies> <build> diff --git a/zeppelin-plugins/notebookrepo/mongo/src/test/java/org/apache/zeppelin/notebook/repo/MongoNotebookRepoTest.java b/zeppelin-plugins/notebookrepo/mongo/src/test/java/org/apache/zeppelin/notebook/repo/MongoNotebookRepoTest.java index 9b507368f6..d3cc370100 100644 --- a/zeppelin-plugins/notebookrepo/mongo/src/test/java/org/apache/zeppelin/notebook/repo/MongoNotebookRepoTest.java +++ b/zeppelin-plugins/notebookrepo/mongo/src/test/java/org/apache/zeppelin/notebook/repo/MongoNotebookRepoTest.java @@ -18,11 +18,8 @@ package org.apache.zeppelin.notebook.repo; import static org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_MONGO_URI; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; import java.io.IOException; import java.net.ServerSocket; import java.util.Map; @@ -37,8 +34,11 @@ import org.apache.zeppelin.notebook.Note; import org.apache.zeppelin.notebook.NoteInfo; import org.apache.zeppelin.notebook.Paragraph; import org.apache.zeppelin.user.AuthenticationInfo; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -public class MongoNotebookRepoTest { +class MongoNotebookRepoTest { private MongodExecutable mongodExecutable; @@ -46,8 +46,8 @@ public class MongoNotebookRepoTest { private MongoNotebookRepo notebookRepo; - @Before - public void setUp() throws IOException { + @BeforeEach + void setUp() throws IOException { String bindIp = "localhost"; ServerSocket socket = new ServerSocket(0); int port = socket.getLocalPort(); @@ -68,15 +68,15 @@ public class MongoNotebookRepoTest { notebookRepo.init(zConf); } - @After - public void tearDown() throws IOException { + @AfterEach + void tearDown() throws IOException { if (mongodExecutable != null) { mongodExecutable.stop(); } } @Test - public void testBasics() throws IOException { + void testBasics() throws IOException { assertEquals(0, notebookRepo.list(AuthenticationInfo.ANONYMOUS).size()); // create note1 @@ -128,7 +128,7 @@ public class MongoNotebookRepoTest { } @Test - public void testGetNotePath() throws IOException { + void testGetNotePath() throws IOException { assertEquals(0, notebookRepo.list(AuthenticationInfo.ANONYMOUS).size()); Note note = new Note(); diff --git a/zeppelin-plugins/notebookrepo/mongo/src/test/java/org/apache/zeppelin/notebook/repo/ToPathArrayTest.java b/zeppelin-plugins/notebookrepo/mongo/src/test/java/org/apache/zeppelin/notebook/repo/ToPathArrayTest.java index 5796c495ef..b1ad61a24a 100644 --- a/zeppelin-plugins/notebookrepo/mongo/src/test/java/org/apache/zeppelin/notebook/repo/ToPathArrayTest.java +++ b/zeppelin-plugins/notebookrepo/mongo/src/test/java/org/apache/zeppelin/notebook/repo/ToPathArrayTest.java @@ -17,84 +17,68 @@ package org.apache.zeppelin.notebook.repo; -import static org.junit.Assert.assertArrayEquals; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import java.util.Arrays; -import java.util.Collection; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import java.util.stream.Stream; -@RunWith(Parameterized.class) -public class ToPathArrayTest { - @Rule - public ExpectedException thrown = ExpectedException.none(); +class ToPathArrayTest { private MongoNotebookRepo repo = new MongoNotebookRepo(); - private String pathStr; - - private boolean includeLast; - - private String[] expactPathArray; - - public ToPathArrayTest(String pathStr, boolean includeLast, String[] expactPathArray) { - this.pathStr = pathStr; - this.includeLast = includeLast; - this.expactPathArray = expactPathArray; + private static Stream<Arguments> data() { + return Stream.of( + Arguments.of(null, true, null), + Arguments.of(null, false, null), + Arguments.of("", true, null), + Arguments.of("", false, null), + Arguments.of("/", true, new String[0]), + Arguments.of("/", false, new String[0]), + + Arguments.of("/abc", true, new String[] { "abc" }), + Arguments.of("/abc/", true, new String[] { "abc" }), + Arguments.of("/a/b/c", true, new String[] { "a", "b", "c" }), + Arguments.of("/a/b//c/", true, new String[] { "a", "b", "c" }), + + Arguments.of("/abc", false, new String[] {}), + Arguments.of("/abc/", false, new String[] {}), + Arguments.of("/a/b/c", false, new String[] { "a", "b" }), + Arguments.of("/a/b//c/", false, new String[] { "a", "b" }), + + Arguments.of("abc", true, new String[] { "abc" }), + Arguments.of("abc/", true, new String[] { "abc" }), + Arguments.of("a/b/c", true, new String[] { "a", "b", "c" }), + Arguments.of("a/b//c/", true, new String[] { "a", "b", "c" }), + + Arguments.of("abc", false, new String[] {}), + Arguments.of("abc/", false, new String[] {}), + Arguments.of("a/b/c", false, new String[] { "a", "b" }), + Arguments.of("a/b//c/", false, new String[] { "a", "b" })); } - @Parameterized.Parameters - public static Collection params() { - Object[][] arrs = { - {null, true, null}, - {null, false, null}, - {"", true, null}, - {"", false, null}, - {"/", true, new String[0]}, - {"/", false, new String[0]}, - - {"/abc", true, new String[]{"abc"}}, - {"/abc/", true, new String[]{"abc"}}, - {"/a/b/c", true, new String[]{"a", "b", "c"}}, - {"/a/b//c/", true, new String[]{"a", "b", "c"}}, - - {"/abc", false, new String[]{}}, - {"/abc/", false, new String[]{}}, - {"/a/b/c", false, new String[]{"a", "b"}}, - {"/a/b//c/", false, new String[]{"a", "b"}}, - - {"abc", true, new String[]{"abc"}}, - {"abc/", true, new String[]{"abc"}}, - {"a/b/c", true, new String[]{"a", "b", "c"}}, - {"a/b//c/", true, new String[]{"a", "b", "c"}}, - - {"abc", false, new String[]{}}, - {"abc/", false, new String[]{}}, - {"a/b/c", false, new String[]{"a", "b"}}, - {"a/b//c/", false, new String[]{"a", "b"}}, - }; - return Arrays.asList(arrs); - } - @Test - public void runTest() { + @ParameterizedTest + @MethodSource("data") + void runTest(String pathStr, boolean includeLast, String[] expactPathArray) { if (expactPathArray == null) { - runForThrow(); + runForThrow(pathStr, includeLast, expactPathArray); } else { - runNormally(); + runNormally(pathStr, includeLast, expactPathArray); } } - private void runForThrow() { - thrown.expect(NullPointerException.class); - runNormally(); + private void runForThrow(String pathStr, boolean includeLast, String[] expactPathArray) { + assertThrows(NullPointerException.class, () -> { + runNormally(pathStr, includeLast, expactPathArray); + }); + } - private void runNormally() { + private void runNormally(String pathStr, boolean includeLast, String[] expactPathArray) { String[] pathArray = repo.toPathArray(pathStr, includeLast); assertArrayEquals(expactPathArray, pathArray); } diff --git a/zeppelin-plugins/notebookrepo/oss/src/test/java/org/apache/zeppelin/notebook/repo/OSSNotebookRepoTest.java b/zeppelin-plugins/notebookrepo/oss/src/test/java/org/apache/zeppelin/notebook/repo/OSSNotebookRepoTest.java index a84598d0aa..0de6ff0a19 100644 --- a/zeppelin-plugins/notebookrepo/oss/src/test/java/org/apache/zeppelin/notebook/repo/OSSNotebookRepoTest.java +++ b/zeppelin-plugins/notebookrepo/oss/src/test/java/org/apache/zeppelin/notebook/repo/OSSNotebookRepoTest.java @@ -24,19 +24,20 @@ import org.apache.zeppelin.notebook.Paragraph; import org.apache.zeppelin.notebook.repo.storage.RemoteStorageOperator; import org.apache.zeppelin.scheduler.Job; import org.apache.zeppelin.user.AuthenticationInfo; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Map; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; -public class OSSNotebookRepoTest { +class OSSNotebookRepoTest { private AuthenticationInfo anonymous = AuthenticationInfo.ANONYMOUS; private OSSNotebookRepo notebookRepo; @@ -46,8 +47,8 @@ public class OSSNotebookRepoTest { - @Before - public void setUp() throws IOException { + @BeforeEach + void setUp() throws IOException { bucket = "zeppelin-test-bucket"; String endpoint = "yourEndpoint"; String accessKeyId = "yourAccessKeyId"; @@ -70,8 +71,8 @@ public class OSSNotebookRepoTest { notebookRepo.setOssOperator(ossOperator); } - @After - public void tearDown() throws InterruptedException, IOException { + @AfterEach + void tearDown() throws InterruptedException, IOException { ossOperator.deleteDir(bucket, ""); ossOperator.deleteBucket(bucket); // The delete operations on OSS Service above has a delay. @@ -85,7 +86,7 @@ public class OSSNotebookRepoTest { } @Test - public void testNotebookRepo() throws IOException { + void testNotebookRepo() throws IOException { Map<String, NoteInfo> notesInfo = notebookRepo.list(anonymous); assertEquals(0, notesInfo.size()); @@ -118,7 +119,7 @@ public class OSSNotebookRepoTest { notebookRepo.get("invalid_id", "/invalid_path", anonymous); fail("Should fail to get non-existed note1"); } catch (IOException e) { - assertEquals(e.getMessage(), "Note or its revision not found"); + assertEquals("Note or its revision not found", e.getMessage()); } // create another Note note2 @@ -161,7 +162,7 @@ public class OSSNotebookRepoTest { @Test - public void testNotebookRepoWithVersionControl() throws IOException { + void testNotebookRepoWithVersionControl() throws IOException { Map<String, NoteInfo> notesInfo = notebookRepo.list(anonymous); assertEquals(0, notesInfo.size()); @@ -198,7 +199,7 @@ public class OSSNotebookRepoTest { notebookRepo.get(note1.getId(), note1.getPath(), revisionList.get(i - 1).id, anonymous); fail("Should fail to get non-existed note1"); } catch (IOException e) { - assertEquals(e.getMessage(), "Note or its revision not found"); + assertEquals("Note or its revision not found", e.getMessage()); } } diff --git a/zeppelin-plugins/notebookrepo/s3/pom.xml b/zeppelin-plugins/notebookrepo/s3/pom.xml index 3d102055b1..2d45c9398e 100644 --- a/zeppelin-plugins/notebookrepo/s3/pom.xml +++ b/zeppelin-plugins/notebookrepo/s3/pom.xml @@ -36,6 +36,7 @@ <properties> <aws.sdk.version>1.12.261</aws.sdk.version> <plugin.name>NotebookRepo/S3NotebookRepo</plugin.name> + <jackson.version>2.12.6</jackson.version> </properties> <dependencyManagement> @@ -46,7 +47,7 @@ <dependency> <groupId>com.fasterxml.jackson.dataformat</groupId> <artifactId>jackson-dataformat-cbor</artifactId> - <version>2.12.6</version> + <version>${jackson.version}</version> <exclusions> <exclusion> <groupId>com.fasterxml.jackson.core</groupId> @@ -54,6 +55,27 @@ </exclusion> </exclusions> </dependency> + <dependency> + <groupId>com.fasterxml.jackson.dataformat</groupId> + <artifactId>jackson-dataformat-xml</artifactId> + <version>${jackson.version}</version> + <exclusions> + <exclusion> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-databind</artifactId> + </exclusion> + </exclusions> + </dependency> + <!-- Fix enforcer plugin for hadoop2 + Can be removed when hadoop2 is removed. + hadoop2 ships with a very old version. + Keep the version in sync with s3proxy test dependency + --> + <dependency> + <groupId>com.google.inject</groupId> + <artifactId>guice</artifactId> + <version>5.0.1</version> + </dependency> </dependencies> </dependencyManagement> <dependencies> @@ -90,7 +112,7 @@ <dependency> <groupId>org.gaul</groupId> <artifactId>s3proxy</artifactId> - <version>1.7.1</version> + <version>2.0.0</version> <scope>test</scope> <exclusions> <exclusion> @@ -113,10 +135,6 @@ <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> </exclusion> - <exclusion> - <groupId>com.fasterxml.jackson.dataformat</groupId> - <artifactId>jackson-dataformat-xml</artifactId> - </exclusion> <exclusion> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-util</artifactId> @@ -137,6 +155,14 @@ <groupId>com.google.code.findbugs</groupId> <artifactId>jsr305</artifactId> </exclusion> + <exclusion> + <groupId>javax.annotation</groupId> + <artifactId>javax.annotation-api</artifactId> + </exclusion> + <exclusion> + <groupId>jakarta.xml.bind</groupId> + <artifactId>jakarta.xml.bind-api</artifactId> + </exclusion> </exclusions> </dependency> </dependencies> diff --git a/zeppelin-plugins/notebookrepo/s3/src/test/java/org/apache/zeppelin/notebook/repo/S3NotebookRepoTest.java b/zeppelin-plugins/notebookrepo/s3/src/test/java/org/apache/zeppelin/notebook/repo/S3NotebookRepoTest.java index e5562caed1..3c31329af6 100644 --- a/zeppelin-plugins/notebookrepo/s3/src/test/java/org/apache/zeppelin/notebook/repo/S3NotebookRepoTest.java +++ b/zeppelin-plugins/notebookrepo/s3/src/test/java/org/apache/zeppelin/notebook/repo/S3NotebookRepoTest.java @@ -27,32 +27,32 @@ import org.apache.zeppelin.conf.ZeppelinConfiguration; import org.apache.zeppelin.notebook.Note; import org.apache.zeppelin.notebook.NoteInfo; import org.apache.zeppelin.user.AuthenticationInfo; -import org.gaul.s3proxy.junit.S3ProxyRule; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.gaul.s3proxy.junit.S3ProxyExtension; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import java.io.IOException; import java.util.Map; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; -public class S3NotebookRepoTest { +class S3NotebookRepoTest { private AuthenticationInfo anonymous = AuthenticationInfo.ANONYMOUS; private S3NotebookRepo notebookRepo; - @Rule - public S3ProxyRule s3Proxy = S3ProxyRule.builder() - .withCredentials("access", "secret") - .build(); + @RegisterExtension + static S3ProxyExtension s3Proxy = S3ProxyExtension.builder() + .withCredentials("access", "secret") + .build(); - @Before - public void setUp() throws IOException { + @BeforeEach + void setUp() throws IOException { String bucket = "test-bucket"; notebookRepo = new S3NotebookRepo(); ZeppelinConfiguration conf = ZeppelinConfiguration.create(); @@ -79,20 +79,20 @@ public class S3NotebookRepoTest { s3Client.createBucket(bucket); } - @After - public void tearDown() { + @AfterEach + void tearDown() { if (notebookRepo != null) { notebookRepo.close(); } } @Test - public void testAwsSTSLibraryOnClassPath() throws ClassNotFoundException { - Class.forName("com.amazonaws.auth.STSSessionCredentialsProvider", false, getClass().getClassLoader()); + void testAwsSTSLibraryOnClassPath() throws ClassNotFoundException { + assertNotNull(Class.forName("com.amazonaws.auth.STSSessionCredentialsProvider", false, getClass().getClassLoader())); } @Test - public void testNotebookRepo() throws IOException { + void testNotebookRepo() throws IOException { Map<String, NoteInfo> notesInfo = notebookRepo.list(anonymous); assertEquals(0, notesInfo.size()); diff --git a/zeppelin-plugins/pom.xml b/zeppelin-plugins/pom.xml index d894a3c804..6f6c11a2f1 100644 --- a/zeppelin-plugins/pom.xml +++ b/zeppelin-plugins/pom.xml @@ -78,12 +78,6 @@ <scope>test</scope> </dependency> - <dependency> - <groupId>org.junit.vintage</groupId> - <artifactId>junit-vintage-engine</artifactId> - <scope>test</scope> - </dependency> - <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-core</artifactId>