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

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


The following commit(s) were added to refs/heads/master by this push:
     new fe5f5504d0 HDDS-9490. Migrate tests in ozone-tools to JUnit5 (#5531)
fe5f5504d0 is described below

commit fe5f5504d0aad434ea5bdbec75ab88499bdc111e
Author: Raju Balpande <[email protected]>
AuthorDate: Tue Nov 7 15:18:52 2023 +0530

    HDDS-9490. Migrate tests in ozone-tools to JUnit5 (#5531)
---
 hadoop-ozone/tools/pom.xml                         |  5 ++
 .../hadoop/ozone/audit/parser/TestAuditParser.java | 33 +++++++------
 .../hadoop/ozone/checknative/TestCheckNative.java  | 17 ++++---
 .../hadoop/ozone/conf/TestGetConfOptions.java      | 29 +++++------
 .../ozone/debug/TestDBDefinitionFactory.java       |  5 +-
 .../hadoop/ozone/freon/TestContentGenerator.java   | 15 +++---
 .../apache/hadoop/ozone/freon/TestProgressBar.java | 13 +++--
 .../containergenerator/TestGeneratorDatanode.java  |  6 +--
 .../TestGenerateOzoneRequiredConfigurations.java   | 40 ++++++++--------
 .../shell/TestOzoneAddressClientCreation.java      | 56 +++++++++++-----------
 10 files changed, 112 insertions(+), 107 deletions(-)

diff --git a/hadoop-ozone/tools/pom.xml b/hadoop-ozone/tools/pom.xml
index 7a9fafc20f..118474827f 100644
--- a/hadoop-ozone/tools/pom.xml
+++ b/hadoop-ozone/tools/pom.xml
@@ -126,6 +126,11 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd";>
       <artifactId>junit-jupiter-params</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-junit-jupiter</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
   <build>
     <plugins>
diff --git 
a/hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/audit/parser/TestAuditParser.java
 
b/hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/audit/parser/TestAuditParser.java
index 36aa75a748..99406fec0f 100644
--- 
a/hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/audit/parser/TestAuditParser.java
+++ 
b/hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/audit/parser/TestAuditParser.java
@@ -19,12 +19,14 @@ package org.apache.hadoop.ozone.audit.parser;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang3.RandomStringUtils;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import picocli.CommandLine;
@@ -43,8 +45,6 @@ import java.util.Arrays;
 import java.util.List;
 
 import static java.nio.charset.StandardCharsets.UTF_8;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 /**
  * Tests AuditParser.
@@ -71,7 +71,7 @@ public class TestAuditParser {
    *
    * @throws Exception In case of exception while creating output directory.
    */
-  @BeforeClass
+  @BeforeAll
   public static void init() throws Exception {
     outputBaseDir = getRandomTempDir();
     dbName = getRandomTempDir() + "/testAudit.db";
@@ -80,13 +80,13 @@ public class TestAuditParser {
     execute(args, "");
   }
 
-  @Before
+  @BeforeEach
   public void setup() throws UnsupportedEncodingException {
     System.setOut(new PrintStream(OUT, false, DEFAULT_CODING));
     System.setErr(new PrintStream(err, false, DEFAULT_CODING));
   }
 
-  @After
+  @AfterEach
   public void reset() {
     // reset stream after each unit test
     OUT.reset();
@@ -100,7 +100,7 @@ public class TestAuditParser {
   /**
    * Cleans up the output base directory.
    */
-  @AfterClass
+  @AfterAll
   public static void cleanup() throws IOException {
     FileUtils.deleteDirectory(outputBaseDir);
   }
@@ -128,9 +128,8 @@ public class TestAuditParser {
         exceptionHandler, args);
     try {
       String output = OUT.toString(DEFAULT_CODING);
-      Assert.assertTrue(
-          "Output:\n" + output + "\nshould contain:\n" + msg,
-          output.contains(msg));
+      assertTrue(output.contains(msg),
+          "Output:\n" + output + "\nshould contain:\n" + msg);
     } catch (UnsupportedEncodingException ignored) {
     }
   }
@@ -193,8 +192,8 @@ public class TestAuditParser {
       execute(args1, "");
       fail("No exception thrown.");
     } catch (Exception e) {
-      assertTrue(e.getMessage()
-          .contains("java.lang.ArrayIndexOutOfBoundsException: 5"));
+      assertTrue(e.getCause() instanceof ArrayIndexOutOfBoundsException);
+      assertTrue(e.getMessage().contains(": 5"));
     }
   }
 
diff --git 
a/hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/checknative/TestCheckNative.java
 
b/hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/checknative/TestCheckNative.java
index 0aff651367..f53ecca912 100644
--- 
a/hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/checknative/TestCheckNative.java
+++ 
b/hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/checknative/TestCheckNative.java
@@ -19,17 +19,16 @@
 package org.apache.hadoop.ozone.checknative;
 
 import org.apache.hadoop.ozone.shell.checknative.CheckNative;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Test;
 import java.io.ByteArrayOutputStream;
 import java.io.PrintStream;
 import java.io.UnsupportedEncodingException;
 
 import static java.nio.charset.StandardCharsets.UTF_8;
-import static org.junit.Assert.assertTrue;
 
 /**
  * Tests for {@link CheckNative}.
@@ -41,7 +40,7 @@ public class TestCheckNative {
 
   private static final String DEFAULT_ENCODING = UTF_8.name();
 
-  @BeforeClass
+  @BeforeAll
   public static void init() throws UnsupportedEncodingException {
     psBackup = System.out;
     outputStream = new ByteArrayOutputStream();
@@ -62,12 +61,12 @@ public class TestCheckNative {
     assertTrue(stdOut.contains("ISA-L: false"));
   }
 
-  @After
+  @AfterEach
   public void setUp() {
     outputStream.reset();
   }
 
-  @AfterClass
+  @AfterAll
   public static void tearDown() {
     System.setOut(psBackup);
   }
diff --git 
a/hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/conf/TestGetConfOptions.java
 
b/hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/conf/TestGetConfOptions.java
index ef692c960c..4f7233f148 100644
--- 
a/hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/conf/TestGetConfOptions.java
+++ 
b/hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/conf/TestGetConfOptions.java
@@ -20,11 +20,12 @@ package org.apache.hadoop.ozone.conf;
 import org.apache.hadoop.hdds.conf.OzoneConfiguration;
 import org.apache.hadoop.hdds.scm.ScmConfigKeys;
 import org.apache.hadoop.ozone.om.OMConfigKeys;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Test;
 
 import java.io.ByteArrayOutputStream;
 import java.io.PrintStream;
@@ -41,7 +42,7 @@ public class TestGetConfOptions {
   private static PrintStream psBackup;
   private static final String DEFAULT_ENCODING = UTF_8.name();
 
-  @BeforeClass
+  @BeforeAll
   public static void init() throws UnsupportedEncodingException {
     conf = new OzoneConfiguration();
     conf.set(OMConfigKeys.OZONE_OM_NODE_ID_KEY, "1");
@@ -53,12 +54,12 @@ public class TestGetConfOptions {
     System.setOut(psOut);
   }
 
-  @After
+  @AfterEach
   public void setUp() {
     bout.reset();
   }
 
-  @AfterClass
+  @AfterAll
   public static void tearDown() {
     System.setOut(psBackup);
   }
@@ -68,30 +69,30 @@ public class TestGetConfOptions {
       throws UnsupportedEncodingException {
     new OzoneGetConf(conf)
         .run(new String[] {"-confKey", ScmConfigKeys.OZONE_SCM_NAMES});
-    Assert.assertEquals("localhost\n", bout.toString(DEFAULT_ENCODING));
+    assertEquals("localhost\n", bout.toString(DEFAULT_ENCODING));
     bout.reset();
     new OzoneGetConf(conf)
         .run(new String[] {"confKey", OMConfigKeys.OZONE_OM_NODE_ID_KEY});
-    Assert.assertEquals("1\n", bout.toString(DEFAULT_ENCODING));
+    assertEquals("1\n", bout.toString(DEFAULT_ENCODING));
   }
 
   @Test
   public void testGetConfWithTheOptionStorageContainerManagers()
       throws UnsupportedEncodingException {
     new OzoneGetConf(conf).run(new String[] {"-storagecontainermanagers"});
-    Assert.assertEquals("localhost\n", bout.toString(DEFAULT_ENCODING));
+    assertEquals("localhost\n", bout.toString(DEFAULT_ENCODING));
     bout.reset();
     new OzoneGetConf(conf).run(new String[] {"storagecontainermanagers"});
-    Assert.assertEquals("localhost\n", bout.toString(DEFAULT_ENCODING));
+    assertEquals("localhost\n", bout.toString(DEFAULT_ENCODING));
   }
 
   @Test
   public void testGetConfWithTheOptionOzoneManagers()
       throws UnsupportedEncodingException {
     new OzoneGetConf(conf).run(new String[] {"-ozonemanagers"});
-    Assert.assertEquals("", bout.toString(DEFAULT_ENCODING));
+    assertEquals("", bout.toString(DEFAULT_ENCODING));
     bout.reset();
     new OzoneGetConf(conf).run(new String[] {"ozonemanagers"});
-    Assert.assertEquals("", bout.toString(DEFAULT_ENCODING));
+    assertEquals("", bout.toString(DEFAULT_ENCODING));
   }
 }
diff --git 
a/hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/debug/TestDBDefinitionFactory.java
 
b/hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/debug/TestDBDefinitionFactory.java
index a311d30dff..eae13308a3 100644
--- 
a/hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/debug/TestDBDefinitionFactory.java
+++ 
b/hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/debug/TestDBDefinitionFactory.java
@@ -32,8 +32,9 @@ import 
org.apache.hadoop.ozone.recon.spi.impl.ReconDBDefinition;
 
 import static 
org.apache.hadoop.ozone.recon.ReconConstants.RECON_CONTAINER_KEY_DB;
 import static 
org.apache.hadoop.ozone.recon.ReconConstants.RECON_OM_SNAPSHOT_DB;
-import static org.junit.Assert.assertTrue;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.junit.jupiter.api.Test;
 
 /**
  * Simple factory unit test.
diff --git 
a/hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/freon/TestContentGenerator.java
 
b/hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/freon/TestContentGenerator.java
index c3d28021b5..5fa21455cf 100644
--- 
a/hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/freon/TestContentGenerator.java
+++ 
b/hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/freon/TestContentGenerator.java
@@ -19,8 +19,9 @@ package org.apache.hadoop.ozone.freon;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 
-import org.junit.Assert;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import org.junit.jupiter.api.Test;
 
 import org.apache.hadoop.fs.StreamCapabilities;
 import org.apache.hadoop.fs.Syncable;
@@ -40,7 +41,7 @@ public class TestContentGenerator {
     ByteArrayOutputStream output = new ByteArrayOutputStream();
 
     generator.write(output);
-    Assert.assertArrayEquals(generator.getBuffer(), output.toByteArray());
+    assertArrayEquals(generator.getBuffer(), output.toByteArray());
   }
 
   @Test
@@ -50,7 +51,7 @@ public class TestContentGenerator {
     ByteArrayOutputStream baos = new ByteArrayOutputStream();
     generator.write(baos);
 
-    Assert.assertEquals(10000, baos.toByteArray().length);
+    assertEquals(10000, baos.toByteArray().length);
   }
 
   @Test
@@ -59,7 +60,7 @@ public class TestContentGenerator {
     ByteArrayOutputStream output = new ByteArrayOutputStream();
 
     generator.write(output);
-    Assert.assertArrayEquals(generator.getBuffer(), output.toByteArray());
+    assertArrayEquals(generator.getBuffer(), output.toByteArray());
   }
 
   @Test
@@ -68,7 +69,7 @@ public class TestContentGenerator {
     ByteArrayOutputStream output = new ByteArrayOutputStream();
 
     generator.write(output);
-    Assert.assertArrayEquals(generator.getBuffer(), output.toByteArray());
+    assertArrayEquals(generator.getBuffer(), output.toByteArray());
   }
 
   @Test
@@ -83,7 +84,7 @@ public class TestContentGenerator {
     System.arraycopy(buffer, 0, expected, 0, buffer.length);
     System.arraycopy(buffer, 0, expected, 8, buffer.length);
     System.arraycopy(buffer, 0, expected, 16, 4);
-    Assert.assertArrayEquals(expected, output.toByteArray());
+    assertArrayEquals(expected, output.toByteArray());
   }
 
   @Test
diff --git 
a/hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/freon/TestProgressBar.java
 
b/hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/freon/TestProgressBar.java
index 50233a454d..5bd2ee1cfc 100644
--- 
a/hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/freon/TestProgressBar.java
+++ 
b/hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/freon/TestProgressBar.java
@@ -16,11 +16,10 @@
  */
 package org.apache.hadoop.ozone.freon;
 
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
-
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;
 import java.io.PrintStream;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.function.LongSupplier;
@@ -35,14 +34,14 @@ import static org.mockito.Mockito.verify;
 /**
  * Tests for the Progressbar class for Freon.
  */
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
 public class TestProgressBar {
 
   private PrintStream stream;
   private AtomicLong numberOfKeysAdded;
   private LongSupplier currentValue;
 
-  @Before
+  @BeforeEach
   public void setupMock() {
     numberOfKeysAdded = new AtomicLong(0L);
     currentValue = numberOfKeysAdded::get;
diff --git 
a/hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/freon/containergenerator/TestGeneratorDatanode.java
 
b/hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/freon/containergenerator/TestGeneratorDatanode.java
index 4fd036a933..7792e03e11 100644
--- 
a/hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/freon/containergenerator/TestGeneratorDatanode.java
+++ 
b/hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/freon/containergenerator/TestGeneratorDatanode.java
@@ -16,8 +16,8 @@
  */
 package org.apache.hadoop.ozone.freon.containergenerator;
 
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
 
 import java.util.Arrays;
 import java.util.HashSet;
@@ -64,7 +64,7 @@ public class TestGeneratorDatanode {
       int maxDatanodes,
       int overlap,
       Integer... expectations) {
-    Assert.assertEquals(
+    Assertions.assertEquals(
         new HashSet<Integer>(Arrays.asList(expectations)),
         GeneratorDatanode.getPlacement(containerId, maxDatanodes, overlap));
   }
diff --git 
a/hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/genconf/TestGenerateOzoneRequiredConfigurations.java
 
b/hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/genconf/TestGenerateOzoneRequiredConfigurations.java
index b378628da4..4b0540d82f 100644
--- 
a/hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/genconf/TestGenerateOzoneRequiredConfigurations.java
+++ 
b/hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/genconf/TestGenerateOzoneRequiredConfigurations.java
@@ -22,12 +22,14 @@ import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang3.RandomStringUtils;
 import org.apache.hadoop.hdds.conf.OzoneConfiguration;
 import org.apache.ozone.test.GenericTestUtils;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import picocli.CommandLine;
@@ -68,20 +70,20 @@ public class TestGenerateOzoneRequiredConfigurations {
    *
    * @throws Exception In case of exception while creating output directory.
    */
-  @BeforeClass
+  @BeforeAll
   public static void init() throws Exception {
     outputBaseDir = GenericTestUtils.getTestDir();
     FileUtils.forceMkdir(outputBaseDir);
     genconfTool = new GenerateOzoneRequiredConfigurations();
   }
 
-  @Before
+  @BeforeEach
   public void setup() throws Exception {
     System.setOut(new PrintStream(out, false, DEFAULT_ENCODING));
     System.setErr(new PrintStream(err, false, DEFAULT_ENCODING));
   }
 
-  @After
+  @AfterEach
   public void reset() {
     // reset stream after each unit test
     out.reset();
@@ -95,7 +97,7 @@ public class TestGenerateOzoneRequiredConfigurations {
   /**
    * Cleans up the output base directory.
    */
-  @AfterClass
+  @AfterAll
   public static void cleanup() throws IOException {
     FileUtils.deleteDirectory(outputBaseDir);
   }
@@ -122,7 +124,7 @@ public class TestGenerateOzoneRequiredConfigurations {
         };
     cmd.parseWithHandlers(new CommandLine.RunLast(),
         exceptionHandler, args);
-    Assert.assertTrue(out.toString(DEFAULT_ENCODING).contains(msg));
+    assertTrue(out.toString(DEFAULT_ENCODING).contains(msg));
   }
 
   private void executeWithException(String[] args, String msg) {
@@ -148,8 +150,8 @@ public class TestGenerateOzoneRequiredConfigurations {
       cmd.parseWithHandlers(new CommandLine.RunLast(),
           exceptionHandler, args);
     }  catch (Exception ex) {
-      Assert.assertTrue("Expected " + msg + ", but got: " + ex.getMessage(),
-          ex.getMessage().contains(msg));
+      assertTrue(ex.getMessage().contains(msg),
+          "Expected " + msg + ", but got: " + ex.getMessage());
     }
   }
 
@@ -176,8 +178,7 @@ public class TestGenerateOzoneRequiredConfigurations {
 
     //Asserts all properties have a non-empty value
     for (OzoneConfiguration.Property p : allProperties) {
-      Assert.assertTrue(
-          p.getValue() != null && p.getValue().length() > 0);
+      assertTrue(p.getValue() != null && p.getValue().length() > 0);
     }
   }
 
@@ -205,8 +206,7 @@ public class TestGenerateOzoneRequiredConfigurations {
         oc.readPropertyFromXml(url);
 
     for (OzoneConfiguration.Property p : allProperties) {
-      Assert.assertTrue(
-          p.getValue() != null && p.getValue().length() > 0);
+      assertTrue(p.getValue() != null && p.getValue().length() > 0);
     }
     ozoneConfigurationCount = allProperties.size();
 
@@ -222,13 +222,11 @@ public class TestGenerateOzoneRequiredConfigurations {
     allProperties = oc.readPropertyFromXml(url);
 
     for (OzoneConfiguration.Property p : allProperties) {
-      Assert.assertTrue(
-          p.getValue() != null && p.getValue().length() > 0);
+      assertTrue(p.getValue() != null && p.getValue().length() > 0);
     }
     ozoneSecurityConfigurationCount = allProperties.size();
 
-    Assert.assertNotEquals(ozoneConfigurationCount,
-        ozoneSecurityConfigurationCount);
+    assertNotEquals(ozoneConfigurationCount, ozoneSecurityConfigurationCount);
   }
 
   /**
diff --git 
a/hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneAddressClientCreation.java
 
b/hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneAddressClientCreation.java
index 31d64993d1..02bc2cade0 100644
--- 
a/hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneAddressClientCreation.java
+++ 
b/hadoop-ozone/tools/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneAddressClientCreation.java
@@ -27,8 +27,9 @@ import org.apache.hadoop.ozone.client.OzoneClientException;
 import org.apache.hadoop.hdds.conf.InMemoryConfiguration;
 
 import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_SERVICE_IDS_KEY;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+
+import org.junit.jupiter.api.Test;
 
 /**
  * Test ozone client creation.
@@ -40,7 +41,7 @@ public class TestOzoneAddressClientCreation {
     TestableOzoneAddress address =
         new TestableOzoneAddress("/vol1/bucket1/key1");
     address.createClient(new InMemoryConfiguration());
-    Assert.assertTrue(address.simpleCreation);
+    Assertions.assertTrue(address.simpleCreation);
   }
 
   @Test
@@ -50,18 +51,18 @@ public class TestOzoneAddressClientCreation {
         new TestableOzoneAddress("/vol1/bucket1/key1");
     address.createClient(
         new InMemoryConfiguration(OZONE_OM_SERVICE_IDS_KEY, "service1"));
-    Assert.assertFalse(address.simpleCreation);
-    Assert.assertEquals("service1", address.serviceId);
+    Assertions.assertFalse(address.simpleCreation);
+    Assertions.assertEquals("service1", address.serviceId);
   }
 
-  @Test(expected = OzoneClientException.class)
+  @Test
   public void implicitHaMultipleServiceId()
       throws OzoneClientException, IOException {
     TestableOzoneAddress address =
         new TestableOzoneAddress("/vol1/bucket1/key1");
-    address.createClient(
-        new InMemoryConfiguration(OZONE_OM_SERVICE_IDS_KEY,
-            "service1,service2"));
+    Assertions.assertThrows(OzoneClientException.class, () ->
+        address.createClient(new 
InMemoryConfiguration(OZONE_OM_SERVICE_IDS_KEY,
+            "service1,service2")));
   }
 
   @Test
@@ -72,8 +73,8 @@ public class TestOzoneAddressClientCreation {
     address.createClient(
         new InMemoryConfiguration(OZONE_OM_SERVICE_IDS_KEY,
             "service1,service2"));
-    Assert.assertFalse(address.simpleCreation);
-    Assert.assertEquals("service1", address.serviceId);
+    Assertions.assertFalse(address.simpleCreation);
+    Assertions.assertEquals("service1", address.serviceId);
   }
 
   @Test
@@ -81,9 +82,9 @@ public class TestOzoneAddressClientCreation {
     TestableOzoneAddress address =
         new TestableOzoneAddress("o3://om:9862/vol1/bucket1/key1");
     address.createClient(new InMemoryConfiguration());
-    Assert.assertFalse(address.simpleCreation);
-    Assert.assertEquals("om", address.host);
-    Assert.assertEquals(9862, address.port);
+    Assertions.assertFalse(address.simpleCreation);
+    Assertions.assertEquals("om", address.host);
+    Assertions.assertEquals(9862, address.port);
   }
 
   @Test
@@ -93,9 +94,9 @@ public class TestOzoneAddressClientCreation {
         new TestableOzoneAddress("o3://om:9862/vol1/bucket1/key1");
     address.createClient(
         new InMemoryConfiguration(OZONE_OM_SERVICE_IDS_KEY, "service1"));
-    Assert.assertFalse(address.simpleCreation);
-    Assert.assertEquals("om", address.host);
-    Assert.assertEquals(9862, address.port);
+    Assertions.assertFalse(address.simpleCreation);
+    Assertions.assertEquals("om", address.host);
+    Assertions.assertEquals(9862, address.port);
   }
 
   @Test
@@ -106,9 +107,9 @@ public class TestOzoneAddressClientCreation {
     address.createClient(
         new InMemoryConfiguration(OZONE_OM_SERVICE_IDS_KEY,
             "service1,service2"));
-    Assert.assertFalse(address.simpleCreation);
-    Assert.assertEquals("om", address.host);
-    Assert.assertEquals(9862, address.port);
+    Assertions.assertFalse(address.simpleCreation);
+    Assertions.assertEquals("om", address.host);
+    Assertions.assertEquals(9862, address.port);
   }
 
   @Test
@@ -117,8 +118,8 @@ public class TestOzoneAddressClientCreation {
         new TestableOzoneAddress("o3://om/vol1/bucket1/key1");
     address.createClient(
         new InMemoryConfiguration(OZONE_OM_SERVICE_IDS_KEY, "service1"));
-    Assert.assertFalse(address.simpleCreation);
-    Assert.assertEquals("om", address.host);
+    Assertions.assertFalse(address.simpleCreation);
+    Assertions.assertEquals("om", address.host);
   }
 
   @Test
@@ -126,16 +127,17 @@ public class TestOzoneAddressClientCreation {
     TestableOzoneAddress address =
         new TestableOzoneAddress("o3://om:1234/vol1/bucket1/key1");
     address.createClient(new InMemoryConfiguration());
-    Assert.assertFalse(address.simpleCreation);
-    Assert.assertEquals("om", address.host);
-    Assert.assertEquals(1234, address.port);
+    Assertions.assertFalse(address.simpleCreation);
+    Assertions.assertEquals("om", address.host);
+    Assertions.assertEquals(1234, address.port);
   }
 
-  @Test(expected = OzoneClientException.class)
+  @Test
   public void explicitWrongScheme() throws OzoneClientException, IOException {
     TestableOzoneAddress address =
         new TestableOzoneAddress("ssh://host/vol1/bucket1/key1");
-    address.createClient(new InMemoryConfiguration());
+    Assertions.assertThrows(OzoneClientException.class, () ->
+        address.createClient(new InMemoryConfiguration()));
   }
 
   /**


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to