MySQL Test + CIProperties

This commit is contained in:
Rsl1122 2018-12-26 20:32:33 +02:00
parent c17b1c1aca
commit 131585179d
4 changed files with 52 additions and 2 deletions

View File

@ -9,6 +9,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;
@ -50,7 +51,7 @@ public class SeleniumExtension implements ParameterResolver, BeforeAllCallback,
}
private WebDriver getChromeWebDriver() {
if (System.getProperty("TRAVIS").equals("true")) {
if (Boolean.parseBoolean(System.getProperty(CIProperties.IS_TRAVIS))) {
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setBinary("/usr/bin/google-chrome-stable");
chromeOptions.setHeadless(true);

View File

@ -0,0 +1,15 @@
package utilities;
/**
* Test Utility class that holds System property names used in Travis.
*
* @author Rsl1122
*/
public class CIProperties {
public static final String IS_TRAVIS = "TRAVIS";
private CIProperties() {
/* Static variable class */
}
}

View File

@ -98,7 +98,7 @@ public abstract class CommonDBTest {
@AfterClass
public static void tearDownClass() {
Optional.ofNullable(system).ifPresent(PlanSystem::disable);
if (system != null) system.disable();
}
@Before

View File

@ -0,0 +1,34 @@
package com.djrapitops.plan.system.database.databases;
import com.djrapitops.plan.system.settings.config.PlanConfig;
import com.djrapitops.plan.system.settings.paths.DatabaseSettings;
import org.junit.BeforeClass;
import utilities.CIProperties;
import static org.junit.Assume.assumeTrue;
/**
* Tests for {@link com.djrapitops.plan.system.database.databases.sql.MySQLDB}.
* <p>
* These settings assume Travis CI environment with MySQL service running.
* 'Plan' database should be created before the test.
*
* @author Rsl1122
*/
public class MySQLTest extends CommonDBTest {
@BeforeClass
public static void setUpDatabase() throws Exception {
boolean isTravis = Boolean.parseBoolean(System.getProperty(CIProperties.IS_TRAVIS));
assumeTrue(isTravis);
PlanConfig config = component.getPlanSystem().getConfigSystem().getConfig();
config.set(DatabaseSettings.MYSQL_DATABASE, "Plan");
config.set(DatabaseSettings.MYSQL_USER, "travis");
config.set(DatabaseSettings.MYSQL_PASS, "");
config.set(DatabaseSettings.MYSQL_HOST, "127.0.0.1");
config.set(DatabaseSettings.TYPE, "MySQL");
handleSetup("MySQL");
}
}