You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2012/07/18 10:00:26 UTC
svn commit: r1362801 - in /myfaces/tobago/branches/tobago-1.5.x: ./
tobago-example/tobago-example-test/
tobago-example/tobago-example-test/src/main/java/org/
tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/
tobag...
Author: lofwyr
Date: Wed Jul 18 08:00:25 2012
New Revision: 1362801
URL: http://svn.apache.org/viewvc?rev=1362801&view=rev
Log:
TOBAGO-1174: Easier handling of Selenium tests
Merged from trunk [from revision 1361380]
Added:
myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/KillSession.java
- copied unchanged from r1361380, myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/KillSession.java
myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/tc/popup/popup-bug-tobago-1091.selenium.html
- copied unchanged from r1361380, myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/popup/popup-bug-tobago-1091.selenium.html
myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/tc/tree/tree-select.selenium.html
- copied unchanged from r1361380, myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/tree/tree-select.selenium.html
myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/test/java/org/apache/myfaces/tobago/example/test/SeleniumScript.java
- copied unchanged from r1361380, myfaces/tobago/trunk/tobago-example/tobago-example-test/src/test/java/org/apache/myfaces/tobago/example/test/SeleniumScript.java
myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/test/java/org/apache/myfaces/tobago/example/test/SeleniumScriptItem.java
- copied unchanged from r1361380, myfaces/tobago/trunk/tobago-example/tobago-example-test/src/test/java/org/apache/myfaces/tobago/example/test/SeleniumScriptItem.java
Modified:
myfaces/tobago/branches/tobago-1.5.x/ (props changed)
myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/pom.xml
myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/java/org/ (props changed)
myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/TestPageFilter.java
myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/WEB-INF/web.xml
myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/tc/ (props changed)
myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/tc/tree/tree-select.xhtml
myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/test/java/org/apache/myfaces/tobago/example/test/AutomaticSeleniumTest.java (contents, props changed)
myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/test/java/org/apache/myfaces/tobago/example/test/SeleniumTest.java (contents, props changed)
Propchange: myfaces/tobago/branches/tobago-1.5.x/
------------------------------------------------------------------------------
Merged /myfaces/tobago/trunk:r1361380
Modified: myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/pom.xml?rev=1362801&r1=1362800&r2=1362801&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/pom.xml (original)
+++ myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/pom.xml Wed Jul 18 08:00:25 2012
@@ -210,6 +210,11 @@
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>net.sourceforge.nekohtml</groupId>
+ <artifactId>nekohtml</artifactId>
+ <version>1.9.15</version>
+ </dependency>
</dependencies>
<profiles>
<profile>
Propchange: myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/java/org/
------------------------------------------------------------------------------
Merged /myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org:r1361380
Modified: myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/TestPageFilter.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/TestPageFilter.java?rev=1362801&r1=1362800&r2=1362801&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/TestPageFilter.java (original)
+++ myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/TestPageFilter.java Wed Jul 18 08:00:25 2012
@@ -37,7 +37,8 @@ public class TestPageFilter {
"/WEB-INF.*",
"/org/.*",
"/src/.*",
- ".*/\\.svn/.*"
+ ".*/\\.svn/.*",
+ ".*\\.selenium\\.html"
));
/**
Modified: myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/WEB-INF/web.xml?rev=1362801&r1=1362800&r2=1362801&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/WEB-INF/web.xml (original)
+++ myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/WEB-INF/web.xml Wed Jul 18 08:00:25 2012
@@ -66,6 +66,11 @@
<servlet-class>org.apache.myfaces.tobago.servlet.ResourceServlet</servlet-class>
</servlet>
+ <servlet>
+ <servlet-name>KillSessionServlet</servlet-name>
+ <servlet-class>org.apache.myfaces.tobago.example.test.KillSession</servlet-class>
+ </servlet>
+
<servlet-mapping>
<servlet-name>FacesServlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
@@ -76,6 +81,11 @@
<url-pattern>/org/apache/myfaces/tobago/renderkit/html/*</url-pattern>
</servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>KillSessionServlet</servlet-name>
+ <url-pattern>/KillSession</url-pattern>
+ </servlet-mapping>
+
<filter>
<filter-name>MyFacesExtensionsFilter</filter-name>
<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
Propchange: myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/tc/
------------------------------------------------------------------------------
Merged /myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc:r1361380
Modified: myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/tc/tree/tree-select.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/tc/tree/tree-select.xhtml?rev=1362801&r1=1362800&r2=1362801&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/tc/tree/tree-select.xhtml (original)
+++ myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/tc/tree/tree-select.xhtml Wed Jul 18 08:00:25 2012
@@ -19,11 +19,13 @@
<f:view
xmlns:tc="http://myfaces.apache.org/tobago/component"
xmlns:tx="http://myfaces.apache.org/tobago/extension"
- xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core">
- <tc:page>
+ <tc:page id="page">
<tc:gridLayoutConstraint width="600px" height="300px"/>
+ <f:facet name="layout">
+ <tc:gridLayout rows="*;auto;auto"/>
+ </f:facet>
<tc:tree id="tree" selectable="single" showRoot="true" showRootJunction="true">
<tc:treeData value="#{tree.tree}" var="node" id="data">
@@ -34,5 +36,15 @@
</tc:treeData>
</tc:tree>
+ <tx:in fieldId="in" label="Required" required="true"/>
+ <tc:panel>
+ <f:facet name="layout">
+ <tc:gridLayout columns="*;auto;auto"/>
+ </f:facet>
+ <tc:panel/>
+ <tc:button id="cancel" label="Cancel" immediate="true"/>
+ <tc:button id="submit" label="Submit"/>
+ </tc:panel>
+
</tc:page>
</f:view>
Modified: myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/test/java/org/apache/myfaces/tobago/example/test/AutomaticSeleniumTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/test/java/org/apache/myfaces/tobago/example/test/AutomaticSeleniumTest.java?rev=1362801&r1=1362800&r2=1362801&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/test/java/org/apache/myfaces/tobago/example/test/AutomaticSeleniumTest.java (original)
+++ myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/test/java/org/apache/myfaces/tobago/example/test/AutomaticSeleniumTest.java Wed Jul 18 08:00:25 2012
@@ -20,8 +20,13 @@ package org.apache.myfaces.tobago.exampl
import org.apache.myfaces.tobago.util.Parameterized;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.xml.sax.SAXException;
+import javax.xml.xpath.XPathExpressionException;
import java.io.File;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -30,6 +35,8 @@ import java.util.List;
@RunWith(Parameterized.class)
public class AutomaticSeleniumTest extends SeleniumTest {
+ private static final Logger LOG = LoggerFactory.getLogger(AutomaticSeleniumTest.class);
+
private static final String MAVEN_TARGET = "target/tobago-example-test";
private String url;
@@ -39,9 +46,23 @@ public class AutomaticSeleniumTest exten
}
@Test
- public void testPageConsistency() {
- getSelenium().open(url);
- checkPage();
+ public void testPageConsistency() throws Exception {
+ SeleniumScript script = getSeleniumScript(url);
+
+ getCommandProcessor().doCommand("open", new String[] {"http://localhost:8080/" + "KillSession", ""});
+
+ for (SeleniumScriptItem item : script.getItems()) {
+ LOG.info("Calling: " + item);
+ getCommandProcessor().doCommand(item.getCommand(), item.getParameters());
+ checkPage();
+ }
+ }
+
+ private SeleniumScript getSeleniumScript(String url) throws XPathExpressionException, SAXException, IOException {
+ String seleniumUrl = url.substring("/faces/".length());
+ seleniumUrl = seleniumUrl.substring(0, seleniumUrl.lastIndexOf("."));
+ seleniumUrl = "http://localhost:8080/" + seleniumUrl + ".selenium.html";
+ return new SeleniumScript(seleniumUrl, url);
}
@Parameterized.Parameters
Propchange: myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/test/java/org/apache/myfaces/tobago/example/test/AutomaticSeleniumTest.java
------------------------------------------------------------------------------
Merged /myfaces/tobago/trunk/tobago-example/tobago-example-test/src/test/java/org/apache/myfaces/tobago/example/test/AutomaticSeleniumTest.java:r1361380
Modified: myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/test/java/org/apache/myfaces/tobago/example/test/SeleniumTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/test/java/org/apache/myfaces/tobago/example/test/SeleniumTest.java?rev=1362801&r1=1362800&r2=1362801&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/test/java/org/apache/myfaces/tobago/example/test/SeleniumTest.java (original)
+++ myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/test/java/org/apache/myfaces/tobago/example/test/SeleniumTest.java Wed Jul 18 08:00:25 2012
@@ -17,7 +17,9 @@ package org.apache.myfaces.tobago.exampl
* limitations under the License.
*/
+import com.thoughtworks.selenium.CommandProcessor;
import com.thoughtworks.selenium.DefaultSelenium;
+import com.thoughtworks.selenium.HttpCommandProcessor;
import com.thoughtworks.selenium.SeleniumException;
import org.junit.AfterClass;
import org.junit.Assert;
@@ -33,25 +35,35 @@ public abstract class SeleniumTest {
public static final String HAS_ERROR_SEVERITY = "has error severity";
public static final String IS_BROKEN = "is broken";
+ @Deprecated
private static DefaultSelenium selenium;
+ private static CommandProcessor commandProcessor;
@BeforeClass
public static void setUp() throws Exception {
selenium = createSeleniumClient();
selenium.start();
+//todo alternative commandProcessor.start();
}
@AfterClass
public static void tearDown() throws Exception {
selenium.stop();
+//todo alternative commandProcessor.stop();
}
+ @Deprecated
protected DefaultSelenium getSelenium() {
return selenium;
}
+ protected CommandProcessor getCommandProcessor() {
+ return commandProcessor;
+ }
+
protected static DefaultSelenium createSeleniumClient() throws Exception {
- return new DefaultSelenium("localhost", 4444, "*firefox", "http://localhost:8080/");
+ commandProcessor = new HttpCommandProcessor("localhost", 4444, "*firefox", "http://localhost:8080/");
+ return new DefaultSelenium(commandProcessor);
}
protected void waitForAjaxComplete() {
Propchange: myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/test/java/org/apache/myfaces/tobago/example/test/SeleniumTest.java
------------------------------------------------------------------------------
Merged /myfaces/tobago/trunk/tobago-example/tobago-example-test/src/test/java/org/apache/myfaces/tobago/example/test/SeleniumTest.java:r1361380