Author: musachy Date: Fri Aug 1 19:34:11 2008 New Revision: 681928 URL: http://svn.apache.org/viewvc?rev=681928&view=rev Log: Add some integration tests
Added: struts/struts2/trunk/apps/showcase/src/main/webapp/tags/ui/actionTagExampleCalled.jsp struts/struts2/trunk/apps/showcase/src/main/webapp/tags/ui/actionTagExampleCalling.jsp struts/struts2/trunk/apps/showcase/src/test/java/it/ struts/struts2/trunk/apps/showcase/src/test/java/it/org/ struts/struts2/trunk/apps/showcase/src/test/java/it/org/apache/ struts/struts2/trunk/apps/showcase/src/test/java/it/org/apache/struts2/ struts/struts2/trunk/apps/showcase/src/test/java/it/org/apache/struts2/showcase/ struts/struts2/trunk/apps/showcase/src/test/java/it/org/apache/struts2/showcase/ActionTagExampleTest.java (with props) struts/struts2/trunk/apps/showcase/src/test/java/it/org/apache/struts2/showcase/ComponentTagExampleTest.java (with props) struts/struts2/trunk/apps/showcase/src/test/java/it/org/apache/struts2/showcase/ITBaseTest.java (with props) struts/struts2/trunk/apps/showcase/src/test/java/it/org/apache/struts2/showcase/ParameterUtils.java (with props) struts/struts2/trunk/apps/showcase/src/test/java/it/org/apache/struts2/showcase/UITagExampleTest.java (with props) Modified: struts/struts2/trunk/apps/showcase/pom.xml struts/struts2/trunk/apps/showcase/src/main/resources/struts-tags-ui.xml struts/struts2/trunk/apps/showcase/src/main/webapp/tags/ui/example.jsp struts/struts2/trunk/apps/showcase/src/main/webapp/tags/ui/index.jsp Modified: struts/struts2/trunk/apps/showcase/pom.xml URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/pom.xml?rev=681928&r1=681927&r2=681928&view=diff ============================================================================== --- struts/struts2/trunk/apps/showcase/pom.xml (original) +++ struts/struts2/trunk/apps/showcase/pom.xml Fri Aug 1 19:34:11 2008 @@ -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> Modified: struts/struts2/trunk/apps/showcase/src/main/resources/struts-tags-ui.xml URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/resources/struts-tags-ui.xml?rev=681928&r1=681927&r2=681928&view=diff ============================================================================== --- struts/struts2/trunk/apps/showcase/src/main/resources/struts-tags-ui.xml (original) +++ struts/struts2/trunk/apps/showcase/src/main/resources/struts-tags-ui.xml Fri Aug 1 19:34:11 2008 @@ -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> Added: struts/struts2/trunk/apps/showcase/src/main/webapp/tags/ui/actionTagExampleCalled.jsp URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/tags/ui/actionTagExampleCalled.jsp?rev=681928&view=auto ============================================================================== --- struts/struts2/trunk/apps/showcase/src/main/webapp/tags/ui/actionTagExampleCalled.jsp (added) +++ struts/struts2/trunk/apps/showcase/src/main/webapp/tags/ui/actionTagExampleCalled.jsp Fri Aug 1 19:34:11 2008 @@ -0,0 +1,2 @@ +<[EMAIL PROTECTED] prefix="s" uri="/struts-tags" %> +This text is from the called class \ No newline at end of file Added: struts/struts2/trunk/apps/showcase/src/main/webapp/tags/ui/actionTagExampleCalling.jsp URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/tags/ui/actionTagExampleCalling.jsp?rev=681928&view=auto ============================================================================== --- struts/struts2/trunk/apps/showcase/src/main/webapp/tags/ui/actionTagExampleCalling.jsp (added) +++ struts/struts2/trunk/apps/showcase/src/main/webapp/tags/ui/actionTagExampleCalling.jsp Fri Aug 1 19:34:11 2008 @@ -0,0 +1,14 @@ +<[EMAIL PROTECTED] 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> \ No newline at end of file Modified: struts/struts2/trunk/apps/showcase/src/main/webapp/tags/ui/example.jsp URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/tags/ui/example.jsp?rev=681928&r1=681927&r2=681928&view=diff ============================================================================== --- struts/struts2/trunk/apps/showcase/src/main/webapp/tags/ui/example.jsp (original) +++ struts/struts2/trunk/apps/showcase/src/main/webapp/tags/ui/example.jsp Fri Aug 1 19:34:11 2008 @@ -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> Modified: struts/struts2/trunk/apps/showcase/src/main/webapp/tags/ui/index.jsp URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/tags/ui/index.jsp?rev=681928&r1=681927&r2=681928&view=diff ============================================================================== --- struts/struts2/trunk/apps/showcase/src/main/webapp/tags/ui/index.jsp (original) +++ struts/struts2/trunk/apps/showcase/src/main/webapp/tags/ui/index.jsp Fri Aug 1 19:34:11 2008 @@ -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--%> Added: struts/struts2/trunk/apps/showcase/src/test/java/it/org/apache/struts2/showcase/ActionTagExampleTest.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/test/java/it/org/apache/struts2/showcase/ActionTagExampleTest.java?rev=681928&view=auto ============================================================================== --- struts/struts2/trunk/apps/showcase/src/test/java/it/org/apache/struts2/showcase/ActionTagExampleTest.java (added) +++ struts/struts2/trunk/apps/showcase/src/test/java/it/org/apache/struts2/showcase/ActionTagExampleTest.java Fri Aug 1 19:34:11 2008 @@ -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"); + } + +} Propchange: struts/struts2/trunk/apps/showcase/src/test/java/it/org/apache/struts2/showcase/ActionTagExampleTest.java ------------------------------------------------------------------------------ svn:keywords = Id Added: struts/struts2/trunk/apps/showcase/src/test/java/it/org/apache/struts2/showcase/ComponentTagExampleTest.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/test/java/it/org/apache/struts2/showcase/ComponentTagExampleTest.java?rev=681928&view=auto ============================================================================== --- struts/struts2/trunk/apps/showcase/src/test/java/it/org/apache/struts2/showcase/ComponentTagExampleTest.java (added) +++ struts/struts2/trunk/apps/showcase/src/test/java/it/org/apache/struts2/showcase/ComponentTagExampleTest.java Fri Aug 1 19:34:11 2008 @@ -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"); + } +} Propchange: struts/struts2/trunk/apps/showcase/src/test/java/it/org/apache/struts2/showcase/ComponentTagExampleTest.java ------------------------------------------------------------------------------ svn:keywords = Id Added: struts/struts2/trunk/apps/showcase/src/test/java/it/org/apache/struts2/showcase/ITBaseTest.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/test/java/it/org/apache/struts2/showcase/ITBaseTest.java?rev=681928&view=auto ============================================================================== --- struts/struts2/trunk/apps/showcase/src/test/java/it/org/apache/struts2/showcase/ITBaseTest.java (added) +++ struts/struts2/trunk/apps/showcase/src/test/java/it/org/apache/struts2/showcase/ITBaseTest.java Fri Aug 1 19:34:11 2008 @@ -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()); + } +} Propchange: struts/struts2/trunk/apps/showcase/src/test/java/it/org/apache/struts2/showcase/ITBaseTest.java ------------------------------------------------------------------------------ svn:keywords = Id Added: struts/struts2/trunk/apps/showcase/src/test/java/it/org/apache/struts2/showcase/ParameterUtils.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/test/java/it/org/apache/struts2/showcase/ParameterUtils.java?rev=681928&view=auto ============================================================================== --- struts/struts2/trunk/apps/showcase/src/test/java/it/org/apache/struts2/showcase/ParameterUtils.java (added) +++ struts/struts2/trunk/apps/showcase/src/test/java/it/org/apache/struts2/showcase/ParameterUtils.java Fri Aug 1 19:34:11 2008 @@ -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"; + } +} Propchange: struts/struts2/trunk/apps/showcase/src/test/java/it/org/apache/struts2/showcase/ParameterUtils.java ------------------------------------------------------------------------------ svn:keywords = Id Added: struts/struts2/trunk/apps/showcase/src/test/java/it/org/apache/struts2/showcase/UITagExampleTest.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/test/java/it/org/apache/struts2/showcase/UITagExampleTest.java?rev=681928&view=auto ============================================================================== --- struts/struts2/trunk/apps/showcase/src/test/java/it/org/apache/struts2/showcase/UITagExampleTest.java (added) +++ struts/struts2/trunk/apps/showcase/src/test/java/it/org/apache/struts2/showcase/UITagExampleTest.java Fri Aug 1 19:34:11 2008 @@ -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"); + } +} Propchange: struts/struts2/trunk/apps/showcase/src/test/java/it/org/apache/struts2/showcase/UITagExampleTest.java ------------------------------------------------------------------------------ svn:keywords = Id