diff --git a/samples/contacts-xml/contacts.gradle b/samples/contacts-xml/contacts.gradle
index 62169a7774..5ac499f66c 100644
--- a/samples/contacts-xml/contacts.gradle
+++ b/samples/contacts-xml/contacts.gradle
@@ -25,4 +25,5 @@ dependencies {
"ch.qos.logback:logback-classic:$logbackVersion",
"net.sf.ehcache:ehcache-core:$ehcacheVersion"
+ integrationTestCompile gebDependencies
}
\ No newline at end of file
diff --git a/samples/contacts-xml/pom.xml b/samples/contacts-xml/pom.xml
index 14a18b356a..57a896e796 100644
--- a/samples/contacts-xml/pom.xml
+++ b/samples/contacts-xml/pom.xml
@@ -196,24 +196,72 @@
4.0.2.RELEASEruntime
+
+ commons-httpclient
+ commons-httpclient
+ 3.1
+ test
+ junitjunit4.11test
+
+ org.codehaus.groovy
+ groovy
+ 2.0.5
+ test
+ org.easytestingfest-assert1.4test
+
+ org.gebish
+ geb-spock
+ 0.9.0
+ test
+ org.mockitomockito-core1.9.5test
+
+ org.seleniumhq.selenium
+ selenium-htmlunit-driver
+ 2.33.0
+ test
+
+
+ org.spockframework
+ spock-core
+ 0.7-groovy-2.0
+ test
+
+
+ junit-dep
+ junit
+
+
+
+
+ org.spockframework
+ spock-spring
+ 0.7-groovy-2.0
+ test
+
+
+ junit-dep
+ junit
+
+
+ org.springframeworkspring-test
diff --git a/samples/contacts-xml/src/integration-test/groovy/org/springframework/security/samples/ContactsTests.groovy b/samples/contacts-xml/src/integration-test/groovy/org/springframework/security/samples/ContactsTests.groovy
new file mode 100644
index 0000000000..18dd2abb2a
--- /dev/null
+++ b/samples/contacts-xml/src/integration-test/groovy/org/springframework/security/samples/ContactsTests.groovy
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2011 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.security.samples
+
+import geb.spock.*
+import spock.lang.Stepwise
+import org.springframework.security.samples.pages.*
+
+/**
+ * Tests the CAS sample application using service tickets.
+ *
+ * @author Rob Winch
+ */
+@Stepwise
+class ContactsTests extends GebReportingSpec {
+ def 'access home page with unauthenticated user success'() {
+ when: 'Unauthenticated user accesses the Home Page'
+ to HomePage
+ then: 'The page is displayed'
+ at HomePage
+ }
+
+ def 'access manage page with unauthenticated user sends to login page'() {
+ when: 'Unauthenticated user accesses the Manage Page'
+ manage.click(LoginPage)
+ then: 'The login page is displayed'
+ at LoginPage
+ }
+
+ def 'authenticated user is sent to original page'() {
+ when: 'user authenticates'
+ login()
+ then: 'The manage page is displayed'
+ at ContactsPage
+ }
+
+ def 'add contact link works'() {
+ when: 'user clicks add link'
+ addContact.click(AddPage)
+ then: 'The add page is displayed'
+ at AddPage
+ }
+
+ def 'add contact'() {
+ when: 'add a contact'
+ addContact
+ then: 'The add page is displayed'
+ at ContactsPage
+ and: 'The new contact is displayed'
+ contacts.find { it.email == 'rob@example.com' }?.name == 'Rob Winch'
+ }
+
+ def 'delete contact'() {
+ when: 'delete a contact'
+ contacts.find { it.email == 'rob@example.com' }.delete()
+ then: 'Delete confirmation displayed'
+ at DeleteConfirmPage
+ when: 'View Manage Page'
+ manage.click()
+ then: 'New contact has been removed'
+ !contacts.find { it.email == 'rob@example.com' }
+ }
+
+ def 'authenticated user logs out'() {
+ when: 'user logs out'
+ logout.click()
+ then: 'the default logout success page is displayed'
+ at HomePage
+ when: 'Unauthenticated user accesses the Manage Page'
+ via ContactsPage
+ then: 'The login page is displayed'
+ at LoginPage
+ }
+}
\ No newline at end of file
diff --git a/samples/contacts-xml/src/integration-test/groovy/org/springframework/security/samples/pages/AddPage.groovy b/samples/contacts-xml/src/integration-test/groovy/org/springframework/security/samples/pages/AddPage.groovy
new file mode 100644
index 0000000000..50a3571135
--- /dev/null
+++ b/samples/contacts-xml/src/integration-test/groovy/org/springframework/security/samples/pages/AddPage.groovy
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2011 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.security.samples.pages
+
+import geb.Page
+
+/**
+ * The login page.
+ *
+ * @author Rob Winch
+ */
+class AddPage extends Page {
+ static url = 'add'
+ static at = { assert driver.title == 'Add New Contact'; true}
+ static content = {
+ addContact(required:false) { name = 'Rob Winch', email = 'rob@example.com'->
+ addForm.name = name
+ addForm.email = email
+ submit.click()
+ }
+ addForm { $('form') }
+ submit { $('input', type: 'submit') }
+ }
+}
\ No newline at end of file
diff --git a/samples/contacts-xml/src/integration-test/groovy/org/springframework/security/samples/pages/ContactsPage.groovy b/samples/contacts-xml/src/integration-test/groovy/org/springframework/security/samples/pages/ContactsPage.groovy
new file mode 100644
index 0000000000..768fee4879
--- /dev/null
+++ b/samples/contacts-xml/src/integration-test/groovy/org/springframework/security/samples/pages/ContactsPage.groovy
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2011 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.security.samples.pages
+
+import geb.*
+
+/**
+ * The home page
+ *
+ * @author Rob Winch
+ */
+class ContactsPage extends Page {
+ static url = 'secure/'
+ static at = { assert driver.title == 'Your Contacts'; true}
+ static content = {
+ addContact(to: AddPage) { $('a', text: 'Add') }
+ contacts { moduleList Contact, $("table tr").tail() }
+ logout { $("input[type=submit]", value: "Logoff") }
+ }
+}
+
+class Contact extends Module {
+ static content = {
+ cell { $("td", it) }
+ id { cell(0).text().toInteger() }
+ name { cell(1).text() }
+ email { cell(2).text() }
+ delete { cell(3).$('a').click() }
+ adminPermission { cell(4).$('a') }
+ }
+}
\ No newline at end of file
diff --git a/samples/contacts-xml/src/integration-test/groovy/org/springframework/security/samples/pages/DeleteConfirmPage.groovy b/samples/contacts-xml/src/integration-test/groovy/org/springframework/security/samples/pages/DeleteConfirmPage.groovy
new file mode 100644
index 0000000000..b064e79a1d
--- /dev/null
+++ b/samples/contacts-xml/src/integration-test/groovy/org/springframework/security/samples/pages/DeleteConfirmPage.groovy
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2011 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.security.samples.pages
+
+import geb.Page
+
+/**
+ * The home page
+ *
+ * @author Rob Winch
+ */
+class DeleteConfirmPage extends Page {
+ static at = { assert driver.title == 'Deletion completed'; true}
+ static content = {
+ manage(to: ContactsPage) { $('a', text: 'Manage') }
+ }
+}
\ No newline at end of file
diff --git a/samples/contacts-xml/src/integration-test/groovy/org/springframework/security/samples/pages/HomePage.groovy b/samples/contacts-xml/src/integration-test/groovy/org/springframework/security/samples/pages/HomePage.groovy
new file mode 100644
index 0000000000..42e3bae6d1
--- /dev/null
+++ b/samples/contacts-xml/src/integration-test/groovy/org/springframework/security/samples/pages/HomePage.groovy
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2011 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.security.samples.pages;
+
+import geb.*
+
+/**
+ * The home page
+ *
+ * @author Rob Winch
+ */
+class HomePage extends Page {
+ static url = ''
+ static at = { assert driver.title == 'Contacts Security Demo'; true}
+ static content = {
+ manage(to: [ContactsPage,LoginPage]) { $('a', text: 'Manage') }
+ debug { $('a', text: 'Debug').click() }
+ frames { $('a', text: 'Frames').click() }
+ }
+}
\ No newline at end of file
diff --git a/samples/contacts-xml/src/integration-test/groovy/org/springframework/security/samples/pages/LoginPage.groovy b/samples/contacts-xml/src/integration-test/groovy/org/springframework/security/samples/pages/LoginPage.groovy
new file mode 100644
index 0000000000..35d92ab305
--- /dev/null
+++ b/samples/contacts-xml/src/integration-test/groovy/org/springframework/security/samples/pages/LoginPage.groovy
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2011 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.security.samples.pages;
+
+import geb.*
+
+/**
+ * The login page.
+ *
+ * @author Rob Winch
+ */
+class LoginPage extends Page {
+ static url = 'login'
+ static at = { assert driver.title == 'Login'; true}
+ static content = {
+ login(required:false) { user='rod', password='koala' ->
+ loginForm.j_username = user
+ loginForm.j_password = password
+ submit.click()
+ }
+ loginForm { $('form') }
+ submit { $('input', type: 'submit') }
+ }
+}
\ No newline at end of file
diff --git a/samples/contacts-xml/src/main/webapp/WEB-INF/jsp/index.jsp b/samples/contacts-xml/src/main/webapp/WEB-INF/jsp/index.jsp
index 1945221044..bd4fdc4829 100644
--- a/samples/contacts-xml/src/main/webapp/WEB-INF/jsp/index.jsp
+++ b/samples/contacts-xml/src/main/webapp/WEB-INF/jsp/index.jsp
@@ -27,6 +27,11 @@
-