You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by ni...@apache.org on 2007/11/16 07:43:35 UTC
svn commit: r595575 - in /struts/struts2/trunk/apps/portlet: ./
src/test/java/org/ src/test/java/org/apache/
src/test/java/org/apache/struts2/ src/test/java/org/apache/struts2/portlet/
src/test/java/org/apache/struts2/portlet/test/
Author: nilsga
Date: Thu Nov 15 22:43:29 2007
New Revision: 595575
URL: http://svn.apache.org/viewvc?rev=595575&view=rev
Log:
Added the tests again, but excluding them from beeing run with excludes in pom.xml
Added:
struts/struts2/trunk/apps/portlet/src/test/java/org/
struts/struts2/trunk/apps/portlet/src/test/java/org/apache/
struts/struts2/trunk/apps/portlet/src/test/java/org/apache/struts2/
struts/struts2/trunk/apps/portlet/src/test/java/org/apache/struts2/portlet/
struts/struts2/trunk/apps/portlet/src/test/java/org/apache/struts2/portlet/test/
struts/struts2/trunk/apps/portlet/src/test/java/org/apache/struts2/portlet/test/BasePortletTest.java
struts/struts2/trunk/apps/portlet/src/test/java/org/apache/struts2/portlet/test/Struts2PortletTest.java
Modified:
struts/struts2/trunk/apps/portlet/pom.xml
Modified: struts/struts2/trunk/apps/portlet/pom.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/portlet/pom.xml?rev=595575&r1=595574&r2=595575&view=diff
==============================================================================
--- struts/struts2/trunk/apps/portlet/pom.xml (original)
+++ struts/struts2/trunk/apps/portlet/pom.xml Thu Nov 15 22:43:29 2007
@@ -40,6 +40,21 @@
<url>http://svn.apache.org/viewcvs.cgi/struts/struts2/trunk/apps/portlet/</url>
</scm>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <!-- Excluded so the integration tests don't run in the main Bamboo build -->
+ <excludes>
+ <exclude>org/apache/struts2/portlet/test/*</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
<profiles>
<profile>
<id>pluto</id>
Added: struts/struts2/trunk/apps/portlet/src/test/java/org/apache/struts2/portlet/test/BasePortletTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/portlet/src/test/java/org/apache/struts2/portlet/test/BasePortletTest.java?rev=595575&view=auto
==============================================================================
--- struts/struts2/trunk/apps/portlet/src/test/java/org/apache/struts2/portlet/test/BasePortletTest.java (added)
+++ struts/struts2/trunk/apps/portlet/src/test/java/org/apache/struts2/portlet/test/BasePortletTest.java Thu Nov 15 22:43:29 2007
@@ -0,0 +1,75 @@
+package org.apache.struts2.portlet.test;
+
+import net.sourceforge.jwebunit.junit.WebTestCase;
+
+import org.apache.pluto.core.PortletServlet;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.servlet.ServletHolder;
+import org.mortbay.jetty.webapp.WebAppContext;
+
+public abstract class BasePortletTest extends WebTestCase {
+
+ protected Server server;
+
+ private int port = 9876;
+
+ private String contextPath = "/test";
+
+ public void setUp() throws Exception {
+ System.setProperty("org.apache.pluto.embedded.portletId", getPortletName());
+ server = new Server(port);
+ WebAppContext webapp = new WebAppContext("src/main/webapp", contextPath);
+ webapp.setDefaultsDescriptor("/WEB-INF/jetty-pluto-web-default.xml");
+ ServletHolder portletServlet = new ServletHolder(new PortletServlet());
+ portletServlet.setInitParameter("portlet-name", getPortletName());
+ portletServlet.setInitOrder(1);
+ webapp.addServlet(portletServlet, "/PlutoInvoker/" + getPortletName());
+ server.addHandler(webapp);
+ server.start();
+ getTestContext().setBaseUrl("http://localhost:" + port + contextPath);
+ }
+
+
+ public void tearDown() throws Exception {
+ server.stop();
+ }
+
+ public void minimizeWindow() {
+ clickElementByXPath("//span[@class='minimized']/..");
+ }
+
+ public void maximizeWindow() {
+ clickElementByXPath("//span[@class='minimized']/..");
+ }
+
+ public void restoreWindow() {
+ clickElementByXPath("//span[@class='normal']/..");
+ }
+
+ public void switchEdit() {
+ clickElementByXPath("//span[@class='edit']/..");
+ }
+
+ public void switchView() {
+ clickElementByXPath("//span[@class='view']/..");
+ }
+
+ public void switchHelp() {
+ clickElementByXPath("//span[@class='help']/..");
+ }
+
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ public void setContextPath(String contextPath) {
+ if(!contextPath.startsWith("/")) {
+ this.contextPath = "/" + contextPath;
+ }
+ else {
+ this.contextPath = contextPath;
+ }
+ }
+
+ public abstract String getPortletName();
+}
Added: struts/struts2/trunk/apps/portlet/src/test/java/org/apache/struts2/portlet/test/Struts2PortletTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/portlet/src/test/java/org/apache/struts2/portlet/test/Struts2PortletTest.java?rev=595575&view=auto
==============================================================================
--- struts/struts2/trunk/apps/portlet/src/test/java/org/apache/struts2/portlet/test/Struts2PortletTest.java (added)
+++ struts/struts2/trunk/apps/portlet/src/test/java/org/apache/struts2/portlet/test/Struts2PortletTest.java Thu Nov 15 22:43:29 2007
@@ -0,0 +1,83 @@
+package org.apache.struts2.portlet.test;
+
+public class Struts2PortletTest extends BasePortletTest {
+
+ private final static String PORTLET_NAME = "StrutsPortlet";
+
+ public void testIndexPage() throws Exception {
+ beginAt("pluto/index.jsp");
+ assertTextPresent("Welcome to the Struts example portlet");
+ assertLinkPresentWithExactText("A simple form");
+ assertLinkPresentWithExactText("Validation");
+ }
+
+ public void testFormExample() throws Exception {
+ beginAt("pluto/index.jsp");
+ clickLinkWithExactText("A simple form");
+ assertFormPresent("processFormExample");
+ assertTextPresent("Input your name");
+ setWorkingForm("processFormExample");
+ setTextField("firstName", "Nils-Helge");
+ setTextField("lastName", "Garli");
+ submit();
+ assertTextPresent("Hello Nils-Helge Garli");
+ }
+
+ public void testValidationExample() throws Exception {
+ beginAt("pluto/index.jsp");
+ clickLinkWithExactText("Validation");
+ assertFormPresent("processValidationExample");
+ assertTextPresent("Input your name");
+ setWorkingForm("processValidationExample");
+ setTextField("firstName", "Nils-Helge");
+ submit();
+ assertTextFieldEquals("firstName", "Nils-Helge");
+ assertTextPresent("You must enter a last name");
+ setTextField("lastName", "Garli");
+ submit();
+ assertTextPresent("Hello Nils-Helge Garli");
+ }
+
+ public void testValidationErrorMessagesStickBetweenWindowStateChanges() throws Exception {
+ beginAt("pluto/index.jsp");
+ clickLinkWithExactText("Validation");
+ assertFormPresent("processValidationExample");
+ assertTextPresent("Input your name");
+ setWorkingForm("processValidationExample");
+ setTextField("firstName", "Nils-Helge");
+ submit();
+ assertTextFieldEquals("firstName", "Nils-Helge");
+ assertTextPresent("You must enter a last name");
+ minimizeWindow();
+ assertTextNotPresent("Input your name");
+ restoreWindow();
+ assertTextPresent("Input your name");
+ assertTextPresent("You must enter a last name");
+ }
+
+ public void testTokenExample() throws Exception {
+ beginAt("pluto/index.jsp");
+ clickLinkWithText("Token");
+ setWorkingForm(0);
+ setTextField("theValue", "something");
+ submit();
+ assertTextPresent("ERROR");
+ setWorkingForm(1);
+ setTextField("theValue", "somethingElse");
+ submit();
+ assertTextPresent("The form was successfully submitted with a valid token");
+ }
+
+ public void testSwitchFromViewToEditShouldGoToDefaultEditPage() throws Exception {
+ beginAt("pluto/index.jsp");
+ assertTextPresent("Welcome to the Struts example portlet");
+ switchEdit();
+ assertTextPresent("Back to view mode");
+ }
+
+ @Override
+ public String getPortletName() {
+ return PORTLET_NAME;
+ }
+
+}