[seam-commits] Seam SVN: r9933 - in trunk: src/test/ftest and 11 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Thu Jan 15 06:04:37 EST 2009
Author: jharting
Date: 2009-01-15 06:04:37 -0500 (Thu, 15 Jan 2009)
New Revision: 9933
Added:
trunk/src/test/ftest/examples/registration/
trunk/src/test/ftest/examples/registration/build.xml
trunk/src/test/ftest/examples/registration/jboss-embedded.xml
trunk/src/test/ftest/examples/registration/jboss.xml
trunk/src/test/ftest/examples/registration/src/
trunk/src/test/ftest/examples/registration/src/org/
trunk/src/test/ftest/examples/registration/src/org/jboss/
trunk/src/test/ftest/examples/registration/src/org/jboss/seam/
trunk/src/test/ftest/examples/registration/src/org/jboss/seam/example/
trunk/src/test/ftest/examples/registration/src/org/jboss/seam/example/registration/
trunk/src/test/ftest/examples/registration/src/org/jboss/seam/example/registration/test/
trunk/src/test/ftest/examples/registration/src/org/jboss/seam/example/registration/test/selenium/
trunk/src/test/ftest/examples/registration/src/org/jboss/seam/example/registration/test/selenium/RegistrationTest.java
trunk/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeamSelenium.java
Modified:
trunk/examples/registration/view/register.xhtml
trunk/src/test/ftest/build.xml
trunk/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeamSeleniumTest.java
Log:
JBSEAM-3690 Added tests for registration example
Modified: trunk/examples/registration/view/register.xhtml
===================================================================
--- trunk/examples/registration/view/register.xhtml 2009-01-14 21:11:57 UTC (rev 9932)
+++ trunk/examples/registration/view/register.xhtml 2009-01-15 11:04:37 UTC (rev 9933)
@@ -11,16 +11,16 @@
</head>
<body>
<f:view>
- <h:form>
+ <h:form id="registration">
<s:validateAll>
<h:panelGrid columns="2">
- Username: <h:inputText value="#{user.username}" required="true"/>
- Real Name: <h:inputText value="#{user.name}" required="true"/>
- Password: <h:inputSecret value="#{user.password}" required="true"/>
+ Username: <h:inputText id="username" value="#{user.username}" required="true"/>
+ Real Name: <h:inputText id="name" value="#{user.name}" required="true"/>
+ Password: <h:inputSecret id="password" value="#{user.password}" required="true"/>
</h:panelGrid>
</s:validateAll>
- <h:messages/>
- <h:commandButton value="Register" action="#{register.register}"/>
+ <h:messages id="messages"/>
+ <h:commandButton id="register" value="Register" action="#{register.register}"/>
</h:form>
</f:view>
</body>
Modified: trunk/src/test/ftest/build.xml
===================================================================
--- trunk/src/test/ftest/build.xml 2009-01-14 21:11:57 UTC (rev 9932)
+++ trunk/src/test/ftest/build.xml 2009-01-15 11:04:37 UTC (rev 9933)
@@ -62,6 +62,7 @@
<testexample name="nestedbooking" />
<testexample name="numberguess" />
<testexample name="quartz" />
+ <testexample name="registration" />
<testexample name="seampay" />
<testexample name="spring" />
<testexample name="wicket" />
@@ -75,6 +76,7 @@
<testexample name="blog" />
<testexample name="dvdstore" />
<testexample name="numberguess" />
+ <testexample name="registration" />
<testexample name="seampay" />
<testexample name="booking" />
<testexample name="jpa" />
@@ -134,6 +136,7 @@
<cleanexample name="nestedbooking" />
<cleanexample name="numberguess" />
<cleanexample name="quartz" />
+ <cleanexample name="registration" />
<cleanexample name="seampay" />
<cleanexample name="spring" />
<cleanexample name="wicket" />
@@ -152,6 +155,7 @@
<undeployexample name="nestedbooking" />
<undeployexample name="numberguess" />
<undeployexample name="quartz" />
+ <undeployexample name="registration" />
<undeployexample name="seampay" />
<undeployexample name="spring" />
<undeployexample name="wicket" />
Added: trunk/src/test/ftest/examples/registration/build.xml
===================================================================
--- trunk/src/test/ftest/examples/registration/build.xml (rev 0)
+++ trunk/src/test/ftest/examples/registration/build.xml 2009-01-15 11:04:37 UTC (rev 9933)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+JBoss, Home of Professional Open Source
+Copyright 2008, Red Hat Middleware LLC, and individual contributors
+by the @authors tag. See the copyright.txt in the distribution for a
+full listing of individual contributors.
+
+This is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of
+the License, or (at your option) any later version.
+
+This software 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this software; if not, write to the Free
+Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+02110-1301 USA, or see the FSF site: http://www.fsf.org.
+-->
+<project name="registration.ftest.build" basedir="." default="build">
+ <property name="example.name" value="registration"/>
+ <property name="jboss.deploy.target" value="deploy"/>
+ <property name="jboss.undeploy.target" value="undeploy"/>
+ <property name="jboss.example.ready.check.url" value="seam-registration/register.seam"/>
+ <property name="jboss-embedded.deploy.target" value="tomcat.deploy"/>
+ <property name="jboss-embedded.undeploy.target" value="tomcat.undeploy"/>
+ <property name="jboss-embedded.example.ready.check.url" value="jboss-seam-registration/register.seam"/>
+
+ <import file="../build.xml" />
+</project>
Property changes on: trunk/src/test/ftest/examples/registration/build.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/src/test/ftest/examples/registration/jboss-embedded.xml
===================================================================
--- trunk/src/test/ftest/examples/registration/jboss-embedded.xml (rev 0)
+++ trunk/src/test/ftest/examples/registration/jboss-embedded.xml 2009-01-15 11:04:37 UTC (rev 9933)
@@ -0,0 +1,31 @@
+<!--
+JBoss, Home of Professional Open Source
+Copyright 2008, Red Hat Middleware LLC, and individual contributors
+by the @authors tag. See the copyright.txt in the distribution for a
+full listing of individual contributors.
+
+This is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of
+the License, or (at your option) any later version.
+
+This software 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this software; if not, write to the Free
+Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+02110-1301 USA, or see the FSF site: http://www.fsf.org.
+-->
+<!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
+<suite name="Registration example" verbose="2" parallel="false">
+ <test name="registration_jboss-embedded">
+ <parameter name="PROPERTY_FILE" value="" />
+ <parameter name="CONTEXT_PATH" value="/jboss-seam-registration" />
+ <classes>
+ <class name="org.jboss.seam.example.registration.test.selenium.RegistrationTest" />
+ </classes>
+ </test>
+</suite>
Property changes on: trunk/src/test/ftest/examples/registration/jboss-embedded.xml
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ text/plain
Added: trunk/src/test/ftest/examples/registration/jboss.xml
===================================================================
--- trunk/src/test/ftest/examples/registration/jboss.xml (rev 0)
+++ trunk/src/test/ftest/examples/registration/jboss.xml 2009-01-15 11:04:37 UTC (rev 9933)
@@ -0,0 +1,31 @@
+<!--
+JBoss, Home of Professional Open Source
+Copyright 2008, Red Hat Middleware LLC, and individual contributors
+by the @authors tag. See the copyright.txt in the distribution for a
+full listing of individual contributors.
+
+This is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of
+the License, or (at your option) any later version.
+
+This software 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this software; if not, write to the Free
+Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+02110-1301 USA, or see the FSF site: http://www.fsf.org.
+-->
+<!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
+<suite name="Registration example" verbose="2" parallel="false">
+ <test name="registration_jboss">
+ <parameter name="PROPERTY_FILE" value="" />
+ <parameter name="CONTEXT_PATH" value="/seam-registration" />
+ <classes>
+ <class name="org.jboss.seam.example.registration.test.selenium.RegistrationTest" />
+ </classes>
+ </test>
+</suite>
Property changes on: trunk/src/test/ftest/examples/registration/jboss.xml
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ text/plain
Added: trunk/src/test/ftest/examples/registration/src/org/jboss/seam/example/registration/test/selenium/RegistrationTest.java
===================================================================
--- trunk/src/test/ftest/examples/registration/src/org/jboss/seam/example/registration/test/selenium/RegistrationTest.java (rev 0)
+++ trunk/src/test/ftest/examples/registration/src/org/jboss/seam/example/registration/test/selenium/RegistrationTest.java 2009-01-15 11:04:37 UTC (rev 9933)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.example.registration.test.selenium;
+
+import org.jboss.seam.example.common.test.selenium.SeamSeleniumTest;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+import static org.testng.AssertJUnit.assertTrue;
+import static org.testng.AssertJUnit.assertEquals;
+
+/**
+ * This class tests registration form functionality in registration example.
+ *
+ * @author Jozef Hartinger
+ *
+ */
+public class RegistrationTest extends SeamSeleniumTest
+{
+ protected static String REGISTRATION_URL = "/register.seam";
+ protected static String REGISTRATION_USERNAME = "registration:username";
+ protected static String REGISTRATION_NAME = "registration:name";
+ protected static String REGISTRATION_PASSWORD = "registration:password";
+ protected static String REGISTRATION_SUBMIT = "registration:register";
+ protected static String REGISTRATION_MESSAGE = "registration:messages";
+ protected static String REGISTRATION_MESSAGE_COUNT = "//ul[@id='registration:messages']/li";
+ protected static String REGISTERED_URL = "/registered.seam";
+
+ @Override
+ @BeforeMethod
+ public void setUp()
+ {
+ super.setUp();
+ browser.open(CONTEXT_PATH + REGISTRATION_URL);
+ }
+
+ @Test
+ public void simpleRegistrationTest()
+ {
+ String username = "johny";
+ String name = "John Doe";
+ String password = "secretPassword";
+ submitRegistrationForm(username, name, password);
+ assertTrue("After-registration page expected.", browser.getLocation().contains(REGISTERED_URL));
+ assertTrue("Welcome message should contain username.", browser.isTextPresent(username));
+ assertTrue("Welcome message should contain name.", browser.isTextPresent(name));
+ }
+
+ @Test(dependsOnMethods = { "simpleRegistrationTest" })
+ public void duplicateUsernameTest()
+ {
+ String username = "jane";
+ String name = "Jane Doe";
+ String password = "secretPassword";
+ submitRegistrationForm(username, name, password);
+ browser.goBackAndWait();
+ submitRegistrationForm(username, name, password);
+ assertTrue("Registration page expected.", browser.getLocation().contains(REGISTRATION_URL));
+ assertTrue("Error message did not appear.", browser.isElementPresent(REGISTRATION_MESSAGE));
+ }
+
+ @Test
+ public void emptyValuesTest()
+ {
+ submitRegistrationForm("", "", "");
+ assertTrue("Registration page expected.", browser.getLocation().contains(REGISTRATION_URL));
+ assertEquals("Unexpected number of error messages.", 3, browser.getXpathCount(REGISTRATION_MESSAGE_COUNT));
+ }
+
+ protected void submitRegistrationForm(String username, String name, String password)
+ {
+ browser.type(REGISTRATION_USERNAME, username);
+ browser.type(REGISTRATION_NAME, name);
+ browser.type(REGISTRATION_PASSWORD, password);
+ browser.clickAndWait(REGISTRATION_SUBMIT);
+ }
+
+}
Property changes on: trunk/src/test/ftest/examples/registration/src/org/jboss/seam/example/registration/test/selenium/RegistrationTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeamSelenium.java
===================================================================
--- trunk/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeamSelenium.java (rev 0)
+++ trunk/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeamSelenium.java 2009-01-15 11:04:37 UTC (rev 9933)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.example.common.test.selenium;
+
+import com.thoughtworks.selenium.DefaultSelenium;
+
+/**
+ * This class slightly enhaces a Selenium API for controlling a browser.
+ * @author Jozef Hartinger
+ *
+ */
+public class SeamSelenium extends DefaultSelenium
+{
+
+ protected String timeout = "30000";
+
+ public SeamSelenium(String serverHost, int serverPort, String browserStartCommand, String browserURL)
+ {
+ super(serverHost, serverPort, browserStartCommand, browserURL);
+ }
+
+ @Override
+ public void setTimeout(String timeout) {
+ super.setTimeout(timeout);
+ this.timeout = timeout;
+ }
+
+ /**
+ * Same as click method but waits for page to load after clicking. Default timeout can be changed by setTimeout() method.
+ * @param locator
+ */
+ public void clickAndWait(String locator) {
+ super.click(locator);
+ super.waitForPageToLoad(timeout);
+ }
+
+ /**
+ * Simulates a user pressing "back" button and waits for page to load. Default timeout can be changed by setTimeout() method.
+ */
+ public void goBackAndWait() {
+ super.goBack();
+ super.waitForPageToLoad(timeout);
+ }
+
+
+}
Property changes on: trunk/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeamSelenium.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeamSeleniumTest.java
===================================================================
--- trunk/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeamSeleniumTest.java 2009-01-14 21:11:57 UTC (rev 9932)
+++ trunk/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeamSeleniumTest.java 2009-01-15 11:04:37 UTC (rev 9933)
@@ -32,12 +32,12 @@
import org.testng.annotations.Optional;
import org.testng.annotations.Parameters;
-import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Selenium;
/**
* Base class for all Seam based selenium tests.
* @author jbalunas
+ * @author jharting
*
*/
public abstract class SeamSeleniumTest {
@@ -53,14 +53,14 @@
private static Properties properties = new Properties();
private static boolean propertiesLoaded = false;
- protected Selenium browser;
+ protected SeamSelenium browser;
@BeforeClass
@Parameters( { "selenium.host", "selenium.server.port", "selenium.browser",
"selenium.browser.url", "selenium.speed", "selenium.timeout",
"PROPERTY_FILE", "CONTEXT_PATH" })
public void setParameters(String host, String port, String browser,
- String browserUrl, String speed, String timeout, String propertyFile, @Optional String contextPath) {
+ String browserUrl, String speed, String timeout, String propertyFile, @Optional("") String contextPath) {
HOST = host;
PORT = Integer.parseInt(port);
BROWSER = browser;
@@ -73,7 +73,7 @@
@BeforeMethod
public void setUp() {
- startBrowser();
+ browser = startBrowser();
}
@AfterMethod
@@ -81,11 +81,13 @@
stopBrowser();
}
- public void startBrowser() {
- browser = new DefaultSelenium(HOST, PORT, BROWSER, BROWSER_URL);
- browser.start();
- browser.allowNativeXpath("false");
- browser.setSpeed(SPEED);
+ public SeamSelenium startBrowser() {
+ SeamSelenium newBrowser = new SeamSelenium(HOST, PORT, BROWSER, BROWSER_URL);
+ newBrowser.start();
+ newBrowser.allowNativeXpath("false");
+ newBrowser.setSpeed(SPEED);
+ newBrowser.setTimeout(TIMEOUT);
+ return newBrowser;
}
public void stopBrowser() {
More information about the seam-commits
mailing list