Skip to content

Commit 8e78e51

Browse files
Migrate xml-contacts groovy->java
See spring-projects#4939.
1 parent 59862fb commit 8e78e51

File tree

12 files changed

+449
-269
lines changed

12 files changed

+449
-269
lines changed

samples/xml/contacts/spring-security-samples-xml-contacts.gradle

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
* Copyright 2002-2018 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
apply plugin: 'io.spring.convention.spring-sample-war'
217

318
dependencies {
@@ -24,5 +39,5 @@ dependencies {
2439
runtime 'org.slf4j:jcl-over-slf4j'
2540
runtime 'org.springframework:spring-context-support'
2641

27-
integrationTestCompile gebDependencies
42+
integrationTestCompile seleniumDependencies
2843
}

samples/xml/contacts/src/integration-test/groovy/org/springframework/security/samples/ContactsTests.groovy

Lines changed: 0 additions & 87 deletions
This file was deleted.

samples/xml/contacts/src/integration-test/groovy/org/springframework/security/samples/pages/AddPage.groovy

Lines changed: 0 additions & 37 deletions
This file was deleted.

samples/xml/contacts/src/integration-test/groovy/org/springframework/security/samples/pages/ContactsPage.groovy

Lines changed: 0 additions & 44 deletions
This file was deleted.

samples/xml/contacts/src/integration-test/groovy/org/springframework/security/samples/pages/DeleteConfirmPage.groovy

Lines changed: 0 additions & 30 deletions
This file was deleted.

samples/xml/contacts/src/integration-test/groovy/org/springframework/security/samples/pages/HomePage.groovy

Lines changed: 0 additions & 33 deletions
This file was deleted.

samples/xml/contacts/src/integration-test/groovy/org/springframework/security/samples/pages/LoginPage.groovy

Lines changed: 0 additions & 37 deletions
This file was deleted.
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/*
2+
* Copyright 2002-2018 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.security.samples;
17+
18+
import org.junit.After;
19+
import org.junit.Before;
20+
import org.junit.Test;
21+
import org.openqa.selenium.WebDriver;
22+
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
23+
import org.springframework.security.samples.pages.ContactsPage;
24+
import org.springframework.security.samples.pages.HomePage;
25+
26+
/**
27+
* @author Michael Simons
28+
*/
29+
public class ContactsTests {
30+
private WebDriver driver;
31+
32+
private int port;
33+
34+
@Before
35+
public void setup() {
36+
this.port = Integer.parseInt(System.getProperty("app.httpPort"));
37+
this.driver = new HtmlUnitDriver();
38+
}
39+
40+
@After
41+
public void tearDown() {
42+
this.driver.quit();
43+
}
44+
45+
@Test
46+
public void accessHomePageWithUnauthenticatedUserSuccess() {
47+
final HomePage homePage = HomePage.to(this.driver, this.port);
48+
homePage.assertAt();
49+
}
50+
51+
@Test
52+
public void authenticatedUserCanAddContacts() {
53+
final String name = "Rob Winch";
54+
final String email = "[email protected]";
55+
56+
// @formatter:off
57+
ContactsPage.accessManagePageWithUnauthenticatedUser(this.driver, this.port)
58+
.sendsToLoginPage()
59+
.username("rod")
60+
.password("koala")
61+
.submit()
62+
.isAtContactsPage()
63+
.addContact()
64+
.name(name)
65+
.email(email)
66+
.submit()
67+
.andHasContact(name, email)
68+
.delete()
69+
.andConfirmDeletion()
70+
.isAtContactsPage()
71+
.andConctactHasBeenRemoved(name, email);
72+
// @formatter:on
73+
}
74+
75+
76+
@Test
77+
public void authenticatedUserLogsOut() {
78+
// @formatter:off
79+
final HomePage homePage = ContactsPage.accessManagePageWithUnauthenticatedUser(this.driver, this.port)
80+
.sendsToLoginPage()
81+
.username("rod")
82+
.password("koala")
83+
.submit()
84+
.isAtContactsPage()
85+
.logout();
86+
// @formatter:on
87+
homePage.assertAt();
88+
89+
ContactsPage.accessManagePageWithUnauthenticatedUser(this.driver, this.port)
90+
.sendsToLoginPage();
91+
}
92+
}

0 commit comments

Comments
 (0)