diff --git a/hbase-http/pom.xml b/hbase-http/pom.xml
index b73eb2b58675..ba3a6f5345e3 100644
--- a/hbase-http/pom.xml
+++ b/hbase-http/pom.xml
@@ -122,11 +122,6 @@
junit-jupiter-params
test
-
- org.junit.vintage
- junit-vintage-engine
- test
-
org.hamcrest
hamcrest-library
diff --git a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/HttpServerFunctionalTest.java b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/HttpServerFunctionalTest.java
index c11a203620ad..c7b8db2cb0b4 100644
--- a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/HttpServerFunctionalTest.java
+++ b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/HttpServerFunctionalTest.java
@@ -17,8 +17,8 @@
*/
package org.apache.hadoop.hbase.http;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.BufferedReader;
import java.io.File;
@@ -215,7 +215,7 @@ public static void stop(HttpServer server) throws Exception {
* @throws MalformedURLException if the URL cannot be created.
*/
public static URL getServerURL(HttpServer server) throws MalformedURLException {
- assertNotNull("No server", server);
+ assertNotNull(server, "No server");
return new URL("http://" + NetUtils.getHostPortString(server.getConnectorAddress(0)));
}
diff --git a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestGlobalFilter.java b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestGlobalFilter.java
index 80b02006c036..46e8902bbd61 100644
--- a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestGlobalFilter.java
+++ b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestGlobalFilter.java
@@ -17,7 +17,7 @@
*/
package org.apache.hadoop.hbase.http;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.util.Set;
@@ -30,21 +30,17 @@
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.net.NetUtils;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category({ MiscTests.class, SmallTests.class })
+@Tag(MiscTests.TAG)
+@Tag(SmallTests.TAG)
public class TestGlobalFilter extends HttpServerFunctionalTest {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestGlobalFilter.class);
private static final Logger LOG = LoggerFactory.getLogger(HttpServer.class);
private static final Set RECORDS = new TreeSet<>();
diff --git a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestHtmlQuoting.java b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestHtmlQuoting.java
index 0fe46194083a..4728e1f057e3 100644
--- a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestHtmlQuoting.java
+++ b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestHtmlQuoting.java
@@ -17,26 +17,22 @@
*/
package org.apache.hadoop.hbase.http;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import javax.servlet.http.HttpServletRequest;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
-@Category({ MiscTests.class, SmallTests.class })
+@Tag(MiscTests.TAG)
+@Tag(SmallTests.TAG)
public class TestHtmlQuoting {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestHtmlQuoting.class);
@Test
public void testNeedsQuoting() throws Exception {
@@ -85,17 +81,17 @@ public void testRequestQuoting() throws Exception {
new HttpServer.QuotingInputFilter.RequestQuoter(mockReq);
Mockito.doReturn("a cookies = HttpCookie.parse(header);
- Assert.assertTrue(!cookies.isEmpty());
- Assert.assertTrue(header.contains("; HttpOnly"));
- Assert.assertTrue("token".equals(cookies.get(0).getValue()));
+ assertTrue(!cookies.isEmpty());
+ assertTrue(header.contains("; HttpOnly"));
+ assertTrue("token".equals(cookies.get(0).getValue()));
}
@Test
@@ -141,13 +138,13 @@ public void testHttpsCookie() throws IOException, GeneralSecurityException {
conn.setSSLSocketFactory(clientSslFactory.createSSLSocketFactory());
String header = conn.getHeaderField("Set-Cookie");
- Assert.assertTrue(header != null);
+ assertTrue(header != null);
List cookies = HttpCookie.parse(header);
- Assert.assertTrue(!cookies.isEmpty());
- Assert.assertTrue(header.contains("; HttpOnly"));
- Assert.assertTrue(cookies.get(0).getSecure());
- Assert.assertTrue("token".equals(cookies.get(0).getValue()));
+ assertTrue(!cookies.isEmpty());
+ assertTrue(header.contains("; HttpOnly"));
+ assertTrue(cookies.get(0).getSecure());
+ assertTrue("token".equals(cookies.get(0).getValue()));
}
@Test
@@ -162,16 +159,16 @@ public void testHttpsCookieDefaultServlets() throws Exception {
conn.setSSLSocketFactory(clientSslFactory.createSSLSocketFactory());
String header = conn.getHeaderField("Set-Cookie");
- Assert.assertTrue(header != null);
+ assertTrue(header != null);
List cookies = HttpCookie.parse(header);
- Assert.assertTrue(!cookies.isEmpty());
- Assert.assertTrue(header.contains("; HttpOnly"));
- Assert.assertTrue(cookies.get(0).getSecure());
- Assert.assertTrue("token".equals(cookies.get(0).getValue()));
+ assertTrue(!cookies.isEmpty());
+ assertTrue(header.contains("; HttpOnly"));
+ assertTrue(cookies.get(0).getSecure());
+ assertTrue("token".equals(cookies.get(0).getValue()));
}
}
- @AfterClass
+ @AfterAll
public static void cleanup() throws Exception {
server.stop();
FileUtil.fullyDelete(new File(BASEDIR));
diff --git a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestHttpRequestLog.java b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestHttpRequestLog.java
index 904b1d4ca0ad..2e5bffacf855 100644
--- a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestHttpRequestLog.java
+++ b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestHttpRequestLog.java
@@ -19,31 +19,26 @@
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
-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;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.apache.hbase.thirdparty.org.eclipse.jetty.server.CustomRequestLog;
import org.apache.hbase.thirdparty.org.eclipse.jetty.server.RequestLog;
import org.apache.hbase.thirdparty.org.eclipse.jetty.server.Slf4jRequestLogWriter;
-@Category({ MiscTests.class, SmallTests.class })
+@Tag(MiscTests.TAG)
+@Tag(SmallTests.TAG)
public class TestHttpRequestLog {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestHttpRequestLog.class);
-
@Test
public void testAppenderDefined() {
RequestLog requestLog = HttpRequestLog.getRequestLog("test");
- assertNotNull("RequestLog should not be null", requestLog);
+ assertNotNull(requestLog, "RequestLog should not be null");
assertThat(requestLog, instanceOf(CustomRequestLog.class));
CustomRequestLog crl = (CustomRequestLog) requestLog;
assertThat(crl.getWriter(), instanceOf(Slf4jRequestLogWriter.class));
diff --git a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestHttpServer.java b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestHttpServer.java
index ad9c9d3a0671..7091a2ac7014 100644
--- a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestHttpServer.java
+++ b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestHttpServer.java
@@ -18,10 +18,11 @@
package org.apache.hadoop.hbase.http;
import static org.hamcrest.Matchers.greaterThan;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+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 java.io.BufferedReader;
import java.io.IOException;
@@ -57,7 +58,6 @@
import javax.servlet.http.HttpServletResponse;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.CommonConfigurationKeys;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.http.HttpServer.QuotingInputFilter.RequestQuoter;
import org.apache.hadoop.hbase.http.resource.JerseyResource;
import org.apache.hadoop.hbase.testclassification.MiscTests;
@@ -74,13 +74,11 @@
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.hamcrest.MatcherAssert;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -88,11 +86,9 @@
import org.apache.hbase.thirdparty.org.eclipse.jetty.server.ServerConnector;
import org.apache.hbase.thirdparty.org.eclipse.jetty.util.ajax.JSON;
-@Category({ MiscTests.class, SmallTests.class })
+@Tag(MiscTests.TAG)
+@Tag(SmallTests.TAG)
public class TestHttpServer extends HttpServerFunctionalTest {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestHttpServer.class);
private static final Logger LOG = LoggerFactory.getLogger(TestHttpServer.class);
private static HttpServer server;
@@ -148,7 +144,7 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) thro
public static class LongHeaderServlet extends HttpServlet {
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) {
- Assert.assertEquals(63 * 1024, request.getHeader("longheader").length());
+ assertEquals(63 * 1024, request.getHeader("longheader").length());
response.setStatus(HttpServletResponse.SC_OK);
}
}
@@ -164,7 +160,7 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) thro
}
}
- @BeforeClass
+ @BeforeAll
public static void setup() throws Exception {
Configuration conf = new Configuration();
conf.setInt(HttpServer.HTTP_MAX_THREADS, MAX_THREADS);
@@ -179,7 +175,7 @@ public static void setup() throws Exception {
LOG.info("HTTP server started: " + baseUrl);
}
- @AfterClass
+ @AfterAll
public static void cleanup() throws Exception {
server.stop();
}
@@ -201,9 +197,8 @@ public void testMaxThreads() throws Exception {
start.await();
assertEquals("a:b\nc:d\n", readOutput(new URL(baseUrl, "/echo?a=b&c=d")));
int serverThreads = server.webServer.getThreadPool().getThreads();
- assertTrue(
- "More threads are started than expected, Server Threads count: " + serverThreads,
- serverThreads <= MAX_THREADS);
+ assertTrue(serverThreads <= MAX_THREADS,
+ "More threads are started than expected, Server Threads count: " + serverThreads);
LOG.info("Number of threads = " + serverThreads
+ " which is less or equal than the max = " + MAX_THREADS);
} catch (Exception e) {
@@ -419,7 +414,7 @@ public List getGroups(String user) {
* authentication filters are set, but authorization is not enabled.
*/
@Test
- @Ignore
+ @Disabled
public void testDisabledAuthorizationOfDefaultServlets() throws Exception {
Configuration conf = new Configuration();
@@ -450,7 +445,7 @@ public void testDisabledAuthorizationOfDefaultServlets() throws Exception {
* Verify the administrator access for /logs, /stacks, /conf, /logLevel and /metrics servlets.
*/
@Test
- @Ignore
+ @Disabled
public void testAuthorizationOfDefaultServlets() throws Exception {
Configuration conf = new Configuration();
conf.setBoolean(CommonConfigurationKeys.HADOOP_SECURITY_AUTHORIZATION, true);
@@ -491,8 +486,8 @@ public void testRequestQuoterWithNull() {
Mockito.doReturn(null).when(request).getParameterValues("dummy");
RequestQuoter requestQuoter = new RequestQuoter(request);
String[] parameterValues = requestQuoter.getParameterValues("dummy");
- Assert.assertNull("It should return null " + "when there are no values for the parameter",
- parameterValues);
+ assertNull(parameterValues,
+ "It should return null " + "when there are no values for the parameter");
}
@Test
@@ -502,7 +497,7 @@ public void testRequestQuoterWithNotNull() {
Mockito.doReturn(values).when(request).getParameterValues("dummy");
RequestQuoter requestQuoter = new RequestQuoter(request);
String[] parameterValues = requestQuoter.getParameterValues("dummy");
- Assert.assertTrue("It should return Parameter Values", Arrays.equals(values, parameterValues));
+ assertTrue(Arrays.equals(values, parameterValues), "It should return Parameter Values");
}
@SuppressWarnings("unchecked")
@@ -533,26 +528,26 @@ public void testHasAdministratorAccess() throws Exception {
HttpServletResponse response = Mockito.mock(HttpServletResponse.class);
// authorization OFF
- Assert.assertTrue(HttpServer.hasAdministratorAccess(context, request, response));
+ assertTrue(HttpServer.hasAdministratorAccess(context, request, response));
// authorization ON & user NULL
response = Mockito.mock(HttpServletResponse.class);
conf.setBoolean(CommonConfigurationKeys.HADOOP_SECURITY_AUTHORIZATION, true);
- Assert.assertFalse(HttpServer.hasAdministratorAccess(context, request, response));
+ assertFalse(HttpServer.hasAdministratorAccess(context, request, response));
Mockito.verify(response).sendError(Mockito.eq(HttpServletResponse.SC_UNAUTHORIZED),
Mockito.anyString());
// authorization ON & user NOT NULL & ACLs NULL
response = Mockito.mock(HttpServletResponse.class);
Mockito.when(request.getRemoteUser()).thenReturn("foo");
- Assert.assertTrue(HttpServer.hasAdministratorAccess(context, request, response));
+ assertTrue(HttpServer.hasAdministratorAccess(context, request, response));
// authorization ON & user NOT NULL & ACLs NOT NULL & user not in ACLs
response = Mockito.mock(HttpServletResponse.class);
AccessControlList acls = Mockito.mock(AccessControlList.class);
Mockito.when(acls.isUserAllowed(Mockito. any())).thenReturn(false);
Mockito.when(context.getAttribute(HttpServer.ADMINS_ACL)).thenReturn(acls);
- Assert.assertFalse(HttpServer.hasAdministratorAccess(context, request, response));
+ assertFalse(HttpServer.hasAdministratorAccess(context, request, response));
Mockito.verify(response).sendError(Mockito.eq(HttpServletResponse.SC_FORBIDDEN),
Mockito.anyString());
@@ -560,7 +555,7 @@ public void testHasAdministratorAccess() throws Exception {
response = Mockito.mock(HttpServletResponse.class);
Mockito.when(acls.isUserAllowed(Mockito. any())).thenReturn(true);
Mockito.when(context.getAttribute(HttpServer.ADMINS_ACL)).thenReturn(acls);
- Assert.assertTrue(HttpServer.hasAdministratorAccess(context, request, response));
+ assertTrue(HttpServer.hasAdministratorAccess(context, request, response));
}
@@ -573,7 +568,7 @@ public void testRequiresAuthorizationAccess() throws Exception {
HttpServletResponse response = Mockito.mock(HttpServletResponse.class);
// requires admin access to instrumentation, FALSE by default
- Assert.assertTrue(HttpServer.isInstrumentationAccessAllowed(context, request, response));
+ assertTrue(HttpServer.isInstrumentationAccessAllowed(context, request, response));
// requires admin access to instrumentation, TRUE
conf.setBoolean(CommonConfigurationKeys.HADOOP_SECURITY_INSTRUMENTATION_REQUIRES_ADMIN, true);
@@ -581,7 +576,7 @@ public void testRequiresAuthorizationAccess() throws Exception {
AccessControlList acls = Mockito.mock(AccessControlList.class);
Mockito.when(acls.isUserAllowed(Mockito. any())).thenReturn(false);
Mockito.when(context.getAttribute(HttpServer.ADMINS_ACL)).thenReturn(acls);
- Assert.assertFalse(HttpServer.isInstrumentationAccessAllowed(context, request, response));
+ assertFalse(HttpServer.isInstrumentationAccessAllowed(context, request, response));
}
@Test
diff --git a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestHttpServerLifecycle.java b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestHttpServerLifecycle.java
index 63c99387c00d..420604824628 100644
--- a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestHttpServerLifecycle.java
+++ b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestHttpServerLifecycle.java
@@ -17,38 +17,33 @@
*/
package org.apache.hadoop.hbase.http;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
-import org.junit.ClassRule;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Ignore("Hangs on occasion; see HBASE-14430")
-@Category({ MiscTests.class, SmallTests.class })
+@Disabled("Hangs on occasion; see HBASE-14430")
+@Tag(MiscTests.TAG)
+@Tag(SmallTests.TAG)
public class TestHttpServerLifecycle extends HttpServerFunctionalTest {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestHttpServerLifecycle.class);
-
/**
* Check that a server is alive by probing the {@link HttpServer#isAlive()} method and the text of
* its toString() description
* @param server server
*/
private void assertAlive(HttpServer server) {
- assertTrue("Server is not alive", server.isAlive());
+ assertTrue(server.isAlive(), "Server is not alive");
assertToStringContains(server, HttpServer.STATE_DESCRIPTION_ALIVE);
}
private void assertNotLive(HttpServer server) {
- assertTrue("Server should not be live", !server.isAlive());
+ assertTrue(!server.isAlive(), "Server should not be live");
assertToStringContains(server, HttpServer.STATE_DESCRIPTION_NOT_LIVE);
}
@@ -88,8 +83,8 @@ public void testStartedServerIsAlive() throws Throwable {
*/
private void assertToStringContains(HttpServer server, String text) {
String description = server.toString();
- assertTrue("Did not find \"" + text + "\" in \"" + description + "\"",
- description.contains(text));
+ assertTrue(description.contains(text),
+ "Did not find \"" + text + "\" in \"" + description + "\"");
}
/**
@@ -132,6 +127,6 @@ public void testWepAppContextAfterServerStop() throws Throwable {
assertAlive(server);
assertEquals(value, server.getAttribute(key));
stop(server);
- assertNull("Server context should have cleared", server.getAttribute(key));
+ assertNull(server.getAttribute(key), "Server context should have cleared");
}
}
diff --git a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestHttpServerWebapps.java b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestHttpServerWebapps.java
index 85aec180c11c..a836c67726c9 100644
--- a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestHttpServerWebapps.java
+++ b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestHttpServerWebapps.java
@@ -17,28 +17,23 @@
*/
package org.apache.hadoop.hbase.http;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.FileNotFoundException;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Test webapp loading
*/
-@Category({ MiscTests.class, SmallTests.class })
+@Tag(MiscTests.TAG)
+@Tag(SmallTests.TAG)
public class TestHttpServerWebapps extends HttpServerFunctionalTest {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestHttpServerWebapps.class);
-
private static final Logger log = LoggerFactory.getLogger(TestHttpServerWebapps.class);
/**
diff --git a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestPathFilter.java b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestPathFilter.java
index 75d798cb0778..bcb147dacafe 100644
--- a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestPathFilter.java
+++ b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestPathFilter.java
@@ -17,7 +17,7 @@
*/
package org.apache.hadoop.hbase.http;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.util.Set;
@@ -30,21 +30,17 @@
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.net.NetUtils;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category({ MiscTests.class, SmallTests.class })
+@Tag(MiscTests.TAG)
+@Tag(SmallTests.TAG)
public class TestPathFilter extends HttpServerFunctionalTest {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestPathFilter.class);
private static final Logger LOG = LoggerFactory.getLogger(HttpServer.class);
private static final Set RECORDS = new TreeSet<>();
diff --git a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestProfileOutputServlet.java b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestProfileOutputServlet.java
index 442fc0e37fe7..cfa4c8877205 100644
--- a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestProfileOutputServlet.java
+++ b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestProfileOutputServlet.java
@@ -17,22 +17,17 @@
*/
package org.apache.hadoop.hbase.http;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.util.Arrays;
import java.util.List;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.SmallTests;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Category({ SmallTests.class })
+@Tag(SmallTests.TAG)
public class TestProfileOutputServlet {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestProfileOutputServlet.class);
@Test
public void testSanitization() {
@@ -43,12 +38,8 @@ public void testSanitization() {
}
List bad = Arrays.asList("function(){console.log(\"oops\")}", "uhoh");
for (String input : bad) {
- try {
- ProfileOutputServlet.sanitize(input);
- fail("Expected sanitization of \"" + input + "\" to fail");
- } catch (RuntimeException e) {
- // Pass
- }
+ assertThrows(RuntimeException.class, () -> ProfileOutputServlet.sanitize(input),
+ "Expected sanitization of \"" + input + "\" to fail");
}
}
diff --git a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestProxyUserSpnegoHttpServer.java b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestProxyUserSpnegoHttpServer.java
index e6842bbb02ec..90f498acd05b 100644
--- a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestProxyUserSpnegoHttpServer.java
+++ b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestProxyUserSpnegoHttpServer.java
@@ -17,10 +17,10 @@
*/
package org.apache.hadoop.hbase.http;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+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.assertTrue;
import java.io.File;
import java.net.HttpURLConnection;
@@ -31,7 +31,6 @@
import javax.security.auth.Subject;
import javax.security.auth.kerberos.KerberosTicket;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseCommonTestingUtility;
import org.apache.hadoop.hbase.http.TestHttpServer.EchoServlet;
import org.apache.hadoop.hbase.http.resource.JerseyResource;
@@ -62,11 +61,10 @@
import org.ietf.jgss.GSSManager;
import org.ietf.jgss.GSSName;
import org.ietf.jgss.Oid;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -75,11 +73,9 @@
* HttpComponents to verify that the doas= mechanicsm works, and that the proxyuser settings are
* observed.
*/
-@Category({ MiscTests.class, SmallTests.class })
+@Tag(MiscTests.TAG)
+@Tag(SmallTests.TAG)
public class TestProxyUserSpnegoHttpServer extends HttpServerFunctionalTest {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestProxyUserSpnegoHttpServer.class);
private static final Logger LOG = LoggerFactory.getLogger(TestProxyUserSpnegoHttpServer.class);
private static final String KDC_SERVER_HOST = "localhost";
@@ -97,7 +93,7 @@ public class TestProxyUserSpnegoHttpServer extends HttpServerFunctionalTest {
private static File privilegedKeytab;
private static File privileged2Keytab;
- @BeforeClass
+ @BeforeAll
public static void setupServer() throws Exception {
Configuration conf = new Configuration();
HBaseCommonTestingUtility htu = new HBaseCommonTestingUtility(conf);
@@ -137,7 +133,7 @@ public static void setupServer() throws Exception {
LOG.info("HTTP server started: " + baseUrl);
}
- @AfterClass
+ @AfterAll
public static void stopServer() throws Exception {
try {
if (null != server) {
diff --git a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestSSLHttpServer.java b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestSSLHttpServer.java
index 4654a27d87ae..6c27c21b762d 100644
--- a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestSSLHttpServer.java
+++ b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestSSLHttpServer.java
@@ -17,7 +17,7 @@
*/
package org.apache.hadoop.hbase.http;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -29,7 +29,6 @@
import javax.net.ssl.HttpsURLConnection;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileUtil;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseCommonTestingUtility;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.http.ssl.KeyStoreTestUtil;
@@ -38,11 +37,10 @@
import org.apache.hadoop.io.IOUtils;
import org.apache.hadoop.net.NetUtils;
import org.apache.hadoop.security.ssl.SSLFactory;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -50,13 +48,10 @@
* This testcase issues SSL certificates configures the HttpServer to serve HTTPS using the created
* certficates and calls an echo servlet using the corresponding HTTPS URL.
*/
-@Category({ MiscTests.class, MediumTests.class })
+@Tag(MiscTests.TAG)
+@Tag(MediumTests.TAG)
public class TestSSLHttpServer extends HttpServerFunctionalTest {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestSSLHttpServer.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestSSLHttpServer.class);
private static Configuration serverConf;
private static HttpServer server;
@@ -66,7 +61,7 @@ public class TestSSLHttpServer extends HttpServerFunctionalTest {
private static SSLFactory clientSslFactory;
private static HBaseCommonTestingUtility HTU;
- @BeforeClass
+ @BeforeAll
public static void setup() throws Exception {
HTU = new HBaseCommonTestingUtility();
@@ -106,7 +101,7 @@ public static void setup() throws Exception {
LOG.info("HTTP server started: " + baseUrl);
}
- @AfterClass
+ @AfterAll
public static void cleanup() throws Exception {
server.stop();
FileUtil.fullyDelete(new File(HTU.getDataTestDir().toString()));
diff --git a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestSecurityHeadersFilter.java b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestSecurityHeadersFilter.java
index 006025e0a978..ec50921d8cda 100644
--- a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestSecurityHeadersFilter.java
+++ b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestSecurityHeadersFilter.java
@@ -28,25 +28,19 @@
import java.net.HttpURLConnection;
import java.net.URL;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.hamcrest.core.Is;
import org.hamcrest.core.IsEqual;
-import org.junit.After;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Category({ HttpServerFunctionalTest.class, MediumTests.class })
+@Tag(MediumTests.TAG)
public class TestSecurityHeadersFilter {
private static URL baseUrl;
private HttpServer http;
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestSecurityHeadersFilter.class);
-
- @After
+ @AfterEach
public void tearDown() throws Exception {
http.stop();
}
diff --git a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestServletFilter.java b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestServletFilter.java
index 1b95e0dfe236..711f213eeee7 100644
--- a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestServletFilter.java
+++ b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestServletFilter.java
@@ -17,9 +17,10 @@
*/
package org.apache.hadoop.hbase.http;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.util.Random;
@@ -32,24 +33,19 @@
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.net.NetUtils;
import org.apache.hadoop.util.StringUtils;
-import org.junit.Assert;
-import org.junit.ClassRule;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category({ MiscTests.class, SmallTests.class })
+@Tag(MiscTests.TAG)
+@Tag(SmallTests.TAG)
public class TestServletFilter extends HttpServerFunctionalTest {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestServletFilter.class);
private static final Logger LOG = LoggerFactory.getLogger(HttpServer.class);
private static volatile String uri = null;
@@ -94,12 +90,12 @@ public void initFilter(FilterContainer container, Configuration conf) {
private static void assertExceptionContains(String string, Throwable t) {
String msg = t.getMessage();
- Assert.assertTrue("Expected to find '" + string + "' but got unexpected exception:"
- + StringUtils.stringifyException(t), msg.contains(string));
+ assertTrue(msg.contains(string), "Expected to find '" + string
+ + "' but got unexpected exception:" + StringUtils.stringifyException(t));
}
@Test
- @Ignore
+ @Disabled
// From stack
// Its a 'foreign' test, one that came in from hadoop when we copy/pasted http
// It's second class. Could comment it out if only failing test (as per @nkeywal – sort of)
@@ -169,12 +165,8 @@ public void testServletFilterWhenInitThrowsException() throws Exception {
// start an http server with ErrorFilter
conf.set(HttpServer.FILTER_INITIALIZERS_PROPERTY, ErrorFilter.Initializer.class.getName());
HttpServer http = createTestServer(conf);
- try {
- http.start();
- fail("expecting exception");
- } catch (IOException e) {
- assertExceptionContains("Problem starting http server", e);
- }
+ IOException e = assertThrows(IOException.class, () -> http.start());
+ assertExceptionContains("Problem starting http server", e);
}
/**
@@ -187,11 +179,7 @@ public void testContextSpecificServletFilterWhenInitThrowsException() throws Exc
HttpServer http = createTestServer(conf);
HttpServer.defineFilter(http.webAppContext, "ErrorFilter", ErrorFilter.class.getName(), null,
null);
- try {
- http.start();
- fail("expecting exception");
- } catch (IOException e) {
- assertExceptionContains("Unable to initialize WebAppContext", e);
- }
+ IOException e = assertThrows(IOException.class, () -> http.start());
+ assertExceptionContains("Unable to initialize WebAppContext", e);
}
}
diff --git a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestSpnegoHttpServer.java b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestSpnegoHttpServer.java
index 68f8d88ddff2..6d7c82157807 100644
--- a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestSpnegoHttpServer.java
+++ b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestSpnegoHttpServer.java
@@ -17,9 +17,10 @@
*/
package org.apache.hadoop.hbase.http;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
+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.assertThrows;
import java.io.File;
import java.io.IOException;
@@ -31,7 +32,6 @@
import javax.security.auth.Subject;
import javax.security.auth.kerberos.KerberosTicket;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseCommonTestingUtility;
import org.apache.hadoop.hbase.http.TestHttpServer.EchoServlet;
import org.apache.hadoop.hbase.http.resource.JerseyResource;
@@ -61,11 +61,10 @@
import org.ietf.jgss.GSSManager;
import org.ietf.jgss.GSSName;
import org.ietf.jgss.Oid;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -73,11 +72,9 @@
* Test class for SPNEGO authentication on the HttpServer. Uses Kerby's MiniKDC and Apache
* HttpComponents to verify that a simple Servlet is reachable via SPNEGO and unreachable w/o.
*/
-@Category({ MiscTests.class, SmallTests.class })
+@Tag(MiscTests.TAG)
+@Tag(SmallTests.TAG)
public class TestSpnegoHttpServer extends HttpServerFunctionalTest {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestSpnegoHttpServer.class);
private static final Logger LOG = LoggerFactory.getLogger(TestSpnegoHttpServer.class);
private static final String KDC_SERVER_HOST = "localhost";
@@ -89,7 +86,7 @@ public class TestSpnegoHttpServer extends HttpServerFunctionalTest {
private static File infoServerKeytab;
private static File clientKeytab;
- @BeforeClass
+ @BeforeAll
public static void setupServer() throws Exception {
Configuration conf = new Configuration();
HBaseCommonTestingUtility htu = new HBaseCommonTestingUtility(conf);
@@ -121,7 +118,7 @@ public static void setupServer() throws Exception {
LOG.info("HTTP server started: " + baseUrl);
}
- @AfterClass
+ @AfterAll
public static void stopServer() throws Exception {
try {
if (null != server) {
@@ -221,7 +218,7 @@ public HttpResponse run() throws Exception {
assertEquals("a:b", EntityUtils.toString(resp.getEntity()).trim());
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testMissingConfigurationThrowsException() throws Exception {
Configuration conf = new Configuration();
conf.setInt(HttpServer.HTTP_MAX_THREADS, TestHttpServer.MAX_THREADS);
@@ -229,9 +226,12 @@ public void testMissingConfigurationThrowsException() throws Exception {
conf.set("hbase.security.authentication", "kerberos");
// Intentionally skip keytab and principal
- HttpServer customServer = createTestServerWithSecurity(conf);
- customServer.addUnprivilegedServlet("echo", "/echo", EchoServlet.class);
- customServer.addJerseyResourcePackage(JerseyResource.class.getPackage().getName(), "/jersey/*");
- customServer.start();
+ assertThrows(IllegalArgumentException.class, () -> {
+ HttpServer customServer = createTestServerWithSecurity(conf);
+ customServer.addUnprivilegedServlet("echo", "/echo", EchoServlet.class);
+ customServer.addJerseyResourcePackage(JerseyResource.class.getPackage().getName(),
+ "/jersey/*");
+ customServer.start();
+ });
}
}
diff --git a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/conf/TestConfServlet.java b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/conf/TestConfServlet.java
index fe202906e9c5..7bed30d721ec 100644
--- a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/conf/TestConfServlet.java
+++ b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/conf/TestConfServlet.java
@@ -17,9 +17,9 @@
*/
package org.apache.hadoop.hbase.http.conf;
-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.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.StringReader;
import java.io.StringWriter;
@@ -29,12 +29,10 @@
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -47,13 +45,10 @@
* Basic test case that the ConfServlet can write configuration to its output in XML and JSON
* format.
*/
-@Category({ MiscTests.class, SmallTests.class })
+@Tag(MiscTests.TAG)
+@Tag(SmallTests.TAG)
public class TestConfServlet {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestConfServlet.class);
-
private static final String TEST_KEY = "testconfservlet.key";
private static final String TEST_VAL = "testval";
@@ -125,12 +120,8 @@ public void testMask() {
@Test
public void testBadFormat() throws Exception {
StringWriter sw = new StringWriter();
- try {
- ConfServlet.writeResponse(getTestConf(), sw, "not a format");
- fail("writeResponse with bad format didn't throw!");
- } catch (ConfServlet.BadFormatException bfe) {
- // expected
- }
+ assertThrows(ConfServlet.BadFormatException.class,
+ () -> ConfServlet.writeResponse(getTestConf(), sw, "not a format"));
assertEquals("", sw.toString());
}
}
diff --git a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/jmx/TestJMXJsonServlet.java b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/jmx/TestJMXJsonServlet.java
index 8872fd927ed7..ec0820466310 100644
--- a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/jmx/TestJMXJsonServlet.java
+++ b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/jmx/TestJMXJsonServlet.java
@@ -17,9 +17,9 @@
*/
package org.apache.hadoop.hbase.http.jmx;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.net.HttpURLConnection;
import java.net.URL;
@@ -27,31 +27,26 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.servlet.http.HttpServletResponse;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.http.HttpServer;
import org.apache.hadoop.hbase.http.HttpServerFunctionalTest;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category({ MiscTests.class, SmallTests.class })
+@Tag(MiscTests.TAG)
+@Tag(SmallTests.TAG)
public class TestJMXJsonServlet extends HttpServerFunctionalTest {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestJMXJsonServlet.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestJMXJsonServlet.class);
private static HttpServer server;
private static URL baseUrl;
- @BeforeClass
+ @BeforeAll
public static void setup() throws Exception {
// Eclipse doesn't pick this up correctly from the plugin
// configuration in the pom.
@@ -61,7 +56,7 @@ public static void setup() throws Exception {
baseUrl = getServerURL(server);
}
- @AfterClass
+ @AfterAll
public static void cleanup() throws Exception {
server.stop();
}
@@ -69,13 +64,13 @@ public static void cleanup() throws Exception {
public static void assertReFind(String re, String value) {
Pattern p = Pattern.compile(re);
Matcher m = p.matcher(value);
- assertTrue("'" + p + "' does not match " + value, m.find());
+ assertTrue(m.find(), "'" + p + "' does not match " + value);
}
public static void assertNotFind(String re, String value) {
Pattern p = Pattern.compile(re);
Matcher m = p.matcher(value);
- assertFalse("'" + p + "' should not match " + value, m.find());
+ assertFalse(m.find(), "'" + p + "' should not match " + value);
}
@Test
diff --git a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/lib/TestAuthenticationFilterInitializer.java b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/lib/TestAuthenticationFilterInitializer.java
index 68c48f282737..6ffef18b25eb 100644
--- a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/lib/TestAuthenticationFilterInitializer.java
+++ b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/lib/TestAuthenticationFilterInitializer.java
@@ -17,29 +17,26 @@
*/
package org.apache.hadoop.hbase.http.lib;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.ArgumentMatchers.any;
import java.util.Map;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.http.FilterContainer;
import org.apache.hadoop.hbase.http.HttpServer;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.security.authentication.server.AuthenticationFilter;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
-@Category({ MiscTests.class, SmallTests.class })
+@Tag(MiscTests.TAG)
+@Tag(SmallTests.TAG)
public class TestAuthenticationFilterInitializer {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestAuthenticationFilterInitializer.class);
@Test
public void testConfiguration() throws Exception {
diff --git a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/lib/TestStaticUserWebFilter.java b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/lib/TestStaticUserWebFilter.java
index 9ad5ab9e9d9f..22faab984f8e 100644
--- a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/lib/TestStaticUserWebFilter.java
+++ b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/lib/TestStaticUserWebFilter.java
@@ -17,7 +17,7 @@
*/
package org.apache.hadoop.hbase.http.lib;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
@@ -30,23 +30,18 @@
import javax.servlet.http.HttpServletRequestWrapper;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.CommonConfigurationKeys;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.http.ServerConfigurationKeys;
import org.apache.hadoop.hbase.http.lib.StaticUserWebFilter.StaticUserFilter;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
-@Category({ MiscTests.class, SmallTests.class })
+@Tag(MiscTests.TAG)
+@Tag(SmallTests.TAG)
public class TestStaticUserWebFilter {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestStaticUserWebFilter.class);
-
private FilterConfig mockConfig(String username) {
FilterConfig mock = mock(FilterConfig.class);
doReturn(username).when(mock).getInitParameter(ServerConfigurationKeys.HBASE_HTTP_STATIC_USER);
diff --git a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/log/TestLogLevel.java b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/log/TestLogLevel.java
index 5ac316e0147c..ac48b89f2787 100644
--- a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/log/TestLogLevel.java
+++ b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/log/TestLogLevel.java
@@ -17,12 +17,12 @@
*/
package org.apache.hadoop.hbase.http.log;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertSame;
-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.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.File;
import java.io.IOException;
@@ -41,7 +41,6 @@
import org.apache.hadoop.fs.CommonConfigurationKeys;
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
import org.apache.hadoop.fs.FileUtil;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseCommonTestingUtility;
import org.apache.hadoop.hbase.http.HttpConfig;
import org.apache.hadoop.hbase.http.HttpServer;
@@ -58,20 +57,17 @@
import org.apache.hadoop.security.ssl.SSLFactory;
import org.apache.hadoop.test.GenericTestUtils;
import org.apache.hadoop.util.StringUtils;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
/**
* Test LogLevel.
*/
-@Category({ MiscTests.class, SmallTests.class })
+@Tag(MiscTests.TAG)
+@Tag(SmallTests.TAG)
public class TestLogLevel {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestLogLevel.class);
private static String keystoresDir;
private static String sslConfDir;
@@ -120,7 +116,7 @@ private enum Protocol {
}
}
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
serverConf = new Configuration();
serverConf.setStrings(LogLevel.READONLY_LOGGERS_CONF_KEY, protectedPrefix);
@@ -200,7 +196,7 @@ private static Configuration getSslConfig(Configuration conf) {
return sslConf;
}
- @AfterClass
+ @AfterAll
public static void tearDown() {
if (kdc != null) {
kdc.stop();
@@ -295,14 +291,14 @@ private void testGetLogLevel(Protocol protocol, boolean isSpnego, String loggerN
String expectedLevel) throws Exception {
withLogLevelServer(protocol, isSpnego, (authority) -> {
final String level = getLevel(protocol.client, authority, loggerName);
- assertEquals("Log level not equal to expected: ", expectedLevel, level);
+ assertEquals(expectedLevel, level, "Log level not equal to expected: ");
});
}
private void testSetLogLevel(Protocol protocol, boolean isSpnego, String loggerName,
String newLevel) throws Exception {
String oldLevel = Log4jUtils.getEffectiveLevel(loggerName);
- assertNotEquals("New level is same as old level: ", newLevel, oldLevel);
+ assertNotEquals(newLevel, oldLevel, "New level is same as old level: ");
try {
withLogLevelServer(protocol, isSpnego, (authority) -> {
@@ -388,8 +384,8 @@ private void setLevel(String protocol, String authority, String logName, String
final String response = cli.fetchSetLevelResponse();
final String responseLevel = extractEffectiveLevel(response);
final String currentLevel = Log4jUtils.getEffectiveLevel(logName);
- assertEquals("new level not equal to expected: ", newLevel, currentLevel);
- assertSame("new level not equal to response level: ", newLevel, responseLevel);
+ assertEquals(newLevel, currentLevel, "new level not equal to expected: ");
+ assertSame(newLevel, responseLevel, "new level not equal to response level: ");
}
/**
diff --git a/hbase-http/src/test/java/org/apache/hadoop/hbase/util/TestJSONBean.java b/hbase-http/src/test/java/org/apache/hadoop/hbase/util/TestJSONBean.java
index ef36d19c0468..66132f395109 100644
--- a/hbase-http/src/test/java/org/apache/hadoop/hbase/util/TestJSONBean.java
+++ b/hbase-http/src/test/java/org/apache/hadoop/hbase/util/TestJSONBean.java
@@ -17,7 +17,7 @@
*/
package org.apache.hadoop.hbase.util;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.mock;
@@ -33,12 +33,10 @@
import javax.management.MBeanInfo;
import javax.management.MBeanServer;
import javax.management.ObjectName;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.apache.hbase.thirdparty.com.google.common.reflect.TypeToken;
import org.apache.hbase.thirdparty.com.google.gson.Gson;
@@ -46,11 +44,9 @@
/**
* Test {@link JSONBean}.
*/
-@Category({ MiscTests.class, SmallTests.class })
+@Tag(MiscTests.TAG)
+@Tag(SmallTests.TAG)
public class TestJSONBean {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestJSONBean.class);
private MBeanServer getMockMBeanServer() throws Exception {
MBeanServer mbeanServer = mock(MBeanServer.class);