6
6
import static io .appium .java_client .service .local .AppiumServiceBuilder .APPIUM_PATH ;
7
7
import static io .appium .java_client .service .local .AppiumServiceBuilder .BROADCAST_IP_ADDRESS ;
8
8
import static io .appium .java_client .service .local .AppiumServiceBuilder .DEFAULT_APPIUM_PORT ;
9
+ import static io .appium .java_client .service .local .flags .GeneralServerFlag .BASEPATH ;
9
10
import static io .appium .java_client .service .local .flags .GeneralServerFlag .CALLBACK_ADDRESS ;
10
11
import static io .appium .java_client .service .local .flags .GeneralServerFlag .SESSION_OVERRIDE ;
11
- import static io .appium .java_client .service .local .flags .GeneralServerFlag .BASEPATH ;
12
12
import static io .github .bonigarcia .wdm .WebDriverManager .chromedriver ;
13
13
import static java .lang .System .getProperty ;
14
14
import static java .lang .System .setProperty ;
21
21
import static org .junit .Assert .assertEquals ;
22
22
import static org .junit .Assert .assertFalse ;
23
23
import static org .junit .Assert .assertThat ;
24
+ import static org .junit .Assert .assertThrows ;
24
25
import static org .junit .Assert .assertTrue ;
25
- import static org .junit .Assert .fail ;
26
26
27
27
import com .google .common .collect .ImmutableMap ;
28
28
import io .appium .java_client .android .options .UiAutomator2Options ;
29
29
import io .github .bonigarcia .wdm .WebDriverManager ;
30
- import org .junit .After ;
31
- import org .junit .BeforeClass ;
32
- import org .junit .Test ;
33
-
34
30
import java .io .File ;
35
31
import java .io .FileOutputStream ;
36
32
import java .io .OutputStream ;
37
33
import java .nio .file .Path ;
38
34
import java .time .Duration ;
39
35
import java .util .ArrayList ;
40
36
import java .util .List ;
37
+ import org .junit .After ;
38
+ import org .junit .BeforeClass ;
39
+ import org .junit .Test ;
41
40
42
41
@ SuppressWarnings ("ResultOfMethodCallIgnored" )
43
42
public class ServerBuilderTest {
@@ -327,7 +326,7 @@ public void checkAbilityToStartServiceUsingValidBasePathWithMultiplePathParams()
327
326
service = new AppiumServiceBuilder ().withArgument (BASEPATH , basePath ).build ();
328
327
service .start ();
329
328
assertTrue (service .isRunning ());
330
- assertEquals (baseUrl + basePath + "/" ,service .getUrl ().toString ());
329
+ assertEquals (baseUrl + basePath + "/" , service .getUrl ().toString ());
331
330
}
332
331
333
332
@ Test
@@ -337,38 +336,29 @@ public void checkAbilityToStartServiceUsingValidBasePathWithSinglePathParams() {
337
336
service = new AppiumServiceBuilder ().withArgument (BASEPATH , basePath ).build ();
338
337
service .start ();
339
338
assertTrue (service .isRunning ());
340
- assertEquals (baseUrl + basePath .substring (1 ) , service .getUrl ().toString ());
339
+ assertEquals (baseUrl + basePath .substring (1 ), service .getUrl ().toString ());
341
340
}
342
341
343
342
@ Test
344
343
public void checkAbilityToValidateBasePathForEmptyBasePath () {
345
- try {
344
+ Exception exception = assertThrows ( IllegalArgumentException . class , () -> {
346
345
service = new AppiumServiceBuilder ().withArgument (BASEPATH , "" ).build ();
347
- fail ("Base path was not validated for Blank or Empty string" );
348
- } catch (Exception e ) {
349
- assertEquals (InvalidBasePathException .class , e .getClass ());
350
- assertEquals (INVALID_BASE_PATH_ERROR_MESSAGE , e .getMessage ());
351
- }
346
+ });
347
+ assertEquals (INVALID_BASE_PATH_ERROR_MESSAGE , exception .getMessage ());
352
348
}
353
349
354
350
@ Test
355
351
public void checkAbilityToValidateBasePathForBlankBasePath () {
356
- try {
352
+ Exception exception = assertThrows ( IllegalArgumentException . class , () -> {
357
353
service = new AppiumServiceBuilder ().withArgument (BASEPATH , " " ).build ();
358
- fail ("Base path was not validated for Blank or Empty string" );
359
- } catch (Exception e ) {
360
- assertEquals (InvalidBasePathException .class , e .getClass ());
361
- assertEquals (INVALID_BASE_PATH_ERROR_MESSAGE , e .getMessage ());
362
- }
354
+ });
355
+ assertEquals (INVALID_BASE_PATH_ERROR_MESSAGE , exception .getMessage ());
363
356
}
364
357
365
358
@ Test
366
359
public void checkAbilityToValidateBasePathForNullBasePath () {
367
- try {
360
+ assertThrows ( NullPointerException . class , () -> {
368
361
service = new AppiumServiceBuilder ().withArgument (BASEPATH , null ).build ();
369
- fail ("Base path was not validated for a null value" );
370
- } catch (Exception e ) {
371
- assertEquals (NullPointerException .class , e .getClass ());
372
- }
362
+ });
373
363
}
374
364
}
0 commit comments