mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-06 15:44:49 +08: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.List;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
abstract class DBPatchRegressionTest {
|
||||
|
||||
@ -91,6 +91,6 @@ abstract class DBPatchRegressionTest {
|
||||
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.stream.Collectors;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* Test for {@link PingStoreTransaction#getMeanValue()}.
|
||||
|
@ -26,7 +26,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* Test class for {@link LocaleFileWriter}.
|
||||
|
@ -24,8 +24,8 @@ import org.junit.runner.RunWith;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@RunWith(JUnitPlatform.class)
|
||||
class VersionInfoLoaderTest {
|
||||
|
@ -24,7 +24,7 @@ import utilities.HTTPConnector;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
interface HttpsServerTest {
|
||||
|
||||
@ -36,7 +36,7 @@ interface HttpsServerTest {
|
||||
|
||||
@Test
|
||||
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.system.PlanSystem;
|
||||
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.paths.WebserverSettings;
|
||||
import com.djrapitops.plan.system.webserver.cache.PageId;
|
||||
@ -47,7 +46,7 @@ import java.nio.file.Path;
|
||||
import java.util.UUID;
|
||||
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.
|
||||
@ -108,14 +107,18 @@ class JSErrorRegressionTest {
|
||||
void playerPageDoesNotHaveJavascriptErrors(WebDriver driver) {
|
||||
System.out.println("Testing Player Page");
|
||||
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
|
||||
void playerPageAccessibleViaUUID(WebDriver driver) {
|
||||
System.out.println("Testing Player Page via 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
|
||||
@ -123,7 +126,7 @@ class JSErrorRegressionTest {
|
||||
System.out.println("Testing Server Page");
|
||||
// Open the page that has refreshing info
|
||||
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
|
||||
Awaitility.await()
|
||||
@ -133,20 +136,20 @@ class JSErrorRegressionTest {
|
||||
// Open the page with analysis stuff
|
||||
SeleniumExtension.newTab(driver);
|
||||
driver.get("http://localhost:" + TEST_PORT_NUMBER + "/server");
|
||||
assertFalse(driver.getPageSource(), driver.getPageSource().contains("500 Internal Error occurred"));
|
||||
assertNo500Error(driver);
|
||||
}
|
||||
|
||||
@Test
|
||||
void playersPageDoesNotHaveJavascriptErrors(WebDriver driver) {
|
||||
System.out.println("Testing Players Page");
|
||||
driver.get("http://localhost:" + TEST_PORT_NUMBER + "/players");
|
||||
assertFalse(driver.getPageSource(), driver.getPageSource().contains("500 Internal Error occurred"));
|
||||
assertNo500Error(driver);
|
||||
}
|
||||
|
||||
@Test
|
||||
void debugPageDoesNotHaveJavascriptErrors(WebDriver driver) {
|
||||
System.out.println("Testing Debug Page");
|
||||
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;
|
||||
|
||||
import org.apache.commons.lang3.SystemUtils;
|
||||
import org.junit.Assume;
|
||||
import org.junit.jupiter.api.Assumptions;
|
||||
import org.junit.jupiter.api.extension.*;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.Keys;
|
||||
@ -60,8 +60,8 @@ public class SeleniumExtension implements ParameterResolver, BeforeAllCallback,
|
||||
@Override
|
||||
public void beforeAll(ExtensionContext context) {
|
||||
String driverLocation = getChromeDriverLocation();
|
||||
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());
|
||||
Assumptions.assumeFalse(driverLocation == null, "rules.SeleniumDriver: Chrome driver location not specified for this OS type");
|
||||
Assumptions.assumeTrue(new File(driverLocation).exists(), "rules.SeleniumDriver: Chrome driver not found at " + driverLocation);
|
||||
|
||||
System.setProperty("webdriver.chrome.driver", driverLocation);
|
||||
driver = getChromeWebDriver();
|
||||
|
@ -26,7 +26,7 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class TestResources {
|
||||
|
||||
@ -44,13 +44,7 @@ public class TestResources {
|
||||
public static void copyResourceIntoFile(File toFile, String resourcePath) {
|
||||
createEmptyFile(toFile);
|
||||
writeResourceToFile(toFile, resourcePath);
|
||||
assertTrue("Failed to copy resource: '" + resourcePath + "'", toFile.exists());
|
||||
}
|
||||
|
||||
public static void copyTestResourceIntoFile(File toFile, InputStream testResource) {
|
||||
createEmptyFile(toFile);
|
||||
copyResourceToFile(toFile, testResource);
|
||||
assertTrue("Failed to copy resource: '" + toFile.getAbsolutePath() + "'", toFile.exists());
|
||||
assertTrue(toFile.exists(), () -> "Failed to copy resource: '" + resourcePath + "'");
|
||||
}
|
||||
|
||||
private static void copyResourceToFile(File toFile, InputStream testResource) {
|
||||
|
Loading…
Reference in New Issue
Block a user