1717 */
1818package org .apache .hadoop .hbase ;
1919
20- import static org .junit .Assert .assertEquals ;
21- import static org .junit .Assert .assertNotNull ;
22- import static org .junit .Assert .assertNull ;
23- import static org .junit .Assert .assertTrue ;
20+ import static org .junit .jupiter . api . Assertions .assertEquals ;
21+ import static org .junit .jupiter . api . Assertions .assertNotNull ;
22+ import static org .junit .jupiter . api . Assertions .assertNull ;
23+ import static org .junit .jupiter . api . Assertions .assertTrue ;
2424import static org .mockito .ArgumentMatchers .any ;
2525import static org .mockito .Mockito .doReturn ;
2626import static org .mockito .Mockito .mock ;
5555import org .apache .hadoop .hbase .util .Bytes ;
5656import org .apache .hadoop .hbase .util .EnvironmentEdgeManager ;
5757import org .apache .hadoop .hbase .util .Pair ;
58- import org .junit .AfterClass ;
59- import org .junit .BeforeClass ;
60- import org .junit .ClassRule ;
61- import org .junit .Rule ;
62- import org .junit .Test ;
63- import org .junit .experimental .categories .Category ;
64- import org .junit .rules .TestName ;
58+ import org .junit .jupiter .api .AfterAll ;
59+ import org .junit .jupiter .api .BeforeAll ;
60+ import org .junit .jupiter .api .Tag ;
61+ import org .junit .jupiter .api .Test ;
62+ import org .junit .jupiter .api .TestInfo ;
6563import org .slf4j .Logger ;
6664import org .slf4j .LoggerFactory ;
6765
7068/**
7169 * Test {@link org.apache.hadoop.hbase.MetaTableAccessor}.
7270 */
73- @ Category ({ MiscTests .class , MediumTests .class })
71+ @ Tag (MiscTests .TAG )
72+ @ Tag (MediumTests .TAG )
7473@ SuppressWarnings ("deprecation" )
7574public class TestMetaTableAccessor {
76- @ ClassRule
77- public static final HBaseClassTestRule CLASS_RULE =
78- HBaseClassTestRule .forClass (TestMetaTableAccessor .class );
79-
8075 private static final Logger LOG = LoggerFactory .getLogger (TestMetaTableAccessor .class );
8176 private static final HBaseTestingUtil UTIL = new HBaseTestingUtil ();
8277 private static Connection connection ;
8378
84- @ Rule
85- public TestName name = new TestName ();
86-
87- @ BeforeClass
79+ @ BeforeAll
8880 public static void beforeClass () throws Exception {
8981 UTIL .startMiniCluster (3 );
9082
@@ -96,7 +88,7 @@ public static void beforeClass() throws Exception {
9688 connection = ConnectionFactory .createConnection (c );
9789 }
9890
99- @ AfterClass
91+ @ AfterAll
10092 public static void afterClass () throws Exception {
10193 connection .close ();
10294 UTIL .shutdownMiniCluster ();
@@ -122,8 +114,8 @@ public void testIsMetaWhenMetaGoesOffline() throws InterruptedException {
122114 * while its hosted server is restarted to prove our retrying works.
123115 */
124116 @ Test
125- public void testRetrying () throws IOException , InterruptedException {
126- final TableName tableName = TableName .valueOf (name . getMethodName ());
117+ public void testRetrying (TestInfo testInfo ) throws IOException , InterruptedException {
118+ final TableName tableName = TableName .valueOf (testInfo . getTestMethod (). get (). getName ());
127119 LOG .info ("Started " + tableName );
128120 Table t = UTIL .createMultiRegionTable (tableName , HConstants .CATALOG_FAMILY );
129121 int regionCount = -1 ;
@@ -178,8 +170,8 @@ void metaTask() throws IOException {
178170 }
179171 }
180172
181- assertTrue ("reader: " + reader .toString (), reader . isProgressing ());
182- assertTrue ("writer: " + writer .toString (), writer . isProgressing ());
173+ assertTrue (reader . isProgressing (), "reader: " + reader .toString ());
174+ assertTrue (writer . isProgressing (), "writer: " + writer .toString ());
183175 } catch (IOException e ) {
184176 throw e ;
185177 } finally {
@@ -190,7 +182,7 @@ void metaTask() throws IOException {
190182 t .close ();
191183 }
192184 long exeTime = EnvironmentEdgeManager .currentTime () - startTime ;
193- assertTrue ("Timeout: test took " + exeTime / 1000 + " sec" , exeTime < timeOut );
185+ assertTrue (exeTime < timeOut , "Timeout: test took " + exeTime / 1000 + " sec" );
194186 }
195187
196188 /**
@@ -242,8 +234,8 @@ public String toString() {
242234 }
243235
244236 @ Test
245- public void testGetRegion () throws IOException , InterruptedException {
246- final String name = this . name . getMethodName ();
237+ public void testGetRegion (TestInfo testInfo ) throws IOException , InterruptedException {
238+ final String name = testInfo . getTestMethod (). get (). getName ();
247239 LOG .info ("Started " + name );
248240 // Test get on non-existent region.
249241 Pair <RegionInfo , ServerName > pair =
@@ -254,8 +246,8 @@ public void testGetRegion() throws IOException, InterruptedException {
254246
255247 // Test for the optimization made in HBASE-3650
256248 @ Test
257- public void testScanMetaForTable () throws IOException , InterruptedException {
258- final TableName tableName = TableName .valueOf (name . getMethodName ());
249+ public void testScanMetaForTable (TestInfo testInfo ) throws IOException , InterruptedException {
250+ final TableName tableName = TableName .valueOf (testInfo . getTestMethod (). get (). getName ());
259251 LOG .info ("Started " + tableName );
260252
261253 /**
@@ -291,23 +283,26 @@ private static void testGetRegion(final Connection connection, final RegionInfo
291283 }
292284
293285 @ Test
294- public void testMetaLocationsForRegionReplicas () throws IOException {
286+ public void testMetaLocationsForRegionReplicas (TestInfo testInfo ) throws IOException {
295287 Random rand = ThreadLocalRandom .current ();
296288
297289 ServerName serverName0 = ServerName .valueOf ("foo" , 60010 , rand .nextLong ());
298290 ServerName serverName1 = ServerName .valueOf ("bar" , 60010 , rand .nextLong ());
299291 ServerName serverName100 = ServerName .valueOf ("baz" , 60010 , rand .nextLong ());
300292
301293 long regionId = EnvironmentEdgeManager .currentTime ();
302- RegionInfo primary = RegionInfoBuilder .newBuilder (TableName .valueOf (name .getMethodName ()))
303- .setStartKey (HConstants .EMPTY_START_ROW ).setEndKey (HConstants .EMPTY_END_ROW ).setSplit (false )
304- .setRegionId (regionId ).setReplicaId (0 ).build ();
305- RegionInfo replica1 = RegionInfoBuilder .newBuilder (TableName .valueOf (name .getMethodName ()))
306- .setStartKey (HConstants .EMPTY_START_ROW ).setEndKey (HConstants .EMPTY_END_ROW ).setSplit (false )
307- .setRegionId (regionId ).setReplicaId (1 ).build ();
308- RegionInfo replica100 = RegionInfoBuilder .newBuilder (TableName .valueOf (name .getMethodName ()))
309- .setStartKey (HConstants .EMPTY_START_ROW ).setEndKey (HConstants .EMPTY_END_ROW ).setSplit (false )
310- .setRegionId (regionId ).setReplicaId (100 ).build ();
294+ RegionInfo primary =
295+ RegionInfoBuilder .newBuilder (TableName .valueOf (testInfo .getTestMethod ().get ().getName ()))
296+ .setStartKey (HConstants .EMPTY_START_ROW ).setEndKey (HConstants .EMPTY_END_ROW ).setSplit (false )
297+ .setRegionId (regionId ).setReplicaId (0 ).build ();
298+ RegionInfo replica1 =
299+ RegionInfoBuilder .newBuilder (TableName .valueOf (testInfo .getTestMethod ().get ().getName ()))
300+ .setStartKey (HConstants .EMPTY_START_ROW ).setEndKey (HConstants .EMPTY_END_ROW ).setSplit (false )
301+ .setRegionId (regionId ).setReplicaId (1 ).build ();
302+ RegionInfo replica100 =
303+ RegionInfoBuilder .newBuilder (TableName .valueOf (testInfo .getTestMethod ().get ().getName ()))
304+ .setStartKey (HConstants .EMPTY_START_ROW ).setEndKey (HConstants .EMPTY_END_ROW ).setSplit (false )
305+ .setRegionId (regionId ).setReplicaId (100 ).build ();
311306
312307 long seqNum0 = rand .nextLong ();
313308 long seqNum1 = rand .nextLong ();
@@ -372,11 +367,13 @@ public static void assertEmptyMetaLocation(Table meta, byte[] row, int replicaId
372367 }
373368
374369 @ Test
375- public void testMetaLocationForRegionReplicasIsAddedAtTableCreation () throws IOException {
370+ public void testMetaLocationForRegionReplicasIsAddedAtTableCreation (TestInfo testInfo )
371+ throws IOException {
376372 long regionId = EnvironmentEdgeManager .currentTime ();
377- RegionInfo primary = RegionInfoBuilder .newBuilder (TableName .valueOf (name .getMethodName ()))
378- .setStartKey (HConstants .EMPTY_START_ROW ).setEndKey (HConstants .EMPTY_END_ROW ).setSplit (false )
379- .setRegionId (regionId ).setReplicaId (0 ).build ();
373+ RegionInfo primary =
374+ RegionInfoBuilder .newBuilder (TableName .valueOf (testInfo .getTestMethod ().get ().getName ()))
375+ .setStartKey (HConstants .EMPTY_START_ROW ).setEndKey (HConstants .EMPTY_END_ROW ).setSplit (false )
376+ .setRegionId (regionId ).setReplicaId (0 ).build ();
380377
381378 Table meta = MetaTableAccessor .getMetaHTable (connection );
382379 try {
@@ -391,10 +388,10 @@ public void testMetaLocationForRegionReplicasIsAddedAtTableCreation() throws IOE
391388 }
392389
393390 @ Test
394- public void testMetaScanner () throws Exception {
395- LOG .info ("Starting " + name . getMethodName ());
391+ public void testMetaScanner (TestInfo testInfo ) throws Exception {
392+ LOG .info ("Starting " + testInfo . getTestMethod (). get (). getName ());
396393
397- final TableName tableName = TableName .valueOf (name . getMethodName ());
394+ final TableName tableName = TableName .valueOf (testInfo . getTestMethod (). get (). getName ());
398395 final byte [] FAMILY = Bytes .toBytes ("family" );
399396 final byte [][] SPLIT_KEYS =
400397 new byte [][] { Bytes .toBytes ("region_a" ), Bytes .toBytes ("region_b" ) };
@@ -437,11 +434,12 @@ public void testMetaScanner() throws Exception {
437434 * Tests whether maximum of masters system time versus RSs local system time is used
438435 */
439436 @ Test
440- public void testMastersSystemTimeIsUsedInUpdateLocations () throws IOException {
437+ public void testMastersSystemTimeIsUsedInUpdateLocations (TestInfo testInfo ) throws IOException {
441438 long regionId = EnvironmentEdgeManager .currentTime ();
442- RegionInfo regionInfo = RegionInfoBuilder .newBuilder (TableName .valueOf (name .getMethodName ()))
443- .setStartKey (HConstants .EMPTY_START_ROW ).setEndKey (HConstants .EMPTY_END_ROW ).setSplit (false )
444- .setRegionId (regionId ).setReplicaId (0 ).build ();
439+ RegionInfo regionInfo =
440+ RegionInfoBuilder .newBuilder (TableName .valueOf (testInfo .getTestMethod ().get ().getName ()))
441+ .setStartKey (HConstants .EMPTY_START_ROW ).setEndKey (HConstants .EMPTY_END_ROW ).setSplit (false )
442+ .setRegionId (regionId ).setReplicaId (0 ).build ();
445443
446444 ServerName sn = ServerName .valueOf ("bar" , 0 , 0 );
447445 try (Table meta = MetaTableAccessor .getMetaHTable (connection )) {
0 commit comments