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 2013/04/04 17:49:32 UTC
svn commit: r1464599 - in
/myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test:
./ src/test/java/org/apache/myfaces/tobago/example/test/
Author: lofwyr
Date: Thu Apr 4 15:49:32 2013
New Revision: 1464599
URL: http://svn.apache.org/r1464599
Log:
selenium tests:
- removing nekohtml, because is requires xercesImpl.jar
- removing selenium repository, because all stuff is now in the default repo
Modified:
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/test/java/org/apache/myfaces/tobago/example/test/AutomaticSeleniumTest.java
myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/test/java/org/apache/myfaces/tobago/example/test/SeleniumScript.java
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=1464599&r1=1464598&r2=1464599&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 Thu Apr 4 15:49:32 2013
@@ -200,7 +200,7 @@
<dependency>
<groupId>org.seleniumhq.selenium.client-drivers</groupId>
<artifactId>selenium-java-client-driver</artifactId>
- <version>1.0.1</version>
+ <version>1.0.2</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -210,11 +210,6 @@
<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>
@@ -402,17 +397,4 @@
</profile>
</profiles>
- <repositories>
- <repository>
- <id>openqa</id>
- <name>OpenQA Repository</name>
- <url>http://nexus.openqa.org/content/repositories/releases/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- <releases>
- <enabled>true</enabled>
- </releases>
- </repository>
- </repositories>
</project>
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=1464599&r1=1464598&r2=1464599&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 Thu Apr 4 15:49:32 2013
@@ -26,9 +26,11 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xml.sax.SAXException;
+import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPathExpressionException;
import java.io.File;
import java.io.IOException;
+import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -60,11 +62,12 @@ public class AutomaticSeleniumTest exten
}
}
- private SeleniumScript getSeleniumScript(String url) throws XPathExpressionException, SAXException, IOException {
+ private SeleniumScript getSeleniumScript(String url)
+ throws XPathExpressionException, SAXException, IOException, ParserConfigurationException {
String seleniumUrl = url.substring("/faces/".length());
seleniumUrl = seleniumUrl.substring(0, seleniumUrl.lastIndexOf("."));
seleniumUrl = "http://localhost:8080/" + seleniumUrl + ".selenium.html";
- return new SeleniumScript(seleniumUrl, url);
+ return new SeleniumScript(new URL(seleniumUrl), url);
}
@Parameterized.Parameters
Modified: myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/test/java/org/apache/myfaces/tobago/example/test/SeleniumScript.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/SeleniumScript.java?rev=1464599&r1=1464598&r2=1464599&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/test/java/org/apache/myfaces/tobago/example/test/SeleniumScript.java (original)
+++ myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/test/java/org/apache/myfaces/tobago/example/test/SeleniumScript.java Thu Apr 4 15:49:32 2013
@@ -19,21 +19,25 @@
package org.apache.myfaces.tobago.example.test;
-import org.apache.html.dom.HTMLDocumentImpl;
-import org.cyberneko.html.parsers.DOMFragmentParser;
import org.junit.Assert;
-import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import org.w3c.dom.html.HTMLDocument;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.io.StringReader;
+import java.net.URL;
import java.util.ArrayList;
import java.util.List;
@@ -49,35 +53,37 @@ public class SeleniumScript {
static {
try {
XPATH_FACTORY = XPathFactory.newInstance();
- XPATH_EXPRESSION = XPATH_FACTORY.newXPath().compile("//TABLE/TBODY");
- TR_XPATH = XPATH_FACTORY.newXPath().compile("TR");
- TD_XPATH = XPATH_FACTORY.newXPath().compile("TD");
+ XPATH_EXPRESSION = XPATH_FACTORY.newXPath().compile("//table/tbody");
+ TR_XPATH = XPATH_FACTORY.newXPath().compile("tr");
+ TD_XPATH = XPATH_FACTORY.newXPath().compile("td");
} catch (XPathExpressionException e) {
throw new RuntimeException(e);
}
}
- public SeleniumScript(String scriptUrl, String url) throws IOException, SAXException, XPathExpressionException {
- DOMFragmentParser parser = new DOMFragmentParser();
- HTMLDocument document = new HTMLDocumentImpl();
- DocumentFragment fragment = document.createDocumentFragment();
+ public SeleniumScript(URL scriptUrl, String url)
+ throws IOException, XPathExpressionException, SAXException, ParserConfigurationException {
try {
- parser.parse(scriptUrl, fragment);
- // not nice, it seems that parse also throws a FileNotFoundException sometimes.
- // XXX I don't know why
- if (fragment.getTextContent().contains("The page was not found!")) {
- throw new FileNotFoundException(scriptUrl);
- }
- addSeleniumItems(fragment, url);
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder parser = factory.newDocumentBuilder();
+ parser.setEntityResolver(new EntityResolver() {
+ public InputSource resolveEntity(String publicId, String systemId)
+ throws SAXException, IOException {
+ // do not any resource resolving
+ return new InputSource(new StringReader(""));
+ }
+ });
+
+ Document document = parser.parse(scriptUrl.openStream());
+ addSeleniumItems(document, url);
} catch (FileNotFoundException e) {
// using default
items.add(new SeleniumScriptItem("open", url, ""));
}
}
- private void addSeleniumItems(DocumentFragment fragment, String url) throws XPathExpressionException {
-
- final Object table = XPATH_EXPRESSION.evaluate(fragment, XPathConstants.NODE);
+ private void addSeleniumItems(Document document, String url) throws XPathExpressionException {
+ final Object table = XPATH_EXPRESSION.evaluate(document, XPathConstants.NODE);
final NodeList trList = (NodeList) TR_XPATH.evaluate(table, XPathConstants.NODESET);
for (int i = 0; i < trList.getLength(); i++) {