1717 */
1818package org .apache .hadoop .mapred ;
1919
20- import static org .junit .Assert .assertEquals ;
21- import static org .junit .Assert .assertFalse ;
22- import static org .junit .Assert .assertTrue ;
20+ import static org .junit .jupiter .api .Assertions .assertEquals ;
21+ import static org .junit .jupiter .api .Assertions .assertFalse ;
22+ import static org .junit .jupiter .api .Assertions .assertNotNull ;
23+ import static org .junit .jupiter .api .Assertions .assertNull ;
24+ import static org .junit .jupiter .api .Assertions .assertTrue ;
25+ import static org .junit .jupiter .api .Assertions .fail ;
2326
2427import java .io .IOException ;
2528import java .text .ParseException ;
2629import java .util .HashSet ;
2730import java .util .Iterator ;
2831import java .util .Random ;
2932
30- import org .junit .Assert ;
31-
3233import org .apache .hadoop .mapred .Counters .Counter ;
3334import org .apache .hadoop .mapred .Counters .CountersExceededException ;
3435import org .apache .hadoop .mapred .Counters .Group ;
3839import org .apache .hadoop .mapreduce .TaskCounter ;
3940import org .apache .hadoop .mapreduce .counters .FrameworkCounterGroup ;
4041import org .apache .hadoop .mapreduce .counters .CounterGroupFactory .FrameworkGroupFactory ;
41- import org .junit .Test ;
42+ import org .junit .jupiter . api . Test ;
4243import org .slf4j .Logger ;
4344import org .slf4j .LoggerFactory ;
4445
@@ -85,14 +86,14 @@ private Counters getEnumCounters(String[] gNames, String[] cNames) {
8586 */
8687 private void testCounter (Counters counter ) throws ParseException {
8788 String compactEscapedString = counter .makeEscapedCompactString ();
88- assertFalse (" compactEscapedString should not contain null" ,
89- compactEscapedString . contains ( " null") );
89+ assertFalse (compactEscapedString . contains ( " null") ,
90+ "compactEscapedString should not contain null" );
9091
9192 Counters recoveredCounter =
9293 Counters .fromEscapedCompactString (compactEscapedString );
9394 // Check for recovery from string
94- assertEquals ("Recovered counter does not match on content" ,
95- counter , recoveredCounter );
95+ assertEquals (counter , recoveredCounter ,
96+ "Recovered counter does not match on content" );
9697 }
9798
9899 @ Test
@@ -134,19 +135,19 @@ public void testCounterValue() {
134135 long expectedValue = initValue ;
135136 Counter counter = counters .findCounter ("foo" , "bar" );
136137 counter .setValue (initValue );
137- assertEquals ("Counter value is not initialized correctly" ,
138- expectedValue , counter . getValue () );
138+ assertEquals (expectedValue , counter . getValue () ,
139+ "Counter value is not initialized correctly" );
139140 for (int j = 0 ; j < NUMBER_INC ; j ++) {
140141 int incValue = rand .nextInt ();
141142 counter .increment (incValue );
142143 expectedValue += incValue ;
143- assertEquals ("Counter value is not incremented correctly" ,
144- expectedValue , counter . getValue () );
144+ assertEquals (expectedValue , counter . getValue () ,
145+ "Counter value is not incremented correctly" );
145146 }
146147 expectedValue = rand .nextInt ();
147148 counter .setValue (expectedValue );
148- assertEquals ("Counter value is not set correctly" ,
149- expectedValue , counter . getValue () );
149+ assertEquals (expectedValue , counter . getValue () ,
150+ "Counter value is not set correctly" );
150151 }
151152 }
152153
@@ -174,29 +175,28 @@ public void testWriteWithLegacyNames() {
174175
175176 @ SuppressWarnings ("deprecation" )
176177 private void checkLegacyNames (Counters counters ) {
177- assertEquals ("New name" , 1 , counters .findCounter (
178- TaskCounter .class .getName (), "MAP_INPUT_RECORDS" ).getValue ());
179- assertEquals ("Legacy name" , 1 , counters .findCounter (
178+ assertEquals (1 , counters .findCounter (
179+ TaskCounter .class .getName (), "MAP_INPUT_RECORDS" ).getValue (), "New name" );
180+ assertEquals (1 , counters .findCounter (
180181 "org.apache.hadoop.mapred.Task$Counter" ,
181- "MAP_INPUT_RECORDS" ).getValue ());
182- assertEquals ("Legacy enum" , 1 ,
183- counters .findCounter (Task .Counter .MAP_INPUT_RECORDS ).getValue ());
182+ "MAP_INPUT_RECORDS" ).getValue (), "Legacy name" );
183+ assertEquals (1 , counters .findCounter (Task .Counter .MAP_INPUT_RECORDS ).getValue (), "Legacy enum" );
184184
185- assertEquals ("New name" , 1 , counters .findCounter (
186- JobCounter .class .getName (), "DATA_LOCAL_MAPS" ).getValue ());
187- assertEquals ("Legacy name" , 1 , counters .findCounter (
185+ assertEquals (1 , counters .findCounter (
186+ JobCounter .class .getName (), "DATA_LOCAL_MAPS" ).getValue (), "New name" );
187+ assertEquals (1 , counters .findCounter (
188188 "org.apache.hadoop.mapred.JobInProgress$Counter" ,
189- "DATA_LOCAL_MAPS" ).getValue ());
190- assertEquals ("Legacy enum" , 1 ,
191- counters .findCounter (JobInProgress .Counter .DATA_LOCAL_MAPS ).getValue ());
189+ "DATA_LOCAL_MAPS" ).getValue (), "Legacy name" );
190+ assertEquals (1 ,
191+ counters .findCounter (JobInProgress .Counter .DATA_LOCAL_MAPS ).getValue (), "Legacy enum" );
192192
193- assertEquals ("New name" , 1 , counters .findCounter (
194- FileSystemCounter .class .getName (), "FILE_BYTES_READ" ).getValue ());
195- assertEquals ("New name and method" , 1 , counters .findCounter ("file" ,
196- FileSystemCounter .BYTES_READ ).getValue ());
197- assertEquals ("Legacy name" , 1 , counters .findCounter (
193+ assertEquals (1 , counters .findCounter (
194+ FileSystemCounter .class .getName (), "FILE_BYTES_READ" ).getValue (), "New name" );
195+ assertEquals (1 , counters .findCounter ("file" ,
196+ FileSystemCounter .BYTES_READ ).getValue (), "New name and method" );
197+ assertEquals (1 , counters .findCounter (
198198 "FileSystemCounters" ,
199- "FILE_BYTES_READ" ).getValue ());
199+ "FILE_BYTES_READ" ).getValue (), "Legacy name" );
200200 }
201201
202202 @ SuppressWarnings ("deprecation" )
@@ -266,8 +266,8 @@ public void testMakeCompactString() {
266266 assertEquals ("group1.counter1:1" , counters .makeCompactString ());
267267 counters .incrCounter ("group2" , "counter2" , 3 );
268268 String cs = counters .makeCompactString ();
269- assertTrue ("Bad compact string" ,
270- cs . equals ( GC1 + ',' + GC2 ) || cs . equals ( GC2 + ',' + GC1 ) );
269+ assertTrue (cs . equals ( GC1 + ',' + GC2 ) || cs . equals ( GC2 + ',' + GC1 ) ,
270+ "Bad compact string" );
271271 }
272272
273273 @ Test
@@ -321,7 +321,7 @@ private void shouldThrow(Class<? extends Exception> ecls, Runnable runnable) {
321321 } catch (CountersExceededException e ) {
322322 return ;
323323 }
324- Assert . fail ("Should've thrown " + ecls .getSimpleName ());
324+ fail ("Should've thrown " + ecls .getSimpleName ());
325325 }
326326
327327 public static void main (String [] args ) throws IOException {
@@ -341,12 +341,12 @@ public void testFrameworkCounter() {
341341
342342 org .apache .hadoop .mapreduce .Counter count1 =
343343 counterGroup .findCounter (JobCounter .NUM_FAILED_MAPS .toString ());
344- Assert . assertNotNull (count1 );
344+ assertNotNull (count1 );
345345
346346 // Verify no exception get thrown when finding an unknown counter
347347 org .apache .hadoop .mapreduce .Counter count2 =
348348 counterGroup .findCounter ("Unknown" );
349- Assert . assertNull (count2 );
349+ assertNull (count2 );
350350 }
351351
352352 @ SuppressWarnings ("rawtypes" )
@@ -363,19 +363,19 @@ public void testTaskCounter() {
363363 org .apache .hadoop .mapreduce .Counter count1 =
364364 counterGroup .findCounter (
365365 TaskCounter .PHYSICAL_MEMORY_BYTES .toString ());
366- Assert . assertNotNull (count1 );
366+ assertNotNull (count1 );
367367 count1 .increment (10 );
368368 count1 .increment (10 );
369- Assert . assertEquals (20 , count1 .getValue ());
369+ assertEquals (20 , count1 .getValue ());
370370
371371 // Verify no exception get thrown when finding an unknown counter
372372 org .apache .hadoop .mapreduce .Counter count2 =
373373 counterGroup .findCounter (
374374 TaskCounter .MAP_PHYSICAL_MEMORY_BYTES_MAX .toString ());
375- Assert . assertNotNull (count2 );
375+ assertNotNull (count2 );
376376 count2 .increment (5 );
377377 count2 .increment (10 );
378- Assert . assertEquals (10 , count2 .getValue ());
378+ assertEquals (10 , count2 .getValue ());
379379 }
380380
381381 @ Test
@@ -385,12 +385,12 @@ public void testFilesystemCounter() {
385385
386386 org .apache .hadoop .mapreduce .Counter count1 =
387387 fsGroup .findCounter ("ANY_BYTES_READ" );
388- Assert . assertNotNull (count1 );
388+ assertNotNull (count1 );
389389
390390 // Verify no exception get thrown when finding an unknown counter
391391 org .apache .hadoop .mapreduce .Counter count2 =
392392 fsGroup .findCounter ("Unknown" );
393- Assert . assertNull (count2 );
393+ assertNull (count2 );
394394 }
395395
396396}
0 commit comments