18
18
19
19
package org .apache .hadoop .yarn .server .resourcemanager .placement ;
20
20
21
- import org .junit .Test ;
21
+ import org .junit .jupiter . api . Test ;
22
22
23
23
import static org .apache .hadoop .yarn .server .resourcemanager .placement .FairQueuePlacementUtils .DOT ;
24
24
import static org .apache .hadoop .yarn .server .resourcemanager .placement .FairQueuePlacementUtils .DOT_REPLACEMENT ;
25
25
import static org .apache .hadoop .yarn .server .resourcemanager .placement .FairQueuePlacementUtils .ROOT_QUEUE ;
26
26
import static org .apache .hadoop .yarn .server .resourcemanager .placement .FairQueuePlacementUtils .assureRoot ;
27
27
import static org .apache .hadoop .yarn .server .resourcemanager .placement .FairQueuePlacementUtils .cleanName ;
28
28
import 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 ;
34
34
35
35
/**
36
36
* Tests of the utility methods from {@link FairQueuePlacementUtils}.
@@ -50,27 +50,27 @@ public void testCleanName() {
50
50
final String unTrimmed = " .invalid. " ; // not really a valid queue
51
51
52
52
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" );
54
54
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" );
57
57
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" );
63
63
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" );
69
69
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" );
74
74
}
75
75
76
76
@ Test
@@ -82,23 +82,22 @@ public void testAssureRoot() {
82
82
final String alreadyRoot = "root.base" ;
83
83
84
84
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)" );
87
87
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)" );
90
90
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" );
95
95
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" );
102
101
}
103
102
104
103
@ Test
@@ -113,25 +112,24 @@ public void testIsValidQueueName() {
113
112
final String endSpace = "invalid " ;
114
113
final String unicodeSpace = "\u00A0 invalid" ;
115
114
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 )" );
133
131
// 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)" );
136
134
}
137
135
}
0 commit comments