1919
2020import static org .apache .hadoop .hbase .HBaseTestingUtility .fam1 ;
2121import static org .apache .hadoop .hbase .HBaseTestingUtility .fam2 ;
22- import static org .junit .Assert .assertEquals ;
23- import static org .junit .Assert .assertNotNull ;
24- import static org .junit .Assert .assertTrue ;
25- import static org .junit .Assert .fail ;
22+ import static org .junit .jupiter . api . Assertions .assertEquals ;
23+ import static org .junit .jupiter . api . Assertions .assertNotNull ;
24+ import static org .junit .jupiter . api . Assertions .assertTrue ;
25+ import static org .junit .jupiter . api . Assertions .fail ;
2626
2727import java .io .IOException ;
2828import java .util .ArrayList ;
3838import org .apache .hadoop .hbase .Cell ;
3939import org .apache .hadoop .hbase .CellUtil ;
4040import org .apache .hadoop .hbase .CompareOperator ;
41- import org .apache .hadoop .hbase .HBaseClassTestRule ;
4241import org .apache .hadoop .hbase .HBaseTestingUtility ;
4342import org .apache .hadoop .hbase .HColumnDescriptor ;
4443import org .apache .hadoop .hbase .HConstants ;
6968import org .apache .hadoop .hbase .testclassification .VerySlowRegionServerTests ;
7069import org .apache .hadoop .hbase .util .Bytes ;
7170import org .apache .hadoop .hbase .wal .WAL ;
72- import org .junit .After ;
73- import org .junit .Before ;
74- import org .junit .ClassRule ;
75- import org .junit .Rule ;
76- import org .junit .Test ;
77- import org .junit .experimental .categories .Category ;
78- import org .junit .rules .TestName ;
71+ import org .junit .jupiter .api .AfterEach ;
72+ import org .junit .jupiter .api .BeforeEach ;
73+ import org .junit .jupiter .api .Tag ;
74+ import org .junit .jupiter .api .Test ;
75+ import org .junit .jupiter .api .TestInfo ;
7976import org .slf4j .Logger ;
8077import org .slf4j .LoggerFactory ;
8178
8279/**
8380 * Testing of HRegion.incrementColumnValue, HRegion.increment, and HRegion.append
8481 */
85- @ Category ({ VerySlowRegionServerTests .class , LargeTests .class }) // Starts 100 threads
82+ @ Tag (VerySlowRegionServerTests .TAG )
83+ @ Tag (LargeTests .TAG ) // Starts 100 threads
8684public class TestAtomicOperation {
8785
88- @ ClassRule
89- public static final HBaseClassTestRule CLASS_RULE =
90- HBaseClassTestRule .forClass (TestAtomicOperation .class );
91-
9286 private static final Logger LOG = LoggerFactory .getLogger (TestAtomicOperation .class );
93- @ Rule
94- public TestName name = new TestName ();
87+ private String name ;
9588
9689 HRegion region = null ;
9790 private HBaseTestingUtility TEST_UTIL = HBaseTestingUtility .createLocalHTU ();
@@ -106,12 +99,13 @@ public class TestAtomicOperation {
10699 static final byte [] row = Bytes .toBytes ("rowA" );
107100 static final byte [] row2 = Bytes .toBytes ("rowB" );
108101
109- @ Before
110- public void setup () {
111- tableName = Bytes .toBytes (name .getMethodName ());
102+ @ BeforeEach
103+ public void setup (TestInfo testInfo ) {
104+ this .name = testInfo .getTestMethod ().get ().getName ();
105+ tableName = Bytes .toBytes (name );
112106 }
113107
114- @ After
108+ @ AfterEach
115109 public void teardown () throws IOException {
116110 if (region != null ) {
117111 CacheConfig cacheConfig = region .getStores ().get (0 ).getCacheConfig ();
@@ -132,11 +126,11 @@ public void teardown() throws IOException {
132126
133127 /**
134128 * Test basic append operation. More tests in
135- * @see org.apache.hadoop.hbase.client.TestFromClientSide #testAppend()
129+ * {@link org.apache.hadoop.hbase.client.FromClientSideTest5 #testAppend()}.
136130 */
137131 @ Test
138132 public void testAppend () throws IOException {
139- initHRegion (tableName , name . getMethodName () , fam1 );
133+ initHRegion (tableName , name , fam1 );
140134 String v1 =
141135 "Ultimate Answer to the Ultimate Question of Life," + " The Universe, and Everything" ;
142136 String v2 = " is... 42." ;
@@ -156,7 +150,7 @@ public void testAppend() throws IOException {
156150 @ Test
157151 public void testAppendWithMultipleFamilies () throws IOException {
158152 final byte [] fam3 = Bytes .toBytes ("colfamily31" );
159- initHRegion (tableName , name . getMethodName () , fam1 , fam2 , fam3 );
153+ initHRegion (tableName , name , fam1 , fam2 , fam3 );
160154 String v1 = "Appended" ;
161155 String v2 = "Value" ;
162156
@@ -165,8 +159,8 @@ public void testAppendWithMultipleFamilies() throws IOException {
165159 a .addColumn (fam1 , qual1 , Bytes .toBytes (v1 ));
166160 a .addColumn (fam2 , qual2 , Bytes .toBytes (v2 ));
167161 Result result = region .append (a , HConstants .NO_NONCE , HConstants .NO_NONCE );
168- assertTrue ("Expected an empty result but result contains " + result . size () + " keys" ,
169- result . isEmpty () );
162+ assertTrue (result . isEmpty () ,
163+ "Expected an empty result but result contains " + result . size () + " keys" );
170164
171165 a = new Append (row );
172166 a .addColumn (fam2 , qual2 , Bytes .toBytes (v1 ));
@@ -181,10 +175,10 @@ public void testAppendWithMultipleFamilies() throws IOException {
181175 byte [] actualValue3 = result .getValue (fam3 , qual3 );
182176 byte [] actualValue4 = result .getValue (fam1 , qual2 );
183177
184- assertNotNull ("Value1 should bot be null" , actualValue1 );
185- assertNotNull ("Value2 should bot be null" , actualValue2 );
186- assertNotNull ("Value3 should bot be null" , actualValue3 );
187- assertNotNull ("Value4 should bot be null" , actualValue4 );
178+ assertNotNull (actualValue1 , "Value1 should bot be null" );
179+ assertNotNull (actualValue2 , "Value2 should bot be null" );
180+ assertNotNull (actualValue3 , "Value3 should bot be null" );
181+ assertNotNull (actualValue4 , "Value4 should bot be null" );
188182 assertEquals (0 , Bytes .compareTo (Bytes .toBytes (v1 + v2 ), actualValue1 ));
189183 assertEquals (0 , Bytes .compareTo (Bytes .toBytes (v2 + v1 ), actualValue2 ));
190184 assertEquals (0 , Bytes .compareTo (Bytes .toBytes (v2 ), actualValue3 ));
@@ -193,7 +187,7 @@ public void testAppendWithMultipleFamilies() throws IOException {
193187
194188 @ Test
195189 public void testAppendWithNonExistingFamily () throws IOException {
196- initHRegion (tableName , name . getMethodName () , fam1 );
190+ initHRegion (tableName , name , fam1 );
197191 final String v1 = "Value" ;
198192 final Append a = new Append (row );
199193 a .addColumn (fam1 , qual1 , Bytes .toBytes (v1 ));
@@ -211,7 +205,7 @@ public void testAppendWithNonExistingFamily() throws IOException {
211205
212206 @ Test
213207 public void testIncrementWithNonExistingFamily () throws IOException {
214- initHRegion (tableName , name . getMethodName () , fam1 );
208+ initHRegion (tableName , name , fam1 );
215209 final Increment inc = new Increment (row );
216210 inc .addColumn (fam1 , qual1 , 1 );
217211 inc .addColumn (fam2 , qual2 , 1 );
@@ -236,7 +230,7 @@ public void testIncrementMultiThreads() throws IOException {
236230 boolean fast = true ;
237231 LOG .info ("Starting test testIncrementMultiThreads" );
238232 // run a with mixed column families (1 and 3 versions)
239- initHRegion (tableName , name . getMethodName () , new int [] { 1 , 3 }, fam1 , fam2 );
233+ initHRegion (tableName , name , new int [] { 1 , 3 }, fam1 , fam2 );
240234
241235 // Create 100 threads, each will increment by its own quantity. All 100 threads update the
242236 // same row over two column families.
@@ -339,8 +333,8 @@ public void run() {
339333 Bytes .toLong (result .getValue (fam1 , qual2 )));
340334 long fam1Increment = Bytes .toLong (result .getValue (fam1 , qual1 )) * 3 ;
341335 long fam2Increment = Bytes .toLong (result .getValue (fam2 , qual3 ));
342- assertEquals ("fam1=" + fam1Increment + ", fam2=" + fam2Increment , fam1Increment ,
343- fam2Increment );
336+ assertEquals (fam1Increment , fam2Increment ,
337+ "fam1=" + fam1Increment + ", fam2=" + fam2Increment );
344338 }
345339 } catch (IOException e ) {
346340 e .printStackTrace ();
@@ -353,7 +347,7 @@ public void run() {
353347 public void testAppendMultiThreads () throws IOException {
354348 LOG .info ("Starting test testAppendMultiThreads" );
355349 // run a with mixed column families (1 and 3 versions)
356- initHRegion (tableName , name . getMethodName () , new int [] { 1 , 3 }, fam1 , fam2 );
350+ initHRegion (tableName , name , new int [] { 1 , 3 }, fam1 , fam2 );
357351
358352 int numThreads = 100 ;
359353 int opsPerThread = 100 ;
@@ -417,7 +411,7 @@ public void run() {
417411 @ Test
418412 public void testRowMutationMultiThreads () throws IOException {
419413 LOG .info ("Starting test testRowMutationMultiThreads" );
420- initHRegion (tableName , name . getMethodName () , fam1 );
414+ initHRegion (tableName , name , fam1 );
421415
422416 // create 10 threads, each will alternate between adding and
423417 // removing a column
@@ -508,7 +502,7 @@ public void run() {
508502 public void testMultiRowMutationMultiThreads () throws IOException {
509503
510504 LOG .info ("Starting test testMultiRowMutationMultiThreads" );
511- initHRegion (tableName , name . getMethodName () , fam1 );
505+ initHRegion (tableName , name , fam1 );
512506
513507 // create 10 threads, each will alternate between adding and
514508 // removing a column
@@ -634,8 +628,8 @@ private enum TestStep {
634628 public void testPutAndCheckAndPutInParallel () throws Exception {
635629 Configuration conf = TEST_UTIL .getConfiguration ();
636630 conf .setClass (HConstants .REGION_IMPL , MockHRegion .class , HeapSize .class );
637- HTableDescriptor htd = new HTableDescriptor ( TableName . valueOf ( name . getMethodName ()))
638- .addFamily (new HColumnDescriptor (family ));
631+ HTableDescriptor htd =
632+ new HTableDescriptor ( TableName . valueOf ( name )) .addFamily (new HColumnDescriptor (family ));
639633 this .region = TEST_UTIL .createLocalHRegion (htd , null , null );
640634 Put [] puts = new Put [1 ];
641635 Put put = new Put (Bytes .toBytes ("r1" ));
0 commit comments