Revision: 1317
http://stripes.svn.sourceforge.net/stripes/?rev=1317&view=rev
Author: bengunter
Date: 2010-11-10 18:06:51 +0000 (Wed, 10 Nov 2010)
Log Message:
-----------
Rolled up Remi's webtests patches from 1.5.x branch and applied to trunk.
Modified Paths:
--------------
trunk/examples/pom.xml
trunk/pom.xml
Added Paths:
-----------
trunk/webtests/
trunk/webtests/pom.xml
trunk/webtests/src/
trunk/webtests/src/test/
trunk/webtests/src/test/groovy/
trunk/webtests/src/test/groovy/net/
trunk/webtests/src/test/groovy/net/sourceforge/
trunk/webtests/src/test/groovy/net/sourceforge/stripes/
trunk/webtests/src/test/groovy/net/sourceforge/stripes/webtests/
trunk/webtests/src/test/groovy/net/sourceforge/stripes/webtests/bugzooky/
trunk/webtests/src/test/groovy/net/sourceforge/stripes/webtests/bugzooky/BugzookyTest.groovy
trunk/webtests/src/test/groovy/net/sourceforge/stripes/webtests/calc/
trunk/webtests/src/test/groovy/net/sourceforge/stripes/webtests/calc/CalcTest.groovy
Property Changed:
----------------
trunk/examples/
Property changes on: trunk/examples
___________________________________________________________________
Modified: svn:ignore
- dist
docs
+ dist
docs
target
Modified: trunk/examples/pom.xml
===================================================================
--- trunk/examples/pom.xml 2010-11-10 16:55:54 UTC (rev 1316)
+++ trunk/examples/pom.xml 2010-11-10 18:06:51 UTC (rev 1317)
@@ -48,10 +48,33 @@
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
+ <dependency>
+ <groupId>commons-fileupload</groupId>
+ <artifactId>commons-fileupload</artifactId>
+ <version>1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.mail</groupId>
+ <artifactId>mail</artifactId>
+ <version>1.4</version>
+ </dependency>
</dependencies>
<build>
<finalName>stripes-examples</finalName>
<sourceDirectory>src</sourceDirectory>
+ <resources>
+ <resource>
+ <directory>src</directory>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </resource>
+ </resources>
<plugins>
<!-- use antrun to copy the sources into the webapp -->
<plugin>
@@ -90,22 +113,6 @@
</configuration>
</plugin>
<plugin>
- <groupId>org.codehaus.cargo</groupId>
- <artifactId>cargo-maven2-plugin</artifactId>
- <configuration>
- <wait>true</wait>
- <!-- Container configuration -->
- <container>
- <containerId>tomcat6x</containerId>
- <home>${tomcat6.home}</home>
- </container>
- <!-- Configuration to use with the container -->
- <configuration>
- <home>${project.build.directory}/tomcat6x</home>
- </configuration>
- </configuration>
- </plugin>
- <plugin>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-11-10 16:55:54 UTC (rev 1316)
+++ trunk/pom.xml 2010-11-10 18:06:51 UTC (rev 1317)
@@ -35,6 +35,7 @@
<modules>
<module>stripes</module>
<module>tests</module>
+ <module>examples</module>
</modules>
<dependencies>
<!--
@@ -163,9 +164,10 @@
</build>
<profiles>
<profile>
- <id>examples</id>
+ <id>webtests</id>
<modules>
<module>examples</module>
+ <module>webtests</module>
</modules>
</profile>
<profile>
Property changes on: trunk/webtests
___________________________________________________________________
Added: svn:ignore
+ target
Added: trunk/webtests/pom.xml
===================================================================
--- trunk/webtests/pom.xml (rev 0)
+++ trunk/webtests/pom.xml 2010-11-10 18:06:51 UTC (rev 1317)
@@ -0,0 +1,122 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>net.sourceforge.stripes</groupId>
+ <version>1.5.4-SNAPSHOT</version>
+ <artifactId>webtests</artifactId>
+ <packaging>war</packaging>
+ <name>webtests</name>
+ <dependencies>
+ <dependency>
+ <groupId>net.sourceforge.stripes</groupId>
+ <artifactId>examples</artifactId>
+ <version>${project.version}</version>
+ <type>war</type>
+ </dependency>
+ <dependency>
+ <groupId>com.canoo.webtest</groupId>
+ <artifactId>webtest</artifactId>
+ <version>3.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-all</artifactId>
+ <version>1.6-RC-3</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <finalName>webtests</finalName>
+ <plugins>
+ <!-- don't deploy test artifacts in the mvn repo -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ <!-- Use Groovy plugin for compilation of .groovy files -->
+ <plugin>
+ <groupId>org.codehaus.groovy.maven</groupId>
+ <artifactId>gmaven-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>generateStubs</goal>
+ <goal>compile</goal>
+ <goal>generateTestStubs</goal>
+ <goal>testCompile</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <!-- skip unit test run, tests to be executed during
integration-test -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ <executions>
+ <execution>
+ <id>surefire-it</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <skip>false</skip>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <!--
+ Use Cargo plugin to start/stop tomcat and deploy examples
+ for integration tests
+ -->
+ <plugin>
+ <groupId>org.codehaus.cargo</groupId>
+ <artifactId>cargo-maven2-plugin</artifactId>
+ <configuration>
+ <wait>false</wait>
+ <container>
+ <containerId>tomcat6x</containerId>
+ <zipUrlInstaller>
+
<url>http://mirror.ibcp.fr/pub/apache//tomcat/tomcat-6/v6.0.29/bin/apache-tomcat-6.0.29.zip</url>
+
<installDir>${basedir}/target/tomcat6-install</installDir>
+ </zipUrlInstaller>
+ </container>
+ <configuration>
+ <home>${project.build.directory}/tomcat6x/container</home>
+ <properties>
+ <cargo.servlet.port>9999</cargo.servlet.port>
+ </properties>
+ </configuration>
+ </configuration>
+ <executions>
+ <execution>
+ <id>start-container</id>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>start</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>stop-container</id>
+ <phase>post-integration-test</phase>
+ <goals>
+ <goal>stop</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added:
trunk/webtests/src/test/groovy/net/sourceforge/stripes/webtests/bugzooky/BugzookyTest.groovy
===================================================================
---
trunk/webtests/src/test/groovy/net/sourceforge/stripes/webtests/bugzooky/BugzookyTest.groovy
(rev 0)
+++
trunk/webtests/src/test/groovy/net/sourceforge/stripes/webtests/bugzooky/BugzookyTest.groovy
2010-11-10 18:06:51 UTC (rev 1317)
@@ -0,0 +1,213 @@
+package net.sourceforge.stripes.webtests.bugzooky
+
+import com.canoo.webtest.WebtestCase
+
+class BugzookyTest extends WebtestCase {
+
+ def homeUrl = 'http://localhost:9999/webtests/bugzooky'
+
+ static int count = 10 //System.currentTimeMillis()
+
+ void testAuthenticationIsRequired() {
+ webtest('testAuthenticationIsRequired') {
+ [
+ 'BugList.jsp',
+ 'AddEditBug.jsp',
+ 'BulkAddEditBugs.jsp',
+ 'AdministerBugzooky.jsp'
+ ].each { p ->
+ invoke "$homeUrl/$p"
+ verifyTitle 'Bugzooky - Login'
+ verifyText 'Login'
+ }
+ }
+ }
+
+ private String register() {
+ count++
+ def username = "foobar$count"
+ ant.invoke "$homeUrl/Register.jsp"
+
+ ant.setInputField name:'user.firstName', value:username
+ ant.clickButton name:'gotoStep2'
+
+ ant.verifyText 'Last Name is a required field'
+ ant.verifyText 'Username is a required field'
+ ant.setInputField name:'user.lastName', value:username
+ ant.setInputField name:'user.username', value:'a'
+ ant.clickButton name:'gotoStep2'
+
+ ant.verifyText 'Username must be at least 5 characters long'
+ ant.setInputField name:'user.username', value:username
+ ant.clickButton name:'gotoStep2'
+
+ ant.verifyText "Welcome $username, please pick a password"
+ ant.setInputField name:'user.password', value:username
+ ant.setInputField name:'confirmPassword', value:'bazbazbaz'
+ ant.clickButton name:'register'
+
+ ant.verifyText 'The Passwords entered did not match'
+ ant.setInputField name:'user.password', value:username
+ ant.setInputField name:'confirmPassword', value:username
+ ant.clickButton name:'register'
+
+ ant.verifyText "Thank you for registering ${username}, your account has
been created with username '${username}'"
+ return username
+ }
+
+ void testBugListSingleEdit() {
+ webtest('testBugListSingleEdit') {
+ register()
+
+ // list bugs
+ invoke "$homeUrl/BugList.jsp"
+
+ verifyTitle 'Bugzooky - Bug List'
+ verifyXPath xpath:'/html/body/div/div[2]/form/table/tbody/tr[2]/td[4]',
+ text:'First ever bug in the system.'
+ clickLink xpath:'/html/body/div/div[2]/form/table/tbody/tr[2]/td[9]/a'
+
+ // bug edition
+ setSelectField name:'bug.component.id', value:'2'
+ clickButton name:'saveAndAgain'
+
+ // fill in new bug
+ setSelectField name:'bug.component.id', value:'3'
+ setSelectField name:'bug.owner.id', value:'4'
+ setSelectField name:'bug.priority', value:'Blocker'
+ setInputField name:'bug.longDescription',
+ value:'This is a long decription for this new bug blah blah
blah...'
+ clickButton name:'save'
+
+ verifyXPath xpath:'/html/body/div/div[2]/ol/li',
+ text:'Short Description is a required field'
+ setInputField name:'bug.shortDescription', value:'brand new bug'
+ clickButton name:'save'
+
+ verifyXPath xpath:'/html/body/div/div[2]/form/table/tbody/tr[7]/td[4]',
+ text:'brand new bug'
+ verifyXPath xpath:'/html/body/div/div[2]/form/table/tbody/tr[7]/td[5]',
+ text:'Component 3'
+ verifyXPath xpath:'/html/body/div/div[2]/form/table/tbody/tr[7]/td[6]',
+ text:'Blocker'
+ verifyXPath xpath:'/html/body/div/div[2]/form/table/tbody/tr[7]/td[8]',
+ text:'velma'
+ }
+ }
+
+ void testBulkAdd() {
+ webtest('testBulkAdd') {
+ register()
+
+ clickLink xpath:'/html/body/div/div/div/a[3]'
+
+ verifyXPath xpath:'/html/body/div/div[2]/div',
+ text:'Bulk Add/Edit Bugs'
+ setSelectField name:'bugs[0].component.id', value:'1'
+ setSelectField name:'bugs[1].component.id', value:'2'
+ setSelectField name:'bugs[0].owner.id', value:'1'
+ setSelectField name:'bugs[1].owner.id', value:'2'
+ setSelectField name:'bugs[0].priority', value:'Critical'
+ setSelectField name:'bugs[1].priority', value:'Blocker'
+ setInputField name:'bugs[0].shortDescription', value:'Short desc 1'
+ setInputField name:'bugs[0].longDescription',
+ value:'This is looooooooooooooooooooooooooooooooooooooooong !'
+ setInputField name:'bugs[1].longDescription',
+ value:'This is looooooooooooooooooooooooooooooooooooooooong too
!'
+ clickButton name:'save'
+
+ verifyText 'Short Description is a required field'
+ setInputField name:'bugs[1].shortDescription',
+ value:'Short desc 2'
+ clickButton name:'save'
+
+ verifyXPath xpath:'/html/body/div/div[2]/form/table/tbody/tr[8]/td[4]',
+ text:'Short desc 1'
+ verifyXPath xpath:'/html/body/div/div[2]/form/table/tbody/tr[8]/td[5]',
+ text:'Component 1'
+ verifyXPath xpath:'/html/body/div/div[2]/form/table/tbody/tr[8]/td[6]',
+ text:'Critical'
+ verifyXPath xpath:'/html/body/div/div[2]/form/table/tbody/tr[8]/td[8]',
+ text:'shaggy'
+ verifyXPath xpath:'/html/body/div/div[2]/form/table/tbody/tr[9]/td[4]',
+ text:'Short desc 2'
+ verifyXPath xpath:'/html/body/div/div[2]/form/table/tbody/tr[9]/td[5]',
+ text:'Component 2'
+ verifyXPath xpath:'/html/body/div/div[2]/form/table/tbody/tr[9]/td[6]',
+ text:'Blocker'
+ verifyXPath xpath:'/html/body/div/div[2]/form/table/tbody/tr[9]/td[8]',
+ text:'scrappy'
+ }
+ }
+
+ void testBugListBulkEdit() {
+ webtest('testBugListBulkEdit') {
+ register()
+
+ // list bugs
+ invoke "$homeUrl/BugList.jsp"
+
+ // check the two first bugs and bulk edit
+ setCheckbox xpath:'/html/body/div/div[2]/form/table/tbody/tr[2]/td/input'
+ setCheckbox xpath:'/html/body/div/div[2]/form/table/tbody/tr[3]/td/input'
+ clickButton xpath:'/html/body/div/div[2]/form/div/input'
+
+ verifyXPath
xpath:'/html/body/div/div[2]/form/table/tbody/tr[2]/td[5]/textarea',
+ text:'First ever bug in the system.',
+ regex:true
+ verifyXPath xpath:
'/html/body/div/div[2]/form/table/tbody/tr[3]/td[5]/textarea',
+ text:'Another bug! Oh no!.',
+ regex:true
+ // don't test more : it's already done in testBulkAdd
+ }
+ }
+
+ void testAdminister() {
+ webtest('testAdminister') {
+ register()
+
+ invoke "$homeUrl/AdministerBugzooky.jsp"
+
+ // change email for first user
+ setInputField
xpath:'/html/body/div/div[2]/form/table/tbody/tr[2]/td[6]/input',
+ value:'[email protected]'
+ clickButton xpath:'/html/body/div/div[2]/form/div/input'
+
+ // check email change, remove first user
+ verifyXPath
xpath:"/html/body/div/div[2]/form/table/tbody/tr[2]/td[6]/inp...@value='[email protected]']"
+ setCheckbox xpath:'/html/body/div/div[2]/form/table/tbody/tr[2]/td/input'
+ clickButton xpath:'/html/body/div/div[2]/form/div/input'
+
+ // check email is not [email protected] for the first user
+ not {
+ verifyXPath
xpath:"/html/body/div/div[2]/form/table/tbody/tr[2]/td[6]/inp...@value='[email protected]']"
+ }
+
+ // change the value of component 3
+ setInputField
xpath:'/html/body/div/div[2]/form[2]/table/tbody/tr[5]/td[3]/input',
+ value:'Component X'
+ clickButton xpath:'/html/body/div/div[2]/form[2]/div/input'
+
+ // verify component name change, and create new component
+ verifyXPath
xpath:"/html/body/div/div[2]/form[2]/table/tbody/tr[5]/td[3]/inp...@value='Component
X']"
+ setInputField
xpath:'/html/body/div/div[2]/form[2]/table/tbody/tr[7]/td[3]/input',
+ value:'My Component'
+ clickButton xpath:'/html/body/div/div[2]/form[2]/div/input'
+
+ // assert component creation, and remove component
+ verifyXPath
xpath:"/html/body/div/div[2]/form[2]/table/tbody/tr[7]/td[3]/inp...@value='My
Component']"
+ setCheckbox
xpath:'/html/body/div/div[2]/form[2]/table/tbody/tr[7]/td/input'
+ clickButton xpath:'/html/body/div/div[2]/form[2]/div/input'
+
+ // assert component removal
+ not {
+ verifyXPath
xpath:"/html/body/div/div[2]/form[2]/table/tbody/tr[7]/td[3]/inp...@value='My
Component']"
+ }
+ }
+ }
+
+
+
+
+
+}
Added:
trunk/webtests/src/test/groovy/net/sourceforge/stripes/webtests/calc/CalcTest.groovy
===================================================================
---
trunk/webtests/src/test/groovy/net/sourceforge/stripes/webtests/calc/CalcTest.groovy
(rev 0)
+++
trunk/webtests/src/test/groovy/net/sourceforge/stripes/webtests/calc/CalcTest.groovy
2010-11-10 18:06:51 UTC (rev 1317)
@@ -0,0 +1,66 @@
+package net.sourceforge.stripes.webtests.calc
+
+import com.canoo.webtest.WebtestCase
+
+class CalcTest extends WebtestCase {
+
+ def homeUrl = 'http://localhost:9999/webtests/quickstart/index.jsp'
+
+ void testCalcHome() {
+ webtest('testCalcHome') {
+ invoke homeUrl
+ verifyTitle 'My First Stripe'
+ verifyText 'Stripes Calculator'
+ }
+ }
+
+ void testAdd() {
+ webtest('testAdd') {
+ invoke homeUrl
+ setInputField(name:'numberOne', value: '2')
+ setInputField(name:'numberTwo', value: '2')
+ clickButton(name:'addition')
+ verifyText 'Result:'
+ verifyText '4.0'
+ }
+ }
+
+ void testDivide() {
+ webtest('testDivide') {
+ invoke homeUrl
+ setInputField(name:'numberOne', value: '2')
+ setInputField(name:'numberTwo', value: '2')
+ clickButton(name:'division')
+ verifyText 'Result:'
+ verifyText '1.0'
+ }
+ }
+
+ void testValidationErrors() {
+ webtest('testValidationErrors') {
+ invoke homeUrl
+ clickButton(name:'division')
+ verifyText 'Number One is a required field'
+ verifyText 'Number Two is a required field'
+
+ invoke homeUrl
+ setInputField(name:'numberOne', value: 'abc')
+ clickButton(name:'division')
+ verifyText 'The value (abc) entered in field Number One must be a valid
number'
+ verifyText 'Number Two is a required field'
+
+ invoke homeUrl
+ setInputField(name:'numberOne', value: '2')
+ clickButton(name:'division')
+ verifyText 'Number Two is a required field'
+
+ invoke homeUrl
+ setInputField(name:'numberOne', value: '2')
+ setInputField(name:'numberTwo', value: '0')
+ clickButton(name:'division')
+ verifyText 'Dividing by zero is not allowed.'
+ }
+ }
+
+
+}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a
Billion" shares his insights and actions to help propel your
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development