mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-21 05:50:18 +08:00
Made it possible to run tests in parallel by class
This commit is contained in:
parent
e1e5d526c7
commit
30bce4e365
@ -15,6 +15,7 @@ import org.junit.runner.RunWith;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import rules.BukkitComponentMocker;
|
||||
import rules.ComponentMocker;
|
||||
import utilities.RandomData;
|
||||
|
||||
/**
|
||||
* Test for Bukkit PlanSystem.
|
||||
@ -29,12 +30,14 @@ public class BukkitSystemTest {
|
||||
@ClassRule
|
||||
public static ComponentMocker component = new BukkitComponentMocker(temporaryFolder);
|
||||
|
||||
private final int TEST_PORT_NUMBER = RandomData.randomInt(9005, 9500);
|
||||
|
||||
@Test
|
||||
public void testEnable() throws EnableException {
|
||||
PlanSystem bukkitSystem = component.getPlanSystem();
|
||||
try {
|
||||
PlanConfig config = bukkitSystem.getConfigSystem().getConfig();
|
||||
config.set(WebserverSettings.PORT, 9005);
|
||||
config.set(WebserverSettings.PORT, TEST_PORT_NUMBER);
|
||||
bukkitSystem.enable();
|
||||
} finally {
|
||||
bukkitSystem.disable();
|
||||
|
@ -20,6 +20,7 @@ import org.junit.runner.RunWith;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import rules.BungeeComponentMocker;
|
||||
import rules.ComponentMocker;
|
||||
import utilities.RandomData;
|
||||
|
||||
/**
|
||||
* Test for Bungee PlanSystem.
|
||||
@ -34,6 +35,8 @@ public class BungeeSystemTest {
|
||||
@ClassRule
|
||||
public static ComponentMocker component = new BungeeComponentMocker(temporaryFolder);
|
||||
|
||||
private final int TEST_PORT_NUMBER = RandomData.randomInt(9005, 9500);
|
||||
|
||||
@Rule
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@ -42,7 +45,7 @@ public class BungeeSystemTest {
|
||||
PlanSystem bungeeSystem = component.getPlanSystem();
|
||||
try {
|
||||
PlanConfig config = bungeeSystem.getConfigSystem().getConfig();
|
||||
config.set(WebserverSettings.PORT, 9005);
|
||||
config.set(WebserverSettings.PORT, TEST_PORT_NUMBER);
|
||||
config.set(ProxySettings.IP, "8.8.8.8");
|
||||
|
||||
DBSystem dbSystem = bungeeSystem.getDatabaseSystem();
|
||||
@ -63,7 +66,7 @@ public class BungeeSystemTest {
|
||||
PlanSystem bungeeSystem = component.getPlanSystem();
|
||||
try {
|
||||
PlanConfig config = bungeeSystem.getConfigSystem().getConfig();
|
||||
config.set(WebserverSettings.PORT, 9005);
|
||||
config.set(WebserverSettings.PORT, TEST_PORT_NUMBER);
|
||||
config.set(ProxySettings.IP, "0.0.0.0");
|
||||
|
||||
DBSystem dbSystem = bungeeSystem.getDatabaseSystem();
|
||||
@ -84,7 +87,7 @@ public class BungeeSystemTest {
|
||||
PlanSystem bungeeSystem = component.getPlanSystem();
|
||||
try {
|
||||
PlanConfig config = bungeeSystem.getConfigSystem().getConfig();
|
||||
config.set(WebserverSettings.PORT, 9005);
|
||||
config.set(WebserverSettings.PORT, TEST_PORT_NUMBER);
|
||||
config.set(ProxySettings.IP, "8.8.8.8");
|
||||
|
||||
bungeeSystem.enable();
|
||||
|
@ -17,6 +17,7 @@ import org.openqa.selenium.WebDriver;
|
||||
import rules.ComponentMocker;
|
||||
import rules.PluginComponentMocker;
|
||||
import rules.SeleniumDriver;
|
||||
import utilities.RandomData;
|
||||
import utilities.TestConstants;
|
||||
|
||||
import java.util.UUID;
|
||||
@ -35,6 +36,8 @@ import static org.junit.Assert.assertFalse;
|
||||
@RunWith(MockitoJUnitRunner.Silent.class)
|
||||
public class JSErrorRegressionTest {
|
||||
|
||||
private static final int TEST_PORT_NUMBER = RandomData.randomInt(9005, 9500);
|
||||
|
||||
@ClassRule
|
||||
public static TemporaryFolder temporaryFolder = new TemporaryFolder();
|
||||
@ClassRule
|
||||
@ -49,7 +52,7 @@ public class JSErrorRegressionTest {
|
||||
bukkitSystem = component.getPlanSystem();
|
||||
|
||||
PlanConfig config = bukkitSystem.getConfigSystem().getConfig();
|
||||
config.set(WebserverSettings.PORT, 9005);
|
||||
config.set(WebserverSettings.PORT, TEST_PORT_NUMBER);
|
||||
|
||||
bukkitSystem.enable();
|
||||
savePlayerData();
|
||||
@ -81,7 +84,7 @@ public class JSErrorRegressionTest {
|
||||
public void playerPageDoesNotHaveJavascriptErrors() {
|
||||
System.out.println("Testing Player Page");
|
||||
WebDriver driver = seleniumDriver.getDriver();
|
||||
driver.get("http://localhost:9005/player/TestPlayer");
|
||||
driver.get("http://localhost:" + TEST_PORT_NUMBER + "/player/TestPlayer");
|
||||
assertFalse(driver.getPageSource(), driver.getPageSource().contains("500 Internal Error occurred"));
|
||||
}
|
||||
|
||||
@ -91,7 +94,7 @@ public class JSErrorRegressionTest {
|
||||
System.out.println("Testing Server Page");
|
||||
WebDriver driver = seleniumDriver.getDriver();
|
||||
// Open the page that has refreshing info
|
||||
driver.get("http://localhost:9005/server");
|
||||
driver.get("http://localhost:" + TEST_PORT_NUMBER + "/server");
|
||||
assertFalse(driver.getPageSource(), driver.getPageSource().contains("500 Internal Error occurred"));
|
||||
|
||||
// Wait until Plan caches analysis results
|
||||
@ -101,7 +104,7 @@ public class JSErrorRegressionTest {
|
||||
|
||||
// Open the page with analysis stuff
|
||||
seleniumDriver.newTab();
|
||||
driver.get("http://localhost:9005/server");
|
||||
driver.get("http://localhost:" + TEST_PORT_NUMBER + "/server");
|
||||
assertFalse(driver.getPageSource(), driver.getPageSource().contains("500 Internal Error occurred"));
|
||||
}
|
||||
|
||||
@ -110,7 +113,7 @@ public class JSErrorRegressionTest {
|
||||
public void playersPageDoesNotHaveJavascriptErrors() {
|
||||
System.out.println("Testing Players Page");
|
||||
WebDriver driver = seleniumDriver.getDriver();
|
||||
driver.get("http://localhost:9005/players");
|
||||
driver.get("http://localhost:" + TEST_PORT_NUMBER + "/players");
|
||||
assertFalse(driver.getPageSource(), driver.getPageSource().contains("500 Internal Error occurred"));
|
||||
}
|
||||
|
||||
@ -118,7 +121,7 @@ public class JSErrorRegressionTest {
|
||||
public void debugPageDoesNotHaveJavascriptErrors() {
|
||||
System.out.println("Testing Debug Page");
|
||||
WebDriver driver = seleniumDriver.getDriver();
|
||||
driver.get("http://localhost:9005/debug");
|
||||
driver.get("http://localhost:" + TEST_PORT_NUMBER + "/debug");
|
||||
assertFalse(driver.getPageSource(), driver.getPageSource().contains("500 Internal Error occurred"));
|
||||
}
|
||||
}
|
@ -15,6 +15,7 @@ import org.mockito.junit.MockitoJUnitRunner;
|
||||
import rules.BukkitComponentMocker;
|
||||
import rules.BungeeComponentMocker;
|
||||
import rules.ComponentMocker;
|
||||
import utilities.RandomData;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -31,6 +32,8 @@ public class BungeeBukkitConnectionTest {
|
||||
@ClassRule
|
||||
public static ComponentMocker bungeeComponent = new BungeeComponentMocker(temporaryFolder);
|
||||
|
||||
private final int TEST_PORT_NUMBER = RandomData.randomInt(9005, 9500);
|
||||
|
||||
@Rule
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@ -57,7 +60,7 @@ public class BungeeBukkitConnectionTest {
|
||||
bukkitSystem = bukkitComponent.getPlanSystem();
|
||||
bungeeSystem = bungeeComponent.getPlanSystem();
|
||||
|
||||
bukkitSystem.getConfigSystem().getConfig().set(WebserverSettings.PORT, 9005);
|
||||
bukkitSystem.getConfigSystem().getConfig().set(WebserverSettings.PORT, TEST_PORT_NUMBER);
|
||||
bungeeSystem.getConfigSystem().getConfig().set(WebserverSettings.PORT, 9250);
|
||||
|
||||
DBSystem dbSystem = bungeeSystem.getDatabaseSystem();
|
||||
|
@ -64,6 +64,8 @@ import static org.junit.Assert.*;
|
||||
*/
|
||||
public abstract class CommonDBTest {
|
||||
|
||||
private static final int TEST_PORT_NUMBER = RandomData.randomInt(9005, 9500);
|
||||
|
||||
@ClassRule
|
||||
public static TemporaryFolder temporaryFolder = new TemporaryFolder();
|
||||
@ClassRule
|
||||
@ -84,7 +86,7 @@ public abstract class CommonDBTest {
|
||||
static void handleSetup(String dbName) throws Exception {
|
||||
System.out.println("--- Test Class Setup ---");
|
||||
system = component.getPlanSystem();
|
||||
system.getConfigSystem().getConfig().set(WebserverSettings.PORT, 9005);
|
||||
system.getConfigSystem().getConfig().set(WebserverSettings.PORT, TEST_PORT_NUMBER);
|
||||
system.enable();
|
||||
|
||||
dbSystem = system.getDatabaseSystem();
|
||||
|
@ -9,6 +9,7 @@ import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import rules.BukkitComponentMocker;
|
||||
import rules.ComponentMocker;
|
||||
import utilities.RandomData;
|
||||
|
||||
public class NetworkSettingsTest {
|
||||
|
||||
@ -17,6 +18,8 @@ public class NetworkSettingsTest {
|
||||
@ClassRule
|
||||
public static ComponentMocker component = new BukkitComponentMocker(temporaryFolder);
|
||||
|
||||
private final int TEST_PORT_NUMBER = RandomData.randomInt(9005, 9500);
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownClass() {
|
||||
component.getPlanSystem().disable();
|
||||
@ -25,7 +28,7 @@ public class NetworkSettingsTest {
|
||||
@Test
|
||||
public void transferDoesNotProduceException() throws EnableException {
|
||||
PlanSystem system = component.getPlanSystem();
|
||||
system.getConfigSystem().getConfig().set(WebserverSettings.PORT, 9005);
|
||||
system.getConfigSystem().getConfig().set(WebserverSettings.PORT, TEST_PORT_NUMBER);
|
||||
system.enable();
|
||||
|
||||
NetworkSettings networkSettings = system.getConfigSystem().getConfig().getNetworkSettings();
|
||||
|
@ -14,6 +14,7 @@ import org.mockito.junit.MockitoJUnitRunner;
|
||||
import rules.BukkitComponentMocker;
|
||||
import rules.ComponentMocker;
|
||||
import utilities.HTTPConnector;
|
||||
import utilities.RandomData;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -25,6 +26,8 @@ import java.security.NoSuchAlgorithmException;
|
||||
@RunWith(MockitoJUnitRunner.Silent.class)
|
||||
public class HTTPSWebServerAuthTest {
|
||||
|
||||
private static final int TEST_PORT_NUMBER = RandomData.randomInt(9005, 9500);
|
||||
|
||||
@ClassRule
|
||||
public static TemporaryFolder temporaryFolder = new TemporaryFolder();
|
||||
@ClassRule
|
||||
@ -49,7 +52,7 @@ public class HTTPSWebServerAuthTest {
|
||||
config.set(WebserverSettings.CERTIFICATE_STOREPASS, "wDwwf663NLTm73gL");
|
||||
config.set(WebserverSettings.CERTIFICATE_ALIAS, "DefaultPlanCert");
|
||||
|
||||
config.set(WebserverSettings.PORT, 9005);
|
||||
config.set(WebserverSettings.PORT, TEST_PORT_NUMBER);
|
||||
|
||||
bukkitSystem.enable();
|
||||
|
||||
@ -70,7 +73,7 @@ public class HTTPSWebServerAuthTest {
|
||||
@Test
|
||||
@Ignore("HTTPS Start fails due to paths being bad for some reason")
|
||||
public void testHTTPSAuthForPages() throws IOException, WebException, KeyManagementException, NoSuchAlgorithmException {
|
||||
String address = "https://localhost:9005";
|
||||
String address = "https://localhost:" + TEST_PORT_NUMBER;
|
||||
URL url = new URL(address);
|
||||
HttpURLConnection connection = connector.getConnection("HET", address);
|
||||
|
||||
|
@ -319,6 +319,7 @@
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.0.0-M2</version>
|
||||
<configuration>
|
||||
<parallel>classes</parallel>
|
||||
<trimStackTrace>false</trimStackTrace>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
@ -14,6 +14,7 @@ import org.junit.runner.RunWith;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import rules.ComponentMocker;
|
||||
import rules.SpongeComponentMocker;
|
||||
import utilities.RandomData;
|
||||
|
||||
/**
|
||||
* Test for Sponge PlanSystem.
|
||||
@ -28,11 +29,13 @@ public class SpongeSystemTest {
|
||||
@ClassRule
|
||||
public static ComponentMocker component = new SpongeComponentMocker(temporaryFolder);
|
||||
|
||||
private final int TEST_PORT_NUMBER = RandomData.randomInt(9005, 9500);
|
||||
|
||||
@Test
|
||||
public void testEnable() throws EnableException {
|
||||
PlanSystem spongeSystem = component.getPlanSystem();
|
||||
try {
|
||||
spongeSystem.getConfigSystem().getConfig().set(WebserverSettings.PORT, 9005);
|
||||
spongeSystem.getConfigSystem().getConfig().set(WebserverSettings.PORT, TEST_PORT_NUMBER);
|
||||
spongeSystem.enable();
|
||||
} finally {
|
||||
spongeSystem.disable();
|
||||
|
@ -16,6 +16,7 @@ import org.junit.runner.RunWith;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import rules.ComponentMocker;
|
||||
import rules.VelocityComponentMocker;
|
||||
import utilities.RandomData;
|
||||
|
||||
/**
|
||||
* Test for Velocity PlanSystem.
|
||||
@ -30,12 +31,14 @@ public class VelocitySystemTest {
|
||||
@ClassRule
|
||||
public static ComponentMocker component = new VelocityComponentMocker(temporaryFolder);
|
||||
|
||||
private final int TEST_PORT_NUMBER = RandomData.randomInt(9005, 9500);
|
||||
|
||||
@Test
|
||||
public void velocityEnables() throws Exception {
|
||||
PlanSystem velocitySystem = component.getPlanSystem();
|
||||
try {
|
||||
PlanConfig config = velocitySystem.getConfigSystem().getConfig();
|
||||
config.set(WebserverSettings.PORT, 9005);
|
||||
config.set(WebserverSettings.PORT, TEST_PORT_NUMBER);
|
||||
config.set(ProxySettings.IP, "8.8.8.8");
|
||||
|
||||
DBSystem dbSystem = velocitySystem.getDatabaseSystem();
|
||||
|
@ -1,7 +1,7 @@
|
||||
cd Plan
|
||||
|
||||
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
|
||||
mvn test
|
||||
mvn -T 1C test
|
||||
fi
|
||||
|
||||
if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
|
||||
|
Loading…
Reference in New Issue
Block a user