r3642 - in trunk/pollen-ui-struts2/src: it/createPoll/src/test/java/org/chorem/pollen/ui/it it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/anonymousPoll it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/creatorOnly it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/everybody it/pollVoteVisibility/src/test/
Author: tchemit Date: 2012-08-27 14:08:51 +0200 (Mon, 27 Aug 2012) New Revision: 3642 Url: http://chorem.org/repositories/revision/pollen/3642 Log: drivers are only init once by it + improve test skeletons Added: trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/CreateFreeDatePollIT.java trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/CreateFreeTextPollIT.java trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/CreateRestrictedTextPollIT.java trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/CreateTextPollForGroupIT.java trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/PollenTestSuite.java trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/PollenTestSuite.java trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/ trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/anonymousPoll/ trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/creatorOnly/ trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/everybody/ trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/java-info.java trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/voterOnly/ trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/restrictedpoll/ trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/restrictedpoll/java-info.java trunk/pollen-ui-struts2/src/it/security/src/test/java/org/chorem/pollen/ui/it/PollenTestSuite.java trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/it/CleanDrivers.java Removed: 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/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/anonymousPoll/ trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/creatorOnly/ trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/everybody/ trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/voterOnly/ Modified: trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/AbstractIT.java trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/anonymousPoll/AnonymousFreePollByAdminIT.java trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/anonymousPoll/AnonymousFreePollByConnectedIT.java trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/anonymousPoll/AnonymousFreePollByNotConnectedIT.java trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/creatorOnly/CreatorOnlyFreePollByAdminIT.java trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/creatorOnly/CreatorOnlyFreePollByConnectedIT.java trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/creatorOnly/CreatorOnlyFreePollByNotConnectedIT.java trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/everybody/EverybodyFreePollByAdminIT.java trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/everybody/EverybodyFreePollByConnectedIT.java trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/everybody/EverybodyFreePollByNotConnectedIT.java trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/voterOnly/VoterOnlyFreePollByAdminIT.java trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/voterOnly/VoterOnlyFreePollByConnectedIT.java trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/voterOnly/VoterOnlyFreePollByNotConnectedIT.java trunk/pollen-ui-struts2/src/it/pollen-ui-it/pom.xml trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/it/WebDriverResources.java Copied: trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/CreateFreeDatePollIT.java (from rev 3640, 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/CreateFreeDatePollIT.java (rev 0) +++ trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/CreateFreeDatePollIT.java 2012-08-27 12:08:51 UTC (rev 3642) @@ -0,0 +1,307 @@ +package org.chorem.pollen.ui.it; +/* + * #%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% + */ + +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 CreateFreeDatePollIT extends AbstractPollenIT { + + public CreateFreeDatePollIT(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/CreateFreeDatePollIT.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Deleted: 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/CreateFreeDatePollSIT.java 2012-08-27 09:33:29 UTC (rev 3641) +++ trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/CreateFreeDatePollSIT.java 2012-08-27 12:08:51 UTC (rev 3642) @@ -1,307 +0,0 @@ -package org.chorem.pollen.ui.it; -/* - * #%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% - */ - -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); - } - -} Copied: trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/CreateFreeTextPollIT.java (from rev 3640, 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/CreateFreeTextPollIT.java (rev 0) +++ trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/CreateFreeTextPollIT.java 2012-08-27 12:08:51 UTC (rev 3642) @@ -0,0 +1,462 @@ +package org.chorem.pollen.ui.it; +/* + * #%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% + */ + +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 CreateFreeTextPollIT extends AbstractPollenIT { + + public CreateFreeTextPollIT(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/CreateFreeTextPollIT.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Deleted: 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/CreateFreeTextPollSIT.java 2012-08-27 09:33:29 UTC (rev 3641) +++ trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/CreateFreeTextPollSIT.java 2012-08-27 12:08:51 UTC (rev 3642) @@ -1,462 +0,0 @@ -package org.chorem.pollen.ui.it; -/* - * #%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% - */ - -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); - } - -} Copied: trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/CreateRestrictedTextPollIT.java (from rev 3640, 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/CreateRestrictedTextPollIT.java (rev 0) +++ trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/CreateRestrictedTextPollIT.java 2012-08-27 12:08:51 UTC (rev 3642) @@ -0,0 +1,308 @@ +package org.chorem.pollen.ui.it; +/* + * #%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% + */ + +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 CreateRestrictedTextPollIT extends AbstractPollenIT { + + public CreateRestrictedTextPollIT(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/CreateRestrictedTextPollIT.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Deleted: 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/CreateRestrictedTextPollSIT.java 2012-08-27 09:33:29 UTC (rev 3641) +++ trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/CreateRestrictedTextPollSIT.java 2012-08-27 12:08:51 UTC (rev 3642) @@ -1,308 +0,0 @@ -package org.chorem.pollen.ui.it; -/* - * #%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% - */ - -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"); - } - -} Copied: trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/CreateTextPollForGroupIT.java (from rev 3640, 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/java/org/chorem/pollen/ui/it/CreateTextPollForGroupIT.java (rev 0) +++ trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/CreateTextPollForGroupIT.java 2012-08-27 12:08:51 UTC (rev 3642) @@ -0,0 +1,484 @@ +package org.chorem.pollen.ui.it; +/* + * #%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% + */ + +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 CreateTextPollForGroupIT extends AbstractPollenIT { + + public CreateTextPollForGroupIT(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/CreateTextPollForGroupIT.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Deleted: 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/java/org/chorem/pollen/ui/it/CreateTextPollForGroupSIT.java 2012-08-27 09:33:29 UTC (rev 3641) +++ trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/CreateTextPollForGroupSIT.java 2012-08-27 12:08:51 UTC (rev 3642) @@ -1,484 +0,0 @@ -package org.chorem.pollen.ui.it; -/* - * #%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% - */ - -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"); - } - -} Added: trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/PollenTestSuite.java =================================================================== --- trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/PollenTestSuite.java (rev 0) +++ trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/PollenTestSuite.java 2012-08-27 12:08:51 UTC (rev 3642) @@ -0,0 +1,26 @@ +package org.chorem.pollen.ui.it; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * Tests to execute in that it. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.4.5 + */ +@RunWith(Suite.class) +@Suite.SuiteClasses( + { + CreateFreeTextPollIT.class, + CreateFreeDatePollIT.class, + CreateRestrictedTextPollIT.class, + CreateTextPollForGroupIT.class, + + // clean drivers + CleanDrivers.class + } + +) +public class PollenTestSuite { +} Property changes on: trunk/pollen-ui-struts2/src/it/createPoll/src/test/java/org/chorem/pollen/ui/it/PollenTestSuite.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/AbstractIT.java =================================================================== --- trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/AbstractIT.java 2012-08-27 09:33:29 UTC (rev 3641) +++ trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/AbstractIT.java 2012-08-27 12:08:51 UTC (rev 3642) @@ -56,6 +56,10 @@ adminVotePollUri = newPollUri(adminVoteId); } + protected PollUri newPollUri(String accountId) { + return PollUri.newPollUri(pollId, accountId); + } + protected final void canNotModifyAnyVote() { checkCanNotModifiyVote(notConnectedVotePollUri); checkCanNotModifiyVote(connectedVotePollUri); Added: trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/PollenTestSuite.java =================================================================== --- trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/PollenTestSuite.java (rev 0) +++ trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/PollenTestSuite.java 2012-08-27 12:08:51 UTC (rev 3642) @@ -0,0 +1,47 @@ +package org.chorem.pollen.ui.it; + +import org.chorem.pollen.ui.it.freepoll.anonymousPoll.AnonymousFreePollByAdminIT; +import org.chorem.pollen.ui.it.freepoll.anonymousPoll.AnonymousFreePollByConnectedIT; +import org.chorem.pollen.ui.it.freepoll.anonymousPoll.AnonymousFreePollByNotConnectedIT; +import org.chorem.pollen.ui.it.freepoll.creatorOnly.CreatorOnlyFreePollByAdminIT; +import org.chorem.pollen.ui.it.freepoll.creatorOnly.CreatorOnlyFreePollByConnectedIT; +import org.chorem.pollen.ui.it.freepoll.creatorOnly.CreatorOnlyFreePollByNotConnectedIT; +import org.chorem.pollen.ui.it.freepoll.everybody.EverybodyFreePollByAdminIT; +import org.chorem.pollen.ui.it.freepoll.everybody.EverybodyFreePollByConnectedIT; +import org.chorem.pollen.ui.it.freepoll.everybody.EverybodyFreePollByNotConnectedIT; +import org.chorem.pollen.ui.it.freepoll.voterOnly.VoterOnlyFreePollByAdminIT; +import org.chorem.pollen.ui.it.freepoll.voterOnly.VoterOnlyFreePollByConnectedIT; +import org.chorem.pollen.ui.it.freepoll.voterOnly.VoterOnlyFreePollByNotConnectedIT; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * Tests to execute in that it. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.4.5 + */ +@RunWith(Suite.class) +@Suite.SuiteClasses( + { + AnonymousFreePollByNotConnectedIT.class, + AnonymousFreePollByConnectedIT.class, + AnonymousFreePollByAdminIT.class, + + CreatorOnlyFreePollByNotConnectedIT.class, + CreatorOnlyFreePollByConnectedIT.class, + CreatorOnlyFreePollByAdminIT.class, + + VoterOnlyFreePollByNotConnectedIT.class, + VoterOnlyFreePollByConnectedIT.class, + VoterOnlyFreePollByAdminIT.class, + + EverybodyFreePollByNotConnectedIT.class, + EverybodyFreePollByConnectedIT.class, + EverybodyFreePollByAdminIT.class, + + CleanDrivers.class + } +) +public class PollenTestSuite { +} Property changes on: trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/PollenTestSuite.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/anonymousPoll/AnonymousFreePollByAdminIT.java =================================================================== --- trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/anonymousPoll/AnonymousFreePollByAdminIT.java 2012-08-26 23:18:28 UTC (rev 3640) +++ trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/anonymousPoll/AnonymousFreePollByAdminIT.java 2012-08-27 12:08:51 UTC (rev 3642) @@ -1,4 +1,4 @@ -package org.chorem.pollen.ui.it.anonymousPoll; +package org.chorem.pollen.ui.it.freepoll.anonymousPoll; /* * #%L * Pollen :: UI (struts2) Modified: trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/anonymousPoll/AnonymousFreePollByConnectedIT.java =================================================================== --- trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/anonymousPoll/AnonymousFreePollByConnectedIT.java 2012-08-26 23:18:28 UTC (rev 3640) +++ trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/anonymousPoll/AnonymousFreePollByConnectedIT.java 2012-08-27 12:08:51 UTC (rev 3642) @@ -1,4 +1,4 @@ -package org.chorem.pollen.ui.it.anonymousPoll; +package org.chorem.pollen.ui.it.freepoll.anonymousPoll; /* * #%L * Pollen :: UI (struts2) Modified: trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/anonymousPoll/AnonymousFreePollByNotConnectedIT.java =================================================================== --- trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/anonymousPoll/AnonymousFreePollByNotConnectedIT.java 2012-08-26 23:18:28 UTC (rev 3640) +++ trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/anonymousPoll/AnonymousFreePollByNotConnectedIT.java 2012-08-27 12:08:51 UTC (rev 3642) @@ -1,4 +1,4 @@ -package org.chorem.pollen.ui.it.anonymousPoll; +package org.chorem.pollen.ui.it.freepoll.anonymousPoll; /* * #%L * Pollen :: UI (struts2) Modified: trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/creatorOnly/CreatorOnlyFreePollByAdminIT.java =================================================================== --- trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/creatorOnly/CreatorOnlyFreePollByAdminIT.java 2012-08-26 23:18:28 UTC (rev 3640) +++ trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/creatorOnly/CreatorOnlyFreePollByAdminIT.java 2012-08-27 12:08:51 UTC (rev 3642) @@ -1,4 +1,4 @@ -package org.chorem.pollen.ui.it.creatorOnly; +package org.chorem.pollen.ui.it.freepoll.creatorOnly; /* * #%L * Pollen :: UI (struts2) Modified: trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/creatorOnly/CreatorOnlyFreePollByConnectedIT.java =================================================================== --- trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/creatorOnly/CreatorOnlyFreePollByConnectedIT.java 2012-08-26 23:18:28 UTC (rev 3640) +++ trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/creatorOnly/CreatorOnlyFreePollByConnectedIT.java 2012-08-27 12:08:51 UTC (rev 3642) @@ -1,4 +1,4 @@ -package org.chorem.pollen.ui.it.creatorOnly; +package org.chorem.pollen.ui.it.freepoll.creatorOnly; /* * #%L * Pollen :: UI (struts2) Modified: trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/creatorOnly/CreatorOnlyFreePollByNotConnectedIT.java =================================================================== --- trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/creatorOnly/CreatorOnlyFreePollByNotConnectedIT.java 2012-08-26 23:18:28 UTC (rev 3640) +++ trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/creatorOnly/CreatorOnlyFreePollByNotConnectedIT.java 2012-08-27 12:08:51 UTC (rev 3642) @@ -1,4 +1,4 @@ -package org.chorem.pollen.ui.it.creatorOnly; +package org.chorem.pollen.ui.it.freepoll.creatorOnly; /* * #%L * Pollen :: UI (struts2) Modified: trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/everybody/EverybodyFreePollByAdminIT.java =================================================================== --- trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/everybody/EverybodyFreePollByAdminIT.java 2012-08-26 23:18:28 UTC (rev 3640) +++ trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/everybody/EverybodyFreePollByAdminIT.java 2012-08-27 12:08:51 UTC (rev 3642) @@ -1,4 +1,4 @@ -package org.chorem.pollen.ui.it.everybody; +package org.chorem.pollen.ui.it.freepoll.everybody; /* * #%L * Pollen :: UI (struts2) Modified: trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/everybody/EverybodyFreePollByConnectedIT.java =================================================================== --- trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/everybody/EverybodyFreePollByConnectedIT.java 2012-08-26 23:18:28 UTC (rev 3640) +++ trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/everybody/EverybodyFreePollByConnectedIT.java 2012-08-27 12:08:51 UTC (rev 3642) @@ -1,4 +1,4 @@ -package org.chorem.pollen.ui.it.everybody; +package org.chorem.pollen.ui.it.freepoll.everybody; /* * #%L * Pollen :: UI (struts2) Modified: trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/everybody/EverybodyFreePollByNotConnectedIT.java =================================================================== --- trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/everybody/EverybodyFreePollByNotConnectedIT.java 2012-08-26 23:18:28 UTC (rev 3640) +++ trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/everybody/EverybodyFreePollByNotConnectedIT.java 2012-08-27 12:08:51 UTC (rev 3642) @@ -1,4 +1,4 @@ -package org.chorem.pollen.ui.it.everybody; +package org.chorem.pollen.ui.it.freepoll.everybody; /* * #%L * Pollen :: UI (struts2) Added: trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/java-info.java =================================================================== --- trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/java-info.java (rev 0) +++ trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/java-info.java 2012-08-27 12:08:51 UTC (rev 3642) @@ -0,0 +1,7 @@ +package org.chorem.pollen.ui.it.freepoll; +/** + * To test on free poll. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.4.5 + */ \ No newline at end of file Property changes on: trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/java-info.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/voterOnly/VoterOnlyFreePollByAdminIT.java =================================================================== --- trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/voterOnly/VoterOnlyFreePollByAdminIT.java 2012-08-26 23:18:28 UTC (rev 3640) +++ trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/voterOnly/VoterOnlyFreePollByAdminIT.java 2012-08-27 12:08:51 UTC (rev 3642) @@ -1,4 +1,4 @@ -package org.chorem.pollen.ui.it.voterOnly; +package org.chorem.pollen.ui.it.freepoll.voterOnly; /* * #%L * Pollen :: UI (struts2) Modified: trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/voterOnly/VoterOnlyFreePollByConnectedIT.java =================================================================== --- trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/voterOnly/VoterOnlyFreePollByConnectedIT.java 2012-08-26 23:18:28 UTC (rev 3640) +++ trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/voterOnly/VoterOnlyFreePollByConnectedIT.java 2012-08-27 12:08:51 UTC (rev 3642) @@ -1,4 +1,4 @@ -package org.chorem.pollen.ui.it.voterOnly; +package org.chorem.pollen.ui.it.freepoll.voterOnly; /* * #%L * Pollen :: UI (struts2) Modified: trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/voterOnly/VoterOnlyFreePollByNotConnectedIT.java =================================================================== --- trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/voterOnly/VoterOnlyFreePollByNotConnectedIT.java 2012-08-26 23:18:28 UTC (rev 3640) +++ trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/freepoll/voterOnly/VoterOnlyFreePollByNotConnectedIT.java 2012-08-27 12:08:51 UTC (rev 3642) @@ -1,4 +1,4 @@ -package org.chorem.pollen.ui.it.voterOnly; +package org.chorem.pollen.ui.it.freepoll.voterOnly; /* * #%L * Pollen :: UI (struts2) Added: trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/restrictedpoll/java-info.java =================================================================== --- trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/restrictedpoll/java-info.java (rev 0) +++ trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/restrictedpoll/java-info.java 2012-08-27 12:08:51 UTC (rev 3642) @@ -0,0 +1,7 @@ +package org.chorem.pollen.ui.it.restrictedpoll; +/** + * To test on restricted poll. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.4.5 + */ \ No newline at end of file Property changes on: trunk/pollen-ui-struts2/src/it/pollVoteVisibility/src/test/java/org/chorem/pollen/ui/it/restrictedpoll/java-info.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native 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-27 09:33:29 UTC (rev 3641) +++ trunk/pollen-ui-struts2/src/it/pollen-ui-it/pom.xml 2012-08-27 12:08:51 UTC (rev 3642) @@ -363,15 +363,15 @@ <plugin> <artifactId>maven-surefire-plugin</artifactId> <executions> - <execution> + <id>run-tests</id> <phase>integration-test</phase> <goals> <goal>test</goal> </goals> <configuration> <includes> - <include>**/*IT.java</include> + <include>**/PollenTestSuite.java</include> </includes> <systemPropertyVariables> <pollenServerPort>${pollenServerPort}</pollenServerPort> Added: trunk/pollen-ui-struts2/src/it/security/src/test/java/org/chorem/pollen/ui/it/PollenTestSuite.java =================================================================== --- trunk/pollen-ui-struts2/src/it/security/src/test/java/org/chorem/pollen/ui/it/PollenTestSuite.java (rev 0) +++ trunk/pollen-ui-struts2/src/it/security/src/test/java/org/chorem/pollen/ui/it/PollenTestSuite.java 2012-08-27 12:08:51 UTC (rev 3642) @@ -0,0 +1,23 @@ +package org.chorem.pollen.ui.it; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * Tests to execute in that it. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.4.5 + */ +@RunWith(Suite.class) +@Suite.SuiteClasses( + { + LoginSIT.class, + SecurityAccessSIT.class, + + CleanDrivers.class + } + +) +public class PollenTestSuite { +} Property changes on: trunk/pollen-ui-struts2/src/it/security/src/test/java/org/chorem/pollen/ui/it/PollenTestSuite.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/it/CleanDrivers.java =================================================================== --- trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/it/CleanDrivers.java (rev 0) +++ trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/it/CleanDrivers.java 2012-08-27 12:08:51 UTC (rev 3642) @@ -0,0 +1,26 @@ +package org.chorem.pollen.ui.it; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.Test; + +/** + * A dummy test to close any used drivers while its. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.4.5 + */ +public class CleanDrivers { + + /** Logger. */ + private static final Log log = LogFactory.getLog(CleanDrivers.class); + + @Test + public void cleanDrivers() { + + if (log.isInfoEnabled()) { + log.info("Clean drivers"); + } + WebDriverResources.cleanDrivers(); + } +} Property changes on: trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/it/CleanDrivers.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native 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-27 09:33:29 UTC (rev 3641) +++ trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/it/WebDriverResources.java 2012-08-27 12:08:51 UTC (rev 3642) @@ -22,12 +22,12 @@ * #L% */ +import com.google.common.base.Preconditions; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.rules.TestWatcher; -import org.junit.runner.Description; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.htmlunit.HtmlUnitDriver; @@ -48,112 +48,84 @@ /** Logger. */ private static final Log log = LogFactory.getLog(WebDriverResources.class); - protected static Collection<Object[]> safeDrivers; + protected static Collection<Object[]> driverTypes; - protected Map<Class<? extends WebDriver>, WebDriver> servers = + protected static Map<Class<? extends WebDriver>, WebDriver> drivers = Maps.newHashMap(); public static Collection<Object[]> driverTypes() { - if (safeDrivers == null) { - - List<Class<? extends WebDriver>> allDrivers = Lists.newArrayList(); -// allDrivers.add(HtmlUnitDriver.class); - allDrivers.add(FirefoxDriver.class); -// allDrivers.add(ChromeDriver.class); -// allDrivers.add(InternetExplorerDriver.class); -// allDrivers.add(SafariDriver.class); - - List<Class<?>> checkedDrivers = Lists.newArrayList(); - for (Class<? extends WebDriver> driver : allDrivers) { - boolean ok = checkDriver(driver); - if (ok) { - checkedDrivers.add(driver); - } - } - Object[][] data = new Object[checkedDrivers.size()][1]; - int i = 0; - for (Class<?> checkedDriver : checkedDrivers) { - data[i++][0] = checkedDriver; - } - safeDrivers = Arrays.asList(data); + if (driverTypes == null) { + driverTypes = prepareDrivers(); } - - return safeDrivers; + Preconditions.checkNotNull(driverTypes); + return driverTypes; } - - private static boolean checkDriver(Class<? extends WebDriver> driverType) { - - boolean result = false; - try { - createDriver(driverType, true); - result = true; - } catch (Exception e) { - - // can not use this driver - if (log.isInfoEnabled()) { - log.info("Can not use driver " + driverType.getName(), e); - } - } - - return result; - } - public <W extends WebDriver> W getDriver(Class<W> driverType) throws Exception { - W result = (W) servers.get(driverType); - if (result == null) { - result = createDriver(driverType, false); - - if (HtmlUnitDriver.class == driverType) { - ((HtmlUnitDriver) result).setJavascriptEnabled(true); - } - servers.put(driverType, result); - } + Preconditions.checkNotNull(driverType); + W result = (W) drivers.get(driverType); + Preconditions.checkNotNull(result); return result; } - @Override - protected void starting(Description description) { - if (log.isInfoEnabled()) { - log.info("Start class test " + description.getClassName()); - } - } - - @Override - protected void finished(Description description) { - - // close all servers - + public static void cleanDrivers() { try { - for (WebDriver webDriver : servers.values()) { + for (WebDriver webDriver : drivers.values()) { try { webDriver.quit(); } catch (Exception e) { if (log.isErrorEnabled()) { - log.error("Could not close nicely driver " + webDriver, e); + log.error("Could not close nicely driver " + + webDriver, e); } } } } finally { // clear servers - servers.clear(); + drivers.clear(); } } - protected static <W extends WebDriver> W createDriver(Class<W> driverType, - boolean clear) - throws Exception { - W result = driverType.getConstructor().newInstance(); + public static List<Object[]> prepareDrivers() { - if (clear) { - result.close(); + List<Class<? extends WebDriver>> allDrivers = Lists.newArrayList(); +// allDrivers.add(HtmlUnitDriver.class); + allDrivers.add(FirefoxDriver.class); +// allDrivers.add(ChromeDriver.class); +// allDrivers.add(InternetExplorerDriver.class); +// allDrivers.add(SafariDriver.class); + + List<Class<?>> checkedDrivers = Lists.newArrayList(); + for (Class<? extends WebDriver> driverType : allDrivers) { + + try { + WebDriver driver = createDriver(driverType); + checkedDrivers.add(driverType); + drivers.put(driverType, driver); + } catch (Exception e) { + + // can not use this driver + if (log.isInfoEnabled()) { + log.info("Can not use driver " + driverType.getName(), e); + } + } } + Object[][] data = new Object[checkedDrivers.size()][1]; + int i = 0; + for (Class<?> checkedDriver : checkedDrivers) { + data[i++][0] = checkedDriver; + } + return Arrays.asList(data); + } + private static <W extends WebDriver> W createDriver(Class<W> driverType) + throws Exception { + W result = driverType.getConstructor().newInstance(); + if (HtmlUnitDriver.class == driverType) { ((HtmlUnitDriver) result).setJavascriptEnabled(true); } return result; } - }
participants (1)
-
tchemit@users.chorem.org