2525import java .util .Map ;
2626import javax .servlet .http .HttpServletRequest ;
2727
28- import org .apache .hadoop .yarn .util .TestBoundedAppender ;
2928import org .junit .jupiter .api .AfterAll ;
3029import org .junit .jupiter .api .BeforeAll ;
3130import org .junit .jupiter .api .Test ;
4443import static org .junit .jupiter .api .Assertions .assertArrayEquals ;
4544import static org .junit .jupiter .api .Assertions .assertEquals ;
4645import static org .junit .jupiter .api .Assertions .assertNull ;
47- import static org .mockito .Mockito .when ;
4846
4947public class TestWebAppUtils {
5048 private static final String RM1_NODE_ID = "rm1" ;
@@ -115,7 +113,7 @@ void testGetPassword() throws Exception {
115113 void testGetPasswordIOException () throws Exception {
116114 Configuration mockConf = Mockito .mock (Configuration .class );
117115
118- when (mockConf .getPassword ("error-alias" )).thenThrow (new IOException ("Simulated IO error" ));
116+ Mockito . when (mockConf .getPassword ("error-alias" )).thenThrow (new IOException ("Simulated IO error" ));
119117
120118 assertNull (WebAppUtils .getPassword (mockConf , "error-alias" ));
121119 }
@@ -197,7 +195,7 @@ protected Configuration provisionCredentialsForSSL() throws IOException,
197195 void testAppendQueryParams () throws Exception {
198196 HttpServletRequest request = Mockito .mock (HttpServletRequest .class );
199197 String targetUri = "/test/path" ;
200- when (request .getCharacterEncoding ()).thenReturn (null );
198+ Mockito . when (request .getCharacterEncoding ()).thenReturn (null );
201199 Map <String , String > paramResultMap = new HashMap <>();
202200 paramResultMap .put ("param1=x" , targetUri + "?" + "param1=x" );
203201 paramResultMap
@@ -206,7 +204,7 @@ void testAppendQueryParams() throws Exception {
206204 targetUri + "?" + "param1=x¶m2=y¶m3=x+y" );
207205
208206 for (Map .Entry <String , String > entry : paramResultMap .entrySet ()) {
209- when (request .getQueryString ()).thenReturn (entry .getKey ());
207+ Mockito . when (request .getQueryString ()).thenReturn (entry .getKey ());
210208 String uri = WebAppUtils .appendQueryParams (request , targetUri );
211209 assertEquals (entry .getValue (), uri );
212210 }
@@ -216,8 +214,8 @@ void testAppendQueryParams() throws Exception {
216214 void testGetHtmlEscapedURIWithQueryString () throws Exception {
217215 HttpServletRequest request = Mockito .mock (HttpServletRequest .class );
218216 String targetUri = "/test/path" ;
219- when (request .getCharacterEncoding ()).thenReturn (null );
220- when (request .getRequestURI ()).thenReturn (targetUri );
217+ Mockito . when (request .getCharacterEncoding ()).thenReturn (null );
218+ Mockito . when (request .getRequestURI ()).thenReturn (targetUri );
221219 Map <String , String > paramResultMap = new HashMap <>();
222220 paramResultMap .put ("param1=x" , targetUri + "?" + "param1=x" );
223221 paramResultMap
@@ -226,7 +224,7 @@ void testGetHtmlEscapedURIWithQueryString() throws Exception {
226224 targetUri + "?" + "param1=x&param2=y&param3=x+y" );
227225
228226 for (Map .Entry <String , String > entry : paramResultMap .entrySet ()) {
229- when (request .getQueryString ()).thenReturn (entry .getKey ());
227+ Mockito . when (request .getQueryString ()).thenReturn (entry .getKey ());
230228 String uri = WebAppUtils .getHtmlEscapedURIWithQueryString (request );
231229 assertEquals (entry .getValue (), uri );
232230 }
0 commit comments