You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by gp...@apache.org on 2010/12/26 03:31:23 UTC
svn commit: r1052824 - in /myfaces/extensions/cdi/trunk: ./
jse-modules/message-module/impl/
test-modules/base-cargo-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/cargo/
test-modules/cargo-test-module/ test-module...
Author: gpetracek
Date: Sun Dec 26 02:31:22 2010
New Revision: 1052824
URL: http://svn.apache.org/viewvc?rev=1052824&view=rev
Log:
EXTCDI-105 refactored cargo test
Added:
myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/view/
myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/view/Utils.java
- copied, changed from r1052124, myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/Utils.java
myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/view/config/
myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/view/config/Pages.java
myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/view/conversation/
myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/view/conversation/ConversationBean.java
- copied, changed from r1052124, myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/conversation/ConversationBean.java
myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/pages/
myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/pages/conversation/
- copied from r1052124, myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/conversation/
myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/cargo/conversation/BaseConversationTest.java
Removed:
myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/Utils.java
myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/conversation/
myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/conversation/
myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/cargo/AbstractCodiTest.java
Modified:
myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/pom.xml
myfaces/extensions/cdi/trunk/pom.xml
myfaces/extensions/cdi/trunk/test-modules/base-cargo-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/cargo/AbstractCargoTest.java
myfaces/extensions/cdi/trunk/test-modules/base-cargo-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/cargo/SimplePageInteraction.java
myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/pom.xml
myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/index.xhtml
myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/pages/conversation/conversation1.xhtml
myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/pages/conversation/conversation2.xhtml
myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/pages/conversation/conversation3.xhtml
myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/pages/conversation/result.xhtml
myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/cargo/conversation/ConversationTestCase.java
myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/pom.xml
Modified: myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/pom.xml?rev=1052824&r1=1052823&r2=1052824&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/pom.xml (original)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/pom.xml Sun Dec 26 02:31:22 2010
@@ -54,7 +54,6 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.7</version>
<scope>test</scope>
</dependency>
Modified: myfaces/extensions/cdi/trunk/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/pom.xml?rev=1052824&r1=1052823&r2=1052824&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/pom.xml (original)
+++ myfaces/extensions/cdi/trunk/pom.xml Sun Dec 26 02:31:22 2010
@@ -240,6 +240,13 @@
<version>0.9.2-SNAPSHOT</version>
</dependency>
+ <!-- Base test infrastructure modules -->
+ <dependency>
+ <groupId>org.apache.myfaces.extensions.cdi.test</groupId>
+ <artifactId>myfaces-extcdi-cargo-base-test-infrastructure</artifactId>
+ <version>0.9.2-SNAPSHOT</version>
+ </dependency>
+
<!--
We currently need this for the CDI test container to emulate the @SessionScoped.
TODO: Finally this should not be necessary anymore.
Modified: myfaces/extensions/cdi/trunk/test-modules/base-cargo-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/cargo/AbstractCargoTest.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/base-cargo-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/cargo/AbstractCargoTest.java?rev=1052824&r1=1052823&r2=1052824&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/base-cargo-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/cargo/AbstractCargoTest.java (original)
+++ myfaces/extensions/cdi/trunk/test-modules/base-cargo-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/cargo/AbstractCargoTest.java Sun Dec 26 02:31:22 2010
@@ -70,6 +70,13 @@ public abstract class AbstractCargoTest
return;
}
+ baseUrl = getCustomBaseURL();
+
+ if(baseUrl != null)
+ {
+ return;
+ }
+
String port = System.getProperty(CARGO_PORT_PROPERTY);
if (port == null)
{
@@ -85,6 +92,12 @@ public abstract class AbstractCargoTest
baseUrl = "http://localhost:" + port + "/" + context + "/";
}
+ protected String getCustomBaseURL()
+ {
+ //override if needed
+ return null;
+ }
+
@Before
public void setUp() throws Exception
{
Modified: myfaces/extensions/cdi/trunk/test-modules/base-cargo-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/cargo/SimplePageInteraction.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/base-cargo-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/cargo/SimplePageInteraction.java?rev=1052824&r1=1052823&r2=1052824&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/base-cargo-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/cargo/SimplePageInteraction.java (original)
+++ myfaces/extensions/cdi/trunk/test-modules/base-cargo-test-infrastructure-module/src/main/java/org/apache/myfaces/extensions/cdi/test/base/cargo/SimplePageInteraction.java Sun Dec 26 02:31:22 2010
@@ -18,8 +18,10 @@
*/
package org.apache.myfaces.extensions.cdi.test.base.cargo;
+import com.gargoylesoftware.htmlunit.ElementNotFoundException;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
+import com.gargoylesoftware.htmlunit.html.HtmlInput;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import org.apache.http.conn.HttpHostConnectException;
import org.apache.myfaces.extensions.cdi.core.api.config.view.ViewConfig;
@@ -45,6 +47,7 @@ public class SimplePageInteraction
private String initialWindowId;
private String okButtonId = "ok";
private boolean checkWindowId;
+ private boolean defaultFormActive = true;
public SimplePageInteraction(TestConfiguration testConfiguration)
{
@@ -76,12 +79,17 @@ public class SimplePageInteraction
public SimplePageInteraction useDefaultForm()
{
- return useForm("mainForm");
+ if(this.defaultFormActive)
+ {
+ return useForm("mainForm");
+ }
+ return this;
}
public SimplePageInteraction useForm(String formId)
{
this.currentForm = this.currentPage.getFormByName(formId);
+ this.defaultFormActive = false;
return this;
}
@@ -142,15 +150,29 @@ public class SimplePageInteraction
return this;
}
- public SimplePageInteraction checkValue(String inputId, String expectedValue)
+ public SimplePageInteraction checkTextValue(String inputId, String expectedValue)
+ {
+ return checkValue(inputId, expectedValue, true);
+ }
+
+ public SimplePageInteraction checkInputValue(String inputId, String expectedValue)
+ {
+ return checkValue(inputId, expectedValue, false);
+ }
+
+ protected SimplePageInteraction checkValue(String inputId, String expectedValue, boolean outputText)
{
- assertEquals(expectedValue, getValue(this.currentPage, inputId));
+ assertEquals(expectedValue, getValue(this.currentPage, inputId, outputText));
return this;
}
- protected String getValue(HtmlPage htmlPage, String inputId)
+ protected String getValue(HtmlPage htmlPage, String id, boolean outputText)
{
- return htmlPage.getElementById(inputId).getAttribute("value");
+ if(outputText)
+ {
+ return htmlPage.getElementById(id).getTextContent();
+ }
+ return htmlPage.getElementById(id).getAttribute("value");
}
protected void setInputValue(HtmlPage htmlPage, String inputId, String value)
@@ -202,8 +224,19 @@ public class SimplePageInteraction
{
try
{
- this.currentPage = this.currentForm.getInputByName(id).click();
- //TODO
+ HtmlInput commandNode;
+
+ try
+ {
+ commandNode = this.currentForm.getInputByName(id);
+ }
+ catch (ElementNotFoundException e)
+ {
+ //in case of get-requests it isn't required that the element is in a form
+ commandNode = this.currentPage.getHtmlElementById(id);
+ }
+
+ this.currentPage = commandNode.click();
useDefaultForm();
if(expectedTarget != null)
Modified: myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/pom.xml?rev=1052824&r1=1052823&r2=1052824&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/pom.xml (original)
+++ myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/pom.xml Sun Dec 26 02:31:22 2010
@@ -37,7 +37,7 @@
</parent>
<properties>
- <cargo.context>myfaces-extcdi-cargo-test</cargo.context>
+ <cargo.context>cargo-test</cargo.context>
<cargo.port>8787</cargo.port> <!-- use port 8787 in order to prevent port-already-in-use on hudson -->
</properties>
@@ -124,7 +124,6 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.8.1</version>
<scope>test</scope>
</dependency>
@@ -134,6 +133,12 @@
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.myfaces.extensions.cdi.test</groupId>
+ <artifactId>myfaces-extcdi-cargo-base-test-infrastructure</artifactId>
+ <scope>test</scope>
+ </dependency>
+
<!-- Servlet container -->
<dependency>
<groupId>javax.servlet</groupId>
@@ -259,4 +264,31 @@
</dependencies>
+ <profiles>
+ <profile>
+ <id>jettyConfig</id>
+ <build>
+ <plugins>
+ <plugin>
+ <!--This plugin allows to run the example using mvn jetty:run -->
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty-maven-plugin</artifactId>
+ <version>${maven.jetty.plugin.version}</version>
+ <configuration>
+ <scanIntervalSeconds>10</scanIntervalSeconds>
+ <webAppConfig>
+ <contextPath>/${cargo.context}</contextPath>
+ </webAppConfig>
+ <connectors>
+ <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
+ <port>${cargo.port}</port>
+ <maxIdleTime>60000</maxIdleTime>
+ </connector>
+ </connectors>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
</project>
Copied: myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/view/Utils.java (from r1052124, myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/Utils.java)
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/view/Utils.java?p2=myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/view/Utils.java&p1=myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/Utils.java&r1=1052124&r2=1052824&rev=1052824&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/Utils.java (original)
+++ myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/view/Utils.java Sun Dec 26 02:31:22 2010
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.myfaces.extensions.cdi.test.cargo;
+package org.apache.myfaces.extensions.cdi.test.cargo.view;
import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.WindowContext;
Added: myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/view/config/Pages.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/view/config/Pages.java?rev=1052824&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/view/config/Pages.java (added)
+++ myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/view/config/Pages.java Sun Dec 26 02:31:22 2010
@@ -0,0 +1,54 @@
+/*
+ * 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 org.apache.myfaces.extensions.cdi.test.cargo.view.config;
+
+import org.apache.myfaces.extensions.cdi.core.api.config.view.ViewConfig;
+import org.apache.myfaces.extensions.cdi.jsf.api.config.view.Page;
+
+import static org.apache.myfaces.extensions.cdi.jsf.api.config.view.Page.NavigationMode.REDIRECT;
+
+/**
+ * @author Gerhard Petracek
+ */
+@Page(navigation = REDIRECT)
+public interface Pages extends ViewConfig
+{
+ public interface Conversation extends Pages
+ {
+ @Page
+ public class Conversation1 implements Conversation
+ {
+ }
+
+ @Page
+ public class Conversation2 implements Conversation
+ {
+ }
+
+ @Page
+ public class Conversation3 implements Conversation
+ {
+ }
+
+ @Page
+ public class Result implements Conversation
+ {
+ }
+ }
+}
Copied: myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/view/conversation/ConversationBean.java (from r1052124, myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/conversation/ConversationBean.java)
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/view/conversation/ConversationBean.java?p2=myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/view/conversation/ConversationBean.java&p1=myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/conversation/ConversationBean.java&r1=1052124&r2=1052824&rev=1052824&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/conversation/ConversationBean.java (original)
+++ myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/java/org/apache/myfaces/extensions/cdi/test/cargo/view/conversation/ConversationBean.java Sun Dec 26 02:31:22 2010
@@ -16,10 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.myfaces.extensions.cdi.test.cargo.conversation;
+package org.apache.myfaces.extensions.cdi.test.cargo.view.conversation;
+import org.apache.myfaces.extensions.cdi.core.api.config.view.ViewConfig;
import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.Conversation;
import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ConversationScoped;
+import org.apache.myfaces.extensions.cdi.test.cargo.view.config.Pages;
import javax.faces.event.ActionEvent;
import javax.inject.Inject;
@@ -33,6 +35,7 @@ import java.io.Serializable;
@ConversationScoped
public class ConversationBean implements Serializable
{
+ private static final long serialVersionUID = -3165721387186644462L;
private String value1;
private String value2;
@@ -41,6 +44,26 @@ public class ConversationBean implements
@Inject
private Conversation conversation;
+ public Class<? extends ViewConfig> step1()
+ {
+ return Pages.Conversation.Conversation1.class;
+ }
+
+ public Class<? extends ViewConfig> step2()
+ {
+ return Pages.Conversation.Conversation2.class;
+ }
+
+ public Class<? extends ViewConfig> step3()
+ {
+ return Pages.Conversation.Conversation3.class;
+ }
+
+ public Class<? extends ViewConfig> finish()
+ {
+ return Pages.Conversation.Result.class;
+ }
+
public void closeConversation(ActionEvent e)
{
conversation.close();
Modified: myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/index.xhtml
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/index.xhtml?rev=1052824&r1=1052823&r2=1052824&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/index.xhtml (original)
+++ myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/index.xhtml Sun Dec 26 02:31:22 2010
@@ -36,7 +36,7 @@
<h2>Scope Tests</h2>
<ul>
- <li><h:link value="Conversation Test" outcome="conversation/conversation1.xhtml" /></li>
+ <li><h:link value="Conversation Test" outcome="pages/conversation/conversation1.xhtml" /></li>
</ul>
</h:body>
Modified: myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/pages/conversation/conversation1.xhtml
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/pages/conversation/conversation1.xhtml?rev=1052824&r1=1052124&r2=1052824&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/pages/conversation/conversation1.xhtml (original)
+++ myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/pages/conversation/conversation1.xhtml Sun Dec 26 02:31:22 2010
@@ -36,7 +36,7 @@
Value1: <h:inputText id="value1" value="#{conversationBean.value1}" />
</p>
- <h:commandButton id="nextPage" value="Next Page" action="conversation2.xhtml" />
+ <h:commandButton id="nextPage" value="Next Page" action="#{conversationBean.step2}" />
</h:form>
</h:body>
Modified: myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/pages/conversation/conversation2.xhtml
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/pages/conversation/conversation2.xhtml?rev=1052824&r1=1052124&r2=1052824&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/pages/conversation/conversation2.xhtml (original)
+++ myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/pages/conversation/conversation2.xhtml Sun Dec 26 02:31:22 2010
@@ -36,8 +36,8 @@
Value2: <h:inputText id="value2" value="#{conversationBean.value2}" />
</p>
- <h:commandButton id="nextPage" value="Next Page" action="conversation3.xhtml" />
- <h:commandButton id="back" value="Back" action="conversation1.xhtml" />
+ <h:commandButton id="nextPage" value="Next Page" action="#{conversationBean.step3}" />
+ <h:commandButton id="back" value="Back" action="#{conversationBean.step1}" />
</h:form>
</h:body>
Modified: myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/pages/conversation/conversation3.xhtml
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/pages/conversation/conversation3.xhtml?rev=1052824&r1=1052124&r2=1052824&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/pages/conversation/conversation3.xhtml (original)
+++ myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/pages/conversation/conversation3.xhtml Sun Dec 26 02:31:22 2010
@@ -36,8 +36,8 @@
Value3: <h:inputText id="value3" value="#{conversationBean.value3}" />
</p>
- <h:commandButton id="submit" value="Submit" action="result.xhtml" />
- <h:commandButton id="back" value="Back" action="conversation2.xhtml" />
+ <h:commandButton id="submit" value="Submit" action="#{conversationBean.finish}" />
+ <h:commandButton id="back" value="Back" action="#{conversationBean.step2}" />
</h:form>
</h:body>
Modified: myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/pages/conversation/result.xhtml
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/pages/conversation/result.xhtml?rev=1052824&r1=1052124&r2=1052824&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/pages/conversation/result.xhtml (original)
+++ myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/main/webapp/pages/conversation/result.xhtml Sun Dec 26 02:31:22 2010
@@ -37,8 +37,8 @@
Value3: <h:outputText id="value3" value="#{conversationBean.value3}" />
</p>
- <h:button id="refresh" value="Refresh (GET)" outcome="result.xhtml" />
- <h:button id="back" value="Back (GET)" outcome="conversation3.xhtml" />
+ <h:button id="refresh" value="Refresh (GET)" outcome="/pages/conversation/result.xhtml" />
+ <h:button id="back" value="Back (GET)" outcome="/pages/conversation/conversation3.xhtml" />
<h:form id="form">
<h:commandButton id="closeConversation" value="Close conversation"
Added: myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/cargo/conversation/BaseConversationTest.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/cargo/conversation/BaseConversationTest.java?rev=1052824&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/cargo/conversation/BaseConversationTest.java (added)
+++ myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/cargo/conversation/BaseConversationTest.java Sun Dec 26 02:31:22 2010
@@ -0,0 +1,33 @@
+/*
+ * 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 org.apache.myfaces.extensions.cdi.test.cargo.conversation;
+
+import org.apache.myfaces.extensions.cdi.test.base.cargo.AbstractCargoTest;
+
+/**
+ * @author Gerhard Petracek
+ */
+abstract class BaseConversationTest extends AbstractCargoTest
+{
+ @Override
+ protected String getCustomBaseURL()
+ {
+ return "http://localhost:8787/cargo-test/";
+ }
+}
Modified: myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/cargo/conversation/ConversationTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/cargo/conversation/ConversationTestCase.java?rev=1052824&r1=1052823&r2=1052824&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/cargo/conversation/ConversationTestCase.java (original)
+++ myfaces/extensions/cdi/trunk/test-modules/cargo-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/cargo/conversation/ConversationTestCase.java Sun Dec 26 02:31:22 2010
@@ -18,19 +18,17 @@
*/
package org.apache.myfaces.extensions.cdi.test.cargo.conversation;
-import com.gargoylesoftware.htmlunit.html.HtmlForm;
-import com.gargoylesoftware.htmlunit.html.HtmlPage;
-import org.apache.myfaces.extensions.cdi.test.cargo.AbstractCodiTest;
-import org.junit.Assert;
+import org.apache.myfaces.extensions.cdi.test.base.cargo.SimplePageInteraction;
+import org.apache.myfaces.extensions.cdi.test.base.cargo.runner.JUnit4WithCargo;
+import org.apache.myfaces.extensions.cdi.test.cargo.view.config.Pages;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* @author Jakob Korherr
*/
-@RunWith(JUnit4.class)
-public class ConversationTestCase extends AbstractCodiTest
+@RunWith(JUnit4WithCargo.class)
+public class ConversationTestCase extends BaseConversationTest
{
// NOTE that new @Test means new WebClient means new WindowContext
@@ -38,99 +36,102 @@ public class ConversationTestCase extend
@Test
public void testConversationDialog() throws Exception
{
- HtmlPage page = webClient.getPage(BASE_URL + "conversation/conversation1.xhtml");
-
- // page 1
- HtmlForm form = page.getFormByName("conversation1");
- form.getInputByName("conversation1:value1").setValueAttribute("1");
- page = form.getInputByName("conversation1:nextPage").click();
-
- // page 2
- form = page.getFormByName("conversation2");
- form.getInputByName("conversation2:value2").setValueAttribute("2");
- page = form.getInputByName("conversation2:nextPage").click();
-
- // page 3
- form = page.getFormByName("conversation3");
- form.getInputByName("conversation3:value3").setValueAttribute("3");
- page = form.getInputByName("conversation3:submit").click();
-
- // result page
- Assert.assertEquals("1", page.getElementById("value1").getTextContent());
- Assert.assertEquals("2", page.getElementById("value2").getTextContent());
- Assert.assertEquals("3", page.getElementById("value3").getTextContent());
-
- // GET request
- page = page.getElementById("refresh").click();
-
- Assert.assertEquals("1", page.getElementById("value1").getTextContent());
- Assert.assertEquals("2", page.getElementById("value2").getTextContent());
- Assert.assertEquals("3", page.getElementById("value3").getTextContent());
-
- // GET request to page 3
- page = page.getElementById("back").click();
-
- // POST request to page 2
- page = page.getElementById("conversation3:back").click();
-
- // page 2
- form = page.getFormByName("conversation2");
- form.getInputByName("conversation2:value2").setValueAttribute("new2");
- page = form.getInputByName("conversation2:nextPage").click();
-
- // page 3
- form = page.getFormByName("conversation3");
- form.getInputByName("conversation3:value3").setValueAttribute("new3");
- page = form.getInputByName("conversation3:submit").click();
-
- // result page
- Assert.assertEquals("1", page.getElementById("value1").getTextContent());
- Assert.assertEquals("new2", page.getElementById("value2").getTextContent());
- Assert.assertEquals("new3", page.getElementById("value3").getTextContent());
+ SimplePageInteraction pageInteraction = new SimplePageInteraction(getTestConfiguration())
+ .with(Pages.Conversation.Conversation1.class)
+ .with(Pages.Conversation.Conversation2.class)
+ .with(Pages.Conversation.Conversation3.class)
+ .with(Pages.Conversation.Result.class)
+ .start(Pages.Conversation.Conversation1.class)
+ .useForm("conversation1");
+
+ pageInteraction.setValue("conversation1:value1", "1");
+ pageInteraction
+ .click("conversation1:nextPage")
+ .checkState(Pages.Conversation.Conversation2.class)
+ .useForm("conversation2");
+
+ pageInteraction.setValue("conversation2:value2", "2")
+ .click("conversation2:nextPage")
+ .checkState(Pages.Conversation.Conversation3.class)
+ .useForm("conversation3");
+
+ pageInteraction.setValue("conversation3:value3", "3")
+ .click("conversation3:submit")
+ .checkState(Pages.Conversation.Result.class);
+
+ pageInteraction.checkTextValue("value1", "1");
+ pageInteraction.checkTextValue("value2", "2");
+ pageInteraction.checkTextValue("value3", "3");
+
+ pageInteraction.click("refresh")
+ .checkState(Pages.Conversation.Result.class);
+
+ pageInteraction.checkTextValue("value1", "1");
+ pageInteraction.checkTextValue("value2", "2");
+ pageInteraction.checkTextValue("value3", "3");
+
+ pageInteraction.click("back")
+ .checkState(Pages.Conversation.Conversation3.class)
+ .useForm("conversation3");
+
+ pageInteraction.click("conversation3:back")
+ .checkState(Pages.Conversation.Conversation2.class)
+ .useForm("conversation2");
+
+ pageInteraction.setValue("conversation2:value2", "new2")
+ .click("conversation2:nextPage")
+ .checkState(Pages.Conversation.Conversation3.class)
+ .useForm("conversation3");
+
+ pageInteraction.setValue("conversation3:value3", "new3")
+ .click("conversation3:submit")
+ .checkState(Pages.Conversation.Result.class);
+
+ pageInteraction.checkTextValue("value1", "1");
+ pageInteraction.checkTextValue("value2", "new2");
+ pageInteraction.checkTextValue("value3", "new3");
// close conversation
- form = page.getFormByName("form");
- page = form.getInputByName("form:closeConversation").click();
+ pageInteraction.useForm("form").click("form:closeConversation");
- // values must be empty
- Assert.assertEquals("", page.getElementById("value1").getTextContent());
- Assert.assertEquals("", page.getElementById("value2").getTextContent());
- Assert.assertEquals("", page.getElementById("value3").getTextContent());
+ pageInteraction.checkTextValue("value1", "");
+ pageInteraction.checkTextValue("value2", "");
+ pageInteraction.checkTextValue("value3", "");
}
@Test
public void testConversationDialogRestart() throws Exception
{
- HtmlPage page = webClient.getPage(BASE_URL + "conversation/conversation1.xhtml");
-
- // page 1
- HtmlForm form = page.getFormByName("conversation1");
- form.getInputByName("conversation1:value1").setValueAttribute("1");
- page = form.getInputByName("conversation1:nextPage").click();
-
- // page 2
- form = page.getFormByName("conversation2");
- form.getInputByName("conversation2:value2").setValueAttribute("2");
- page = form.getInputByName("conversation2:nextPage").click();
-
- // page 3
- form = page.getFormByName("conversation3");
- form.getInputByName("conversation3:value3").setValueAttribute("3");
- page = form.getInputByName("conversation3:submit").click();
-
- // result page
- Assert.assertEquals("1", page.getElementById("value1").getTextContent());
- Assert.assertEquals("2", page.getElementById("value2").getTextContent());
- Assert.assertEquals("3", page.getElementById("value3").getTextContent());
-
- // restart conversation
- form = page.getFormByName("form");
- page = form.getInputByName("form:restartConversation").click();
-
- // values must be empty
- Assert.assertEquals("", page.getElementById("value1").getTextContent());
- Assert.assertEquals("", page.getElementById("value2").getTextContent());
- Assert.assertEquals("", page.getElementById("value3").getTextContent());
+ SimplePageInteraction pageInteraction = new SimplePageInteraction(getTestConfiguration())
+ .with(Pages.Conversation.Conversation1.class)
+ .with(Pages.Conversation.Conversation2.class)
+ .with(Pages.Conversation.Conversation3.class)
+ .with(Pages.Conversation.Result.class)
+ .start(Pages.Conversation.Conversation1.class)
+ .useForm("conversation1");
+
+ pageInteraction.setValue("conversation1:value1", "1")
+ .click("conversation1:nextPage")
+ .checkState(Pages.Conversation.Conversation2.class)
+ .useForm("conversation2");
+
+ pageInteraction.setValue("conversation2:value2", "2")
+ .click("conversation2:nextPage")
+ .checkState(Pages.Conversation.Conversation3.class)
+ .useForm("conversation3");
+
+ pageInteraction.setValue("conversation3:value3", "3")
+ .click("conversation3:submit")
+ .checkState(Pages.Conversation.Result.class);
+
+ pageInteraction.checkTextValue("value1", "1");
+ pageInteraction.checkTextValue("value2", "2");
+ pageInteraction.checkTextValue("value3", "3");
+
+ pageInteraction.useForm("form").click("form:restartConversation");
+
+ pageInteraction.checkTextValue("value1", "");
+ pageInteraction.checkTextValue("value2", "");
+ pageInteraction.checkTextValue("value3", "");
}
-
}
Modified: myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/pom.xml?rev=1052824&r1=1052823&r2=1052824&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/pom.xml (original)
+++ myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/pom.xml Sun Dec 26 02:31:22 2010
@@ -39,7 +39,6 @@
<properties>
<webapptest.version>1.0.0-SNAPSHOT</webapptest.version>
<arquillian.version>1.0.0-SNAPSHOT</arquillian.version>
- <junit.version>4.8.1</junit.version>
<tomcat.version>6.0.26</tomcat.version>
<config.addon.version>1.0.0-alpha</config.addon.version>
</properties>
@@ -62,7 +61,6 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>${junit.version}</version>
<scope>test</scope>
</dependency>