8000 [Old Arquillian testsuite] Migrating Assert JUnit4 to Assertions JUnit5 by lhanusov · Pull Request #47893 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
24 changes: 24 additions & 0 deletions testsuite/integration-arquillian/tests/base/pom.xml
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are all these dependencies needed? Isn't it just junit-jupiter-api that is required, and shouldn't scope be test instead of compile?

Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,30 @@
<artifactId>junit</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-engine</artifactId>
<version>1.10.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-commons</artifactId>
<version>1.10.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.10.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.10.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
import org.jboss.arquillian.test.spi.event.suite.BeforeSuite;
import org.jboss.logging.Logger;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Assert;
import org.junit.jupiter.api.Assertions;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
Expand Down Expand Up @@ -664,7 +664,7 @@ private void checkForNoUnexpectedUncaughtError(Stream<String> logStream) {
Optional<Matcher> anyUncaughtError = logStream.map(UNEXPECTED_UNCAUGHT_ERROR::matcher).filter(Matcher::find).findAny();
if (anyUncaughtError.isPresent()) {
Matcher m = anyUncaughtError.get();
Assert.fail("Uncaught server error detected: " + m.group(1));
Assertions.fail("Uncaught server error detected: " + m.group(1));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class TestClassProvider {
public static final String[] PERMITTED_PACKAGES = new String[] {
"/org/keycloak/testsuite",
"/org/junit",
"/org/opentest4j",
"/org/hamcrest",
"/org/keycloak/admin/client",
"/org/jboss/resteasy/client",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

import static org.keycloak.testsuite.util.UIUtils.clickLink;

import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
Expand Down Expand Up @@ -68,7 +68,7 @@ public boolean isCurrent(WebDriver driver1) {

public void assertClientScopes(List<String> expectedScopes) {
List<String> actualScopes = scopesToApprove.stream().map(WebElement::getText).collect(Collectors.toList());
assertTrue("Expected and actual Client Scopes to approve don't match",
CollectionUtil.collectionEquals(expectedScopes, actualScopes)); // order of scopes doesn't matter
assertTrue(CollectionUtil.collectionEquals(expectedScopes, actualScopes),
"Expected and actual Client Scopes to approve don't match"); // order of scopes doesn't matter
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
import org.jboss.resteasy.client.jaxrs.ResteasyClient;
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget;
import org.junit.Assert;
import org.junit.AssumptionViolatedException;
import org.junit.jupiter.api.Assertions;

/**
* @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
Expand Down Expand Up @@ -98,7 +98,7 @@ public void enableFeature(Profile.Feature feature) {
featureString = feature.getKey();
}
Set<Profile.Feature> disabledFeatures = testing().enableFeature(featureString);
Assert.assertFalse(disabledFeatures.contains(feature));
Assertions.assertFalse(disabledFeatures.contains(feature));
ProfileAssume.updateDisabledFeatures(disabledFeatures);
}

Expand All @@ -114,7 +114,7 @@ public void disableFeature(Profile.Feature feature) {
featureString = feature.getKey();
}
Set<Profile.Feature> disabledFeatures = testing().disableFeature(featureString);
Assert.assertTrue(disabledFeatures.contains(feature));
Assertions.assertTrue(disabledFeatures.contains(feature));
ProfileAssume.updateDisabledFeatures(disabledFeatures);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

import org.jboss.arquillian.drone.api.annotation.Drone;
import org.jboss.logging.Logger;
import org.junit.Assert;
import org.junit.jupiter.api.Assertions;
import org.openqa.selenium.WebDriver;

/**
Expand Down Expand Up @@ -109,7 +109,7 @@ public boolean isCurrent() {

public void assertCurrent() {
String name = getClass().getSimpleName();
Assert.assertTrue("Expected " + name + " but was " + DroneUtils.getCurrentDriver().getTitle() + " (" + DroneUtils.getCurrentDriver().getCurrentUrl() + ")",
isCurrent());
Assertions.assertTrue(isCurrent(),
"Expected " + name + " but was " + DroneUtils.getCurrentDriver().getTitle() + " (" + DroneUtils.getCurrentDriver().getCurrentUrl() + ")");
}
}
10000
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
import static org.keycloak.testsuite.util.UIUtils.isElementVisible;
import static org.keycloak.testsuite.util.WaitUtils.PAGELOAD_TIMEOUT_MILLIS;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
*
Expand Down Expand Up @@ -82,11 +82,11 @@ public boolean isSuccess() {
}

public void assertDisplayed() {
assertTrue("Alert should displayed", isDisplayed());
assertTrue(isDisplayed(), "Alert should displayed");
}

public void assertNotDisplayed() {
assertFalse("Alert shouldn't be displayed", isDisplayed());
assertFalse(isDisplayed(), "Alert shouldn't be displayed");
}

public void assertSuccess() {
Expand All @@ -95,7 +95,7 @@ public void assertSuccess() {

public void assertSuccess(String expectedText) {
assertDisplayed();
assertTrue("Alert type should be success", isSuccess());
assertTrue(isSuccess(), "Alert type should be success");
if (expectedText != null) assertEquals(expectedText, getText());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.keycloak.testsuite.util.oauth.OAuthClient;

import org.jboss.arquillian.test.api.ArquillianResource;
import org.junit.Assert;
import org.junit.jupiter.api.Assertions;
import org.openqa.selenium.WebDriver;

/**
Expand All @@ -36,8 +36,8 @@ public abstract class AbstractPage {

public void assertCurrent() {
String name = getClass().getSimpleName();
Assert.assertTrue("Expected " + name + " but was " + driver.getTitle() + " (" + driver.getCurrentUrl() + ")",
isCurrent());
Assertions.assertTrue(isCurrent(),
"Expected " + name + " but was " + driver.getTitle() + " (" + driver.getCurrentUrl() + ")");
}

abstract public boolean isCurrent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import org.keycloak.testsuite.util.UIUtils;

import org.junit.Assert;
import org.junit.jupiter.api.Assertions;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

Expand Down Expand Up @@ -52,6 +52,6 @@ public void cancel() {
}

public void assertCredentialInMessage(String expectedLabel) {
Assert.assertEquals("Do you want to delete " + expectedLabel + "?", message.getText());
Assertions.assertEquals("Do you want to delete " + expectedLabel + "?", message.getText());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import org.keycloak.testsuite.util.UIUtils;

import org.junit.Assert;
import org.junit.jupiter.api.Assertions;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

Expand Down Expand Up @@ -52,6 +52,6 @@ public void cancel() {
}

public void assertIdpInMessage(String expectedIdpDisplayName) {
Assert.assertEquals("Do you want to link your account with " + expectedIdpDisplayName + "?", message.getText());
Assertions.assertEquals("Do you want to link your account with " + expectedIdpDisplayName + "?", message.getText());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.keycloak.common.util.KeycloakUriBuilder;
import org.keycloak.services.Urls;

import org.junit.Assert;
import org.junit.jupiter.api.Assertions;
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebElement;
Expand Down Expand Up @@ -74,7 +74,7 @@ public boolean isCurrent() {


public String getSuccessCode() {
Assert.assertEquals("Success code", getPageTitleText());
Assertions.assertEquals("Success code", getPageTitleText());
return code.getAttribute("value");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.keycloak.testsuite.util.UIUtils;
import org.keycloak.testsuite.util.WaitUtils;

import org.junit.Assert;
import org.junit.jupiter.api.Assertions;
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
Expand Down Expand Up @@ -81,7 +81,7 @@ public void openLanguage(String language){
String url = langLink.getAttribute("href");
DroneUtils.getCurrentDriver().navigate().to(url);
} catch (URISyntaxException ex) {
Assert.fail(ex.getMessage());
Assertions.fail(ex.getMessage());
}
WaitUtils.waitForPageToLoad();
}
Expand All @@ -90,9 +90,9 @@ public void openLanguage(String language){
public void assertTryAnotherWayLinkAvailability(boolean expectedAvailability) {
try {
driver.findElement(By.id("try-another-way"));
Assert.assertTrue(expectedAvailability);
Assertions.assertTrue(expectedAvailability);
} catch (NoSuchElementException nse) {
Assert.assertFalse(expectedAvailability);
Assertions.assertFalse(expectedAvailability);
}
}

Expand All @@ -103,9 +103,9 @@ public void clickTryAnotherWayLink() {
public void assertAccountLinkAvailability(boolean expectedAvailability) {
try {
driver.findElement(By.id("account"));
Assert.assertTrue(expectedAvailability);
Assertions.assertTrue(expectedAvailability);
} catch (NoSuchElementException nse) {
Assert.assertFalse(expectedAvailability);
Assertions.assertFalse(expectedAvailability);
}
}

Expand All @@ -121,11 +121,11 @@ public void assertAttemptedUsernameAvailability(boolean expectedAvailability) {
public static void assertAttemptedUsernameAvailability(WebDriver driver, boolean expectedAvailability) {
try {
driver.findElement(By.id("kc-attempted-username"));
Assert.assertTrue(expectedAvailability);
Assertions.assertTrue(expectedAvailability);
// make sure the username field is not shown if the attempted username field is present
Assert.assertTrue(driver.findElements(By.id("username")).isEmpty());
Assertions.assertTrue(driver.findElements(By.id("username")).isEmpty());
} catch (NoSuchElementException nse) {
Assert.assertFalse(expectedAvailability);
Assertions.assertFalse(expectedAvailability);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.keycloak.testsuite.util.oauth.OAuthClient;

import org.jboss.arquillian.test.api.ArquillianResource;
import org.junit.Assert;
import org.junit.jupiter.api.Assertions;
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebElement;
Expand Down Expand Up @@ -248,8 +248,8 @@ public boolean isCurrent(String realm) {

public void assertCurrent(String realm) {
String name = getClass().getSimpleName();
Assert.assertTrue("Expected " + name + " but was " + DroneUtils.getCurrentDriver().getTitle() + " (" + DroneUtils.getCurrentDriver().getCurrentUrl() + ")",
isCurrent(realm));
Assertions.assertTrue(isCurrent(realm),
"Expected " + name + " but was " + DroneUtils.getCurrentDriver().getTitle() + " (" + DroneUtils.getCurrentDriver().getCurrentUrl() + ")");
}

public void clickRegister() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.keycloak.common.util.Retry;
import org.keycloak.testsuite.util.UIUtils;

import org.junit.Assert;
import org.junit.jupiter.api.Assertions;
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebElement;
Expand Down Expand Up @@ -91,9 +91,9 @@ public boolean isCurrent() {
public void assertOtpCredentialSelectorAvailability(boolean expectedAvailability) {
try {
driver.findElement(By.className("pf-v5-c-tile"));
Assert.assertTrue(expectedAvailability);
Assertions.assertTrue(expectedAvailability);
} catch (NoSuchElementException nse) {
Assert.assertFalse(expectedAvailability);
Assertions.assertFalse(expectedAvailability);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import org.keycloak.testsuite.util.UIUtils;

import org.junit.Assert;
import org.junit.jupiter.api.Assertions;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

Expand All @@ -35,7 +35,7 @@ public abstract class LogoutSessionsPage extends LanguageComboboxAwarePage {
@Override
public void assertCurrent() {
super.assertCurrent();
Assert.assertTrue("The page doesn't display the logout other sessions checkbox", this.isLogoutSessionDisplayed());
Assertions.assertTrue(this.isLogoutSessionDisplayed(), "The page doesn't display the logout other sessions checkbox");
}

public boolean isLogoutSessionDisplayed() {
Expand All @@ -47,12 +47,12 @@ public boolean isLogoutSessionsChecked() {
}

public void checkLogoutSessions() {
Assert.assertFalse("Logout sessions is checked", isLogoutSessionsChecked());
Assertions.assertFalse(isLogoutSessionsChecked(), "Logout sessions is checked");
UIUtils.switchCheckbox(logoutSessionsCheckbox, true);
}

public void uncheckLogoutSessions() {
Assert.assertTrue("Logout sessions is not checked", isLogoutSessionsChecked());
Assertions.assertTrue(isLogoutSessionsChecked(), "Logout sessions is not checked");
UIUtils.switchCheckbox(logoutSessionsCheckbox, false);
}
}
Loading
Loading
0