Author: jharting
Date: 2009-04-08 09:38:06 -0400 (Wed, 08 Apr 2009)
New Revision: 10349
Added:
trunk/src/test/ftest/lib/ant-launcher.jar
trunk/src/test/ftest/lib/ant.jar
trunk/src/test/ftest/seamgen/
trunk/src/test/ftest/seamgen/build.xml
trunk/src/test/ftest/seamgen/icefaces.xml
trunk/src/test/ftest/seamgen/readme.txt
trunk/src/test/ftest/seamgen/richfaces.xml
trunk/src/test/ftest/seamgen/smoke.xml
trunk/src/test/ftest/seamgen/src/
trunk/src/test/ftest/seamgen/src/main/
trunk/src/test/ftest/seamgen/src/main/org/
trunk/src/test/ftest/seamgen/src/main/org/jboss/
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/DatabaseTest.java
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/GenerateEntitiesTest.java
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/HotDeploymentNewFormTest.java
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/HotDeploymentStaticTest.java
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/IdentityManagementTest.java
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewActionTest.java
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewFormTest.java
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewProjectTest.java
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/PersonTest.java
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/RoleTest.java
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/SeamGenTest.java
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/SeleniumSeamGenTest.java
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/UserTest.java
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/VehicleTest.java
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/generate-entities.sql
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/identity-management.sql
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/utils/
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/utils/SeamGenAdapter.java
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/utils/SeleniumTestListener.java
Modified:
trunk/seam-gen/build.xml
trunk/src/test/ftest/build.xml
trunk/src/test/ftest/ftest.properties
trunk/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeamSelenium.java
Log:
JBQA-2232
Modified: trunk/seam-gen/build.xml
===================================================================
--- trunk/seam-gen/build.xml 2009-04-08 08:06:08 UTC (rev 10348)
+++ trunk/seam-gen/build.xml 2009-04-08 13:38:06 UTC (rev 10349)
@@ -1249,7 +1249,7 @@
</copy>
<replace file="${project.home}/view/layout/menu.xhtml">
<replacetoken><![CDATA[<!-- @newMenuItem@
-->]]></replacetoken>
- <replacevalue><![CDATA[<s:link
view="/useradmin/home.xhtml" value="Identity Management"
propagation="none" rendered="#{true or
identity.hasRole('admin')}"/> <!-- temporarily enabled for all -->
+ <replacevalue><![CDATA[<s:link
view="/useradmin/home.xhtml" id="identityManagement"
value="Identity Management" propagation="none" rendered="#{true
or identity.hasRole('admin')}"/> <!-- temporarily enabled for all
-->
<!-- @newMenuItem@ -->]]></replacevalue>
</replace>
<replace
file="${project.home}/resources/WEB-INF/components.xml">
Modified: trunk/src/test/ftest/build.xml
===================================================================
--- trunk/src/test/ftest/build.xml 2009-04-08 08:06:08 UTC (rev 10348)
+++ trunk/src/test/ftest/build.xml 2009-04-08 13:38:06 UTC (rev 10349)
@@ -42,11 +42,12 @@
</fileset>
</path>
- <target name="testall">
- <antcall target="testall.jboss5" />
+ <target name="testall" description="Run functional testsuite based on
container property">
+ <fail unless="container">Please set container property.</fail>
+ <antcall target="testall.${container}" />
</target>
- <target name="testall.jboss4">
+ <target name="testall.jboss4" description="Run functional testsuite
for JBoss 4">
<property name="container" value="jboss4" />
<antcall target="start.container.before.suite" />
<antcall target="start.selenium.server" />
@@ -83,7 +84,7 @@
<antcall target="stop.selenium.server" />
</target>
- <target name="testall.jboss5">
+ <target name="testall.jboss5" description="Run functional testsuite
for JBoss 5">
<property name="container" value="jboss5" />
<antcall target="start.container.before.suite" />
<antcall target="start.selenium.server" />
@@ -120,7 +121,7 @@
<antcall target="stop.selenium.server" />
</target>
- <target name="testall.jboss-embedded">
+ <target name="testall.jboss-embedded" description="Run functional
testsuite for JBoss Embedded">
<property name="container" value="jboss-embedded" />
<antcall target="start.selenium.server" />
<!-- Execute tests for all examples on jboss-embedded -->
@@ -138,7 +139,7 @@
<antcall target="stop.selenium.server" />
</target>
- <target name="testall.tomcat6">
+ <target name="testall.tomcat6" description="Run functional testsuite
for Tomcat 6">
<property name="container" value="tomcat6" />
<antcall target="start.selenium.server" />
@@ -149,26 +150,27 @@
<antcall target="stop.selenium.server" />
</target>
- <target name="test">
- <antcall target="test.jboss5" />
+ <target name="test" description="Run tests for single example.
Container selection is based on the value of container property">
+ <fail unless="container">Please set container property.</fail>
+ <antcall target="test.${container}" />
</target>
- <target name="test.jboss4">
+ <target name="test.jboss4" description="Run tests for single example
on JBoss 4">
<property name="container" value="jboss4" />
<antcall target="test.single.example" />
</target>
- <target name="test.jboss5">
+ <target name="test.jboss5" description="Run tests for single example
on JBoss 5">
<property name="container" value="jboss5" />
<antcall target="test.single.example" />
</target>
- <target name="test.tomcat6">
+ <target name="test.tomcat6" description="Run tests for single example
on Tomcat 6">
<property name="container" value="tomcat6" />
<antcall target="test.single.example" />
</target>
- <target name="test.jboss-embedded">
+ <target name="test.jboss-embedded" description="Run tests for single
example on JBoss Embedded">
<property name="container" value="jboss-embedded" />
<antcall target="test.single.example" />
</target>
Modified: trunk/src/test/ftest/ftest.properties
===================================================================
--- trunk/src/test/ftest/ftest.properties 2009-04-08 08:06:08 UTC (rev 10348)
+++ trunk/src/test/ftest/ftest.properties 2009-04-08 13:38:06 UTC (rev 10349)
@@ -30,7 +30,8 @@
selenium.browser.port=8080
selenium.browser.url=http://127.0.0.1:8080
selenium.speed=0
-selenium.timeout=60000
+selenium.timeout=120000
+selenium.icefaces.wait.time=2000
# enter any commands wanted for the testng run
selenium.testng.jvmargs=-Dfoo
@@ -41,7 +42,10 @@
#selenium.server.cmd.args= -singleWindow
selenium.server.cmd.args=
-# default max wait times
+# container to be used for tests
+container=jboss5
+
+# default max wait times in seconds
jboss4.deploy.waittime=300
jboss5.deploy.waittime=300
tomcat6.deploy.waittime=60
@@ -49,10 +53,10 @@
# container locations - must be set
# independent from ${seam.dir}/build.properties
-#jboss4.home=
-#jboss5.home=
-#tomcat6.home=
-#jboss-embedded.home=
+jboss4.home=
+jboss5.home=
+tomcat6.home=
+jboss-embedded.home=
# container settings
jboss4.profile=default
@@ -60,3 +64,31 @@
jboss5.profile=default
jboss5.jvm.arguments=-Xms512m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512
-Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000
-Dsun.rmi.dgc.server.gcInterval=3600000
+
+# seam-gen specific properties
+#seamgen.delete.project=true
+
+# workspace for new projects
+workspace.home=
+
+# seam-gen project properties
+database.type=mysql
+database.exists=y
+database.drop=n
+driver.jar=/home/jharting/jboss/mysql-connector-java-5.1.6-bin.jar
+driver.license.jar=
+hibernate.connection.username=seam
+hibernate.connection.password=seam
+hibernate.connection.driver_class=com.mysql.jdbc.Driver
+hibernate.connection.dataSource_class=com.mysql.jdbc.jdbc2.optional.MysqlDataSource
+hibernate.cache.provider_class=org.hibernate.cache.HashtableCacheProvider
+hibernate.default_catalog.null=
+hibernate.default_schema.null=
+hibernate.dialect=org.hibernate.dialect.MySQLDialect
+hibernate.connection.url=jdbc\:mysql\:///seam
+model.package=com.example
+action.package=com.example
+test.package=com.example.test
+richfaces.skin=classic
+icefaces.home=
+jboss.domain=default
Added: trunk/src/test/ftest/lib/ant-launcher.jar
===================================================================
(Binary files differ)
Property changes on: trunk/src/test/ftest/lib/ant-launcher.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/src/test/ftest/lib/ant.jar
===================================================================
(Binary files differ)
Property changes on: trunk/src/test/ftest/lib/ant.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/src/test/ftest/seamgen/build.xml
===================================================================
--- trunk/src/test/ftest/seamgen/build.xml (rev 0)
+++ trunk/src/test/ftest/seamgen/build.xml 2009-04-08 13:38:06 UTC (rev 10349)
@@ -0,0 +1,107 @@
+<?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="ftest.seamgen" basedir="."
default="build"
xmlns:server="http://jboss.org/ns/test/ant/server">
+
+ <!-- Location of Seam -->
+ <dirname property="seam.dir"
file="${ant.file.ftest.seamgen}/../../../../" />
+
+ <!-- default property setup -->
+ <property name="ftest.dir" value="${seam.dir}/src/test/ftest"
/>
+ <property name="common.src.dir" value="${ftest.dir}/src/main"
/>
+ <property name="src.dir" value="src/main" />
+ <property name="build.dir" value="build" />
+ <property name="classes.dir" value="${build.dir}/classes" />
+ <property name="test.output.dir" value="${seam.dir}/test-output"
/>
+ <property name="ftest.lib.dir" value="${ftest.dir}/lib" />
+
+ <property file="${seam.dir}/src/test/ftest/ftest.properties" />
+
+ <!-- common path setup -->
+
+ <path id="classpath.build">
+ <fileset dir="${ftest.lib.dir}" includes="**/*.jar" />
+ </path>
+
+ <path id="classpath.test">
+ <path refid="classpath.build" />
+ <path location="${classes.dir}" />
+ <fileset dir="${seam.dir}/lib/gen" includes="*.jar" />
+ <fileset file="${java.home}/../lib/tools.jar"/>
+ <fileset file="${driver.jar}"/>
+ <!-- TODO why do we need this? -->
+ <fileset dir="${seam.dir}/lib" includes="*.jar" />
+ </path>
+
+ <target name="clean" description="Delete all generated
files">
+ <delete dir="${build.dir}" />
+ <delete dir="${test.output.dir}" />
+ <delete dir="${report.dir}" />
+ <delete dir="${log.dir}" />
+ </target>
+
+ <target name="build" depends="build.common"
description="Compiles the Test">
+ <mkdir dir="${classes.dir}" />
+ <javac srcdir="${src.dir}" destdir="${classes.dir}"
classpathref="classpath.build" debug="true" />
+ <copy todir="${classes.dir}">
+ <fileset dir="${src.dir}">
+ <exclude name="**/*.java" />
+ </fileset>
+ </copy>
+ </target>
+
+ <target name="build.common" description="Compiles the common selenium
test code">
+ <mkdir dir="${classes.dir}" />
+ <javac srcdir="${common.src.dir}" destdir="${classes.dir}"
classpathref="classpath.build" debug="true" />
+ <copy todir="${classes.dir}">
+ <fileset dir="${src.dir}">
+ <include name="**/SeamSelenium.java" />
+ </fileset>
+ </copy>
+ </target>
+
+ <target name="seam-gen.richfaces.testsuite" depends="build"
description="Run Richfaces testsuite">
+ <run.selenium.test suite="richfaces" />
+ </target>
+
+ <target name="seam-gen.icefaces.testsuite" depends="build"
description="Run Icefaces testsuite">
+ <run.selenium.test suite="icefaces" />
+ </target>
+
+ <target name="seam-gen.smoke.testsuite" description="Run smoke
testsuite">
+ <run.selenium.test suite="smoke" />
+ </target>
+
+ <macrodef name="run.selenium.test">
+ <attribute name="suite" />
+ <sequential>
+ <!--<ant antfile="${seam.dir}/build.xml"
target="copyseam"/>-->
+ <taskdef resource="testngtasks" classpathref="classpath.test"
/>
+ <!-- execute testng tests -->
+ <testng haltonfailure="false" outputdir="${test.output.dir}"
classpathref="classpath.test">
+ <xmlfileset file="(a){suite}.xml" />
+ <sysproperty key="seam.dir" value="${seam.dir}" />
+ </testng>
+ </sequential>
+ </macrodef>
+
+</project>
Property changes on: trunk/src/test/ftest/seamgen/build.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/src/test/ftest/seamgen/icefaces.xml
===================================================================
--- trunk/src/test/ftest/seamgen/icefaces.xml (rev 0)
+++ trunk/src/test/ftest/seamgen/icefaces.xml 2009-04-08 13:38:06 UTC (rev 10349)
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
+<suite name="seam-gen ICEfaces suite" parallel="false"
verbose="3">
+ <listeners>
+ <listener
+ class-name="org.jboss.seam.test.functional.seamgen.utils.SeleniumTestListener"
/>
+ </listeners>
+ <parameter name="suffix" value="001" />
+ <test name="ICEfaces exploded Ear Test">
+ <parameter name="icefaces" value="true" />
+ <parameter name="type" value="ear" />
+ <classes>
+ <class name="org.jboss.seam.test.functional.seamgen.NewProjectTest"
/>
+ <class name="org.jboss.seam.test.functional.seamgen.NewActionTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.NewFormTest" />
+ <class
+ name="org.jboss.seam.test.functional.seamgen.HotDeploymentStaticTest"
/>
+ <class name="org.jboss.seam.test.functional.seamgen.PersonTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.VehicleTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.UserTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.UserTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.RoleTest" />
+ </classes>
+ </test>
+ <test name="ICEfaces exploded War Test">
+ <parameter name="icefaces" value="true" />
+ <parameter name="type" value="war" />
+ <classes>
+ <class name="org.jboss.seam.test.functional.seamgen.NewProjectTest"
/>
+ <class name="org.jboss.seam.test.functional.seamgen.NewActionTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.NewFormTest" />
+ <class
+ name="org.jboss.seam.test.functional.seamgen.HotDeploymentNewFormTest"
/>
+ <class
+ name="org.jboss.seam.test.functional.seamgen.HotDeploymentStaticTest"
/>
+ <class name="org.jboss.seam.test.functional.seamgen.PersonTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.VehicleTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.UserTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.RoleTest" />
+ </classes>
+ </test>
+ <test name="ICEfaces Ear Test">
+ <parameter name="icefaces" value="true" />
+ <parameter name="type" value="ear" />
+ <parameter name="explode" value="false" />
+ <classes>
+ <class name="org.jboss.seam.test.functional.seamgen.NewProjectTest"
/>
+ <class name="org.jboss.seam.test.functional.seamgen.NewActionTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.NewFormTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.PersonTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.VehicleTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.UserTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.RoleTest" />
+ </classes>
+ </test>
+ <test name="ICEfaces War Test">
+ <parameter name="icefaces" value="true" />
+ <parameter name="type" value="war" />
+ <parameter name="explode" value="false" />
+ <classes>
+ <class name="org.jboss.seam.test.functional.seamgen.NewProjectTest"
/>
+ <class name="org.jboss.seam.test.functional.seamgen.NewActionTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.NewFormTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.PersonTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.VehicleTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.UserTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.RoleTest" />
+ </classes>
+ </test>
+</suite>
\ No newline at end of file
Property changes on: trunk/src/test/ftest/seamgen/icefaces.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/src/test/ftest/seamgen/readme.txt
===================================================================
--- trunk/src/test/ftest/seamgen/readme.txt (rev 0)
+++ trunk/src/test/ftest/seamgen/readme.txt 2009-04-08 13:38:06 UTC (rev 10349)
@@ -0,0 +1,109 @@
+#
+ # 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.
+ #
+
+Seam-gen functional testsuite
+------------------------------------
+
+UNDER DEVELOPMENT NOT COMPLETE
+
+How to run the testsuite:
+----------------------
+To run seam-gen functional testsuite, please follow these steps:
+
+1.) Export following script to MySQL database
+
+CREATE TABLE `Person` (
+ `username` varchar(10) NOT NULL,
+ `name` varchar(100) NOT NULL,
+ `birthdate` date default NULL,
+ `address` varchar(600) NOT NULL,
+ PRIMARY KEY (`username`)
+) ENGINE=InnoDB;
+
+CREATE TABLE `Vehicle` (
+ `ownerUsername` varchar(10) default NULL,
+ `make` varchar(50) NOT NULL,
+ `model` varchar(50) NOT NULL,
+ `year` int(11) NOT NULL,
+ `registration` varchar(8) NOT NULL,
+ `state` varchar(2) NOT NULL,
+ PRIMARY KEY USING BTREE (`registration`,`state`),
+ KEY `ownerUsername` (`ownerUsername`),
+ CONSTRAINT `owner` FOREIGN KEY (`ownerUsername`) REFERENCES `Person` (`username`)
+) ENGINE=InnoDB;
+
+
+2.) Check setup in ../ftest.properties
+ a) check that selenium.browser property is set to your desired browser
+ b) check that container property is set to either jboss4 or jboss5
+ c) check that jboss*.deploy.waittime is set to sensible value
+ d) check that jboss*.home points to the location of your application server
+ e) check that seamgen.delete.project property is set to true if you want the generated
applications
+ to be deleted immediately after testrun
+ f) check that workspace.home property points to a folder where generated applications
should be stored temporarily
+ g) check that seam-gen project properties (at the end of ftest.properties) are set
correctly.
+ Pay special attention to database connection related properties (Configure to use MySQL
with exported tables).
+
+3.) Start application server. Make sure there are no application deployed from previous
test run.
+#TODO automate this step
+
+4.) Run tests.
+ a) run "ant seam-gen.richfaces.testsuite" to test seam-gen with RichFaces
+ b) run "ant seam-gen.icefaces.testsuite" to test seam-gen with ICEfaces
+
+ The matrix describing these testsuites follows:
+ ---------------------------------------------
+ | EAR WAR |
+ |use deploy target X X |
+ |use explode target X X |
+ ---------------------------------------------
+
+
+5.) Run "ant testreport" in ${seam.dir} to generate nice looking testreports.
+ For every failed test, there is a screenshot and HTML source stored in
test-output/functional-framework
+
+
+Known Limitations:
+---------------------
+* Container must be started (preferably with nothing deployed)
+
+Running tests from Eclipse
+---------------------
+In order to run the testsuite from IDE, you need testng plugin
http://testng.org/doc/eclipse.html
+The procedure of running the testsuite from Eclipse is identical to instructions above,
however you must replace step 3 with
+following steps:
+a) Rightclick on the testsuite's xml file, choose 'Run As' and then 'Run
Configurations'
+b) Modify the classpath to contain ${seam.dir}/lib/gen folder as well as mysql driver jar
file
+c) Run the testsuite by rightclick -> 'Run As' -> 'TestNG Suite'
+
+
+Testsuite customization
+---------------------
+To customize the testsuite, edit particular xml file in this folder.
+You can use following parameters to influence seam-gen application type:
+1.) type - set to ear or war, ear is the default value
+2.) explode - set to true or false, if set to false, application will be deployed and
undeployed using (un)deploy target.
+ (un)explode target will be used otherwise. True is the default value.
+3.) icefaces - set to true to create an ICEfaces project. RichFaces project will be
created otherwise.
+ This parameter defaults to false.
+4.) suffix - value of this parameter will be appended to the application name.
+
Property changes on: trunk/src/test/ftest/seamgen/readme.txt
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/src/test/ftest/seamgen/richfaces.xml
===================================================================
--- trunk/src/test/ftest/seamgen/richfaces.xml (rev 0)
+++ trunk/src/test/ftest/seamgen/richfaces.xml 2009-04-08 13:38:06 UTC (rev 10349)
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
+<suite name="seam-gen RichFaces suite" parallel="false"
verbose="3">
+ <listeners>
+ <listener
+ class-name="org.jboss.seam.test.functional.seamgen.utils.SeleniumTestListener"
/>
+ </listeners>
+ <parameter name="suffix" value="001" />
+ <test name="RichFaces exploded Ear Test">
+ <parameter name="type" value="ear" />
+ <classes>
+ <class name="org.jboss.seam.test.functional.seamgen.NewProjectTest"
/>
+ <class name="org.jboss.seam.test.functional.seamgen.NewActionTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.NewFormTest" />
+ <class
+ name="org.jboss.seam.test.functional.seamgen.HotDeploymentStaticTest"
/>
+ <class name="org.jboss.seam.test.functional.seamgen.PersonTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.VehicleTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.UserTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.RoleTest" />
+ </classes>
+ </test>
+ <test name="RichFaces exploded War Test">
+ <parameter name="type" value="war" />
+ <classes>
+ <class name="org.jboss.seam.test.functional.seamgen.NewProjectTest"
/>
+ <class name="org.jboss.seam.test.functional.seamgen.NewActionTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.NewFormTest" />
+ <class
+ name="org.jboss.seam.test.functional.seamgen.HotDeploymentNewFormTest"
/>
+ <class
+ name="org.jboss.seam.test.functional.seamgen.HotDeploymentStaticTest"
/>
+ <class name="org.jboss.seam.test.functional.seamgen.PersonTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.VehicleTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.UserTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.RoleTest" />
+ </classes>
+ </test>
+ <test name="RichFaces Ear Test">
+ <parameter name="type" value="ear" />
+ <parameter name="explode" value="false" />
+ <classes>
+ <class name="org.jboss.seam.test.functional.seamgen.NewProjectTest"
/>
+ <class name="org.jboss.seam.test.functional.seamgen.NewActionTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.NewFormTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.PersonTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.VehicleTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.UserTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.RoleTest" />
+ </classes>
+ </test>
+ <test name="RichFaces War Test">
+ <parameter name="type" value="war" />
+ <parameter name="explode" value="false" />
+ <classes>
+ <class name="org.jboss.seam.test.functional.seamgen.NewProjectTest"
/>
+ <class name="org.jboss.seam.test.functional.seamgen.NewActionTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.NewFormTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.PersonTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.VehicleTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.UserTest" />
+ <class name="org.jboss.seam.test.functional.seamgen.RoleTest" />
+ </classes>
+ </test>
+</suite>
Property changes on: trunk/src/test/ftest/seamgen/richfaces.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/src/test/ftest/seamgen/smoke.xml
===================================================================
--- trunk/src/test/ftest/seamgen/smoke.xml (rev 0)
+++ trunk/src/test/ftest/seamgen/smoke.xml 2009-04-08 13:38:06 UTC (rev 10349)
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
+<suite name="seam-gen smoke testsuite" parallel="false"
verbose="3">
+ <listeners>
+ <listener
+ class-name="org.jboss.seam.test.functional.seamgen.utils.SeleniumTestListener"></listener>
+ </listeners>
+ <parameter name="suffix" value="smoke001"/>
+ <test name="RichFaces exploded Ear Test">
+ <parameter name="type" value="ear" />
+ <classes>
+ <class name="org.jboss.seam.test.functional.seamgen.NewProjectTest"
/>
+ </classes>
+ </test>
+ <test name="RichFaces exploded War Test">
+ <parameter name="type" value="war" />
+ <classes>
+ <class name="org.jboss.seam.test.functional.seamgen.NewProjectTest"
/>
+ </classes>
+ </test>
+ <test name="RichFaces Ear Test">
+ <parameter name="type" value="ear" />
+ <parameter name="explode" value="false" />
+ <classes>
+ <class name="org.jboss.seam.test.functional.seamgen.NewProjectTest"
/>
+ </classes>
+ </test>
+ <test name="RichFaces War Test">
+ <parameter name="type" value="war" />
+ <parameter name="explode" value="false" />
+ <classes>
+ <class name="org.jboss.seam.test.functional.seamgen.NewProjectTest"
/>
+ </classes>
+ </test>
+ <test name="ICEfaces exploded Ear Test">
+ <parameter name="icefaces" value="true" />
+ <parameter name="type" value="ear" />
+ <classes>
+ <class name="org.jboss.seam.test.functional.seamgen.NewProjectTest"
/>
+ </classes>
+ </test>
+ <test name="ICEfaces exploded War Test">
+ <parameter name="icefaces" value="true" />
+ <parameter name="type" value="war" />
+ <classes>
+ <class name="org.jboss.seam.test.functional.seamgen.NewProjectTest"
/>
+ </classes>
+ </test>
+ <test name="ICEfaces Ear Test">
+ <parameter name="icefaces" value="true" />
+ <parameter name="type" value="ear" />
+ <parameter name="explode" value="false" />
+ <classes>
+ <class name="org.jboss.seam.test.functional.seamgen.NewProjectTest"
/>
+ </classes>
+ </test>
+ <test name="ICEfaces War Test">
+ <parameter name="icefaces" value="true" />
+ <parameter name="type" value="war" />
+ <parameter name="explode" value="false" />
+ <classes>
+ <class name="org.jboss.seam.test.functional.seamgen.NewProjectTest"
/>
+ </classes>
+ </test>
+</suite>
\ No newline at end of file
Property changes on: trunk/src/test/ftest/seamgen/smoke.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/DatabaseTest.java
===================================================================
---
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/DatabaseTest.java
(rev 0)
+++
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/DatabaseTest.java 2009-04-08
13:38:06 UTC (rev 10349)
@@ -0,0 +1,78 @@
+/*
+ * 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.test.functional.seamgen;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.sql.Connection;
+import java.sql.DriverManager;
+
+/**
+ * Every test that uses database and needs import script to be executed should
+ * extend this class.
+ *
+ * @author Jozef Hartinger
+ *
+ */
+public class DatabaseTest extends SeleniumSeamGenTest
+{
+
+ /**
+ * Execute import script against the database defined in import.sql
+ */
+ public void executeImportScript(InputStream is)
+ {
+ Connection conn = null;
+ try
+ {
+
Class.forName(ftestProperties.getProperty("hibernate.connection.driver_class"));
+ String url = ftestProperties.getProperty("hibernate.connection.url");
+ conn = DriverManager.getConnection(url,
ftestProperties.getProperty("hibernate.connection.username"),
ftestProperties.getProperty("hibernate.connection.username"));
+ BufferedReader reader = new BufferedReader(new InputStreamReader(is));
+ String line = reader.readLine();
+ while (line != null)
+ {
+ if (!line.equals(new String())) // don't execute empty lines
+ {
+ conn.createStatement().execute(line);
+ }
+ line = reader.readLine();
+ }
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Database import script failed.", e);
+ }
+ finally
+ {
+ try
+ {
+ conn.close();
+ }
+ catch (Exception e)
+ {
+ }
+ }
+ }
+
+}
Property changes on:
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/DatabaseTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/GenerateEntitiesTest.java
===================================================================
---
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/GenerateEntitiesTest.java
(rev 0)
+++
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/GenerateEntitiesTest.java 2009-04-08
13:38:06 UTC (rev 10349)
@@ -0,0 +1,176 @@
+/*
+ * 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.test.functional.seamgen;
+
+import java.io.InputStream;
+import java.util.Date;
+
+import org.testng.annotations.BeforeGroups;
+
+import com.thoughtworks.selenium.Wait;
+
+/**
+ * This class and its subclasses test seam-gen's "generate-entities"
feature.
+ * Every test method should be part of "generate-entitiesTest" in order to get
+ * entities generated before its execution.
+ *
+ * @author Jozef Hartinger
+ *
+ */
+public class GenerateEntitiesTest extends DatabaseTest
+{
+
+ public static final String PERSON_LINK = "id=PersonId";
+ public static final String PERSON_USERNAME =
"id=person:usernameField:username";
+ public static final String PERSON_ADDRESS =
"id=person:addressField:address";
+ public static final String PERSON_BIRTHDAY =
"id=person:birthdateField:birthdate";
+ public static final String PERSON_NAME = "id=person:nameField:name";
+ public static final String PERSON_SAVE = "id=person:save";
+ public static final String PERSON_CANCEL = "id=person:cancel";
+ public static final String PERSON_DELETE = "id=person:delete";
+ public static final String PERSON_UPDATE = "id=person:update";
+ public static final int PERSON_IDENTIFIER_SIZE = 10;
+
+ public static final String PERSON_LIST_EDIT_BUTTON_BY_NAME =
"xpath=//table[@id='personList']/tbody/tr[normalize-space(td[1]/text()) =
'%s']//a[matches(@id, 'personList:\\d+:personEdit')]";
+ public static final String PERSON_LIST_VIEW_BUTTON_BY_NAME =
"xpath=//table[@id='personList']/tbody/tr[normalize-space(td[1]/text()) =
'%s']//a[matches(@id, 'personList:\\d+:person')]";
+ public static final String PERSON_LIST_RESULT_COUNT =
"//table[@id='personList']/tbody/tr";
+
+ public static final String VEHICLE_REGISTRATION =
"id=vehicle:registrationField:registration";
+ public static final String VEHICLE_STATE = "id=vehicle:stateField:state";
+ public static final String VEHICLE_MAKE = "id=vehicle:makeField:make";
+ public static final String VEHICLE_MODEL = "id=vehicle:modelField:model";
+ public static final String VEHICLE_YEAR = "id=vehicle:yearField:year";
+ public static final String VEHICLE_LINK = "id=VehicleId";
+ public static final String VEHICLE_SAVE = "id=vehicle:save";
+ public static final String VEHICLE_CANCEL = "id=vehicle:cancel";
+ public static final String VEHICLE_DELETE = "id=vehicle:delete";
+ public static final String VEHICLE_UPDATE = "id=vehicle:update";
+ public static final int VEHICLE_IDENTIFIER_SIZE = 8;
+
+ public static final String ENTITY_CREATE_BUTTON = "id=create";
+ public static final String ENTITY_EDIT = "id=edit";
+ public static final String ENTITY_DONE = "id=done";
+ public static final String ENTITY_SELECT_PARENT_BUTTON = "xpath=//*[contains(@id,
'selectParent')]";
+ public static final String VEHICLE_LIST_EDIT_BUTTON_BY_REGISTRATION =
"xpath=//table[@id='vehicleList']/tbody/tr[normalize-space(td[1]/text()) =
\"%s\"]//a[matches(@id, 'vehicleList:\\d+:vehicleEdit')]";
+ public static final String VEHICLE_LIST_VIEW_BUTTON_BY_REGISTRATION =
"xpath=//table[@id='vehicleList']/tbody/tr[normalize-space(td[1]/text()) =
\"%s\"]//a[matches(@id, 'vehicleList:\\d+:vehicle')]";
+ public static final String VEHICLE_LIST_RESULT_COUNT =
"//table[@id='vehicleList']/tbody/tr";
+ public static final String VEHICLE_LIST_ROW_BY_OWNER_NAME =
"xpath=//table[@id='vehicleList']/tbody/tr[normalize-space(td[1]/text()) =
\"%s\"]/td[normalize-space(text()) = \"%s\"]";
+
+ /**
+ * Execute generate-entities.sql script, run ./seam generate-entities, deploy
+ * the application and wait for it to load.
+ *
+ */
+ @BeforeGroups(groups = "generate-entitiesTest")
+ public void generateEntitiesTest()
+ {
+ // open and execute import script
+ InputStream importScript =
getClass().getResourceAsStream("/org/jboss/seam/test/functional/seamgen/generate-entities.sql");
+ executeImportScript(importScript);
+
+ seamGen.generateEntities();
+ seamGen.restart();
+ waitForAppToDeploy(HOME_PAGE, PERSON_LINK);
+ }
+
+ /**
+ * Submit new person.
+ */
+ public void createNewPerson(String username, String address, Date birthday, String
name)
+ {
+ browser.clickAndWait(PERSON_LINK);
+ browser.clickAndWait(ENTITY_CREATE_BUTTON);
+ fillPersonEditPage(username, address, birthday, name);
+ browser.clickAndWait(PERSON_SAVE);
+ }
+
+ /**
+ * Fill user details. Browser must be navigated to user's detail page before
+ * executing this method. This method does not submit the form.
+ */
+ public void fillPersonEditPage(String username, String address, Date birthday, String
name)
+ {
+ browser.type(PERSON_USERNAME, username);
+ browser.type(PERSON_ADDRESS, address);
+ selectDate(birthday);
+ browser.type(PERSON_NAME, name);
+ }
+
+ /**
+ * Select a date using icefaces or richfaces calendar component. Selecting
+ * hardcoded values is only implemented yet.
+ */
+ public void selectDate(Date date)
+ {
+ // TODO
+ final String richFaces = "id=person:birthdateField:birthdateDayCell24";
+ final String iceFaces =
"id=person:birthdateField:birthdate_calendar_1569";
+ final String icefacesCalendarButton =
"person:birthdateField:birthdate_calendarButton";
+
+ if (browser.isElementPresent(richFaces))
+ {
+ browser.click(richFaces);
+ }
+ else if (browser.isElementPresent(icefacesCalendarButton))
+ {
+ browser.click(icefacesCalendarButton);
+ new Wait()
+ {
+
+ @Override
+ public boolean until()
+ {
+ return browser.isElementPresent(iceFaces);
+ }
+ }.wait("Calendar did not appear.", Long.valueOf(SELENIUM_TIMEOUT));
+ browser.click(iceFaces);
+ }
+ else
+ {
+ throw new RuntimeException("Unable to select date." +
browser.getHtmlSource());
+ }
+ }
+
+ /**
+ * Submit new vehicle
+ */
+ public void createNewVehicle(String registration, String state, String make, String
model, String year)
+ {
+ browser.clickAndWait(VEHICLE_LINK);
+ browser.clickAndWait(ENTITY_CREATE_BUTTON);
+ fillVehicleEditPage(registration, state, make, model, year);
+ browser.clickAndWait(VEHICLE_SAVE);
+ }
+
+ /**
+ * Fill vehicle details. Browser must be navigated to vehicle's detail page
before
+ * executing this method. This method does not submit the form.
+ */
+ public void fillVehicleEditPage(String registration, String state, String make, String
model, String year)
+ {
+ browser.type(VEHICLE_REGISTRATION, registration);
+ browser.type(VEHICLE_STATE, state);
+ browser.type(VEHICLE_MAKE, make);
+ browser.type(VEHICLE_MODEL, model);
+ browser.type(VEHICLE_YEAR, year);
+ }
+}
Property changes on:
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/GenerateEntitiesTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/HotDeploymentNewFormTest.java
===================================================================
---
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/HotDeploymentNewFormTest.java
(rev 0)
+++
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/HotDeploymentNewFormTest.java 2009-04-08
13:38:06 UTC (rev 10349)
@@ -0,0 +1,63 @@
+/*
+ * 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.test.functional.seamgen;
+
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.Test;
+
+/**
+ * This test verifies hot deployment of JavaBean components. This class should
+ * only be used to test WAR packaged Seam applications.
+ *
+ * @author Jozef Hartinger
+ *
+ */
+public class HotDeploymentNewFormTest extends NewFormTest
+{
+
+ @Override
+ protected void prepareData()
+ {
+ newComponentProperties = new String[] { "hi", "HiLocal",
"Hi", "hi", "hiPage" };
+ }
+
+ @Override
+ protected void deployNewComponent()
+ {
+ seamGen.hotDeploy();
+ }
+
+ @Override
+ @Test(groups = { "newFormGroup" }, dependsOnGroups = {
"newProjectGroup" })
+ public void testNewComponent()
+ {
+ String username = "admin";
+ String password = "password";
+
+ login(username, password);
+
+ super.testNewComponent();
+
+ assertTrue(isLoggedIn(), "User should be logged in by now. Hot deployment
failure.");
+ }
+
+}
Property changes on:
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/HotDeploymentNewFormTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/HotDeploymentStaticTest.java
===================================================================
---
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/HotDeploymentStaticTest.java
(rev 0)
+++
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/HotDeploymentStaticTest.java 2009-04-08
13:38:06 UTC (rev 10349)
@@ -0,0 +1,103 @@
+/*
+ * 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.test.functional.seamgen;
+
+import java.io.BufferedReader;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+import static org.testng.Assert.assertTrue;
+
+/**
+ * This test verifies hot deployment of static resources. It modifies home.xhtml
+ * page and verifies that changes are reflected within the running app. All is done
+ * within user session to detect if the whole application was restarted or not.
+ *
+ * @author Jozef Hartinger
+ *
+ */
+public class HotDeploymentStaticTest extends SeleniumSeamGenTest
+{
+
+ private String newFeature;
+
+ @BeforeClass
+ public void modifyHomePage() throws IOException, InterruptedException
+ {
+ String homePageLocation = WORKSPACE + "/" + APP_NAME +
"/view/home.xhtml";
+ newFeature = "Works flawlessly as it is tested by Selenium";
+
+ BufferedReader reader = null;
+ StringBuilder homePageContentBuilder = new StringBuilder();
+ try
+ {
+ reader = new BufferedReader(new InputStreamReader(new
FileInputStream(homePageLocation)));
+ // load file content into String
+ String line = reader.readLine();
+ while (line != null)
+ {
+ homePageContentBuilder.append(line);
+ line = reader.readLine();
+ }
+ }
+ finally
+ {
+ reader.close();
+ }
+
+ String homePageContent = homePageContentBuilder.toString();
+
+ // add new item into the feature list
+ homePageContent = homePageContent.replaceAll("<li>Internationalization
support</li>", "<li>Internationalization
support</li>\n<li>" + newFeature + "</li>");
+
+ // write new content
+ Writer writer = null;
+ try
+ {
+ writer = new OutputStreamWriter(new FileOutputStream(homePageLocation));
+ writer.write(homePageContent);
+ writer.flush();
+ }
+ finally
+ {
+ writer.close();
+ }
+
+ seamGen.deploy();
+ }
+
+ @Test(dependsOnGroups = { "newProjectGroup" })
+ public void hotDeploymentOfFaceletTemplateTest()
+ {
+
+ login();
+
+ assertTrue(browser.isTextPresent(newFeature), "New feature not found. Hot
deployment failure.");
+ assertTrue(isLoggedIn(), "Session lost. Hot deployment failure.");
+ }
+}
Property changes on:
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/HotDeploymentStaticTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/IdentityManagementTest.java
===================================================================
---
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/IdentityManagementTest.java
(rev 0)
+++
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/IdentityManagementTest.java 2009-04-08
13:38:06 UTC (rev 10349)
@@ -0,0 +1,76 @@
+/*
+ * 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.test.functional.seamgen;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+
+import org.testng.annotations.BeforeGroups;
+
+/**
+ * Base class for Identity Management tests. Every test method of this class or
+ * its subclasses should be member of "identityManagement" group and should
+ * depend on "newProjectGroup" and "generate-entitiesTest" groups to
be executed
+ * in appropriate order. generate-entities.sql script is executed prior to
+ * "identityManagement" group to feed the database with test values.
+ *
+ * @author Jozef Hartinger
+ *
+ */
+public class IdentityManagementTest extends DatabaseTest
+{
+
+ public static final String IDENTITY_MANAGEMENT = "id=identityManagement";
+ public static final String MANAGE_USERS = "id=manageUsers";
+ public static final String CREATE_USER_BUTTON = "id=newUser";
+ public static final String USER_NAME =
"id=userForm:usernameField:username";
+ public static final String USER_PASSWORD =
"id=userForm:passwordField:password";
+ public static final String USER_CONFIRM =
"id=userForm:confirmField:confirm";
+ public static final String USER_ROLES = "id=userForm:rolesField:roles";
+ public static final String USER_ROLE_BY_NAME_CHECKBOX =
"xpath=//input[matches(@id,
'userForm:rolesField:roles:[_]{0,1}[\\d]+')][normalize-space(../label/text()) =
'%s']";
+ public static final String USER_ENABLED =
"id=userForm:enabledField:enabled";
+ public static final String USER_SAVE = "id=userForm:save";
+ public static final String USER_CANCEL = "id=userForm:cancel";
+ public static final String USER_TABLE_ROW_BY_NAME =
"xpath=//table[@id='users' or
@id='usersCmdForm:users']/tbody/tr[normalize-space(./td[1]/text()) =
'%s']";
+ public static final String USER_TABLE_ROLES = "/td[2]";
+ public static final String USER_TABLE_CHECKBOX_CHECKED =
"/td[3]/div[@class='status-true']";
+ public static final String USER_TABLE_CHECKBOX_UNCHECKED =
"/td[3]/div[@class='status-false']";
+ public static final String USER_TABLE_DELETE = "//a[matches(@id,
'users:\\d+:delete') or matches(@id,
'usersCmdForm:users:\\d+:delete')]";
+ public static final String USER_TABLE_EDIT = "//a[matches(@id,
'users:\\d+:edit') or matches(@id,
'usersCmdForm:users:\\d+:edit')]";
+
+ @BeforeGroups(groups = "identityManagement")
+ public void addIdentityManagement() throws FileNotFoundException
+ {
+ seamGen.addIdentityManagement();
+ seamGen.restart();
+ waitForAppToDeploy(HOME_PAGE, FOOTER);
+
+ // execute testing import script
+ InputStream is =
getClass().getResourceAsStream("/org/jboss/seam/test/functional/seamgen/identity-management.sql");
+ executeImportScript(is);
+ // execute default identity management import script
+ String scriptPath = WORKSPACE + "/" + APP_NAME +
"/resources/import-dev.sql";
+ executeImportScript(new FileInputStream(scriptPath));
+ }
+
+}
Property changes on:
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/IdentityManagementTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewActionTest.java
===================================================================
---
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewActionTest.java
(rev 0)
+++
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewActionTest.java 2009-04-08
13:38:06 UTC (rev 10349)
@@ -0,0 +1,82 @@
+/*
+ * 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.test.functional.seamgen;
+
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertTrue;
+
+/**
+ * This class verifies functionality of "new-action command".
+ * @author Jozef Hartinger
+ *
+ */
+public class NewActionTest extends SeleniumSeamGenTest
+{
+
+ protected String[] newComponentProperties;
+
+ @BeforeClass
+ public void createNewAction() throws InterruptedException {
+ prepareData();
+ generateNewComponent();
+ deployNewComponent();
+ waitForAppToDeploy(getComponentPath(), FOOTER);
+ }
+
+
+ @Test(groups = { "newActionGroup" }, dependsOnGroups = {
"newProjectGroup" })
+ public void testNewComponent()
+ {
+ String form = "id=" + newComponentProperties[0] + "Form";
+ String button = form + ":" + newComponentProperties[3];
+
+ browser.open(getComponentPath());
+
+ assertTrue(browser.isElementPresent(FOOTER), "Footer not found.");
+ assertTrue(browser.isElementPresent(form), form + " not found.");
+ assertTrue(browser.isElementPresent(button), button + " not found.");
+
+ browser.clickAndWait(button);
+
+ assertTrue(browser.isElementPresent(MESSAGES));
+ assertTrue(browser.getText(MESSAGES).contains(newComponentProperties[3]));
+ }
+
+ public void generateNewComponent()
+ {
+ seamGen.newAction(newComponentProperties);
+ }
+
+ protected void prepareData() {
+ newComponentProperties = new String[]{ "ping", "PingLocal",
"Ping", "ping", "pingPage" };
+ }
+
+ public String getComponentPath() {
+ return "/" + APP_NAME + "/" + newComponentProperties[4] +
".seam";
+ }
+
+ protected void deployNewComponent() {
+ seamGen.restart();
+ }
+}
Property changes on:
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewActionTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewFormTest.java
===================================================================
---
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewFormTest.java
(rev 0)
+++
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewFormTest.java 2009-04-08
13:38:06 UTC (rev 10349)
@@ -0,0 +1,71 @@
+/*
+ * 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.test.functional.seamgen;
+
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.assertEquals;
+
+import org.testng.annotations.Test;
+
+/**
+ * This class verifies functionality of "new-action command".
+ * @author Jozef Hartinger
+ *
+ */
+public class NewFormTest extends NewActionTest
+{
+
+ @Override
+ @Test(groups = { "newFormGroup" }, dependsOnGroups = {
"newProjectGroup" })
+ public void testNewComponent()
+ {
+
+ String form = "id=" + newComponentProperties[0] + "Form";
+ String button = form + ":" + newComponentProperties[3];
+ String field = form + ":" + "valueField:value";
+ String value = "world";
+
+ browser.open(getComponentPath());
+
+ assertTrue(browser.isElementPresent(FOOTER), "Footer not found.");
+ assertTrue(browser.isElementPresent(form), form + " not found.");
+ assertTrue(browser.isElementPresent(field), field + " not found.");
+ assertTrue(browser.isElementPresent(button), button + " not found.");
+
+ browser.type(field, value);
+ browser.clickAndWait(button);
+
+ assertTrue(browser.isElementPresent(MESSAGES), "Message not found.");
+ assertEquals(browser.getText(MESSAGES), newComponentProperties[3] + " " +
value, "Unexpected form output.");
+ }
+
+ @Override
+ protected void prepareData() {
+ newComponentProperties = new String[]{ "hello", "HelloLocal",
"Hello", "hello", "helloPage" };
+ }
+
+ @Override
+ public void generateNewComponent()
+ {
+ seamGen.newForm(newComponentProperties);
+ }
+}
Property changes on:
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewFormTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewProjectTest.java
===================================================================
---
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewProjectTest.java
(rev 0)
+++
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewProjectTest.java 2009-04-08
13:38:06 UTC (rev 10349)
@@ -0,0 +1,78 @@
+/*
+ * 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.test.functional.seamgen;
+
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import org.testng.annotations.BeforeGroups;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertTrue;
+
+/**
+ * This class is responsible for creating new project and verifying that deployment
+ * and basic functionality works.
+ *
+ * @author Jozef Hartinger
+ *
+ */
+public class NewProjectTest extends SeleniumSeamGenTest
+{
+
+ @BeforeGroups(groups = { "newProjectGroup" })
+ public void setup() throws FileNotFoundException, IOException, InterruptedException
+ {
+
+ // save properties
+ seamGenProperties.store(new FileOutputStream(SEAMGEN_PROPERTIES_FILE),
"Created by seam-gen functional testsuite.");
+ seamGen.createProject();
+ seamGen.deploy();
+ waitForAppToDeploy(HOME_PAGE, FOOTER);
+ }
+
+ @Test(groups = { "newProjectGroup" })
+ public void validLoginTest()
+ {
+ login();
+ // verify login
+ assertTrue(browser.isElementPresent(LOGOUT), "Logout link expected.");
+ assertTrue(browser.getText(SIGNED_USER).contains(DEFAULT_USERNAME), "Username
not found. " + browser.getText(SIGNED_USER) + " found instead.");
+ // logout
+ browser.clickAndWait(LOGOUT);
+ assertTrue(browser.isElementPresent(LOGIN), "Login link expected.");
+ assertTrue(browser.isElementPresent(HOME), "Home link expected.");
+ }
+
+ @Test(groups = { "newProjectGroup" })
+ public void invalidLoginTest()
+ {
+ String username = "badUser";
+ String password = "password";
+
+ login(username, password);
+ // verify login
+ assertTrue(browser.isElementPresent(LOGIN), "User should not be logged
in.");
+ assertTrue(browser.getText(MESSAGES).contains(LOGIN_FAILED_MESSAGE),
LOGIN_FAILED_MESSAGE + " expected.");
+ }
+}
Property changes on:
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/NewProjectTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/PersonTest.java
===================================================================
---
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/PersonTest.java
(rev 0)
+++
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/PersonTest.java 2009-04-08
13:38:06 UTC (rev 10349)
@@ -0,0 +1,123 @@
+/*
+ * 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.test.functional.seamgen;
+
+import java.util.Date;
+
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.assertEquals;
+
+/**
+ * This test verifies CRUD functionality on the Person table.
+ * @author Jozef Hartinger
+ *
+ */
+public class PersonTest extends GenerateEntitiesTest
+{
+
+ public static final String SEARCH_USERNAME = "xpath=//input[matches(@id,
'personSearch:.+:username')]";
+ public static final String SEARCH_SUBMIT = "personSearch:search";
+ public static final String SEARCH_RESET = "personSearch:reset";
+
+ public static final String VIEW_USERNAME =
"xpath=id('username')/div/span[2]";
+ public static final String VIEW_ADDRESS =
"xpath=id('address')/div/span[2]";
+ public static final String VIEW_NAME =
"xpath=id('name')/div/span[2]";
+
+ @Test(groups = "generate-entitiesTest", dependsOnGroups = {
"newProjectGroup" })
+ public void newPersonTest()
+ {
+ login();
+ String username = "tester";
+ String address = "test address";
+ String name = "John Doe";
+ createNewPerson(username, address, new Date(), name);
+
+ assertTrue(browser.isElementPresent(MESSAGES), "Confirmation message
expected.");
+ assertEquals(browser.getText(MESSAGES), "Successfully created",
"Unexpected confirmation message");
+
+ // search for the person
+ browser.clickAndWait(ENTITY_DONE);
+ int result = search(username);
+ assertEquals(result, 1, "Unexpected count of search results after creating new
user");
+ // verify view page
+ browser.clickAndWait(String.format(PERSON_LIST_VIEW_BUTTON_BY_NAME, username));
+ verifyViewPage(username, address, name);
+ }
+
+ @Test(groups = "generate-entitiesTest", dependsOnGroups = {
"newProjectGroup" })
+ public void updatePersonTest()
+ {
+ String username = "johny";
+ String address = "updated address";
+ String name = "Test User";
+
+ login();
+ browser.clickAndWait(PERSON_LINK);
+ String editButton = String.format(PERSON_LIST_EDIT_BUTTON_BY_NAME, username);
+ browser.clickAndWait(editButton);
+ // update the entity
+ fillPersonEditPage(username, address, new Date(), name);
+ browser.clickAndWait(PERSON_UPDATE);
+ // verify
+ assertTrue(browser.isElementPresent(MESSAGES), "Confirmation message
expected.");
+ assertEquals(browser.getText(MESSAGES), "Successfully updated",
"Unexpected confirmation message");
+ verifyViewPage(username, address, name);
+ }
+
+ @Test(groups = "generate-entitiesTest", dependsOnGroups = {
"newProjectGroup" })
+ public void removePersonTest()
+ {
+ String username = "jane";
+
+ login();
+ browser.clickAndWait(PERSON_LINK);
+ String editButton = String.format(PERSON_LIST_EDIT_BUTTON_BY_NAME, username);
+ browser.clickAndWait(editButton);
+ // delete the person
+ browser.clickAndWait(PERSON_DELETE);
+
+ assertTrue(browser.isElementPresent(MESSAGES), "Confirmation message
expected.");
+ assertEquals(browser.getText(MESSAGES), "Successfully deleted",
"Unexpected confirmation message");
+
+ // search for the user
+ int result = search(username);
+ assertEquals(result, 0, "Unexpected count of search results after removing the
user");
+
+ }
+
+ public int search(String pattern)
+ {
+ browser.type(SEARCH_USERNAME, pattern);
+ browser.clickAndWait(SEARCH_SUBMIT);
+ return browser.getXpathCount(PERSON_LIST_RESULT_COUNT).intValue();
+ }
+
+ public void verifyViewPage(String username, String address, String name)
+ {
+ assertEquals(browser.getText(VIEW_USERNAME), username);
+ assertEquals(browser.getText(VIEW_ADDRESS), address);
+ assertEquals(browser.getText(VIEW_NAME), name);
+ }
+
+}
Property changes on:
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/PersonTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/RoleTest.java
===================================================================
---
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/RoleTest.java
(rev 0)
+++
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/RoleTest.java 2009-04-08
13:38:06 UTC (rev 10349)
@@ -0,0 +1,130 @@
+/*
+ * 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.test.functional.seamgen;
+
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.assertFalse;
+
+/**
+ * This test verifies user role management
+ * @author Jozef Hartinger
+ *
+ */
+public class RoleTest extends IdentityManagementTest
+{
+ public static final String MANAGE_ROLES = "id=manageRoles";
+ public static final String CREATE_ROLE_BUTTON = "id=newRole";
+ public static final String ROLE_NAME = "id=roleForm:roleField:role";
+ public static final String ROLE_ROLES = "id=role:roles";
+ public static final String ROLE_MEMBER_OF_BY_NAME_CHECKBOX =
"xpath=//input[matches(@id,
'roleForm:groupsField:groups:[_]{0,1}[\\d]+')][normalize-space(../label/text()) =
'%s']";
+ public static final String ROLE_SAVE = "id=roleForm:save";
+ public static final String ROLE_CANCEL = "id=roleForm:cancel";
+ public static final String ROLE_TABLE_ROW_BY_NAME =
"xpath=//table[(a)id='roles']/tbody/tr[normalize-space(./td[1]/text()) =
'%s']";
+ // these locators can only be used catenated with ROLE_TABLE_ROW_BY_NAME
+ public static final String ROLE_TABLE_ROLES = "/td[2]";
+ public static final String ROLE_TABLE_DELETE = "//a[matches(@id,
'roles:\\d+:delete')]";
+ public static final String ROLE_TABLE_EDIT = "//a[matches(@id,
'roles:\\d+:edit')]";
+
+ @Override
+ @BeforeMethod
+ public void beforeMethod()
+ {
+ super.beforeMethod();
+ login();
+ browser.clickAndWait(IDENTITY_MANAGEMENT);
+ browser.clickAndWait(MANAGE_ROLES);
+ }
+
+ @Test(groups = { "identityManagement" }, dependsOnGroups = {
"newProjectGroup", "generate-entitiesTest" }, alwaysRun = true)
+ public void roleCreatingTest()
+ {
+ String roleName = "golfer";
+ String[] roles = { "admin", "designer" };
+ createNewRole(roleName, roles);
+ // check that new role is added to role list
+ String roleRow = String.format(ROLE_TABLE_ROW_BY_NAME, roleName);
+ assertTrue(browser.isElementPresent(roleRow), "New role not found in role
list.");
+ String roleTableRoles = browser.getText(roleRow + ROLE_TABLE_ROLES);
+ for (String role : roles)
+ {
+ assertTrue(roleTableRoles.contains(role), "New role is not member of "
+ role + " role.");
+ }
+ // check that new role is available to users
+ browser.clickAndWait(IDENTITY_MANAGEMENT);
+ browser.clickAndWait(MANAGE_USERS);
+ browser.clickAndWait(CREATE_USER_BUTTON);
+ String expectedRole = String.format(USER_ROLE_BY_NAME_CHECKBOX, roleName);
+ assertTrue(browser.isElementPresent(expectedRole), "New role is not available
when creating new user.");
+ }
+
+ @Test(groups = { "identityManagement" }, dependsOnGroups = {
"newProjectGroup", "generate-entitiesTest" }, alwaysRun = true)
+ public void roleEditingTest()
+ {
+ String oldRoleName = "QA";
+ String newRoleName = "QE";
+ String[] newRoles = { "student", "admin", "pilot",
"designer" };
+
+ String oldRoleRow = String.format(ROLE_TABLE_ROW_BY_NAME, oldRoleName);
+ browser.clickAndWait(oldRoleRow + ROLE_TABLE_EDIT);
+ fillRoleDetails(newRoleName, newRoles);
+ browser.clickAndWait(ROLE_SAVE);
+ String newRoleRow = String.format(ROLE_TABLE_ROW_BY_NAME, newRoleName);
+ assertFalse(browser.isElementPresent(oldRoleRow), "Old role still
present.");
+ assertTrue(browser.isElementPresent(newRoleRow), "Updated role not found in
role table.");
+ String updatedRoleTableRoles = browser.getText(newRoleRow + ROLE_TABLE_ROLES);
+ for (String role : newRoles)
+ {
+ assertTrue(updatedRoleTableRoles.contains(role), "New role is not member of
" + role + " role.");
+ }
+ }
+
+ @Test(groups = { "identityManagement" }, dependsOnGroups = {
"newProjectGroup", "generate-entitiesTest" }, alwaysRun = true)
+ public void roleDeletingTest()
+ {
+ String roleName = "commiter";
+
+ String roleRow = String.format(ROLE_TABLE_ROW_BY_NAME, roleName);
+ browser.chooseOkOnNextConfirmation();
+ browser.clickAndWait(roleRow + ROLE_TABLE_DELETE);
+ assertFalse(browser.isElementPresent(roleRow), "Removed role still
present.");
+ }
+
+ public void createNewRole(String name, String[] roles)
+ {
+ browser.clickAndWait(CREATE_ROLE_BUTTON);
+ fillRoleDetails(name, roles);
+ browser.clickAndWait(ROLE_SAVE);
+ }
+
+ public void fillRoleDetails(String name, String[] roles)
+ {
+ browser.type(ROLE_NAME, name);
+ for (String role : roles)
+ {
+
assertTrue(browser.isElementPresent(String.format(ROLE_MEMBER_OF_BY_NAME_CHECKBOX, role)),
"Role not available: " + role);
+ browser.check(String.format(ROLE_MEMBER_OF_BY_NAME_CHECKBOX, role));
+ }
+ }
+
+}
Property changes on:
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/RoleTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/SeamGenTest.java
===================================================================
---
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/SeamGenTest.java
(rev 0)
+++
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/SeamGenTest.java 2009-04-08
13:38:06 UTC (rev 10349)
@@ -0,0 +1,198 @@
+/*
+ * 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.test.functional.seamgen;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Properties;
+
+import org.jboss.seam.test.functional.seamgen.utils.SeamGenAdapter;
+import org.openqa.selenium.server.RemoteControlConfiguration;
+import org.openqa.selenium.server.SeleniumServer;
+import org.testng.annotations.AfterSuite;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeSuite;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Optional;
+import org.testng.annotations.Parameters;
+
+/**
+ * Base class for seam-gen functional tests.
+ * @author Jozef Hartinger
+ */
+public class SeamGenTest
+{
+
+ protected static SeamGenAdapter seamGen;
+ protected static Properties seamGenProperties;
+ protected static Properties ftestProperties = new Properties();
+
+ protected static String SEAM_DIR;
+ protected static String SEAM_FTEST_PROPERTIES_FILE;
+ protected static String SEAMGEN_BUILDFILE;
+ protected static String SEAMGEN_PROPERTIES_FILE;
+ protected static String WORKSPACE;
+
+ // container specific properties
+ protected static String CONTAINER;
+ protected static String CONTAINER_LOCATION;
+ protected static int DEPLOY_TIMEOUT;
+
+ protected static boolean ICEFACES;
+ protected static boolean WAR;
+
+ protected static boolean DELETE_PROJECT;
+
+ protected static String TEST_SEAMGEN_PROPERTIES_FILE;
+
+ // Selenium related constants
+ protected static String SELENIUM_HOST;
+ protected static String SELENIUM_BROWSER;
+ protected static String SELENIUM_BROWSER_URL;
+ protected static int SELENIUM_SERVER_PORT;
+ protected static String SELENIUM_SPEED;
+ protected static String SELENIUM_TIMEOUT;
+ protected static long SELENIUM_ICEFACES_WAIT_TIME;
+
+ protected static String OUTPUT_DIR;
+
+ // Test application specific constants
+ protected static String APP_NAME;
+ protected static String HOME_PAGE;
+
+ // Selenium server instance
+ protected static SeleniumServer seleniumServer;
+
+ @BeforeSuite
+ @Parameters("seam.dir")
+ public void beforeSuite((a)Optional(".") String seamDir) throws Exception {
+ // Seam location
+ SEAM_DIR = seamDir;
+ SEAM_FTEST_PROPERTIES_FILE = SEAM_DIR +
"/src/test/ftest/ftest.properties";
+ SEAMGEN_BUILDFILE = SEAM_DIR + "/seam-gen/build.xml";
+ SEAMGEN_PROPERTIES_FILE = SEAM_DIR + "/seam-gen/build.properties";
+ OUTPUT_DIR = SEAM_DIR + "/test-output/functional-framework/";
+
+ loadFtestProperties();
+ createOutputDir();
+ startSeleniumServer();
+ }
+
+ @AfterSuite
+ public void afterSuite() {
+ seleniumServer.stop();
+ }
+
+ @BeforeTest
+ @Parameters( { "icefaces", "type", "suffix",
"explode" })
+ public void setUp(@Optional("false") boolean icefaces,
@Optional("ear") String type, @Optional("") String suffix,
@Optional("true") boolean explode) throws Exception
+ {
+ ICEFACES = icefaces;
+ WAR = type.equalsIgnoreCase("war");
+ APP_NAME = "seamGenTestApp" + (ICEFACES ? "Ice" :
"Rich") + (WAR ? "War" : "Ear") + (explode? "E" :
"D") + suffix;
+ HOME_PAGE = "/" + APP_NAME + "/home.seam";
+
+ setSeamGenProperties();
+
+ seamGen = new SeamGenAdapter(SEAMGEN_BUILDFILE);
+ seamGen.setExplode(explode);
+
+ }
+
+ @AfterTest
+ public void tearDown()
+ {
+ if (DELETE_PROJECT)
+ {
+ seamGen.deleteProject();
+ }
+ else
+ {
+ seamGen.undeploy();
+ }
+ }
+
+ private void loadFtestProperties() throws FileNotFoundException, IOException
+ {
+ // load general properties
+ ftestProperties.load(new FileInputStream(SEAM_FTEST_PROPERTIES_FILE));
+
+ WORKSPACE = ftestProperties.getProperty("workspace.home");
+
+ // container specific
+ CONTAINER = ftestProperties.getProperty("container",
"jboss5");
+ CONTAINER_LOCATION = ftestProperties.getProperty(CONTAINER + ".home");
+ DEPLOY_TIMEOUT = Integer.parseInt(ftestProperties.getProperty(CONTAINER +
".deploy.waittime")) * 1000; // miliseconds
+ DELETE_PROJECT =
Boolean.valueOf(ftestProperties.getProperty("seamgen.delete.project",
"false"));
+
+ // load selenium constants
+ SELENIUM_HOST = ftestProperties.getProperty("selenium.host");
+ SELENIUM_BROWSER = ftestProperties.getProperty("selenium.browser");
+ SELENIUM_BROWSER_URL =
ftestProperties.getProperty("selenium.browser.url");
+ SELENIUM_SERVER_PORT =
Integer.parseInt(ftestProperties.getProperty("selenium.server.port"));
+ SELENIUM_SPEED = ftestProperties.getProperty("selenium.speed");
+ SELENIUM_TIMEOUT = ftestProperties.getProperty("selenium.timeout");
+ SELENIUM_ICEFACES_WAIT_TIME =
Long.valueOf(ftestProperties.getProperty("selenium.icefaces.wait.time",
"2000"));
+ }
+
+ private void setSeamGenProperties()
+ {
+ seamGenProperties = new Properties();
+
+ String[] propertiesToCopy = { "database.type",
"database.exists", "database.drop", "driver.jar",
"driver.license.jar", "hibernate.connection.username",
"hibernate.connection.password", "hibernate.connection.driver_class",
"hibernate.connection.dataSource_class",
"hibernate.cache.provider_class", "hibernate.default_catalog.null",
"hibernate.default_schema.null", "hibernate.dialect",
"hibernate.connection.url", "model.package",
"action.package", "test.package", "richfaces.skin",
"icefaces.home", "jboss.home" };
+
+ for (String property : propertiesToCopy)
+ {
+ if (ftestProperties.get(property) != null)
+ {
+ seamGenProperties.put(property, ftestProperties.get(property));
+ }
+ }
+
+ // override with ftest.properties
+ seamGenProperties.put("workspace.home", WORKSPACE);
+ seamGenProperties.put("jboss.home", CONTAINER_LOCATION);
+ seamGenProperties.put("icefaces", ICEFACES ? "y" :
"n");
+ seamGenProperties.put("project.type", WAR ? "war" :
"ear");
+ seamGenProperties.put("project.name", APP_NAME);
+ }
+
+ private void startSeleniumServer() throws Exception
+ {
+ RemoteControlConfiguration rcc = new RemoteControlConfiguration();
+ rcc.setPort(SELENIUM_SERVER_PORT);
+ rcc.setLogOutFileName(OUTPUT_DIR + "/selenium-server.log");
+ seleniumServer = new SeleniumServer(rcc);
+ seleniumServer.start();
+ }
+
+ private void createOutputDir()
+ {
+ File dir = new File(OUTPUT_DIR);
+ if (!dir.exists())
+ {
+ dir.mkdir();
+ }
+ }
+}
Property changes on:
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/SeamGenTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/SeleniumSeamGenTest.java
===================================================================
---
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/SeleniumSeamGenTest.java
(rev 0)
+++
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/SeleniumSeamGenTest.java 2009-04-08
13:38:06 UTC (rev 10349)
@@ -0,0 +1,159 @@
+/*
+ * 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.test.functional.seamgen;
+
+import static org.testng.Assert.assertTrue;
+
+import org.jboss.seam.example.common.test.selenium.SeamSelenium;
+import org.testng.annotations.BeforeMethod;
+
+/**
+ * Base class for Selenium seam-gen tests. Separate browser instance is created
+ * prior to each test method execution. Browser instances are stopped by
+ * SeleniumTestListener.
+ *
+ * @author Jozef Hartinger
+ *
+ */
+public class SeleniumSeamGenTest extends SeamGenTest
+{
+ // home page
+ public static final String LOGIN = "id=menuLoginId";
+ public static final String LOGOUT = "id=menuLogoutId";
+ public static final String HOME = "id=menuHomeId";
+ public static final String SIGNED_USER = "id=menuWelcomeId";
+ // login page
+ public static final String LOGIN_USERNAME = "id=loginForm:username";
+ public static final String LOGIN_PASSWORD = "id=loginForm:password";
+ public static final String LOGIN_REMEMBER_ME = "id=loginForm:rememberMe";
+ public static final String LOGIN_SUBMIT = "id=loginForm:submit";
+ public static final String LOGIN_FAILED_MESSAGE = "Login failed";
+
+ public static final String MESSAGES = "id=messages";
+ public static final String FOOTER = "xpath=//div[@class =
'footer']";
+ public static final String MESSAGE_WELCOME = "xpath=//h1[text() = 'Welcome to
Seam!']";
+
+ public static final String DEFAULT_USERNAME = "admin";
+ public static final String DEFAULT_PASSWORD = "";
+
+ public static SeamSelenium browser;
+
+ /**
+ * Start new browser instance and store it into static variable. Moreover,
+ * open application home page.
+ */
+ public void initBrowser()
+ {
+ browser = startBrowser();
+ browser.open(HOME_PAGE);
+ }
+
+ /**
+ * Create new browser instance.
+ */
+ public SeamSelenium startBrowser()
+ {
+ SeamSelenium newBrowser = new SeamSelenium(SELENIUM_HOST, SELENIUM_SERVER_PORT,
SELENIUM_BROWSER, SELENIUM_BROWSER_URL);
+ newBrowser.start();
+ newBrowser.allowNativeXpath("false");
+ newBrowser.setSpeed(SELENIUM_SPEED);
+ newBrowser.setTimeout(SELENIUM_TIMEOUT);
+ if (ICEFACES)
+ {
+ newBrowser.setIcefacesDetection(true);
+ }
+ newBrowser.setIcefacesWaitTime(SELENIUM_ICEFACES_WAIT_TIME);
+ return newBrowser;
+ }
+
+ public void stopBrowser()
+ {
+ browser.stop();
+ }
+
+ public void login(String username, String password)
+ {
+ assertTrue(browser.isElementPresent(LOGIN), "Login link expected.");
+ browser.clickAndWait(LOGIN);
+ browser.type(LOGIN_USERNAME, username);
+ browser.type(LOGIN_PASSWORD, password);
+ browser.clickAndWait(LOGIN_SUBMIT);
+ }
+
+ public void login()
+ {
+ login(DEFAULT_USERNAME, DEFAULT_PASSWORD);
+ }
+
+ public boolean isLoggedIn()
+ {
+ return browser.isElementPresent(SIGNED_USER) &&
browser.isElementPresent(LOGOUT) && !browser.isElementPresent(LOGIN);
+ }
+
+ public void logout()
+ {
+ browser.clickAndWait(LOGOUT);
+ }
+
+ @BeforeMethod
+ public void beforeMethod()
+ {
+ initBrowser();
+ }
+
+ /**
+ * Wait for application (or it's part) to deploy. Separate Selenium browser
+ * instance is used to poll server for specified URL, waiting for specified
+ * element to appear.
+ */
+ public void waitForAppToDeploy(String url, String element)
+ {
+ int step = 5000;
+ int i = DEPLOY_TIMEOUT;
+
+ SeamSelenium browser = startBrowser();
+
+ browser.open(url);
+ try
+ {
+ while (!browser.isElementPresent(element))
+ {
+ i -= step;
+ if (i <= 0)
+ {
+ throw new RuntimeException("Timeout waiting for " + element +
" at " + url);
+ }
+ Thread.sleep(step);
+ browser.open(url); // try again
+ }
+ }
+ catch (InterruptedException ie)
+ {
+ throw new RuntimeException(ie);
+ }
+ finally
+ {
+ browser.stop();
+ }
+ }
+
+}
Property changes on:
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/SeleniumSeamGenTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/UserTest.java
===================================================================
---
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/UserTest.java
(rev 0)
+++
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/UserTest.java 2009-04-08
13:38:06 UTC (rev 10349)
@@ -0,0 +1,157 @@
+/*
+ * 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.test.functional.seamgen;
+
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.assertFalse;
+
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * This class verifies user management.
+ * @author Jozef Hartinger
+ *
+ */
+public class UserTest extends IdentityManagementTest
+{
+
+ @Override
+ @BeforeMethod
+ public void beforeMethod()
+ {
+ super.beforeMethod();
+ login();
+ browser.clickAndWait(IDENTITY_MANAGEMENT);
+ browser.clickAndWait(MANAGE_USERS);
+ }
+
+ @Test(groups = { "identityManagement" }, dependsOnGroups = {
"newProjectGroup", "generate-entitiesTest" }, alwaysRun = true)
+ public void userCreatingTest()
+ {
+ String username = "jharting";
+ String password = "topSecret";
+ String[] roles = { "admin", "student", "pilot" };
+ createNewUser(username, password, password, roles, true);
+ String userRow = String.format(USER_TABLE_ROW_BY_NAME, username);
+ // check user list
+ assertTrue(browser.isElementPresent(userRow), "User not found in
userlist.");
+ for (String role : roles)
+ {
+ assertTrue(browser.getText(userRow + USER_TABLE_ROLES).contains(role),
"User not in " + role + " role.");
+ }
+ assertTrue(browser.isElementPresent(userRow + USER_TABLE_CHECKBOX_CHECKED),
"User not enabled.");
+ // check new user can login
+ browser.clickAndWait(LOGOUT);
+ login(username, password);
+ assertTrue(isLoggedIn(), "Unable to login with new user's
credentials.");
+ }
+
+ @Test(groups = { "identityManagement" }, dependsOnGroups = {
"newProjectGroup", "generate-entitiesTest" }, alwaysRun = true)
+ public void userEditingTest()
+ {
+ String username = "shadowman";
+ String newPassword = "password";
+ String[] newRoles = { "admin", "tester", "designer"
};
+ String userRow = String.format(USER_TABLE_ROW_BY_NAME, username);
+ browser.clickAndWait(userRow + USER_TABLE_EDIT);
+ fillUpdatableUserDetails(newPassword, newPassword, newRoles, true);
+ browser.clickAndWait(USER_SAVE);
+ for (String role : newRoles)
+ {
+ assertTrue(browser.getText(userRow + USER_TABLE_ROLES).contains(role),
"User not in " + role + " role.");
+ }
+ logout();
+ login(username, newPassword);
+ assertTrue(isLoggedIn(), "Unable to login with changed password");
+ }
+
+ @Test(groups = { "identityManagement" }, dependsOnGroups = {
"newProjectGroup", "generate-entitiesTest" }, alwaysRun = true)
+ public void userDeletingTest()
+ {
+ String username = "tester";
+ String userRow = String.format(USER_TABLE_ROW_BY_NAME, username);
+ assertTrue(browser.isElementPresent(userRow), "User " + username + "
not in user list.");
+ browser.chooseOkOnNextConfirmation();
+ browser.click(userRow + USER_TABLE_DELETE);
+ browser.getConfirmation();
+ browser.waitForPageToLoad();
+ assertFalse(browser.isElementPresent(userRow), "User " + username +
" exists after deletion");
+ }
+
+ @Test(groups = { "identityManagement" }, dependsOnGroups = {
"newProjectGroup", "generate-entitiesTest" }, alwaysRun = true)
+ public void cancelledUserDeletingTest() throws InterruptedException
+ {
+ String username = "demo";
+ String userRow = String.format(USER_TABLE_ROW_BY_NAME, username);
+ assertTrue(browser.isElementPresent(userRow), "User " + username + "
not in user list.");
+ browser.chooseCancelOnNextConfirmation();
+ browser.click(userRow + USER_TABLE_DELETE);
+ browser.getConfirmation();
+ browser.refreshAndWait();
+ assertTrue(browser.isElementPresent(userRow), "User " + username + "
missing in user list after cancelled deletion.");
+ }
+
+ @Test(groups = { "identityManagement" }, dependsOnGroups = {
"newProjectGroup", "generate-entitiesTest" }, alwaysRun = true)
+ public void disablingUserAccountTest()
+ {
+ String username = "johndoe";
+ String password = "password";
+ String userRow = String.format(USER_TABLE_ROW_BY_NAME, username);
+ createNewUser(username, password, password, new String[] { "admin",
"student" }, false);
+ assertTrue(browser.isElementPresent(userRow), "User not found in
userlist.");
+ assertTrue(browser.isElementPresent(userRow + USER_TABLE_CHECKBOX_UNCHECKED),
"User account enabled.");
+ logout();
+ login(username, password);
+ assertFalse(isLoggedIn(), "User logged in despite his account was
disabled.");
+ }
+
+ private void createNewUser(String username, String password, String confirm, String[]
roles, boolean enabled)
+ {
+ browser.clickAndWait(CREATE_USER_BUTTON);
+ fillNewUserDetails(username, password, confirm, roles, enabled);
+ browser.clickAndWait(USER_SAVE);
+ }
+
+ private void fillNewUserDetails(String username, String password, String confirm,
String[] roles, boolean enabled)
+ {
+ browser.type(USER_NAME, username);
+ fillUpdatableUserDetails(password, confirm, roles, enabled);
+ }
+
+ private void fillUpdatableUserDetails(String password, String confirm, String[] roles,
boolean enabled)
+ {
+ browser.type(USER_PASSWORD, password);
+ browser.type(USER_CONFIRM, confirm);
+ for (String role : roles)
+ {
+ assertTrue(browser.isElementPresent(String.format(USER_ROLE_BY_NAME_CHECKBOX,
role)), "Unable to add user to role: " + role);
+ browser.check(String.format(USER_ROLE_BY_NAME_CHECKBOX, role));
+ }
+ if (enabled)
+ {
+ browser.check(USER_ENABLED);
+ } else {
+ browser.uncheck(USER_ENABLED);
+ }
+ }
+}
Property changes on:
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/UserTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/VehicleTest.java
===================================================================
---
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/VehicleTest.java
(rev 0)
+++
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/VehicleTest.java 2009-04-08
13:38:06 UTC (rev 10349)
@@ -0,0 +1,167 @@
+/*
+ * 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.test.functional.seamgen;
+
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.assertEquals;
+
+/**
+ * This class tests CRUD on the Vehicle database table.
+ * @author Jozef Hartinger
+ *
+ */
+public class VehicleTest extends GenerateEntitiesTest
+{
+
+ public static final String SEARCH_REGISTRATION = "xpath=//input[matches(@id,
'vehicleSearch:.+:registration')]";
+ public static final String SEARCH_SUBMIT = "vehicleSearch:search";
+ public static final String SEARCH_RESET = "vehicleSearch:reset";
+
+ public static final String VIEW_REGISTRATION =
"xpath=id('registration')/div/span[2]";
+ public static final String VIEW_STATE =
"xpath=id('state')/div/span[2]";
+ public static final String VIEW_MAKE =
"xpath=id('make')/div/span[2]";
+ public static final String VIEW_MODEL =
"xpath=id('model')/div/span[2]";
+ public static final String VIEW_YEAR =
"xpath=id('year')/div/span[2]";
+
+ @Test(groups = "generate-entitiesTest", dependsOnGroups = {
"newProjectGroup" })
+ public void newVehicleTest()
+ {
+ login();
+ String registration = "44444444";
+ String state = "SK";
+ String make = "Honda";
+ String model = "Civic";
+ String year = "2008";
+ createNewVehicle(registration, state, make, model, year);
+
+ assertTrue(browser.isElementPresent(MESSAGES), "Confirmation message
expected.");
+ assertEquals(browser.getText(MESSAGES), "Successfully created",
"Unexpected confirmation message");
+
+ // search for the vehicle
+ browser.clickAndWait(ENTITY_DONE);
+ int result = search(registration);
+ assertEquals(result, 1, "Unexpected count of search results after creating new
vehicle");
+ // verify view page
+ browser.clickAndWait(String.format(VEHICLE_LIST_VIEW_BUTTON_BY_REGISTRATION,
registration));
+ verifyViewPage(registration, state, make, model, year);
+ }
+
+ @Test(groups = "generate-entitiesTest", dependsOnGroups = {
"newProjectGroup" }, dependsOnMethods = { "newVehicleTest" })
+ public void updateVehicleTest()
+ {
+ String registration = "11111111";
+ String state = "CZ";
+ String make = "Mazda";
+ String model = "6";
+ String year = "2005";
+
+ login();
+ browser.clickAndWait(VEHICLE_LINK);
+ String editButton = String.format(VEHICLE_LIST_EDIT_BUTTON_BY_REGISTRATION,
registration);
+ browser.clickAndWait(editButton);
+ // update the entity
+ fillVehicleEditPage(registration, state, make, model, year);
+ browser.clickAndWait(VEHICLE_UPDATE);
+ // verify
+ assertTrue(browser.isElementPresent(MESSAGES), "Confirmation message
expected.");
+ assertEquals(browser.getText(MESSAGES), "Successfully updated",
"Unexpected confirmation message");
+ verifyViewPage(registration, state, make, model, year);
+ }
+
+ @Test(groups = "generate-entitiesTest", dependsOnGroups = {
"newProjectGroup" })
+ public void removeVehicleTest()
+ {
+ String registration = "22222222";
+
+ login();
+ browser.clickAndWait(VEHICLE_LINK);
+ String editButton = String.format(VEHICLE_LIST_EDIT_BUTTON_BY_REGISTRATION,
registration);
+ browser.clickAndWait(editButton);
+ // delete the person
+ browser.clickAndWait(VEHICLE_DELETE);
+
+ assertTrue(browser.isElementPresent(MESSAGES), "Confirmation message
expected.");
+ assertEquals(browser.getText(MESSAGES), "Successfully deleted",
"Unexpected confirmation message");
+
+ // search for the user
+ int result = search(registration);
+ assertEquals(result, 0, "Unexpected count of search results after removing the
user");
+ }
+
+ @Test(groups = "generate-entitiesTest", dependsOnGroups = {
"newProjectGroup" })
+ public void selectVehicleTest()
+ {
+
+ String username = "jharting";
+
+ login();
+ // create new vehicle
+ String registration = "33333333";
+ String state = "SK";
+ String make = "Mazda";
+ String model = "RX-8";
+ String year = "2008";
+ createNewVehicle(registration, state, make, model, year);
+ // select person
+ browser.clickAndWait(ENTITY_EDIT);
+ browser.clickAndWait(ENTITY_SELECT_PARENT_BUTTON);
+ browser.clickAndWait(String.format(PERSON_LIST_VIEW_BUTTON_BY_NAME, username));
+ browser.clickAndWait(VEHICLE_UPDATE);
+ // verify update is OK
+ assertTrue(browser.isElementPresent(MESSAGES), "Confirmation message
expected.");
+ assertEquals(browser.getText(MESSAGES), "Successfully updated",
"Unexpected confirmation message");
+ browser.clickAndWait(ENTITY_DONE);
+ // search for vehicle
+ int result = search(registration);
+ assertEquals(result, 1, "Unexpected count of search results after assigning a
vehicle owner");
+ // verify person is assigned to vehicle
+ assertTrue(browser.isElementPresent(String.format(VEHICLE_LIST_ROW_BY_OWNER_NAME,
registration, username)), "Person not assigned to vehicle.");
+ }
+
+ @Test(groups = "generate-entitiesTest", dependsOnGroups = {
"newProjectGroup" })
+ public void searchTest()
+ {
+ final String searchString = "9999999"; // should return two Audis
+
+ login();
+ browser.clickAndWait(VEHICLE_LINK);
+ assertEquals(search(searchString), 2, "Unexpected number of search results for
" + searchString);
+ }
+
+ public int search(String pattern)
+ {
+ browser.type(SEARCH_REGISTRATION, pattern);
+ browser.clickAndWait(SEARCH_SUBMIT);
+ return browser.getXpathCount(VEHICLE_LIST_RESULT_COUNT).intValue();
+ }
+
+ public void verifyViewPage(String registration, String state, String make, String
model, String year)
+ {
+ assertEquals(browser.getText(VIEW_REGISTRATION), registration);
+ assertEquals(browser.getText(VIEW_STATE), state);
+ assertEquals(browser.getText(VIEW_MAKE), make);
+ assertEquals(browser.getText(VIEW_MODEL), model);
+ assertEquals(browser.getText(VIEW_YEAR), year);
+ }
+}
Property changes on:
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/VehicleTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/generate-entities.sql
===================================================================
---
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/generate-entities.sql
(rev 0)
+++
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/generate-entities.sql 2009-04-08
13:38:06 UTC (rev 10349)
@@ -0,0 +1,26 @@
+# This script is executed prior to "generate-entitiesTest" phase of a testsuite
to feed the database with test data.
+#
+# by Jozef Hartinger
+#
+
+# drop itentity management tables from previous run
+DROP TABLE IF EXISTS user_account;
+DROP TABLE IF EXISTS user_account_role;
+DROP TABLE IF EXISTS user_permission;
+DROP TABLE IF EXISTS user_role;
+DROP TABLE IF EXISTS user_role_group;
+
+# empty testing tables
+DELETE FROM Vehicle;
+DELETE FROM Person;
+
+# Person table inserts
+INSERT INTO Person (username, name, birthdate, address) values ('johny',
'John Doe', '2009-01-01', 'test address'); # updatePersonTest
+INSERT INTO Person (username, name, birthdate, address) values ('jane', 'Jane
Doe', '2009-01-01', 'test address'); # removePersonTest
+INSERT INTO Person (username, name, birthdate, address) values ('jharting',
'Jozef Hartinger', '1987-01-01', 'Purkynova 99, Brno'); #
selectVehicleTest
+
+# Vehicle table inserts
+INSERT INTO Vehicle (make, model, year, registration, state) values ('Honda',
'Civic', '2008', '11111111', 'CZ'); # updateVehicleTest
+INSERT INTO Vehicle (make, model, year, registration, state) values ('Nissan',
'350z', '2006', '22222222', 'CZ'); # removeVehicleTest
+INSERT INTO Vehicle (make, model, year, registration, state) values ('Audi',
'A5', '2009', '99999991', 'CZ'); # searchTest
+INSERT INTO Vehicle (make, model, year, registration, state) values ('Audi',
'A4', '2009', '99999992', 'CZ'); # searchTest
\ No newline at end of file
Added:
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/identity-management.sql
===================================================================
---
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/identity-management.sql
(rev 0)
+++
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/identity-management.sql 2009-04-08
13:38:06 UTC (rev 10349)
@@ -0,0 +1,26 @@
+# This script is executed prior to "identityManagement" phase of a testsuite to
feed the database with test data.
+#
+# by Jozef Hartinger
+#
+
+DELETE FROM user_account;
+DELETE FROM user_account_role;
+DELETE FROM user_permission;
+DELETE FROM user_role;
+DELETE FROM user_role_group;
+
+# test users
+insert into user_account (id, username, password_hash, enabled) values (100,
'shadowman', 'Ss/jICpf9c9GeJj8WKqx1hUClEE=', 1);
+insert into user_account (id, username, password_hash, enabled) values (101,
'tester', 'Ss/jICpf9c9GeJj8WKqx1hUClEE=', 1); # used by userDeletingTest
+insert into user_account (id, username, password_hash, enabled) values (102,
'demo', 'Ss/jICpf9c9GeJj8WKqx1hUClEE=', 1);
+
+# test groups
+insert into user_role (id, name, conditional) values (100, 'commiter', false); #
used by roleDeletingTest
+insert into user_role (id, name, conditional) values (101, 'tester', false); #
used by several tests, do not delete or modify this role
+insert into user_role (id, name, conditional) values (102, 'QA', false);
+insert into user_role (id, name, conditional) values (103, 'designer', false); #
used by several tests, do not delete or modify this role
+insert into user_role (id, name, conditional) values (104, 'pilot', false); #
used by several tests, do not delete or modify this role
+insert into user_role (id, name, conditional) values (105, 'student', false); #
used by several tests, do not delete or modify this role
+
+#insert into user_account_role (account_id, member_of_role) values (1, 1);
+#insert into user_role_group (role_id, member_of_role) values (2, 102);
\ No newline at end of file
Added:
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/utils/SeamGenAdapter.java
===================================================================
---
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/utils/SeamGenAdapter.java
(rev 0)
+++
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/utils/SeamGenAdapter.java 2009-04-08
13:38:06 UTC (rev 10349)
@@ -0,0 +1,204 @@
+/*
+ * 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.test.functional.seamgen.utils;
+
+import java.io.File;
+import java.io.PrintStream;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DefaultLogger;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.ProjectHelper;
+import org.apache.tools.ant.input.InputHandler;
+import org.apache.tools.ant.input.InputRequest;
+
+/**
+ * This class wraps seam-gen ant script in order to be easily usable from Java.
+ * Methods of this class corespond to seam-gen targets. Note that deploy and
+ * undeploy methods are using explode variants of the targets if icefaces
+ * variable is set to true which it is by default.
+ *
+ * @author Jozef Hartinger
+ *
+ */
+public class SeamGenAdapter
+{
+
+ private String buildfile;
+ private DefaultLogger log;
+ private boolean explode = true;
+
+ public SeamGenAdapter(String buildfile)
+ {
+ this(buildfile, System.out, System.err);
+ }
+
+ public SeamGenAdapter(String buildfile, PrintStream out, PrintStream err)
+ {
+ this.buildfile = buildfile;
+ log = new DefaultLogger();
+ log.setOutputPrintStream(out);
+ log.setErrorPrintStream(err);
+ log.setMessageOutputLevel(Project.MSG_INFO);
+ }
+
+ public Project getAntCall()
+ {
+ Project ant = new Project();
+ ant.init();
+ ProjectHelper.configureProject(ant, new File(buildfile));
+ // ant.addBuildListener(log);
+ return ant;
+ }
+
+ public void createProject()
+ {
+ getAntCall().executeTarget("create-project");
+ }
+
+ public void deleteProject()
+ {
+ getAntCall().executeTarget("delete-project");
+ }
+
+ public void newAction(String[] properties)
+ {
+ Project project = getAntCall();
+ project.setInputHandler(getInputHandler(properties));
+ project.executeTarget("new-action");
+ }
+
+ public void newForm(String[] properties)
+ {
+ Project project = getAntCall();
+ project.setInputHandler(getInputHandler(properties));
+ project.executeTarget("new-form");
+ }
+
+ public void generateEntities()
+ {
+ getAntCall().executeTarget("generate-entities");
+ }
+
+ /**
+ * Deploy the application. Using either explode or deploy target, depending
+ * on explode property.
+ */
+ public void deploy()
+ {
+ if (explode)
+ {
+ getAntCall().executeTarget("explode");
+ }
+ else
+ {
+ getAntCall().executeTarget("deploy");
+ }
+ }
+
+ /**
+ * Undeploy the application. Using either unexplode or undeploy target,
+ * depending on explode property.
+ */
+ public void undeploy()
+ {
+ if (explode)
+ {
+ getAntCall().executeTarget("unexplode");
+ }
+ else
+ {
+ getAntCall().executeTarget("undeploy");
+ }
+ }
+
+ public void hotDeploy()
+ {
+ if (explode)
+ {
+ getAntCall().executeTarget("explode");
+ }
+ else
+ {
+ throw new IllegalStateException("Unable to hot deploy non-exploded
archive");
+ }
+ }
+
+ public void restart()
+ {
+ getAntCall().executeTarget("restart");
+ }
+
+ public void addIdentityManagement()
+ {
+ getAntCall().executeTarget("add-identity-management");
+ }
+
+ private InputHandler getInputHandler(final String[] properties)
+ {
+ return new InputHandler()
+ {
+ public void handleInput(InputRequest request) throws BuildException
+ {
+ if (request.getPrompt().contains("Enter the Seam component name"))
+ {
+ request.setInput(properties[0]);
+ }
+ else if (request.getPrompt().contains("Enter the local interface
name"))
+ {
+ request.setInput(properties[1]);
+ }
+ else if (request.getPrompt().contains("Enter the bean class
name"))
+ {
+ request.setInput(properties[2]);
+ }
+ else if (request.getPrompt().contains("Enter the action method
name"))
+ {
+ request.setInput(properties[3]);
+ }
+ else if (request.getPrompt().contains("Enter the page name"))
+ {
+ request.setInput(properties[4]);
+ }
+ else
+ {
+ throw new RuntimeException("Unexpected prompt " +
request.getPrompt());
+ }
+ }
+ };
+ }
+
+ public boolean isExplode()
+ {
+ return explode;
+ }
+
+ /**
+ * Set "deploy" or "explode" variant of deployment.
"Explode" is used by
+ * default.
+ */
+ public void setExplode(boolean explode)
+ {
+ this.explode = explode;
+ }
+
+}
Property changes on:
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/utils/SeamGenAdapter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/utils/SeleniumTestListener.java
===================================================================
---
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/utils/SeleniumTestListener.java
(rev 0)
+++
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/utils/SeleniumTestListener.java 2009-04-08
13:38:06 UTC (rev 10349)
@@ -0,0 +1,73 @@
+/*
+ * 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.test.functional.seamgen.utils;
+
+import org.jboss.seam.test.functional.seamgen.SeleniumSeamGenTest;
+import org.testng.ITestContext;
+import org.testng.ITestListener;
+import org.testng.ITestResult;
+
+/**
+ * Test listener. Captures screenshot and HTML source into the output directory
+ * if test fails. Furthermore, this class is responsible for stopping the
+ * browser instance after the test.
+ *
+ * @author Jozef Hartinger
+ *
+ */
+public class SeleniumTestListener extends SeleniumSeamGenTest implements ITestListener
+{
+
+ public void onFinish(ITestContext arg0)
+ {
+ }
+
+ public void onStart(ITestContext arg0)
+ {
+ }
+
+ public void onTestFailedButWithinSuccessPercentage(ITestResult arg0)
+ {
+ }
+
+ public void onTestFailure(ITestResult arg0)
+ {
+ String logPath = OUTPUT_DIR + APP_NAME + "/" + arg0.getName();
+ browser.captureScreenshot(logPath + ".png");
+ browser.logHTMLContext(logPath + ".html");
+ stopBrowser();
+ }
+
+ public void onTestSkipped(ITestResult arg0)
+ {
+ stopBrowser();
+ }
+
+ public void onTestStart(ITestResult arg0)
+ {
+ }
+
+ public void onTestSuccess(ITestResult arg0)
+ {
+ stopBrowser();
+ }
+}
Property changes on:
trunk/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/utils/SeleniumTestListener.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
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 2009-04-08
08:06:08 UTC (rev 10348)
+++
trunk/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeamSelenium.java 2009-04-08
13:38:06 UTC (rev 10349)
@@ -18,55 +18,205 @@
* 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 java.io.BufferedWriter;
+import java.io.FileOutputStream;
+import java.io.OutputStreamWriter;
+
import com.thoughtworks.selenium.DefaultSelenium;
+import com.thoughtworks.selenium.Wait;
/**
* This class slightly enhaces a Selenium API for controlling a browser.
+ *
* @author Jozef Hartinger
- *
+ *
*/
public class SeamSelenium extends DefaultSelenium
{
-
- protected String timeout = "30000";
+ private String timeout = "30000";
+ private boolean icefacesDetection = false;
+ private long icefacesWaitTime = 1000;
+
+ private final String ICEFACES_CONNECTION_STATUS =
"xpath=//div[@class='iceOutConStat connectionStatus']";
+ private final String ICEFACES_IDLE_VISIBLE =
"xpath=//div[@class='iceOutConStatInactv
connectionStatusInactv'][@style='visibility: visible;']";
+
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.
+ * 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);
+ public void clickAndWait(String locator)
+ {
+ click(locator);
+ waitForPageToLoad();
}
-
+
/**
- * Simulates a user pressing "back" button and waits for page to load.
Default timeout can be changed by setTimeout() method.
+ * Simulates a user pressing "back" button and waits for page to load.
+ * Default timeout can be changed by setTimeout() method.
*/
- public void goBackAndWait() {
+ public void goBackAndWait()
+ {
super.goBack();
super.waitForPageToLoad(timeout);
}
-
+
/**
- * Simulates a user pressing "refresh" button and waits for page to load.
Default timeout can be changed by setTimeout() method.
+ * Simulates a user pressing "refresh" button and waits for page to load.
+ * Default timeout can be changed by setTimeout() method.
*/
- public void refreshAndWait() {
+ public void refreshAndWait()
+ {
super.refresh();
super.waitForPageToLoad(timeout);
}
-
+
+ @Override
+ public void setTimeout(String timeout)
+ {
+ super.setTimeout(timeout);
+ this.timeout = timeout;
+ }
+
+ public String getTimeout()
+ {
+ return timeout;
+ }
+
+ public void waitForPageToLoad()
+ {
+
+ waitForPageToLoad(timeout);
+ }
+
+ @Override
+ public void waitForPageToLoad(String timeout)
+ {
+ if (icefacesDetection && isElementPresent(ICEFACES_CONNECTION_STATUS))
+ {
+ waitForIcefaces(icefacesWaitTime, Long.valueOf(timeout));
+ }
+ else
+ {
+ super.waitForPageToLoad(timeout);
+ }
+ }
+
+ /**
+ * Returns true if icefaces detection is turned on
+ */
+ public boolean isIcefacesDetection()
+ {
+ return icefacesDetection;
+ }
+
+ /**
+ * Switch icefaces detection on/off
+ *
+ * @param icefacesDetection
+ */
+ public void setIcefacesDetection(boolean icefacesDetection)
+ {
+ this.icefacesDetection = icefacesDetection;
+ }
+
+ /**
+ * This wait time will be used when waiting for response after invoking
+ * icefaces action
+ */
+ public long getIcefacesWaitTime()
+ {
+ return icefacesWaitTime;
+ }
+
+ /**
+ * This wait time will be used when waiting for response after invoking
+ * icefaces action
+ *
+ * @param icefacesWaitTime
+ */
+ public void setIcefacesWaitTime(long icefacesWaitTime)
+ {
+ this.icefacesWaitTime = icefacesWaitTime;
+ }
+
+ /**
+ * Captures a screenshot and stores it into a file. Active windows is
+ * maximized before capturing a screenshot.
+ */
+ @Override
+ public void captureScreenshot(String path)
+ {
+ windowMaximize();
+ super.captureScreenshot(path);
+ }
+
+ /**
+ * Logs HTML body into a file.
+ *
+ * @param path
+ */
+ public void logHTMLContext(String path)
+ {
+ String source = getHtmlSource();
+ BufferedWriter writer = null;
+ try
+ {
+ writer = new BufferedWriter(new OutputStreamWriter(new
FileOutputStream(path)));
+ writer.write(source);
+ writer.flush();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Unable to save HTML body", e);
+ }
+ finally
+ {
+ try
+ {
+ writer.close();
+ }
+ catch (Exception e)
+ {
+ }
+ }
+ }
+
+ private void waitForIcefaces(Long waitTime, Long timeout)
+ {
+ new Wait()
+ {
+ @Override
+ public boolean until()
+ {
+ return isElementPresent(ICEFACES_IDLE_VISIBLE);
+ }
+ }.wait("Timeout while waiting for icefaces idle state.", timeout);
+ try
+ {
+ Thread.sleep(icefacesWaitTime);
+ }
+ catch (InterruptedException e)
+ {
+ e.printStackTrace();
+ }
+ new Wait()
+ {
+ @Override
+ public boolean until()
+ {
+ return isElementPresent("xpath=//body");
+ }
+ }.wait("Timeout while waiting for document body after icefaces click.",
timeout);
+ }
}