test: updated JUnit5 test classes and methods to have default package visibility by bipin-k · Pull Request #1755 · appium/java-client

Expand Up @@ -27,20 +27,19 @@ import com.google.common.collect.ImmutableMap; import io.appium.java_client.android.options.UiAutomator2Options; import io.github.bonigarcia.wdm.WebDriverManager; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test;
import java.io.File; import java.io.FileOutputStream; import java.io.OutputStream; import java.nio.file.Files; import java.nio.file.Path; import java.time.Duration; import java.util.ArrayList; import java.util.List; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test;
@SuppressWarnings("ResultOfMethodCallIgnored") public class ServerBuilderTest { class ServerBuilderTest {
/** * It may be impossible to find the path to the instance of appium server due to different circumstance. Expand Down Expand Up @@ -93,7 +92,7 @@ public void tearDown() throws Exception { }
@Test public void checkAbilityToAddLogMessageConsumer() { void checkAbilityToAddLogMessageConsumer() { List<String> log = new ArrayList<>(); service = buildDefaultService(); service.clearOutPutStreams(); Expand All @@ -103,21 +102,21 @@ public void checkAbilityToAddLogMessageConsumer() { }
@Test public void checkAbilityToStartDefaultService() { void checkAbilityToStartDefaultService() { service = buildDefaultService(); service.start(); assertTrue(service.isRunning()); }
@Test public void checkAbilityToFindNodeDefinedInProperties() { void checkAbilityToFindNodeDefinedInProperties() { File definedNode = PATH_T0_TEST_MAIN_JS.toFile(); setProperty(APPIUM_PATH, definedNode.getAbsolutePath()); assertThat(new AppiumServiceBuilder().createArgs().get(0), is(definedNode.getAbsolutePath())); }
@Test public void checkAbilityToUseNodeDefinedExplicitly() { void checkAbilityToUseNodeDefinedExplicitly() { File mainJS = PATH_T0_TEST_MAIN_JS.toFile(); AppiumServiceBuilder builder = new AppiumServiceBuilder() .withAppiumJS(mainJS); Expand All @@ -126,21 +125,21 @@ public void checkAbilityToUseNodeDefinedExplicitly() { }
@Test public void checkAbilityToStartServiceOnAFreePort() { void checkAbilityToStartServiceOnAFreePort() { service = new AppiumServiceBuilder().usingAnyFreePort().build(); service.start(); assertTrue(service.isRunning()); }
@Test public void checkAbilityToStartServiceUsingNonLocalhostIP() { void checkAbilityToStartServiceUsingNonLocalhostIP() { service = new AppiumServiceBuilder().withIPAddress(testIP).build(); service.start(); assertTrue(service.isRunning()); }
@Test public void checkAbilityToStartServiceUsingFlags() { void checkAbilityToStartServiceUsingFlags() { service = new AppiumServiceBuilder() .withArgument(CALLBACK_ADDRESS, testIP) .withArgument(SESSION_OVERRIDE) Expand All @@ -150,7 +149,7 @@ public void checkAbilityToStartServiceUsingFlags() { }
@Test public void checkAbilityToStartServiceUsingCapabilities() { void checkAbilityToStartServiceUsingCapabilities() { UiAutomator2Options options = new UiAutomator2Options() .fullReset() .setNewCommandTimeout(Duration.ofSeconds(60)) Expand All @@ -165,7 +164,7 @@ public void checkAbilityToStartServiceUsingCapabilities() { }
@Test public void checkAbilityToStartServiceUsingCapabilitiesAndFlags() { void checkAbilityToStartServiceUsingCapabilitiesAndFlags() { File app = ROOT_TEST_PATH.resolve("ApiDemos-debug.apk").toFile();
UiAutomator2Options options = new UiAutomator2Options() Expand All @@ -191,21 +190,21 @@ public void checkAbilityToStartServiceUsingCapabilitiesAndFlags() { }
@Test public void checkAbilityToChangeOutputStream() throws Exception { void checkAbilityToChangeOutputStream() throws Exception { testLogFile = new File("test"); testLogFile.createNewFile(); stream = new FileOutputStream(testLogFile); stream = Files.newOutputStream(testLogFile.toPath()); service = buildDefaultService(); service.addOutPutStream(stream); service.start(); assertThat(testLogFile.length(), greaterThan(0L)); }
@Test public void checkAbilityToChangeOutputStreamAfterTheServiceIsStarted() throws Exception { void checkAbilityToChangeOutputStreamAfterTheServiceIsStarted() throws Exception { testLogFile = new File("test"); testLogFile.createNewFile(); stream = new FileOutputStream(testLogFile); stream = Files.newOutputStream(testLogFile.toPath()); service = buildDefaultService(); service.start(); service.addOutPutStream(stream); Expand All @@ -214,15 +213,15 @@ public void checkAbilityToChangeOutputStreamAfterTheServiceIsStarted() throws Ex }
@Test public void checkAbilityToShutDownService() { void checkAbilityToShutDownService() { service = buildDefaultService(); service.start(); service.stop(); assertFalse(service.isRunning()); }
@Test public void checkAbilityToStartAndShutDownFewServices() throws Exception { void checkAbilityToStartAndShutDownFewServices() throws Exception { List<AppiumDriverLocalService> services = asList( new AppiumServiceBuilder().usingAnyFreePort().build(), new AppiumServiceBuilder().usingAnyFreePort().build(), Expand All @@ -236,7 +235,7 @@ public void checkAbilityToStartAndShutDownFewServices() throws Exception { }
@Test public void checkAbilityToStartServiceWithLogFile() throws Exception { void checkAbilityToStartServiceWithLogFile() throws Exception { testLogFile = new File("Log.txt"); testLogFile.createNewFile(); service = new AppiumServiceBuilder().withLogFile(testLogFile).build(); Expand All @@ -246,7 +245,7 @@ public void checkAbilityToStartServiceWithLogFile() throws Exception { }
@Test public void checkAbilityToStartServiceWithPortUsingFlag() { void checkAbilityToStartServiceWithPortUsingFlag() { String port = "8996"; String expectedUrl = String.format("http://0.0.0.0:%s/", port);
Expand All @@ -259,7 +258,7 @@ public void checkAbilityToStartServiceWithPortUsingFlag() { }
@Test public void checkAbilityToStartServiceWithPortUsingShortFlag() { void checkAbilityToStartServiceWithPortUsingShortFlag() { String port = "8996"; String expectedUrl = String.format("http://0.0.0.0:%s/", port);
Expand All @@ -272,7 +271,7 @@ public void checkAbilityToStartServiceWithPortUsingShortFlag() { }
@Test public void checkAbilityToStartServiceWithIpUsingFlag() { void checkAbilityToStartServiceWithIpUsingFlag() { String expectedUrl = String.format("http://%s:4723/", testIP);
service = new AppiumServiceBuilder() Expand All @@ -284,7 +283,7 @@ public void checkAbilityToStartServiceWithIpUsingFlag() { }
@Test public void checkAbilityToStartServiceWithIpUsingShortFlag() { void checkAbilityToStartServiceWithIpUsingShortFlag() { String expectedUrl = String.format("http://%s:4723/", testIP);
service = new AppiumServiceBuilder() Expand All @@ -296,7 +295,7 @@ public void checkAbilityToStartServiceWithIpUsingShortFlag() { }
@Test public void checkAbilityToStartServiceWithLogFileUsingFlag() { void checkAbilityToStartServiceWithLogFileUsingFlag() { testLogFile = new File("Log2.txt");
service = new AppiumServiceBuilder() Expand All @@ -307,7 +306,7 @@ public void checkAbilityToStartServiceWithLogFileUsingFlag() { }
@Test public void checkAbilityToStartServiceWithLogFileUsingShortFlag() { void checkAbilityToStartServiceWithLogFileUsingShortFlag() { testLogFile = new File("Log3.txt");
service = new AppiumServiceBuilder() Expand All @@ -318,7 +317,7 @@ public void checkAbilityToStartServiceWithLogFileUsingShortFlag() { }
@Test public void checkAbilityToStartServiceUsingValidBasePathWithMultiplePathParams() { void checkAbilityToStartServiceUsingValidBasePathWithMultiplePathParams() { String baseUrl = String.format("http://%s:%d/", BROADCAST_IP_ADDRESS, DEFAULT_APPIUM_PORT); String basePath = "wd/hub"; service = new AppiumServiceBuilder().withArgument(BASEPATH, basePath).build(); Expand All @@ -328,7 +327,7 @@ public void checkAbilityToStartServiceUsingValidBasePathWithMultiplePathParams() }
@Test public void checkAbilityToStartServiceUsingValidBasePathWithSinglePathParams() { void checkAbilityToStartServiceUsingValidBasePathWithSinglePathParams() { String baseUrl = String.format("http://%s:%d/", BROADCAST_IP_ADDRESS, DEFAULT_APPIUM_PORT); String basePath = "/wd/"; service = new AppiumServiceBuilder().withArgument(BASEPATH, basePath).build(); Expand All @@ -338,17 +337,17 @@ public void checkAbilityToStartServiceUsingValidBasePathWithSinglePathParams() { }
@Test public void checkAbilityToValidateBasePathForEmptyBasePath() { void checkAbilityToValidateBasePathForEmptyBasePath() { assertThrows(IllegalArgumentException.class, () -> new AppiumServiceBuilder().withArgument(BASEPATH, "")); }
@Test public void checkAbilityToValidateBasePathForBlankBasePath() { void checkAbilityToValidateBasePathForBlankBasePath() { assertThrows(IllegalArgumentException.class, () -> new AppiumServiceBuilder().withArgument(BASEPATH, " ")); }
@Test public void checkAbilityToValidateBasePathForNullBasePath() { void checkAbilityToValidateBasePathForNullBasePath() { assertThrows(NullPointerException.class, () -> new AppiumServiceBuilder().withArgument(BASEPATH, null)); } }