|
4 | 4 | import static io.appium.java_client.TestUtils.getLocalIp4Address; |
5 | 5 | import static io.appium.java_client.service.local.AppiumDriverLocalService.buildDefaultService; |
6 | 6 | import static io.appium.java_client.service.local.AppiumServiceBuilder.APPIUM_PATH; |
| 7 | +import static io.appium.java_client.service.local.AppiumServiceBuilder.BROADCAST_IP_ADDRESS; |
| 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; |
7 | 10 | import static io.appium.java_client.service.local.flags.GeneralServerFlag.CALLBACK_ADDRESS; |
8 | 11 | import static io.appium.java_client.service.local.flags.GeneralServerFlag.SESSION_OVERRIDE; |
9 | 12 | import static io.github.bonigarcia.wdm.WebDriverManager.chromedriver; |
|
18 | 21 | import static org.junit.Assert.assertEquals; |
19 | 22 | import static org.junit.Assert.assertFalse; |
20 | 23 | import static org.junit.Assert.assertThat; |
| 24 | +import static org.junit.Assert.assertThrows; |
21 | 25 | import static org.junit.Assert.assertTrue; |
22 | 26 |
|
23 | 27 | import com.google.common.collect.ImmutableMap; |
@@ -312,4 +316,45 @@ public void checkAbilityToStartServiceWithLogFileUsingShortFlag() { |
312 | 316 | service.start(); |
313 | 317 | assertTrue(testLogFile.exists()); |
314 | 318 | } |
| 319 | + |
| 320 | + @Test |
| 321 | + public void checkAbilityToStartServiceUsingValidBasePathWithMultiplePathParams() { |
| 322 | + String baseUrl = String.format("http://%s:%d/", BROADCAST_IP_ADDRESS, DEFAULT_APPIUM_PORT); |
| 323 | + String basePath = "wd/hub"; |
| 324 | + service = new AppiumServiceBuilder().withArgument(BASEPATH, basePath).build(); |
| 325 | + service.start(); |
| 326 | + assertTrue(service.isRunning()); |
| 327 | + assertEquals(baseUrl + basePath + "/", service.getUrl().toString()); |
| 328 | + } |
| 329 | + |
| 330 | + @Test |
| 331 | + public void checkAbilityToStartServiceUsingValidBasePathWithSinglePathParams() { |
| 332 | + String baseUrl = String.format("http://%s:%d/", BROADCAST_IP_ADDRESS, DEFAULT_APPIUM_PORT); |
| 333 | + String basePath = "/wd/"; |
| 334 | + service = new AppiumServiceBuilder().withArgument(BASEPATH, basePath).build(); |
| 335 | + service.start(); |
| 336 | + assertTrue(service.isRunning()); |
| 337 | + assertEquals(baseUrl + basePath.substring(1), service.getUrl().toString()); |
| 338 | + } |
| 339 | + |
| 340 | + @Test |
| 341 | + public void checkAbilityToValidateBasePathForEmptyBasePath() { |
| 342 | + assertThrows(IllegalArgumentException.class, () -> { |
| 343 | + new AppiumServiceBuilder().withArgument(BASEPATH, "").build(); |
| 344 | + }); |
| 345 | + } |
| 346 | + |
| 347 | + @Test |
| 348 | + public void checkAbilityToValidateBasePathForBlankBasePath() { |
| 349 | + assertThrows(IllegalArgumentException.class, () -> { |
| 350 | + new AppiumServiceBuilder().withArgument(BASEPATH, " ").build(); |
| 351 | + }); |
| 352 | + } |
| 353 | + |
| 354 | + @Test |
| 355 | + public void checkAbilityToValidateBasePathForNullBasePath() { |
| 356 | + assertThrows(NullPointerException.class, () -> { |
| 357 | + new AppiumServiceBuilder().withArgument(BASEPATH, null).build(); |
| 358 | + }); |
| 359 | + } |
315 | 360 | } |
0 commit comments