From 1225902347eb48d4e9ad94898f247779611f98e6 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Wed, 26 Dec 2018 21:39:06 +0200 Subject: [PATCH] Replaced System.getProperty with System.getenv calls in Tests --- .../src/test/java/extension/SeleniumExtension.java | 9 ++++----- Plan/common/src/test/java/rules/SeleniumDriver.java | 10 +++++----- .../plan/system/database/databases/MySQLTest.java | 2 +- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Plan/common/src/test/java/extension/SeleniumExtension.java b/Plan/common/src/test/java/extension/SeleniumExtension.java index 8a09417bd..1f4ac08e3 100644 --- a/Plan/common/src/test/java/extension/SeleniumExtension.java +++ b/Plan/common/src/test/java/extension/SeleniumExtension.java @@ -47,11 +47,12 @@ public class SeleniumExtension implements ParameterResolver, BeforeAllCallback, Assume.assumeNotNull("rules.SeleniumDriver: Chrome driver location not specified for this OS type", driverLocation); Assume.assumeTrue("rules.SeleniumDriver: Chrome driver not found at " + driverLocation, new File(driverLocation).exists()); + System.setProperty("webdriver.chrome.driver", driverLocation); driver = getChromeWebDriver(); } private WebDriver getChromeWebDriver() { - if (Boolean.parseBoolean(System.getProperty(CIProperties.IS_TRAVIS))) { + if (Boolean.parseBoolean(System.getenv(CIProperties.IS_TRAVIS))) { ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.setBinary("/usr/bin/google-chrome-stable"); chromeOptions.setHeadless(true); @@ -65,11 +66,9 @@ public class SeleniumExtension implements ParameterResolver, BeforeAllCallback, private String getChromeDriverLocation() { if (SystemUtils.IS_OS_WINDOWS) { - String driverLocation = "C:\\chromedriver.exe"; - System.setProperty("webdriver.chrome.driver", driverLocation); - return driverLocation; + return "C:\\chromedriver.exe"; } - return System.getProperty("webdriver.chrome.driver"); + return System.getenv("webdriver.chrome.driver"); } @Override diff --git a/Plan/common/src/test/java/rules/SeleniumDriver.java b/Plan/common/src/test/java/rules/SeleniumDriver.java index 69599252b..b0645c162 100644 --- a/Plan/common/src/test/java/rules/SeleniumDriver.java +++ b/Plan/common/src/test/java/rules/SeleniumDriver.java @@ -25,6 +25,7 @@ import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; +import utilities.CIProperties; import java.io.File; import java.util.ArrayList; @@ -41,11 +42,12 @@ public class SeleniumDriver extends ExternalResource { Assume.assumeNotNull("rules.SeleniumDriver: Chrome driver location not specified for this OS type", driverLocation); Assume.assumeTrue("rules.SeleniumDriver: Chrome driver not found at " + driverLocation, new File(driverLocation).exists()); + System.setProperty("webdriver.chrome.driver", driverLocation); driver = getChromeWebDriver(); } private WebDriver getChromeWebDriver() { - if (System.getProperty("TRAVIS").equals("true")) { + if (Boolean.parseBoolean(System.getenv(CIProperties.IS_TRAVIS))) { ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.setBinary("/usr/bin/google-chrome-stable"); chromeOptions.setHeadless(true); @@ -59,11 +61,9 @@ public class SeleniumDriver extends ExternalResource { private String getChromeDriverLocation() { if (SystemUtils.IS_OS_WINDOWS) { - String driverLocation = "C:\\chromedriver.exe"; - System.setProperty("webdriver.chrome.driver", driverLocation); - return driverLocation; + return "C:\\chromedriver.exe"; } - return System.getProperty("webdriver.chrome.driver"); + return System.getenv("webdriver.chrome.driver"); } public void newTab() { diff --git a/Plan/plugin/src/test/java/com/djrapitops/plan/system/database/databases/MySQLTest.java b/Plan/plugin/src/test/java/com/djrapitops/plan/system/database/databases/MySQLTest.java index 0265d9ea2..a68828d71 100644 --- a/Plan/plugin/src/test/java/com/djrapitops/plan/system/database/databases/MySQLTest.java +++ b/Plan/plugin/src/test/java/com/djrapitops/plan/system/database/databases/MySQLTest.java @@ -21,7 +21,7 @@ public class MySQLTest extends CommonDBTest { @BeforeClass public static void setUpDatabase() throws Exception { - boolean isTravis = Boolean.parseBoolean(System.getProperty(CIProperties.IS_TRAVIS)); + boolean isTravis = Boolean.parseBoolean(System.getenv(CIProperties.IS_TRAVIS)); assumeTrue(isTravis); PlanConfig config = component.getPlanSystem().getConfigSystem().getConfig();