1717 */
1818package org .apache .hadoop .hbase .quotas ;
1919
20- import static org .junit .Assert .assertEquals ;
21- import static org .junit .Assert .assertTrue ;
22- import static org .junit .Assert .fail ;
20+ import static org .junit .jupiter . api . Assertions .assertEquals ;
21+ import static org .junit .jupiter . api . Assertions .assertTrue ;
22+ import static org .junit .jupiter . api . Assertions .fail ;
2323
2424import java .io .IOException ;
2525import java .util .ArrayList ;
6464import org .apache .hadoop .hbase .util .Pair ;
6565import org .apache .hadoop .util .StringUtils ;
6666import org .apache .yetus .audience .InterfaceAudience ;
67- import org .junit .rules .TestName ;
6867import org .slf4j .Logger ;
6968import org .slf4j .LoggerFactory ;
7069
@@ -83,11 +82,11 @@ public class SpaceQuotaHelperForTests {
8382 public static final long ONE_GIGABYTE = ONE_MEGABYTE * ONE_KILOBYTE ;
8483
8584 private final HBaseTestingUtility testUtil ;
86- private final TestName testName ;
85+ private final String testName ;
8786 private final AtomicLong counter ;
8887 private static final int NUM_RETRIES = 10 ;
8988
90- public SpaceQuotaHelperForTests (HBaseTestingUtility testUtil , TestName testName ,
89+ public SpaceQuotaHelperForTests (HBaseTestingUtility testUtil , String testName ,
9190 AtomicLong counter ) {
9291 this .testUtil = Objects .requireNonNull (testUtil );
9392 this .testName = Objects .requireNonNull (testName );
@@ -231,12 +230,13 @@ void verifyViolation(SpaceViolationPolicy policyToViolate, TableName tn, Mutatio
231230 assertTrue (
232231 msg .contains ("TableNotEnabledException" ) || msg .contains (policyToViolate .name ()));
233232 } else {
234- assertTrue ("Expected exception message to contain the word '" + policyToViolate .name ()
235- + "', but was " + msg , msg .contains (policyToViolate .name ()));
233+ assertTrue (msg .contains (policyToViolate .name ()),
234+ "Expected exception message to contain the word '" + policyToViolate .name ()
235+ + "', but was " + msg );
236236 }
237237 }
238- assertTrue ("Expected to see an exception writing data to a table exceeding its quota" ,
239- sawError );
238+ assertTrue (sawError ,
239+ "Expected to see an exception writing data to a table exceeding its quota" );
240240 }
241241
242242 /**
@@ -276,7 +276,7 @@ void verifyNoViolation(TableName tn, Mutation m) throws Exception {
276276 scanner .close ();
277277 }
278278 }
279- assertTrue ("Expected to succeed in writing data to a table not having quota " , sawSuccess );
279+ assertTrue (sawSuccess , "Expected to succeed in writing data to a table not having quota " );
280280 }
281281
282282 /**
@@ -289,8 +289,8 @@ void verifyTableUsageSnapshotForSpaceQuotaExist(TableName tn) throws Exception {
289289 ResultScanner rs = quotaTable .getScanner (s );
290290 sawUsageSnapshot = (rs .next () != null );
291291 }
292- assertTrue ("Expected to succeed in getting table usage snapshots for space quota" ,
293- sawUsageSnapshot );
292+ assertTrue (sawUsageSnapshot ,
293+ "Expected to succeed in getting table usage snapshots for space quota" );
294294 }
295295
296296 /**
@@ -335,7 +335,7 @@ ClientServiceCallable<Void> generateFileToLoad(TableName tn, int numFiles, int n
335335 Connection conn = testUtil .getConnection ();
336336 FileSystem fs = testUtil .getTestFileSystem ();
337337 Configuration conf = testUtil .getConfiguration ();
338- Path baseDir = new Path (fs .getHomeDirectory (), testName . getMethodName () + "_files" );
338+ Path baseDir = new Path (fs .getHomeDirectory (), testName + "_files" );
339339 fs .mkdirs (baseDir );
340340 final List <Pair <byte [], String >> famPaths = new ArrayList <Pair <byte [], String >>();
341341 for (int i = 1 ; i <= numFiles ; i ++) {
@@ -363,44 +363,6 @@ public Void rpcCall() throws Exception {
363363 };
364364 }
365365
366- /**
367- * Bulk-loads a number of files with a number of rows to the given table.
368- */
369- // ClientServiceCallable<Boolean> generateFileToLoad(
370- // TableName tn, int numFiles, int numRowsPerFile) throws Exception {
371- // Connection conn = testUtil.getConnection();
372- // FileSystem fs = testUtil.getTestFileSystem();
373- // Configuration conf = testUtil.getConfiguration();
374- // Path baseDir = new Path(fs.getHomeDirectory(), testName.getMethodName() + "_files");
375- // fs.mkdirs(baseDir);
376- // final List<Pair<byte[], String>> famPaths = new ArrayList<>();
377- // for (int i = 1; i <= numFiles; i++) {
378- // Path hfile = new Path(baseDir, "file" + i);
379- // TestHRegionServerBulkLoad.createHFile(
380- // fs, hfile, Bytes.toBytes(SpaceQuotaHelperForTests.F1), Bytes.toBytes("my"),
381- // Bytes.toBytes("file"), numRowsPerFile);
382- // famPaths.add(new Pair<>(Bytes.toBytes(SpaceQuotaHelperForTests.F1), hfile.toString()));
383- // }
384- //
385- // // bulk load HFiles
386- // Table table = conn.getTable(tn);
387- // final String bulkToken = new SecureBulkLoadClient(conf, table).prepareBulkLoad(conn);
388- // return new ClientServiceCallable<Boolean>(
389- // conn, tn, Bytes.toBytes("row"), new RpcControllerFactory(conf).newController(),
390- // HConstants.PRIORITY_UNSET) {
391- // @Override
392- // public Boolean rpcCall() throws Exception {
393- // SecureBulkLoadClient secureClient = null;
394- // byte[] regionName = getLocation().getRegion().getRegionName();
395- // try (Table table = conn.getTable(getTableName())) {
396- // secureClient = new SecureBulkLoadClient(conf, table);
397- // return secureClient.secureBulkLoadHFiles(getStub(), famPaths, regionName,
398- // true, null, bulkToken);
399- // }
400- // }
401- // };
402- // }
403-
404366 /**
405367 * Removes the space quota from the given namespace
406368 */
@@ -596,7 +558,7 @@ TableName getNextTableName() {
596558 }
597559
598560 TableName getNextTableName (String namespace ) {
599- return TableName .valueOf (namespace , testName . getMethodName () + counter .getAndIncrement ());
561+ return TableName .valueOf (namespace , testName + counter .getAndIncrement ());
600562 }
601563
602564 TableName createTable () throws Exception {
@@ -645,8 +607,7 @@ TableName createTableWithRegions(Admin admin, String namespace, int numRegions,
645607
646608 TableName createTableInNamespace (NamespaceDescriptor nd ) throws Exception {
647609 final Admin admin = testUtil .getAdmin ();
648- final TableName tn =
649- TableName .valueOf (nd .getName (), testName .getMethodName () + counter .getAndIncrement ());
610+ final TableName tn = TableName .valueOf (nd .getName (), testName + counter .getAndIncrement ());
650611
651612 // Delete the old table
652613 if (admin .tableExists (tn )) {
0 commit comments