Skip to content

Commit 183b576

Browse files
authored
YARN-11261. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-yarn-server-web-proxy. (#7946)
* YARN-11261. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-yarn-server-web-proxy. Reviewed-by: Cheng Pan <[email protected]> Signed-off-by: Shilun Fan <[email protected]>
1 parent 3fcf03a commit 183b576

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/test/java/org/apache/hadoop/yarn/server/webproxy/TestFedAppReportFetcher.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@
4040
import org.apache.hadoop.yarn.server.federation.utils.FederationStateStoreFacade;
4141
import org.apache.hadoop.yarn.util.StringHelper;
4242
import org.apache.hadoop.yarn.webapp.util.WebAppUtils;
43-
import org.junit.After;
44-
import org.junit.Assert;
45-
import org.junit.Test;
43+
import org.junit.jupiter.api.AfterEach;
44+
import org.junit.jupiter.api.Assertions;
45+
import org.junit.jupiter.api.Test;
4646
import org.mockito.Mockito;
4747

48-
import static org.junit.Assert.fail;
48+
import static org.junit.jupiter.api.Assertions.fail;
4949

5050
public class TestFedAppReportFetcher {
5151

@@ -66,7 +66,7 @@ public class TestFedAppReportFetcher {
6666
private static FedAppReportFetcher fetcher;
6767
private final String appNotFoundExceptionMsg = "APP NOT FOUND";
6868

69-
@After
69+
@AfterEach
7070
public void cleanUp() {
7171
history = null;
7272
fetcher = null;
@@ -132,16 +132,16 @@ public void testFetchReportAHSDisabled() throws Exception {
132132
.getApplicationReport(Mockito.any(GetApplicationReportRequest.class));
133133
Mockito.verify(appManager2, Mockito.times(1))
134134
.getApplicationReport(Mockito.any(GetApplicationReportRequest.class));
135-
Assert.assertNull("HistoryManager should be null as AHS is disabled", history);
135+
Assertions.assertNull(history, "HistoryManager should be null as AHS is disabled");
136136
}
137137

138138
@Test
139139
public void testGetRmAppPageUrlBase() throws IOException, YarnException {
140140
testHelper(true);
141141
String scheme = WebAppUtils.getHttpSchemePrefix(conf);
142-
Assert.assertEquals(fetcher.getRmAppPageUrlBase(appId1),
142+
Assertions.assertEquals(fetcher.getRmAppPageUrlBase(appId1),
143143
StringHelper.pjoin(scheme + clusterInfo1.getRMWebServiceAddress(), "cluster", "app"));
144-
Assert.assertEquals(fetcher.getRmAppPageUrlBase(appId2),
144+
Assertions.assertEquals(fetcher.getRmAppPageUrlBase(appId2),
145145
StringHelper.pjoin(scheme + clusterInfo2.getRMWebServiceAddress(), "cluster", "app"));
146146
}
147147

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/test/java/org/apache/hadoop/yarn/server/webproxy/TestWebAppProxyServletFed.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
package org.apache.hadoop.yarn.server.webproxy;
2020

21-
import static org.junit.Assert.assertEquals;
21+
import static org.junit.jupiter.api.Assertions.assertEquals;
2222

2323
import java.io.IOException;
2424
import java.io.InputStream;
@@ -57,9 +57,10 @@
5757
import org.eclipse.jetty.servlet.ServletContextHandler;
5858
import org.eclipse.jetty.servlet.ServletHolder;
5959
import org.eclipse.jetty.util.thread.QueuedThreadPool;
60-
import org.junit.AfterClass;
61-
import org.junit.BeforeClass;
62-
import org.junit.Test;
60+
import org.junit.jupiter.api.AfterAll;
61+
import org.junit.jupiter.api.BeforeAll;
62+
import org.junit.jupiter.api.Test;
63+
import org.junit.jupiter.api.Timeout;
6364
import org.mockito.Mockito;
6465
import org.slf4j.Logger;
6566
import org.slf4j.LoggerFactory;
@@ -84,7 +85,7 @@ public class TestWebAppProxyServletFed {
8485
/**
8586
* Simple http server. Server should send answer with status 200
8687
*/
87-
@BeforeClass
88+
@BeforeAll
8889
public static void setUp() throws Exception {
8990
mockServer = new Server(0);
9091
((QueuedThreadPool) mockServer.getThreadPool()).setMaxThreads(20);
@@ -102,7 +103,7 @@ public static void setUp() throws Exception {
102103
LOG.info("Running embedded servlet container at: http://localhost:" + mockServerPort);
103104
}
104105

105-
@AfterClass
106+
@AfterAll
106107
public static void tearDown() throws Exception {
107108
if (mockServer != null) {
108109
mockServer.stop();
@@ -139,7 +140,8 @@ public void testWebServlet() throws IOException {
139140
conn.disconnect();
140141
}
141142

142-
@Test(timeout=5000)
143+
@Test
144+
@Timeout(value = 5)
143145
public void testWebAppProxyServletFed() throws Exception {
144146

145147
Configuration conf = new Configuration();

0 commit comments

Comments
 (0)