Skip to content

Commit 4cd786b

Browse files
committed
YARN-11267. Upgrade JUnit from 4 to 5 in hadoop-yarn-server-router.
1 parent 5c10e0d commit 4cd786b

31 files changed

+1467
-1424
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/TestRouter.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
*/
1818
package org.apache.hadoop.yarn.server.router;
1919

20-
import static org.junit.Assert.assertEquals;
21-
import static org.junit.Assert.assertTrue;
22-
import static org.junit.Assert.fail;
20+
import static org.junit.jupiter.api.Assertions.assertEquals;
21+
import static org.junit.jupiter.api.Assertions.assertTrue;
22+
import static org.junit.jupiter.api.Assertions.fail;
2323

2424
import org.apache.hadoop.conf.Configuration;
2525
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
@@ -34,8 +34,8 @@
3434
import org.eclipse.jetty.servlet.FilterHolder;
3535
import org.eclipse.jetty.servlet.ServletHandler;
3636
import org.eclipse.jetty.webapp.WebAppContext;
37-
import org.junit.Assert;
38-
import org.junit.Test;
37+
import org.junit.jupiter.api.Assertions;
38+
import org.junit.jupiter.api.Test;
3939
import org.mockito.Mockito;
4040

4141
import javax.servlet.FilterChain;
@@ -107,7 +107,7 @@ private void verifyServiceACLsRefresh(ServiceAuthorizationManager manager,
107107
for (Class<?> protocolClass : manager.getProtocolsWithAcls()) {
108108
AccessControlList accessList = manager.getProtocolsAcls(protocolClass);
109109
if (protocolClass == protocol) {
110-
Assert.assertEquals(accessList.getAclString(), aclString);
110+
Assertions.assertEquals(accessList.getAclString(), aclString);
111111
}
112112
}
113113
}
@@ -164,9 +164,9 @@ public void testRouterSupportCrossOrigin() throws ServletException, IOException
164164

165165
// Why is 5, because when Filter passes,
166166
// CrossOriginFilter will set 5 values to Map
167-
Assert.assertEquals(5, mockRes.getHeaders().size());
167+
Assertions.assertEquals(5, mockRes.getHeaders().size());
168168
String allowResult = mockRes.getHeader("Access-Control-Allow-Credentials");
169-
Assert.assertEquals("true", allowResult);
169+
Assertions.assertEquals("true", allowResult);
170170

171171
// 2. Simulate [example.org] for access
172172
HttpServletRequest mockReq2 = Mockito.mock(HttpServletRequest.class);
@@ -184,7 +184,7 @@ public void testRouterSupportCrossOrigin() throws ServletException, IOException
184184

185185
// Why is 0, because when the Filter fails,
186186
// CrossOriginFilter will not set any value
187-
Assert.assertEquals(0, mockRes2.getHeaders().size());
187+
Assertions.assertEquals(0, mockRes2.getHeaders().size());
188188

189189
router.stop();
190190
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/TestRouterAuditLogger.java

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

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

21-
import static org.junit.Assert.assertEquals;
21+
import static org.junit.jupiter.api.Assertions.assertEquals;
2222
import static org.mockito.Mockito.mock;
2323
import static org.mockito.Mockito.when;
2424

@@ -37,9 +37,9 @@
3737
import org.apache.hadoop.thirdparty.protobuf.ServiceException;
3838
import org.apache.hadoop.yarn.api.records.ApplicationId;
3939
import org.apache.hadoop.yarn.server.federation.store.records.SubClusterId;
40-
import org.junit.Assert;
41-
import org.junit.Before;
42-
import org.junit.Test;
40+
import org.junit.jupiter.api.Assertions;
41+
import org.junit.jupiter.api.BeforeEach;
42+
import org.junit.jupiter.api.Test;
4343

4444
import java.net.InetAddress;
4545
import java.net.InetSocketAddress;
@@ -56,7 +56,8 @@ public class TestRouterAuditLogger {
5656
private static final ApplicationId APPID = mock(ApplicationId.class);
5757
private static final SubClusterId SUBCLUSTERID = mock(SubClusterId.class);
5858

59-
@Before public void setUp() throws Exception {
59+
@BeforeEach
60+
public void setUp() throws Exception {
6061
when(APPID.toString()).thenReturn("app_1");
6162
when(SUBCLUSTERID.toString()).thenReturn("sc0");
6263
}
@@ -202,8 +203,8 @@ public TestProtos.EmptyResponseProto ping(
202203
throws ServiceException {
203204
// Ensure clientId is received
204205
byte[] clientId = Server.getClientId();
205-
Assert.assertNotNull(clientId);
206-
Assert.assertEquals(ClientId.BYTE_LENGTH, clientId.length);
206+
Assertions.assertNotNull(clientId);
207+
Assertions.assertEquals(ClientId.BYTE_LENGTH, clientId.length);
207208
// test with ip set
208209
testSuccessLogFormat(true);
209210
testFailureLogFormat(true);

0 commit comments

Comments
 (0)