Author: tchemit Date: 2012-08-26 18:34:56 +0200 (Sun, 26 Aug 2012) New Revision: 3632 Url: http://chorem.org/repositories/revision/pollen/3632 Log: refs #606: Add some ITs to prevent regression : move old its as real it Added: trunk/pollen-ui-struts2/src/it/createPoll/ trunk/pollen-ui-struts2/src/it/createPoll/LICENSE.txt trunk/pollen-ui-struts2/src/it/createPoll/README.txt trunk/pollen-ui-struts2/src/it/createPoll/changelog.txt trunk/pollen-ui-struts2/src/it/createPoll/goals.txt trunk/pollen-ui-struts2/src/it/createPoll/pom.xml trunk/pollen-ui-struts2/src/it/createPoll/src/ trunk/pollen-ui-struts2/src/it/createPoll/src/jetty/ trunk/pollen-ui-struts2/src/it/createPoll/src/jetty/jetty-context.xml trunk/pollen-ui-struts2/src/it/createPoll/src/test/ trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/ trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/ trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/ trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/ trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/ trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/CreateFreeDatePollSIT.java trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/CreateFreeTextPollSIT.java trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/CreateRestrictedTextPollSIT.java trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/CreateTextPollForGroupSIT.java trunk/pollen-ui-struts2/src/it/createPoll/src/test/resources/ trunk/pollen-ui-struts2/src/it/createPoll/src/test/resources/data/ trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/ trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/ trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/AnonymousFreePollByAnonymousIT.java trunk/pollen-ui-struts2/src/it/security/ trunk/pollen-ui-struts2/src/it/security/LICENSE.txt trunk/pollen-ui-struts2/src/it/security/README.txt trunk/pollen-ui-struts2/src/it/security/changelog.txt trunk/pollen-ui-struts2/src/it/security/goals.txt trunk/pollen-ui-struts2/src/it/security/pom.xml trunk/pollen-ui-struts2/src/it/security/src/ trunk/pollen-ui-struts2/src/it/security/src/jetty/ trunk/pollen-ui-struts2/src/it/security/src/jetty/jetty-context.xml trunk/pollen-ui-struts2/src/it/security/src/test/ trunk/pollen-ui-struts2/src/it/security/src/test/java/ trunk/pollen-ui-struts2/src/it/security/src/test/java/org/ trunk/pollen-ui-struts2/src/it/security/src/test/java/org/chorem/ trunk/pollen-ui-struts2/src/it/security/src/test/java/org/chorem/pollen/ trunk/pollen-ui-struts2/src/it/security/src/test/java/org/chorem/pollen/ui/ trunk/pollen-ui-struts2/src/it/security/src/test/java/org/chorem/pollen/ui/it/ trunk/pollen-ui-struts2/src/it/security/src/test/java/org/chorem/pollen/ui/it/LoginSIT.java trunk/pollen-ui-struts2/src/it/security/src/test/java/org/chorem/pollen/ui/it/SecurityAccessSIT.java trunk/pollen-ui-struts2/src/it/security/src/test/resources/ trunk/pollen-ui-struts2/src/it/security/src/test/resources/data/ trunk/pollen-ui-struts2/src/it/security/src/test/resources/data/db/ trunk/pollen-ui-struts2/src/it/security/src/test/resources/data/db/pollendb.h2.db trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/it/AbstractPollenIT.java Removed: trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/poll/ trunk/pollen-ui-struts2/src/it/pollen-ui-it/src/ trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/PollenFixtures.java trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/PollenTestApplicationListener.java trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/it/AbstractPollenWebDriverIT.java trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/it/LoginT.java trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/its/ trunk/pollen-ui-struts2/src/test/resources/its/ trunk/pollen-ui-struts2/src/test/resources/log4j.properties trunk/pollen-ui-struts2/src/test/resources/pollen-test.properties trunk/pollen-ui-struts2/src/test/resources/pollendb.h2.db trunk/pollen-ui-struts2/src/test/resources/web-test.xml Modified: trunk/pollen-ui-struts2/pom.xml trunk/pollen-ui-struts2/src/it/pollVoteVisibility/ trunk/pollen-ui-struts2/src/it/pollVoteVisibility/goals.txt trunk/pollen-ui-struts2/src/it/pollVoteVisibility/pom.xml trunk/pollen-ui-struts2/src/it/pollen-ui-it/ trunk/pollen-ui-struts2/src/it/pollen-ui-it/pom.xml trunk/pollen-ui-struts2/src/main/resources/config/struts-poll.xml trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/it/AbstractPollIT.java trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/it/PollenUrlFixtures.java trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/it/WebDriverResources.java Modified: trunk/pollen-ui-struts2/pom.xml =================================================================== --- trunk/pollen-ui-struts2/pom.xml 2012-08-26 16:34:10 UTC (rev 3631) +++ trunk/pollen-ui-struts2/pom.xml 2012-08-26 16:34:56 UTC (rev 3632) @@ -207,6 +207,7 @@ <scope>runtime</scope> </dependency> + <!-- test dependencies --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> @@ -227,26 +228,32 @@ <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-chrome-driver</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-firefox-driver</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-htmlunit-driver</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-ie-driver</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-safari-driver</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-remote-driver</artifactId> + <scope>provided</scope> </dependency> </dependencies> @@ -323,7 +330,6 @@ </plugin> <plugin> - <artifactId>maven-jar-plugin</artifactId> <executions> <execution> @@ -593,6 +599,8 @@ <configuration> <pomIncludes> <pomInclude>pollVoteVisibility/pom.xml</pomInclude> + <pomInclude>createPoll/pom.xml</pomInclude> + <pomInclude>security/pom.xml</pomInclude> </pomIncludes> </configuration> </execution> Property changes on: trunk/pollen-ui-struts2/src/it/createPoll ___________________________________________________________________ Added: svn:ignore + target *.ipr *.iws *.iml .idea Property changes on: trunk/pollen-ui-struts2/src/it/createPoll/LICENSE.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/pollen-ui-struts2/src/it/createPoll/README.txt =================================================================== --- trunk/pollen-ui-struts2/src/it/createPoll/README.txt (rev 0) +++ trunk/pollen-ui-struts2/src/it/createPoll/README.txt 2012-08-26 16:34:56 UTC (rev 3632) @@ -0,0 +1,7 @@ +========== +CreatePoll +========== + +Pour tester la création d'un sondage. + +TODO expliquer les differents scénarios testés. \ No newline at end of file Property changes on: trunk/pollen-ui-struts2/src/it/createPoll/README.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Property changes on: trunk/pollen-ui-struts2/src/it/createPoll/changelog.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/pollen-ui-struts2/src/it/createPoll/goals.txt =================================================================== --- trunk/pollen-ui-struts2/src/it/createPoll/goals.txt (rev 0) +++ trunk/pollen-ui-struts2/src/it/createPoll/goals.txt 2012-08-26 16:34:56 UTC (rev 3632) @@ -0,0 +1 @@ +clean post-integration-test -DrunIts \ No newline at end of file Property changes on: trunk/pollen-ui-struts2/src/it/createPoll/goals.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/pollen-ui-struts2/src/it/createPoll/pom.xml =================================================================== --- trunk/pollen-ui-struts2/src/it/createPoll/pom.xml (rev 0) +++ trunk/pollen-ui-struts2/src/it/createPoll/pom.xml 2012-08-26 16:34:56 UTC (rev 3632) @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.chorem.pollen.it</groupId> + <artifactId>pollen-ui-it</artifactId> + <version>1.4.5-SNAPSHOT</version> + <relativePath>../pollen-ui-it/pom.xml</relativePath> + </parent> + + <artifactId>createPoll</artifactId> + <name>Pollen :: IT createPoll</name> + <description>createPoll</description> + +</project> + Property changes on: trunk/pollen-ui-struts2/src/it/createPoll/pom.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/pollen-ui-struts2/src/it/createPoll/src/jetty/jetty-context.xml =================================================================== --- trunk/pollen-ui-struts2/src/it/createPoll/src/jetty/jetty-context.xml (rev 0) +++ trunk/pollen-ui-struts2/src/it/createPoll/src/jetty/jetty-context.xml 2012-08-26 16:34:56 UTC (rev 3632) @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!-- + #%L + Pollen :: UI (struts2) + $Id$ + $HeadURL: http://svn.chorem.org/svn/pollen/trunk/pollen-ui-struts2/src/jetty/jetty-con... $ + %% + Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + #L% + --> + +<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://www.eclipse.org/jetty/configure.dtd"> + +<Configure class="org.eclipse.jetty.webapp.WebAppContext"> + <Call name="setAttribute"> + <Arg>org.eclipse.jetty.server.webapp.WebInfIncludeJarPattern</Arg> + <Arg>.*/.*jsp-api-[^/]\.jar$|./.*jsp-[^/]\.jar$|./.*taglibs[^/]*\.jar$</Arg> + </Call> +</Configure> \ No newline at end of file Property changes on: trunk/pollen-ui-struts2/src/it/createPoll/src/jetty/jetty-context.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Copied: trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/CreateFreeDatePollSIT.java (from rev 3629, trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/its/CreateFreeDatePollSIT.java) =================================================================== --- trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/CreateFreeDatePollSIT.java (rev 0) +++ trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/CreateFreeDatePollSIT.java 2012-08-26 16:34:56 UTC (rev 3632) @@ -0,0 +1,307 @@ +/* + * #%L + * Pollen :: UI (struts2) + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2012 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package org.chorem.pollen.ui.it; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +import java.util.List; + +/** + * Test the well work of a Free Date poll creation page. + * <p/> + * Tested cases : + * <ul> + * <li>Classic creation with filled mandatory fields (a title and at least 2 choices(OK)</li> + * <li>Classic creation with no title (KO)</li> + * <li>Classic creation with no choice (KO)</li> + * <li>Classic creation with two same choices (KO)</li> + * <li>Classic creation with invalid date format for one of the choices (KO)</li> + * </ul> + * + * @author ymartel <martel@codelutin.com> + * @since 1.4 + */ +public class CreateFreeDatePollSIT extends AbstractPollenIT { + + public CreateFreeDatePollSIT(Class<? extends WebDriver> driverType) { + super(driverType); + } + + /** + * This test create a simple free text poll. + * At the end, should be on summary page. + */ + @Test + public void createSimpleFreeDatePoll() { + + // Go on home page + gotoUrl(urlFixtures.createPoll()); + + // Set title + WebElement titleElement = findElement(By.name("poll.title")); + Assert.assertEquals("input", titleElement.getTagName()); + Assert.assertTrue(titleElement.isDisplayed()); + titleElement.sendKeys("My Date Poll"); + + // Switch to Date choices + List<WebElement> choiceTypesElement = findElements(By.name("poll.choiceType")); + Assert.assertEquals(3, choiceTypesElement.size()); + WebElement dateChoiceTypeElement = choiceTypesElement.get(1); + Assert.assertEquals("input", dateChoiceTypeElement.getTagName()); + Assert.assertEquals("DATE", dateChoiceTypeElement.getAttribute("value")); + Assert.assertTrue(dateChoiceTypeElement.isDisplayed()); + dateChoiceTypeElement.click(); + + // Set first choice + WebElement choiceOneElement = findElement(By.name("dateChoice_0.name")); + Assert.assertEquals("input", choiceOneElement.getTagName()); + Assert.assertTrue(choiceOneElement.isDisplayed()); + choiceOneElement.sendKeys(date(1431, 5, 30)); + + // Set second choice + WebElement choiceTwoElement = findElement(By.name("dateChoice_1.name")); + Assert.assertEquals("input", choiceTwoElement.getTagName()); + Assert.assertTrue(choiceTwoElement.isDisplayed()); + choiceTwoElement.sendKeys(date(1789, 8, 26)); + + // Submit form + WebElement submit = findElement(By.name("action:create")); + submit.click(); + + // All good, should be on summary page ! + checkCurrentUrl(urlFixtures.summaryPoll(), false); + } + + /** + * This test create a free date poll with two choices but no title. + * At the end, should be still on create page, with an error message. + */ + @Test + public void createSimpleFreeDatePollWithoutTitle() { + + // Go on home page + gotoUrl(urlFixtures.createPoll()); + + // Switch to Date choices + List<WebElement> choiceTypesElement = findElements(By.name("poll.choiceType")); + Assert.assertEquals(3, choiceTypesElement.size()); + WebElement dateChoiceTypeElement = choiceTypesElement.get(1); + Assert.assertEquals("input", dateChoiceTypeElement.getTagName()); + Assert.assertEquals("DATE", dateChoiceTypeElement.getAttribute("value")); + Assert.assertTrue(dateChoiceTypeElement.isDisplayed()); + dateChoiceTypeElement.click(); + + // Set first choice + WebElement choiceOneElement = findElement(By.name("dateChoice_0.name")); + Assert.assertEquals("input", choiceOneElement.getTagName()); + Assert.assertTrue(choiceOneElement.isDisplayed()); + String choiceOneValue = date(1431, 5, 30); + choiceOneElement.sendKeys(choiceOneValue); + + // Set second choice + WebElement choiceTwoElement = findElement(By.name("dateChoice_1.name")); + Assert.assertEquals("input", choiceTwoElement.getTagName()); + Assert.assertTrue(choiceTwoElement.isDisplayed()); + String choiceTwoValue = date(1789, 8, 26); + choiceTwoElement.sendKeys(choiceTwoValue); + + // Submit form + WebElement submit = findElement(By.name("action:create")); + submit.click(); + + // Title is missing, should stay on create poll page + checkCurrentUrl(urlFixtures.createPoll(), false); + + // Check an error message has been displayed + WebElement titleError = findElement(By.className("errorMessage")); + Assert.assertNotNull(titleError); + + // Check that choice fields are not lost + choiceOneElement = findElement(By.name("dateChoice_0.name")); + Assert.assertEquals("input", choiceOneElement.getTagName()); + Assert.assertTrue(choiceOneElement.isDisplayed()); + Assert.assertEquals(choiceOneValue, choiceOneElement.getAttribute("value")); + choiceTwoElement = findElement(By.name("dateChoice_1.name")); + Assert.assertEquals("input", choiceTwoElement.getTagName()); + Assert.assertTrue(choiceTwoElement.isDisplayed()); + Assert.assertEquals(choiceTwoValue, choiceTwoElement.getAttribute("value")); + + } + + /** + * This test create a free date poll without choices. + * At the end, should be still on create page, with an error message. + */ + @Test + public void createSimpleFreeDatePollWithoutChoice() { + + // Go on home page + gotoUrl(urlFixtures.createPoll()); + + // Set title + WebElement titleElement = findElement(By.name("poll.title")); + Assert.assertEquals("input", titleElement.getTagName()); + Assert.assertTrue(titleElement.isDisplayed()); + String pollTitle = "My Date Poll"; + titleElement.sendKeys(pollTitle); + + // Switch to Date choices + List<WebElement> choiceTypesElement = findElements(By.name("poll.choiceType")); + Assert.assertEquals(3, choiceTypesElement.size()); + WebElement dateChoiceTypeElement = choiceTypesElement.get(1); + Assert.assertEquals("input", dateChoiceTypeElement.getTagName()); + Assert.assertEquals("DATE", dateChoiceTypeElement.getAttribute("value")); + Assert.assertTrue(dateChoiceTypeElement.isDisplayed()); + dateChoiceTypeElement.click(); + + // Submit form + WebElement submit = findElement(By.name("action:create")); + submit.click(); + + // No choices, should stay on create poll page + checkCurrentUrl(urlFixtures.createPoll(), false); + + // Check that title field is not lost + titleElement = findElement(By.name("poll.title")); + Assert.assertEquals("input", titleElement.getTagName()); + Assert.assertTrue(titleElement.isDisplayed()); + Assert.assertEquals(pollTitle, titleElement.getAttribute("value")); + + // Check an error message has been displayed for choices + WebElement choicesError = findElement(By.id("poll_choices_error")); + Assert.assertNotNull(choicesError); + + // Check that we are still on Date choices + choiceTypesElement = findElements(By.name("poll.choiceType")); + Assert.assertEquals(3, choiceTypesElement.size()); + dateChoiceTypeElement = choiceTypesElement.get(1); + Assert.assertEquals("input", dateChoiceTypeElement.getTagName()); + Assert.assertEquals("DATE", dateChoiceTypeElement.getAttribute("value")); + Assert.assertEquals("true", dateChoiceTypeElement.getAttribute("checked")); + + } + + /** + * This test create a free date poll with a same value for two choices. + * At the end, should be still on create page, with an error message. + */ + @Test + public void createSimpleFreeDatePollWithTwoSameDate() { + + // Go on home page + gotoUrl(urlFixtures.createPoll()); + + // Set title + WebElement titleElement = findElement(By.name("poll.title")); + Assert.assertEquals("input", titleElement.getTagName()); + Assert.assertTrue(titleElement.isDisplayed()); + titleElement.sendKeys("My Date Poll"); + + // Switch to Date choices + List<WebElement> choiceTypesElement = findElements(By.name("poll.choiceType")); + Assert.assertEquals(3, choiceTypesElement.size()); + WebElement dateChoiceTypeElement = choiceTypesElement.get(1); + Assert.assertEquals("input", dateChoiceTypeElement.getTagName()); + Assert.assertEquals("DATE", dateChoiceTypeElement.getAttribute("value")); + Assert.assertTrue(dateChoiceTypeElement.isDisplayed()); + dateChoiceTypeElement.click(); + + // Set first choice + WebElement choiceOneElement = findElement(By.name("dateChoice_0.name")); + Assert.assertEquals("input", choiceOneElement.getTagName()); + Assert.assertTrue(choiceOneElement.isDisplayed()); + String date = date(1431, 5, 30); + choiceOneElement.sendKeys(date); + + // Set second choice + WebElement choiceTwoElement = findElement(By.name("dateChoice_1.name")); + Assert.assertEquals("input", choiceTwoElement.getTagName()); + Assert.assertTrue(choiceTwoElement.isDisplayed()); + choiceTwoElement.sendKeys(date); + + // Submit form + WebElement submit = findElement(By.name("action:create")); + submit.click(); + + // An error, should stay on create page + checkCurrentUrl(urlFixtures.createPoll(), false); + + // Check an error message has been displayed for choices + WebElement choicesError = findElement(By.className("errorMessage")); + Assert.assertNotNull(choicesError); + } + + /** + * This test create a free date poll with a bas format for one of the choices. + * At the end, should be still on create page, with an error message. + */ + @Test + public void createSimpleFreeDatePollWithBadFormatDate() { + + // Go on home page + gotoUrl(urlFixtures.createPoll()); + + // Set title + WebElement titleElement = findElement(By.name("poll.title")); + Assert.assertEquals("input", titleElement.getTagName()); + Assert.assertTrue(titleElement.isDisplayed()); + titleElement.sendKeys("My Date Poll"); + + // Switch to Date choices + List<WebElement> choiceTypesElement = findElements(By.name("poll.choiceType")); + Assert.assertEquals(3, choiceTypesElement.size()); + WebElement dateChoiceTypeElement = choiceTypesElement.get(1); + Assert.assertEquals("input", dateChoiceTypeElement.getTagName()); + Assert.assertEquals("DATE", dateChoiceTypeElement.getAttribute("value")); + Assert.assertTrue(dateChoiceTypeElement.isDisplayed()); + dateChoiceTypeElement.click(); + + // Set first choice + WebElement choiceOneElement = findElement(By.name("dateChoice_0.name")); + Assert.assertEquals("input", choiceOneElement.getTagName()); + Assert.assertTrue(choiceOneElement.isDisplayed()); + choiceOneElement.sendKeys(date(1431, 5, 30)); + + // Set second choice + WebElement choiceTwoElement = findElement(By.name("dateChoice_1.name")); + Assert.assertEquals("input", choiceTwoElement.getTagName()); + Assert.assertTrue(choiceTwoElement.isDisplayed()); + choiceTwoElement.sendKeys("28 08 1789"); + + // Submit form + WebElement submit = findElement(By.name("action:create")); + submit.click(); + + // An error, should stay on create page + checkCurrentUrl(urlFixtures.createPoll(), false); + + // Check an error message has been displayed for choices + WebElement choicesError = findElement(By.className("errorMessage")); + Assert.assertNotNull(choicesError); + } + +} Property changes on: trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/CreateFreeDatePollSIT.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/CreateFreeTextPollSIT.java (from rev 3629, trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/its/CreateFreeTextPollSIT.java) =================================================================== --- trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/CreateFreeTextPollSIT.java (rev 0) +++ trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/CreateFreeTextPollSIT.java 2012-08-26 16:34:56 UTC (rev 3632) @@ -0,0 +1,462 @@ +/* + * #%L + * Pollen :: UI (struts2) + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2012 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package org.chorem.pollen.ui.it; + +import org.apache.commons.lang3.time.DateUtils; +import org.junit.Assert; +import org.junit.Test; +import org.nuiton.util.DateUtil; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +import java.util.Date; + +/** + * Test the well work of a Free text poll creation page. + * <p/> + * Tested cases : + * <ul> + * <li>Classic creation with filled mandatory fields (OK)</li> + * <li>Classic creation with no title (KO)</li> + * <li>Classic creation with no choice (KO)</li> + * <li>Classic creation with two same choices (KO)</li> + * <li>Classic creation with ending date before starting date (KO)</li> + * <li>Classic creation with ending date before now (KO)</li> + * <li>Classic creation with invalid email (KO)</li> + * <li>Classic creation with an authorized number of choice per vote < 1 (KO)</li> + * <li>Classic creation with choice adding ending date before starting date (KO)</li> + * <li>Classic creation with choice adding starting date after poll ending date (KO)</li> + * <li>Classic creation with choice adding ending date after poll ending date (KO)</li> + * </ul> + * + * @author ymartel <martel@codelutin.com> + * @since 1.4 + */ +public class CreateFreeTextPollSIT extends AbstractPollenIT { + + public CreateFreeTextPollSIT(Class<? extends WebDriver> driverType) { + super(driverType); + } + + /** + * This test create a simple free text poll. + * At the end, should be on summary page. + */ + @Test + public void createSimpleFreeTextPoll() { + + // Go on home page + gotoUrl(urlFixtures.createPoll()); + + // Set title + WebElement titleElement = findElement(By.name("poll.title")); + Assert.assertEquals("input", titleElement.getTagName()); + Assert.assertTrue(titleElement.isDisplayed()); + titleElement.sendKeys("My Poll"); + + // Set first choice + WebElement choiceOneElement = findElement(By.name("textChoice_0.name")); + Assert.assertEquals("input", choiceOneElement.getTagName()); + Assert.assertTrue(choiceOneElement.isDisplayed()); + choiceOneElement.sendKeys("Choix numero un"); + + // Set second choice + WebElement choiceTwoElement = findElement(By.name("textChoice_1.name")); + Assert.assertEquals("input", choiceTwoElement.getTagName()); + Assert.assertTrue(choiceTwoElement.isDisplayed()); + choiceTwoElement.sendKeys("Choix numero deux"); + + // Submit form + WebElement submit = findElement(By.name("action:create")); + submit.click(); + + // All good, should be on summary page ! + checkCurrentUrl(urlFixtures.summaryPoll(), false); + } + + /** + * This test create a simple free text poll without a title. + * When submit, an error text should be displayed : title is mandatory + */ + @Test + public void createSimpleFreeTextPollWithoutTitle() { + + // Go on home page + gotoUrl(urlFixtures.createPoll()); + + // Set first choice + WebElement choiceOneElement = findElement(By.name("textChoice_0.name")); + Assert.assertEquals("input", choiceOneElement.getTagName()); + Assert.assertTrue(choiceOneElement.isDisplayed()); + String choiceOneValue = "Choix numero un"; + choiceOneElement.sendKeys(choiceOneValue); + + // Set second choice + WebElement choiceTwoElement = findElement(By.name("textChoice_1.name")); + Assert.assertEquals("input", choiceTwoElement.getTagName()); + Assert.assertTrue(choiceTwoElement.isDisplayed()); + String choiceTwoValue = "Choix numero deux"; + choiceTwoElement.sendKeys(choiceTwoValue); + + // Submit form + WebElement submit = findElement(By.name("action:create")); + submit.click(); + + // Title is missing, should stay on create poll page + checkCurrentUrl(urlFixtures.createPoll(), false); + + // Check an error message has been displayed + WebElement titleError = findElement(By.className("errorMessage")); + Assert.assertNotNull(titleError); + + // Check that choice fields are not lost + choiceOneElement = findElement(By.name("textChoice_0.name")); + Assert.assertEquals("input", choiceOneElement.getTagName()); + Assert.assertTrue(choiceOneElement.isDisplayed()); + Assert.assertEquals(choiceOneValue, choiceOneElement.getAttribute("value")); + choiceTwoElement = findElement(By.name("textChoice_1.name")); + Assert.assertEquals("input", choiceTwoElement.getTagName()); + Assert.assertTrue(choiceTwoElement.isDisplayed()); + Assert.assertEquals(choiceTwoValue, choiceTwoElement.getAttribute("value")); + + } + + /** + * This test create a simple free text poll with no choice. + * When submit, an error text should be displayed : at least one choice must be given + */ + @Test + public void createSimpleFreeTextPollWithoutChoice() { + + // Go on home page + gotoUrl(urlFixtures.createPoll()); + + // Set title + WebElement titleElement = findElement(By.name("poll.title")); + Assert.assertEquals("input", titleElement.getTagName()); + Assert.assertTrue(titleElement.isDisplayed()); + String pollTitle = "My Poll"; + titleElement.sendKeys(pollTitle); + + // Submit form + WebElement submit = findElement(By.name("action:create")); + submit.click(); + + // No choices, should stay on create poll page + checkCurrentUrl(urlFixtures.createPoll(), false); + + // Check that title field is not lost + titleElement = findElement(By.name("poll.title")); + Assert.assertEquals("input", titleElement.getTagName()); + Assert.assertTrue(titleElement.isDisplayed()); + Assert.assertEquals(pollTitle, titleElement.getAttribute("value")); + + // Check an error message has been displayed for choices + WebElement choicesError = findElement(By.id("poll_choices_error")); + Assert.assertNotNull(choicesError); + } + + /** + * This test create a free text poll with a ending date in the past. + * When submit, an error text should be displayed : the poll cannot end before starting ! + */ + @Test + public void createFreeTextPollWithAnteriorEndingDateThanToday() { + + // Go on create poll page + gotoUrl(urlFixtures.createPoll()); + + // Set title + WebElement titleElement = findElement(By.name("poll.title")); + Assert.assertEquals("input", titleElement.getTagName()); + Assert.assertTrue(titleElement.isDisplayed()); + String pollTitle = "My Poll"; + titleElement.sendKeys(pollTitle); + + // Set first choice + WebElement choiceOneElement = findElement(By.name("textChoice_0.name")); + Assert.assertEquals("input", choiceOneElement.getTagName()); + Assert.assertTrue(choiceOneElement.isDisplayed()); + String choiceOne = "Choix numero un"; + choiceOneElement.sendKeys(choiceOne); + + // Go to option panel : click on it + WebElement optionsClick = findElement(By.xpath("//a[@href=\"#toptions\"]")); + optionsClick.click(); + + // Set end date + WebElement endDateElement = findElement(By.name("poll.endDate")); + Assert.assertEquals("input", endDateElement.getTagName()); + Assert.assertTrue(endDateElement.isDisplayed()); + //FIXME ymartel 2012/06/14 : review way to get DAte ? + Date aMonthAgo = DateUtils.addMonths(new Date(), -1); + String formatMonthAgo = DateUtil.formatDate(aMonthAgo, "dd/MM/yyyy HH:mm"); + endDateElement.sendKeys(formatMonthAgo); + + // Submit form + WebElement submit = findElement(By.name("action:create")); + submit.click(); + + // No choices, should stay on create poll page + checkCurrentUrl(urlFixtures.createPoll(), false); + + // Check an error message has been displayed + WebElement dateError = findElement(By.className("errorMessage")); + Assert.assertNotNull(dateError); + + // Check that title is not displayed cause not in the tab in error + titleElement = findElement(By.name("poll.title")); + Assert.assertFalse(titleElement.isDisplayed()); + + // Go on general tab and check that Title and and choice fields values are not lost + WebElement generalClick = findElement(By.xpath("//a[@href=\"#tgeneral\"]")); + generalClick.click(); + + titleElement = findElement(By.name("poll.title")); + Assert.assertTrue(titleElement.isDisplayed()); + Assert.assertEquals(pollTitle, titleElement.getAttribute("value")); + + choiceOneElement = findElement(By.name("textChoice_0.name")); + Assert.assertTrue(choiceOneElement.isDisplayed()); + Assert.assertEquals(choiceOne, choiceOneElement.getAttribute("value")); + } + + /** + * This test create a free text poll with a ending date before the starting date. + * When submit, an error text should be displayed : the poll cannot end before starting ! + */ + @Test + public void createFreeTextPollWithAnteriorEndDateThanStartDate() { + + // Go on create poll page + gotoUrl(urlFixtures.createPoll()); + + // Set title + WebElement titleElement = findElement(By.name("poll.title")); + Assert.assertEquals("input", titleElement.getTagName()); + Assert.assertTrue(titleElement.isDisplayed()); + String pollTitle = "My Poll"; + titleElement.sendKeys(pollTitle); + + // Set first choice + WebElement choiceOneElement = findElement(By.name("textChoice_0.name")); + Assert.assertEquals("input", choiceOneElement.getTagName()); + Assert.assertTrue(choiceOneElement.isDisplayed()); + String choiceOne = "Choix numero un"; + choiceOneElement.sendKeys(choiceOne); + + // Go to option panel : click on it + WebElement optionsClick = findElement(By.xpath("//a[@href=\"#toptions\"]")); + optionsClick.click(); + + // Set start date to two month ago + WebElement startDateElement = findElement(By.name("poll.endDate")); + Assert.assertEquals("input", startDateElement.getTagName()); + Assert.assertTrue(startDateElement.isDisplayed()); + //FIXME ymartel 2012/06/14 : review way to get Date ? + Date twoMonthsAgo = DateUtils.addMonths(new Date(), -2); + String formatTwoMonthsAgo = DateUtil.formatDate(twoMonthsAgo, "dd/MM/yyyy HH:mm"); + startDateElement.sendKeys(formatTwoMonthsAgo); + + // Set end date to one months ago + WebElement endDateElement = findElement(By.name("poll.endDate")); + Assert.assertEquals("input", endDateElement.getTagName()); + Assert.assertTrue(endDateElement.isDisplayed()); + //FIXME ymartel 2012/06/14 : review way to get DAte ? + Date oneMonthAgo = DateUtils.addMonths(new Date(), -1); + String formatOneMonthAgo = DateUtil.formatDate(oneMonthAgo, "dd/MM/yyyy HH:mm"); + endDateElement.sendKeys(formatOneMonthAgo); + + // Submit form + WebElement submit = findElement(By.name("action:create")); + submit.click(); + + // No choices, should stay on create poll page + checkCurrentUrl(urlFixtures.createPoll(), false); + + // Check an error message has been displayed + WebElement dateError = findElement(By.className("errorMessage")); + Assert.assertNotNull(dateError); + + // Go on general tab and check that Title and and choice fields values are not lost + WebElement generalClick = findElement(By.xpath("//a[@href=\"#tgeneral\"]")); + generalClick.click(); + + titleElement = findElement(By.name("poll.title")); + Assert.assertTrue(titleElement.isDisplayed()); + Assert.assertEquals(pollTitle, titleElement.getAttribute("value")); + + choiceOneElement = findElement(By.name("textChoice_0.name")); + Assert.assertTrue(choiceOneElement.isDisplayed()); + Assert.assertEquals(choiceOne, choiceOneElement.getAttribute("value")); + } + + /** + * This test create a free text poll with an invalid email. + * When submit, an error text should be displayed : email should be valid + */ + @Test + public void createFreeTextPollWithInvalidEmail() { + + // Go on create poll page + gotoUrl(urlFixtures.createPoll()); + + // Set title + WebElement titleElement = findElement(By.name("poll.title")); + Assert.assertEquals("input", titleElement.getTagName()); + Assert.assertTrue(titleElement.isDisplayed()); + String pollTitle = "My Poll"; + titleElement.sendKeys(pollTitle); + + // Set first choice + WebElement choiceOneElement = findElement(By.name("textChoice_0.name")); + Assert.assertEquals("input", choiceOneElement.getTagName()); + Assert.assertTrue(choiceOneElement.isDisplayed()); + String choiceOne = "Choix numero un"; + choiceOneElement.sendKeys(choiceOne); + + // Go to option panel : click on it + WebElement optionsClick = findElement(By.xpath("//a[@href=\"#toptions\"]")); + optionsClick.click(); + + WebElement emailElement = findElement(By.name("poll.creator.email")); + Assert.assertEquals("input", emailElement.getTagName()); + Assert.assertTrue(emailElement.isDisplayed()); + emailElement.sendKeys("i@minvalid"); + + // Submit form + WebElement submit = findElement(By.name("action:create")); + submit.click(); + + // No choices, should stay on create poll page + checkCurrentUrl(urlFixtures.createPoll(), false); + + // Check an error message has been displayed + WebElement dateError = findElement(By.className("errorMessage")); + Assert.assertNotNull(dateError); + + // Go on general tab and check that Title and and choice fields values are not lost + WebElement generalClick = findElement(By.xpath("//a[@href=\"#tgeneral\"]")); + generalClick.click(); + + titleElement = findElement(By.name("poll.title")); + Assert.assertTrue(titleElement.isDisplayed()); + Assert.assertEquals(pollTitle, titleElement.getAttribute("value")); + + choiceOneElement = findElement(By.name("textChoice_0.name")); + Assert.assertTrue(choiceOneElement.isDisplayed()); + Assert.assertEquals(choiceOne, choiceOneElement.getAttribute("value")); + } + + /** + * This test create a free text poll with an invalid email. + * When submit, an error text should be displayed : email should be valid + */ + @Test + public void createFreeTextPollWithInvalidMaxVotedChoices() { + + // Go on create poll page + gotoUrl(urlFixtures.createPoll()); + + // Set title + WebElement titleElement = findElement(By.name("poll.title")); + Assert.assertEquals("input", titleElement.getTagName()); + Assert.assertTrue(titleElement.isDisplayed()); + String pollTitle = "My Poll"; + titleElement.sendKeys(pollTitle); + + // Set first choice + WebElement choiceOneElement = findElement(By.name("textChoice_0.name")); + Assert.assertEquals("input", choiceOneElement.getTagName()); + Assert.assertTrue(choiceOneElement.isDisplayed()); + String choiceOne = "Choix numero un"; + choiceOneElement.sendKeys(choiceOne); + + // Go to option panel : click on it + WebElement optionsClick = findElement(By.xpath("//a[@href=\"#toptions\"]")); + optionsClick.click(); + + // Get the maxChoice element : should be disable while limitChoice is not selected + WebElement maxChoiceElement = findElement(By.name("maxChoices")); + Assert.assertEquals("input", maxChoiceElement.getTagName()); + Assert.assertTrue(maxChoiceElement.isDisplayed()); + // Get the checkbox and check it to set number of max choice after + WebElement limitChoiceElement = findElement(By.name("limitChoice")); + Assert.assertEquals("input", limitChoiceElement.getTagName()); + Assert.assertTrue(limitChoiceElement.isEnabled()); + limitChoiceElement.click(); + // Set a negative number of max choice + maxChoiceElement = findElement(By.name("maxChoices")); + Assert.assertTrue(maxChoiceElement.isEnabled()); + maxChoiceElement.clear(); + maxChoiceElement.sendKeys("-1"); + + // Submit form + WebElement submit = findElement(By.name("action:create")); + submit.click(); + + // No choices, should stay on create poll page + checkCurrentUrl(urlFixtures.createPoll(), false); + + // Check an error message has been displayed + WebElement maxChoicesError = findElement(By.className("errorMessage")); + Assert.assertNotNull(maxChoicesError); + + // Go on general tab and check that Title and and choice fields values are not lost + WebElement generalClick = findElement(By.xpath("//a[@href=\"#tgeneral\"]")); + generalClick.click(); + + titleElement = findElement(By.name("poll.title")); + Assert.assertTrue(titleElement.isDisplayed()); + Assert.assertEquals(pollTitle, titleElement.getAttribute("value")); + + choiceOneElement = findElement(By.name("textChoice_0.name")); + Assert.assertTrue(choiceOneElement.isDisplayed()); + Assert.assertEquals(choiceOne, choiceOneElement.getAttribute("value")); + + // Second part: try to set "0" for max choice + + // Go back to option panel : click on it + optionsClick = findElement(By.xpath("//a[@href=\"#toptions\"]")); + optionsClick.click(); + + // Set a negative number of max choice + maxChoiceElement = findElement(By.name("maxChoices")); + Assert.assertEquals("input", maxChoiceElement.getTagName()); + Assert.assertTrue(maxChoiceElement.isEnabled()); + maxChoiceElement.clear(); + maxChoiceElement.sendKeys("0"); + + // Submit form + submit = findElement(By.name("action:create")); + submit.click(); + + // No choices, should stay on create poll page + checkCurrentUrl(urlFixtures.createPoll(), false); + // Check an error message has been displayed + maxChoicesError = findElement(By.className("errorMessage")); + Assert.assertNotNull(maxChoicesError); + } + +} Property changes on: trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/CreateFreeTextPollSIT.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/CreateRestrictedTextPollSIT.java (from rev 3629, trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/its/CreateRestrictedTextPollSIT.java) =================================================================== --- trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/CreateRestrictedTextPollSIT.java (rev 0) +++ trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/CreateRestrictedTextPollSIT.java 2012-08-26 16:34:56 UTC (rev 3632) @@ -0,0 +1,308 @@ +/* + * #%L + * Pollen :: UI (struts2) + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2012 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package org.chorem.pollen.ui.it; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +import java.util.List; + +/** + * Test the well work of a text poll creation page with a restricted list of participant. + * <p/> + * Tested cases : + * <ul> + * <li>Creation without participant (KO)</li> + * <li>Creation with two participants with same name (KO)</li> + * <li>Creation with two participants with same email (KO)</li> + * <li>Creation with a participant without email (KO)</li> + * <li>Creation with a participant with only an email (no name) (KO)</li> + * </ul> + * + * @author ymartel <martel@codelutin.com> + * @since 1.4 + */ +public class CreateRestrictedTextPollSIT extends AbstractPollenIT { + + public CreateRestrictedTextPollSIT(Class<? extends WebDriver> driverType) { + super(driverType); + } + + /** + * This test create a text poll with restriction on participant but no participant. + * At the end, should stay on create poll page, cause at least one participant is needed. + */ + @Test + public void createRestrictedTextPollWithoutParticipant() { + + // Prepare the poll + preparePoll(); + + // Go to option panel : click on it + WebElement optionsClick = findElement(By.xpath("//a[@href=\"#toptions\"]")); + optionsClick.click(); + + // Switch to restricted type + List<WebElement> pollTypesElement = findElements(By.name("poll.pollType")); + Assert.assertEquals(3, pollTypesElement.size()); + WebElement restrictedTypeElement = pollTypesElement.get(1); + Assert.assertEquals("input", restrictedTypeElement.getTagName()); + Assert.assertEquals("RESTRICTED", restrictedTypeElement.getAttribute("value")); + Assert.assertTrue(restrictedTypeElement.isDisplayed()); + restrictedTypeElement.click(); + + // Check that the participant form is displayed + WebElement participantOneNameElement = findElement(By.id("votingListRESTRICTED_0PersonToList_0.votingId")); + Assert.assertEquals("input", participantOneNameElement.getTagName()); + Assert.assertTrue(participantOneNameElement.isDisplayed()); + + // Submit form + WebElement submit = findElement(By.name("action:create")); + submit.click(); + + // All good, should be on summary page ! + checkCurrentUrl(urlFixtures.createPoll(), false); + // Check an error message has been displayed + WebElement errorMessage = findElement(By.className("errorMessage")); + Assert.assertNotNull(errorMessage); + // Check we are in good table + participantOneNameElement = findElement(By.id("votingListRESTRICTED_0PersonToList_0.votingId")); + Assert.assertEquals("input", participantOneNameElement.getTagName()); + Assert.assertTrue(participantOneNameElement.isDisplayed()); + } + + /** + * This test create a restricted text poll, with two participant with same name. + * At the end, should stay on create poll page, cause the name should be unique. + */ + @Test + public void createRestrictedTextPollWithParticipantsWithSameName() { + + // Prepare the poll + preparePoll(); + + // Go to option panel : click on it + WebElement optionsClick = findElement(By.xpath("//a[@href=\"#toptions\"]")); + optionsClick.click(); + + // Switch to restricted type + List<WebElement> pollTypesElement = findElements(By.name("poll.pollType")); + Assert.assertEquals(3, pollTypesElement.size()); + WebElement restrictedTypeElement = pollTypesElement.get(1); + Assert.assertEquals("input", restrictedTypeElement.getTagName()); + Assert.assertEquals("RESTRICTED", restrictedTypeElement.getAttribute("value")); + Assert.assertTrue(restrictedTypeElement.isDisplayed()); + restrictedTypeElement.click(); + + // Set first participant + // send name + String participantOneName = "toto"; + sendKeysById("votingListRESTRICTED_0PersonToList_0.votingId", participantOneName); + // send email + String participantOneEmail = "toto@codelutin.com"; + sendKeysById("votingListRESTRICTED_0PersonToList_0.email", participantOneEmail); + // Set second participant + // send name + sendKeysById("votingListRESTRICTED_0PersonToList_1.votingId", participantOneName); + // send email + String participantTwoEmail = "toto2@codelutin.com"; + sendKeysById("votingListRESTRICTED_0PersonToList_1.email", participantTwoEmail); + + // Submit form + WebElement submit = findElement(By.name("action:create")); + submit.click(); + + // All good, should be on summary page ! + checkCurrentUrl(urlFixtures.createPoll(), false); + // Check an error message has been displayed + WebElement errorMessage = findElement(By.className("errorMessage")); + Assert.assertNotNull(errorMessage); + // Check we are in good table + checkWebElementValue(By.id("votingListRESTRICTED_0PersonToList_0.votingId"), participantOneName); + checkWebElementValue(By.id("votingListRESTRICTED_0PersonToList_0.email"), participantOneEmail); + checkWebElementValue(By.id("votingListRESTRICTED_0PersonToList_1.votingId"), participantOneName); + checkWebElementValue(By.id("votingListRESTRICTED_0PersonToList_1.email"), participantTwoEmail); + } + + /** + * This test create a restricted text poll, with two participant with same email. + * At the end, should stay on create poll page, cause the email should be unique. + */ + @Test + public void createRestrictedTextPollWithParticipantsWithSameEmail() { + + // Prepare the poll + preparePoll(); + + // Go to option panel : click on it + WebElement optionsClick = findElement(By.xpath("//a[@href=\"#toptions\"]")); + optionsClick.click(); + + // Switch to restricted type + List<WebElement> pollTypesElement = findElements(By.name("poll.pollType")); + Assert.assertEquals(3, pollTypesElement.size()); + WebElement restrictedTypeElement = pollTypesElement.get(1); + Assert.assertEquals("input", restrictedTypeElement.getTagName()); + Assert.assertEquals("RESTRICTED", restrictedTypeElement.getAttribute("value")); + Assert.assertTrue(restrictedTypeElement.isDisplayed()); + restrictedTypeElement.click(); + + // Set first participant + // send name + String participantOneName = "toto"; + sendKeysById("votingListRESTRICTED_0PersonToList_0.votingId", participantOneName); + // send email + String participantOneEmail = "toto@codelutin.com"; + sendKeysById("votingListRESTRICTED_0PersonToList_0.email", participantOneEmail); + // Set second participant + // send name + String participantTwoName = "toto2"; + sendKeysById("votingListRESTRICTED_0PersonToList_1.votingId", participantTwoName); + // send email + sendKeysById("votingListRESTRICTED_0PersonToList_1.email", participantOneEmail); + + // Submit form + WebElement submit = findElement(By.name("action:create")); + submit.click(); + + // All good, should be on summary page ! + checkCurrentUrl(urlFixtures.createPoll(), false); + // Check an error message has been displayed + WebElement errorMessage = findElement(By.className("errorMessage")); + Assert.assertNotNull(errorMessage); + // Check we are in good table + checkWebElementValue(By.id("votingListRESTRICTED_0PersonToList_0.votingId"), participantOneName); + checkWebElementValue(By.id("votingListRESTRICTED_0PersonToList_0.email"), participantOneEmail); + checkWebElementValue(By.id("votingListRESTRICTED_0PersonToList_1.votingId"), participantTwoName); + checkWebElementValue(By.id("votingListRESTRICTED_0PersonToList_1.email"), participantOneEmail); + } + + /** + * This test create a restricted text poll, with one participant without email. + * At the end, should stay on create poll page, cause the mail is mandatory. + */ + @Test + public void createRestrictedTextPollWithParticipantWithoutMail() { + + // Prepare the poll + preparePoll(); + + // Go to option panel : click on it + WebElement optionsClick = findElement(By.xpath("//a[@href=\"#toptions\"]")); + optionsClick.click(); + + // Switch to restricted type + List<WebElement> pollTypesElement = findElements(By.name("poll.pollType")); + Assert.assertEquals(3, pollTypesElement.size()); + WebElement restrictedTypeElement = pollTypesElement.get(1); + Assert.assertEquals("input", restrictedTypeElement.getTagName()); + Assert.assertEquals("RESTRICTED", restrictedTypeElement.getAttribute("value")); + Assert.assertTrue(restrictedTypeElement.isDisplayed()); + restrictedTypeElement.click(); + + // Set first participant + // send name + String participantOneName = "toto"; + sendKeysById("votingListRESTRICTED_0PersonToList_0.votingId", participantOneName); + // send email + String participantOneEmail = " "; + sendKeysById("votingListRESTRICTED_0PersonToList_0.email", participantOneEmail); + + // Submit form + WebElement submit = findElement(By.name("action:create")); + submit.click(); + + // All good, should be on summary page ! + checkCurrentUrl(urlFixtures.createPoll(), false); + // Check an error message has been displayed + WebElement errorMessage = findElement(By.className("errorMessage")); + Assert.assertNotNull(errorMessage); + // Check we are in good table + checkWebElementValue(By.id("votingListRESTRICTED_0PersonToList_0.votingId"), participantOneName); + checkWebElementValue(By.id("votingListRESTRICTED_0PersonToList_0.email"), participantOneEmail); + } + + /** + * This test create a restricted text poll, with one participant without email. + * At the end, should stay on create poll page, cause the mail is mandatory. + */ + @Test + public void createRestrictedTextPollWithParticipantWithoutName() { + + // Prepare the poll + preparePoll(); + + // Go to option panel : click on it + WebElement optionsClick = findElement(By.xpath("//a[@href=\"#toptions\"]")); + optionsClick.click(); + + // Switch to restricted type + List<WebElement> pollTypesElement = findElements(By.name("poll.pollType")); + Assert.assertEquals(3, pollTypesElement.size()); + WebElement restrictedTypeElement = pollTypesElement.get(1); + Assert.assertEquals("input", restrictedTypeElement.getTagName()); + Assert.assertEquals("RESTRICTED", restrictedTypeElement.getAttribute("value")); + Assert.assertTrue(restrictedTypeElement.isDisplayed()); + restrictedTypeElement.click(); + + // Set first participant + // send name + String participantOneName = ""; + sendKeysById("votingListRESTRICTED_0PersonToList_0.votingId", participantOneName); + // send email + String participantOneEmail = "toto@codelutin.com"; + sendKeysById("votingListRESTRICTED_0PersonToList_0.email", participantOneEmail); + + // Submit form + WebElement submit = findElement(By.name("action:create")); + submit.click(); + + // All good, should be on summary page ! + checkCurrentUrl(urlFixtures.createPoll(), false); + // Check an error message has been displayed + WebElement errorMessage = findElement(By.className("errorMessage")); + Assert.assertNotNull(errorMessage); + // Check we are in good table + checkWebElementValue(By.id("votingListRESTRICTED_0PersonToList_0.votingId"), participantOneName); + checkWebElementValue(By.id("votingListRESTRICTED_0PersonToList_0.email"), participantOneEmail); + } + + /** Prepare the poll with general data : one title and two choices */ + void preparePoll() { + // Go on home page + gotoUrl(urlFixtures.createPoll()); + + // Set title + sendKeysByName("poll.title", "My Poll"); + + // Set first choice + sendKeysByName("textChoice_0.name", "Choix numero un"); + + // Set second choice + sendKeysByName("textChoice_1.name", "Choix numero deux"); + } + +} Property changes on: trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/CreateRestrictedTextPollSIT.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/CreateTextPollForGroupSIT.java (from rev 3629, trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/its/CreateTextPollForGroupSIT.java) =================================================================== --- trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/CreateTextPollForGroupSIT.java (rev 0) +++ trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/CreateTextPollForGroupSIT.java 2012-08-26 16:34:56 UTC (rev 3632) @@ -0,0 +1,484 @@ +/* + * #%L + * Pollen :: UI (struts2) + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2012 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package org.chorem.pollen.ui.it; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +import java.util.List; + +/** + * Test the well work of a text poll creation page with the use of groups. + * <p/> + * Tested cases : + * <ul> + * <li>Creation with a nonamed group (KO)</li> + * <li>Creation with two group with same name (KO)</li> + * <li>Creation with a participant without email (KO)</li> + * <li>Creation with a participant with only an email (no name) (KO)</li> + * <li>Creation with two participants with same name in same group (KO)</li> + * <li>Creation with two participants with same email (KO)</li> + * <li>Creation with two participants with same name in different group (KO)</li> + * <li>Creation with two participants with same email in different group (KO)</li> + * </ul> + * + * @author ymartel <martel@codelutin.com> + * @since 1.4 + */ +public class CreateTextPollForGroupSIT extends AbstractPollenIT { + + public CreateTextPollForGroupSIT(Class<? extends WebDriver> driverType) { + super(driverType); + } + + /** + * This test create a text poll with group of participant but with no name on group. + * At the end, should stay on create page cause the group name is mandatory + */ + @Test + public void createTextPollWithNoNamedGroup() { + + // Prepare the poll + preparePoll(); + + // Go to option panel and display group form + goToGroupForm(); + + // Check that the group form is displayed + WebElement groupNameElement = findElement(By.id("votingListGROUP_0.name")); + Assert.assertEquals("input", groupNameElement.getTagName()); + Assert.assertTrue(groupNameElement.isDisplayed()); + + // Set a participant in the group + // send name + String participantOneName = "toto"; + sendKeysById("votingListGROUP_0PersonToList_0.votingId", participantOneName); + // send email + String participantOneEmail = "toto@codelutin.com"; + sendKeysById("votingListGROUP_0PersonToList_0.email", participantOneEmail); + + // Submit form + WebElement submit = findElement(By.name("action:create")); + submit.click(); + + // All good, should be on summary page ! + checkCurrentUrl(urlFixtures.createPoll(), false); + // Check an error message has been displayed + WebElement errorMessage = findElement(By.className("errorMessage")); + Assert.assertNotNull(errorMessage); + // Check we are in good table, and group form is still displayed + groupNameElement = findElement(By.id("votingListGROUP_0.name")); + Assert.assertEquals("input", groupNameElement.getTagName()); + Assert.assertTrue(groupNameElement.isDisplayed()); + // check the participant is still here + checkWebElementValue(By.id("votingListGROUP_0PersonToList_0.votingId"), participantOneName); + checkWebElementValue(By.id("votingListGROUP_0PersonToList_0.email"), participantOneEmail); + } + + /** + * This test create a group text poll, with two groups with same name. + * At the end, should stay on create poll page, cause the group name should be unique. + * The group names and participants should not be lost. + */ + @Test + public void createGroupTextPollWithGroupsWithSameName() { + + // Prepare the poll + preparePoll(); + + // Go to option panel and display group form + goToGroupForm(); + + // Set First group name + String groupOneName = "my group"; + sendKeysById("votingListGROUP_0.name", groupOneName); + // Set first participant in Group 1 + // send name + String participantOneName = "toto"; + sendKeysById("votingListGROUP_0PersonToList_0.votingId", participantOneName); + // send email + String participantOneEmail = "toto@codelutin.com"; + sendKeysById("votingListGROUP_0PersonToList_0.email", participantOneEmail); + + // Add a group + WebElement addGroupElement = findElement(By.name("pollen.action.addVotingList")); + Assert.assertEquals("input", addGroupElement.getTagName()); + Assert.assertTrue(addGroupElement.isDisplayed()); + addGroupElement.click(); + + // Set name of the second group: same as first one + sendKeysById("votingListGROUP_1.name", groupOneName); + // Set second participant in second group + // send name + String participantTwoName = "toto2"; + sendKeysById("votingListGROUP_1PersonToList_0.votingId", participantTwoName); + // send email + String participantTwoEmail = "toto2@codelutin.com"; + sendKeysById("votingListGROUP_1PersonToList_0.email", participantTwoEmail); + + // Submit form + WebElement submit = findElement(By.name("action:create")); + submit.click(); + + // All good, should be on summary page ! + checkCurrentUrl(urlFixtures.createPoll(), false); + // Check an error message has been displayed + WebElement errorMessage = findElement(By.className("errorMessage")); + Assert.assertNotNull(errorMessage); + // Check we are in good table + checkWebElementValue(By.id("votingListGROUP_0.name"), groupOneName); + checkWebElementValue(By.id("votingListGROUP_0PersonToList_0.votingId"), participantOneName); + checkWebElementValue(By.id("votingListGROUP_0PersonToList_0.email"), participantOneEmail); + checkWebElementValue(By.id("votingListGROUP_1.name"), groupOneName); + checkWebElementValue(By.id("votingListGROUP_1PersonToList_0.votingId"), participantTwoName); + checkWebElementValue(By.id("votingListGROUP_1PersonToList_0.email"), participantTwoEmail); + } + + /** + * This test create a group text poll, with one participant without email. + * At the end, should stay on create poll page, cause the mail is mandatory. + */ + @Test + public void createGroupTextPollWithParticipantWithoutMail() { + + // Prepare the poll + preparePoll(); + + // Go to option panel and display group form + goToGroupForm(); + + // Set group name + String groupName = "my group"; + sendKeysById("votingListGROUP_0.name", groupName); + + // Set first participant + // send name + String participantName = "toto"; + sendKeysById("votingListGROUP_0PersonToList_0.votingId", participantName); + // send an empty email + sendKeysById("votingListGROUP_0PersonToList_0.email", ""); + + // Submit form + WebElement submit = findElement(By.name("action:create")); + submit.click(); + + // All good, should be on summary page ! + checkCurrentUrl(urlFixtures.createPoll(), false); + // Check an error message has been displayed + WebElement errorMessage = findElement(By.className("errorMessage")); + Assert.assertNotNull(errorMessage); + // Check we are in good table + checkWebElementValue(By.id("votingListGROUP_0.name"), groupName); // group name still here + checkWebElementValue(By.id("votingListGROUP_0PersonToList_0.votingId"), participantName); // participant name still here + checkWebElementValue(By.id("votingListGROUP_0PersonToList_0.email"), ""); // still no email + } + + /** + * This test create a group text poll, with one participant without name. + * At the end, should stay on create poll page, cause the mail is mandatory. + */ + @Test + public void createGroupTextPollWithParticipantWithoutName() { + + // Prepare the poll + preparePoll(); + // Go to option panel and display group form + goToGroupForm(); + + + // Set group name + String groupName = "my group"; + sendKeysById("votingListGROUP_0.name", groupName); + + // Set a participant + // send name + sendKeysById("votingListGROUP_0PersonToList_0.votingId", ""); + // send an empty email + String participantEmail = "toto@codelutin.com"; + sendKeysById("votingListGROUP_0PersonToList_0.email", participantEmail); + + // Submit form + WebElement submit = findElement(By.name("action:create")); + submit.click(); + + // All good, should be on summary page ! + checkCurrentUrl(urlFixtures.createPoll(), false); + // Check an error message has been displayed + WebElement errorMessage = findElement(By.className("errorMessage")); + Assert.assertNotNull(errorMessage); + // Check we are in good table + checkWebElementValue(By.id("votingListGROUP_0.name"), groupName); // group name still here + checkWebElementValue(By.id("votingListGROUP_0PersonToList_0.votingId"), ""); // participant name still empty + checkWebElementValue(By.id("votingListGROUP_0PersonToList_0.email"), participantEmail); // still the mail + } + + /** + * This test create a group text poll, with two participants with same email in same group. + * At the end, should stay on create poll page, cause the email should be unique. + */ + @Test + public void createTextPollWithSameGroupParticipantsWithSameEmail() { + + // Prepare the poll + preparePoll(); + + // Go to option panel and display group form + goToGroupForm(); + + // Set group name + String groupName = "my group"; + sendKeysById("votingListGROUP_0.name", groupName); + // Set first participant in Group + // send name + String participantOneName = "toto"; + sendKeysById("votingListGROUP_0PersonToList_0.votingId", participantOneName); + // send email + String participantEmail = "toto@codelutin.com"; + sendKeysById("votingListGROUP_0PersonToList_0.email", participantEmail); + + // Set second participant in Group with same email + // send name + String participantTwoName = "toto2"; + sendKeysById("votingListGROUP_0PersonToList_1.votingId", participantTwoName); + // send email + sendKeysById("votingListGROUP_0PersonToList_1.email", participantEmail); + + // Submit form + WebElement submit = findElement(By.name("action:create")); + submit.click(); + + // All good, should be on summary page ! + checkCurrentUrl(urlFixtures.createPoll(), false); + // Check an error message has been displayed + WebElement errorMessage = findElement(By.className("errorMessage")); + Assert.assertNotNull(errorMessage); + // Check we are in good table + checkWebElementValue(By.id("votingListGROUP_0.name"), groupName); + checkWebElementValue(By.id("votingListGROUP_0PersonToList_0.votingId"), participantOneName); + checkWebElementValue(By.id("votingListGROUP_0PersonToList_0.email"), participantEmail); + checkWebElementValue(By.id("votingListGROUP_0PersonToList_1.votingId"), participantTwoName); + checkWebElementValue(By.id("votingListGROUP_0PersonToList_1.email"), participantEmail); + } + + /** + * This test create a group text poll, with two participants on different group with same email. + * At the end, should stay on create poll page, cause the participant names should be unique. + * The group names and participants should not be lost. + */ + @Test + public void createGroupTextPollWithParticipantsWithSameEmail() { + + // Prepare the poll + preparePoll(); + + // Go to option panel and display group form + goToGroupForm(); + + // Set First group name + String groupOneName = "my group"; + sendKeysById("votingListGROUP_0.name", groupOneName); + // Set first participant in Group 1 + // send name + String participantOneName = "toto"; + sendKeysById("votingListGROUP_0PersonToList_0.votingId", participantOneName); + // send email + String participantEmail = "toto@codelutin.com"; + sendKeysById("votingListGROUP_0PersonToList_0.email", participantEmail); + + // Add a group + WebElement addGroupElement = findElement(By.name("pollen.action.addVotingList")); + Assert.assertEquals("input", addGroupElement.getTagName()); + Assert.assertTrue(addGroupElement.isDisplayed()); + addGroupElement.click(); + + // Set name of the second group + String groupTwoName = "my other group"; + sendKeysById("votingListGROUP_1.name", groupTwoName); + // Set second participant in second group + // send name + String participantTwoName = "toto2"; + sendKeysById("votingListGROUP_1PersonToList_0.votingId", participantTwoName); + // send email + sendKeysById("votingListGROUP_1PersonToList_0.email", participantEmail); + + // Submit form + WebElement submit = findElement(By.name("action:create")); + submit.click(); + + // All good, should be on summary page ! + checkCurrentUrl(urlFixtures.createPoll(), false); + // Check an error message has been displayed + WebElement errorMessage = findElement(By.className("errorMessage")); + Assert.assertNotNull(errorMessage); + // Check we are in good table + checkWebElementValue(By.id("votingListGROUP_0.name"), groupOneName); + checkWebElementValue(By.id("votingListGROUP_0PersonToList_0.votingId"), participantOneName); + checkWebElementValue(By.id("votingListGROUP_0PersonToList_0.email"), participantEmail); + checkWebElementValue(By.id("votingListGROUP_1.name"), groupTwoName); + checkWebElementValue(By.id("votingListGROUP_1PersonToList_0.votingId"), participantTwoName); + checkWebElementValue(By.id("votingListGROUP_1PersonToList_0.email"), participantEmail); + } + + /** + * This test create a group text poll, with two participant with same name in a group. + * At the end, should stay on create poll page, cause the email should be unique. + * The group name and participant info must be not lost + */ + @Test + public void createTextPollWithSameGroupParticipantsWithSameName() { + + // Prepare the poll + preparePoll(); + + // Go to option panel and display option panel + goToGroupForm(); + + // Set group name + String groupName = "my group"; + sendKeysById("votingListGROUP_0.name", groupName); + // Set first participant in Group + // send name + String participantName = "toto"; + sendKeysById("votingListGROUP_0PersonToList_0.votingId", participantName); + // send email + String participantOneEmail = "toto@codelutin.com"; + sendKeysById("votingListGROUP_0PersonToList_0.email", participantOneEmail); + + // Set second participant in Group with same email + // send name + sendKeysById("votingListGROUP_0PersonToList_1.votingId", participantName); + // send email + String participantTwoEmail = "toto@codelutin.com"; + sendKeysById("votingListGROUP_0PersonToList_1.email", participantTwoEmail); + + // Submit form + WebElement submit = findElement(By.name("action:create")); + submit.click(); + + // All good, should be on summary page ! + checkCurrentUrl(urlFixtures.createPoll(), false); + // Check an error message has been displayed + WebElement errorMessage = findElement(By.className("errorMessage")); + Assert.assertNotNull(errorMessage); + // Check we are in good table + checkWebElementValue(By.id("votingListGROUP_0.name"), groupName); + checkWebElementValue(By.id("votingListGROUP_0PersonToList_0.votingId"), participantName); + checkWebElementValue(By.id("votingListGROUP_0PersonToList_0.email"), participantOneEmail); + checkWebElementValue(By.id("votingListGROUP_0PersonToList_1.votingId"), participantName); + checkWebElementValue(By.id("votingListGROUP_0PersonToList_1.email"), participantTwoEmail); + } + + /** + * This test create a group text poll, with two participants of different group with same name. + * At the end, should stay on create poll page, cause the participant name should be unique. + * The group names and participants should not be lost. + */ + @Test + public void createGroupTextPollWithParticipantsWithSameName() { + + // Prepare the poll + preparePoll(); + + // Go to option panel and group form + goToGroupForm(); + + // Set First group name + String groupOneName = "my group"; + sendKeysById("votingListGROUP_0.name", groupOneName); + // Set first participant in Group 1 + // send name + String participantName = "toto"; + sendKeysById("votingListGROUP_0PersonToList_0.votingId", participantName); + // send email + String participantOneEmail = "toto@codelutin.com"; + sendKeysById("votingListGROUP_0PersonToList_0.email", participantOneEmail); + + // Add a group + WebElement addGroupElement = findElement(By.name("pollen.action.addVotingList")); + Assert.assertEquals("input", addGroupElement.getTagName()); + Assert.assertTrue(addGroupElement.isDisplayed()); + addGroupElement.click(); + + // Set name of the second group + String groupTwoName = "my other group"; + sendKeysById("votingListGROUP_1.name", groupTwoName); + // Set second participant in second group + // send name + sendKeysById("votingListGROUP_1PersonToList_0.votingId", participantName); + // send email + String participantTwoEmail = "toto@codelutin.com"; + sendKeysById("votingListGROUP_1PersonToList_0.email", participantTwoEmail); + + // Submit form + WebElement submit = findElement(By.name("action:create")); + submit.click(); + + // All good, should be on summary page ! + checkCurrentUrl(urlFixtures.createPoll(), false); + // Check an error message has been displayed + WebElement errorMessage = findElement(By.className("errorMessage")); + Assert.assertNotNull(errorMessage); + // Check we are in good table + checkWebElementValue(By.id("votingListGROUP_0.name"), groupOneName); + checkWebElementValue(By.id("votingListGROUP_0PersonToList_0.votingId"), participantName); + checkWebElementValue(By.id("votingListGROUP_0PersonToList_0.email"), participantOneEmail); + checkWebElementValue(By.id("votingListGROUP_1.name"), groupTwoName); + checkWebElementValue(By.id("votingListGROUP_1PersonToList_0.votingId"), participantName); + checkWebElementValue(By.id("votingListGROUP_1PersonToList_0.email"), participantTwoEmail); + } + + /** Click on option panel, and select Group type to restrict the poll participation */ + void goToGroupForm() { + // Go to option panel : click on it + WebElement optionsClick = findElement(By.xpath("//a[@href=\"#toptions\"]")); + optionsClick.click(); + + // Switch to group type + List<WebElement> pollTypesElement = findElements(By.name("poll.pollType")); + Assert.assertEquals(3, pollTypesElement.size()); + WebElement restrictedTypeElement = pollTypesElement.get(2); + Assert.assertEquals("input", restrictedTypeElement.getTagName()); + Assert.assertEquals("GROUP", restrictedTypeElement.getAttribute("value")); + Assert.assertTrue(restrictedTypeElement.isDisplayed()); + restrictedTypeElement.click(); + } + + /** Prepare the poll with general data : one title and two choices */ + void preparePoll() { + // Go on home page + gotoUrl(urlFixtures.createPoll()); + + // Set title + sendKeysByName("poll.title", "My Poll"); + + // Set first choice + sendKeysByName("textChoice_0.name", "Choix numero un"); + + // Set second choice + sendKeysByName("textChoice_1.name", "Choix numero deux"); + } + +} Property changes on: trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/CreateTextPollForGroupSIT.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: trunk/pollen-ui-struts2/src/it/pollVoteVisibility ___________________________________________________________________ Modified: svn:ignore - *.ipr *.iws *.iml + *.ipr *.iws *.iml .idea target Modified: trunk/pollen-ui-struts2/src/it/pollVoteVisibility/goals.txt =================================================================== --- trunk/pollen-ui-struts2/src/it/pollVoteVisibility/goals.txt 2012-08-26 16:34:10 UTC (rev 3631) +++ trunk/pollen-ui-struts2/src/it/pollVoteVisibility/goals.txt 2012-08-26 16:34:56 UTC (rev 3632) @@ -1 +1 @@ -clean post-integration-test -Prun-it \ No newline at end of file +clean post-integration-test -DrunIts \ No newline at end of file Modified: trunk/pollen-ui-struts2/src/it/pollVoteVisibility/pom.xml =================================================================== --- trunk/pollen-ui-struts2/src/it/pollVoteVisibility/pom.xml 2012-08-26 16:34:10 UTC (rev 3631) +++ trunk/pollen-ui-struts2/src/it/pollVoteVisibility/pom.xml 2012-08-26 16:34:56 UTC (rev 3632) @@ -9,6 +9,7 @@ <groupId>org.chorem.pollen.it</groupId> <artifactId>pollen-ui-it</artifactId> <version>1.4.5-SNAPSHOT</version> + <relativePath>../pollen-ui-it/pom.xml</relativePath> </parent> <artifactId>pollVoteVisibility</artifactId> Copied: trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/AnonymousFreePollByAnonymousIT.java (from rev 3629, trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/poll/ui/it/AnonymousFreePollByAnonymousIT.java) =================================================================== --- trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/AnonymousFreePollByAnonymousIT.java (rev 0) +++ trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/AnonymousFreePollByAnonymousIT.java 2012-08-26 16:34:56 UTC (rev 3632) @@ -0,0 +1,103 @@ +package org.chorem.pollen.ui.it; + +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; + +/** + * Test a anonymous free poll created by a anonymous user. + * <p/> + * For that poll nobody can see votes. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.4.5 + */ +public class AnonymousFreePollByAnonymousIT extends AbstractPollIT { + + public AnonymousFreePollByAnonymousIT(Class<? extends WebDriver> driverType) { + super(driverType, + "cacb52f4d49047b7a7aa24ec528fcc87", + "e814ba6e25174d5983ad796c400520f5"); + } + + @Test + public void checkSummaryPollPage() { + + // can not access to summary page with no pollId + gotoUrl(urlFixtures.summaryPoll(), urlFixtures.poll_required(), false); + + // can not access to summary page with no creatorId + gotoUrl(urlFixtures.summaryPoll(pollUri), urlFixtures.poll_creator_required(), false); + + // access to summary page + gotoUrl(urlFixtures.summaryPoll(adminPollUri), true); + + // user can vote (#voteUrl) + findElement(By.id("voteUrl")); + } + + @Test + public void checkModeratePollPage() { + + // can not access to moderate page with no pollId + gotoUrl(urlFixtures.moderatePoll(), urlFixtures.poll_required(), false); + + // can not access to moderate page with no creatorId + gotoUrl(urlFixtures.moderatePoll(pollUri), urlFixtures.poll_creator_required(), false); + + // access to moderate page + gotoUrl(urlFixtures.moderatePoll(adminPollUri), true); + + // can not vote + checkCanNotVote(); + + // can not see votes + checkCanNotSeeVote(); + } + + @Test + public void checkVoteForPage() { + + // access to votefor page with no accountId + gotoUrl(urlFixtures.voteforPoll(pollUri), true); + + // can vote + checkCanVote(); + + // can not see votes + checkCanNotSeeVote(); + } + + @Test + public void checkVoteForPageWithCreatorId() { + + // access to votefor page with creatorId + gotoUrl(urlFixtures.voteforPoll(adminPollUri), true); + + // can not vote + checkCanNotVote(); + + // can not see votes + checkCanNotSeeVote(); + } + + protected void checkCanNotSeeVote() { + checkNoElement(By.className("voted")); + checkNoElement(By.className("notVoted")); + } + + protected void checkCanSeeVote() { + findElement(By.className("voted")); + findElement(By.className("notVoted")); + } + + protected void checkCanNotVote() { + checkNoElement(By.id("voteForm_pollen_action_pollVote")); + checkNoElement(By.name("vote.choiceVoteToChoice[0].voteValue")); + } + + protected void checkCanVote() { + findElement(By.id("voteForm_pollen_action_pollVote")); + findElement(By.name("vote.choiceVoteToChoice[0].voteValue")); + } +} Property changes on: trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/AnonymousFreePollByAnonymousIT.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Property changes on: trunk/pollen-ui-struts2/src/it/pollen-ui-it ___________________________________________________________________ Modified: svn:ignore - *.iml *.ipr *.iws .idea + *.iml *.ipr *.iws .idea target Modified: trunk/pollen-ui-struts2/src/it/pollen-ui-it/pom.xml =================================================================== --- trunk/pollen-ui-struts2/src/it/pollen-ui-it/pom.xml 2012-08-26 16:34:10 UTC (rev 3631) +++ trunk/pollen-ui-struts2/src/it/pollen-ui-it/pom.xml 2012-08-26 16:34:56 UTC (rev 3632) @@ -13,7 +13,7 @@ <groupId>org.chorem.pollen.it</groupId> <artifactId>pollen-ui-it</artifactId> - <name>Pollen :: UI (IT)</name> + <name>Pollen :: IT</name> <description>Super Pom des ITs</description> <packaging>pom</packaging> @@ -24,7 +24,8 @@ <explodedWarPath>../pollen-ui-it/target/war</explodedWarPath> <pollenConfigurationFile>pollen-it.properties</pollenConfigurationFile> - <pollenDataDirectory>${project.build.testOutputDirectory}/data</pollenDataDirectory> + <pollenDataDirectory>${project.build.testOutputDirectory}/data + </pollenDataDirectory> </properties> <dependencies> @@ -112,14 +113,79 @@ <outputDirectory> ${project.build.directory}/war </outputDirectory> - <excludes>**/lib/*.jar</excludes> + <excludes>**/lib/*.jar,**/*.jsp</excludes> </artifactItem> + <artifactItem> + <groupId>org.chorem.pollen</groupId> + <artifactId>pollen-ui-struts2</artifactId> + <version>${project.version}</version> + <type>war</type> + <overWrite>true</overWrite> + <outputDirectory> + ${project.build.directory}/toprocess + </outputDirectory> + <includes>WEB-INF/web.xml,WEB-INF/**/*.jsp,WEB-INF/**/*.class</includes> + </artifactItem> </artifactItems> </configuration> </execution> </executions> </plugin> + <plugin> + <groupId>org.mortbay.jetty</groupId> + <artifactId>jetty-jspc-maven-plugin</artifactId> + <version>${jettyPluginVersion}</version> + <inherited>false</inherited> + <executions> + <execution> + <id>jspc</id> + <goals> + <goal>jspc</goal> + </goals> + <configuration> + <!--<verbose>true</verbose>--> + <webAppSourceDirectory> + ${project.build.directory}/toprocess + </webAppSourceDirectory> + <generatedClasses> + ${project.build.directory}/war/WEB-INF/classes + </generatedClasses> + <webXmlFragment> + ${project.build.directory}/war/WEB-INF/webfrag.xml + </webXmlFragment> + <webXml> + ${project.build.directory}/toprocess/WEB-INF/web.xml + </webXml> + <packageRoot>org.apache.jsp</packageRoot> + + </configuration> + </execution> + </executions> + <dependencies> + <dependency> + <groupId>org.apache.struts</groupId> + <artifactId>struts2-core</artifactId> + <version>${struts2Version}</version> + </dependency> + <dependency> + <groupId>com.jgeppert.struts2.jquery</groupId> + <artifactId>struts2-jquery-plugin</artifactId> + <version>${jqueryPluginVersion}</version> + </dependency> + <dependency> + <groupId>com.jgeppert.struts2.jquery</groupId> + <artifactId>struts2-jquery-grid-plugin</artifactId> + <version>${jqueryPluginVersion}</version> + </dependency> + <dependency> + <groupId>org.apache.struts</groupId> + <artifactId>struts2-sitemesh-plugin</artifactId> + <version>${struts2Version}</version> + </dependency> + </dependencies> + </plugin> + </plugins> <pluginManagement> @@ -186,17 +252,25 @@ <profiles> <profile> - <id>run-it</id> + <id>start-server</id> + <activation> + <property> + <name>runIts</name> + <value>true</value> + </property> + </activation> + <properties> + <jetty.daemon>${runIts}</jetty.daemon> + </properties> <build> - <defaultGoal>post-integration-test</defaultGoal> + <defaultGoal>pre-integration-test</defaultGoal> <plugins> <plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <executions> - <execution> <id>start-pollen</id> <phase>pre-integration-test</phase> @@ -204,7 +278,7 @@ <goal>run</goal> </goals> <configuration> - <daemon>true</daemon> + <!--<daemon>true</daemon>--> <webAppSourceDirectory> ${explodedWarPath} </webAppSourceDirectory> @@ -219,17 +293,23 @@ <useTestScope>true</useTestScope> </configuration> </execution> - - <execution> - <id>stop-pollen</id> - <phase>post-integration-test</phase> - <goals> - <goal>stop</goal> - </goals> - </execution> </executions> </plugin> + </plugins> + </build> + </profile> + <profile> + <id>run-tests</id> + <activation> + <property> + <name>runIts</name> + <value>true</value> + </property> + </activation> + <build> + <defaultGoal>integration-test</defaultGoal> + <plugins> <plugin> <artifactId>maven-surefire-plugin</artifactId> <executions> @@ -261,6 +341,35 @@ </build> </profile> + <profile> + <id>stop-server</id> + <activation> + <property> + <name>runIts</name> + <value>true</value> + </property> + </activation> + <build> + <defaultGoal>post-integration-test</defaultGoal> + <plugins> + + <plugin> + <groupId>org.mortbay.jetty</groupId> + <artifactId>jetty-maven-plugin</artifactId> + <executions> + <execution> + <id>stop-pollen</id> + <phase>post-integration-test</phase> + <goals> + <goal>stop</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + </profiles> </project> Property changes on: trunk/pollen-ui-struts2/src/it/security ___________________________________________________________________ Added: svn:ignore + target *.ipr *.iws *.iml .idea Property changes on: trunk/pollen-ui-struts2/src/it/security/LICENSE.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/pollen-ui-struts2/src/it/security/README.txt =================================================================== --- trunk/pollen-ui-struts2/src/it/security/README.txt (rev 0) +++ trunk/pollen-ui-struts2/src/it/security/README.txt 2012-08-26 16:34:56 UTC (rev 3632) @@ -0,0 +1,7 @@ +======== +security +======== + +Pour tester la sécurité dans Pollen. + +TODO expliquer les differents scénarios testés. \ No newline at end of file Property changes on: trunk/pollen-ui-struts2/src/it/security/README.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Property changes on: trunk/pollen-ui-struts2/src/it/security/changelog.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/pollen-ui-struts2/src/it/security/goals.txt =================================================================== --- trunk/pollen-ui-struts2/src/it/security/goals.txt (rev 0) +++ trunk/pollen-ui-struts2/src/it/security/goals.txt 2012-08-26 16:34:56 UTC (rev 3632) @@ -0,0 +1 @@ +clean post-integration-test -DrunIts \ No newline at end of file Property changes on: trunk/pollen-ui-struts2/src/it/security/goals.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/pollen-ui-struts2/src/it/security/pom.xml =================================================================== --- trunk/pollen-ui-struts2/src/it/security/pom.xml (rev 0) +++ trunk/pollen-ui-struts2/src/it/security/pom.xml 2012-08-26 16:34:56 UTC (rev 3632) @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.chorem.pollen.it</groupId> + <artifactId>pollen-ui-it</artifactId> + <version>1.4.5-SNAPSHOT</version> + <relativePath>../pollen-ui-it/pom.xml</relativePath> + </parent> + + <artifactId>security</artifactId> + <name>Pollen :: IT security</name> + <description>security</description> + +</project> + Property changes on: trunk/pollen-ui-struts2/src/it/security/pom.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/pollen-ui-struts2/src/it/security/src/jetty/jetty-context.xml =================================================================== --- trunk/pollen-ui-struts2/src/it/security/src/jetty/jetty-context.xml (rev 0) +++ trunk/pollen-ui-struts2/src/it/security/src/jetty/jetty-context.xml 2012-08-26 16:34:56 UTC (rev 3632) @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!-- + #%L + Pollen :: UI (struts2) + $Id$ + $HeadURL: http://svn.chorem.org/svn/pollen/trunk/pollen-ui-struts2/src/jetty/jetty-con... $ + %% + Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + #L% + --> + +<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://www.eclipse.org/jetty/configure.dtd"> + +<Configure class="org.eclipse.jetty.webapp.WebAppContext"> + <Call name="setAttribute"> + <Arg>org.eclipse.jetty.server.webapp.WebInfIncludeJarPattern</Arg> + <Arg>.*/.*jsp-api-[^/]\.jar$|./.*jsp-[^/]\.jar$|./.*taglibs[^/]*\.jar$</Arg> + </Call> +</Configure> \ No newline at end of file Property changes on: trunk/pollen-ui-struts2/src/it/security/src/jetty/jetty-context.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Copied: trunk/pollen-ui-struts2/src/it/security/src/test/java/org/chorem/pollen/ui/it/LoginSIT.java (from rev 3629, trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/its/LoginSIT.java) =================================================================== --- trunk/pollen-ui-struts2/src/it/security/src/test/java/org/chorem/pollen/ui/it/LoginSIT.java (rev 0) +++ trunk/pollen-ui-struts2/src/it/security/src/test/java/org/chorem/pollen/ui/it/LoginSIT.java 2012-08-26 16:34:56 UTC (rev 3632) @@ -0,0 +1,60 @@ +package org.chorem.pollen.ui.it; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +import java.util.List; + +/** + * Test the login action. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.4 + */ +public class LoginSIT extends AbstractPollenIT { + + public LoginSIT(Class<? extends WebDriver> driverType) { + super(driverType); + } + + @Test + public void loginAdmin() { + +// gotoUrl(urlFixtures.home()); + + connect("admin", "admin"); + + // check info_success is on + findElement(By.className("info_success")); + + // check there is a admin menu (so 4 menus) + List<WebElement> menus = findElements(By.className("menu_elt")); + Assert.assertEquals(4, menus.size()); + } + + @Test + public void loginUser() { + +// gotoUrl(urlFixtures.home()); + + connect("user", "user"); + + // check info_success is on + findElement(By.className("info_success")); + + // check there is not a admin menu (so 3 menus) + List<WebElement> menus = findElements(By.className("menu_elt")); + Assert.assertEquals(3, menus.size()); + } + + @Test + public void badLogin() { + + connect("admin", "admin" + System.currentTimeMillis()); + + findElement(By.className("info_error")); + } +} Property changes on: trunk/pollen-ui-struts2/src/it/security/src/test/java/org/chorem/pollen/ui/it/LoginSIT.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/pollen-ui-struts2/src/it/security/src/test/java/org/chorem/pollen/ui/it/SecurityAccessSIT.java (from rev 3629, trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/its/SecurityAccessSIT.java) =================================================================== --- trunk/pollen-ui-struts2/src/it/security/src/test/java/org/chorem/pollen/ui/it/SecurityAccessSIT.java (rev 0) +++ trunk/pollen-ui-struts2/src/it/security/src/test/java/org/chorem/pollen/ui/it/SecurityAccessSIT.java 2012-08-26 16:34:56 UTC (rev 3632) @@ -0,0 +1,330 @@ +/* + * #%L + * Pollen :: UI (struts2) + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package org.chorem.pollen.ui.it; + +import org.chorem.pollen.bean.PollUri; +import org.junit.Test; +import org.openqa.selenium.WebDriver; + +/** + * Test the security on some restricted pages : + * <p/> + * <ul> + * <li>Access to "connected pages" when connected (OK)</li> + * <li>Access to "connected pages" when not connected (KO)</li> + * <li>Access to "admin pages" when not connected (KO)</li> + * <li>Access to "admin pages" when not connected as admin (KO)</li> + * <li>Access to "admin pages" when connected as admin (OK)</li> + * <li>Access to "poll page" with a good pollId (OK)</li> + * <li>Access to "poll page" with a bad pollId (KO)</li> + * <li>Access to "poll admin page" with a good tokenId (OK)</li> + * <li>Access to "poll admin page" with a bad tokenId (KO)</li> + * <li>Access to "poll moderation page" with a good tokenId (OK)</li> + * <li>Access to "poll moderation page" with a bad tokenId (KO)</li> + * </ul> + * <p/> + * TODO ymartel 2012/06/12 + * Should check those security access to : + * <ul> + * <li>Access to "restricted poll page" with a good accountId (OK)</li> + * <li>Access to "restricted poll page" with a bad accountId (KO)</li> + * </ul> + * + * @author ymartel <martel@codelutin.com> + * @author tchemit <chemit@codelutin.com> + * @since 1.4 + */ +public class SecurityAccessSIT extends AbstractPollIT { + + public SecurityAccessSIT(Class<? extends WebDriver> driverType) { + super(driverType, + "c7082f9752844b83a1859abcae3b681c", + "b9b434acd58d42fca083d473ee021fce"); + } + + /** + * This test : + * <ol> + * <li>Connect the user "user"</li> + * <li>Try to access to createdList page</li> + * <li>Try to access to invitedList page</li> + * <li>Try to access to participatedList page</li> + * <li>Try to access to favoriteLists page</li> + * </ol> + * <p/> + * All the page should be accessed. + */ + @Test + public void accessConnectedPageAsUser() { + + // login as user + connect("user", "user"); + + // try to access to createdList page, current url should be good one + gotoUrl(urlFixtures.createdList()); + + // try to access to participatedList page, current url should be good one + gotoUrl(urlFixtures.participatedList()); + + // try to access to invitedList page, current url should be good one + gotoUrl(urlFixtures.invitedList()); + + // try to access to favoriteLists page, current url should be good one + gotoUrl(urlFixtures.favoriteLists()); + } + + /** + * This test : + * <ol> + * <li>Don't login</li> + * <li>Try to access to createdList page</li> + * <li>Try to access to invitedList page</li> + * <li>Try to access to participatedList page</li> + * <li>Try to access to favoriteLists page</li> + * </ol> + * <p/> + * All the page should be redirected to connected_required page. + */ + @Test + public void accessConnectedPageAsAnonymous() { + + // try to access to createdList page, current url should be the connected_required one + gotoUrl(urlFixtures.createdList(), urlFixtures.connected_required(), false); + + // try to access to participatedList page, current url should be the connected_required one + gotoUrl(urlFixtures.participatedList(), urlFixtures.connected_required(), false); + + // try to access to invitedList page, current url should be the connected_required one + gotoUrl(urlFixtures.invitedList(), urlFixtures.connected_required(), false); + + // try to access to favoriteLists page, current url should be the connected_required one + gotoUrl(urlFixtures.favoriteLists(), urlFixtures.connected_required(), false); + } + + /** + * This test : + * <ol> + * <li>Don't login</li> + * <li>Try to access to admin polls list page</li> + * <li>Try to access to admin users list page</li> + * </ol> + * <p/> + * All the page should be redirected to connected_required page. + */ + @Test + public void accessAdminPageAsAnonymous() { + + // try to access to admin polls list page, current url should be the connected_required one + gotoUrl(urlFixtures.pollsList(), urlFixtures.connected_required(), false); + + // try to access to admin users list page, current url should be the connected_required one + gotoUrl(urlFixtures.usersList(), urlFixtures.connected_required(), false); + } + + /** + * This test : + * <ol> + * <li>Login as lambda user</li> + * <li>Try to access to admin polls list page</li> + * <li>Try to access to admin users list page</li> + * </ol> + * <p/> + * All the page should be redirected to admin_required page. + */ + @Test + public void accessAdminPageAsUser() { + + // login as user + connect("user", "user"); + + // try to access to admin polls list page, current url should be the admin_required one + gotoUrl(urlFixtures.pollsList(), urlFixtures.admin_required(), false); + + // try to access to admin users list page, current url should be the admin_required one + gotoUrl(urlFixtures.usersList(), urlFixtures.admin_required(), false); + } + + /** + * This test : + * <ol> + * <li>Login as admin</li> + * <li>Try to access to admin polls list page</li> + * <li>Try to access to admin users list page</li> + * </ol> + * <p/> + * All the page should be accessed. + */ + @Test + public void accessAdminPageAsAdmin() { + + // login as admin + connect("admin", "admin"); + + // try to access to admin polls list page, current url should be good one + gotoUrl(urlFixtures.pollsList()); + + // try to access to admin users list page, current url should be good one + gotoUrl(urlFixtures.usersList()); + } + + /** + * This test : + * <ol> + * <li>Try to access to normal poll with good pollId</li> + * <li>Try to access to normal poll with bad pollId (should be redirected)</li> + * <li>Try to access to moderation page for normal poll with good pollId & good tokenId</li> + * <li>Try to access to moderation page for normal poll with good pollId & bad tokenId (should be redirected)</li> + * <li>Try to access to modification page for normal poll with just a good pollId</li> + * <li>Try to access to modification page for normal poll with good pollId & good tokenId</li> + * <li>Try to access to modification page for normal poll with good pollId & bad tokenId (should be redirected)</li> + * </ol> + * <p/> + * All the page should be accessed. + */ + @Test + public void accessNormalPollActionsAsAnonymous() { + + String badPollId = pollId + System.nanoTime(); + String badCreatorId = accountId + System.nanoTime(); + + // try to access to poll page, current url should be good one + String normalPollURL = urlFixtures.voteforPoll(pollUri); + gotoUrl(normalPollURL); + + // try to access to poll page with bad pollId, current url should be the poll_required one + gotoUrl(urlFixtures.voteforPoll(PollUri.newPollUri(badPollId)), urlFixtures.poll_required(), false); + + // try to access to poll moderation page, current url should be good one + String moderationURL = urlFixtures.voteforPoll(adminPollUri); + gotoUrl(moderationURL); + + // try to access to poll page with bad pollId, current url should be the poll_required one + gotoUrl(urlFixtures.voteforPoll(newPollUri(badCreatorId)), urlFixtures.poll_access_required(), false); + + // try to access to poll moderation page, current url should be good one + String normalPollAdminURL = urlFixtures.editPoll(adminPollUri); + gotoUrl(normalPollAdminURL); + + // try to access to poll page with bad pollId, current url should be the poll_required one + gotoUrl(urlFixtures.editPoll(newPollUri(badCreatorId)), urlFixtures.poll_creator_required(), false); + } + + /** + * This test : + * <ol> + * <li>Login as Admin</li> + * <li>Try to access to normal poll with good pollId</li> + * <li>Try to access to normal poll with bad pollId (should be redirected)</li> + * <li>Try to access to moderation page for normal poll with good pollId & good tokenId</li> + * <li>Try to access to moderation page for normal poll with good pollId & bad tokenId (should be redirected)</li> + * <li>Try to access to admin page for normal poll with good pollId & good tokenId</li> + * <li>Try to access to admin page for normal poll with good pollId & bad tokenId (should be redirected)</li> + * </ol> + * <p/> + * All the page should be accessed. + */ + @Test + public void accessNormalPollActionsAsAdmin() { + + // login as admin + connect("admin", "admin"); + + String badPollId = pollId + System.nanoTime(); + String badCreatorId = accountId + System.nanoTime(); + + // try to access to poll page, current url should be good one + String normalPollURL = urlFixtures.voteforPoll(pollUri); + gotoUrl(normalPollURL); + + // try to access to poll page with bad pollId, current url should be the poll_required one + gotoUrl(urlFixtures.voteforPoll(PollUri.newPollUri(badPollId)), urlFixtures.poll_required(), false); + + // try to access to poll moderation page, current url should be good one + String moderationURL = urlFixtures.voteforPoll(adminPollUri); + gotoUrl(moderationURL); + + // try to access to poll page with bad creatorId, current url should be the poll_required one + gotoUrl(urlFixtures.voteforPoll(newPollUri(badCreatorId)), urlFixtures.poll_access_required(), false); + + // try to access to poll modification page without creator Id, current url should be good one (admin access) + String simpleNormalPollAdminURL = urlFixtures.editPoll(pollUri); + gotoUrl(simpleNormalPollAdminURL); + + // try to access to poll modification page with creator Id, current url should be good one + String normalPollAdminURL = urlFixtures.editPoll(adminPollUri); + gotoUrl(normalPollAdminURL); + + // try to access to poll modifcation page with bad creatorId, current url should be the poll_creator_required one, even if we are admin + gotoUrl(urlFixtures.editPoll(newPollUri(badCreatorId)), urlFixtures.poll_creator_required(), false); + } + + /** + * This test : + * <ol> + * <li>Login as "User" (owner of the poll)</li> + * <li>Try to access to normal poll with good pollId</li> + * <li>Try to access to normal poll with bad pollId (should be redirected)</li> + * <li>Try to access to moderation page for normal poll with good pollId & good tokenId</li> + * <li>Try to access to moderation page for normal poll with good pollId & bad tokenId (should be redirected)</li> + * <li>Try to access to admin page for normal poll with good pollId & good tokenId</li> + * <li>Try to access to admin page for normal poll with good pollId & bad tokenId (should be redirected)</li> + * </ol> + * <p/> + * All the page should be accessed. + */ + @Test + public void accessNormalPollActionsAsOwner() { + + // login as user + connect("user", "user"); + + String badPollId = pollId + System.nanoTime(); + String badCreatorId = accountId + System.nanoTime(); + + // try to access to poll page, current url should be good one + String normalPollURL = urlFixtures.voteforPoll(pollUri); + gotoUrl(normalPollURL); + + // try to access to poll page with bad pollId, current url should be the poll_required one + gotoUrl(urlFixtures.voteforPoll(PollUri.newPollUri(badPollId)), urlFixtures.poll_required(), false); + + // try to access to poll moderation page, current url should be good one + String moderationURL = urlFixtures.voteforPoll(adminPollUri); + gotoUrl(moderationURL); + + // try to access to poll page with bad pollId, current url should be the poll_required one + gotoUrl(urlFixtures.voteforPoll(newPollUri(badCreatorId)), urlFixtures.poll_access_required(), false); + + // try to access to poll modification page without creator Id, current url should be good one (owner access) + String simpleNormalPollModificationURL = urlFixtures.editPoll(pollUri); + gotoUrl(simpleNormalPollModificationURL); + + // try to access to poll modification page with creator Id, current url should be good one + String normalPollModificationURL = urlFixtures.editPoll(adminPollUri); + gotoUrl(normalPollModificationURL); + + // try to access to poll modifcation page with bad creatorId, current url should be the poll_creator_required one, even if we are owner + gotoUrl(urlFixtures.editPoll(newPollUri(badCreatorId)), urlFixtures.poll_creator_required(), false); + } + +} Property changes on: trunk/pollen-ui-struts2/src/it/security/src/test/java/org/chorem/pollen/ui/it/SecurityAccessSIT.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/pollen-ui-struts2/src/it/security/src/test/resources/data/db/pollendb.h2.db (from rev 3629, trunk/pollen-ui-struts2/src/test/resources/pollendb.h2.db) =================================================================== (Binary files differ) Property changes on: trunk/pollen-ui-struts2/src/it/security/src/test/resources/data/db/pollendb.h2.db ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/pollen-ui-struts2/src/main/resources/config/struts-poll.xml =================================================================== --- trunk/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-08-26 16:34:10 UTC (rev 3631) +++ trunk/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-08-26 16:34:56 UTC (rev 3632) @@ -214,7 +214,7 @@ <!-- display * --> <action name="display*" - class="org.chorem.pollen.ui.actions.poll.Display{1}"> + class="org.chorem.pollen.ui.actions.poll.form.Display{1}"> <result>/WEB-INF/jsp/poll/display{1}.jsp</result> </action> Deleted: trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/PollenFixtures.java =================================================================== --- trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/PollenFixtures.java 2012-08-26 16:34:10 UTC (rev 3631) +++ trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/PollenFixtures.java 2012-08-26 16:34:56 UTC (rev 3632) @@ -1,169 +0,0 @@ -/* - * #%L - * Pollen :: UI (struts2) - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ -package org.chorem.pollen.ui; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.chorem.pollen.PollenConfiguration; -import org.chorem.pollen.bean.PollUri; -import org.nuiton.util.DateUtil; - -import java.util.Calendar; -import java.util.Date; - -/** - * Some fixtures for tests. - * - * @author tchemit <chemit@codelutin.com> - * @since 1.4 - */ -public class PollenFixtures { - - /** Logger. */ - private static final Log log = LogFactory.getLog(PollenFixtures.class); - - /** - * The base url of the application. - * <p/> - * This url contains also the web context. This url is obtain from - * the configuration. - * <p/> - * Example: - * <p/> - * <pre>http://localhost:8765/pollen</pre> - * - * @see PollenConfiguration#getApplicationUrl() - */ - protected static String baseUrl; - - public String baseUrl() { - if (baseUrl == null) { - - //get it from configuration - - PollenConfiguration configuration = new PollenConfiguration( - "pollen-test.properties", - null); - baseUrl = configuration.getApplicationUrl().toString(); - if (!baseUrl.endsWith("/")) { - baseUrl += "/"; - } - if (log.isInfoEnabled()) { - log.info("Base url = " + baseUrl); - } - } - return baseUrl; - } - - public String normalPollId() { - return "c7082f9752844b83a1859abcae3b681c"; - } - - public String normalPollCreatorId() { - return "b9b434acd58d42fca083d473ee021fce"; - } - - public String datePattern() { - return "dd/MM/yyyy HH:mm"; - } - - public String homeURL() { - return baseUrl() + "home"; - } - - public String createdListURL() { - return baseUrl() + "user/createdList"; - } - - public String invitedListURL() { - return baseUrl() + "user/invitedList"; - } - - public String participatedListURL() { - return baseUrl() + "user/participatedList"; - } - - public String favoriteListsURL() { - return baseUrl() + "user/favoriteLists"; - } - - public String pollsListURL() { - return baseUrl() + "admin/pollsList"; - } - - public String usersListURL() { - return baseUrl() + "admin/usersList"; - } - - public String connected_requiredURL() { - return baseUrl() + "security/connected_required"; - } - - public String admin_requiredURL() { - return baseUrl() + "security/admin_required"; - } - - public String poll_requiredURL() { - return baseUrl() + "security/illegal_access"; - } - - public String poll_access_requiredURL() { - return baseUrl() + "security/illegal_access"; - } - - public String poll_creator_requiredURL() { - return baseUrl() + "security/illegal_access"; - } - - public String voteforURL(PollUri pollUri) { - return baseUrl() + "poll/votefor/" + pollUri.toString(); - } - - public String editURL(PollUri pollUri) { - return baseUrl() + "poll/edit/" + pollUri.toString() + "!input"; - } - - public String createPollURL() { - return baseUrl() + "poll/create"; - } - - public String summaryURL() { - return baseUrl() + "poll/summary"; - } - - public String date(int year, int month, int day, int hour, int minute) { - Calendar instance = Calendar.getInstance(); - instance.set(year, month, day, hour, minute); - Date date = instance.getTime(); - String dateString = DateUtil.formatDate(date, datePattern()); - return dateString; - } - - public String date(int year, int month, int day) { - return date(year, month, day, 0, 0); - } - - public String logoutURL() { - return baseUrl() + "user/logout"; - } -} Deleted: trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/PollenTestApplicationListener.java =================================================================== --- trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/PollenTestApplicationListener.java 2012-08-26 16:34:10 UTC (rev 3631) +++ trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/PollenTestApplicationListener.java 2012-08-26 16:34:56 UTC (rev 3632) @@ -1,93 +0,0 @@ -/* - * #%L - * Pollen :: UI (struts2) - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ -package org.chorem.pollen.ui; - -import org.apache.commons.io.FileUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.chorem.pollen.PollenConfiguration; -import org.chorem.pollen.PollenConfigurationOption; - -import java.io.File; -import java.io.IOException; -import java.util.Properties; - -/** - * Pollen application listener used for test purposes. - * - * @author tchemit <chemit@codelutin.com> - * @since 1.4 - */ -public class PollenTestApplicationListener extends PollenApplicationListener { - - /** Logger. */ - private static final Log log = - LogFactory.getLog(PollenTestApplicationListener.class); - - @Override - protected PollenConfiguration prepareConfiguration() { - PollenConfiguration configuration = new PollenConfiguration( - "pollen-test.properties", - null) { - - @Override - protected void loadApplicationConfig(String file, - Properties defaultOptions) { - super.loadApplicationConfig(file, defaultOptions); - - // let's add a suffix (to isolate this data dir) - File dataDirectory = new File(getDataDirectory(), - String.valueOf(System.nanoTime())); - if (log.isInfoEnabled()) { - log.info("Data directory = " + dataDirectory); - } - setOption(PollenConfigurationOption.DATA_DIR.getKey(), - dataDirectory.getAbsolutePath()); - - - File incomingDatabase = getOptionAsFile("incomingDatabase"); - - if (log.isInfoEnabled()) { - log.info("Incoming db = " + incomingDatabase); - } - // copy db to correct path - File dbDirectory = new File(dataDirectory, "db"); - - try { - if (log.isInfoEnabled()) { - log.info("Copy incoming db [" + incomingDatabase + - "] to [" + dbDirectory + "]"); - } - FileUtils.copyFileToDirectory( - incomingDatabase, dbDirectory); - } catch (IOException e) { - throw new IllegalStateException( - "Could not copy db to " + dbDirectory); - } - - } - }; - - return configuration; - } -} Modified: trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/it/AbstractPollIT.java =================================================================== --- trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/it/AbstractPollIT.java 2012-08-26 16:34:10 UTC (rev 3631) +++ trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/it/AbstractPollIT.java 2012-08-26 16:34:56 UTC (rev 3632) @@ -1,49 +1,17 @@ package org.chorem.pollen.ui.it; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.chorem.pollen.bean.PollUri; import org.chorem.pollen.business.persistence.Poll; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.ClassRule; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import java.util.Collection; -import java.util.List; - /** * Base class test for a it on a specific poll. * * @author tchemit <chemit@codelutin.com> * @since 1.4.5 */ -@RunWith(value = Parameterized.class) -public class AbstractPollIT { +public class AbstractPollIT extends AbstractPollenIT { - /** Logger. */ - protected final Log log = LogFactory.getLog(getClass()); - - @Parameterized.Parameters - public static Collection<Object[]> driverTypes() { - return WebDriverResources.driverTypes(); - } - - /** Selenium driver to use for all tests of this class. */ - @ClassRule - public static final WebDriverResources seleniumServer = new WebDriverResources(); - - /** URL fixtures. */ - protected static final PollenUrlFixtures urlFixtures = new PollenUrlFixtures(); - - /** Type of driver used by currenttest. */ - protected final Class<? extends WebDriver> driverType; - /** {@link Poll#getPollId()}. */ protected final String pollId; @@ -56,169 +24,17 @@ /** {@link PollUri} of the poll (with admin accountId ) */ protected final PollUri adminPollUri; - /** Driver used by current test. */ - protected WebDriver driver; - protected AbstractPollIT(Class<? extends WebDriver> driverType, String pollId, String accountId) { + super(driverType); this.pollId = pollId; this.accountId = accountId; - this.driverType = driverType; pollUri = PollUri.newPollUri(pollId); adminPollUri = PollUri.newPollUri(pollId, accountId); } - @Before - public void setUp() throws Exception { - driver = seleniumServer.getDriver(driverType); - } - - @After - public void after() { - - // make sure driver came back in original state: - // go back to home page and logout if was loggued in - logout(); - } - protected PollUri newPollUri(String accountId) { return PollUri.newPollUri(pollId, accountId); } - - protected void logout() { - gotoUrl(urlFixtures.logout(), urlFixtures.home(), true); - } - - protected void gotoUrl(String url, boolean strict) { - gotoUrl(url, null, strict); - } - - protected void gotoUrl(String url) { - gotoUrl(url, null, true); - } - - protected void gotoUrl(String url, String fallBackUrl) { - gotoUrl(url, fallBackUrl, true); - } - - protected void gotoUrl(String url, String fallBackUrl, boolean strict) { - driver.get(url); - String expectedUrl; - if (fallBackUrl == null) { - expectedUrl = url; - } else { - expectedUrl = fallBackUrl; - } - checkCurrentUrl(expectedUrl, strict); - } - - /** - * Check that the current URL is the expected one. - * If it is a strict comparison, the URL should be the same that the wanted. - * If not, it only checks that the current URL start with the wanted url. - */ - protected void checkCurrentUrl(String expectedUrl, boolean strict) { - if (strict) { - Assert.assertEquals("Current url [" + driver.getCurrentUrl() + "] should be " + expectedUrl, expectedUrl, driver.getCurrentUrl()); - } else { - Assert.assertTrue("Current url [" + driver.getCurrentUrl() + "] should starts with " + expectedUrl, driver.getCurrentUrl().startsWith(expectedUrl)); - } - } - - protected WebElement findElement(By by) { - WebElement element = driver.findElement(by); - return element; - } - - protected List<WebElement> findElements(By by) { - List<WebElement> result = driver.findElements(by); - return result; - } - - /** Try to log in using the given {@code username} and {@code password}. */ - protected void connect(String username, String password) { - - // click on tologin element (display the login form) - WebElement loginClick = driver.findElement(By.id("tologin")); - loginClick.click(); - - // Find the text input element by its name - WebElement loginElement = driver.findElement(By.name("login")); - Assert.assertEquals("input", loginElement.getTagName()); - Assert.assertTrue(loginElement.isDisplayed()); - loginElement.sendKeys(username); - - WebElement passwordElement = driver.findElement(By.name("password")); - Assert.assertTrue(passwordElement.isDisplayed()); - Assert.assertEquals("input", passwordElement.getTagName()); - passwordElement.sendKeys(password); - - WebElement submit = driver.findElement(By.name("action:login")); - submit.click(); - } - - /** - * Set a value for a WebElement. - * <p/> - * This operations does 3 steps : - * <ul> - * <li>Get the WebElement thanks to its id (given in parameter)</li> - * <li>check the element is an input</li> - * <li>check the element is displayed</li> - * <li>clear the element</li> - * <li>send the wanted keys</li> - * </ul> - */ - protected void sendKeysById(String webElementId, String value) { - sendKeysBy(By.id(webElementId), value); - } - - /** - * Set a value for a WebElement. - * <p/> - * This operations does 3 steps : - * <ul> - * <li>Get the WebElement thanks to its name (given in parameter)</li> - * <li>check the element is an input</li> - * <li>check the element is displayed</li> - * <li>clear the element</li> - * <li>send the wanted keys</li> - * </ul> - */ - protected void sendKeysByName(String webElementName, String value) { - By byName = By.name(webElementName); - sendKeysBy(byName, value); - } - - /** - * Set a value for a WebElement. - * <p/> - * This operations does 3 steps : - * <ul> - * <li>Get the WebElement thanks to a {@link By} locator</li> - * <li>check the element is an input</li> - * <li>check the element is displayed</li> - * <li>clear the element</li> - * <li>send the wanted keys</li> - * </ul> - */ - protected void sendKeysBy(By by, String value) { - WebElement webElement = findElement(by); - Assert.assertEquals("input", webElement.getTagName()); - Assert.assertTrue(webElement.isDisplayed()); - webElement.sendKeys(value); - Assert.assertEquals(value, webElement.getAttribute("value")); - } - - /** - * Get a WebElement with a {@link By} locator, and check it is an input - * and that is value is the one expected. - */ - protected void checkWebElementValue(By by, String expectedValue) { - WebElement webElement = findElement(by); - Assert.assertEquals("input", webElement.getTagName()); - Assert.assertTrue(webElement.isDisplayed()); - Assert.assertEquals(expectedValue, webElement.getAttribute("value")); - } } Added: trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/it/AbstractPollenIT.java =================================================================== --- trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/it/AbstractPollenIT.java (rev 0) +++ trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/it/AbstractPollenIT.java 2012-08-26 16:34:56 UTC (rev 3632) @@ -0,0 +1,241 @@ +package org.chorem.pollen.ui.it; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.ClassRule; +import org.junit.Rule; +import org.junit.rules.TestName; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.nuiton.util.DateUtil; +import org.openqa.selenium.By; +import org.openqa.selenium.NoSuchElementException; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +import java.util.Calendar; +import java.util.Collection; +import java.util.Date; +import java.util.List; + +/** + * Base it test. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.4.5 + */ +@RunWith(value = Parameterized.class) +public abstract class AbstractPollenIT { + + /** Logger. */ + protected Log log = LogFactory.getLog(getClass()); + + @Parameterized.Parameters + public static Collection<Object[]> driverTypes() { + return WebDriverResources.driverTypes(); + } + + /** Selenium driver to use for all tests of this class. */ + @ClassRule + public static final WebDriverResources seleniumServer = new WebDriverResources(); + + /** URL fixtures. */ + protected static final PollenUrlFixtures urlFixtures = new PollenUrlFixtures(); + + /** Type of driver used by currenttest. */ + protected final Class<? extends WebDriver> driverType; + + @Rule + public final TestName testName = new TestName(); + + /** Driver used by current test. */ + protected WebDriver driver; + + protected AbstractPollenIT(Class<? extends WebDriver> driverType) { + this.driverType = driverType; + } + + @Before + public void setUp() throws Exception { + driver = seleniumServer.getDriver(driverType); + if (log.isInfoEnabled()) { + log.info("start test " + getClass().getName() + "#" + + testName.getMethodName() + + " (" + driverType.getSimpleName() + ")"); + } + + gotoUrl(urlFixtures.home(), false); + } + + @After + public void after() { + + // make sure driver came back in original state: + // go back to home page and logout if was loggued in + logout(); + } + + protected void logout() { + gotoUrl(urlFixtures.logout(), urlFixtures.home(), false); + } + + protected void gotoUrl(String url, boolean strict) { + gotoUrl(url, null, strict); + } + + protected void gotoUrl(String url) { + gotoUrl(url, null, true); + } + + protected void gotoUrl(String url, String fallBackUrl) { + gotoUrl(url, fallBackUrl, true); + } + + protected void gotoUrl(String url, String fallBackUrl, boolean strict) { + driver.get(url); + String expectedUrl; + if (fallBackUrl == null) { + expectedUrl = url; + } else { + expectedUrl = fallBackUrl; + } + checkCurrentUrl(expectedUrl, strict); + } + + /** + * Check that the current URL is the expected one. + * If it is a strict comparison, the URL should be the same that the wanted. + * If not, it only checks that the current URL start with the wanted url. + */ + protected void checkCurrentUrl(String expectedUrl, boolean strict) { + if (strict) { + Assert.assertEquals("Current url [" + driver.getCurrentUrl() + "] should be " + expectedUrl, expectedUrl, driver.getCurrentUrl()); + } else { + Assert.assertTrue("Current url [" + driver.getCurrentUrl() + "] should starts with " + expectedUrl, driver.getCurrentUrl().startsWith(expectedUrl)); + } + } + + protected void checkNoElement(By by) { + try { + findElement(by); + Assert.fail(); + } catch (NoSuchElementException e) { + Assert.assertTrue(true); + } + } + + protected WebElement findElement(By by) { + WebElement element = driver.findElement(by); + return element; + } + + protected List<WebElement> findElements(By by) { + List<WebElement> result = driver.findElements(by); + return result; + } + + /** Try to log in using the given {@code username} and {@code password}. */ + protected void connect(String username, String password) { + + // click on tologin element (display the login form) + WebElement loginClick = findElement(By.id("tologin")); + loginClick.click(); + + // Find the text input element by its name + WebElement loginElement = findElement(By.name("login")); + Assert.assertEquals("input", loginElement.getTagName()); + Assert.assertTrue(loginElement.isDisplayed()); + loginElement.sendKeys(username); + + WebElement passwordElement = findElement(By.name("password")); + Assert.assertTrue(passwordElement.isDisplayed()); + Assert.assertEquals("input", passwordElement.getTagName()); + passwordElement.sendKeys(password); + + WebElement submit = findElement(By.name("action:login")); + submit.click(); + } + + /** + * Set a value for a WebElement. + * <p/> + * This operations does 3 steps : + * <ul> + * <li>Get the WebElement thanks to its id (given in parameter)</li> + * <li>check the element is an input</li> + * <li>check the element is displayed</li> + * <li>clear the element</li> + * <li>send the wanted keys</li> + * </ul> + */ + protected void sendKeysById(String webElementId, String value) { + sendKeysBy(By.id(webElementId), value); + } + + /** + * Set a value for a WebElement. + * <p/> + * This operations does 3 steps : + * <ul> + * <li>Get the WebElement thanks to its name (given in parameter)</li> + * <li>check the element is an input</li> + * <li>check the element is displayed</li> + * <li>clear the element</li> + * <li>send the wanted keys</li> + * </ul> + */ + protected void sendKeysByName(String webElementName, String value) { + By byName = By.name(webElementName); + sendKeysBy(byName, value); + } + + /** + * Set a value for a WebElement. + * <p/> + * This operations does 3 steps : + * <ul> + * <li>Get the WebElement thanks to a {@link By} locator</li> + * <li>check the element is an input</li> + * <li>check the element is displayed</li> + * <li>clear the element</li> + * <li>send the wanted keys</li> + * </ul> + */ + protected void sendKeysBy(By by, String value) { + WebElement webElement = findElement(by); + Assert.assertEquals("input", webElement.getTagName()); + Assert.assertTrue(webElement.isDisplayed()); + webElement.sendKeys(value); + Assert.assertEquals(value, webElement.getAttribute("value")); + } + + /** + * Get a WebElement with a {@link By} locator, and check it is an input + * and that is value is the one expected. + */ + protected void checkWebElementValue(By by, String expectedValue) { + WebElement webElement = findElement(by); + Assert.assertEquals("input", webElement.getTagName()); + Assert.assertTrue(webElement.isDisplayed()); + Assert.assertEquals(expectedValue, webElement.getAttribute("value")); + } + + protected String datePattern() { + return "dd/MM/yyyy HH:mm"; + } + + protected String date(int year, int month, int day, int hour, int minute) { + Calendar instance = Calendar.getInstance(); + instance.set(year, month, day, hour, minute); + Date date = instance.getTime(); + String dateString = DateUtil.formatDate(date, datePattern()); + return dateString; + } + + protected String date(int year, int month, int day) { + return date(year, month, day, 0, 0); + } +} Property changes on: trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/it/AbstractPollenIT.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Deleted: trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/it/AbstractPollenWebDriverIT.java =================================================================== --- trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/it/AbstractPollenWebDriverIT.java 2012-08-26 16:34:10 UTC (rev 3631) +++ trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/it/AbstractPollenWebDriverIT.java 2012-08-26 16:34:56 UTC (rev 3632) @@ -1,205 +0,0 @@ -package org.chorem.pollen.ui.it; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.chorem.pollen.ui.PollenFixtures; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.ClassRule; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; - -import java.util.Collection; -import java.util.List; - -/** - * TODO - * - * @author tchemit <chemit@codelutin.com> - * @since TODO - */ -@RunWith(value = Parameterized.class) -public abstract class AbstractPollenWebDriverIT { - - /** Logger. */ - protected final Log log = LogFactory.getLog(getClass()); - - @Parameterized.Parameters - public static Collection<Object[]> driverTypes() { - return WebDriverResources.driverTypes(); - } - - @ClassRule - public static final WebDriverResources seleniumServer = new WebDriverResources(); - - protected final Class<? extends WebDriver> driverType; - - protected WebDriver driver; - - protected PollenFixtures fixtures; - - @Before - public void setUp() throws Exception { - driver = seleniumServer.getDriver(driverType); - fixtures = new PollenFixtures(); - } - - @After - public void after() { - - // make sure driver came back in original state: - // go back to home page and logout if was loggued in - - gotoUrl(fixtures.logoutURL(), fixtures.homeURL(), true); - - } - - protected AbstractPollenWebDriverIT(Class<? extends WebDriver> driverType) { - this.driverType = driverType; - } - - protected void gotoUrl(String url, boolean strict) { - gotoUrl(url, null, strict); - } - - protected void gotoUrl(String url) { - gotoUrl(url, null, true); - } - - protected void gotoUrl(String url, String fallBackUrl) { - gotoUrl(url, fallBackUrl, true); - } - - protected void gotoUrl(String url, String fallBackUrl, boolean strict) { - driver.get(url); - String expectedUrl; - if (fallBackUrl == null) { - expectedUrl = url; - } else { - expectedUrl = fallBackUrl; - } - checkCurrentUrl(expectedUrl, strict); - } - - /** - * Check that the current URL is the expected one. - * If it is a strict comparison, the URL should be the same that the wanted. - * If not, it only checks that the current URL start with the wanted url. - */ - protected void checkCurrentUrl(String expectedUrl, boolean strict) { - if (strict) { - Assert.assertEquals("Current url [" + driver.getCurrentUrl() + "] should be " + expectedUrl, expectedUrl, driver.getCurrentUrl()); - } else { - Assert.assertTrue("Current url [" + driver.getCurrentUrl() + "] should starts with " + expectedUrl, driver.getCurrentUrl().startsWith(expectedUrl)); - } - } - - protected WebElement findElement(By by) { - WebElement element = driver.findElement(by); - return element; - } - - protected List<WebElement> findElements(By by) { - List<WebElement> result = driver.findElements(by); - return result; - } - - /** Try to log in using the given {@code username} and {@code password}. */ - protected void connect(String username, String password) { - - // click on tologin element (display the login form) - WebElement loginClick = driver.findElement(By.id("tologin")); - loginClick.click(); - - // Find the text input element by its name - WebElement loginElement = driver.findElement(By.name("login")); - Assert.assertEquals("input", loginElement.getTagName()); - Assert.assertTrue(loginElement.isDisplayed()); - loginElement.sendKeys(username); - - WebElement passwordElement = driver.findElement(By.name("password")); - Assert.assertTrue(passwordElement.isDisplayed()); - Assert.assertEquals("input", passwordElement.getTagName()); - passwordElement.sendKeys(password); - - WebElement submit = driver.findElement(By.name("action:login")); - submit.click(); - } - - /** Prepare the poll with general data : one title and two choices */ - void preparePoll() { - // Go on home page - gotoUrl(fixtures.createPollURL()); - - // Set title - sendKeysByName("poll.title", "My Poll"); - - // Set first choice - sendKeysByName("textChoice_0.name", "Choix numero un"); - - // Set second choice - sendKeysByName("textChoice_1.name", "Choix numero deux"); - } - - /** - * Set a value for a WebElement. - * This operations does 3 steps : - * <ul> - * <li>Get the WebElement thanks to its id (given in parameter)</li> - * <li>check the element is an input</li> - * <li>check the element is displayed</li> - * <li>clear the element</li> - * <li>send the wanted keys</li> - * </ul> - */ - protected void sendKeysById(String webElementId, String value) { - sendKeysBy(By.id(webElementId), value); - } - - /** - * Set a value for a WebElement. - * This operations does 3 steps : - * <ul> - * <li>Get the WebElement thanks to its name (given in parameter)</li> - * <li>check the element is an input</li> - * <li>check the element is displayed</li> - * <li>clear the element</li> - * <li>send the wanted keys</li> - * </ul> - */ - protected void sendKeysByName(String webElementName, String value) { - By byName = By.name(webElementName); - sendKeysBy(byName, value); - } - - /** - * Set a value for a WebElement. - * This operations does 3 steps : - * <ul> - * <li>Get the WebElement thanks to a {@link By} locator</li> - * <li>check the element is an input</li> - * <li>check the element is displayed</li> - * <li>clear the element</li> - * <li>send the wanted keys</li> - * </ul> - */ - protected void sendKeysBy(By by, String value) { - WebElement webElement = findElement(by); - Assert.assertEquals("input", webElement.getTagName()); - Assert.assertTrue(webElement.isDisplayed()); - webElement.sendKeys(value); - Assert.assertEquals(value, webElement.getAttribute("value")); - } - - /** Get a WebElement with a {@link By} locator, and check it is an input and that is value is the one expected. */ - protected void checkWebElementValue(By by, String expectedValue) { - WebElement webElement = findElement(by); - Assert.assertEquals("input", webElement.getTagName()); - Assert.assertTrue(webElement.isDisplayed()); - Assert.assertEquals(expectedValue, webElement.getAttribute("value")); - } -} Deleted: trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/it/LoginT.java =================================================================== --- trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/it/LoginT.java 2012-08-26 16:34:10 UTC (rev 3631) +++ trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/it/LoginT.java 2012-08-26 16:34:56 UTC (rev 3632) @@ -1,62 +0,0 @@ -package org.chorem.pollen.ui.it; - -import org.junit.Assert; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; - -import java.util.List; - -/** - * TODO - * - * @author tchemit <chemit@codelutin.com> - * @since TODO - */ -public class LoginT extends AbstractPollenWebDriverIT { - - public LoginT(Class<? extends WebDriver> driverType) { - super(driverType); - } - - @Test - public void loginAdmin() throws Exception { - - gotoUrl(fixtures.homeURL()); - - connect("admin", "admin"); - - // check info_success is on - findElement(By.className("info_success")); - - // check there is a admin menu (so 4 menus) - List<WebElement> menus = findElements(By.className("menu_elt")); - Assert.assertEquals(4, menus.size()); - } - - @Test - public void loginUser() throws Exception { - - gotoUrl(fixtures.homeURL()); - - connect("user", "user"); - - // check info_success is on - findElement(By.className("info_success")); - - // check there is not a admin menu (so 3 menus) - List<WebElement> menus = findElements(By.className("menu_elt")); - Assert.assertEquals(3, menus.size()); - } - - @Test - public void badLogin() throws Exception { - - gotoUrl(fixtures.homeURL()); - - connect("admin", "admin" + System.currentTimeMillis()); - - findElement(By.className("info_error")); - } -} Modified: trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/it/PollenUrlFixtures.java =================================================================== --- trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/it/PollenUrlFixtures.java 2012-08-26 16:34:10 UTC (rev 3631) +++ trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/it/PollenUrlFixtures.java 2012-08-26 16:34:56 UTC (rev 3632) @@ -25,12 +25,14 @@ */ private static enum POLLEN_URL { + //-- Security urls --// poll_creator_required("security/illegal_access"), poll_access_required("security/illegal_access"), poll_required("security/illegal_access"), - admin_required("security/illegal_access"), - connected_required("security/illegal_access"), + admin_required("security/admin_required"), + connected_required("security/connected_required"), + //-- user urls --// home("home"), createdList("user/createdList"), invitedList("user/invitedList"), @@ -38,12 +40,15 @@ favoriteLists("user/favoriteLists"), logout("user/logout"), + //-- admin urls --// pollsList("admin/pollsList"), usersList("admin/usersList"), + //-- poll urls --// createPoll("poll/create"), editPoll("poll/edit", "!input"), voteforPoll("poll/votefor"), + moderatePoll("poll/moderate"), summaryPoll("poll/summary"); private final String path; @@ -180,13 +185,21 @@ } public String summaryPoll(PollUri pollUri) { - return POLLEN_URL.summaryPoll.toURL(this,pollUri); + return POLLEN_URL.summaryPoll.toURL(this, pollUri); } public String summaryPoll() { return POLLEN_URL.summaryPoll.toURL(this); } + public String moderatePoll(PollUri pollUri) { + return POLLEN_URL.moderatePoll.toURL(this, pollUri); + } + + public String moderatePoll() { + return POLLEN_URL.moderatePoll.toURL(this); + } + public String logout() { return POLLEN_URL.logout.toURL(this); } Modified: trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/it/WebDriverResources.java =================================================================== --- trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/it/WebDriverResources.java 2012-08-26 16:34:10 UTC (rev 3631) +++ trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/it/WebDriverResources.java 2012-08-26 16:34:56 UTC (rev 3632) @@ -92,11 +92,8 @@ @Override protected void starting(Description description) { - String testName = - description.getClassName() + "#" + description.getMethodName(); - if (log.isInfoEnabled()) { - log.info("Start test " + testName); + log.info("Start class test " + description.getClassName()); } } @@ -105,14 +102,20 @@ // close all servers - for (WebDriver webDriver : servers.values()) { - try { - webDriver.quit(); - } catch (Exception e) { - if (log.isErrorEnabled()) { - log.error("Could not close nicely driver " + webDriver, e); + try { + for (WebDriver webDriver : servers.values()) { + try { + webDriver.quit(); + } catch (Exception e) { + if (log.isErrorEnabled()) { + log.error("Could not close nicely driver " + webDriver, e); + } } } + } finally { + + // clear servers + servers.clear(); } } Deleted: trunk/pollen-ui-struts2/src/test/resources/log4j.properties =================================================================== --- trunk/pollen-ui-struts2/src/test/resources/log4j.properties 2012-08-26 16:34:10 UTC (rev 3631) +++ trunk/pollen-ui-struts2/src/test/resources/log4j.properties 2012-08-26 16:34:56 UTC (rev 3632) @@ -1,39 +0,0 @@ -### -# #%L -# Pollen :: UI (struts2) -# $Id$ -# $HeadURL$ -# %% -# Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit -# %% -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# #L% -### -log4j.rootCategory=ERROR, console, file - -log4j.appender.console=org.apache.log4j.ConsoleAppender -log4j.appender.console.layout=org.apache.log4j.PatternLayout -log4j.appender.console.layout.ConversionPattern=[%p] %c %m%n - -log4j.logger.org.chorem.pollen=INFO -log4j.logger.org.chorem.pollen.ui.PollenShiroIsAdministratorFilter=DEBUG -log4j.logger.org.nuiton=INFO - -# FileAppender : need to have pollen.log.dir in system properties at application startup -log4j.appender.file=org.apache.log4j.RollingFileAppender -log4j.appender.file.File=${basedir}/target/pollen.log -log4j.appender.file.MaxFileSize=10MB -log4j.appender.file.MaxBackupIndex=4 -log4j.appender.file.layout=org.apache.log4j.PatternLayout -log4j.appender.file.layout.ConversionPattern=%d{yyyy/MM/dd hh:mm:ss} %5p (%F:%L) %m%n Deleted: trunk/pollen-ui-struts2/src/test/resources/pollen-test.properties =================================================================== --- trunk/pollen-ui-struts2/src/test/resources/pollen-test.properties 2012-08-26 16:34:10 UTC (rev 3631) +++ trunk/pollen-ui-struts2/src/test/resources/pollen-test.properties 2012-08-26 16:34:56 UTC (rev 3632) @@ -1,44 +0,0 @@ -### -# #%L -# Pollen :: UI (struts2) Test -# $Id$ -# $HeadURL$ -# %% -# Copyright (C) 2009 - 2012 CodeLutin -# %% -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# #L% -### - -# Db configuration -hibernate.dialect=org.hibernate.dialect.H2Dialect -hibernate.connection.username=sa -hibernate.connection.password=sa -hibernate.connection.driver_class=org.h2.Driver -hibernate.show_sql=false -hibernate.hbm2ddl.auto=update - -# Database migration configuration -topia.service.migration=org.nuiton.topia.migration.TopiaMigrationEngine -topia.service.migration.callback=org.chorem.pollen.entities.migration.PollenMigrationCallback -topia.service.migration.showSql=false - -# Version de l'application -pollen.version=${project.version} - -# répertoire des données (chaque execution utilisera un sous répertoire) -pollen.dataDirectory=${basedir}/target/surefire-workdir/pollen-data - -# emplacement de la base de test à utiliser (elle sera recopié à chaque démarrage d'un build de tests) -incomingDatabase=${basedir}/target/test-classes/pollendb.h2.db \ No newline at end of file Deleted: trunk/pollen-ui-struts2/src/test/resources/pollendb.h2.db =================================================================== (Binary files differ) Deleted: trunk/pollen-ui-struts2/src/test/resources/web-test.xml =================================================================== --- trunk/pollen-ui-struts2/src/test/resources/web-test.xml 2012-08-26 16:34:10 UTC (rev 3631) +++ trunk/pollen-ui-struts2/src/test/resources/web-test.xml 2012-08-26 16:34:56 UTC (rev 3632) @@ -1,103 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - #%L - Pollen :: UI (struts2) - $Id$ - $HeadURL$ - %% - Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit - %% - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - #L% - --> - -<web-app id="Pollen" version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> - - <display-name>Pollen</display-name> - - <filter> - <filter-name>topiaTransaction</filter-name> - <filter-class>org.chorem.pollen.ui.PollenTopiaTransactionFilter</filter-class> - </filter> - - <filter> - <filter-name>struts-prepare</filter-name> - <filter-class> - org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter - </filter-class> - </filter> - <filter> - <filter-name>ShiroFilter</filter-name> - <filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class> - </filter> - - <filter> - <filter-name>sitemesh</filter-name> - <filter-class>com.opensymphony.sitemesh.webapp.SiteMeshFilter</filter-class> - </filter> - - <filter> - <filter-name>struts-execute</filter-name> - <filter-class> - org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter - </filter-class> - </filter> - - <filter-mapping> - <filter-name>topiaTransaction</filter-name> - <url-pattern>/*</url-pattern> - </filter-mapping> - - <filter-mapping> - <filter-name>ShiroFilter</filter-name> - <url-pattern>/*</url-pattern> - <dispatcher>REQUEST</dispatcher> - <dispatcher>FORWARD</dispatcher> - <dispatcher>INCLUDE</dispatcher> - <dispatcher>ERROR</dispatcher> - </filter-mapping> - - <filter-mapping> - <filter-name>struts-prepare</filter-name> - <url-pattern>/*</url-pattern> - </filter-mapping> - - <filter-mapping> - <filter-name>sitemesh</filter-name> - <url-pattern>/*</url-pattern> - </filter-mapping> - - <filter-mapping> - <filter-name>struts-execute</filter-name> - <url-pattern>/*</url-pattern> - </filter-mapping> - - <listener> - <description>Init</description> - <listener-class>org.chorem.pollen.ui.PollenTestApplicationListener</listener-class> - </listener> - - <listener> - <description>Shiro security layer</description> - <listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class> - </listener> - - <welcome-file-list> - <welcome-file>/</welcome-file> - <welcome-file>index.jsp</welcome-file> - <welcome-file>home</welcome-file> - </welcome-file-list> -</web-app>