1818
1919package org .apache .hadoop .yarn .server .resourcemanager .placement ;
2020
21- import org .junit .Test ;
21+ import org .junit .jupiter . api . Test ;
2222
2323import static org .apache .hadoop .yarn .server .resourcemanager .placement .FairQueuePlacementUtils .DOT ;
2424import static org .apache .hadoop .yarn .server .resourcemanager .placement .FairQueuePlacementUtils .DOT_REPLACEMENT ;
2525import static org .apache .hadoop .yarn .server .resourcemanager .placement .FairQueuePlacementUtils .ROOT_QUEUE ;
2626import static org .apache .hadoop .yarn .server .resourcemanager .placement .FairQueuePlacementUtils .assureRoot ;
2727import static org .apache .hadoop .yarn .server .resourcemanager .placement .FairQueuePlacementUtils .cleanName ;
2828import static org .apache .hadoop .yarn .server .resourcemanager .placement .FairQueuePlacementUtils .isValidQueueName ;
29- import static org .junit .Assert .assertEquals ;
30- import static org .junit .Assert .assertFalse ;
31- import static org .junit .Assert .assertNotEquals ;
32- import static org .junit .Assert .assertNull ;
33- import static org .junit .Assert .assertTrue ;
29+ import static org .junit .jupiter . api . Assertions .assertEquals ;
30+ import static org .junit .jupiter . api . Assertions .assertFalse ;
31+ import static org .junit .jupiter . api . Assertions .assertNotEquals ;
32+ import static org .junit .jupiter . api . Assertions .assertNull ;
33+ import static org .junit .jupiter . api . Assertions .assertTrue ;
3434
3535/**
3636 * Tests of the utility methods from {@link FairQueuePlacementUtils}.
@@ -50,27 +50,27 @@ public void testCleanName() {
5050 final String unTrimmed = " .invalid. " ; // not really a valid queue
5151
5252 String cleaned = cleanName (clean );
53- assertEquals ("Name was changed and it should not" , clean , cleaned );
53+ assertEquals (clean , cleaned , "Name was changed and it should not" );
5454 cleaned = cleanName (dotted );
55- assertFalse ("Cleaned name contains dots and it should not" ,
56- cleaned . contains ( DOT ) );
55+ assertFalse (cleaned . contains ( DOT ) ,
56+ "Cleaned name contains dots and it should not" );
5757 cleaned = cleanName (multiDot );
58- assertFalse ("Cleaned name contains dots and it should not" ,
59- cleaned . contains ( DOT ) );
60- assertNotEquals ("Multi dot failed: wrong replacements found" ,
61- cleaned .indexOf (DOT_REPLACEMENT ),
62- cleaned . lastIndexOf ( DOT_REPLACEMENT ) );
58+ assertFalse (cleaned . contains ( DOT ) ,
59+ "Cleaned name contains dots and it should not" );
60+ assertNotEquals (cleaned . indexOf ( DOT_REPLACEMENT ) ,
61+ cleaned .lastIndexOf (DOT_REPLACEMENT ),
62+ "Multi dot failed: wrong replacements found" );
6363 cleaned = cleanName (seqDot );
64- assertFalse ("Cleaned name contains dots and it should not" ,
65- cleaned . contains ( DOT ) );
66- assertNotEquals ("Sequential dot failed: wrong replacements found" ,
67- cleaned .indexOf (DOT_REPLACEMENT ),
68- cleaned . lastIndexOf ( DOT_REPLACEMENT ) );
64+ assertFalse (cleaned . contains ( DOT ) ,
65+ "Cleaned name contains dots and it should not" );
66+ assertNotEquals (cleaned . indexOf ( DOT_REPLACEMENT ) ,
67+ cleaned .lastIndexOf (DOT_REPLACEMENT ),
68+ "Sequential dot failed: wrong replacements found" );
6969 cleaned = cleanName (unTrimmed );
70- assertTrue ("Trimming start failed: space not removed or dot not replaced" ,
71- cleaned . startsWith ( DOT_REPLACEMENT ) );
72- assertTrue ("Trimming end failed: space not removed or dot not replaced" ,
73- cleaned . endsWith ( DOT_REPLACEMENT ) );
70+ assertTrue (cleaned . startsWith ( DOT_REPLACEMENT ) ,
71+ "Trimming start failed: space not removed or dot not replaced" );
72+ assertTrue (cleaned . endsWith ( DOT_REPLACEMENT ) ,
73+ "Trimming end failed: space not removed or dot not replaced" );
7474 }
7575
7676 @ Test
@@ -82,23 +82,22 @@ public void testAssureRoot() {
8282 final String alreadyRoot = "root.base" ;
8383
8484 String rooted = assureRoot (queueName );
85- assertTrue ("Queue should have root prefix (base)" ,
86- rooted . startsWith ( ROOT_QUEUE + DOT ) );
85+ assertTrue (rooted . startsWith ( ROOT_QUEUE + DOT ) ,
86+ "Queue should have root prefix (base)" );
8787 rooted = assureRoot (rootOnly );
88- assertEquals ("'root' queue should not have root prefix (root)" ,
89- rootOnly , rooted );
88+ assertEquals (rootOnly , rooted ,
89+ "'root' queue should not have root prefix (root)" );
9090 rooted = assureRoot (rootNoDot );
91- assertTrue ("Queue should have root prefix (rootbase)" ,
92- rooted . startsWith ( ROOT_QUEUE + DOT ) );
93- assertEquals ("'root' queue base was replaced and not prefixed" , 5 ,
94- rooted . lastIndexOf ( ROOT_QUEUE ) );
91+ assertTrue (rooted . startsWith ( ROOT_QUEUE + DOT ) ,
92+ "Queue should have root prefix (rootbase)" );
93+ assertEquals (5 , rooted . lastIndexOf ( ROOT_QUEUE ) ,
94+ "'root' queue base was replaced and not prefixed" );
9595 rooted = assureRoot (alreadyRoot );
96- assertEquals ("Root prefixed queue changed and it should not (root.base)" ,
97- rooted , alreadyRoot );
98- assertNull ("Null queue did not return null queue" ,
99- assureRoot (null ));
100- assertEquals ("Empty queue did not return empty name" , "" ,
101- assureRoot ("" ));
96+ assertEquals (rooted , alreadyRoot ,
97+ "Root prefixed queue changed and it should not (root.base)" );
98+ assertNull (assureRoot (null ), "Null queue did not return null queue" );
99+ assertEquals ("" , assureRoot ("" ),
100+ "Empty queue did not return empty name" );
102101 }
103102
104103 @ Test
@@ -113,25 +112,24 @@ public void testIsValidQueueName() {
113112 final String endSpace = "invalid " ;
114113 final String unicodeSpace = "\u00A0 invalid" ;
115114
116- assertFalse ("'null' queue was not marked as invalid" ,
117- isValidQueueName (null ));
118- assertTrue ("empty queue was not tagged valid" , isValidQueueName ("" ));
119- assertTrue ("Simple queue name was not tagged valid (valid)" ,
120- isValidQueueName (valid ));
121- assertTrue ("Root only queue was not tagged valid (root)" ,
122- isValidQueueName (rootOnly ));
123- assertTrue ("Root prefixed queue was not tagged valid (root.valid)" ,
124- isValidQueueName (validRooted ));
125- assertFalse ("Queue starting with dot was not tagged invalid (.invalid)" ,
126- isValidQueueName (startDot ));
127- assertFalse ("Queue ending with dot was not tagged invalid (invalid.)" ,
128- isValidQueueName (endDot ));
129- assertFalse ("Queue starting with space was not tagged invalid ( invalid)" ,
130- isValidQueueName (startSpace ));
131- assertFalse ("Queue ending with space was not tagged invalid (invalid )" ,
132- isValidQueueName (endSpace ));
115+ assertFalse (isValidQueueName (null ), "'null' queue was not marked as invalid" );
116+ assertTrue (isValidQueueName ("" ), "empty queue was not tagged valid" );
117+ assertTrue (isValidQueueName (valid ),
118+ "Simple queue name was not tagged valid (valid)" );
119+ assertTrue (isValidQueueName (rootOnly ),
120+ "Root only queue was not tagged valid (root)" );
121+ assertTrue (isValidQueueName (validRooted ),
122+ "Root prefixed queue was not tagged valid (root.valid)" );
123+ assertFalse (isValidQueueName (startDot ),
124+ "Queue starting with dot was not tagged invalid (.invalid)" );
125+ assertFalse (isValidQueueName (endDot ),
126+ "Queue ending with dot was not tagged invalid (invalid.)" );
127+ assertFalse (isValidQueueName (startSpace ),
128+ "Queue starting with space was not tagged invalid ( invalid)" );
129+ assertFalse (isValidQueueName (endSpace ),
130+ "Queue ending with space was not tagged invalid (invalid )" );
133131 // just one for sanity check extensive tests are in the scheduler utils
134- assertFalse ("Queue with unicode space was not tagged as invalid (unicode)" ,
135- isValidQueueName ( unicodeSpace ) );
132+ assertFalse (isValidQueueName ( unicodeSpace ) ,
133+ "Queue with unicode space was not tagged as invalid (unicode)" );
136134 }
137135}
0 commit comments