Skip to content

Commit

Permalink
HDDS-9497. Migrate TestRpcClient to JUnit5 (apache#5699)
Browse files Browse the repository at this point in the history
  • Loading branch information
VarshaRaviCV authored Nov 29, 2023
1 parent 6bf5374 commit 55836a6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 27 deletions.
7 changes: 7 additions & 0 deletions hadoop-ozone/client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
<description>Apache Ozone Client</description>
<name>Apache Ozone Client</name>
<packaging>jar</packaging>
<properties>
<allow.junit4>false</allow.junit4>
</properties>

<dependencies>
<dependency>
Expand Down Expand Up @@ -57,6 +60,10 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.reload4j</groupId>
<artifactId>reload4j</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,19 @@
import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
import org.apache.hadoop.ozone.OzoneManagerVersion;
import org.apache.hadoop.ozone.om.helpers.ServiceInfo;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import java.util.Arrays;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;
import java.util.LinkedList;
import java.util.List;

import static org.apache.hadoop.ozone.client.rpc.RpcClient.validateOmVersion;
import static org.junit.Assert.assertThrows;
import static org.junit.jupiter.api.Assertions.assertThrows;

/**
* Run RPC Client tests.
*/
@RunWith(Parameterized.class)
public class TestRpcClient {
private enum ValidateOmVersionTestCases {
NULL_EXPECTED_NO_OM(
Expand All @@ -62,10 +59,10 @@ private enum ValidateOmVersionTestCases {
true
),
NULL_EXPECTED_ONE_CURRENT_ONE_FUTURE_OM(
null,
OzoneManagerVersion.CURRENT,
OzoneManagerVersion.FUTURE_VERSION,
true
null,
OzoneManagerVersion.CURRENT,
OzoneManagerVersion.FUTURE_VERSION,
true
),
NULL_EXPECTED_TWO_FUTURE_OM(
null,
Expand Down Expand Up @@ -193,19 +190,9 @@ private enum ValidateOmVersionTestCases {
}
}

@Parameterized.Parameters(name = "{0}")
public static Iterable<ValidateOmVersionTestCases> parameters() {
return Arrays.asList(ValidateOmVersionTestCases.values());
}

private ValidateOmVersionTestCases testCase;

public TestRpcClient(ValidateOmVersionTestCases testCase) {
this.testCase = testCase;
}

@Test
public void testValidateOmVersion() {
@ParameterizedTest
@EnumSource(ValidateOmVersionTestCases.class)
public void testValidateOmVersion(ValidateOmVersionTestCases testCase) {
List<ServiceInfo> serviceInfoList = new LinkedList<>();
ServiceInfo.Builder b1 = new ServiceInfo.Builder();
ServiceInfo.Builder b2 = new ServiceInfo.Builder();
Expand All @@ -219,8 +206,9 @@ public void testValidateOmVersion() {
b2.setOmVersion(testCase.om2Version);
serviceInfoList.add(b2.build());
}
Assert.assertEquals("Running test " + testCase, testCase.validation,
validateOmVersion(testCase.expectedVersion, serviceInfoList));
Assertions.assertEquals(testCase.validation,
validateOmVersion(testCase.expectedVersion, serviceInfoList),
"Running test " + testCase);
}

@Test
Expand Down

0 comments on commit 55836a6

Please sign in to comment.