Fix hello-security-explicit checkstyle
This commit is contained in:
parent
9b76605c2f
commit
67ea8e7438
@ -22,10 +22,13 @@ import org.junit.jupiter.api.BeforeEach;
|
|||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.openqa.selenium.WebDriver;
|
import org.openqa.selenium.WebDriver;
|
||||||
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
|
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
|
||||||
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.web.server.LocalServerPort;
|
import org.springframework.boot.web.server.LocalServerPort;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Integration tests.
|
||||||
|
*
|
||||||
* @author Michael Simons
|
* @author Michael Simons
|
||||||
*/
|
*/
|
||||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||||
@ -37,27 +40,25 @@ public class HelloSecurityExplicitITests {
|
|||||||
private int port;
|
private int port;
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void setup() {
|
void setup() {
|
||||||
this.driver = new HtmlUnitDriver();
|
this.driver = new HtmlUnitDriver();
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterEach
|
@AfterEach
|
||||||
public void tearDown() {
|
void tearDown() {
|
||||||
this.driver.quit();
|
this.driver.quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void login() {
|
void login() {
|
||||||
final LoginPage loginPage = HomePage.to(this.driver, this.port);
|
final LoginPage loginPage = HomePage.to(this.driver, this.port);
|
||||||
loginPage.assertAt();
|
loginPage.assertAt();
|
||||||
|
|
||||||
HomePage homePage = loginPage.loginForm()
|
HomePage homePage = loginPage.loginForm().username("user").password("password").submit();
|
||||||
.username("user")
|
|
||||||
.password("password")
|
|
||||||
.submit();
|
|
||||||
homePage.assertAt();
|
homePage.assertAt();
|
||||||
|
|
||||||
LoginPage logoutSuccess = homePage.logout();
|
LoginPage logoutSuccess = homePage.logout();
|
||||||
logoutSuccess.assertAt();
|
logoutSuccess.assertAt();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,16 +23,19 @@ import org.openqa.selenium.support.PageFactory;
|
|||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* The home page.
|
||||||
|
*
|
||||||
* @author Michael Simons
|
* @author Michael Simons
|
||||||
*/
|
*/
|
||||||
public class HomePage {
|
public class HomePage {
|
||||||
|
|
||||||
private final WebDriver webDriver;
|
private final WebDriver webDriver;
|
||||||
|
|
||||||
@FindBy(id = "logout")
|
@FindBy(id = "logout")
|
||||||
private WebElement logout;
|
private WebElement logout;
|
||||||
|
|
||||||
public static LoginPage to(WebDriver driver, int port) {
|
public static LoginPage to(WebDriver driver, int port) {
|
||||||
driver.get("http://localhost:" + port +"/");
|
driver.get("http://localhost:" + port + "/");
|
||||||
return PageFactory.initElements(driver, LoginPage.class);
|
return PageFactory.initElements(driver, LoginPage.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,4 +52,5 @@ public class HomePage {
|
|||||||
this.logout.click();
|
this.logout.click();
|
||||||
return PageFactory.initElements(this.webDriver, LogoutConfirmPage.class).logout();
|
return PageFactory.initElements(this.webDriver, LogoutConfirmPage.class).logout();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,8 @@ import org.openqa.selenium.support.PageFactory;
|
|||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* The login page.
|
||||||
|
*
|
||||||
* @author Michael Simons
|
* @author Michael Simons
|
||||||
*/
|
*/
|
||||||
public class LoginPage {
|
public class LoginPage {
|
||||||
@ -46,9 +48,13 @@ public class LoginPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class LoginForm {
|
public static class LoginForm {
|
||||||
|
|
||||||
private WebDriver webDriver;
|
private WebDriver webDriver;
|
||||||
|
|
||||||
private WebElement username;
|
private WebElement username;
|
||||||
|
|
||||||
private WebElement password;
|
private WebElement password;
|
||||||
|
|
||||||
@FindBy(css = "button[type=submit]")
|
@FindBy(css = "button[type=submit]")
|
||||||
private WebElement submit;
|
private WebElement submit;
|
||||||
|
|
||||||
@ -70,5 +76,7 @@ public class LoginPage {
|
|||||||
this.submit.click();
|
this.submit.click();
|
||||||
return PageFactory.initElements(this.webDriver, HomePage.class);
|
return PageFactory.initElements(this.webDriver, HomePage.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,33 +21,41 @@ import org.openqa.selenium.WebElement;
|
|||||||
import org.openqa.selenium.support.FindBy;
|
import org.openqa.selenium.support.FindBy;
|
||||||
import org.openqa.selenium.support.PageFactory;
|
import org.openqa.selenium.support.PageFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The log out confirmation page.
|
||||||
|
* @author Rob Winch
|
||||||
|
*/
|
||||||
public class LogoutConfirmPage {
|
public class LogoutConfirmPage {
|
||||||
|
|
||||||
private final WebDriver webDriver;
|
private final WebDriver webDriver;
|
||||||
|
|
||||||
private final LogoutConfirmPage.LogoutForm logoutForm;
|
private final LogoutConfirmPage.LogoutForm logoutForm;
|
||||||
|
|
||||||
public LogoutConfirmPage(WebDriver webDriver) {
|
public LogoutConfirmPage(WebDriver webDriver) {
|
||||||
this.webDriver = webDriver;
|
this.webDriver = webDriver;
|
||||||
this.logoutForm = PageFactory.initElements(this.webDriver, LogoutForm.class);
|
this.logoutForm = PageFactory.initElements(this.webDriver, LogoutForm.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoginPage logout() {
|
public LoginPage logout() {
|
||||||
return this.logoutForm.logout();
|
return this.logoutForm.logout();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class LogoutForm {
|
public static class LogoutForm {
|
||||||
private WebDriver webDriver;
|
|
||||||
@FindBy(css = "button[type=submit]")
|
|
||||||
private WebElement submit;
|
|
||||||
|
|
||||||
public LogoutForm(WebDriver webDriver) {
|
private WebDriver webDriver;
|
||||||
this.webDriver = webDriver;
|
|
||||||
}
|
@FindBy(css = "button[type=submit]")
|
||||||
|
private WebElement submit;
|
||||||
|
|
||||||
|
public LogoutForm(WebDriver webDriver) {
|
||||||
|
this.webDriver = webDriver;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LoginPage logout() {
|
||||||
|
this.submit.click();
|
||||||
|
return PageFactory.initElements(this.webDriver, LoginPage.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public LoginPage logout() {
|
|
||||||
this.submit.click();
|
|
||||||
return PageFactory.initElements(this.webDriver, LoginPage.class);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user