Add some integration tests

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@681928 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Musachy Barroso
2008-08-02 02:34:11 +00:00
parent 18724a34cb
commit 68d84d684d
11 changed files with 297 additions and 40 deletions
+71 -12
View File
@@ -181,6 +181,32 @@
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>net.sourceforge.jwebunit</groupId>
<artifactId>jwebunit-core</artifactId>
<version>1.4.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.sourceforge.jwebunit</groupId>
<artifactId>jwebunit-htmlunit-plugin</artifactId>
<version>1.4.1</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>xom</groupId>
<artifactId>xom</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
@@ -211,19 +237,52 @@
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.twdata.maven</groupId>
<artifactId>maven-itblast-plugin</artifactId>
<version>0.3</version>
<executions>
<execution>
<phase>integration-test</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<containers>tomcat5x,jetty6x,jboss42x,resin3x</containers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
<exclude>it/**</exclude>
<exclude>**/*$*</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
<resources>
<!-- Include resources under src/main/java in WEB-INF/classes -->
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.java</include>
</includes>
</resource>
</resources>
<resources>
<!-- Include resources under src/main/java in WEB-INF/classes -->
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.java</include>
</includes>
</resource>
</resources>
</build>
<pluginRepositories>
<pluginRepository>
<id>twdata-m2-repository</id>
<name>twdata.org Maven Repository</name>
<url>http://twdata-m2-repository.googlecode.com/svn/</url>
</pluginRepository>
</pluginRepositories>
</project>
@@ -3,7 +3,7 @@
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="ui-tags" extends="struts-default" namespace="/tags/ui">
<action name="example" class="org.apache.struts2.showcase.UITagExample">
@@ -40,26 +40,30 @@
</action>
<!-- START SNIPPET: treeExampleDynamicXWorkXml -->
<action name="showDynamicTreeAction" class="org.apache.struts2.showcase.ShowDynamicTreeAction">
<result>/tags/ui/treeExampleDynamic.jsp</result>
</action>
<!-- END SNIPPET: treeExampleDynamicXWorkXml -->
<action name="showDynamicAjaxTreeAction">
<result>/tags/ui/treeExampleAjaxDynamic.jsp</result>
</action>
<action name="showComponentTagExampleCode">
<result type="plainText">/tags/ui/componentTagExample.jsp</result>
</action>
<action name="actionTagExample">
<result>/tags/ui/actionTagExampleCalled.jsp</result>
<result name="input">/tags/ui/actionTagExampleCalling.jsp</result>
</action>
</package>
<!-- START SNIPPET: treeExampleXWorkXml -->
<package name="ui-tags-ajax" namespace="/tags/ui/ajax" extends="struts-default">
<package name="ui-tags-ajax" namespace="/tags/ui/ajax" extends="struts-default">
<!-- Actions dealing with Tree Example -->
<action name="staticTreeSelectAction">
<result>/tags/ui/staticTreeSelect.jsp</result>
@@ -68,6 +72,6 @@
<result>/tags/ui/dynamicTreeSelect.jsp</result>
</action>
</package>
<!-- END SNIPPET: treeExampleXWorkXml -->
</struts>
@@ -0,0 +1,2 @@
<%@taglib prefix="s" uri="/struts-tags" %>
This text is from the called class
@@ -0,0 +1,14 @@
<%@taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>Showcase - Tags - UI Tags - Action Tag</title>
</head>
<body>
<b>Example 1:</b>
This example calls an action and includes the output on the page
<p id="example1" style="background-color:yellow;">
<s:action name="/tags/ui" name="actionTagExample" executeResult="true"/>
</p>
</body>
</html>
@@ -16,8 +16,8 @@
<s:form action="exampleSubmit" enctype="multipart/form-data" javascriptTooltip="true">
<s:textfield
label="Name"
<s:textfield
label="Name"
name="name"
tooltip="Enter your Name here"/>
@@ -25,13 +25,13 @@
tooltip="Select Your Birthday"
label="Birthday"
name="birthday" />
<sx:datetimepicker
tooltip="Enter the time you wake up"
label="Wake up time"
name="wakeup"
name="wakeup"
type="time"/>
<s:textarea
tooltip="Enter your Biography"
label="Biography"
@@ -76,7 +76,7 @@
name="region" list="{'North', 'South'}"
value="'South'"
doubleValue="'Florida'"
doubleList="top == 'North' ? {'Oregon', 'Washington'} : {'Texas', 'Florida'}"
doubleList="top == 'North' ? {'Oregon', 'Washington'} : {'Texas', 'Florida'}"
doubleName="state"
headerKey="-1"
headerValue="---------- Please Select ----------"
@@ -100,35 +100,35 @@
<s:file
tooltip="Upload Your Picture"
label="Picture"
label="Picture"
name="picture" />
<s:optiontransferselect
tooltip="Select Your Favourite Cartoon Characters"
label="Favourite Cartoons Characters"
name="leftSideCartoonCharacters"
name="leftSideCartoonCharacters"
leftTitle="Left Title"
rightTitle="Right Title"
list="{'Popeye', 'He-Man', 'Spiderman'}"
list="{'Popeye', 'He-Man', 'Spiderman'}"
multiple="true"
headerKey="headerKey"
headerValue="--- Please Select ---"
emptyOption="true"
doubleList="{'Superman', 'Mickey Mouse', 'Donald Duck'}"
doubleList="{'Superman', 'Mickey Mouse', 'Donald Duck'}"
doubleName="rightSideCartoonCharacters"
doubleHeaderKey="doubleHeaderKey"
doubleHeaderValue="--- Please Select ---"
doubleHeaderValue="--- Please Select ---"
doubleEmptyOption="true"
doubleMultiple="true" />
<s:textarea
label="Your Thougths"
name="thoughts"
name="thoughts"
tooltip="Enter your thoughts here" />
<s:submit onclick="alert('Custom onclick event triggered before submitting form... Press OK to continue!');" />
<s:submit />
<s:reset onclick="alert('Resetting form now... Press OK to continue!');" />
</s:form>
</body>
</html>
@@ -6,7 +6,7 @@
</head>
<body>
<h1>UI Tags</h1>
<ul>
<li><s:url var="url" namespace="/tags/ui" action="example" method="input" /><s:a href="%{url}">UI Example</s:a></li>
<li><s:url var="url" namespace="/tags/ui" action="exampleVelocity" method="input" /><s:a href="%{url}">UI Example (Velocity)</s:a></li>
@@ -16,6 +16,7 @@
<li><s:url var="url" namespace="/tags/ui" action="showDynamicTreeAction"/><s:a href="%{url}">Tree Example (dynamic)</s:a>
<li><s:url var="url" namespace="/tags/ui" action="showDynamicAjaxTreeAction"/><s:a href="%{url}">Tree Example (dynamic ajax loading)</s:a>
<li><s:url var="url" value="componentTagExample.jsp"/><s:a href="%{#url}">Component Tag Example</s:a>
<li><s:url var="url" namespace="/tags/ui" action="actionTagExample" method="input" /><s:a href="%{url}">Action Tag Example</s:a></li>
<li><a href="datepicker/index.jsp">DateTime picker tag - Pick a date</a></li>
<li><a href="timepicker/index.jsp">DateTime picker tag - Pick a time</a></li>
<%--li><s:url var="url" namespace="/tags/ui" action="populateUsingIterator" method="input" /><s:a href="%{url}">UI population using iterator tag</s:a></li--%>
@@ -0,0 +1,29 @@
/*
* $Id$
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package it.org.apache.struts2.showcase;
public class ActionTagExampleTest extends ITBaseTest {
public void test() {
beginAt("/tags/ui/actionTagExample!input.action");
assertTextPresent("This text is from the called class");
}
}
@@ -0,0 +1,31 @@
/*
* $Id$
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package it.org.apache.struts2.showcase;
public class ComponentTagExampleTest extends ITBaseTest {
public void test() {
beginAt("/tags/ui/componentTagExample.jsp");
assertTextPresent("Freemarker Custom Template - parameter 'paramName' - paramValue1");
assertTextPresent("Freemarker Custom Template - parameter 'paramName' - paramValue4");
assertTextPresent("JSP Custom Template - parameter 'paramName' - paramValue2");
assertTextPresent("JSP Custom Template - parameter 'paramName' - paramValue3");
}
}
@@ -0,0 +1,30 @@
/*
* $Id$
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package it.org.apache.struts2.showcase;
import net.sourceforge.jwebunit.junit.WebTestCase;
public abstract class ITBaseTest extends WebTestCase {
public void setUp() throws Exception {
getTestContext().setBaseUrl(ParameterUtils.getBaseUrl());
}
}
@@ -0,0 +1,32 @@
/*
* $Id$
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package it.org.apache.struts2.showcase;
public class ParameterUtils {
public static String getBaseUrl() {
String port = System.getProperty("http.port");
if (port == null) {
port = "8080";
}
return "http://localhost:"+port+"/struts2-showcase";
}
}
@@ -0,0 +1,55 @@
/*
* $Id$
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package it.org.apache.struts2.showcase;
public class UITagExampleTest extends ITBaseTest {
public void testInputForm() {
setScriptingEnabled(false);
beginAt("/tags/ui/example!input.action");
assertFormPresent("exampleSubmit");
// text box
assertFormElementPresent("name");
// textarea
assertFormElementPresent("bio");
// select
assertFormElementPresent("favouriteColor");
// checkbox list
assertFormElementPresent("friends");
// checkbox
assertFormElementPresent("legalAge");
// set fields
setTextField("name", "name");
setTextField("bio", "bio");
selectOption("favouriteColor", "Red");
checkCheckbox("friends", "Patrick");
checkCheckbox("friends", "Jason");
checkCheckbox("legalAge");
submit();
assertTextInElement("name", "name");
assertTextInElement("bio", "bio");
assertTextInElement("favouriteColor", "Red");
assertTextInElement("friends", "[Patrick, Jason]");
assertTextInElement("legalAge", "true");
}
}