This is an automated email from the ASF dual-hosted git repository.
zhangduo pushed a commit to branch branch-2.5
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2.5 by this push:
new 16f9abb00b8 HBASE-29902 Upgrade hbase-thrift to use junit5 (#7781)
16f9abb00b8 is described below
commit 16f9abb00b89d243aa1e51d8b98806010f853547
Author: Liu Xiao <[email protected]>
AuthorDate: Tue Feb 24 00:15:15 2026 +0800
HBASE-29902 Upgrade hbase-thrift to use junit5 (#7781)
Signed-off-by: Duo Zhang <[email protected]>
(cherry picked from commit 5ce637b0d29f2eb5a00b99d7bebc2cd3401ef319)
---
hbase-thrift/pom.xml | 5 -
.../hbase/thrift/TestBindExceptionHandling.java | 14 +-
.../apache/hadoop/hbase/thrift/TestCallQueue.java | 36 ++--
.../hadoop/hbase/thrift/TestThriftHttpServer.java | 181 ++-------------------
...tpServer.java => TestThriftHttpServerBase.java} | 46 ++----
.../hbase/thrift/TestThriftHttpServerSSL.java | 30 ++--
.../hadoop/hbase/thrift/TestThriftServer.java | 70 ++++----
.../hbase/thrift/TestThriftServerCmdLine.java | 45 +++--
.../thrift/TestThriftSpnegoHttpFallbackServer.java | 45 +++--
.../hbase/thrift/TestThriftSpnegoHttpServer.java | 47 +++---
.../hbase/thrift2/TestThrift2HttpServer.java | 34 ++--
.../hbase/thrift2/TestThrift2ServerCmdLine.java | 26 +--
.../hadoop/hbase/thrift2/TestThriftConnection.java | 32 ++--
.../thrift2/TestThriftHBaseServiceHandler.java | 69 ++++----
.../TestThriftHBaseServiceHandlerWithLabels.java | 37 ++---
.../TestThriftHBaseServiceHandlerWithReadOnly.java | 33 ++--
16 files changed, 267 insertions(+), 483 deletions(-)
diff --git a/hbase-thrift/pom.xml b/hbase-thrift/pom.xml
index 84c2d6950ff..8ddf535de91 100644
--- a/hbase-thrift/pom.xml
+++ b/hbase-thrift/pom.xml
@@ -112,11 +112,6 @@
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.junit.vintage</groupId>
- <artifactId>junit-vintage-engine</artifactId>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
diff --git
a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestBindExceptionHandling.java
b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestBindExceptionHandling.java
index 04a4f03cfb6..a5de9efa37b 100644
---
a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestBindExceptionHandling.java
+++
b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestBindExceptionHandling.java
@@ -17,21 +17,17 @@
*/
package org.apache.hadoop.hbase.thrift;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.testclassification.ClientTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
-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({ ClientTests.class, MediumTests.class })
+@Tag(ClientTests.TAG)
+@Tag(MediumTests.TAG)
public class TestBindExceptionHandling {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestBindExceptionHandling.class);
private static final HBaseTestingUtility HTU = new HBaseTestingUtility();
diff --git
a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestCallQueue.java
b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestCallQueue.java
index 3c8f99d7e75..1ced4c1a2a7 100644
---
a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestCallQueue.java
+++
b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestCallQueue.java
@@ -18,35 +18,30 @@
package org.apache.hadoop.hbase.thrift;
import java.util.ArrayList;
-import java.util.Collection;
+import java.util.List;
import java.util.concurrent.LinkedBlockingQueue;
+import java.util.stream.Stream;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.CompatibilitySingletonFactory;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.HBaseParameterizedTestTemplate;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.test.MetricsAssertHelper;
import org.apache.hadoop.hbase.testclassification.ClientTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.TestTemplate;
+import org.junit.jupiter.params.provider.Arguments;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Unit testing for CallQueue, a part of the org.apache.hadoop.hbase.thrift
package.
*/
-@Category({ ClientTests.class, SmallTests.class })
-@RunWith(Parameterized.class)
+@Tag(ClientTests.TAG)
+@Tag(SmallTests.TAG)
+@HBaseParameterizedTestTemplate
public class TestCallQueue {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestCallQueue.class);
-
private static final Logger LOG =
LoggerFactory.getLogger(TestCallQueue.class);
private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
@@ -56,15 +51,14 @@ public class TestCallQueue {
private int elementsAdded;
private int elementsRemoved;
- @Parameters
- public static Collection<Object[]> getParameters() {
- Collection<Object[]> parameters = new ArrayList<>();
+ public static Stream<Arguments> parameters() {
+ List<Arguments> params = new ArrayList<>();
for (int elementsAdded : new int[] { 100, 200, 300 }) {
for (int elementsRemoved : new int[] { 0, 20, 100 }) {
- parameters.add(new Object[] { elementsAdded, elementsRemoved });
+ params.add(Arguments.of(elementsAdded, elementsRemoved));
}
}
- return parameters;
+ return params.stream();
}
public TestCallQueue(int elementsAdded, int elementsRemoved) {
@@ -74,7 +68,7 @@ public class TestCallQueue {
}
- @Test
+ @TestTemplate
public void testPutTake() throws Exception {
ThriftMetrics metrics = createMetrics();
CallQueue callQueue = new CallQueue(new LinkedBlockingQueue<>(), metrics);
@@ -87,7 +81,7 @@ public class TestCallQueue {
verifyMetrics(metrics, "timeInQueue_num_ops", elementsRemoved);
}
- @Test
+ @TestTemplate
public void testOfferPoll() throws Exception {
ThriftMetrics metrics = createMetrics();
CallQueue callQueue = new CallQueue(new LinkedBlockingQueue<>(), metrics);
diff --git
a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftHttpServer.java
b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftHttpServer.java
index 6104ea5abfc..b6223c184be 100644
---
a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftHttpServer.java
+++
b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftHttpServer.java
@@ -17,184 +17,27 @@
*/
package org.apache.hadoop.hbase.thrift;
-import static
org.apache.hadoop.hbase.thrift.TestThriftServerCmdLine.createBoundServer;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.fail;
-
-import java.io.IOException;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.function.Supplier;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
-import org.apache.hadoop.hbase.HBaseTestingUtility;
-import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.testclassification.ClientTests;
import org.apache.hadoop.hbase.testclassification.LargeTests;
-import org.apache.hadoop.hbase.thrift.generated.Hbase;
-import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
-import org.apache.hadoop.hbase.util.EnvironmentEdgeManagerTestHelper;
-import org.apache.hadoop.hbase.util.IncrementingEnvironmentEdge;
-import org.apache.hadoop.hbase.util.TableDescriptorChecker;
-import org.apache.thrift.protocol.TBinaryProtocol;
-import org.apache.thrift.protocol.TProtocol;
-import org.apache.thrift.transport.THttpClient;
-import org.apache.thrift.transport.TTransportException;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.ExpectedException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
/**
* Start the HBase Thrift HTTP server on a random port through the
command-line interface and talk
* to it from client side.
*/
-@Category({ ClientTests.class, LargeTests.class })
-public class TestThriftHttpServer {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestThriftHttpServer.class);
-
- private static final Logger LOG =
LoggerFactory.getLogger(TestThriftHttpServer.class);
-
- protected static final HBaseTestingUtility TEST_UTIL = new
HBaseTestingUtility();
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- TEST_UTIL.getConfiguration().setBoolean(Constants.USE_HTTP_CONF_KEY, true);
-
TEST_UTIL.getConfiguration().setBoolean(TableDescriptorChecker.TABLE_SANITY_CHECKS,
false);
- TEST_UTIL.startMiniCluster();
- // ensure that server time increments every time we do an operation,
otherwise
- // successive puts having the same timestamp will override each other
- EnvironmentEdgeManagerTestHelper.injectEdge(new
IncrementingEnvironmentEdge());
- }
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- TEST_UTIL.shutdownMiniCluster();
- EnvironmentEdgeManager.reset();
- }
-
- @Test
- public void testExceptionThrownWhenMisConfigured() throws IOException {
- Configuration conf = new Configuration(TEST_UTIL.getConfiguration());
- conf.set("hbase.thrift.security.qop", "privacy");
- conf.setBoolean("hbase.thrift.ssl.enabled", false);
- ExpectedException thrown = ExpectedException.none();
- ThriftServerRunner tsr = null;
- try {
- thrown.expect(IllegalArgumentException.class);
- thrown.expectMessage(
- "Thrift HTTP Server's QoP is privacy, " + "but
hbase.thrift.ssl.enabled is false");
- tsr = TestThriftServerCmdLine.createBoundServer(() -> new
ThriftServer(conf));
- fail("Thrift HTTP Server starts up even with wrong security
configurations.");
- } catch (Exception e) {
- LOG.info("Expected!", e);
- } finally {
- if (tsr != null) {
- tsr.close();
- }
- }
- }
+@Tag(ClientTests.TAG)
+@Tag(LargeTests.TAG)
+public class TestThriftHttpServer extends TestThriftHttpServerBase {
- @Rule
- public ExpectedException exception = ExpectedException.none();
-
- @Test
- public void testRunThriftServerWithHeaderBufferLength() throws Exception {
- // Test thrift server with HTTP header length less than 64k
- try {
- runThriftServer(1024 * 63);
- } catch (TTransportException tex) {
- assertFalse(tex.getMessage().equals("HTTP Response code: 431"));
- }
-
- // Test thrift server with HTTP header length more than 64k, expect an
exception
- exception.expect(TTransportException.class);
- exception.expectMessage("HTTP Response code: 431");
- runThriftServer(1024 * 64);
+ @BeforeAll
+ public static void beforeAll() throws Exception {
+ setUpBeforeClass();
}
- protected Supplier<ThriftServer> getThriftServerSupplier() {
- return () -> new ThriftServer(TEST_UTIL.getConfiguration());
- }
-
- @Test
- public void testRunThriftServer() throws Exception {
- runThriftServer(0);
- }
-
- void runThriftServer(int customHeaderSize) throws Exception {
- // Add retries in case we see stuff like connection reset
- Exception clientSideException = null;
- for (int i = 0; i < 10; i++) {
- clientSideException = null;
- ThriftServerRunner tsr = createBoundServer(getThriftServerSupplier());
- String url = "http://" + HConstants.LOCALHOST + ":" +
tsr.getThriftServer().listenPort;
- try {
- checkHttpMethods(url);
- talkToThriftServer(url, customHeaderSize);
- break;
- } catch (Exception ex) {
- clientSideException = ex;
- LOG.info("Client-side Exception", ex);
- } finally {
- tsr.close();
- tsr.join();
- if (tsr.getRunException() != null) {
- LOG.error("Invocation of HBase Thrift server threw exception",
tsr.getRunException());
- throw tsr.getRunException();
- }
- }
- }
-
- if (clientSideException != null) {
- LOG.error("Thrift Client", clientSideException);
- throw clientSideException;
- }
- }
-
- private void checkHttpMethods(String url) throws Exception {
- // HTTP TRACE method should be disabled for security
- // See https://www.owasp.org/index.php/Cross_Site_Tracing
- HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
- conn.setRequestMethod("TRACE");
- conn.connect();
- Assert.assertEquals(conn.getResponseMessage(),
HttpURLConnection.HTTP_FORBIDDEN,
- conn.getResponseCode());
- }
-
- protected static volatile boolean tableCreated = false;
-
- protected void talkToThriftServer(String url, int customHeaderSize) throws
Exception {
- THttpClient httpClient = new THttpClient(url);
- httpClient.open();
-
- if (customHeaderSize > 0) {
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < customHeaderSize; i++) {
- sb.append("a");
- }
- httpClient.setCustomHeader("User-Agent", sb.toString());
- }
-
- try {
- TProtocol prot;
- prot = new TBinaryProtocol(httpClient);
- Hbase.Client client = new Hbase.Client(prot);
- if (!tableCreated) {
- TestThriftServer.createTestTables(client);
- tableCreated = true;
- }
- TestThriftServer.checkTableList(client);
- } finally {
- httpClient.close();
- }
+ @AfterAll
+ public static void afterAll() throws Exception {
+ tearDownAfterClass();
}
}
diff --git
a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftHttpServer.java
b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftHttpServerBase.java
similarity index 83%
copy from
hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftHttpServer.java
copy to
hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftHttpServerBase.java
index 6104ea5abfc..1f2c53ec69a 100644
---
a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftHttpServer.java
+++
b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftHttpServerBase.java
@@ -18,19 +18,18 @@
package org.apache.hadoop.hbase.thrift;
import static
org.apache.hadoop.hbase.thrift.TestThriftServerCmdLine.createBoundServer;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.function.Supplier;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
-import org.apache.hadoop.hbase.testclassification.ClientTests;
-import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.thrift.generated.Hbase;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManagerTestHelper;
@@ -40,32 +39,21 @@ import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.THttpClient;
import org.apache.thrift.transport.TTransportException;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Test;
import org.junit.rules.ExpectedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Start the HBase Thrift HTTP server on a random port through the
command-line interface and talk
- * to it from client side.
+ * Base class for testing HBase Thrift HTTP server. Shared logic without
@BeforeAll/@AfterAll to
+ * allow subclasses to manage their own lifecycle.
*/
-@Category({ ClientTests.class, LargeTests.class })
-public class TestThriftHttpServer {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestThriftHttpServer.class);
+public class TestThriftHttpServerBase {
- private static final Logger LOG =
LoggerFactory.getLogger(TestThriftHttpServer.class);
+ private static final Logger LOG =
LoggerFactory.getLogger(TestThriftHttpServerBase.class);
protected static final HBaseTestingUtility TEST_UTIL = new
HBaseTestingUtility();
- @BeforeClass
public static void setUpBeforeClass() throws Exception {
TEST_UTIL.getConfiguration().setBoolean(Constants.USE_HTTP_CONF_KEY, true);
TEST_UTIL.getConfiguration().setBoolean(TableDescriptorChecker.TABLE_SANITY_CHECKS,
false);
@@ -75,7 +63,6 @@ public class TestThriftHttpServer {
EnvironmentEdgeManagerTestHelper.injectEdge(new
IncrementingEnvironmentEdge());
}
- @AfterClass
public static void tearDownAfterClass() throws Exception {
TEST_UTIL.shutdownMiniCluster();
EnvironmentEdgeManager.reset();
@@ -103,22 +90,19 @@ public class TestThriftHttpServer {
}
}
- @Rule
- public ExpectedException exception = ExpectedException.none();
-
@Test
public void testRunThriftServerWithHeaderBufferLength() throws Exception {
// Test thrift server with HTTP header length less than 64k
try {
runThriftServer(1024 * 63);
} catch (TTransportException tex) {
- assertFalse(tex.getMessage().equals("HTTP Response code: 431"));
+ assertNotEquals("HTTP Response code: 431", tex.getMessage());
}
// Test thrift server with HTTP header length more than 64k, expect an
exception
- exception.expect(TTransportException.class);
- exception.expectMessage("HTTP Response code: 431");
- runThriftServer(1024 * 64);
+ TTransportException exception =
+ assertThrows(TTransportException.class, () -> runThriftServer(1024 *
64));
+ assertEquals("HTTP Response code: 431", exception.getMessage());
}
protected Supplier<ThriftServer> getThriftServerSupplier() {
@@ -166,8 +150,8 @@ public class TestThriftHttpServer {
HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
conn.setRequestMethod("TRACE");
conn.connect();
- Assert.assertEquals(conn.getResponseMessage(),
HttpURLConnection.HTTP_FORBIDDEN,
- conn.getResponseCode());
+ assertEquals(HttpURLConnection.HTTP_FORBIDDEN, conn.getResponseCode(),
+ conn.getResponseMessage());
}
protected static volatile boolean tableCreated = false;
diff --git
a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftHttpServerSSL.java
b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftHttpServerSSL.java
index 8cfa712d7de..1d81a6fc088 100644
---
a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftHttpServerSSL.java
+++
b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftHttpServerSSL.java
@@ -18,7 +18,7 @@
package org.apache.hadoop.hbase.thrift;
import static
org.apache.hadoop.hbase.thrift.TestThriftServerCmdLine.createBoundServer;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.BufferedInputStream;
import java.io.File;
@@ -32,7 +32,6 @@ import java.security.KeyStore;
import java.security.cert.X509Certificate;
import javax.net.ssl.SSLContext;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.testclassification.ClientTests;
@@ -53,21 +52,18 @@ import org.apache.http.ssl.SSLContexts;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TMemoryBuffer;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-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.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category({ ClientTests.class, LargeTests.class })
+@Tag(ClientTests.TAG)
+@Tag(LargeTests.TAG)
public class TestThriftHttpServerSSL {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestThriftHttpServerSSL.class);
private static final Logger LOG =
LoggerFactory.getLogger(TestThriftHttpServerSSL.class);
private static final HBaseTestingUtility TEST_UTIL = new
HBaseTestingUtility();
@@ -79,7 +75,7 @@ public class TestThriftHttpServerSSL {
private ThriftServerRunner tsr;
private HttpPost httpPost = null;
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
TEST_UTIL.getConfiguration().setBoolean(Constants.USE_HTTP_CONF_KEY, true);
TEST_UTIL.getConfiguration().setBoolean(TableDescriptorChecker.TABLE_SANITY_CHECKS,
false);
@@ -89,13 +85,13 @@ public class TestThriftHttpServerSSL {
EnvironmentEdgeManagerTestHelper.injectEdge(new
IncrementingEnvironmentEdge());
}
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() throws Exception {
TEST_UTIL.shutdownMiniCluster();
EnvironmentEdgeManager.reset();
}
- @Before
+ @BeforeEach
public void setUp() throws Exception {
initializeAlgorithmId();
keyDir = initKeystoreDir();
@@ -134,7 +130,7 @@ public class TestThriftHttpServerSSL {
httpPost.setHeader("User-Agent", "Java/THttpClient/HC");
}
- @After
+ @AfterEach
public void tearDown() throws IOException {
if (httpPost != null) {
httpPost.releaseConnection();
diff --git
a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java
b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java
index 4975d1c9451..dd420e3745a 100644
---
a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java
+++
b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java
@@ -18,11 +18,11 @@
package org.apache.hadoop.hbase.thrift;
import static org.apache.hadoop.hbase.thrift.Constants.COALESCE_INC_KEY;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+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.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.IOException;
import java.net.InetAddress;
@@ -36,7 +36,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.CompatibilityFactory;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HConstants;
@@ -71,13 +70,11 @@ import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TestName;
+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.junit.jupiter.api.TestInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -85,13 +82,10 @@ import org.slf4j.LoggerFactory;
* Unit testing for ThriftServerRunner.HBaseServiceHandler, a part of the
* org.apache.hadoop.hbase.thrift package.
*/
-@Category({ ClientTests.class, LargeTests.class })
+@Tag(ClientTests.TAG)
+@Tag(LargeTests.TAG)
public class TestThriftServer {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestThriftServer.class);
-
private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
private static final Logger LOG =
LoggerFactory.getLogger(TestThriftServer.class);
private static final MetricsAssertHelper metricsHelper =
@@ -120,10 +114,7 @@ public class TestThriftServer {
private static ByteBuffer valueDname = asByteBuffer("valueD");
private static ByteBuffer valueEname = asByteBuffer(100l);
- @Rule
- public TestName name = new TestName();
-
- @BeforeClass
+ @BeforeAll
public static void beforeClass() throws Exception {
UTIL.getConfiguration().setBoolean(COALESCE_INC_KEY, true);
UTIL.getConfiguration().setBoolean(TableDescriptorChecker.TABLE_SANITY_CHECKS,
false);
@@ -131,7 +122,7 @@ public class TestThriftServer {
UTIL.startMiniCluster();
}
- @AfterClass
+ @AfterAll
public static void afterClass() throws Exception {
UTIL.shutdownMiniCluster();
}
@@ -216,7 +207,6 @@ public class TestThriftServer {
int currentCountDisableTable = getCurrentCount("disableTable_num_ops", 2,
metrics);
createTestTables(handler);
dropTestTables(handler);
- ;
metricsHelper.assertCounter("createTable_num_ops", currentCountCreateTable
+ 2,
metrics.getSource());
metricsHelper.assertCounter("deleteTable_num_ops", currentCountDeleteTable
+ 2,
@@ -249,8 +239,8 @@ public class TestThriftServer {
public static void createTestTables(Hbase.Iface handler) throws Exception {
// Create/enable/disable/delete tables, ensure methods act correctly
List<java.nio.ByteBuffer> bbs = handler.getTableNames();
- assertEquals(bbs.stream().map(b ->
Bytes.toString(b.array())).collect(Collectors.joining(",")),
- 0, bbs.size());
+ assertEquals(0, bbs.size(),
+ bbs.stream().map(b ->
Bytes.toString(b.array())).collect(Collectors.joining(",")));
handler.createTable(tableAname, getColumnDescriptors());
assertEquals(1, handler.getTableNames().size());
assertEquals(2, handler.getColumnDescriptors(tableAname).size());
@@ -308,8 +298,10 @@ public class TestThriftServer {
Thread.sleep(1000);
long lv = handler.get(tableAname, rowAname, columnAname,
null).get(0).value.getLong();
// Wait on all increments being flushed
- while (handler.coalescer.getQueueSize() != 0)
+ while (handler.coalescer.getQueueSize() != 0) {
Threads.sleep(10);
+ }
+
assertEquals((100 + (2 * numIncrements)), lv);
lv = handler.get(tableAname, rowBname, columnAAname,
null).get(0).value.getLong();
@@ -602,14 +594,14 @@ public class TestThriftServer {
assertEquals(1, handler.getTableNames().size());
List<TRegionInfo> regions = handler.getTableRegions(tableAname);
int regionCount = regions.size();
- assertEquals("empty table should have only 1 region, " + "but found " +
regionCount, 1,
- regionCount);
- LOG.info("Region found:" + regions.get(0));
+ assertEquals(1, regionCount,
+ "empty table should have only 1 region, " + "but found " + regionCount);
+ LOG.info("Region found:{}", regions.get(0));
handler.disableTable(tableAname);
handler.deleteTable(tableAname);
regionCount = handler.getTableRegions(tableAname).size();
- assertEquals("non-existing table should have 0 region, " + "but found " +
regionCount, 0,
- regionCount);
+ assertEquals(0, regionCount,
+ "non-existing table should have 0 region, " + "but found " +
regionCount);
}
public void doTestFilterRegistration() throws Exception {
@@ -732,12 +724,12 @@ public class TestThriftServer {
}
@Test
- public void testMetricsWithException() throws Exception {
+ public void testMetricsWithException(TestInfo testInfo) throws Exception {
String rowkey = "row1";
String family = "f";
String col = "c";
// create a table which will throw exceptions for requests
- final TableName tableName = TableName.valueOf(name.getMethodName());
+ final TableName tableName =
TableName.valueOf(testInfo.getTestMethod().get().getName());
try {
HTableDescriptor tableDesc = new HTableDescriptor(tableName);
tableDesc.addCoprocessor(ErrorThrowingGetObserver.class.getName());
@@ -829,8 +821,14 @@ public class TestThriftServer {
*/
private List<ByteBuffer> getColumnList(boolean includeA, boolean includeB) {
List<ByteBuffer> columnList = new ArrayList<>();
- if (includeA) columnList.add(columnAname);
- if (includeB) columnList.add(columnBname);
+
+ if (includeA) {
+ columnList.add(columnAname);
+ }
+ if (includeB) {
+ columnList.add(columnBname);
+ }
+
return columnList;
}
diff --git
a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServerCmdLine.java
b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServerCmdLine.java
index 7dbe6703a3e..87c4200bbdd 100644
---
a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServerCmdLine.java
+++
b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServerCmdLine.java
@@ -22,17 +22,17 @@ import static
org.apache.hadoop.hbase.thrift.Constants.COMPACT_OPTION;
import static org.apache.hadoop.hbase.thrift.Constants.FRAMED_OPTION;
import static org.apache.hadoop.hbase.thrift.Constants.INFOPORT_OPTION;
import static org.apache.hadoop.hbase.thrift.Constants.PORT_OPTION;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.net.BindException;
import java.net.InetAddress;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.List;
import java.util.function.Supplier;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
+import java.util.stream.Stream;
+import org.apache.hadoop.hbase.HBaseParameterizedTestTemplate;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.net.BoundSocketMaker;
import org.apache.hadoop.hbase.testclassification.ClientTests;
@@ -50,14 +50,11 @@ import org.apache.thrift.server.TServer;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;
import org.apache.thrift.transport.layered.TFramedTransport;
-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.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.TestTemplate;
+import org.junit.jupiter.params.provider.Arguments;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -67,14 +64,11 @@ import
org.apache.hbase.thirdparty.com.google.common.base.Joiner;
* Start the HBase Thrift server on a random port through the command-line
interface and talk to it
* from client side.
*/
-@Category({ ClientTests.class, LargeTests.class })
-@RunWith(Parameterized.class)
+@Tag(ClientTests.TAG)
+@Tag(LargeTests.TAG)
+@HBaseParameterizedTestTemplate
public class TestThriftServerCmdLine {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestThriftServerCmdLine.class);
-
private static final Logger LOG =
LoggerFactory.getLogger(TestThriftServerCmdLine.class);
protected final ImplType implType;
@@ -84,9 +78,8 @@ public class TestThriftServerCmdLine {
protected static final HBaseTestingUtility TEST_UTIL = new
HBaseTestingUtility();
- @Parameters
- public static Collection<Object[]> getParameters() {
- Collection<Object[]> parameters = new ArrayList<>();
+ public static Stream<Arguments> parameters() {
+ List<Arguments> params = new ArrayList<>();
for (ImplType implType : ImplType.values()) {
for (boolean specifyFramed : new boolean[] { false, true }) {
for (boolean specifyBindIP : new boolean[] { false, true }) {
@@ -94,12 +87,12 @@ public class TestThriftServerCmdLine {
continue;
}
for (boolean specifyCompact : new boolean[] { false, true }) {
- parameters.add(new Object[] { implType, specifyFramed,
specifyBindIP, specifyCompact });
+ params.add(Arguments.of(implType, specifyFramed, specifyBindIP,
specifyCompact));
}
}
}
}
- return parameters;
+ return params.stream();
}
public TestThriftServerCmdLine(ImplType implType, boolean specifyFramed,
boolean specifyBindIP,
@@ -116,7 +109,7 @@ public class TestThriftServerCmdLine {
+ "specifyBindIP=" + specifyBindIP + ", " + "specifyCompact=" +
specifyCompact;
}
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
TEST_UTIL.getConfiguration().setBoolean(TableDescriptorChecker.TABLE_SANITY_CHECKS,
false);
TEST_UTIL.startMiniCluster();
@@ -125,7 +118,7 @@ public class TestThriftServerCmdLine {
EnvironmentEdgeManagerTestHelper.injectEdge(new
IncrementingEnvironmentEdge());
}
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() throws Exception {
TEST_UTIL.shutdownMiniCluster();
EnvironmentEdgeManager.reset();
@@ -276,7 +269,7 @@ public class TestThriftServerCmdLine {
return false;
}
- @Test
+ @TestTemplate
public void testRunThriftServer() throws Exception {
// Add retries in case we see stuff like connection reset
Exception clientSideException = null;
diff --git
a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftSpnegoHttpFallbackServer.java
b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftSpnegoHttpFallbackServer.java
index 7d1b6880db1..fa87b17d590 100644
---
a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftSpnegoHttpFallbackServer.java
+++
b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftSpnegoHttpFallbackServer.java
@@ -18,9 +18,9 @@
package org.apache.hadoop.hbase.thrift;
import static
org.apache.hadoop.hbase.thrift.Constants.THRIFT_SUPPORT_PROXYUSER_KEY;
-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.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.nio.file.Paths;
@@ -31,7 +31,6 @@ import java.util.function.Supplier;
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.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.security.HBaseKerberosUtils;
@@ -60,11 +59,11 @@ import org.ietf.jgss.GSSCredential;
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.Disabled;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -74,11 +73,9 @@ import org.slf4j.LoggerFactory;
* TestThriftSpnegoHttpServer which falls back to the original Kerberos
principal and keytab
* configuration properties, not the separate SPNEGO-specific properties.
*/
-@Category({ ClientTests.class, LargeTests.class })
-public class TestThriftSpnegoHttpFallbackServer extends TestThriftHttpServer {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestThriftSpnegoHttpFallbackServer.class);
+@Tag(ClientTests.TAG)
+@Tag(LargeTests.TAG)
+public class TestThriftSpnegoHttpFallbackServer extends
TestThriftHttpServerBase {
private static final Logger LOG =
LoggerFactory.getLogger(TestThriftSpnegoHttpFallbackServer.class);
@@ -108,8 +105,8 @@ public class TestThriftSpnegoHttpFallbackServer extends
TestThriftHttpServer {
conf.set(Constants.THRIFT_KERBEROS_PRINCIPAL_KEY, spnegoServerPrincipal);
}
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ public static void beforeAll() throws Exception {
kdc = SimpleKdcServerUtil.getRunningSimpleKdcServer(
new File(TEST_UTIL.getDataTestDir().toString()),
HBaseTestingUtility::randomFreePort);
@@ -130,12 +127,12 @@ public class TestThriftSpnegoHttpFallbackServer extends
TestThriftHttpServer {
TEST_UTIL.getConfiguration().setBoolean(Constants.USE_HTTP_CONF_KEY, true);
addSecurityConfigurations(TEST_UTIL.getConfiguration());
- TestThriftHttpServer.setUpBeforeClass();
+ TestThriftHttpServerBase.setUpBeforeClass();
}
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- TestThriftHttpServer.tearDownAfterClass();
+ @AfterAll
+ public static void afterAll() throws Exception {
+ TestThriftHttpServerBase.tearDownAfterClass();
try {
if (null != kdc) {
@@ -173,15 +170,15 @@ public class TestThriftSpnegoHttpFallbackServer extends
TestThriftHttpServer {
final Subject clientSubject =
JaasKrbUtil.loginUsingKeytab(clientPrincipal, clientKeytab);
final Set<Principal> clientPrincipals = clientSubject.getPrincipals();
// Make sure the subject has a principal
- assertFalse("Found no client principals in the clientSubject.",
clientPrincipals.isEmpty());
+ assertFalse(clientPrincipals.isEmpty(), "Found no client principals in the
clientSubject.");
// Get a TGT for the subject (might have many, different encryption
types). The first should
// be the default encryption type.
Set<KerberosTicket> privateCredentials =
clientSubject.getPrivateCredentials(KerberosTicket.class);
- assertFalse("Found no private credentials in the clientSubject.",
privateCredentials.isEmpty());
+ assertFalse(privateCredentials.isEmpty(), "Found no private credentials in
the clientSubject.");
KerberosTicket tgt = privateCredentials.iterator().next();
- assertNotNull("No kerberos ticket found.", tgt);
+ assertNotNull(tgt, "No kerberos ticket found.");
// The name of the principal
final String clientPrincipalName =
clientPrincipals.iterator().next().getName();
@@ -217,7 +214,7 @@ public class TestThriftSpnegoHttpFallbackServer extends
TestThriftHttpServer {
* place to succeed. Let the super impl of this test be responsible for
verifying we fail if bad
* header size.
*/
- @org.junit.Ignore
+ @Disabled
@Test
@Override
public void testRunThriftServerWithHeaderBufferLength() throws Exception {
diff --git
a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftSpnegoHttpServer.java
b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftSpnegoHttpServer.java
index 21e86498874..13653d02c42 100644
---
a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftSpnegoHttpServer.java
+++
b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftSpnegoHttpServer.java
@@ -18,8 +18,9 @@
package org.apache.hadoop.hbase.thrift;
import static
org.apache.hadoop.hbase.thrift.Constants.THRIFT_SUPPORT_PROXYUSER_KEY;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
+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.InetAddress;
@@ -34,7 +35,6 @@ import java.util.stream.Collectors;
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.HBaseTestingUtility;
import org.apache.hadoop.hbase.security.HBaseKerberosUtils;
import org.apache.hadoop.hbase.testclassification.ClientTests;
@@ -63,12 +63,11 @@ import org.ietf.jgss.GSSCredential;
import org.ietf.jgss.GSSManager;
import org.ietf.jgss.GSSName;
import org.ietf.jgss.Oid;
-import org.junit.AfterClass;
-import org.junit.Assert;
-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.Disabled;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -76,11 +75,9 @@ import org.slf4j.LoggerFactory;
* Start the HBase Thrift HTTP server on a random port through the
command-line interface and talk
* to it from client side with SPNEGO security enabled.
*/
-@Category({ ClientTests.class, LargeTests.class })
-public class TestThriftSpnegoHttpServer extends TestThriftHttpServer {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestThriftSpnegoHttpServer.class);
+@Tag(ClientTests.TAG)
+@Tag(LargeTests.TAG)
+public class TestThriftSpnegoHttpServer extends TestThriftHttpServerBase {
private static final Logger LOG =
LoggerFactory.getLogger(TestThriftSpnegoHttpServer.class);
@@ -111,12 +108,12 @@ public class TestThriftSpnegoHttpServer extends
TestThriftHttpServer {
conf.set(Constants.THRIFT_SPNEGO_KEYTAB_FILE_KEY,
spnegoServerKeytab.getAbsolutePath());
}
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ public static void beforeAll() throws Exception {
kdc = SimpleKdcServerUtil.getRunningSimpleKdcServer(
new File(TEST_UTIL.getDataTestDir().toString()),
HBaseTestingUtility::randomFreePort);
File keytabDir =
Paths.get(TEST_UTIL.getRandomDir().toString()).toAbsolutePath().toFile();
- Assert.assertTrue(keytabDir.mkdirs());
+ assertTrue(keytabDir.mkdirs());
clientPrincipal = "client@" + kdc.getKdcConfig().getKdcRealm();
clientKeytab = new File(keytabDir, clientPrincipal + ".keytab");
@@ -135,7 +132,7 @@ public class TestThriftSpnegoHttpServer extends
TestThriftHttpServer {
TEST_UTIL.getConfiguration().setBoolean(Constants.USE_HTTP_CONF_KEY, true);
addSecurityConfigurations(TEST_UTIL.getConfiguration());
- TestThriftHttpServer.setUpBeforeClass();
+ TestThriftHttpServerBase.setUpBeforeClass();
}
@Override
@@ -143,9 +140,9 @@ public class TestThriftSpnegoHttpServer extends
TestThriftHttpServer {
return () -> new ThriftServer(TEST_UTIL.getConfiguration());
}
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- TestThriftHttpServer.tearDownAfterClass();
+ @AfterAll
+ public static void afterAll() throws Exception {
+ TestThriftHttpServerBase.tearDownAfterClass();
try {
if (null != kdc) {
@@ -163,7 +160,7 @@ public class TestThriftSpnegoHttpServer extends
TestThriftHttpServer {
* place to succeed. Let the super impl of this test be responsible for
verifying we fail if bad
* header size.
*/
- @org.junit.Ignore
+ @Disabled
@Test
@Override
public void testRunThriftServerWithHeaderBufferLength() throws Exception {
@@ -205,15 +202,15 @@ public class TestThriftSpnegoHttpServer extends
TestThriftHttpServer {
final Subject clientSubject =
JaasKrbUtil.loginUsingKeytab(clientPrincipal, clientKeytab);
final Set<Principal> clientPrincipals = clientSubject.getPrincipals();
// Make sure the subject has a principal
- assertFalse("Found no client principals in the clientSubject.",
clientPrincipals.isEmpty());
+ assertFalse(clientPrincipals.isEmpty(), "Found no client principals in the
clientSubject.");
// Get a TGT for the subject (might have many, different encryption
types). The first should
// be the default encryption type.
Set<KerberosTicket> privateCredentials =
clientSubject.getPrivateCredentials(KerberosTicket.class);
- assertFalse("Found no private credentials in the clientSubject.",
privateCredentials.isEmpty());
+ assertFalse(privateCredentials.isEmpty(), "Found no private credentials in
the clientSubject.");
KerberosTicket tgt = privateCredentials.iterator().next();
- assertNotNull("No kerberos ticket found.", tgt);
+ assertNotNull(tgt, "No kerberos ticket found.");
// The name of the principal
final String clientPrincipalName =
clientPrincipals.iterator().next().getName();
diff --git
a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThrift2HttpServer.java
b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThrift2HttpServer.java
index 9f663d698a9..a693f31e454 100644
---
a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThrift2HttpServer.java
+++
b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThrift2HttpServer.java
@@ -17,12 +17,14 @@
*/
package org.apache.hadoop.hbase.thrift2;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.util.ArrayList;
import java.util.function.Supplier;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.ClientTests;
import org.apache.hadoop.hbase.testclassification.LargeTests;
-import org.apache.hadoop.hbase.thrift.TestThriftHttpServer;
+import org.apache.hadoop.hbase.thrift.TestThriftHttpServerBase;
import org.apache.hadoop.hbase.thrift.ThriftServer;
import org.apache.hadoop.hbase.thrift2.generated.TColumnFamilyDescriptor;
import org.apache.hadoop.hbase.thrift2.generated.THBaseService;
@@ -32,17 +34,24 @@ import org.apache.hadoop.hbase.util.Bytes;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.THttpClient;
-import org.junit.Assert;
-import org.junit.ClassRule;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
-@Category({ ClientTests.class, LargeTests.class })
-public class TestThrift2HttpServer extends TestThriftHttpServer {
+@Tag(ClientTests.TAG)
+@Tag(LargeTests.TAG)
+public class TestThrift2HttpServer extends TestThriftHttpServerBase {
private static final String TABLENAME = "TestThrift2HttpServerTable";
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestThrift2HttpServer.class);
+ @BeforeAll
+ public static void beforeAll() throws Exception {
+ TestThriftHttpServerBase.setUpBeforeClass();
+ }
+
+ @AfterAll
+ public static void afterAll() throws Exception {
+ TestThriftHttpServerBase.tearDownAfterClass();
+ }
@Override
protected Supplier<ThriftServer> getThriftServerSupplier() {
@@ -70,7 +79,7 @@ public class TestThrift2HttpServer extends
TestThriftHttpServer {
tTableName.setNs(Bytes.toBytes(""));
tTableName.setQualifier(Bytes.toBytes(TABLENAME));
if (!tableCreated) {
- Assert.assertTrue(!client.tableExists(tTableName));
+ assertFalse(client.tableExists(tTableName));
TTableDescriptor tTableDescriptor = new TTableDescriptor();
tTableDescriptor.setTableName(tTableName);
TColumnFamilyDescriptor columnFamilyDescriptor = new
TColumnFamilyDescriptor();
@@ -79,10 +88,9 @@ public class TestThrift2HttpServer extends
TestThriftHttpServer {
client.createTable(tTableDescriptor, new ArrayList<>());
tableCreated = true;
}
- Assert.assertTrue(client.tableExists(tTableName));
+ assertTrue(client.tableExists(tTableName));
} finally {
httpClient.close();
}
}
-
}
diff --git
a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThrift2ServerCmdLine.java
b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThrift2ServerCmdLine.java
index 240c9b881ab..4e2173cec5f 100644
---
a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThrift2ServerCmdLine.java
+++
b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThrift2ServerCmdLine.java
@@ -17,10 +17,14 @@
*/
package org.apache.hadoop.hbase.thrift2;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.function.Supplier;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
+import java.util.stream.Stream;
+import org.apache.hadoop.hbase.HBaseParameterizedTestTemplate;
import org.apache.hadoop.hbase.testclassification.ClientTests;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.thrift.ImplType;
@@ -37,18 +41,20 @@ import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;
import org.apache.thrift.transport.layered.TFramedTransport;
-import org.junit.Assert;
-import org.junit.ClassRule;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.params.provider.Arguments;
-@Category({ ClientTests.class, LargeTests.class })
+@Tag(ClientTests.TAG)
+@Tag(LargeTests.TAG)
+@HBaseParameterizedTestTemplate
public class TestThrift2ServerCmdLine extends TestThriftServerCmdLine {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestThrift2ServerCmdLine.class);
private static final String TABLENAME = "TestThrift2ServerCmdLineTable";
+ public static Stream<Arguments> parameters() {
+ return TestThriftServerCmdLine.parameters();
+ }
+
public TestThrift2ServerCmdLine(ImplType implType, boolean specifyFramed,
boolean specifyBindIP,
boolean specifyCompact) {
super(implType, specifyFramed, specifyBindIP, specifyCompact);
@@ -80,7 +86,7 @@ public class TestThrift2ServerCmdLine extends
TestThriftServerCmdLine {
tTableName.setNs(Bytes.toBytes(""));
tTableName.setQualifier(Bytes.toBytes(TABLENAME));
if (!tableCreated) {
- Assert.assertTrue(!client.tableExists(tTableName));
+ assertFalse(client.tableExists(tTableName));
TTableDescriptor tTableDescriptor = new TTableDescriptor();
tTableDescriptor.setTableName(tTableName);
TColumnFamilyDescriptor columnFamilyDescriptor = new
TColumnFamilyDescriptor();
@@ -89,7 +95,7 @@ public class TestThrift2ServerCmdLine extends
TestThriftServerCmdLine {
client.createTable(tTableDescriptor, new ArrayList<>());
tableCreated = true;
}
- Assert.assertTrue("tableCreated " + tableCreated,
client.tableExists(tTableName));
+ assertTrue(client.tableExists(tTableName), "tableCreated " +
tableCreated);
} finally {
sock.close();
}
diff --git
a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftConnection.java
b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftConnection.java
index 24c1ccdeccc..dd1b13d5315 100644
---
a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftConnection.java
+++
b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftConnection.java
@@ -18,11 +18,11 @@
package org.apache.hadoop.hbase.thrift2;
import static org.apache.hadoop.hbase.thrift.Constants.THRIFT_INFO_SERVER_PORT;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-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.IOException;
import java.util.ArrayList;
@@ -33,7 +33,6 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.CompareOperator;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
@@ -66,23 +65,18 @@ import org.apache.hadoop.hbase.thrift.Constants;
import org.apache.hadoop.hbase.thrift2.client.ThriftConnection;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
-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({ RestTests.class, LargeTests.class })
-
+@Tag(RestTests.TAG)
+@Tag(LargeTests.TAG)
public class TestThriftConnection {
private static final Logger LOG =
LoggerFactory.getLogger(TestThriftConnection.class);
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestThriftConnection.class);
-
private static final byte[] FAMILYA = Bytes.toBytes("fa");
private static final byte[] FAMILYB = Bytes.toBytes("fb");
private static final byte[] FAMILYC = Bytes.toBytes("fc");
@@ -156,7 +150,7 @@ public class TestThriftConnection {
return ConnectionFactory.createConnection(conf);
}
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
// Do not start info server
TEST_UTIL.getConfiguration().setInt(THRIFT_INFO_SERVER_PORT, -1);
@@ -175,7 +169,7 @@ public class TestThriftConnection {
}
- @AfterClass
+ @AfterAll
public static void shutdown() throws Exception {
if (thriftAdmin != null) {
thriftAdmin.close();
diff --git
a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandler.java
b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandler.java
index dac3a8d0a59..3c98a1f2e62 100644
---
a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandler.java
+++
b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandler.java
@@ -27,12 +27,12 @@ import static
org.apache.hadoop.hbase.thrift2.ThriftUtilities.getFromThrift;
import static
org.apache.hadoop.hbase.thrift2.ThriftUtilities.incrementFromThrift;
import static org.apache.hadoop.hbase.thrift2.ThriftUtilities.putFromThrift;
import static org.apache.hadoop.hbase.thrift2.ThriftUtilities.scanFromThrift;
-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.Assert.fail;
+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 static org.junit.jupiter.api.Assertions.fail;
import java.io.IOException;
import java.io.InterruptedIOException;
@@ -54,7 +54,6 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CompatibilityFactory;
import org.apache.hadoop.hbase.CoprocessorEnvironment;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
@@ -123,15 +122,13 @@ import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TestName;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -142,13 +139,10 @@ import
org.apache.hbase.thirdparty.org.apache.commons.collections4.CollectionUti
* Unit testing for ThriftServer.HBaseServiceHandler, a part of the
org.apache.hadoop.hbase.thrift2
* package.
*/
-@Category({ ClientTests.class, LargeTests.class })
+@Tag(ClientTests.TAG)
+@Tag(LargeTests.TAG)
public class TestThriftHBaseServiceHandler {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestThriftHBaseServiceHandler.class);
-
private static final Logger LOG =
LoggerFactory.getLogger(TestThriftHBaseServiceHandler.class);
private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
@@ -167,9 +161,6 @@ public class TestThriftHBaseServiceHandler {
private static final MetricsAssertHelper metricsHelper =
CompatibilityFactory.getInstance(MetricsAssertHelper.class);
- @Rule
- public TestName name = new TestName();
-
public void assertTColumnValuesEqual(List<TColumnValue> columnValuesA,
List<TColumnValue> columnValuesB) {
assertEquals(columnValuesA.size(), columnValuesB.size());
@@ -196,7 +187,7 @@ public class TestThriftHBaseServiceHandler {
assertArrayEquals(a.getValue(), b.getValue());
}
- @BeforeClass
+ @BeforeAll
public static void beforeClass() throws Exception {
UTIL.getConfiguration().set("hbase.client.retries.number", "3");
UTIL.getConfiguration().setBoolean("hbase.regionserver.slowlog.buffer.enabled",
true);
@@ -210,12 +201,12 @@ public class TestThriftHBaseServiceHandler {
}
}
- @AfterClass
+ @AfterAll
public static void afterClass() throws Exception {
UTIL.shutdownMiniCluster();
}
- @Before
+ @BeforeEach
public void setup() throws Exception {
}
@@ -1278,12 +1269,12 @@ public class TestThriftHBaseServiceHandler {
}
@Test
- public void testMetricsWithException() throws Exception {
+ public void testMetricsWithException(TestInfo testInfo) throws Exception {
byte[] rowkey = Bytes.toBytes("row1");
byte[] family = Bytes.toBytes("f");
byte[] col = Bytes.toBytes("c");
// create a table which will throw exceptions for requests
- TableName tableName = TableName.valueOf(name.getMethodName());
+ TableName tableName =
TableName.valueOf(testInfo.getTestMethod().get().getName());
HTableDescriptor tableDesc = new HTableDescriptor(tableName);
tableDesc.addCoprocessor(ErrorThrowingGetObserver.class.getName());
tableDesc.addFamily(new HColumnDescriptor(family));
@@ -1579,8 +1570,9 @@ public class TestThriftHBaseServiceHandler {
assertEquals(0, result.getColumnValuesSize());
// checkAndMutate -- condition should fail because the value doesn't exist.
- assertFalse("Expected condition to not pass",
handler.checkAndMutate(table, row, family,
- qualifier, TCompareOp.EQUAL, value, tRowMutations));
+ assertFalse(
+ handler.checkAndMutate(table, row, family, qualifier, TCompareOp.EQUAL,
value, tRowMutations),
+ "Expected condition to not pass");
List<TColumnValue> columnValuesA = new ArrayList<>(1);
TColumnValue columnValueA = new TColumnValue(family, qualifier, value);
@@ -1595,8 +1587,9 @@ public class TestThriftHBaseServiceHandler {
assertTColumnValueEqual(columnValueA, result.getColumnValues().get(0));
// checkAndMutate -- condition should pass since we added the value
- assertTrue("Expected condition to pass", handler.checkAndMutate(table,
row, family, qualifier,
- TCompareOp.EQUAL, value, tRowMutations));
+ assertTrue(
+ handler.checkAndMutate(table, row, family, qualifier, TCompareOp.EQUAL,
value, tRowMutations),
+ "Expected condition to pass");
result = handler.get(table, new TGet(row));
assertEquals(2, result.getColumnValuesSize());
@@ -1770,18 +1763,18 @@ public class TestThriftHBaseServiceHandler {
Set<TServerName> tServerNames =
ThriftUtilities.getServerNamesFromHBase(new HashSet<>(serverNames));
List<Boolean> clearedResponses =
thriftHBaseServiceHandler.clearSlowLogResponses(tServerNames);
- clearedResponses.forEach(Assert::assertTrue);
+ clearedResponses.forEach(Assertions::assertTrue);
TLogQueryFilter tLogQueryFilter = new TLogQueryFilter();
tLogQueryFilter.setLimit(15);
- Assert.assertEquals(tLogQueryFilter.getFilterByOperator(),
TFilterByOperator.OR);
+ assertEquals(TFilterByOperator.OR, tLogQueryFilter.getFilterByOperator());
LogQueryFilter logQueryFilter =
ThriftUtilities.getSlowLogQueryFromThrift(tLogQueryFilter);
- Assert.assertEquals(logQueryFilter.getFilterByOperator(),
LogQueryFilter.FilterByOperator.OR);
+ assertEquals(LogQueryFilter.FilterByOperator.OR,
logQueryFilter.getFilterByOperator());
tLogQueryFilter.setFilterByOperator(TFilterByOperator.AND);
logQueryFilter =
ThriftUtilities.getSlowLogQueryFromThrift(tLogQueryFilter);
- Assert.assertEquals(logQueryFilter.getFilterByOperator(),
LogQueryFilter.FilterByOperator.AND);
+ assertEquals(LogQueryFilter.FilterByOperator.AND,
logQueryFilter.getFilterByOperator());
List<TOnlineLogRecord> tLogRecords =
thriftHBaseServiceHandler.getSlowLogResponses(tServerNames,
tLogQueryFilter);
- assertEquals(tLogRecords.size(), 0);
+ assertEquals(0, tLogRecords.size());
}
public static class DelayingRegionObserver implements RegionCoprocessor,
RegionObserver {
diff --git
a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandlerWithLabels.java
b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandlerWithLabels.java
index 505295d7700..bf3d8f81ba6 100644
---
a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandlerWithLabels.java
+++
b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandlerWithLabels.java
@@ -18,10 +18,11 @@
package org.apache.hadoop.hbase.thrift2;
import static java.nio.ByteBuffer.wrap;
-import static org.junit.Assert.assertArrayEquals;
-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.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.fail;
import java.io.IOException;
import java.nio.ByteBuffer;
@@ -31,7 +32,6 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
@@ -63,23 +63,18 @@ import org.apache.hadoop.hbase.thrift2.generated.TPut;
import org.apache.hadoop.hbase.thrift2.generated.TResult;
import org.apache.hadoop.hbase.thrift2.generated.TScan;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-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.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category({ ClientTests.class, MediumTests.class })
+@Tag(ClientTests.TAG)
+@Tag(MediumTests.TAG)
public class TestThriftHBaseServiceHandlerWithLabels {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestThriftHBaseServiceHandlerWithLabels.class);
-
private static final Logger LOG =
LoggerFactory.getLogger(TestThriftHBaseServiceHandlerWithLabels.class);
private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
@@ -127,7 +122,7 @@ public class TestThriftHBaseServiceHandlerWithLabels {
}
}
- @BeforeClass
+ @BeforeAll
public static void beforeClass() throws Exception {
SUPERUSER = User.createUserForTesting(conf, "admin", new String[] {
"supergroup" });
@@ -176,12 +171,12 @@ public class TestThriftHBaseServiceHandlerWithLabels {
}
}
- @AfterClass
+ @AfterAll
public static void afterClass() throws Exception {
UTIL.shutdownMiniCluster();
}
- @Before
+ @BeforeEach
public void setup() throws Exception {
}
@@ -232,7 +227,7 @@ public class TestThriftHBaseServiceHandlerWithLabels {
int scanId = handler.openScanner(table, scan);
List<TResult> results = handler.getScannerRows(scanId, 10);
assertEquals(9, results.size());
- Assert.assertFalse(Bytes.equals(results.get(5).getRow(),
Bytes.toBytes("testScan" + 5)));
+ assertFalse(Bytes.equals(results.get(5).getRow(), Bytes.toBytes("testScan"
+ 5)));
for (int i = 0; i < 9; i++) {
if (i < 5) {
assertArrayEquals(Bytes.toBytes("testScan" + i),
results.get(i).getRow());
diff --git
a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandlerWithReadOnly.java
b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandlerWithReadOnly.java
index 3bb39e8c0a5..00f674e92c0 100644
---
a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandlerWithReadOnly.java
+++
b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandlerWithReadOnly.java
@@ -18,9 +18,9 @@
package org.apache.hadoop.hbase.thrift2;
import static java.nio.ByteBuffer.wrap;
-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.io.IOException;
import java.nio.ByteBuffer;
@@ -29,7 +29,6 @@ import java.util.Arrays;
import java.util.List;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.DoNotRetryIOException;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
@@ -52,20 +51,16 @@ import
org.apache.hadoop.hbase.thrift2.generated.TRowMutations;
import org.apache.hadoop.hbase.thrift2.generated.TScan;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.thrift.TException;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-@Category({ ClientTests.class, MediumTests.class })
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+
+@Tag(ClientTests.TAG)
+@Tag(MediumTests.TAG)
public class TestThriftHBaseServiceHandlerWithReadOnly {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
-
HBaseClassTestRule.forClass(TestThriftHBaseServiceHandlerWithReadOnly.class);
-
private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
// Static names for tables, columns, rows, and values
@@ -80,7 +75,7 @@ public class TestThriftHBaseServiceHandlerWithReadOnly {
new HColumnDescriptor[] { new
HColumnDescriptor(familyAname).setMaxVersions(3),
new HColumnDescriptor(familyBname).setMaxVersions(2) };
- @BeforeClass
+ @BeforeAll
public static void beforeClass() throws Exception {
UTIL.getConfiguration().setBoolean("hbase.thrift.readonly", true);
UTIL.getConfiguration().set("hbase.client.retries.number", "3");
@@ -94,12 +89,12 @@ public class TestThriftHBaseServiceHandlerWithReadOnly {
admin.close();
}
- @AfterClass
+ @AfterAll
public static void afterClass() throws Exception {
UTIL.shutdownMiniCluster();
}
- @Before
+ @BeforeEach
public void setup() throws Exception {
}