mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-02-15 03:41:38 +01:00
Replaced JUnit 4 imports
This commit is contained in:
parent
b1a299a9b2
commit
5dca308e18
@ -24,7 +24,7 @@ import utilities.TestConstants;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
abstract class DBPatchRegressionTest {
|
abstract class DBPatchRegressionTest {
|
||||||
|
|
||||||
@ -91,6 +91,6 @@ abstract class DBPatchRegressionTest {
|
|||||||
failed.add(patch.getClass().getSimpleName());
|
failed.add(patch.getClass().getSimpleName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assertTrue("Patches " + failed + " were not applied properly.", failed.isEmpty());
|
assertTrue(failed.isEmpty(), "Patches " + failed + " were not applied properly.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ import java.util.List;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link PingStoreTransaction#getMeanValue()}.
|
* Test for {@link PingStoreTransaction#getMeanValue()}.
|
||||||
|
@ -26,7 +26,7 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class for {@link LocaleFileWriter}.
|
* Test class for {@link LocaleFileWriter}.
|
||||||
|
@ -24,8 +24,8 @@ import org.junit.runner.RunWith;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
@RunWith(JUnitPlatform.class)
|
@RunWith(JUnitPlatform.class)
|
||||||
class VersionInfoLoaderTest {
|
class VersionInfoLoaderTest {
|
||||||
|
@ -24,7 +24,7 @@ import utilities.HTTPConnector;
|
|||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
interface HttpsServerTest {
|
interface HttpsServerTest {
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ interface HttpsServerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
default void webServerIsRunningHTTPS() {
|
default void webServerIsRunningHTTPS() {
|
||||||
assertTrue("WebServer is not using https", getWebServer().isUsingHTTPS());
|
assertTrue(getWebServer().isUsingHTTPS(), "WebServer is not using https");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,7 +23,6 @@ import com.djrapitops.plan.db.access.transactions.events.SessionEndTransaction;
|
|||||||
import com.djrapitops.plan.db.access.transactions.events.WorldNameStoreTransaction;
|
import com.djrapitops.plan.db.access.transactions.events.WorldNameStoreTransaction;
|
||||||
import com.djrapitops.plan.system.PlanSystem;
|
import com.djrapitops.plan.system.PlanSystem;
|
||||||
import com.djrapitops.plan.system.database.DBSystem;
|
import com.djrapitops.plan.system.database.DBSystem;
|
||||||
import com.djrapitops.plan.system.locale.lang.ErrorPageLang;
|
|
||||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||||
import com.djrapitops.plan.system.settings.paths.WebserverSettings;
|
import com.djrapitops.plan.system.settings.paths.WebserverSettings;
|
||||||
import com.djrapitops.plan.system.webserver.cache.PageId;
|
import com.djrapitops.plan.system.webserver.cache.PageId;
|
||||||
@ -47,7 +46,7 @@ import java.nio.file.Path;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This test class is for catching any JavaScript errors.
|
* This test class is for catching any JavaScript errors.
|
||||||
@ -108,14 +107,18 @@ class JSErrorRegressionTest {
|
|||||||
void playerPageDoesNotHaveJavascriptErrors(WebDriver driver) {
|
void playerPageDoesNotHaveJavascriptErrors(WebDriver driver) {
|
||||||
System.out.println("Testing Player Page");
|
System.out.println("Testing Player Page");
|
||||||
driver.get("http://localhost:" + TEST_PORT_NUMBER + "/player/TestPlayer");
|
driver.get("http://localhost:" + TEST_PORT_NUMBER + "/player/TestPlayer");
|
||||||
assertFalse(driver.getPageSource(), driver.getPageSource().contains("500 Internal Error occurred"));
|
assertNo500Error(driver);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertNo500Error(WebDriver driver) {
|
||||||
|
assertFalse(driver.getPageSource().contains("500 Internal Error occurred"), driver.getPageSource());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void playerPageAccessibleViaUUID(WebDriver driver) {
|
void playerPageAccessibleViaUUID(WebDriver driver) {
|
||||||
System.out.println("Testing Player Page via UUID");
|
System.out.println("Testing Player Page via UUID");
|
||||||
driver.get("http://localhost:" + TEST_PORT_NUMBER + "/player/" + TestConstants.PLAYER_ONE_UUID);
|
driver.get("http://localhost:" + TEST_PORT_NUMBER + "/player/" + TestConstants.PLAYER_ONE_UUID);
|
||||||
assertFalse(driver.getPageSource(), driver.getPageSource().contains(ErrorPageLang.NOT_PLAYED_404.getDefault()));
|
assertNo500Error(driver);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -123,7 +126,7 @@ class JSErrorRegressionTest {
|
|||||||
System.out.println("Testing Server Page");
|
System.out.println("Testing Server Page");
|
||||||
// Open the page that has refreshing info
|
// Open the page that has refreshing info
|
||||||
driver.get("http://localhost:" + TEST_PORT_NUMBER + "/server");
|
driver.get("http://localhost:" + TEST_PORT_NUMBER + "/server");
|
||||||
assertFalse(driver.getPageSource(), driver.getPageSource().contains("500 Internal Error occurred"));
|
assertNo500Error(driver);
|
||||||
|
|
||||||
// Wait until Plan caches analysis results
|
// Wait until Plan caches analysis results
|
||||||
Awaitility.await()
|
Awaitility.await()
|
||||||
@ -133,20 +136,20 @@ class JSErrorRegressionTest {
|
|||||||
// Open the page with analysis stuff
|
// Open the page with analysis stuff
|
||||||
SeleniumExtension.newTab(driver);
|
SeleniumExtension.newTab(driver);
|
||||||
driver.get("http://localhost:" + TEST_PORT_NUMBER + "/server");
|
driver.get("http://localhost:" + TEST_PORT_NUMBER + "/server");
|
||||||
assertFalse(driver.getPageSource(), driver.getPageSource().contains("500 Internal Error occurred"));
|
assertNo500Error(driver);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void playersPageDoesNotHaveJavascriptErrors(WebDriver driver) {
|
void playersPageDoesNotHaveJavascriptErrors(WebDriver driver) {
|
||||||
System.out.println("Testing Players Page");
|
System.out.println("Testing Players Page");
|
||||||
driver.get("http://localhost:" + TEST_PORT_NUMBER + "/players");
|
driver.get("http://localhost:" + TEST_PORT_NUMBER + "/players");
|
||||||
assertFalse(driver.getPageSource(), driver.getPageSource().contains("500 Internal Error occurred"));
|
assertNo500Error(driver);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void debugPageDoesNotHaveJavascriptErrors(WebDriver driver) {
|
void debugPageDoesNotHaveJavascriptErrors(WebDriver driver) {
|
||||||
System.out.println("Testing Debug Page");
|
System.out.println("Testing Debug Page");
|
||||||
driver.get("http://localhost:" + TEST_PORT_NUMBER + "/debug");
|
driver.get("http://localhost:" + TEST_PORT_NUMBER + "/debug");
|
||||||
assertFalse(driver.getPageSource(), driver.getPageSource().contains("500 Internal Error occurred"));
|
assertNo500Error(driver);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -17,7 +17,7 @@
|
|||||||
package extension;
|
package extension;
|
||||||
|
|
||||||
import org.apache.commons.lang3.SystemUtils;
|
import org.apache.commons.lang3.SystemUtils;
|
||||||
import org.junit.Assume;
|
import org.junit.jupiter.api.Assumptions;
|
||||||
import org.junit.jupiter.api.extension.*;
|
import org.junit.jupiter.api.extension.*;
|
||||||
import org.openqa.selenium.By;
|
import org.openqa.selenium.By;
|
||||||
import org.openqa.selenium.Keys;
|
import org.openqa.selenium.Keys;
|
||||||
@ -60,8 +60,8 @@ public class SeleniumExtension implements ParameterResolver, BeforeAllCallback,
|
|||||||
@Override
|
@Override
|
||||||
public void beforeAll(ExtensionContext context) {
|
public void beforeAll(ExtensionContext context) {
|
||||||
String driverLocation = getChromeDriverLocation();
|
String driverLocation = getChromeDriverLocation();
|
||||||
Assume.assumeNotNull("rules.SeleniumDriver: Chrome driver location not specified for this OS type", driverLocation);
|
Assumptions.assumeFalse(driverLocation == null, "rules.SeleniumDriver: Chrome driver location not specified for this OS type");
|
||||||
Assume.assumeTrue("rules.SeleniumDriver: Chrome driver not found at " + driverLocation, new File(driverLocation).exists());
|
Assumptions.assumeTrue(new File(driverLocation).exists(), "rules.SeleniumDriver: Chrome driver not found at " + driverLocation);
|
||||||
|
|
||||||
System.setProperty("webdriver.chrome.driver", driverLocation);
|
System.setProperty("webdriver.chrome.driver", driverLocation);
|
||||||
driver = getChromeWebDriver();
|
driver = getChromeWebDriver();
|
||||||
|
@ -26,7 +26,7 @@ import java.nio.file.Files;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
public class TestResources {
|
public class TestResources {
|
||||||
|
|
||||||
@ -44,13 +44,7 @@ public class TestResources {
|
|||||||
public static void copyResourceIntoFile(File toFile, String resourcePath) {
|
public static void copyResourceIntoFile(File toFile, String resourcePath) {
|
||||||
createEmptyFile(toFile);
|
createEmptyFile(toFile);
|
||||||
writeResourceToFile(toFile, resourcePath);
|
writeResourceToFile(toFile, resourcePath);
|
||||||
assertTrue("Failed to copy resource: '" + resourcePath + "'", toFile.exists());
|
assertTrue(toFile.exists(), () -> "Failed to copy resource: '" + resourcePath + "'");
|
||||||
}
|
|
||||||
|
|
||||||
public static void copyTestResourceIntoFile(File toFile, InputStream testResource) {
|
|
||||||
createEmptyFile(toFile);
|
|
||||||
copyResourceToFile(toFile, testResource);
|
|
||||||
assertTrue("Failed to copy resource: '" + toFile.getAbsolutePath() + "'", toFile.exists());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void copyResourceToFile(File toFile, InputStream testResource) {
|
private static void copyResourceToFile(File toFile, InputStream testResource) {
|
||||||
|
Loading…
Reference in New Issue
Block a user