Thread: [JWebUnit-development] SF.net SVN: jwebunit:[735] trunk
Brought to you by:
henryju
|
From: <he...@us...> - 2008-07-18 09:58:30
|
Revision: 735
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=735&view=rev
Author: henryju
Date: 2008-07-18 09:58:23 +0000 (Fri, 18 Jul 2008)
Log Message:
-----------
Please don't commit specific IDE files. Use mvn eclipse:eclipse to regenerate Eclipse config files.
Removed Paths:
-------------
trunk/.classpath
trunk/.project
Deleted: trunk/.classpath
===================================================================
--- trunk/.classpath 2008-07-08 17:40:47 UTC (rev 734)
+++ trunk/.classpath 2008-07-18 09:58:23 UTC (rev 735)
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
- <classpathentry kind="output" path="target/classes"/>
-</classpath>
Deleted: trunk/.project
===================================================================
--- trunk/.project 2008-07-08 17:40:47 UTC (rev 734)
+++ trunk/.project 2008-07-18 09:58:23 UTC (rev 735)
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>jwebunit</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.maven.ide.eclipse.maven2Builder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.maven.ide.eclipse.maven2Nature</nature>
- </natures>
-</projectDescription>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <he...@us...> - 2008-07-25 09:16:44
|
Revision: 736
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=736&view=rev
Author: henryju
Date: 2008-07-25 09:16:41 +0000 (Fri, 25 Jul 2008)
Log Message:
-----------
Updated to HtmlUnit 2.2
Modified Paths:
--------------
trunk/pom.xml
trunk/src/changes/changes.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2008-07-18 09:58:23 UTC (rev 735)
+++ trunk/pom.xml 2008-07-25 09:16:41 UTC (rev 736)
@@ -282,7 +282,7 @@
<dependency>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
- <version>2.1</version>
+ <version>2.2</version>
</dependency>
<dependency>
<groupId>org.openqa.selenium.client-drivers</groupId>
Modified: trunk/src/changes/changes.xml
===================================================================
--- trunk/src/changes/changes.xml 2008-07-18 09:58:23 UTC (rev 735)
+++ trunk/src/changes/changes.xml 2008-07-25 09:16:41 UTC (rev 736)
@@ -8,6 +8,9 @@
</properties>
<body>
<release version="2.0" date="UNKNOW">
+ <action type="update" dev="henryju">
+ Updated to HtmlUnit 2.2.
+ </action>
<action type="fix" dev="joshlane" issue="2007985,2009776" due-to="Josh Lane">
selectOptionByValue failed with Selenium Plugin.
selectOption always failed, cannot find element.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <he...@us...> - 2008-10-06 13:35:14
|
Revision: 738
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=738&view=rev
Author: henryju
Date: 2008-10-06 13:30:06 +0000 (Mon, 06 Oct 2008)
Log Message:
-----------
Updated to HtmlUnit 2.3
Modified Paths:
--------------
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java
trunk/pom.xml
trunk/src/changes/changes.xml
Modified: trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java
===================================================================
--- trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java 2008-07-30 14:18:34 UTC (rev 737)
+++ trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java 2008-10-06 13:30:06 UTC (rev 738)
@@ -83,9 +83,7 @@
import net.sourceforge.jwebunit.util.TestContext;
import org.apache.commons.httpclient.Cookie;
-import org.apache.commons.httpclient.HttpState;
import org.apache.commons.httpclient.NameValuePair;
-
import org.apache.regexp.RE;
import org.apache.regexp.RESyntaxException;
import org.slf4j.Logger;
@@ -217,14 +215,13 @@
public List<javax.servlet.http.Cookie> getCookies() {
List<javax.servlet.http.Cookie> result = new LinkedList<javax.servlet.http.Cookie>();
- final HttpState stateForUrl = wc.getWebConnection().getState();
- Cookie[] cookies = stateForUrl.getCookies();
- for (int i = 0; i < cookies.length; i++) {
+ Set<Cookie> cookies = wc.getCookieManager().getCookies();
+ for (Cookie cookie : cookies) {
javax.servlet.http.Cookie c = new javax.servlet.http.Cookie(
- cookies[i].getName(), cookies[i].getValue());
- c.setComment(cookies[i].getComment());
- c.setDomain(cookies[i].getDomain());
- Date expire = cookies[i].getExpiryDate();
+ cookie.getName(), cookie.getValue());
+ c.setComment(cookie.getComment());
+ c.setDomain(cookie.getDomain());
+ Date expire = cookie.getExpiryDate();
if (expire == null) {
c.setMaxAge(-1);
} else {
@@ -234,9 +231,9 @@
(expire.getTime() - now.getTime()) / 1000);
c.setMaxAge(second.intValue());
}
- c.setPath(cookies[i].getPath());
- c.setSecure(cookies[i].getSecure());
- c.setVersion(cookies[i].getVersion());
+ c.setPath(cookie.getPath());
+ c.setSecure(cookie.getSecure());
+ c.setVersion(cookie.getVersion());
result.add(c);
}
return result;
@@ -839,7 +836,7 @@
// Deal with cookies
for (javax.servlet.http.Cookie c : getTestContext().getCookies()) {
// If Path==null, cookie is not send to the server.
- wc.getWebConnection().getState().addCookie(
+ wc.getCookieManager().addCookie(
new Cookie(c.getDomain() != null ? c.getDomain() : "", c
.getName(), c.getValue(), c.getPath() != null ? c
.getPath() : "", c.getMaxAge(), c.getSecure()));
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2008-07-30 14:18:34 UTC (rev 737)
+++ trunk/pom.xml 2008-10-06 13:30:06 UTC (rev 738)
@@ -282,7 +282,7 @@
<dependency>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
- <version>2.2</version>
+ <version>2.3</version>
</dependency>
<dependency>
<groupId>org.openqa.selenium.client-drivers</groupId>
Modified: trunk/src/changes/changes.xml
===================================================================
--- trunk/src/changes/changes.xml 2008-07-30 14:18:34 UTC (rev 737)
+++ trunk/src/changes/changes.xml 2008-10-06 13:30:06 UTC (rev 738)
@@ -9,7 +9,7 @@
<body>
<release version="2.0" date="UNKNOW">
<action type="update" dev="henryju">
- Updated to HtmlUnit 2.2.
+ Updated to HtmlUnit 2.3.
</action>
<action type="fix" dev="joshlane" issue="2007985,2009776" due-to="Josh Lane">
selectOptionByValue failed with Selenium Plugin.
@@ -17,7 +17,7 @@
Other improvements to Selenium plugin.
</action>
<action type="update" dev="henryju" issue="1950248" due-to="Agnes Ro">
- Update to HtmlUnit 2.1 and Java 1.5.
+ Updated to HtmlUnit 2.1 and Java 1.5.
</action>
</release>
<release version="1.5" date="april 22, 2008" description="The latest major release before Java 1.5 migration">
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <he...@us...> - 2008-10-07 16:28:09
|
Revision: 739
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=739&view=rev
Author: henryju
Date: 2008-10-07 16:28:07 +0000 (Tue, 07 Oct 2008)
Log Message:
-----------
Updated site documentation (how-to-contribute, selenium part, ...).
Modified Paths:
--------------
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java
trunk/jwebunit-htmlunit-plugin/src/site/xdoc/index.xml
trunk/jwebunit-selenium-plugin/src/site/xdoc/index.xml
trunk/src/site/fml/faq.fml
trunk/src/site/resources/images/jwebunit-architecture.odg
trunk/src/site/resources/images/jwebunit-architecture.png
trunk/src/site/site.xml
trunk/src/site/xdoc/building-maven.xml
trunk/src/site/xdoc/index.xml
Added Paths:
-----------
trunk/src/site/xdoc/how-to-contribute.xml
Modified: trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java
===================================================================
--- trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java 2008-10-06 13:30:06 UTC (rev 738)
+++ trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java 2008-10-07 16:28:07 UTC (rev 739)
@@ -838,7 +838,7 @@
// If Path==null, cookie is not send to the server.
wc.getCookieManager().addCookie(
new Cookie(c.getDomain() != null ? c.getDomain() : "", c
- .getName(), c.getValue(), c.getPath() != null ? c
+ .getName(), c.getValue(), c.getPath() != null ? c
.getPath() : "", c.getMaxAge(), c.getSecure()));
}
// Deal with custom request header
Modified: trunk/jwebunit-htmlunit-plugin/src/site/xdoc/index.xml
===================================================================
--- trunk/jwebunit-htmlunit-plugin/src/site/xdoc/index.xml 2008-10-06 13:30:06 UTC (rev 738)
+++ trunk/jwebunit-htmlunit-plugin/src/site/xdoc/index.xml 2008-10-07 16:28:07 UTC (rev 739)
@@ -90,7 +90,7 @@
<dependency>
<groupId>net.sourceforge.jwebunit</groupId>
<artifactId>jwebunit-htmlunit-plugin</artifactId>
- <version>1.4</version>
+ <version>2.0</version>
</dependency>
...
</dependencies>
Modified: trunk/jwebunit-selenium-plugin/src/site/xdoc/index.xml
===================================================================
--- trunk/jwebunit-selenium-plugin/src/site/xdoc/index.xml 2008-10-06 13:30:06 UTC (rev 738)
+++ trunk/jwebunit-selenium-plugin/src/site/xdoc/index.xml 2008-10-07 16:28:07 UTC (rev 739)
@@ -1,84 +1,22 @@
<?xml version="1.0"?>
<document>
<properties>
- <author email="dashorst.at.users.sourceforge.net">Martijn Dashorst</author>
+ <author email="henryju.at.users.sourceforge.net">Julien HENRY</author>
<title>JWebUnit</title>
</properties>
- <meta name="keyword" content="jwebunit, java, junit, htmlunit, jacobie, httpunit, integration, test, automated, html, webtest"/>
+ <meta name="keyword" content="jwebunit, java, junit, htmlunit, jacobie, httpunit, integration, test, automated, html, webtest, selenium"/>
<head>
<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
</head>
<body>
-<section name="HtmlUnit plugin">
+<section name="Selenium plugin">
<p>
- The following sample testcases illustrate the conciseness of JWebUnit versus HtmlUnit
- and JUnit alone. The tests perform a google search
- for the HtmlUnit home page, navigate to that page from Google, and validate that
- there is a link to the user manual on the HtmlUnit home page. The code in the
- first column is pure HtmlUnit / JUnit, while the second column uses the JWebUnit framework.
+ The Selenium plugin allow to run your test in a real browser. The main advantage is the JavaScript support is perfectly identical to
+ your target browser (of course). The main drawbacks are it is slooooooow and can't run on a headless server.
</p>
<p>
-<table cellspacing="2" border="0">
-<tr><th>JUnit/HtmlUnit Test</th><th>JWebUnit Test</th></tr>
-<tr>
-<td valign="top" nowrap="nowrap">
-<source>
-import java.net.URL;
-
-import com.gargoylesoftware.htmlunit.WebClient;
-import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
-import com.gargoylesoftware.htmlunit.html.HtmlForm;
-import com.gargoylesoftware.htmlunit.html.HtmlPage;
-import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
-import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
-
-import junit.framework.TestCase;
-
-public class SearchExample extends TestCase {
-
- public void testSearch() throws Exception {
- final WebClient webClient = new WebClient();
- final URL url = new URL("http://www.google.com");
- final HtmlPage page = (HtmlPage)webClient.getPage(url);
- HtmlForm form = (HtmlForm) page.getForms().get(0);
- HtmlTextInput text = (HtmlTextInput) form.getInputByName("q");
- text.setValueAttribute("HtmlUnit");
- HtmlSubmitInput btn = (HtmlSubmitInput) form.getInputByName("btnG");
- HtmlPage page2 = (HtmlPage) btn.click();
- HtmlAnchor link = page2.getAnchorByHref("http://htmlunit.sourceforge.net/");
- HtmlPage page3 = (HtmlPage) link.click();
- assertEquals(page3.getTitleText(), "htmlunit - Welcome to HtmlUnit");
- assertNotNull(page3.getAnchorByHref("gettingStarted.html"));
- }
-}
-</source>
-</td>
-<td valign="top" nowrap="nowrap">
-<source>
-import net.sourceforge.jwebunit.util.TestingEngineRegistry;
-import net.sourceforge.jwebunit.junit.WebTestCase;
-
-public class SearchExample extends WebTestCase {
-
- public void setUp() {
- setTestingEngineKey(TestingEngineRegistry.TESTING_ENGINE_HTMLUNIT);
- getTestContext().setBaseUrl("http://www.google.com");
- }
-
- public void testSearch() throws Exception {
- beginAt("/");
- setTextField("q", "htmlunit");
- submit("btnG");
- clickLinkWithText("HtmlUnit");
- assertTitleEquals("htmlunit - Welcome to HtmlUnit");
- assertLinkPresentWithText("Get started");
- }
-}
-</source>
-</td>
-</tr>
-</table>
-</p>
+ This plugin is still in development. In fact not all test cases works. Feel free to <a href="../how-to-contribute.html">contribute</a>
+ </p>
</section>
<section name="HowTo manage dependencies with Maven 2">
<p>
@@ -89,8 +27,8 @@
...
<dependency>
<groupId>net.sourceforge.jwebunit</groupId>
- <artifactId>jwebunit-htmlunit-plugin</artifactId>
- <version>1.4</version>
+ <artifactId>jwebunit-selenium-plugin</artifactId>
+ <version>2.0</version>
</dependency>
...
</dependencies>
Modified: trunk/src/site/fml/faq.fml
===================================================================
--- trunk/src/site/fml/faq.fml 2008-10-06 13:30:06 UTC (rev 738)
+++ trunk/src/site/fml/faq.fml 2008-10-07 16:28:07 UTC (rev 739)
@@ -31,6 +31,7 @@
setScriptingEnabled(true);
...
}</source>
+Have a look at http://htmlunit.sourceforge.net/submittingJSBugs.html
</answer>
</faq>
</part>
@@ -51,4 +52,4 @@
</faq>
</part>
-</faqs>
\ No newline at end of file
+</faqs>
Modified: trunk/src/site/site.xml
===================================================================
--- trunk/src/site/site.xml 2008-10-06 13:30:06 UTC (rev 738)
+++ trunk/src/site/site.xml 2008-10-07 16:28:07 UTC (rev 739)
@@ -71,6 +71,9 @@
href="#Building JWebUnit Web site and reports" />
</item>
+ <item name="How-To contribute"
+ href="/how-to-contribute.html" collapse="true">
+ </item>
</menu>
<menu name="Sourceforge">
<item name="Project page"
Modified: trunk/src/site/xdoc/building-maven.xml
===================================================================
--- trunk/src/site/xdoc/building-maven.xml 2008-10-06 13:30:06 UTC (rev 738)
+++ trunk/src/site/xdoc/building-maven.xml 2008-10-07 16:28:07 UTC (rev 739)
@@ -39,7 +39,7 @@
<li>
add an environment variable MAVEN_HOME which
points to the install directory of Maven,
- i.e. /opt/apache-maven-2.0.8
+ i.e. /opt/apache-maven-2.0.9
</li>
<li>
add
Added: trunk/src/site/xdoc/how-to-contribute.xml
===================================================================
--- trunk/src/site/xdoc/how-to-contribute.xml (rev 0)
+++ trunk/src/site/xdoc/how-to-contribute.xml 2008-10-07 16:28:07 UTC (rev 739)
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<document>
+ <properties>
+ <author>Julien Henry</author>
+ <title>How-To contribute to JWebUnit</title>
+ </properties>
+ <body class="default">
+ <section name="How-To contribute to JWebUnit">
+ <p>
+ JWebUnit is an open-source project and is looking for contributors. Please read the following sections if you plan to help.
+ </p>
+ <subsection name="What needs to be done?">
+ <p>
+ Here are some ideas:
+ <ul>
+ <li>
+ Improve Selenium plugin (should ideally pass 100% unit tests). May need some modifications of the API.
+ </li>
+ <li>
+ Improve Web 2.0 support (AJAX, drag&drop, focus, mouse clicks, keypress, ...). Will need additions/modifications of the API.
+ </li>
+ <li>
+ Take advantage of Java 5 (migrate to JUnit 4, use generics, ...)
+ </li>
+ <li>
+ Create a record tool like SeleniumIDE or WebTestRecorder.
+ </li>
+ </ul>
+ Of course these are simple suggestions and you can propose many different things.
+ </p>
+ </subsection>
+ <subsection name="OK, I want to help. How to start with?">
+ <p>
+ First, you need to do your homeworks. Checkout latest code from trunk then try to <a href="building-maven.html">build JWebUnit with Maven</a>.
+ </p>
+ <p>
+ Please subscribe to the developper mailing-list and tell me what feature you are working on.
+ </p>
+ <p>
+ I will review your first contribution and if it doesn't break anything you will certainly be granted with commit rights (you need a sourceforge account for that).
+ </p>
+ </subsection>
+ </section>
+ </body>
+</document>
Modified: trunk/src/site/xdoc/index.xml
===================================================================
--- trunk/src/site/xdoc/index.xml 2008-10-06 13:30:06 UTC (rev 738)
+++ trunk/src/site/xdoc/index.xml 2008-10-07 16:28:07 UTC (rev 739)
@@ -2,7 +2,7 @@
<document>
<properties>
<author email="dashorst.at.users.sourceforge.net">Martijn Dashorst</author>
- <title>JWebUnit 1.x</title>
+ <title>JWebUnit</title>
</properties>
<meta name="keyword" content="jwebunit, java, junit, htmlunit, jacobie, httpunit, integration, test, automated, html, webtest"/>
<head>
@@ -11,10 +11,16 @@
<body>
<section name="Welcome">
<p>
- You are on the JWebUnit 1.x website. Current version is 1.5. This is
- the "stable" version of JWebUnit. You can also consult <a href="2.x/index.html">JWebUnit 2.x website</a>.
+ You are on the JWebUnit website. Current version is 2.0. This is
+ the "stable" version of JWebUnit. This version requires Java 1.5.
</p>
</section>
+<section name="Please help JWebUnit !!">
+ <p>
+ JWebUnit is not dead but is looking for contributors. The current maintainer will only be able to do quick fix, a bit of support on the
+ mailing-list and perfom releases. If you want new functionalities feel free to <a href="how-to-contribute.html">contribute</a>.
+ </p>
+</section>
<section name="What is JWebUnit?">
<p>
JWebUnit is a Java framework that facilitates creation of acceptance tests for web applications. It
@@ -27,13 +33,14 @@
</section>
<section name="What does JWebUnit provide?">
<p>
- JWebUnit provides a high-level API for navigating a web application combined with a set
+ JWebUnit provides a high-level Java API for navigating a web application combined with a set
of assertions to verify the application's correctness. This includes navigation
via links, form entry and submission, validation of table contents, and other
typical business web application features. This code try to stay independent of the libraries behind
the scenes. The simple navigation methods and ready-to-use assertions allow for
more rapid test creation than using only JUnit and HtmlUnit. And if you want to switch
- from HtmlUnit to the other soon available plugins, no need to rewrite your tests.
+ from HtmlUnit to the other soon available plugins, no need to rewrite your tests (in the past, the HttpUnit to HtmlUnit migration was done
+ with only minor API changes).
</p>
<img src="images/jwebunit-architecture.png" alt="JWebUnit architecture"/>
</section>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <he...@us...> - 2008-10-27 08:12:22
|
Revision: 740
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=740&view=rev
Author: henryju
Date: 2008-10-27 08:12:20 +0000 (Mon, 27 Oct 2008)
Log Message:
-----------
Prepare for 2.0 release.
Added Paths:
-----------
trunk/README.txt
Removed Paths:
-------------
trunk/README-1.5.txt
Deleted: trunk/README-1.5.txt
===================================================================
--- trunk/README-1.5.txt 2008-10-07 16:28:07 UTC (rev 739)
+++ trunk/README-1.5.txt 2008-10-27 08:12:20 UTC (rev 740)
@@ -1,17 +0,0 @@
-The JWebUnit team is pleased to announce the JWebUnit 1.5 release!
-
-http://jwebunit.sourceforge.net
-
-JWebUnit is a Java framework that facilitates creation of acceptance tests for
-web applications. It evolved from a project where we were using HttpUnit and
-JUnit to create acceptance tests. As the tests were being written, they were
-continuously refactored to remove duplication and other bad smells in the test
-code. JWebUnit is the result of these refactorings.
-We are now using HtmlUnit (htmlunit.sourceforge.net).
-
-Changes in this version are available here:
-http://jwebunit.sourceforge.net/changes-report.html
-
-Have fun!
--The JWebUnit team
-
Copied: trunk/README.txt (from rev 739, trunk/README-1.5.txt)
===================================================================
--- trunk/README.txt (rev 0)
+++ trunk/README.txt 2008-10-27 08:12:20 UTC (rev 740)
@@ -0,0 +1,17 @@
+The JWebUnit team is pleased to announce the JWebUnit 2.0 release!
+
+http://jwebunit.sourceforge.net
+
+JWebUnit is a Java framework that facilitates creation of acceptance tests for
+web applications. It evolved from a project where we were using HttpUnit and
+JUnit to create acceptance tests. As the tests were being written, they were
+continuously refactored to remove duplication and other bad smells in the test
+code. JWebUnit is the result of these refactorings.
+We are now using HtmlUnit (htmlunit.sourceforge.net).
+
+Changes in this version are available here:
+http://jwebunit.sourceforge.net/changes-report.html
+
+Have fun!
+-The JWebUnit team
+
Property changes on: trunk/README.txt
___________________________________________________________________
Added: svn:mergeinfo
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <he...@us...> - 2008-10-27 08:22:29
|
Revision: 743
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=743&view=rev
Author: henryju
Date: 2008-10-27 08:21:29 +0000 (Mon, 27 Oct 2008)
Log Message:
-----------
[maven-release-plugin] prepare for next development iteration
Modified Paths:
--------------
trunk/jwebunit-commons-tests/pom.xml
trunk/jwebunit-core/pom.xml
trunk/jwebunit-htmlunit-plugin/pom.xml
trunk/jwebunit-selenium-plugin/pom.xml
trunk/jwebunit-webtestcase-generator/pom.xml
trunk/pom.xml
Modified: trunk/jwebunit-commons-tests/pom.xml
===================================================================
--- trunk/jwebunit-commons-tests/pom.xml 2008-10-27 08:21:07 UTC (rev 742)
+++ trunk/jwebunit-commons-tests/pom.xml 2008-10-27 08:21:29 UTC (rev 743)
@@ -2,7 +2,7 @@
<parent>
<artifactId>jwebunit</artifactId>
<groupId>net.sourceforge.jwebunit</groupId>
- <version>2.0</version>
+ <version>2.1-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: trunk/jwebunit-core/pom.xml
===================================================================
--- trunk/jwebunit-core/pom.xml 2008-10-27 08:21:07 UTC (rev 742)
+++ trunk/jwebunit-core/pom.xml 2008-10-27 08:21:29 UTC (rev 743)
@@ -2,7 +2,7 @@
<parent>
<artifactId>jwebunit</artifactId>
<groupId>net.sourceforge.jwebunit</groupId>
- <version>2.0</version>
+ <version>2.1-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: trunk/jwebunit-htmlunit-plugin/pom.xml
===================================================================
--- trunk/jwebunit-htmlunit-plugin/pom.xml 2008-10-27 08:21:07 UTC (rev 742)
+++ trunk/jwebunit-htmlunit-plugin/pom.xml 2008-10-27 08:21:29 UTC (rev 743)
@@ -2,7 +2,7 @@
<parent>
<artifactId>jwebunit</artifactId>
<groupId>net.sourceforge.jwebunit</groupId>
- <version>2.0</version>
+ <version>2.1-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: trunk/jwebunit-selenium-plugin/pom.xml
===================================================================
--- trunk/jwebunit-selenium-plugin/pom.xml 2008-10-27 08:21:07 UTC (rev 742)
+++ trunk/jwebunit-selenium-plugin/pom.xml 2008-10-27 08:21:29 UTC (rev 743)
@@ -2,7 +2,7 @@
<parent>
<artifactId>jwebunit</artifactId>
<groupId>net.sourceforge.jwebunit</groupId>
- <version>2.0</version>
+ <version>2.1-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: trunk/jwebunit-webtestcase-generator/pom.xml
===================================================================
--- trunk/jwebunit-webtestcase-generator/pom.xml 2008-10-27 08:21:07 UTC (rev 742)
+++ trunk/jwebunit-webtestcase-generator/pom.xml 2008-10-27 08:21:29 UTC (rev 743)
@@ -2,7 +2,7 @@
<parent>
<artifactId>jwebunit</artifactId>
<groupId>net.sourceforge.jwebunit</groupId>
- <version>2.0</version>
+ <version>2.1-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2008-10-27 08:21:07 UTC (rev 742)
+++ trunk/pom.xml 2008-10-27 08:21:29 UTC (rev 743)
@@ -3,7 +3,7 @@
<groupId>net.sourceforge.jwebunit</groupId>
<artifactId>jwebunit</artifactId>
<name>JWebUnit</name>
- <version>2.0</version>
+ <version>2.1-SNAPSHOT</version>
<packaging>pom</packaging>
<description>
JWebUnit is a Java framework that facilitates creation of
@@ -168,9 +168,9 @@
</license>
</licenses>
<scm>
- <connection>scm:svn:http://jwebunit.svn.sourceforge.net/svnroot/jwebunit/tags/jwebunit-2.0</connection>
- <developerConnection>scm:svn:https://jwebunit.svn.sourceforge.net/svnroot/jwebunit/tags/jwebunit-2.0</developerConnection>
- <url>http://jwebunit.svn.sourceforge.net/viewvc/jwebunit/tags/jwebunit-2.0</url>
+ <connection>scm:svn:http://jwebunit.svn.sourceforge.net/svnroot/jwebunit/trunk</connection>
+ <developerConnection>scm:svn:https://jwebunit.svn.sourceforge.net/svnroot/jwebunit/trunk</developerConnection>
+ <url>http://jwebunit.svn.sourceforge.net/viewvc/jwebunit/trunk</url>
</scm>
<organization>
<name>SourceForge</name>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <he...@us...> - 2008-10-27 09:28:31
|
Revision: 741
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=741&view=rev
Author: henryju
Date: 2008-10-27 08:17:15 +0000 (Mon, 27 Oct 2008)
Log Message:
-----------
[maven-release-plugin] prepare release jwebunit-2.0
Modified Paths:
--------------
trunk/jwebunit-commons-tests/pom.xml
trunk/jwebunit-core/pom.xml
trunk/jwebunit-htmlunit-plugin/pom.xml
trunk/jwebunit-selenium-plugin/pom.xml
trunk/jwebunit-webtestcase-generator/pom.xml
trunk/pom.xml
Modified: trunk/jwebunit-commons-tests/pom.xml
===================================================================
--- trunk/jwebunit-commons-tests/pom.xml 2008-10-27 08:12:20 UTC (rev 740)
+++ trunk/jwebunit-commons-tests/pom.xml 2008-10-27 08:17:15 UTC (rev 741)
@@ -2,7 +2,7 @@
<parent>
<artifactId>jwebunit</artifactId>
<groupId>net.sourceforge.jwebunit</groupId>
- <version>1.6-SNAPSHOT</version>
+ <version>2.0</version>
<relativePath>../</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: trunk/jwebunit-core/pom.xml
===================================================================
--- trunk/jwebunit-core/pom.xml 2008-10-27 08:12:20 UTC (rev 740)
+++ trunk/jwebunit-core/pom.xml 2008-10-27 08:17:15 UTC (rev 741)
@@ -2,7 +2,7 @@
<parent>
<artifactId>jwebunit</artifactId>
<groupId>net.sourceforge.jwebunit</groupId>
- <version>1.6-SNAPSHOT</version>
+ <version>2.0</version>
<relativePath>../</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: trunk/jwebunit-htmlunit-plugin/pom.xml
===================================================================
--- trunk/jwebunit-htmlunit-plugin/pom.xml 2008-10-27 08:12:20 UTC (rev 740)
+++ trunk/jwebunit-htmlunit-plugin/pom.xml 2008-10-27 08:17:15 UTC (rev 741)
@@ -2,7 +2,7 @@
<parent>
<artifactId>jwebunit</artifactId>
<groupId>net.sourceforge.jwebunit</groupId>
- <version>1.6-SNAPSHOT</version>
+ <version>2.0</version>
<relativePath>../</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: trunk/jwebunit-selenium-plugin/pom.xml
===================================================================
--- trunk/jwebunit-selenium-plugin/pom.xml 2008-10-27 08:12:20 UTC (rev 740)
+++ trunk/jwebunit-selenium-plugin/pom.xml 2008-10-27 08:17:15 UTC (rev 741)
@@ -2,7 +2,7 @@
<parent>
<artifactId>jwebunit</artifactId>
<groupId>net.sourceforge.jwebunit</groupId>
- <version>1.6-SNAPSHOT</version>
+ <version>2.0</version>
<relativePath>..</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: trunk/jwebunit-webtestcase-generator/pom.xml
===================================================================
--- trunk/jwebunit-webtestcase-generator/pom.xml 2008-10-27 08:12:20 UTC (rev 740)
+++ trunk/jwebunit-webtestcase-generator/pom.xml 2008-10-27 08:17:15 UTC (rev 741)
@@ -2,7 +2,7 @@
<parent>
<artifactId>jwebunit</artifactId>
<groupId>net.sourceforge.jwebunit</groupId>
- <version>1.6-SNAPSHOT</version>
+ <version>2.0</version>
<relativePath>../</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2008-10-27 08:12:20 UTC (rev 740)
+++ trunk/pom.xml 2008-10-27 08:17:15 UTC (rev 741)
@@ -1,11 +1,9 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.sourceforge.jwebunit</groupId>
<artifactId>jwebunit</artifactId>
<name>JWebUnit</name>
- <version>1.6-SNAPSHOT</version>
+ <version>2.0</version>
<packaging>pom</packaging>
<description>
JWebUnit is a Java framework that facilitates creation of
@@ -170,15 +168,9 @@
</license>
</licenses>
<scm>
- <connection>
- scm:svn:http://jwebunit.svn.sourceforge.net/svnroot/jwebunit/trunk
- </connection>
- <developerConnection>
- scm:svn:https://jwebunit.svn.sourceforge.net/svnroot/jwebunit/trunk
- </developerConnection>
- <url>
- http://jwebunit.svn.sourceforge.net/viewvc/jwebunit/trunk
- </url>
+ <connection>scm:svn:http://jwebunit.svn.sourceforge.net/svnroot/jwebunit/tags/jwebunit-2.0</connection>
+ <developerConnection>scm:svn:https://jwebunit.svn.sourceforge.net/svnroot/jwebunit/tags/jwebunit-2.0</developerConnection>
+ <url>http://jwebunit.svn.sourceforge.net/viewvc/jwebunit/tags/jwebunit-2.0</url>
</scm>
<organization>
<name>SourceForge</name>
@@ -482,4 +474,4 @@
<name>JWebUnit Maven 2 Snapshots Repository</name>
</snapshotRepository>
</distributionManagement>
-</project>
+</project>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <he...@us...> - 2008-10-28 08:08:08
|
Revision: 744
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=744&view=rev
Author: henryju
Date: 2008-10-28 08:08:04 +0000 (Tue, 28 Oct 2008)
Log Message:
-----------
Fixed new Sourceforge URL (web site deploy still doesn't work).
Fixed date of 2.0 release.
Modified Paths:
--------------
trunk/pom.xml
trunk/src/changes/changes.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2008-10-27 08:21:29 UTC (rev 743)
+++ trunk/pom.xml 2008-10-28 08:08:04 UTC (rev 744)
@@ -462,16 +462,16 @@
<repository>
<id>jwebunit-m2-repo</id>
<url>
- scp://shell.sourceforge.net/home/groups/j/jw/jwebunit/htdocs/m2-repo
+ sftp://web.sourceforge.net/home/groups/j/jw/jwebunit/htdocs/m2-repo
</url>
<name>JWebUnit Maven 2 Repository</name>
</repository>
<snapshotRepository>
<id>jwebunit-m2-repo-snapshots</id>
<url>
- scp://shell.sourceforge.net/home/groups/j/jw/jwebunit/htdocs/m2-repo-snapshots
+ sftp://web.sourceforge.net/home/groups/j/jw/jwebunit/htdocs/m2-repo-snapshots
</url>
<name>JWebUnit Maven 2 Snapshots Repository</name>
</snapshotRepository>
</distributionManagement>
-</project>
\ No newline at end of file
+</project>
Modified: trunk/src/changes/changes.xml
===================================================================
--- trunk/src/changes/changes.xml 2008-10-27 08:21:29 UTC (rev 743)
+++ trunk/src/changes/changes.xml 2008-10-28 08:08:04 UTC (rev 744)
@@ -7,7 +7,7 @@
</author>
</properties>
<body>
- <release version="2.0" date="UNKNOW">
+ <release version="2.0" date="october 27, 2008">
<action type="update" dev="henryju">
Updated to HtmlUnit 2.3.
</action>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jev...@us...> - 2008-10-28 13:40:05
|
Revision: 752
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=752&view=rev
Author: jevonwright
Date: 2008-10-28 12:34:23 +0000 (Tue, 28 Oct 2008)
Log Message:
-----------
adding some basic support for retrieving the HTTP status codes
Modified Paths:
--------------
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/ButtonAssertionsTest.java
trunk/jwebunit-commons-tests/src/main/resources/testcases/ButtonAssertionsTest/pageWithOneForm.html
trunk/jwebunit-commons-tests/src/main/resources/testcases/WEB-INF/web.xml
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/api/ITestingEngine.java
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java
trunk/jwebunit-htmlunit-plugin/src/test/java/net/sourceforge/jwebunit/htmlunit/JWebUnitTest.java
trunk/jwebunit-selenium-plugin/src/main/java/net/sourceforge/jwebunit/selenium/SeleniumTestingEngineImpl.java
trunk/jwebunit-selenium-plugin/src/test/java/net/sourceforge/jwebunit/selenium/JWebUnitTest.java
Added Paths:
-----------
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/ResponseServletTest.java
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/ResponseServlet.java
trunk/jwebunit-commons-tests/src/main/resources/testcases/ResponseServletTest/
trunk/jwebunit-commons-tests/src/main/resources/testcases/ResponseServletTest/SimpleForm.html
Modified: trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/ButtonAssertionsTest.java
===================================================================
--- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/ButtonAssertionsTest.java 2008-10-28 10:58:12 UTC (rev 751)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/ButtonAssertionsTest.java 2008-10-28 12:34:23 UTC (rev 752)
@@ -20,6 +20,9 @@
assertButtonPresent("buttonOutside");
assertButtonPresent("button1");
assertButtonPresent("buttonOutside");
+
+ // test for issue 1874971
+ assertButtonPresentWithText("Input button");
}
public void testAssertButtonwithTowFormsfound() {
Added: trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/ResponseServletTest.java
===================================================================
--- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/ResponseServletTest.java (rev 0)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/ResponseServletTest.java 2008-10-28 12:34:23 UTC (rev 752)
@@ -0,0 +1,72 @@
+/******************************************************************************
+ * JWebUnit project (http://jwebunit.sourceforge.net) *
+ * Distributed open-source, see full license under LICENCE.txt *
+ ******************************************************************************/
+package net.sourceforge.jwebunit.tests;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import net.sourceforge.jwebunit.tests.util.JettySetup;
+
+/**
+ * Test redirection support.
+ *
+ * @author Julien Henry
+ */
+public class ResponseServletTest extends JWebUnitAPITestCase {
+
+ public static Test suite() {
+ Test suite = new TestSuite(ResponseServletTest.class);
+ return new JettySetup(suite);
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+ setIgnoreFailingStatusCodes(true); // ignore failing status codes
+ getTestContext().setBaseUrl(HOST_PATH + "/ResponseServletTest");
+ }
+
+ /*
+ * currently we can't get the response code from HtmlUnit unless it is a failing code
+ *
+ public void testDefault() {
+ beginAt("/SimpleForm.html");
+ submit();
+ assertResponseCodeBetween(200, 299);
+ }
+
+ public void testResponse200() {
+ beginAt("/SimpleForm.html");
+ setTextField("status", "200");
+ submit();
+ assertResponseCode(200);
+ }
+ */
+
+ /*
+ * HtmlUnit cannot handle a 301 without a valid Location: header
+ public void testResponse301() {
+ beginAt("/SimpleForm.html");
+ setTextField("status", "301");
+ submit();
+ assertResponseCode(301);
+ }
+ */
+
+ public void testResponse404() {
+ beginAt("/SimpleForm.html");
+ assertTitleEquals("response form");
+ setTextField("status", "404");
+ submit();
+ assertResponseCode(404);
+ }
+
+ public void testResponse501() {
+ beginAt("/SimpleForm.html");
+ assertTitleEquals("response form");
+ setTextField("status", "501");
+ submit();
+ assertResponseCode(501);
+ }
+
+}
Added: trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/ResponseServlet.java
===================================================================
--- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/ResponseServlet.java (rev 0)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/ResponseServlet.java 2008-10-28 12:34:23 UTC (rev 752)
@@ -0,0 +1,39 @@
+/******************************************************************************
+ * JWebUnit project (http://jwebunit.sourceforge.net) *
+ * Distributed open-source, see full license under LICENCE.txt *
+ ******************************************************************************/
+package net.sourceforge.jwebunit.tests.util;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * A simple servlet that allows us to test for HTTP response codes.
+ *
+ * @author Jevon
+ *
+ */
+public class ResponseServlet extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+
+ protected void doGet(HttpServletRequest request,
+ HttpServletResponse response) throws ServletException, IOException {
+
+ // set the status?
+ if (request.getParameter("status") != null && request.getParameter("status").length() > 0) {
+ response.setStatus( new Integer(request.getParameter("status")) );
+ }
+
+ // set the content type?
+ if (request.getParameter("content-type") != null && request.getParameter("content-type").length() > 0) {
+ response.setContentType( request.getParameter("content-type") );
+ }
+
+ }
+
+}
Modified: trunk/jwebunit-commons-tests/src/main/resources/testcases/ButtonAssertionsTest/pageWithOneForm.html
===================================================================
--- trunk/jwebunit-commons-tests/src/main/resources/testcases/ButtonAssertionsTest/pageWithOneForm.html 2008-10-28 10:58:12 UTC (rev 751)
+++ trunk/jwebunit-commons-tests/src/main/resources/testcases/ButtonAssertionsTest/pageWithOneForm.html 2008-10-28 12:34:23 UTC (rev 752)
@@ -8,5 +8,6 @@
<button id="button1">Testbutton</button>
</form>
<button id="buttonOutside">Outside</button>
+<input type="button" value="Input button" />
</body>
</html>
Added: trunk/jwebunit-commons-tests/src/main/resources/testcases/ResponseServletTest/SimpleForm.html
===================================================================
--- trunk/jwebunit-commons-tests/src/main/resources/testcases/ResponseServletTest/SimpleForm.html (rev 0)
+++ trunk/jwebunit-commons-tests/src/main/resources/testcases/ResponseServletTest/SimpleForm.html 2008-10-28 12:34:23 UTC (rev 752)
@@ -0,0 +1,14 @@
+<html>
+<head>
+ <title>response form</title>
+</head>
+<body>
+ <form method="get" action="../response.jsp">
+ <ol>
+ <li>Desired status: <input type="text" name="status" value="" /></li>
+ <li>Desired content-type: <input type="text" name="content-type" value="" /></li>
+ <li><input type="submit" /></li>
+ </ol>
+ </form>
+</body>
+</html>
\ No newline at end of file
Modified: trunk/jwebunit-commons-tests/src/main/resources/testcases/WEB-INF/web.xml
===================================================================
--- trunk/jwebunit-commons-tests/src/main/resources/testcases/WEB-INF/web.xml 2008-10-28 10:58:12 UTC (rev 751)
+++ trunk/jwebunit-commons-tests/src/main/resources/testcases/WEB-INF/web.xml 2008-10-28 12:34:23 UTC (rev 752)
@@ -16,6 +16,10 @@
<servlet-name>RedirectServlet</servlet-name>
<servlet-class>net.sourceforge.jwebunit.tests.util.RedirectServlet</servlet-class>
</servlet>
+<servlet>
+ <servlet-name>ResponseServlet</servlet-name>
+ <servlet-class>net.sourceforge.jwebunit.tests.util.ResponseServlet</servlet-class>
+</servlet>
<servlet-mapping>
<servlet-name>ParamsServlet</servlet-name>
<url-pattern>/params.jsp</url-pattern>
@@ -28,6 +32,10 @@
<servlet-name>RedirectServlet</servlet-name>
<url-pattern>/redirect.jsp</url-pattern>
</servlet-mapping>
+<servlet-mapping>
+ <servlet-name>ResponseServlet</servlet-name>
+ <url-pattern>/response.jsp</url-pattern>
+</servlet-mapping>
<!--security-constraint>
<web-resource-collection>
Modified: trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/api/ITestingEngine.java
===================================================================
--- trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/api/ITestingEngine.java 2008-10-28 10:58:12 UTC (rev 751)
+++ trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/api/ITestingEngine.java 2008-10-28 12:34:23 UTC (rev 752)
@@ -869,5 +869,20 @@
* @return List of all elements found
*/
List<IElement> getElementsByXPath(String xpath);
+
+ /**
+ * Get the request response code.
+ *
+ * @return The request response code.
+ */
+ int getServerResponseCode();
+ /**
+ * Should the tester ignore failing status codes (300+)? Otherwise,
+ * failing status codes will throw an exception.
+ *
+ * @param ignore
+ */
+ public void setIgnoreFailingStatusCodes(boolean ignore);
+
}
Modified: trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java
===================================================================
--- trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java 2008-10-28 10:58:12 UTC (rev 751)
+++ trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java 2008-10-28 12:34:23 UTC (rev 752)
@@ -251,8 +251,38 @@
}
// Assertions
+
+ /**
+ * Assert that the page response has a particular code.
+ *
+ * @param status the expected status code
+ */
+ public void assertResponseCode(int status) {
+ Assert.assertEquals( getTestingEngine().getServerResponseCode(), status );
+ }
/**
+ * Assert that the page response has a particular code between lower and higher
+ * (<code>lower <= status <= higher</code>).
+ *
+ * @param lower the lower bound for the expected status code
+ * @param higher the upper bound for the expected status code
+ */
+ public void assertResponseCodeBetween(int lower, int higher) {
+ Assert.assertTrue( getTestingEngine().getServerResponseCode() >= lower && getTestingEngine().getServerResponseCode() <= higher );
+ }
+
+ /**
+ * Should the tester ignore failing status codes (300+)? Otherwise,
+ * failing status codes will throw an exception.
+ *
+ * @param ignore
+ */
+ public void setIgnoreFailingStatusCodes(boolean ignore) {
+ getTestingEngine().setIgnoreFailingStatusCodes(ignore);
+ }
+
+ /**
* Assert title of current html page in conversation matches an expected
* value.
*
@@ -2407,6 +2437,13 @@
assertElementPresentByXPath(xpath);
return getTestingEngine().getElementAttributByXPath(xpath, attribute);
}
+
+ /**
+ * @deprecated Use {@link #getElementAttributeByXPath(String, String)}
+ */
+ public String getElementAttributByXPath(String xpath, String attribute) {
+ return getElementAttributeByXPath(xpath, attribute);
+ }
/**
* Get text of the given element.
@@ -2546,9 +2583,17 @@
*
* @return HTTP server response.
*/
- public String getServeurResponse() {
+ public String getServerResponse() {
return getTestingEngine().getServerResponse();
}
+
+ /**
+ * @deprecated use {@link #getServerResponse()}
+ * @return
+ */
+ public String getServeurResponse() {
+ return getServerResponse();
+ }
/**
* Save the last downloaded page (or file) to the disk.
Modified: trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java
===================================================================
--- trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java 2008-10-28 10:58:12 UTC (rev 751)
+++ trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java 2008-10-28 12:34:23 UTC (rev 752)
@@ -143,6 +143,16 @@
*/
private LinkedList<JavascriptPrompt> expectedJavascriptPrompts = new LinkedList<JavascriptPrompt>();
+ /**
+ * The last web response status code, if HtmlUnit threw a FailingHttpStatusCodeException.
+ */
+ private int lastWebResponse = 0;
+
+ /**
+ * Should we ignore failing status codes?
+ */
+ private boolean ignoreFailingStatusCodes = false;
+
// Implementation of IJWebUnitDialog
/**
@@ -156,17 +166,7 @@
throws TestingEngineResponseException {
this.setTestContext(context);
initWebClient();
- try {
- wc.getPage(initialURL);
- win = wc.getCurrentWindow();
- form = null;
- } catch (FailingHttpStatusCodeException aException) {
- throw new TestingEngineResponseException(
- aException.getStatusCode(), aException);
-
- } catch (IOException aException) {
- throw new RuntimeException(aException);
- }
+ gotoPage(initialURL);
}
public void closeBrowser() throws ExpectedJavascriptAlertException,
@@ -191,15 +191,27 @@
}
+ /**
+ * Go to a particular page.
+ *
+ * @throws TestingEngineResponseException if an error response code is encountered and ignoreFailingStatusCodes is not enabled.
+ */
public void gotoPage(URL initialURL) throws TestingEngineResponseException {
try {
wc.getPage(initialURL);
win = wc.getCurrentWindow();
form = null;
- } catch (FailingHttpStatusCodeException aException) {
- throw new TestingEngineResponseException(aException.getStatusCode());
- } catch (IOException aException) {
- throw new RuntimeException(aException);
+ } catch (FailingHttpStatusCodeException ex) {
+ // save this web response
+ lastWebResponse = ex.getStatusCode();
+
+ // only throw exception if necessary
+ if (!ignoreFailingStatusCodes) {
+ throw new TestingEngineResponseException(
+ ex.getStatusCode(), ex);
+ }
+ } catch (IOException ex) {
+ throw new RuntimeException(ex);
}
}
@@ -376,8 +388,17 @@
HtmlElement outside_element = getHtmlElementWithAttribute("name", paramName);
if (outside_element != null) {
if (outside_element instanceof HtmlInput) {
+ // set current form if not null
+ if (outside_element.getEnclosingForm() != null)
+ form = outside_element.getEnclosingForm();
return ((HtmlInput) outside_element).getValueAttribute();
}
+ if (outside_element instanceof HtmlTextArea) {
+ // set current form if not null
+ if (outside_element.getEnclosingForm() != null)
+ form = outside_element.getEnclosingForm();
+ return ((HtmlTextArea) outside_element).getText();
+ }
}
// we can't find it anywhere
@@ -426,66 +447,44 @@
* @param fieldName name of the input element or textarea
* @param text parameter value to submit for the element.
*/
- public void setTextField(String fieldName, String text) {
- List<HtmlElement> textFieldElements = new LinkedList<HtmlElement>();
- if (form != null) {
- textFieldElements.addAll(getForm().getHtmlElementsByAttribute(
- "input", "name", fieldName));
- textFieldElements.addAll(getForm().getTextAreasByName(fieldName));
- } else {
- for (Iterator<HtmlForm> i = getCurrentPage().getForms().iterator(); i
- .hasNext();) {
- HtmlForm f = (HtmlForm) i.next();
- textFieldElements.addAll(f.getHtmlElementsByAttribute("input",
- "name", fieldName));
- textFieldElements.addAll(f.getTextAreasByName(fieldName));
- }
- }
- for (Iterator<HtmlElement> i = textFieldElements.iterator(); i.hasNext();) {
- HtmlElement e = (HtmlElement) i.next();
- if (e instanceof HtmlTextInput) {
- ((HtmlTextInput) e).setValueAttribute(text);
- if (form == null) {
- form = e.getEnclosingFormOrDie();
- }
- return;
- }
- if (e instanceof HtmlPasswordInput) {
- ((HtmlPasswordInput) e).setValueAttribute(text);
- if (form == null) {
- form = e.getEnclosingFormOrDie();
- }
- return;
- }
- if (e instanceof HtmlFileInput) {
- ((HtmlFileInput) e).setValueAttribute(text);
- if (form == null) {
- form = e.getEnclosingFormOrDie();
- }
- return;
- }
- if (e instanceof HtmlTextArea) {
- ((HtmlTextArea) e).setText(text);
- if (form == null) {
- form = e.getEnclosingFormOrDie();
- }
- return;
- }
- }
+ public void setTextField(String paramName, String text) {
+ // first try the current form
+ if (form != null) {
+ for (HtmlElement e : form.getAllHtmlChildElements()) {
+ if (e instanceof HtmlInput && e.getAttribute("name").equals(paramName)) {
+ // we found it
+ ((HtmlInput) e).setValueAttribute(text);
+ return;
+ }
+ if (e instanceof HtmlTextArea && e.getAttribute("name").equals(paramName)) {
+ // we found it
+ ((HtmlTextArea) e).setText(text);
+ return;
+ }
+ }
+ }
- // if we get this far, there is no enclosing form,
- // and we need to set the field manually (if it exists)
- // TODO refactor and clean this up in other methods
- HtmlElement outside_element = getHtmlElementWithAttribute("name", fieldName);
+ // not in the current form: try *all* elements
+ HtmlElement outside_element = getHtmlElementWithAttribute("name", paramName);
if (outside_element != null) {
if (outside_element instanceof HtmlInput) {
- ((HtmlInput) outside_element).setValueAttribute(text);
- return;
+ ((HtmlInput) outside_element).setValueAttribute(text);
+ // set current form if not null
+ if (outside_element.getEnclosingForm() != null)
+ form = outside_element.getEnclosingForm();
+ return;
}
+ if (outside_element instanceof HtmlTextArea) {
+ ((HtmlTextArea) outside_element).setText(text);
+ // set current form if not null
+ if (outside_element.getEnclosingForm() != null)
+ form = outside_element.getEnclosingForm();
+ return;
+ }
}
// we can't find it anywhere
- throw new RuntimeException("No text field with name [" + fieldName
+ throw new RuntimeException("No text field with name [" + paramName
+ "] was found.");
}
@@ -1405,7 +1404,7 @@
public void submit() {
try {
Object[] inpt = getForm().getHtmlElementsByTagName("input")
- .toArray();
+ .toArray();
for (int i = 0; i < inpt.length; i++) {
if (inpt[i] instanceof HtmlSubmitInput) {
((HtmlSubmitInput) inpt[i]).click();
@@ -1422,6 +1421,15 @@
return;
}
}
+
+ } catch (FailingHttpStatusCodeException e) {
+ // entirely possible that it can fail here
+ if (!ignoreFailingStatusCodes)
+ throw new TestingEngineResponseException(
+ e.getStatusCode(), e);
+
+ lastWebResponse = e.getStatusCode();
+ return;
} catch (IOException e) {
throw new RuntimeException(
"HtmlUnit Error submitting form using default submit button, "
@@ -1461,6 +1469,14 @@
}
}
}
+ } catch (FailingHttpStatusCodeException e) {
+ // entirely possible that it can fail here
+ if (!ignoreFailingStatusCodes)
+ throw new TestingEngineResponseException(
+ e.getStatusCode(), e);
+
+ lastWebResponse = e.getStatusCode();
+ return;
} catch (IOException e) {
throw new RuntimeException(
"HtmlUnit Error submitting form using default submit button", e);
@@ -1505,6 +1521,14 @@
}
}
}
+ } catch (FailingHttpStatusCodeException e) {
+ // entirely possible that it can fail here
+ if (!ignoreFailingStatusCodes)
+ throw new TestingEngineResponseException(
+ e.getStatusCode(), e);
+
+ lastWebResponse = e.getStatusCode();
+ return;
} catch (IOException e) {
throw new RuntimeException(
"HtmlUnit Error submitting form using submit button with name ["
@@ -2147,4 +2171,25 @@
return children;
}
+ /* (non-Javadoc)
+ * @see net.sourceforge.jwebunit.api.ITestingEngine#getServerResponseCode()
+ */
+ public int getServerResponseCode() {
+ return this.lastWebResponse;
+ }
+
+ /*
+ * @return the ignoreFailingStatusCodes
+ */
+ public boolean isIgnoreFailingStatusCodes() {
+ return ignoreFailingStatusCodes;
+ }
+
+ /*
+ * @param ignoreFailingStatusCodes the ignoreFailingStatusCodes to set
+ */
+ public void setIgnoreFailingStatusCodes(boolean ignore) {
+ this.ignoreFailingStatusCodes = ignore;
+ }
+
}
Modified: trunk/jwebunit-htmlunit-plugin/src/test/java/net/sourceforge/jwebunit/htmlunit/JWebUnitTest.java
===================================================================
--- trunk/jwebunit-htmlunit-plugin/src/test/java/net/sourceforge/jwebunit/htmlunit/JWebUnitTest.java 2008-10-28 10:58:12 UTC (rev 751)
+++ trunk/jwebunit-htmlunit-plugin/src/test/java/net/sourceforge/jwebunit/htmlunit/JWebUnitTest.java 2008-10-28 12:34:23 UTC (rev 752)
@@ -53,6 +53,7 @@
suite.addTestSuite(ResourceBundleAssertionsTest.class);
suite.addTestSuite(SelectOptionsTest.class);
suite.addTestSuite(IElementTest.class);
+ suite.addTestSuite(ResponseServletTest.class);
suite.addTest(JUnitPerfTest.suite());
// $JUnit-END$
return new JettySetup(suite);
Modified: trunk/jwebunit-selenium-plugin/src/main/java/net/sourceforge/jwebunit/selenium/SeleniumTestingEngineImpl.java
===================================================================
--- trunk/jwebunit-selenium-plugin/src/main/java/net/sourceforge/jwebunit/selenium/SeleniumTestingEngineImpl.java 2008-10-28 10:58:12 UTC (rev 751)
+++ trunk/jwebunit-selenium-plugin/src/main/java/net/sourceforge/jwebunit/selenium/SeleniumTestingEngineImpl.java 2008-10-28 12:34:23 UTC (rev 752)
@@ -682,8 +682,17 @@
* @see net.sourceforge.jwebunit.api.ITestingEngine#getElementsByXPath(java.lang.String)
*/
public List<IElement> getElementsByXPath(String xpath) {
- // TODO Auto-generated method stub
+ // TODO implement method
throw new UnsupportedOperationException("getElementsByXPath");
}
+ /* (non-Javadoc)
+ * @see net.sourceforge.jwebunit.api.ITestingEngine#getServerResponseCode()
+ */
+ public int getServerResponseCode() {
+ // TODO implement method
+ // I'm not even sure if Selenium can get this response code out.
+ throw new UnsupportedOperationException("getServerResponseCode");
+ }
+
}
Modified: trunk/jwebunit-selenium-plugin/src/test/java/net/sourceforge/jwebunit/selenium/JWebUnitTest.java
===================================================================
--- trunk/jwebunit-selenium-plugin/src/test/java/net/sourceforge/jwebunit/selenium/JWebUnitTest.java 2008-10-28 10:58:12 UTC (rev 751)
+++ trunk/jwebunit-selenium-plugin/src/test/java/net/sourceforge/jwebunit/selenium/JWebUnitTest.java 2008-10-28 12:34:23 UTC (rev 752)
@@ -51,6 +51,7 @@
suite.addTestSuite(ImageTest.class);
suite.addTestSuite(ResourceBundleAssertionsTest.class);
suite.addTestSuite(IElementTest.class);
+ suite.addTestSuite(ResponseServletTest.class);
//suite.addTest(JUnitPerfTest.suite());
// $JUnit-END$
return new JettySetup(suite);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jev...@us...> - 2008-10-28 23:50:19
|
Revision: 753
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=753&view=rev
Author: jevonwright
Date: 2008-10-28 23:50:09 +0000 (Tue, 28 Oct 2008)
Log Message:
-----------
added assertHeader*() and assertResponseCode*() methods
cleaning up HtmlUnitTestingEngineImpl and adding more documentation
Modified Paths:
--------------
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/ResponseServletTest.java
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/ResponseServlet.java
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/api/ITestingEngine.java
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java
trunk/jwebunit-selenium-plugin/src/main/java/net/sourceforge/jwebunit/selenium/SeleniumTestingEngineImpl.java
trunk/jwebunit-webtestcase-generator/src/main/javacc/Java1.5.jj
trunk/src/changes/changes.xml
Modified: trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/ResponseServletTest.java
===================================================================
--- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/ResponseServletTest.java 2008-10-28 12:34:23 UTC (rev 752)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/ResponseServletTest.java 2008-10-28 23:50:09 UTC (rev 753)
@@ -28,11 +28,17 @@
/*
* currently we can't get the response code from HtmlUnit unless it is a failing code
- *
+ */
public void testDefault() {
beginAt("/SimpleForm.html");
submit();
assertResponseCodeBetween(200, 299);
+
+ // test the headers
+ assertHeaderPresent("Test");
+ assertHeaderNotPresent("Not-present");
+ assertHeaderEquals("Test", "test2");
+ assertHeaderMatches("Header-Added", "[0-9]{2}");
}
public void testResponse200() {
@@ -41,7 +47,6 @@
submit();
assertResponseCode(200);
}
- */
/*
* HtmlUnit cannot handle a 301 without a valid Location: header
@@ -51,7 +56,7 @@
submit();
assertResponseCode(301);
}
- */
+ */
public void testResponse404() {
beginAt("/SimpleForm.html");
Modified: trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/ResponseServlet.java
===================================================================
--- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/ResponseServlet.java 2008-10-28 12:34:23 UTC (rev 752)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/ResponseServlet.java 2008-10-28 23:50:09 UTC (rev 753)
@@ -32,7 +32,11 @@
// set the content type?
if (request.getParameter("content-type") != null && request.getParameter("content-type").length() > 0) {
response.setContentType( request.getParameter("content-type") );
- }
+ }
+
+ // lets set some headers
+ response.setHeader("Test", "test2");
+ response.setHeader("Header-Added", new java.util.Date().toString());
}
Modified: trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/api/ITestingEngine.java
===================================================================
--- trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/api/ITestingEngine.java 2008-10-28 12:34:23 UTC (rev 752)
+++ trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/api/ITestingEngine.java 2008-10-28 23:50:09 UTC (rev 753)
@@ -878,6 +878,21 @@
int getServerResponseCode();
/**
+ * Get a particular header or null.
+ *
+ * @param name The header name
+ * @return The first header value or null
+ */
+ String getHeader(String name);
+
+ /**
+ * Get all headers.
+ *
+ * @return The header values stored in a map.
+ */
+ java.util.Map<String,String> getAllHeaders();
+
+ /**
* Should the tester ignore failing status codes (300+)? Otherwise,
* failing status codes will throw an exception.
*
Modified: trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java
===================================================================
--- trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java 2008-10-28 12:34:23 UTC (rev 752)
+++ trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java 2008-10-28 23:50:09 UTC (rev 753)
@@ -17,6 +17,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
+import java.util.Map;
import java.util.ResourceBundle;
import javax.imageio.ImageIO;
@@ -281,6 +282,70 @@
public void setIgnoreFailingStatusCodes(boolean ignore) {
getTestingEngine().setIgnoreFailingStatusCodes(ignore);
}
+
+ /**
+ * Assert a header is present.
+ *
+ * @param name The header to find
+ */
+ public void assertHeaderPresent(String name) {
+ Assert.assertFalse( "header '" + name + "' not present", getTestingEngine().getHeader(name) == null );
+ }
+
+ /**
+ * Assert a header is NOT present.
+ *
+ * @param name The header to find
+ */
+ public void assertHeaderNotPresent(String name) {
+ Assert.assertTrue( "header '" + name + "' present", getTestingEngine().getHeader(name) == null );
+ }
+
+ /**
+ * Assert a header is equal to a particular value.
+ *
+ * @param name Header to find
+ * @param value Value to compare against
+ */
+ public void assertHeaderEquals(String name, String value) {
+ Assert.assertEquals( value, getTestingEngine().getHeader(name) );
+ }
+
+ /**
+ * Assert a header matches a particular pattern.
+ *
+ * @param name Header to find
+ * @param regexp Pattern to compare against
+ */
+ public void assertHeaderMatches(String name, String regexp) {
+ RE re = null;
+ try {
+ re = new RE(regexp, RE.MATCH_SINGLELINE);
+ } catch (RESyntaxException e) {
+ Assert.fail(e.toString());
+ }
+ Assert.assertTrue("Unable to match [" + regexp + "] in header [" + name + "]",
+ re.match( getTestingEngine().getHeader(name) ));
+ }
+
+ /**
+ * Get a particular header value.
+ *
+ * @param name Header to find
+ * @return The found header value, or null
+ */
+ public String getHeader(String name) {
+ return getTestingEngine().getHeader(name);
+ }
+
+ /**
+ * Get all response headers.
+ *
+ * @return A map of response headers
+ */
+ public Map<String, String> getAllHeaders() {
+ return getTestingEngine().getAllHeaders();
+ }
/**
* Assert title of current html page in conversation matches an expected
Modified: trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java
===================================================================
--- trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java 2008-10-28 12:34:23 UTC (rev 752)
+++ trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java 2008-10-28 23:50:09 UTC (rev 753)
@@ -142,11 +142,6 @@
* Javascript prompts.
*/
private LinkedList<JavascriptPrompt> expectedJavascriptPrompts = new LinkedList<JavascriptPrompt>();
-
- /**
- * The last web response status code, if HtmlUnit threw a FailingHttpStatusCodeException.
- */
- private int lastWebResponse = 0;
/**
* Should we ignore failing status codes?
@@ -169,6 +164,10 @@
gotoPage(initialURL);
}
+ /**
+ * Close the browser and check that all expected Javascript alerts, confirms and
+ * prompts have been taken care of.
+ */
public void closeBrowser() throws ExpectedJavascriptAlertException,
ExpectedJavascriptConfirmException,
ExpectedJavascriptPromptException {
@@ -194,7 +193,8 @@
/**
* Go to a particular page.
*
- * @throws TestingEngineResponseException if an error response code is encountered and ignoreFailingStatusCodes is not enabled.
+ * @throws TestingEngineResponseException if an error response code is encountered
+ * and ignoreFailingStatusCodes is not enabled.
*/
public void gotoPage(URL initialURL) throws TestingEngineResponseException {
try {
@@ -202,9 +202,6 @@
win = wc.getCurrentWindow();
form = null;
} catch (FailingHttpStatusCodeException ex) {
- // save this web response
- lastWebResponse = ex.getStatusCode();
-
// only throw exception if necessary
if (!ignoreFailingStatusCodes) {
throw new TestingEngineResponseException(
@@ -294,6 +291,9 @@
}
}
+ /**
+ * Close the current window.
+ */
public void closeWindow() {
if (win != null) {
wc.deregisterWebWindow(win);
@@ -414,31 +414,30 @@
* name.
*/
public String getHiddenFieldValue(String paramName) {
- List<HtmlElement> hiddenFieldElements = new LinkedList<HtmlElement>();
- if (form != null) {
- hiddenFieldElements.addAll(getForm().getHtmlElementsByAttribute(
- "input", "type", "hidden"));
- } else {
- for (Iterator<HtmlForm> i = getCurrentPage().getForms().iterator(); i
- .hasNext();) {
- HtmlForm f = (HtmlForm) i.next();
- hiddenFieldElements.addAll(f.getHtmlElementsByAttribute(
- "input", "type", "hidden"));
- }
+ // first try the current form
+ if (form != null) {
+ for (HtmlElement e : form.getAllHtmlChildElements()) {
+ if (e instanceof HtmlHiddenInput && e.getAttribute("name").equals(paramName)) {
+ // we found it
+ return ((HtmlInput) e).getValueAttribute();
+ }
+ }
+ }
+
+ // not in the current form: try *all* elements
+ HtmlElement outside_element = getHtmlElementWithAttribute("name", paramName);
+ if (outside_element != null) {
+ if (outside_element instanceof HtmlHiddenInput) {
+ // set current form if not null
+ if (outside_element.getEnclosingForm() != null)
+ form = outside_element.getEnclosingForm();
+ return ((HtmlHiddenInput) outside_element).getValueAttribute();
+ }
}
- Iterator<HtmlElement> it = hiddenFieldElements.iterator();
- while (it.hasNext()) {
- HtmlHiddenInput hiddenInput = (HtmlHiddenInput) it.next();
- if (paramName.equals(hiddenInput.getNameAttribute())) {
- if (form == null) {
- form = hiddenInput.getEnclosingFormOrDie();
- }
- return hiddenInput.getValueAttribute();
- }
- }
- throw new RuntimeException(
- "getHiddenFieldParameterValue failed, hidden field with name ["
- + paramName + "] does not exist.");
+
+ // we can't find it anywhere
+ throw new RuntimeException("No hidden field with name [" + paramName
+ + "] was found.");
}
/**
@@ -495,26 +494,30 @@
* @param paramValue parameter value to submit for the element.
*/
public void setHiddenField(String fieldName, String text) {
- List<HtmlInput> hiddenFieldElements = new LinkedList<HtmlInput>();
- if (form != null) {
- hiddenFieldElements.addAll(getForm().getInputsByName(fieldName));
- } else {
- for (Iterator<HtmlForm> i = getCurrentPage().getForms().iterator(); i
- .hasNext();) {
- HtmlForm f = (HtmlForm) i.next();
- hiddenFieldElements.addAll(f.getInputsByName(fieldName));
- }
+ // first try the current form
+ if (form != null) {
+ for (HtmlElement e : form.getAllHtmlChildElements()) {
+ if (e instanceof HtmlHiddenInput && e.getAttribute("name").equals(fieldName)) {
+ // we found it
+ ((HtmlHiddenInput) e).setValueAttribute(text);
+ return;
+ }
+ }
+ }
+
+ // not in the current form: try *all* elements
+ HtmlElement outside_element = getHtmlElementWithAttribute("name", fieldName);
+ if (outside_element != null) {
+ if (outside_element instanceof HtmlHiddenInput) {
+ ((HtmlHiddenInput) outside_element).setValueAttribute(text);
+ // set current form if not null
+ if (outside_element.getEnclosingForm() != null)
+ form = outside_element.getEnclosingForm();
+ return;
+ }
}
- for (Iterator<HtmlInput> i = hiddenFieldElements.iterator(); i.hasNext();) {
- HtmlElement e = (HtmlElement) i.next();
- if (e instanceof HtmlHiddenInput) {
- ((HtmlHiddenInput) e).setValueAttribute(text);
- if (form == null) {
- form = e.getEnclosingFormOrDie();
- }
- return;
- }
- }
+
+ // we can't find it anywhere
throw new RuntimeException("No hidden field with name [" + fieldName
+ "] was found.");
}
@@ -1428,7 +1431,6 @@
throw new TestingEngineResponseException(
e.getStatusCode(), e);
- lastWebResponse = e.getStatusCode();
return;
} catch (IOException e) {
throw new RuntimeException(
@@ -1475,7 +1477,6 @@
throw new TestingEngineResponseException(
e.getStatusCode(), e);
- lastWebResponse = e.getStatusCode();
return;
} catch (IOException e) {
throw new RuntimeException(
@@ -1527,7 +1528,6 @@
throw new TestingEngineResponseException(
e.getStatusCode(), e);
- lastWebResponse = e.getStatusCode();
return;
} catch (IOException e) {
throw new RuntimeException(
@@ -2175,8 +2175,15 @@
* @see net.sourceforge.jwebunit.api.ITestingEngine#getServerResponseCode()
*/
public int getServerResponseCode() {
- return this.lastWebResponse;
+ return getWebResponse().getStatusCode();
}
+
+ /**
+ * Get the last WebResponse from HtmlUnit.
+ */
+ public WebResponse getWebResponse() {
+ return wc.getCurrentWindow().getEnclosedPage().getWebResponse();
+ }
/*
* @return the ignoreFailingStatusCodes
@@ -2192,4 +2199,22 @@
this.ignoreFailingStatusCodes = ignore;
}
+ /* (non-Javadoc)
+ * @see net.sourceforge.jwebunit.api.ITestingEngine#getHeader(java.lang.String)
+ */
+ public String getHeader(String name) {
+ return getWebResponse().getResponseHeaderValue(name);
+ }
+
+ /* (non-Javadoc)
+ * @see net.sourceforge.jwebunit.api.ITestingEngine#getAllHeaders()
+ */
+ public Map<String, String> getAllHeaders() {
+ Map<String, String> map = new java.util.HashMap<String, String>();
+ for (NameValuePair header : getWebResponse().getResponseHeaders()) {
+ map.put(header.getName(), header.getValue());
+ }
+ return map;
+ }
+
}
Modified: trunk/jwebunit-selenium-plugin/src/main/java/net/sourceforge/jwebunit/selenium/SeleniumTestingEngineImpl.java
===================================================================
--- trunk/jwebunit-selenium-plugin/src/main/java/net/sourceforge/jwebunit/selenium/SeleniumTestingEngineImpl.java 2008-10-28 12:34:23 UTC (rev 752)
+++ trunk/jwebunit-selenium-plugin/src/main/java/net/sourceforge/jwebunit/selenium/SeleniumTestingEngineImpl.java 2008-10-28 23:50:09 UTC (rev 753)
@@ -9,6 +9,7 @@
import java.net.URL;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
import net.sourceforge.jwebunit.api.IElement;
import net.sourceforge.jwebunit.api.ITestingEngine;
@@ -695,4 +696,28 @@
throw new UnsupportedOperationException("getServerResponseCode");
}
+ /* (non-Javadoc)
+ * @see net.sourceforge.jwebunit.api.ITestingEngine#getAllHeaders()
+ */
+ public Map<String, String> getAllHeaders() {
+ // TODO implement method
+ throw new UnsupportedOperationException("getAllHeaders");
+ }
+
+ /* (non-Javadoc)
+ * @see net.sourceforge.jwebunit.api.ITestingEngine#getHeader(java.lang.String)
+ */
+ public String getHeader(String name) {
+ // TODO implement method
+ throw new UnsupportedOperationException("getHeader");
+ }
+
+ /* (non-Javadoc)
+ * @see net.sourceforge.jwebunit.api.ITestingEngine#setIgnoreFailingStatusCodes(boolean)
+ */
+ public void setIgnoreFailingStatusCodes(boolean ignore) {
+ // TODO implement method
+ throw new UnsupportedOperationException("setIgnoreFailingStatusCodes");
+ }
+
}
Modified: trunk/jwebunit-webtestcase-generator/src/main/javacc/Java1.5.jj
===================================================================
--- trunk/jwebunit-webtestcase-generator/src/main/javacc/Java1.5.jj 2008-10-28 12:34:23 UTC (rev 752)
+++ trunk/jwebunit-webtestcase-generator/src/main/javacc/Java1.5.jj 2008-10-28 23:50:09 UTC (rev 753)
@@ -491,6 +491,7 @@
sb.append("import java.io.File;\n");
sb.append("import java.io.PrintStream;\n");
sb.append("import java.util.List;\n");
+ sb.append("import java.util.Map;\n");
sb.append("import java.net.URL;\n\n");
sb.append("import net.sourceforge.jwebunit.api.IElement;\n");
sb.append("import net.sourceforge.jwebunit.api.ITestingEngine;\n");
Modified: trunk/src/changes/changes.xml
===================================================================
--- trunk/src/changes/changes.xml 2008-10-28 12:34:23 UTC (rev 752)
+++ trunk/src/changes/changes.xml 2008-10-28 23:50:09 UTC (rev 753)
@@ -9,8 +9,11 @@
<body>
<release version="2.1" date="Unknown">
<action type="add" dev="jevonwright">
- Adding new IElement element interface, and methods to directly access elements by XPath.
+ Added new IElement element interface, and methods to directly access elements by XPath.
</action>
+ <action type="add" dev="jevonwright" issue="1744628">
+ Added assertHeader*() and assertResponseCode*() methods
+ </action>
<action type="update" dev="jevonwright">
BC CHANGE: setFormElement(), assertFormElementEquals() methods will no longer assert that a form already exists in the page (as allowed by the HTML standard).
</action>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jev...@us...> - 2008-10-29 00:01:43
|
Revision: 754
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=754&view=rev
Author: jevonwright
Date: 2008-10-29 00:01:40 +0000 (Wed, 29 Oct 2008)
Log Message:
-----------
adding xpath methods to IElement
Modified Paths:
--------------
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/IElementTest.java
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/api/IElement.java
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitElementImpl.java
Modified: trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/IElementTest.java
===================================================================
--- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/IElementTest.java 2008-10-28 23:50:09 UTC (rev 753)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/IElementTest.java 2008-10-29 00:01:40 UTC (rev 754)
@@ -123,4 +123,29 @@
}
+ public void testWithXpath() {
+ IElement element = getElementByXPath("//body");
+ assertNotNull(element);
+ assertEquals("body", element.getName());
+
+ // get first input children
+ IElement input = element.getElement("input");
+ assertNotNull(input);
+ assertEquals("input", input.getName());
+ assertEquals("element_name", input.getAttribute("name"));
+ assertEquals("test3", input.getAttribute("value"));
+
+ // get all input children
+ List<IElement> inputs = element.getElements("input");
+ assertEquals(2, inputs.size()); // there should be two
+ assertEquals("test3", inputs.get(0).getAttribute("value"));
+ assertEquals("Do nothing", inputs.get(1).getAttribute("value"));
+
+ // get parent through xpath
+ IElement parent = element.getElement("..");
+ assertNotNull(parent);
+ assertEquals("html", parent.getName());
+
+ }
+
}
Modified: trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/api/IElement.java
===================================================================
--- trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/api/IElement.java 2008-10-28 23:50:09 UTC (rev 753)
+++ trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/api/IElement.java 2008-10-29 00:01:40 UTC (rev 754)
@@ -51,4 +51,20 @@
*/
public List<IElement> getChildren();
+ /**
+ * Get an element from this element by xpath.
+ *
+ * @param xpath The xpath to serach
+ * @return an IElement if found, or null
+ */
+ public IElement getElement(String xpath);
+
+ /**
+ * Get all elements from this element by xpath.
+ *
+ * @param xpath The xpath to search
+ * @return A list of all matching elements
+ */
+ public List<IElement> getElements(String xpath);
+
}
Modified: trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitElementImpl.java
===================================================================
--- trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitElementImpl.java 2008-10-28 23:50:09 UTC (rev 753)
+++ trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitElementImpl.java 2008-10-29 00:01:40 UTC (rev 754)
@@ -82,4 +82,26 @@
return element.getTextContent();
}
+
+ /* (non-Javadoc)
+ * @see net.sourceforge.jwebunit.api.IElement#getElement(java.lang.String)
+ */
+ public IElement getElement(String xpath) {
+ // if this fails with a ClassCastException, use getElements().get(0) (performance penalty)
+ return new HtmlUnitElementImpl((HtmlElement) element.getFirstByXPath(xpath));
+ }
+
+
+ /* (non-Javadoc)
+ * @see net.sourceforge.jwebunit.api.IElement#getElements(java.lang.String)
+ */
+ public List<IElement> getElements(String xpath) {
+ List<IElement> elements = new ArrayList<IElement>();
+ for (Object o : element.getByXPath(xpath)) {
+ if (o instanceof HtmlElement)
+ elements.add(new HtmlUnitElementImpl((HtmlElement) o));
+ }
+ return elements;
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jev...@us...> - 2008-10-29 00:25:00
|
Revision: 755
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=755&view=rev
Author: jevonwright
Date: 2008-10-29 00:24:52 +0000 (Wed, 29 Oct 2008)
Log Message:
-----------
issue 1728676: add a WebTestCase(WebTester) constructor
Modified Paths:
--------------
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/JWebUnitAPITestCase.java
trunk/jwebunit-htmlunit-plugin/src/test/java/net/sourceforge/jwebunit/htmlunit/JWebUnitTest.java
trunk/jwebunit-selenium-plugin/src/test/java/net/sourceforge/jwebunit/selenium/JWebUnitTest.java
trunk/jwebunit-webtestcase-generator/src/main/javacc/Java1.5.jj
trunk/src/changes/changes.xml
Added Paths:
-----------
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/CustomTesterTest.java
trunk/jwebunit-commons-tests/src/main/resources/testcases/CustomTesterTest/
trunk/jwebunit-commons-tests/src/main/resources/testcases/CustomTesterTest/test.html
Added: trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/CustomTesterTest.java
===================================================================
--- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/CustomTesterTest.java (rev 0)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/CustomTesterTest.java 2008-10-29 00:24:52 UTC (rev 755)
@@ -0,0 +1,58 @@
+/******************************************************************************
+ * JWebUnit project (http://jwebunit.sourceforge.net) *
+ * Distributed open-source, see full license under LICENCE.txt *
+ ******************************************************************************/
+package net.sourceforge.jwebunit.tests;
+
+import net.sourceforge.jwebunit.junit.WebTester;
+import net.sourceforge.jwebunit.tests.util.JettySetup;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Test the new constructor methods for custom web testers
+ *
+ * @author jmwright
+ *
+ */
+public class CustomTesterTest extends JWebUnitAPITestCase {
+
+ /**
+ * A custom tester to allow us to make sure it is called.
+ *
+ * @author jmwright
+ *
+ */
+ static class MyWebTester extends WebTester {
+
+ /**
+ * We extend the normal method to not fail for our special case.
+ *
+ * @see net.sourceforge.jwebunit.junit.WebTester#assertTitleEquals(java.lang.String)
+ */
+ @Override
+ public void assertTitleEquals(String title) {
+ super.assertTitleEquals(title + " [custom]");
+ }
+
+ }
+
+ public CustomTesterTest() {
+ super("CustomTesterTest", new MyWebTester());
+ }
+
+ public static Test suite() {
+ Test suite = new TestSuite(CustomTesterTest.class);
+ return new JettySetup(suite);
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+ getTestContext().setBaseUrl(HOST_PATH + "/CustomTesterTest");
+ }
+
+ public void testCustomTester() throws Throwable {
+ beginAt("/test.html");
+ assertTitleEquals("test"); // this will normally fail for a non-custom class
+ }
+}
Modified: trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/JWebUnitAPITestCase.java
===================================================================
--- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/JWebUnitAPITestCase.java 2008-10-29 00:01:40 UTC (rev 754)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/JWebUnitAPITestCase.java 2008-10-29 00:24:52 UTC (rev 755)
@@ -8,6 +8,7 @@
import junit.framework.AssertionFailedError;
import net.sourceforge.jwebunit.junit.WebTestCase;
+import net.sourceforge.jwebunit.junit.WebTester;
import net.sourceforge.jwebunit.tests.util.reflect.MethodInvoker;
/**
@@ -27,6 +28,10 @@
public static final String HOST_PATH = "http://localhost:" + JETTY_PORT
+ JETTY_URL;
+ public JWebUnitAPITestCase(String name, WebTester custom) {
+ super(name, custom);
+ }
+
/**
* @param name
*/
Added: trunk/jwebunit-commons-tests/src/main/resources/testcases/CustomTesterTest/test.html
===================================================================
--- trunk/jwebunit-commons-tests/src/main/resources/testcases/CustomTesterTest/test.html (rev 0)
+++ trunk/jwebunit-commons-tests/src/main/resources/testcases/CustomTesterTest/test.html 2008-10-29 00:24:52 UTC (rev 755)
@@ -0,0 +1,8 @@
+<html>
+ <head>
+ <title>test [custom]</title>
+ </head>
+ <body>
+ This is a test page.
+ </body>
+</html>
\ No newline at end of file
Modified: trunk/jwebunit-htmlunit-plugin/src/test/java/net/sourceforge/jwebunit/htmlunit/JWebUnitTest.java
===================================================================
--- trunk/jwebunit-htmlunit-plugin/src/test/java/net/sourceforge/jwebunit/htmlunit/JWebUnitTest.java 2008-10-29 00:01:40 UTC (rev 754)
+++ trunk/jwebunit-htmlunit-plugin/src/test/java/net/sourceforge/jwebunit/htmlunit/JWebUnitTest.java 2008-10-29 00:24:52 UTC (rev 755)
@@ -54,6 +54,7 @@
suite.addTestSuite(SelectOptionsTest.class);
suite.addTestSuite(IElementTest.class);
suite.addTestSuite(ResponseServletTest.class);
+ suite.addTestSuite(CustomTesterTest.class);
suite.addTest(JUnitPerfTest.suite());
// $JUnit-END$
return new JettySetup(suite);
Modified: trunk/jwebunit-selenium-plugin/src/test/java/net/sourceforge/jwebunit/selenium/JWebUnitTest.java
===================================================================
--- trunk/jwebunit-selenium-plugin/src/test/java/net/sourceforge/jwebunit/selenium/JWebUnitTest.java 2008-10-29 00:01:40 UTC (rev 754)
+++ trunk/jwebunit-selenium-plugin/src/test/java/net/sourceforge/jwebunit/selenium/JWebUnitTest.java 2008-10-29 00:24:52 UTC (rev 755)
@@ -52,6 +52,7 @@
suite.addTestSuite(ResourceBundleAssertionsTest.class);
suite.addTestSuite(IElementTest.class);
suite.addTestSuite(ResponseServletTest.class);
+ suite.addTestSuite(CustomTesterTest.class);
//suite.addTest(JUnitPerfTest.suite());
// $JUnit-END$
return new JettySetup(suite);
Modified: trunk/jwebunit-webtestcase-generator/src/main/javacc/Java1.5.jj
===================================================================
--- trunk/jwebunit-webtestcase-generator/src/main/javacc/Java1.5.jj 2008-10-29 00:01:40 UTC (rev 754)
+++ trunk/jwebunit-webtestcase-generator/src/main/javacc/Java1.5.jj 2008-10-29 00:24:52 UTC (rev 755)
@@ -676,6 +676,18 @@
{}
{ {sb.append("{\n");
sb.append(" protected WebTester tester = null;\n\n");
+ sb.append(" protected WebTester customTester = null;\n\n");
+ sb.append(" /***\n");
+ sb.append(" * From 2.1 you can provide your own WebTester to run test cases.\n");
+ sb.append(" */\n");
+ sb.append(" public WebTestCase(WebTester customTester) {\n");
+ sb.append(" super();\n");
+ sb.append(" this.customTester = customTester;\n");
+ sb.append(" }\n\n");
+ sb.append(" public WebTestCase(String name, WebTester customTester) {\n");
+ sb.append(" super(name);\n");
+ sb.append(" this.customTester = customTester;\n");
+ sb.append(" }\n\n");
sb.append(" public WebTestCase(String name) {\n");
sb.append(" super(name);\n");
sb.append(" }\n\n");
@@ -704,10 +716,13 @@
sb.append(" */\n");
sb.append(" public void runBare() throws Throwable {\n");
sb.append(" try {\n");
- sb.append(" tester=new WebTester();\n");
+ sb.append(" if (customTester == null)\n");
+ sb.append(" tester = new WebTester();\n");
+ sb.append(" else\n");
+ sb.append(" tester = customTester;\n");
sb.append(" super.runBare();\n");
sb.append(" } finally {\n");
- sb.append(" tester=null;\n");
+ sb.append(" tester = null;\n");
sb.append(" }\n");
sb.append(" }\n\n");}
"{" ( ClassOrInterfaceBodyDeclaration(isInterface, sb) )* "}"
Modified: trunk/src/changes/changes.xml
===================================================================
--- trunk/src/changes/changes.xml 2008-10-29 00:01:40 UTC (rev 754)
+++ trunk/src/changes/changes.xml 2008-10-29 00:24:52 UTC (rev 755)
@@ -14,6 +14,9 @@
<action type="add" dev="jevonwright" issue="1744628">
Added assertHeader*() and assertResponseCode*() methods
</action>
+ <action type="add" dev="jevonwright" issue="1728676">
+ Added WebTestCase(WebTester) constructor
+ </action>
<action type="update" dev="jevonwright">
BC CHANGE: setFormElement(), assertFormElementEquals() methods will no longer assert that a form already exists in the page (as allowed by the HTML standard).
</action>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jev...@us...> - 2008-10-29 02:08:56
|
Revision: 756
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=756&view=rev
Author: jevonwright
Date: 2008-10-29 02:08:52 +0000 (Wed, 29 Oct 2008)
Log Message:
-----------
issue 1519807: added assertLabeledFieldEquals(id, text) and assertLabel*() methods
Modified Paths:
--------------
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormAssertionsTest.java
trunk/jwebunit-commons-tests/src/main/resources/testcases/FormAssertionsTest/testPage.html
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitElementImpl.java
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java
trunk/src/changes/changes.xml
Modified: trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormAssertionsTest.java
===================================================================
--- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormAssertionsTest.java 2008-10-29 00:24:52 UTC (rev 755)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormAssertionsTest.java 2008-10-29 02:08:52 UTC (rev 756)
@@ -257,5 +257,35 @@
assertRadioOptionSelected(option1, "1");
}
+
+ // tests for label elements
+ public void testLabels() {
+ beginAt("/testPage.html");
+
+ assertLabelPresent("label1");
+ assertLabeledFieldEquals("label1", "one");
+ assertLabelPresent("label2");
+ assertLabeledFieldEquals("label2", "two");
+
+ assertLabelPresent("label3");
+ assertLabeledFieldEquals("label3", "three");
+
+ assertLabelPresent("label4");
+ assertLabeledFieldEquals("label4", "2");
+
+ assertLabelPresent("label5");
+ assertLabeledFieldEquals("label5", "2");
+
+ assertLabelPresent("label6");
+ assertLabeledFieldEquals("label6", "ten");
+
+ assertLabelPresent("label7");
+ assertLabeledFieldEquals("label7", "10");
+
+ assertLabelPresent("label8");
+ assertLabeledFieldEquals("label8", "eight");
+
+ }
+
}
Modified: trunk/jwebunit-commons-tests/src/main/resources/testcases/FormAssertionsTest/testPage.html
===================================================================
--- trunk/jwebunit-commons-tests/src/main/resources/testcases/FormAssertionsTest/testPage.html 2008-10-29 00:24:52 UTC (rev 755)
+++ trunk/jwebunit-commons-tests/src/main/resources/testcases/FormAssertionsTest/testPage.html 2008-10-29 02:08:52 UTC (rev 756)
@@ -55,6 +55,50 @@
</form>
</td>
</tr>
+ <tr>
+ <td colspan="3">
+ <h1>Field with labels</h1>
+
+ <label id="label1">
+ Field 1:
+ <input type="text" name="label1_field1" value="one" />
+ </label>
+ <label id="label2">
+ Field 2:
+ <input name="label1_field2" value="two" />
+ </label>
+ <label id="label3">
+ <textarea>three</textarea>
+ </label>
+ <label id="label4">
+ <input type="checkbox" value="1"> Not selected<br />
+ <input type="checkbox" value="2" checked>Selected<br />
+ </label>
+ <label id="label5">
+ <input type="radio" value="1">Not selected<br />
+ <input type="radio" value="2" selected>Selected<br />
+ <input type="text" name="label5_field1" value="Ignore this" />
+ </label>
+ <label id="label6">
+ <select name="seven" id="label6_seven">
+ <option>eight</option>
+ <option>nine</option>
+ <option selected>ten</option>
+ <option>eleven</option>
+ </select>
+ </label>
+ <label id="label7">
+ <select name="eight" id="label7_eight">
+ <option value="8">eight</option>
+ <option value="9">nine</option>
+ <option value="10" selected>ten</option>
+ <option value="11">eleven</option>
+ </select>
+ </label>
+ <label id="label8" for="input8">Label 8</label>
+ <input id="input8" type="text" value="eight" />
+ </td>
+ </tr>
</table>
</body>
</html>
Modified: trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java
===================================================================
--- trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java 2008-10-29 00:24:52 UTC (rev 755)
+++ trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java 2008-10-29 02:08:52 UTC (rev 756)
@@ -2554,7 +2554,141 @@
public List<IElement> getElementsByXPath(String xpath) {
return getTestingEngine().getElementsByXPath(xpath);
}
+
+ // label methods
+ /**
+ * Assert a label for a given ID exists.
+ */
+ public void assertLabelPresent(String id) {
+ // get all labels
+ for (IElement e : getTestingEngine().getElementsByXPath("//label")) {
+ if (e.getName().equals("label") && id.equals(e.getAttribute("id")))
+ return; // label found
+ }
+ Assert.fail("No label found with id [" + id + "]");
+ }
+
+ /**
+ * Find a particular element with given text
+ *
+ * @param elementName the element type e.g. "input", "label"
+ * @param text the text to search for
+ * @return the found element, or null
+ */
+ private IElement getElementWithText(String elementName, String text) {
+ for (IElement e : getTestingEngine().getElementsByXPath("//" + elementName)) {
+ if (elementName.equals(e.getName()) && text.equals(e.getTextContent())) {
+ return e;
+ }
+ }
+ return null;
+ }
+ /**
+ * Assert a label exists.
+ */
+ public void assertLabelMatches(String regexp) {
+ // get regexp
+ RE re = null;
+ try {
+ re = new RE(regexp, RE.MATCH_SINGLELINE);
+ } catch (RESyntaxException e) {
+ Assert.fail(e.toString());
+ }
+
+ // get all labels
+ for (IElement e : getTestingEngine().getElementsByXPath("//label")) {
+ if (e.getName().equals("label") && re.match( e.getTextContent() ))
+ return; // label found
+ }
+ Assert.fail("No label found with text matching [" + regexp + "]");
+ }
+
+ /**
+ * Private method to test the value of a field connected to a particular IElement label.
+ *
+ * @param label
+ * @param fieldText
+ */
+ private void assertLabeledFieldEquals(String identifier, IElement label, String fieldText) {
+ List<IElement> fields = new java.util.ArrayList<IElement>();
+ // a direct "for" attribute
+ if (label.getAttribute("for") != null) {
+ IElement e = getTestingEngine().getElementByID(label.getAttribute("for"));
+ if (e != null)
+ fields.add(e);
+ }
+
+ // implicitly the elements inside the label
+ if (fields.isEmpty()) {
+ // get elements inside the label
+ for (IElement e : label.getChildren()) {
+ if (e.getName().equals("input") || e.getName().equals("textarea") || e.getName().equals("select")) {
+ fields.add(e);
+ }
+ }
+ }
+
+ Assert.assertFalse("No field found for label [" + identifier + "]", fields.isEmpty());
+ String value = null;
+ // cycle through all fields trying to find value
+ for (IElement field : fields) {
+ if (value != null) // stop at first correct value found
+ break;
+ if (field == null)
+ throw new RuntimeException("unexpected null field " + field);
+
+ if ("input".equals(field.getName())) {
+ if (field.getAttribute("type") != null) {
+ if (field.getAttribute("type").toLowerCase().equals("checkbox")) {
+ if (field.getAttribute("checked") != null) {
+ value = field.getAttribute("value");
+ }
+ } else if (field.getAttribute("type").toLowerCase().equals("radio")) {
+ if (field.getAttribute("selected") != null) {
+ value = field.getAttribute("value");
+ }
+ } else {
+ // any other input type
+ value = field.getAttribute("value");
+ }
+ } else {
+ // unspecified input type, default = text
+ value = field.getAttribute("value");
+ }
+ } else if ("textarea".equals(field.getName())) {
+ value = field.getTextContent();
+ } else if ("select".equals(field.getName())) {
+ // get the selected option
+ for (IElement children : field.getChildren()) {
+ if (children.getName().equals("option") && children.getAttribute("selected") != null) {
+ value = children.getAttribute("value") == null ? children.getTextContent() : children.getAttribute("value");
+ break;
+ }
+ }
+ } else {
+ throw new RuntimeException("Unexpected field type " + field.getName());
+ }
+ }
+
+ Assert.assertEquals("value of field for label [" + identifier + "] should be [" + fieldText + "]", fieldText, value);
+ }
+
+ /**
+ * Assert that a labeled field exists (for the given id) and the
+ * field that it labels equals the given text
+ *
+ * @param id
+ * @param fieldText
+ */
+ public void assertLabeledFieldEquals(String id, String fieldText) {
+ IElement label = getTestingEngine().getElementByID(id);
+ Assert.assertNotNull("no label for id [" + id + "] found", label);
+ Assert.assertEquals("element with id [" + id + "] is not a label", "label", label.getName());
+
+ assertLabeledFieldEquals(id, label, fieldText);
+ }
+
// Window and Frame Navigation Methods
/**
Modified: trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitElementImpl.java
===================================================================
--- trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitElementImpl.java 2008-10-29 00:24:52 UTC (rev 755)
+++ trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitElementImpl.java 2008-10-29 02:08:52 UTC (rev 756)
@@ -26,6 +26,8 @@
private HtmlElement element;
public HtmlUnitElementImpl(HtmlElement element) {
+ if (element == null)
+ throw new NullPointerException("Cannot create an IElement for a null element.");
this.element = element;
}
@@ -34,6 +36,9 @@
* @see net.sourceforge.jwebunit.api.IElement#attribute(java.lang.String)
*/
public String getAttribute(String name) {
+ if (!element.hasAttribute(name))
+ return null;
+
return element.getAttribute(name);
}
@@ -51,8 +56,10 @@
*/
public List<IElement> getChildren() {
List<IElement> children = new ArrayList<IElement>();
- for (HtmlElement e : element.getChildElements())
- children.add(new HtmlUnitElementImpl(e));
+ for (HtmlElement e : element.getChildElements()) {
+ if (e != null)
+ children.add(new HtmlUnitElementImpl(e));
+ }
return children;
}
@@ -103,5 +110,9 @@
}
return elements;
}
+
+ public String toString() {
+ return "IElement[name=" + getName() + " wrapped=" + element + "]";
+ }
}
Modified: trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java
===================================================================
--- trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java 2008-10-29 00:24:52 UTC (rev 755)
+++ trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java 2008-10-29 02:08:52 UTC (rev 756)
@@ -2149,14 +2149,20 @@
* @see net.sourceforge.jwebunit.api.ITestingEngine#getElementByXPath(java.lang.String)
*/
public IElement getElementByXPath(String xpath) {
- return new HtmlUnitElementImpl(this.getHtmlElementByXPath(xpath));
+ HtmlElement element = this.getHtmlElementByXPath(xpath);
+ if (element != null)
+ return new HtmlUnitElementImpl(element);
+ return null;
}
/* (non-Javadoc)
* @see net.sourceforge.jwebunit.api.ITestingEngine#getElementByID(java.lang.String)
*/
public IElement getElementByID(String id) {
- return new HtmlUnitElementImpl(this.getHtmlElement(id));
+ HtmlElement element = this.getHtmlElement(id);
+ if (element != null)
+ return new HtmlUnitElementImpl(element);
+ return null;
}
/* (non-Javadoc)
Modified: trunk/src/changes/changes.xml
===================================================================
--- trunk/src/changes/changes.xml 2008-10-29 00:24:52 UTC (rev 755)
+++ trunk/src/changes/changes.xml 2008-10-29 02:08:52 UTC (rev 756)
@@ -17,6 +17,9 @@
<action type="add" dev="jevonwright" issue="1728676">
Added WebTestCase(WebTester) constructor
</action>
+ <action type="add" dev="jevonwright" issue="1519807">
+ Added assertLabeledFieldEquals(id, text) and assertLabel*() methods
+ </action>
<action type="update" dev="jevonwright">
BC CHANGE: setFormElement(), assertFormElementEquals() methods will no longer assert that a form already exists in the page (as allowed by the HTML standard).
</action>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jev...@us...> - 2008-10-29 03:14:13
|
Revision: 757
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=757&view=rev
Author: jevonwright
Date: 2008-10-29 03:14:02 +0000 (Wed, 29 Oct 2008)
Log Message:
-----------
cleaning up Eclipse warnings (serialVersionUIDs, missing generics, unused imports etc)
Modified Paths:
--------------
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/IElementTest.java
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/JWebUnitAPITestCase.java
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/NonHtmlContentTest.java
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/TestContextTest.java
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/CookiesServlet.java
trunk/jwebunit-commons-tests/src/main/resources/testcases/FormAssertionsTest/testPage.html
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/api/ITestingEngine.java
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/ElementNotFoundException.java
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/ExpectedJavascriptAlertException.java
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/ExpectedJavascriptConfirmException.java
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/ExpectedJavascriptPromptException.java
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/TestingEngineRegistryException.java
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/TestingEngineResponseException.java
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/UnableToSetFormException.java
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/UnexpectedJavascriptAlertException.java
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/UnexpectedJavascriptConfirmException.java
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/UnexpectedJavascriptPromptException.java
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/util/TestContext.java
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/util/TestingEngineRegistry.java
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitElementImpl.java
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java
Modified: trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/IElementTest.java
===================================================================
--- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/IElementTest.java 2008-10-29 02:08:52 UTC (rev 756)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/IElementTest.java 2008-10-29 03:14:02 UTC (rev 757)
@@ -44,7 +44,7 @@
public void testMissing() {
// a missing element should throw an exception
try {
- IElement element = getElementByXPath("//input[@id='test2']");
+ getElementByXPath("//input[@id='test2']");
fail("getElementByXPath() should have thrown an assertion exception.");
} catch (AssertionFailedError e) {
// nothing
Modified: trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/JWebUnitAPITestCase.java
===================================================================
--- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/JWebUnitAPITestCase.java 2008-10-29 02:08:52 UTC (rev 756)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/JWebUnitAPITestCase.java 2008-10-29 03:14:02 UTC (rev 757)
@@ -86,7 +86,7 @@
assertException(AssertionFailedError.class, methodName, args);
}
- public void assertException(Class exceptionClass, String methodName,
+ public void assertException(Class<?> exceptionClass, String methodName,
Object[] args) {
MethodInvoker invoker = new MethodInvoker(this, methodName, args);
try {
Modified: trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/NonHtmlContentTest.java
===================================================================
--- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/NonHtmlContentTest.java 2008-10-29 02:08:52 UTC (rev 756)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/NonHtmlContentTest.java 2008-10-29 03:14:02 UTC (rev 757)
@@ -4,12 +4,10 @@
******************************************************************************/
package net.sourceforge.jwebunit.tests;
-import java.io.File;
import java.io.IOException;
import junit.framework.Test;
import junit.framework.TestSuite;
-
import net.sourceforge.jwebunit.tests.util.JettySetup;
/**
Modified: trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/TestContextTest.java
===================================================================
--- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/TestContextTest.java 2008-10-29 02:08:52 UTC (rev 756)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/TestContextTest.java 2008-10-29 03:14:02 UTC (rev 757)
@@ -32,7 +32,7 @@
assertTrue(context.hasCookies());
assertEquals(context.getUser(), "user");
assertEquals(context.getPassword(), "pwd");
- List cookies = context.getCookies();
+ List<?> cookies = context.getCookies();
Cookie c = (Cookie)cookies.get(0);
assertEquals(c.getName(), "key");
assertEquals(c.getValue(), "val");
Modified: trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/CookiesServlet.java
===================================================================
--- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/CookiesServlet.java 2008-10-29 02:08:52 UTC (rev 756)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/CookiesServlet.java 2008-10-29 03:14:02 UTC (rev 757)
@@ -6,8 +6,6 @@
import java.io.IOException;
import java.io.PrintWriter;
-import java.util.Iterator;
-import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
@@ -15,12 +13,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.apache.commons.fileupload.FileItem;
-import org.apache.commons.fileupload.FileItemFactory;
-import org.apache.commons.fileupload.FileUploadException;
-import org.apache.commons.fileupload.disk.DiskFileItemFactory;
-import org.apache.commons.fileupload.servlet.ServletFileUpload;
-
public class CookiesServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
Modified: trunk/jwebunit-commons-tests/src/main/resources/testcases/FormAssertionsTest/testPage.html
===================================================================
--- trunk/jwebunit-commons-tests/src/main/resources/testcases/FormAssertionsTest/testPage.html 2008-10-29 02:08:52 UTC (rev 756)
+++ trunk/jwebunit-commons-tests/src/main/resources/testcases/FormAssertionsTest/testPage.html 2008-10-29 03:14:02 UTC (rev 757)
@@ -76,7 +76,7 @@
</label>
<label id="label5">
<input type="radio" value="1">Not selected<br />
- <input type="radio" value="2" selected>Selected<br />
+ <input type="radio" value="2" checked>Selected<br />
<input type="text" name="label5_field1" value="Ignore this" />
</label>
<label id="label6">
Modified: trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/api/ITestingEngine.java
===================================================================
--- trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/api/ITestingEngine.java 2008-10-29 02:08:52 UTC (rev 756)
+++ trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/api/ITestingEngine.java 2008-10-29 03:14:02 UTC (rev 757)
@@ -71,7 +71,7 @@
*
* @return List of javax.servlet.http.Cookie.
*/
- List getCookies();
+ List<?> getCookies();
/**
* Test if the window with the given name is present.
Modified: trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/ElementNotFoundException.java
===================================================================
--- trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/ElementNotFoundException.java 2008-10-29 02:08:52 UTC (rev 756)
+++ trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/ElementNotFoundException.java 2008-10-29 03:14:02 UTC (rev 757)
@@ -12,7 +12,9 @@
*/
public class ElementNotFoundException extends Exception {
- public ElementNotFoundException(String msg) {
+ private static final long serialVersionUID = 1L;
+
+ public ElementNotFoundException(String msg) {
super(msg);
}
Modified: trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/ExpectedJavascriptAlertException.java
===================================================================
--- trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/ExpectedJavascriptAlertException.java 2008-10-29 02:08:52 UTC (rev 756)
+++ trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/ExpectedJavascriptAlertException.java 2008-10-29 03:14:02 UTC (rev 757)
@@ -4,7 +4,6 @@
******************************************************************************/
package net.sourceforge.jwebunit.exception;
-import junit.framework.AssertionFailedError;
/**
* A Javascript alert was expected but was not thrown.
@@ -13,6 +12,8 @@
*/
public class ExpectedJavascriptAlertException extends Exception {
+ private static final long serialVersionUID = 1L;
+
/**
* Expected message in the alert
*/
Modified: trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/ExpectedJavascriptConfirmException.java
===================================================================
--- trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/ExpectedJavascriptConfirmException.java 2008-10-29 02:08:52 UTC (rev 756)
+++ trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/ExpectedJavascriptConfirmException.java 2008-10-29 03:14:02 UTC (rev 757)
@@ -4,7 +4,6 @@
******************************************************************************/
package net.sourceforge.jwebunit.exception;
-import junit.framework.AssertionFailedError;
/**
* A Javascript confirm was expected but was not thrown.
@@ -13,6 +12,8 @@
*/
public class ExpectedJavascriptConfirmException extends Exception {
+ private static final long serialVersionUID = 1L;
+
/**
* Expected message in the confirm
*/
Modified: trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/ExpectedJavascriptPromptException.java
===================================================================
--- trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/ExpectedJavascriptPromptException.java 2008-10-29 02:08:52 UTC (rev 756)
+++ trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/ExpectedJavascriptPromptException.java 2008-10-29 03:14:02 UTC (rev 757)
@@ -4,7 +4,6 @@
******************************************************************************/
package net.sourceforge.jwebunit.exception;
-import junit.framework.AssertionFailedError;
/**
* A Javascript prompt was expected but was not thrown.
@@ -12,7 +11,10 @@
* @author Julien Henry
*/
public class ExpectedJavascriptPromptException extends Exception {
- /**
+
+ private static final long serialVersionUID = 1L;
+
+ /**
* Expected message in the prompt
*/
private String message;
Modified: trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/TestingEngineRegistryException.java
===================================================================
--- trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/TestingEngineRegistryException.java 2008-10-29 02:08:52 UTC (rev 756)
+++ trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/TestingEngineRegistryException.java 2008-10-29 03:14:02 UTC (rev 757)
@@ -10,7 +10,10 @@
* @author Nick Neuberger
*/
public class TestingEngineRegistryException extends RuntimeException {
- public TestingEngineRegistryException() {
+
+ private static final long serialVersionUID = 1L;
+
+ public TestingEngineRegistryException() {
}
public TestingEngineRegistryException(String s) {
Modified: trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/TestingEngineResponseException.java
===================================================================
--- trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/TestingEngineResponseException.java 2008-10-29 02:08:52 UTC (rev 756)
+++ trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/TestingEngineResponseException.java 2008-10-29 03:14:02 UTC (rev 757)
@@ -15,6 +15,7 @@
*/
public class TestingEngineResponseException extends RuntimeException {
+ private static final long serialVersionUID = 1L;
private int httpStatusCode = -1;
/**
Modified: trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/UnableToSetFormException.java
===================================================================
--- trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/UnableToSetFormException.java 2008-10-29 02:08:52 UTC (rev 756)
+++ trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/UnableToSetFormException.java 2008-10-29 03:14:02 UTC (rev 757)
@@ -11,7 +11,10 @@
* @author Wilkes Joiner
*/
public class UnableToSetFormException extends RuntimeException {
- public UnableToSetFormException() {
+
+ private static final long serialVersionUID = 1L;
+
+ public UnableToSetFormException() {
}
public UnableToSetFormException(String s) {
Modified: trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/UnexpectedJavascriptAlertException.java
===================================================================
--- trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/UnexpectedJavascriptAlertException.java 2008-10-29 02:08:52 UTC (rev 756)
+++ trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/UnexpectedJavascriptAlertException.java 2008-10-29 03:14:02 UTC (rev 757)
@@ -11,6 +11,8 @@
*/
public class UnexpectedJavascriptAlertException extends RuntimeException {
+ private static final long serialVersionUID = 1L;
+
/**
* Message in the unexpected alert
*/
Modified: trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/UnexpectedJavascriptConfirmException.java
===================================================================
--- trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/UnexpectedJavascriptConfirmException.java 2008-10-29 02:08:52 UTC (rev 756)
+++ trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/UnexpectedJavascriptConfirmException.java 2008-10-29 03:14:02 UTC (rev 757)
@@ -11,6 +11,8 @@
*/
public class UnexpectedJavascriptConfirmException extends RuntimeException {
+ private static final long serialVersionUID = 1L;
+
/**
* Message in the unexpected confirm
*/
Modified: trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/UnexpectedJavascriptPromptException.java
===================================================================
--- trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/UnexpectedJavascriptPromptException.java 2008-10-29 02:08:52 UTC (rev 756)
+++ trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/UnexpectedJavascriptPromptException.java 2008-10-29 03:14:02 UTC (rev 757)
@@ -11,6 +11,8 @@
*/
public class UnexpectedJavascriptPromptException extends RuntimeException {
+ private static final long serialVersionUID = 1L;
+
/**
* Message in the unexpected prompt
*/
Modified: trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java
===================================================================
--- trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java 2008-10-29 02:08:52 UTC (rev 756)
+++ trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java 2008-10-29 03:14:02 UTC (rev 757)
@@ -94,7 +94,7 @@
protected ITestingEngine initializeDialog() {
ITestingEngine theIJWebUnitDialog = null;
String theTestingEngineKey = getTestingEngineKey();
- Class theClass;
+ Class<?> theClass;
try {
theClass = TestingEngineRegistry
.getTestingEngineClass(theTestingEngineKey);
@@ -2081,8 +2081,8 @@
* @param cookieName The cookie name
*/
public void assertCookiePresent(String cookieName) {
- List cookies = getTestingEngine().getCookies();
- for (Iterator i = cookies.iterator(); i.hasNext();) {
+ List<?> cookies = getTestingEngine().getCookies();
+ for (Iterator<?> i = cookies.iterator(); i.hasNext();) {
if (((Cookie) i.next()).getName().equals(cookieName)) {
return;
}
@@ -2098,8 +2098,8 @@
*/
public void assertCookieValueEquals(String cookieName, String expectedValue) {
assertCookiePresent(cookieName);
- List cookies = getTestingEngine().getCookies();
- for (Iterator i = cookies.iterator(); i.hasNext();) {
+ List<?> cookies = getTestingEngine().getCookies();
+ for (Iterator<?> i = cookies.iterator(); i.hasNext();) {
Cookie c = (Cookie) i.next();
if (c.getName().equals(cookieName)) {
Assert.assertEquals(expectedValue, c.getValue());
@@ -2123,8 +2123,8 @@
} catch (RESyntaxException e) {
Assert.fail(e.toString());
}
- List cookies = getTestingEngine().getCookies();
- for (Iterator i = cookies.iterator(); i.hasNext();) {
+ List<?> cookies = getTestingEngine().getCookies();
+ for (Iterator<?> i = cookies.iterator(); i.hasNext();) {
Cookie c = (Cookie) i.next();
if (c.getName().equals(cookieName)) {
Assert.assertTrue("Unable to match [" + regexp
@@ -2645,7 +2645,7 @@
value = field.getAttribute("value");
}
} else if (field.getAttribute("type").toLowerCase().equals("radio")) {
- if (field.getAttribute("selected") != null) {
+ if (field.getAttribute("checked") != null) {
value = field.getAttribute("value");
}
} else {
@@ -2758,8 +2758,8 @@
*
*/
public void dumpCookies() {
- List cookies = getTestingEngine().getCookies();
- for (Iterator i = cookies.iterator(); i.hasNext();) {
+ List<?> cookies = getTestingEngine().getCookies();
+ for (Iterator<?> i = cookies.iterator(); i.hasNext();) {
Cookie c = (Cookie) i.next();
System.out.println("Name=" + c.getName() + "; Value="
+ c.getValue() + "; Domain=" + c.getDomain() + "; Comment="
@@ -2825,7 +2825,7 @@
tmp.deleteOnExit();
saveAs(tmp);
Assert.assertTrue("Files are not binary equals.", areFilesEqual(
- expected, tmp.toURL()));
+ expected, tmp.toURI().toURL()));
} catch (IOException e) {
e.printStackTrace();
Assert.fail(e.toString());
Modified: trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/util/TestContext.java
===================================================================
--- trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/util/TestContext.java 2008-10-29 02:08:52 UTC (rev 756)
+++ trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/util/TestContext.java 2008-10-29 03:14:02 UTC (rev 757)
@@ -60,7 +60,7 @@
* Construct a test client context.
*/
public TestContext() {
- cookies = new ArrayList();
+ cookies = new ArrayList<javax.servlet.http.Cookie>();
try {
baseUrl = new URL("http://localhost:8080");
} catch (MalformedURLException e) {
@@ -330,7 +330,7 @@
*
*/
public void clearRequestHeaders() {
- requestHeaders = new HashMap();
+ requestHeaders = new HashMap<String, String>();
}
}
Modified: trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/util/TestingEngineRegistry.java
===================================================================
--- trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/util/TestingEngineRegistry.java 2008-10-29 02:08:52 UTC (rev 756)
+++ trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/util/TestingEngineRegistry.java 2008-10-29 03:14:02 UTC (rev 757)
@@ -26,7 +26,7 @@
*/
public final static String TESTING_ENGINE_SELENIUM = "TestingEngineSelenium";
- private static Hashtable testingEngineMap = new Hashtable();
+ private static Hashtable<String,Class<?>> testingEngineMap = new Hashtable<String,Class<?>>();
static {
String cp = "net.sourceforge.jwebunit.htmlunit.HtmlUnitTestingEngineImpl";
@@ -51,9 +51,9 @@
* @param aKey Key of the testing engine
* @return the testing engine class.
*/
- public static Class getTestingEngineClass(String aKey)
+ public static Class<?> getTestingEngineClass(String aKey)
throws ClassNotFoundException {
- Class theClass = (Class) testingEngineMap.get(aKey);
+ Class<?> theClass = (Class<?>) testingEngineMap.get(aKey);
return theClass;
}
@@ -66,7 +66,7 @@
*/
public static void addTestingEngine(String key, String classpath)
throws ClassNotFoundException {
- Class c = Class.forName(classpath);
+ Class<?> c = Class.forName(classpath);
if (ITestingEngine.class.isAssignableFrom(c)) {
testingEngineMap.put(key, c);
} else {
Modified: trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitElementImpl.java
===================================================================
--- trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitElementImpl.java 2008-10-29 02:08:52 UTC (rev 756)
+++ trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitElementImpl.java 2008-10-29 03:14:02 UTC (rev 757)
@@ -6,12 +6,11 @@
import java.util.ArrayList;
import java.util.List;
+import net.sourceforge.jwebunit.api.IElement;
+
import com.gargoylesoftware.htmlunit.html.DomNode;
import com.gargoylesoftware.htmlunit.html.HtmlElement;
-import com.gargoylesoftware.htmlunit.javascript.host.Node;
-import net.sourceforge.jwebunit.api.IElement;
-
/**
* HtmlUnit implementation of IElement wrapper.
*
Modified: trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java
===================================================================
--- trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java 2008-10-29 02:08:52 UTC (rev 756)
+++ trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java 2008-10-29 03:14:02 UTC (rev 757)
@@ -13,7 +13,6 @@
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -70,14 +69,12 @@
import com.gargoylesoftware.htmlunit.html.HtmlButtonInput;
import com.gargoylesoftware.htmlunit.html.HtmlCheckBoxInput;
import com.gargoylesoftware.htmlunit.html.HtmlElement;
-import com.gargoylesoftware.htmlunit.html.HtmlFileInput;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlHiddenInput;
import com.gargoylesoftware.htmlunit.html.HtmlImageInput;
import com.gargoylesoftware.htmlunit.html.HtmlInput;
import com.gargoylesoftware.htmlunit.html.HtmlOption;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
-import com.gargoylesoftware.htmlunit.html.HtmlPasswordInput;
import com.gargoylesoftware.htmlunit.html.HtmlRadioButtonInput;
import com.gargoylesoftware.htmlunit.html.HtmlResetInput;
import com.gargoylesoftware.htmlunit.html.HtmlSelect;
@@ -86,7 +83,6 @@
import com.gargoylesoftware.htmlunit.html.HtmlTableCell;
import com.gargoylesoftware.htmlunit.html.HtmlTableRow;
import com.gargoylesoftware.htmlunit.html.HtmlTextArea;
-import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
import com.gargoylesoftware.htmlunit.html.HtmlTableRow.CellIterator;
import com.gargoylesoftware.htmlunit.xml.XmlPage;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jev...@us...> - 2008-10-29 04:17:23
|
Revision: 758
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=758&view=rev
Author: jevonwright
Date: 2008-10-29 04:17:14 +0000 (Wed, 29 Oct 2008)
Log Message:
-----------
added setLabeledFormElementField(id, value) method
Modified Paths:
--------------
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormAssertionsTest.java
trunk/jwebunit-commons-tests/src/main/resources/testcases/FormAssertionsTest/testPage.html
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/api/IElement.java
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitElementImpl.java
trunk/src/changes/changes.xml
Modified: trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormAssertionsTest.java
===================================================================
--- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormAssertionsTest.java 2008-10-29 03:14:02 UTC (rev 757)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormAssertionsTest.java 2008-10-29 04:17:14 UTC (rev 758)
@@ -4,6 +4,7 @@
******************************************************************************/
package net.sourceforge.jwebunit.tests;
+import net.sourceforge.jwebunit.api.IElement;
import net.sourceforge.jwebunit.tests.util.JettySetup;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -258,7 +259,9 @@
}
- // tests for label elements
+ /**
+ * tests for label elements
+ */
public void testLabels() {
beginAt("/testPage.html");
@@ -285,7 +288,42 @@
assertLabelPresent("label8");
assertLabeledFieldEquals("label8", "eight");
+ }
+
+ /**
+ * Test setting elements retrieved through labels
+ */
+ public void testSetLabels() {
+ beginAt("/testPage.html");
+ assertLabelPresent("label1");
+ assertLabeledFieldEquals("label1", "one");
+ assertTextFieldEquals("label1_field1", "one");
+ assertEquals(getElementById("field1_id").getAttribute("value"), "one");
+
+ // through setLabeledFormElementField
+ setLabeledFormElementField("label1", "two");
+
+ assertLabeledFieldEquals("label1", "two");
+ assertTextFieldEquals("label1_field1", "two");
+ assertEquals(getElementById("field1_id").getAttribute("value"), "two");
+
+ // through normal setValue
+ setTextField("label1_field1", "three");
+
+ assertLabeledFieldEquals("label1", "three");
+ assertTextFieldEquals("label1_field1", "three");
+ assertEquals(getElementById("field1_id").getAttribute("value"), "three");
+
+ // through IElement
+ IElement element = getElementById("field1_id");
+ assertNotNull(element);
+ element.setAttribute("value", "four");
+
+ assertLabeledFieldEquals("label1", "four");
+ assertTextFieldEquals("label1_field1", "four");
+ assertEquals(getElementById("field1_id").getAttribute("value"), "four");
+
}
}
Modified: trunk/jwebunit-commons-tests/src/main/resources/testcases/FormAssertionsTest/testPage.html
===================================================================
--- trunk/jwebunit-commons-tests/src/main/resources/testcases/FormAssertionsTest/testPage.html 2008-10-29 03:14:02 UTC (rev 757)
+++ trunk/jwebunit-commons-tests/src/main/resources/testcases/FormAssertionsTest/testPage.html 2008-10-29 04:17:14 UTC (rev 758)
@@ -61,7 +61,7 @@
<label id="label1">
Field 1:
- <input type="text" name="label1_field1" value="one" />
+ <input type="text" name="label1_field1" id="field1_id" value="one" />
</label>
<label id="label2">
Field 2:
Modified: trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/api/IElement.java
===================================================================
--- trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/api/IElement.java 2008-10-29 03:14:02 UTC (rev 757)
+++ trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/api/IElement.java 2008-10-29 04:17:14 UTC (rev 758)
@@ -66,5 +66,27 @@
* @return A list of all matching elements
*/
public List<IElement> getElements(String xpath);
+
+ /**
+ * Set an attribute on this element.
+ *
+ * @param string
+ */
+ public void setAttribute(String string);
+
+ /**
+ * Set an attribute on this element.
+ *
+ * @param string
+ * @param value
+ */
+ public void setAttribute(String string, String value);
+
+ /**
+ * Set the text content on this element.
+ *
+ * @param value
+ */
+ public void setTextContent(String value);
}
Modified: trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java
===================================================================
--- trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java 2008-10-29 03:14:02 UTC (rev 757)
+++ trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java 2008-10-29 04:17:14 UTC (rev 758)
@@ -2560,12 +2560,22 @@
* Assert a label for a given ID exists.
*/
public void assertLabelPresent(String id) {
+ Assert.assertNotNull("No label found with id [" + id + "]", getLabel(id));
+ }
+
+ /**
+ * Get a label for a particular ID.
+ *
+ * @param id
+ * @return
+ */
+ private IElement getLabel(String id) {
// get all labels
for (IElement e : getTestingEngine().getElementsByXPath("//label")) {
if (e.getName().equals("label") && id.equals(e.getAttribute("id")))
- return; // label found
+ return e; // label found
}
- Assert.fail("No label found with id [" + id + "]");
+ return null;
}
/**
@@ -2605,12 +2615,12 @@
}
/**
- * Private method to test the value of a field connected to a particular IElement label.
+ * Get all the fields that are referenced or contained in a particular label.
*
- * @param label
- * @param fieldText
+ * @param label The label to consider
+ * @return A list of all fields contained or referenced in this label
*/
- private void assertLabeledFieldEquals(String identifier, IElement label, String fieldText) {
+ private List<IElement> getFieldsForLabel(IElement label) {
List<IElement> fields = new java.util.ArrayList<IElement>();
// a direct "for" attribute
if (label.getAttribute("for") != null) {
@@ -2628,7 +2638,19 @@
}
}
}
+
+ return fields;
+ }
+ /**
+ * Private method to test the value of a field connected to a particular IElement label.
+ *
+ * @param label
+ * @param fieldText
+ */
+ private void assertLabeledFieldEquals(String identifier, IElement label, String fieldText) {
+ List<IElement> fields = getFieldsForLabel(label);
+
Assert.assertFalse("No field found for label [" + identifier + "]", fields.isEmpty());
String value = null;
// cycle through all fields trying to find value
@@ -2682,12 +2704,66 @@
* @param fieldText
*/
public void assertLabeledFieldEquals(String id, String fieldText) {
- IElement label = getTestingEngine().getElementByID(id);
+ IElement label = getLabel(id);
Assert.assertNotNull("no label for id [" + id + "] found", label);
- Assert.assertEquals("element with id [" + id + "] is not a label", "label", label.getName());
assertLabeledFieldEquals(id, label, fieldText);
}
+
+ public void setLabeledFormElementField(String id, String value) {
+ IElement label = getLabel(id);
+ Assert.assertNotNull("no label for id [" + id + "] found", label);
+
+ List<IElement> fields = getFieldsForLabel(label);
+ Assert.assertNotSame("there should be at least one element referenced for label [" + id + "]", 0, fields.size());
+
+ // find the first element that we can change
+ for (IElement field : fields) {
+ if (field == null)
+ throw new RuntimeException("unexpected null field " + field);
+
+ if ("input".equals(field.getName())) {
+ if (field.getAttribute("type") != null) {
+ if (field.getAttribute("type").toLowerCase().equals("checkbox")) {
+ if (value.equals(field.getAttribute("value"))) {
+ field.setAttribute("checked");
+ return;
+ }
+ } else if (field.getAttribute("type").toLowerCase().equals("radio")) {
+ if (value.equals(field.getAttribute("value"))) {
+ field.setAttribute("checked");
+ return;
+ }
+ } else {
+ // any other input type
+ field.setAttribute("value", value);
+ return;
+ }
+ } else {
+ // unspecified input type, default = text
+ field.setAttribute("value", value);
+ return;
+ }
+ } else if ("textarea".equals(field.getName())) {
+ field.setTextContent(value);
+ return;
+ } else if ("select".equals(field.getName())) {
+ // get the selected option
+ for (IElement children : field.getChildren()) {
+ // find the option which matches the given value (we can't specify random values)
+ if (children.getName().equals("option") &&
+ (children.getAttribute("value") == null ? value.equals(children.getTextContent()) : value.equals(children.getAttribute("value")))) {
+ children.setAttribute("selected");
+ return;
+ }
+ }
+ } else {
+ throw new RuntimeException("Unexpected field type " + field.getName());
+ }
+ }
+
+ Assert.fail("could not find any fields for label [" + id + "] to set.");
+ }
// Window and Frame Navigation Methods
Modified: trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitElementImpl.java
===================================================================
--- trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitElementImpl.java 2008-10-29 03:14:02 UTC (rev 757)
+++ trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitElementImpl.java 2008-10-29 04:17:14 UTC (rev 758)
@@ -114,4 +114,28 @@
return "IElement[name=" + getName() + " wrapped=" + element + "]";
}
+
+ /* (non-Javadoc)
+ * @see net.sourceforge.jwebunit.api.IElement#setAttribute(java.lang.String)
+ */
+ public void setAttribute(String string) {
+ element.setAttribute(string, "1");
+ }
+
+
+ /* (non-Javadoc)
+ * @see net.sourceforge.jwebunit.api.IElement#setAttribute(java.lang.String, java.lang.String)
+ */
+ public void setAttribute(String string, String value) {
+ element.setAttribute(string, value);
+ }
+
+
+ /* (non-Javadoc)
+ * @see net.sourceforge.jwebunit.api.IElement#setTextContent(java.lang.String)
+ */
+ public void setTextContent(String value) {
+ element.setTextContent(value);
+ }
+
}
Modified: trunk/src/changes/changes.xml
===================================================================
--- trunk/src/changes/changes.xml 2008-10-29 03:14:02 UTC (rev 757)
+++ trunk/src/changes/changes.xml 2008-10-29 04:17:14 UTC (rev 758)
@@ -18,7 +18,7 @@
Added WebTestCase(WebTester) constructor
</action>
<action type="add" dev="jevonwright" issue="1519807">
- Added assertLabeledFieldEquals(id, text) and assertLabel*() methods
+ Added assertLabeledFieldEquals(id, text), assertLabel*(), and setLabeledFormElementField(id, value) methods
</action>
<action type="update" dev="jevonwright">
BC CHANGE: setFormElement(), assertFormElementEquals() methods will no longer assert that a form already exists in the page (as allowed by the HTML standard).
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jev...@us...> - 2008-10-30 03:57:35
|
Revision: 760
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=760&view=rev
Author: jevonwright
Date: 2008-10-30 03:57:26 +0000 (Thu, 30 Oct 2008)
Log Message:
-----------
fixed issue 1724695: navigator.userAgent is no longer null by default
added prototype.js test case
Modified Paths:
--------------
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormSubmissionTest.java
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/JavaScriptTest.java
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/ResponseServlet.java
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java
trunk/src/changes/changes.xml
Added Paths:
-----------
trunk/jwebunit-commons-tests/src/main/resources/testcases/JavaScriptTest/prototype-1.6.0.3.js
trunk/jwebunit-commons-tests/src/main/resources/testcases/JavaScriptTest/prototype.html
trunk/jwebunit-commons-tests/src/main/resources/testcases/JavaScriptTest/userAgent.html
Modified: trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormSubmissionTest.java
===================================================================
--- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormSubmissionTest.java 2008-10-29 09:30:17 UTC (rev 759)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormSubmissionTest.java 2008-10-30 03:57:26 UTC (rev 760)
@@ -77,8 +77,8 @@
setTextField("file", filename);
submit("button");
assertTextPresent("Submitted parameters");
- //The following depend on the browser: IE send full path but FF send only file name.
- assertTextPresent("file=" + temp.getAbsolutePath() + "{abcdefgh}");
+ //The following depend on the browser: IE send full path (i.e. temp.getAbsolutePath()) but FF send only file name.
+ assertTextPresent("file=" + temp.getName() + "{abcdefgh}");
}
public void testSubmitImageInput() {
Modified: trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/JavaScriptTest.java
===================================================================
--- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/JavaScriptTest.java 2008-10-29 09:30:17 UTC (rev 759)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/JavaScriptTest.java 2008-10-30 03:57:26 UTC (rev 760)
@@ -68,4 +68,32 @@
beginAt("Prompt.html");
assertTextPresent("Cancel");
}
+
+ /**
+ * Test that the <code>navigator.userAgent</code> is actually available.
+ *
+ * @see bug 1724695
+ */
+ public void testUserAgent() {
+ beginAt("userAgent.html");
+ assertTextPresent("Mozilla"); // the default browser is a Mozilla browser
+ }
+
+ /**
+ * Test prototype.js integration and make sure that it works
+ * in JWebUnit
+ *
+ * @see bug 2208784
+ * @author Jevon
+ * @throws InterruptedException
+ */
+ public void testPrototypeJs() throws InterruptedException {
+ beginAt("prototype.html");
+ clickButtonWithText("do ajax");
+ // we wait a while for the ajax to return
+ Thread.sleep(500);
+ assertTextPresent("hello, world!");
+ assertTextNotPresent("not loaded");
+ }
+
}
Modified: trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/ResponseServlet.java
===================================================================
--- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/ResponseServlet.java 2008-10-29 09:30:17 UTC (rev 759)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/ResponseServlet.java 2008-10-30 03:57:26 UTC (rev 760)
@@ -37,6 +37,8 @@
// lets set some headers
response.setHeader("Test", "test2");
response.setHeader("Header-Added", new java.util.Date().toString());
+
+ response.getWriter().println("hello, world!");
}
Added: trunk/jwebunit-commons-tests/src/main/resources/testcases/JavaScriptTest/prototype-1.6.0.3.js
===================================================================
--- trunk/jwebunit-commons-tests/src/main/resources/testcases/JavaScriptTest/prototype-1.6.0.3.js (rev 0)
+++ trunk/jwebunit-commons-tests/src/main/resources/testcases/JavaScriptTest/prototype-1.6.0.3.js 2008-10-30 03:57:26 UTC (rev 760)
@@ -0,0 +1,4320 @@
+/* Prototype JavaScript framework, version 1.6.0.3
+ * (c) 2005-2008 Sam Stephenson
+ *
+ * Prototype is freely distributable under the terms of an MIT-style license.
+ * For details, see the Prototype web site: http://www.prototypejs.org/
+ *
+ *--------------------------------------------------------------------------*/
+
+var Prototype = {
+ Version: '1.6.0.3',
+
+ Browser: {
+ IE: !!(window.attachEvent &&
+ navigator.userAgent.indexOf('Opera') === -1),
+ Opera: navigator.userAgent.indexOf('Opera') > -1,
+ WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
+ Gecko: navigator.userAgent.indexOf('Gecko') > -1 &&
+ navigator.userAgent.indexOf('KHTML') === -1,
+ MobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/)
+ },
+
+ BrowserFeatures: {
+ XPath: !!document.evaluate,
+ SelectorsAPI: !!document.querySelector,
+ ElementExtensions: !!window.HTMLElement,
+ SpecificElementExtensions:
+ document.createElement('div')['__proto__'] &&
+ document.createElement('div')['__proto__'] !==
+ document.createElement('form')['__proto__']
+ },
+
+ ScriptFragment: '<script[^>]*>([\\S\\s]*?)<\/script>',
+ JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/,
+
+ emptyFunction: function() { },
+ K: function(x) { return x }
+};
+
+if (Prototype.Browser.MobileSafari)
+ Prototype.BrowserFeatures.SpecificElementExtensions = false;
+
+
+/* Based on Alex Arnell's inheritance implementation. */
+var Class = {
+ create: function() {
+ var parent = null, properties = $A(arguments);
+ if (Object.isFunction(properties[0]))
+ parent = properties.shift();
+
+ function klass() {
+ this.initialize.apply(this, arguments);
+ }
+
+ Object.extend(klass, Class.Methods);
+ klass.superclass = parent;
+ klass.subclasses = [];
+
+ if (parent) {
+ var subclass = function() { };
+ subclass.prototype = parent.prototype;
+ klass.prototype = new subclass;
+ parent.subclasses.push(klass);
+ }
+
+ for (var i = 0; i < properties.length; i++)
+ klass.addMethods(properties[i]);
+
+ if (!klass.prototype.initialize)
+ klass.prototype.initialize = Prototype.emptyFunction;
+
+ klass.prototype.constructor = klass;
+
+ return klass;
+ }
+};
+
+Class.Methods = {
+ addMethods: function(source) {
+ var ancestor = this.superclass && this.superclass.prototype;
+ var properties = Object.keys(source);
+
+ if (!Object.keys({ toString: true }).length)
+ properties.push("toString", "valueOf");
+
+ for (var i = 0, length = properties.length; i < length; i++) {
+ var property = properties[i], value = source[property];
+ if (ancestor && Object.isFunction(value) &&
+ value.argumentNames().first() == "$super") {
+ var method = value;
+ value = (function(m) {
+ return function() { return ancestor[m].apply(this, arguments) };
+ })(property).wrap(method);
+
+ value.valueOf = method.valueOf.bind(method);
+ value.toString = method.toString.bind(method);
+ }
+ this.prototype[property] = value;
+ }
+
+ return this;
+ }
+};
+
+var Abstract = { };
+
+Object.extend = function(destination, source) {
+ for (var property in source)
+ destination[property] = source[property];
+ return destination;
+};
+
+Object.extend(Object, {
+ inspect: function(object) {
+ try {
+ if (Object.isUndefined(object)) return 'undefined';
+ if (object === null) return 'null';
+ return object.inspect ? object.inspect() : String(object);
+ } catch (e) {
+ if (e instanceof RangeError) return '...';
+ throw e;
+ }
+ },
+
+ toJSON: function(object) {
+ var type = typeof object;
+ switch (type) {
+ case 'undefined':
+ case 'function':
+ case 'unknown': return;
+ case 'boolean': return object.toString();
+ }
+
+ if (object === null) return 'null';
+ if (object.toJSON) return object.toJSON();
+ if (Object.isElement(object)) return;
+
+ var results = [];
+ for (var property in object) {
+ var value = Object.toJSON(object[property]);
+ if (!Object.isUndefined(value))
+ results.push(property.toJSON() + ': ' + value);
+ }
+
+ return '{' + results.join(', ') + '}';
+ },
+
+ toQueryString: function(object) {
+ return $H(object).toQueryString();
+ },
+
+ toHTML: function(object) {
+ return object && object.toHTML ? object.toHTML() : String.interpret(object);
+ },
+
+ keys: function(object) {
+ var keys = [];
+ for (var property in object)
+ keys.push(property);
+ return keys;
+ },
+
+ values: function(object) {
+ var values = [];
+ for (var property in object)
+ values.push(object[property]);
+ return values;
+ },
+
+ clone: function(object) {
+ return Object.extend({ }, object);
+ },
+
+ isElement: function(object) {
+ return !!(object && object.nodeType == 1);
+ },
+
+ isArray: function(object) {
+ return object != null && typeof object == "object" &&
+ 'splice' in object && 'join' in object;
+ },
+
+ isHash: function(object) {
+ return object instanceof Hash;
+ },
+
+ isFunction: function(object) {
+ return typeof object == "function";
+ },
+
+ isString: function(object) {
+ return typeof object == "string";
+ },
+
+ isNumber: function(object) {
+ return typeof object == "number";
+ },
+
+ isUndefined: function(object) {
+ return typeof object == "undefined";
+ }
+});
+
+Object.extend(Function.prototype, {
+ argumentNames: function() {
+ var names = this.toString().match(/^[\s\(]*function[^(]*\(([^\)]*)\)/)[1]
+ .replace(/\s+/g, '').split(',');
+ return names.length == 1 && !names[0] ? [] : names;
+ },
+
+ bind: function() {
+ if (arguments.length < 2 && Object.isUndefined(arguments[0])) return this;
+ var __method = this, args = $A(arguments), object = args.shift();
+ return function() {
+ return __method.apply(object, args.concat($A(arguments)));
+ }
+ },
+
+ bindAsEventListener: function() {
+ var __method = this, args = $A(arguments), object = args.shift();
+ return function(event) {
+ return __method.apply(object, [event || window.event].concat(args));
+ }
+ },
+
+ curry: function() {
+ if (!arguments.length) return this;
+ var __method = this, args = $A(arguments);
+ return function() {
+ return __method.apply(this, args.concat($A(arguments)));
+ }
+ },
+
+ delay: function() {
+ var __method = this, args = $A(arguments), timeout = args.shift() * 1000;
+ return window.setTimeout(function() {
+ return __method.apply(__method, args);
+ }, timeout);
+ },
+
+ defer: function() {
+ var args = [0.01].concat($A(arguments));
+ return this.delay.apply(this, args);
+ },
+
+ wrap: function(wrapper) {
+ var __method = this;
+ return function() {
+ return wrapper.apply(this, [__method.bind(this)].concat($A(arguments)));
+ }
+ },
+
+ methodize: function() {
+ if (this._methodized) return this._methodized;
+ var __method = this;
+ return this._methodized = function() {
+ return __method.apply(null, [this].concat($A(arguments)));
+ };
+ }
+});
+
+Date.prototype.toJSON = function() {
+ return '"' + this.getUTCFullYear() + '-' +
+ (this.getUTCMonth() + 1).toPaddedString(2) + '-' +
+ this.getUTCDate().toPaddedString(2) + 'T' +
+ this.getUTCHours().toPaddedString(2) + ':' +
+ this.getUTCMinutes().toPaddedString(2) + ':' +
+ this.getUTCSeconds().toPaddedString(2) + 'Z"';
+};
+
+var Try = {
+ these: function() {
+ var returnValue;
+
+ for (var i = 0, length = arguments.length; i < length; i++) {
+ var lambda = arguments[i];
+ try {
+ returnValue = lambda();
+ break;
+ } catch (e) { }
+ }
+
+ return returnValue;
+ }
+};
+
+RegExp.prototype.match = RegExp.prototype.test;
+
+RegExp.escape = function(str) {
+ return String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
+};
+
+/*--------------------------------------------------------------------------*/
+
+var PeriodicalExecuter = Class.create({
+ initialize: function(callback, frequency) {
+ this.callback = callback;
+ this.frequency = frequency;
+ this.currentlyExecuting = false;
+
+ this.registerCallback();
+ },
+
+ registerCallback: function() {
+ this.timer = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000);
+ },
+
+ execute: function() {
+ this.callback(this);
+ },
+
+ stop: function() {
+ if (!this.timer) return;
+ clearInterval(this.timer);
+ this.timer = null;
+ },
+
+ onTimerEvent: function() {
+ if (!this.currentlyExecuting) {
+ try {
+ this.currentlyExecuting = true;
+ this.execute();
+ } finally {
+ this.currentlyExecuting = false;
+ }
+ }
+ }
+});
+Object.extend(String, {
+ interpret: function(value) {
+ return value == null ? '' : String(value);
+ },
+ specialChar: {
+ '\b': '\\b',
+ '\t': '\\t',
+ '\n': '\\n',
+ '\f': '\\f',
+ '\r': '\\r',
+ '\\': '\\\\'
+ }
+});
+
+Object.extend(String.prototype, {
+ gsub: function(pattern, replacement) {
+ var result = '', source = this, match;
+ replacement = arguments.callee.prepareReplacement(replacement);
+
+ while (source.length > 0) {
+ if (match = source.match(pattern)) {
+ result += source.slice(0, match.index);
+ result += String.interpret(replacement(match));
+ source = source.slice(match.index + match[0].length);
+ } else {
+ result += source, source = '';
+ }
+ }
+ return result;
+ },
+
+ sub: function(pattern, replacement, count) {
+ replacement = this.gsub.prepareReplacement(replacement);
+ count = Object.isUndefined(count) ? 1 : count;
+
+ return this.gsub(pattern, function(match) {
+ if (--count < 0) return match[0];
+ return replacement(match);
+ });
+ },
+
+ scan: function(pattern, iterator) {
+ this.gsub(pattern, iterator);
+ return String(this);
+ },
+
+ truncate: function(length, truncation) {
+ length = length || 30;
+ truncation = Object.isUndefined(truncation) ? '...' : truncation;
+ return this.length > length ?
+ this.slice(0, length - truncation.length) + truncation : String(this);
+ },
+
+ strip: function() {
+ return this.replace(/^\s+/, '').replace(/\s+$/, '');
+ },
+
+ stripTags: function() {
+ return this.replace(/<\/?[^>]+>/gi, '');
+ },
+
+ stripScripts: function() {
+ return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), '');
+ },
+
+ extractScripts: function() {
+ var matchAll = new RegExp(Prototype.ScriptFragment, 'img');
+ var matchOne = new RegExp(Prototype.ScriptFragment, 'im');
+ return (this.match(matchAll) || []).map(function(scriptTag) {
+ return (scriptTag.match(matchOne) || ['', ''])[1];
+ });
+ },
+
+ evalScripts: function() {
+ return this.extractScripts().map(function(script) { return eval(script) });
+ },
+
+ escapeHTML: function() {
+ var self = arguments.callee;
+ self.text.data = this;
+ return self.div.innerHTML;
+ },
+
+ unescapeHTML: function() {
+ var div = new Element('div');
+ div.innerHTML = this.stripTags();
+ return div.childNodes[0] ? (div.childNodes.length > 1 ?
+ $A(div.childNodes).inject('', function(memo, node) { return memo+node.nodeValue }) :
+ div.childNodes[0].nodeValue) : '';
+ },
+
+ toQueryParams: function(separator) {
+ var match = this.strip().match(/([^?#]*)(#.*)?$/);
+ if (!match) return { };
+
+ return match[1].split(separator || '&').inject({ }, function(hash, pair) {
+ if ((pair = pair.split('='))[0]) {
+ var key = decodeURIComponent(pair.shift());
+ var value = pair.length > 1 ? pair.join('=') : pair[0];
+ if (value != undefined) value = decodeURIComponent(value);
+
+ if (key in hash) {
+ if (!Object.isArray(hash[key])) hash[key] = [hash[key]];
+ hash[key].push(value);
+ }
+ else hash[key] = value;
+ }
+ return hash;
+ });
+ },
+
+ toArray: function() {
+ return this.split('');
+ },
+
+ succ: function() {
+ return this.slice(0, this.length - 1) +
+ String.fromCharCode(this.charCodeAt(this.length - 1) + 1);
+ },
+
+ times: function(count) {
+ return count < 1 ? '' : new Array(count + 1).join(this);
+ },
+
+ camelize: function() {
+ var parts = this.split('-'), len = parts.length;
+ if (len == 1) return parts[0];
+
+ var camelized = this.charAt(0) == '-'
+ ? parts[0].charAt(0).toUpperCase() + parts[0].substring(1)
+ : parts[0];
+
+ for (var i = 1; i < len; i++)
+ camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1);
+
+ return camelized;
+ },
+
+ capitalize: function() {
+ return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase();
+ },
+
+ underscore: function() {
+ return this.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'#{1}_#{2}').gsub(/([a-z\d])([A-Z])/,'#{1}_#{2}').gsub(/-/,'_').toLowerCase();
+ },
+
+ dasherize: function() {
+ return this.gsub(/_/,'-');
+ },
+
+ inspect: function(useDoubleQuotes) {
+ var escapedString = this.gsub(/[\x00-\x1f\\]/, function(match) {
+ var character = String.specialChar[match[0]];
+ return character ? character : '\\u00' + match[0].charCodeAt().toPaddedString(2, 16);
+ });
+ if (useDoubleQuotes) return '"' + escapedString.replace(/"/g, '\\"') + '"';
+ return "'" + escapedString.replace(/'/g, '\\\'') + "'";
+ },
+
+ toJSON: function() {
+ return this.inspect(true);
+ },
+
+ unfilterJSON: function(filter) {
+ return this.sub(filter || Prototype.JSONFilter, '#{1}');
+ },
+
+ isJSON: function() {
+ var str = this;
+ if (str.blank()) return false;
+ str = this.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, '');
+ return (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(str);
+ },
+
+ evalJSON: function(sanitize) {
+ var json = this.unfilterJSON();
+ try {
+ if (!sanitize || json.isJSON()) return eval('(' + json + ')');
+ } catch (e) { }
+ throw new SyntaxError('Badly formed JSON string: ' + this.inspect());
+ },
+
+ include: function(pattern) {
+ return this.indexOf(pattern) > -1;
+ },
+
+ startsWith: function(pattern) {
+ return this.indexOf(pattern) === 0;
+ },
+
+ endsWith: function(pattern) {
+ var d = this.length - pattern.length;
+ return d >= 0 && this.lastIndexOf(pattern) === d;
+ },
+
+ empty: function() {
+ return this == '';
+ },
+
+ blank: function() {
+ return /^\s*$/.test(this);
+ },
+
+ interpolate: function(object, pattern) {
+ return new Template(this, pattern).evaluate(object);
+ }
+});
+
+if (Prototype.Browser.WebKit || Prototype.Browser.IE) Object.extend(String.prototype, {
+ escapeHTML: function() {
+ return this.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
+ },
+ unescapeHTML: function() {
+ return this.stripTags().replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
+ }
+});
+
+String.prototype.gsub.prepareReplacement = function(replacement) {
+ if (Object.isFunction(replacement)) return replacement;
+ var template = new Template(replacement);
+ return function(match) { return template.evaluate(match) };
+};
+
+String.prototype.parseQuery = String.prototype.toQueryParams;
+
+Object.extend(String.prototype.escapeHTML, {
+ div: document.createElement('div'),
+ text: document.createTextNode('')
+});
+
+String.prototype.escapeHTML.div.appendChild(String.prototype.escapeHTML.text);
+
+var Template = Class.create({
+ initialize: function(template, pattern) {
+ this.template = template.toString();
+ this.pattern = pattern || Template.Pattern;
+ },
+
+ evaluate: function(object) {
+ if (Object.isFunction(object.toTemplateReplacements))
+ object = object.toTemplateReplacements();
+
+ return this.template.gsub(this.pattern, function(match) {
+ if (object == null) return '';
+
+ var before = match[1] || '';
+ if (before == '\\') return match[2];
+
+ var ctx = object, expr = match[3];
+ var pattern = /^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/;
+ match = pattern.exec(expr);
+ if (match == null) return before;
+
+ while (match != null) {
+ var comp = match[1].startsWith('[') ? match[2].gsub('\\\\]', ']') : match[1];
+ ctx = ctx[comp];
+ if (null == ctx || '' == match[3]) break;
+ expr = expr.substring('[' == match[3] ? match[1].length : match[0].length);
+ match = pattern.exec(expr);
+ }
+
+ return before + String.interpret(ctx);
+ });
+ }
+});
+Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/;
+
+var $break = { };
+
+var Enumerable = {
+ each: function(iterator, context) {
+ var index = 0;
+ try {
+ this._each(function(value) {
+ iterator.call(context, value, index++);
+ });
+ } catch (e) {
+ if (e != $break) throw e;
+ }
+ return this;
+ },
+
+ eachSlice: function(number, iterator, context) {
+ var index = -number, slices = [], array = this.toArray();
+ if (number < 1) return array;
+ while ((index += number) < array.length)
+ slices.push(array.slice(index, index+number));
+ return slices.collect(iterator, context);
+ },
+
+ all: function(iterator, context) {
+ iterator = iterator || Prototype.K;
+ var result = true;
+ this.each(function(value, index) {
+ result = result && !!iterator.call(context, value, index);
+ if (!result) throw $break;
+ });
+ return result;
+ },
+
+ any: function(iterator, context) {
+ iterator = iterator || Prototype.K;
+ var result = false;
+ this.each(function(value, index) {
+ if (result = !!iterator.call(context, value, index))
+ throw $break;
+ });
+ return result;
+ },
+
+ collect: function(iterator, context) {
+ iterator = iterator || Prototype.K;
+ var results = [];
+ this.each(function(value, index) {
+ results.push(iterator.call(context, value, index));
+ });
+ return results;
+ },
+
+ detect: function(iterator, context) {
+ var result;
+ this.each(function(value, index) {
+ if (iterator.call(context, value, index)) {
+ result = value;
+ throw $break;
+ }
+ });
+ return result;
+ },
+
+ findAll: function(iterator, context) {
+ var results = [];
+ this.each(function(value, index) {
+ if (iterator.call(context, value, index))
+ results.push(value);
+ });
+ return results;
+ },
+
+ grep: function(filter, iterator, context) {
+ iterator = iterator || Prototype.K;
+ var results = [];
+
+ if (Object.isString(filter))
+ filter = new RegExp(filter);
+
+ this.each(function(value, index) {
+ if (filter.match(value))
+ results.push(iterator.call(context, value, index));
+ });
+ return results;
+ },
+
+ include: function(object) {
+ if (Object.isFunction(this.indexOf))
+ if (this.indexOf(object) != -1) return true;
+
+ var found = false;
+ this.each(function(value) {
+ if (value == object) {
+ found = true;
+ throw $break;
+ }
+ });
+ return found;
+ },
+
+ inGroupsOf: function(number, fillWith) {
+ fillWith = Object.isUndefined(fillWith) ? null : fillWith;
+ return this.eachSlice(number, function(slice) {
+ while(slice.length < number) slice.push(fillWith);
+ return slice;
+ });
+ },
+
+ inject: function(memo, iterator, context) {
+ this.each(function(value, index) {
+ memo = iterator.call(context, memo, value, index);
+ });
+ return memo;
+ },
+
+ invoke: function(method) {
+ var args = $A(arguments).slice(1);
+ return this.map(function(value) {
+ return value[method].apply(value, args);
+ });
+ },
+
+ max: function(iterator, context) {
+ iterator = iterator || Prototype.K;
+ var result;
+ this.each(function(value, index) {
+ value = iterator.call(context, value, index);
+ if (result == null || value >= result)
+ result = value;
+ });
+ return result;
+ },
+
+ min: function(iterator, context) {
+ iterator = iterator || Prototype.K;
+ var result;
+ this.each(function(value, index) {
+ value = iterator.call(context, value, index);
+ if (result == null || value < result)
+ result = value;
+ });
+ return result;
+ },
+
+ partition: function(iterator, context) {
+ iterator = iterator || Prototype.K;
+ var trues = [], falses = [];
+ this.each(function(value, index) {
+ (iterator.call(context, value, index) ?
+ trues : falses).push(value);
+ });
+ return [trues, falses];
+ },
+
+ pluck: function(property) {
+ var results = [];
+ this.each(function(value) {
+ results.push(value[property]);
+ });
+ return results;
+ },
+
+ reject: function(iterator, context) {
+ var results = [];
+ this.each(function(value, index) {
+ if (!iterator.call(context, value, index))
+ results.push(value);
+ });
+ return results;
+ },
+
+ sortBy: function(iterator, context) {
+ return this.map(function(value, index) {
+ return {
+ value: value,
+ criteria: iterator.call(context, value, index)
+ };
+ }).sort(function(left, right) {
+ var a = left.criteria, b = right.criteria;
+ return a < b ? -1 : a > b ? 1 : 0;
+ }).pluck('value');
+ },
+
+ toArray: function() {
+ return this.map();
+ },
+
+ zip: function() {
+ var iterator = Prototype.K, args = $A(arguments);
+ if (Object.isFunction(args.last()))
+ iterator = args.pop();
+
+ var collections = [this].concat(args).map($A);
+ return this.map(function(value, index) {
+ return iterator(collections.pluck(index));
+ });
+ },
+
+ size: function() {
+ return this.toArray().length;
+ },
+
+ inspect: function() {
+ return '#<Enumerable:' + this.toArray().inspect() + '>';
+ }
+};
+
+Object.extend(Enumerable, {
+ map: Enumerable.collect,
+ find: Enumerable.detect,
+ select: Enumerable.findAll,
+ filter: Enumerable.findAll,
+ member: Enumerable.include,
+ entries: Enumerable.toArray,
+ every: Enumerable.all,
+ some: Enumerable.any
+});
+function $A(iterable) {
+ if (!iterable) return [];
+ if (iterable.toArray) return iterable.toArray();
+ var length = iterable.length || 0, results = new Array(length);
+ while (length--) results[length] = iterable[length];
+ return results;
+}
+
+if (Prototype.Browser.WebKit) {
+ $A = function(iterable) {
+ if (!iterable) return [];
+ // In Safari, only use the `toArray` method if it's not a NodeList.
+ // A NodeList is a function, has an function `item` property, and a numeric
+ // `length` property. Adapted from Google Doctype.
+ if (!(typeof iterable === 'function' && typeof iterable.length ===
+ 'number' && typeof iterable.item === 'function') && iterable.toArray)
+ return iterable.toArray();
+ var length = iterable.length || 0, results = new Array(length);
+ while (length--) results[length] = iterable[length];
+ return results;
+ };
+}
+
+Array.from = $A;
+
+Object.extend(Array.prototype, Enumerable);
+
+if (!Array.prototype._reverse) Array.prototype._reverse = Array.prototype.reverse;
+
+Object.extend(Array.prototype, {
+ _each: function(iterator) {
+ for (var i = 0, length = this.length; i < length; i++)
+ iterator(this[i]);
+ },
+
+ clear: function() {
+ this.length = 0;
+ return this;
+ },
+
+ first: function() {
+ return this[0];
+ },
+
+ last: function() {
+ return this[this.length - 1];
+ },
+
+ compact: function() {
+ return this.select(function(value) {
+ return value != null;
+ });
+ },
+
+ flatten: function() {
+ return this.inject([], function(array, value) {
+ return array.concat(Object.isArray(value) ?
+ value.flatten() : [value]);
+ });
+ },
+
+ without: function() {
+ var values = $A(arguments);
+ return this.select(function(value) {
+ return !values.include(value);
+ });
+ },
+
+ reverse: function(inline) {
+ return (inline !== false ? this : this.toArray())._reverse();
+ },
+
+ reduce: function() {
+ return this.length > 1 ? this : this[0];
+ },
+
+ uniq: function(sorted) {
+ return this.inject([], function(array, value, index) {
+ if (0 == index || (sorted ? array.last() != value : !array.include(value)))
+ array.push(value);
+ return array;
+ });
+ },
+
+ intersect: function(array) {
+ return this.uniq().findAll(function(item) {
+ return array.detect(function(value) { return item === value });
+ });
+ },
+
+ clone: function() {
+ return [].concat(this);
+ },
+
+ size: function() {
+ return this.length;
+ },
+
+ inspect: function() {
+ return '[' + this.map(Object.inspect).join(', ') + ']';
+ },
+
+ toJSON: function() {
+ var results = [];
+ this.each(function(object) {
+ var value = Object.toJSON(object);
+ if (!Object.isUndefined(value)) results.push(value);
+ });
+ return '[' + results.join(', ') + ']';
+ }
+});
+
+// use native browser JS 1.6 implementation if available
+if (Object.isFunction(Array.prototype.forEach))
+ Array.prototype._each = Array.prototype.forEach;
+
+if (!Array.prototype.indexOf) Array.prototype.indexOf = function(item, i) {
+ i || (i = 0);
+ var length = this.length;
+ if (i < 0) i = length + i;
+ for (; i < length; i++)
+ if (this[i] === item) return i;
+ return -1;
+};
+
+if (!Array.prototype.lastIndexOf) Array.prototype.lastIndexOf = function(item, i) {
+ i = isNaN(i) ? this.length : (i < 0 ? this.length + i : i) + 1;
+ v...
[truncated message content] |
|
From: <jev...@us...> - 2008-11-04 11:21:32
|
Revision: 761
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=761&view=rev
Author: jevonwright
Date: 2008-11-04 11:21:23 +0000 (Tue, 04 Nov 2008)
Log Message:
-----------
IElement.setAttribute("value") on an HtmlInput or IElement.setTextContent() on an HtmlTextArea will now call any attached onChange Javascript
Modified Paths:
--------------
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/IElementTest.java
trunk/jwebunit-commons-tests/src/main/resources/testcases/IElementTest/template.html
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitElementImpl.java
Modified: trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/IElementTest.java
===================================================================
--- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/IElementTest.java 2008-10-30 03:57:26 UTC (rev 760)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/IElementTest.java 2008-11-04 11:21:23 UTC (rev 761)
@@ -137,9 +137,11 @@
// get all input children
List<IElement> inputs = element.getElements("input");
- assertEquals(2, inputs.size()); // there should be two
+ assertEquals(4, inputs.size()); // there should be two
assertEquals("test3", inputs.get(0).getAttribute("value"));
assertEquals("Do nothing", inputs.get(1).getAttribute("value"));
+ assertEquals("initial", inputs.get(2).getAttribute("value"));
+ assertEquals("unchanged", inputs.get(3).getAttribute("value"));
// get parent through xpath
IElement parent = element.getElement("..");
@@ -148,4 +150,33 @@
}
+ /**
+ * Test that setting attributes manually (e.g setAttribute("value")
+ * properly calls any attached Javascript.
+ */
+ public void testAttributeJavascript() {
+ String testingText = new Date().toString();
+
+ {
+ IElement js1 = getElementById("js1");
+ IElement js2 = getElementById("js2");
+
+ assertEquals(js1.getAttribute("value"), "initial");
+ assertEquals(js2.getAttribute("value"), "unchanged");
+
+ // change js1's value
+ js1.setAttribute("value", testingText);
+ }
+
+ // refresh the elements and check they have changed
+ {
+ IElement js1 = getElementById("js1");
+ IElement js2 = getElementById("js2");
+
+ assertEquals(js1.getAttribute("value"), testingText);
+ assertEquals(js2.getAttribute("value"), testingText);
+ }
+
+ }
+
}
Modified: trunk/jwebunit-commons-tests/src/main/resources/testcases/IElementTest/template.html
===================================================================
--- trunk/jwebunit-commons-tests/src/main/resources/testcases/IElementTest/template.html 2008-10-30 03:57:26 UTC (rev 760)
+++ trunk/jwebunit-commons-tests/src/main/resources/testcases/IElementTest/template.html 2008-11-04 11:21:23 UTC (rev 761)
@@ -27,5 +27,11 @@
<li>four</li>
</ol>
+<hr>
+
+<p>A small Javascript test.</p>
+<input id="js1" value="initial" onChange="document.getElementById('js2').value=this.value;" />
+<input id="js2" value="unchanged" />
+
</body>
</html>
Modified: trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitElementImpl.java
===================================================================
--- trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitElementImpl.java 2008-10-30 03:57:26 UTC (rev 760)
+++ trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitElementImpl.java 2008-11-04 11:21:23 UTC (rev 761)
@@ -10,6 +10,8 @@
import com.gargoylesoftware.htmlunit.html.DomNode;
import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlInput;
+import com.gargoylesoftware.htmlunit.html.HtmlTextArea;
/**
* HtmlUnit implementation of IElement wrapper.
@@ -119,7 +121,7 @@
* @see net.sourceforge.jwebunit.api.IElement#setAttribute(java.lang.String)
*/
public void setAttribute(String string) {
- element.setAttribute(string, "1");
+ element.setAttributeValue(string, "1");
}
@@ -127,7 +129,12 @@
* @see net.sourceforge.jwebunit.api.IElement#setAttribute(java.lang.String, java.lang.String)
*/
public void setAttribute(String string, String value) {
- element.setAttribute(string, value);
+ if ("value".equals(string) && element instanceof HtmlInput) {
+ // for HtmlInputs, we want to run any onChange code if the value changes
+ ((HtmlInput) element).setValueAttribute(value);
+ } else {
+ element.setAttributeValue(string, value);
+ }
}
@@ -135,7 +142,11 @@
* @see net.sourceforge.jwebunit.api.IElement#setTextContent(java.lang.String)
*/
public void setTextContent(String value) {
- element.setTextContent(value);
+ if (element instanceof HtmlTextArea) {
+ ((HtmlTextArea) element).setText(value);
+ } else {
+ element.setTextContent(value);
+ }
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jev...@us...> - 2008-11-10 01:20:21
|
Revision: 762
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=762&view=rev
Author: jevonwright
Date: 2008-11-10 01:20:13 +0000 (Mon, 10 Nov 2008)
Log Message:
-----------
checking if a labeled field is empty will no longer fail if no "value" attribute is specified
Modified Paths:
--------------
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormAssertionsTest.java
trunk/jwebunit-commons-tests/src/main/resources/testcases/FormAssertionsTest/testPage.html
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java
Modified: trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormAssertionsTest.java
===================================================================
--- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormAssertionsTest.java 2008-11-04 11:21:23 UTC (rev 761)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormAssertionsTest.java 2008-11-10 01:20:13 UTC (rev 762)
@@ -325,5 +325,15 @@
assertEquals(getElementById("field1_id").getAttribute("value"), "four");
}
+
+ /**
+ * Even though the element has no value set (i.e. getAttribute("value") == null),
+ * it should still qualify as equal to an empty string.
+ */
+ public void testLabeledEmptyElement() {
+ beginAt("/testPage.html");
+ assertLabeledFieldEquals("label9", "");
+ }
+
}
Modified: trunk/jwebunit-commons-tests/src/main/resources/testcases/FormAssertionsTest/testPage.html
===================================================================
--- trunk/jwebunit-commons-tests/src/main/resources/testcases/FormAssertionsTest/testPage.html 2008-11-04 11:21:23 UTC (rev 761)
+++ trunk/jwebunit-commons-tests/src/main/resources/testcases/FormAssertionsTest/testPage.html 2008-11-10 01:20:13 UTC (rev 762)
@@ -97,6 +97,10 @@
</label>
<label id="label8" for="input8">Label 8</label>
<input id="input8" type="text" value="eight" />
+ <label id="label9">
+ Field 9:
+ <input name="label9_field1" /><!-- no "value" attribute -->
+ </label>
</td>
</tr>
</table>
Modified: trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java
===================================================================
--- trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java 2008-11-04 11:21:23 UTC (rev 761)
+++ trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java 2008-11-10 01:20:13 UTC (rev 762)
@@ -2693,7 +2693,7 @@
}
}
- Assert.assertEquals("value of field for label [" + identifier + "] should be [" + fieldText + "]", fieldText, value);
+ Assert.assertEquals("value of field for label [" + identifier + "] should be [" + fieldText + "]", fieldText, value == null ? "" : value);
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jev...@us...> - 2008-11-18 01:43:44
|
Revision: 763
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=763&view=rev
Author: jevonwright
Date: 2008-11-18 01:43:31 +0000 (Tue, 18 Nov 2008)
Log Message:
-----------
implementing patch fix for issue 2306967, thanks to r_monson
Modified Paths:
--------------
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java
trunk/src/changes/changes.xml
Modified: trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java
===================================================================
--- trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java 2008-11-10 01:20:13 UTC (rev 762)
+++ trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java 2008-11-18 01:43:31 UTC (rev 763)
@@ -756,7 +756,7 @@
}
if (getTestContext().hasProxyAuthorization()) {
creds.addProxyCredentials(getTestContext().getProxyUser(),
- getTestContext().getPassword(), getTestContext()
+ getTestContext().getProxyPasswd(), getTestContext()
.getProxyHost(), getTestContext().getProxyPort());
}
wc.setCredentialsProvider(creds);
Modified: trunk/src/changes/changes.xml
===================================================================
--- trunk/src/changes/changes.xml 2008-11-10 01:20:13 UTC (rev 762)
+++ trunk/src/changes/changes.xml 2008-11-18 01:43:31 UTC (rev 763)
@@ -27,6 +27,9 @@
navigator.userAgent is no longer null by default.
Test cases now use the Firefox 3.0 user agent as the default, rather than MSIE 4.0.
</action>
+ <action type="fix" dev="jevonwright" issue="2306967" due-to="r_monson">
+ Fixed proxy authentication bug in HtmlUnit implementation.
+ </action>
</release>
<release version="2.0" date="October 27, 2008">
<action type="update" dev="henryju">
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jev...@us...> - 2008-11-18 02:18:36
|
Revision: 764
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=764&view=rev
Author: jevonwright
Date: 2008-11-18 02:18:30 +0000 (Tue, 18 Nov 2008)
Log Message:
-----------
issue 1637716: adding assertMatch(regexp, text) and assertNotMatch(regexp, text) methods
Modified Paths:
--------------
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/IElementTest.java
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java
trunk/src/changes/changes.xml
Modified: trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/IElementTest.java
===================================================================
--- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/IElementTest.java 2008-11-18 01:43:31 UTC (rev 763)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/IElementTest.java 2008-11-18 02:18:30 UTC (rev 764)
@@ -143,6 +143,12 @@
assertEquals("initial", inputs.get(2).getAttribute("value"));
assertEquals("unchanged", inputs.get(3).getAttribute("value"));
+ // test regexps
+ assertMatch("init.+", inputs.get(2).getAttribute("value"));
+ assertNotMatch("^xinitial", inputs.get(2).getAttribute("value"));
+ assertMatch("test regexp with message", "init.+", inputs.get(2).getAttribute("value"));
+ assertNotMatch("test regexp with message", "$xinitial", inputs.get(2).getAttribute("value"));
+
// get parent through xpath
IElement parent = element.getElement("..");
assertNotNull(parent);
Modified: trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java
===================================================================
--- trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java 2008-11-18 01:43:31 UTC (rev 763)
+++ trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java 2008-11-18 02:18:30 UTC (rev 764)
@@ -428,7 +428,7 @@
}
/**
- * Assert that supplied regexp is matched.
+ * Assert that supplied regexp is matched in the text of a page.
*
* @param regexp
*/
@@ -438,8 +438,53 @@
Assert.fail("Expected rexexp not matched in response: [" + regexp
+ "]");
}
+
+ /**
+ * Assert a given string matches a given regular expression.
+ *
+ * @param regexp
+ * @param text
+ */
+ public void assertMatch(String regexp, String text) {
+ assertMatch("Expected rexexp '" + regexp + "' not matched in text '" + text + "'", regexp, text);
+ }
/**
+ * Assert a given string does not match a given regular expression.
+ *
+ * @param regexp
+ * @param text
+ */
+ public void assertNotMatch(String regexp, String text) {
+ assertNotMatch("Expected rexexp '" + regexp + "' matched in text '" + text + "'", regexp, text);
+ }
+
+
+ /**
+ * Assert a given string matches a given regular expression.
+ *
+ * @param regexp
+ * @param text
+ */
+ public void assertMatch(String message, String regexp, String text) {
+ RE re = getRE(regexp);
+ if (!re.match(text))
+ Assert.fail(message);
+ }
+
+ /**
+ * Assert a given string does not match a given regular expression.
+ *
+ * @param regexp
+ * @param text
+ */
+ public void assertNotMatch(String message, String regexp, String text) {
+ RE re = getRE(regexp);
+ if (re.match(text))
+ Assert.fail(message);
+ }
+
+ /**
* Assert that a web resource's value is not present.
*
* @param key web resource name
Modified: trunk/src/changes/changes.xml
===================================================================
--- trunk/src/changes/changes.xml 2008-11-18 01:43:31 UTC (rev 763)
+++ trunk/src/changes/changes.xml 2008-11-18 02:18:30 UTC (rev 764)
@@ -30,6 +30,9 @@
<action type="fix" dev="jevonwright" issue="2306967" due-to="r_monson">
Fixed proxy authentication bug in HtmlUnit implementation.
</action>
+ <action type="fix" dev="jevonwright" issue="1637716">
+ Added assertMatch(regexp, text) and assertNotMatch(regexp, text) methods.
+ </action>
</release>
<release version="2.0" date="October 27, 2008">
<action type="update" dev="henryju">
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jev...@us...> - 2008-11-18 02:55:31
|
Revision: 766
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=766&view=rev
Author: jevonwright
Date: 2008-11-18 02:55:26 +0000 (Tue, 18 Nov 2008)
Log Message:
-----------
issue 1277374: added assertCommentPresent(text) and assertCommentNotPresent(text) methods
Modified Paths:
--------------
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/IElementTest.java
trunk/jwebunit-commons-tests/src/main/resources/testcases/IElementTest/template.html
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/api/ITestingEngine.java
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java
trunk/jwebunit-selenium-plugin/src/main/java/net/sourceforge/jwebunit/selenium/SeleniumTestingEngineImpl.java
trunk/src/changes/changes.xml
Modified: trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/IElementTest.java
===================================================================
--- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/IElementTest.java 2008-11-18 02:22:58 UTC (rev 765)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/IElementTest.java 2008-11-18 02:55:26 UTC (rev 766)
@@ -185,4 +185,19 @@
}
+ /**
+ * Tests searching for comments.
+ */
+ public void testComments() {
+ // whitespace is ignored
+ assertCommentPresent("a comment");
+ assertCommentPresent("another comment");
+ assertCommentPresent(" a comment");
+ assertCommentPresent(" another comment ");
+
+ // but case is not
+ assertCommentNotPresent("A Comment");
+ assertCommentNotPresent("definitely not here");
+ }
+
}
Modified: trunk/jwebunit-commons-tests/src/main/resources/testcases/IElementTest/template.html
===================================================================
--- trunk/jwebunit-commons-tests/src/main/resources/testcases/IElementTest/template.html 2008-11-18 02:22:58 UTC (rev 765)
+++ trunk/jwebunit-commons-tests/src/main/resources/testcases/IElementTest/template.html 2008-11-18 02:55:26 UTC (rev 766)
@@ -33,5 +33,10 @@
<input id="js1" value="initial" onChange="document.getElementById('js2').value=this.value;" />
<input id="js2" value="unchanged" />
+<!--a comment-->
+<!--
+ another comment
+-->
+
</body>
</html>
Modified: trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/api/ITestingEngine.java
===================================================================
--- trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/api/ITestingEngine.java 2008-11-18 02:22:58 UTC (rev 765)
+++ trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/api/ITestingEngine.java 2008-11-18 02:55:26 UTC (rev 766)
@@ -900,4 +900,9 @@
*/
public void setIgnoreFailingStatusCodes(boolean ignore);
+ /**
+ * Get all the comments in a document, as a list of strings.
+ */
+ public List<String> getComments();
+
}
Modified: trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java
===================================================================
--- trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java 2008-11-18 02:22:58 UTC (rev 765)
+++ trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java 2008-11-18 02:55:26 UTC (rev 766)
@@ -2012,6 +2012,31 @@
Assert.assertFalse("Located element with xpath \"" + xpath + "\"",
getTestingEngine().hasElementByXPath(xpath));
}
+
+ /**
+ * Get all the comments in a document, as a list of strings.
+ */
+ public List<String> getComments() {
+ return getTestingEngine().getComments();
+ }
+
+ /**
+ * Assert that a comment is present.
+ *
+ * @param comment
+ */
+ public void assertCommentPresent(String comment) {
+ Assert.assertTrue("Comment present: '" + comment + "'", getComments().contains(comment.trim()));
+ }
+
+ /**
+ * Assert that a comment is not present.
+ *
+ * @param comment
+ */
+ public void assertCommentNotPresent(String comment) {
+ Assert.assertFalse("Comment not present: '" + comment + "'", getComments().contains(comment.trim()));
+ }
/**
* Assert that a given element contains specific text.
Modified: trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java
===================================================================
--- trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java 2008-11-18 02:22:58 UTC (rev 765)
+++ trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java 2008-11-18 02:55:26 UTC (rev 766)
@@ -42,6 +42,8 @@
import org.apache.regexp.RESyntaxException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
import com.gargoylesoftware.htmlunit.AlertHandler;
import com.gargoylesoftware.htmlunit.BrowserVersion;
@@ -62,6 +64,7 @@
import com.gargoylesoftware.htmlunit.WebWindowListener;
import com.gargoylesoftware.htmlunit.WebWindowNotFoundException;
import com.gargoylesoftware.htmlunit.html.ClickableElement;
+import com.gargoylesoftware.htmlunit.html.DomComment;
import com.gargoylesoftware.htmlunit.html.DomNode;
import com.gargoylesoftware.htmlunit.html.FrameWindow;
import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
@@ -890,6 +893,34 @@
}
/**
+ * Get all the comments in a document, as a list of strings.
+ */
+ public List<String> getComments() {
+ List<String> comments = new ArrayList<String>();
+ getComments(comments, ((HtmlPage) win.getEnclosedPage()));
+
+ return comments;
+ }
+
+ /**
+ * Recursively find comments for all child nodes.
+ *
+ * @param comments
+ * @param node
+ */
+ private void getComments(List<String> comments, Node node) {
+ NodeList nodes = node.getChildNodes();
+ for (int i = 0; i < nodes.getLength(); i++) {
+ Node n = nodes.item(i);
+ if (n instanceof DomComment) {
+ comments.add(((DomComment) n).getData().trim());
+ }
+ // add all child nodes
+ getComments(comments, n);
+ }
+ }
+
+ /**
* Return the first open window with the given title.
*/
private WebWindow getWindowByTitle(String title) {
Modified: trunk/jwebunit-selenium-plugin/src/main/java/net/sourceforge/jwebunit/selenium/SeleniumTestingEngineImpl.java
===================================================================
--- trunk/jwebunit-selenium-plugin/src/main/java/net/sourceforge/jwebunit/selenium/SeleniumTestingEngineImpl.java 2008-11-18 02:22:58 UTC (rev 765)
+++ trunk/jwebunit-selenium-plugin/src/main/java/net/sourceforge/jwebunit/selenium/SeleniumTestingEngineImpl.java 2008-11-18 02:55:26 UTC (rev 766)
@@ -720,4 +720,9 @@
throw new UnsupportedOperationException("setIgnoreFailingStatusCodes");
}
+ public boolean hasDomComment(String comment) {
+ // TODO implement method
+ throw new UnsupportedOperationException("hasDomComment");
+ }
+
}
Modified: trunk/src/changes/changes.xml
===================================================================
--- trunk/src/changes/changes.xml 2008-11-18 02:22:58 UTC (rev 765)
+++ trunk/src/changes/changes.xml 2008-11-18 02:55:26 UTC (rev 766)
@@ -30,9 +30,12 @@
<action type="fix" dev="jevonwright" issue="2306967" due-to="r_monson">
Fixed proxy authentication bug in HtmlUnit implementation.
</action>
- <action type="fix" dev="jevonwright" issue="1637716">
+ <action type="add" dev="jevonwright" issue="1637716">
Added assertMatch(regexp, text) and assertNotMatch(regexp, text) methods.
</action>
+ <action type="add" dev="jevonwright" issue="1277374">
+ Added assertCommentPresent(text) and assertCommentNotPresent(text) methods.
+ </action>
</release>
<release version="2.0" date="October 27, 2008">
<action type="update" dev="henryju">
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jev...@us...> - 2008-11-27 04:34:13
|
Revision: 772
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=772&view=rev
Author: jevonwright
Date: 2008-11-27 04:34:06 +0000 (Thu, 27 Nov 2008)
Log Message:
-----------
issue 2352851: adding assertTitleNotSame(...) method
cleaning up some regexp matching methods
Modified Paths:
--------------
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/HelloWorldTest.java
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java
Modified: trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/HelloWorldTest.java
===================================================================
--- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/HelloWorldTest.java 2008-11-24 03:09:49 UTC (rev 771)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/HelloWorldTest.java 2008-11-27 04:34:06 UTC (rev 772)
@@ -30,6 +30,7 @@
public void testTitle() {
assertTitleEquals("Hello, World!");
+ assertTitleNotSame("Goodbye, World!");
}
}
\ No newline at end of file
Modified: trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java
===================================================================
--- trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java 2008-11-24 03:09:49 UTC (rev 771)
+++ trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java 2008-11-27 04:34:06 UTC (rev 772)
@@ -318,14 +318,7 @@
* @param regexp Pattern to compare against
*/
public void assertHeaderMatches(String name, String regexp) {
- RE re = null;
- try {
- re = new RE(regexp, RE.MATCH_SINGLELINE);
- } catch (RESyntaxException e) {
- Assert.fail(e.toString());
- }
- Assert.assertTrue("Unable to match [" + regexp + "] in header [" + name + "]",
- re.match( getTestingEngine().getHeader(name) ));
+ assertMatch("Unable to match [" + regexp + "] in header [" + name + "]", regexp, getTestingEngine().getHeader(name));
}
/**
@@ -357,6 +350,17 @@
public void assertTitleEquals(String title) {
Assert.assertEquals(title, getTestingEngine().getPageTitle());
}
+
+ /**
+ * Assert title of current html page in conversation is not
+ * equal to another value.
+ *
+ * @param title
+ * unexpected title value
+ */
+ public void assertTitleNotSame(String title) {
+ Assert.assertNotSame(title, getTestingEngine().getPageTitle());
+ }
/**
* Assert title of current html page in conversation matches an expected regexp.
@@ -364,14 +368,7 @@
* @param regexp expected title regexp
*/
public void assertTitleMatch(String regexp) {
- RE re = null;
- try {
- re = new RE(regexp, RE.MATCH_SINGLELINE);
- } catch (RESyntaxException e) {
- Assert.fail(e.toString());
- }
- Assert.assertTrue("Unable to match [" + regexp + "] in title", re
- .match(getTestingEngine().getPageTitle()));
+ assertMatch("Unable to match [" + regexp + "] in title", regexp, getTestingEngine().getPageTitle());
}
/**
@@ -421,7 +418,7 @@
* @param text
*/
public void assertTextPresent(String text) {
- if (!(getTestingEngine().getPageText().indexOf(text) >= 0))
+ if (!(getTestingEngine().getPageText().contains(text)))
Assert.fail("Expected text not found in current page: [" + text
+ "]\n Page content was: ["
+ getTestingEngine().getPageText() + "]");
@@ -509,7 +506,7 @@
* @param text
*/
public void assertTextNotPresent(String text) {
- if (getTestingEngine().getPageText().indexOf(text) >= 0)
+ if (getTestingEngine().getPageText().contains(text))
Assert.fail("Text found in response when not expected: [" + text
+ "]");
}
@@ -520,10 +517,8 @@
* @param regexp
*/
public void assertNoMatch(String regexp) {
- RE re = getRE(regexp);
- if (re.match(getTestingEngine().getPageText()))
- Assert.fail("Regexp matched in response when not expected: ["
- + regexp + "]");
+ assertNotMatch("Regexp matched in response when not expected: [" + regexp + "]",
+ getTestingEngine().getPageText());
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jev...@us...> - 2008-11-30 23:54:29
|
Revision: 775
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=775&view=rev
Author: jevonwright
Date: 2008-11-30 23:54:23 +0000 (Sun, 30 Nov 2008)
Log Message:
-----------
issue 1674646: added setTimeout() method for HtmlUnit
Modified Paths:
--------------
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/ResponseServletTest.java
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/ResponseServlet.java
trunk/jwebunit-commons-tests/src/main/resources/testcases/ResponseServletTest/SimpleForm.html
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/api/ITestingEngine.java
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java
trunk/jwebunit-selenium-plugin/src/main/java/net/sourceforge/jwebunit/selenium/SeleniumTestingEngineImpl.java
trunk/src/changes/changes.xml
Modified: trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/ResponseServletTest.java
===================================================================
--- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/ResponseServletTest.java 2008-11-30 23:17:46 UTC (rev 774)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/ResponseServletTest.java 2008-11-30 23:54:23 UTC (rev 775)
@@ -4,6 +4,8 @@
******************************************************************************/
package net.sourceforge.jwebunit.tests;
+import java.net.SocketTimeoutException;
+
import junit.framework.Test;
import junit.framework.TestSuite;
import net.sourceforge.jwebunit.tests.util.JettySetup;
@@ -22,6 +24,7 @@
public void setUp() throws Exception {
super.setUp();
+ setTimeout(2); // specify a global timeout of 2 (must be set before the WebConnection is initialised)
setIgnoreFailingStatusCodes(true); // ignore failing status codes
getTestContext().setBaseUrl(HOST_PATH + "/ResponseServletTest");
}
@@ -73,5 +76,21 @@
submit();
assertResponseCode(501);
}
+
+ /**
+ * Issue 1674646: add support for specifying the timeout of pages
+ */
+ public void testTimeout() {
+ beginAt("/SimpleForm.html");
+ assertTitleEquals("response form");
+ setTextField("timeout", "10"); // server wait for 4 seconds
+ try {
+ submit();
+ } catch (RuntimeException e) {
+ assertTrue("timeout caused by SocketTimeoutException, but was " + e.getCause().getClass(), e.getCause() instanceof SocketTimeoutException);
+ }
+ assertTextNotPresent("hello, world!"); // this will only display if the timeout is completed
+
+ }
}
Modified: trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/ResponseServlet.java
===================================================================
--- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/ResponseServlet.java 2008-11-30 23:17:46 UTC (rev 774)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/ResponseServlet.java 2008-11-30 23:54:23 UTC (rev 775)
@@ -34,6 +34,14 @@
response.setContentType( request.getParameter("content-type") );
}
+ // wait for a timeout?
+ if (request.getParameter("timeout") != null && request.getParameter("timeout").length() > 0) {
+ int seconds = Integer.parseInt(request.getParameter("timeout"));
+ long start = System.nanoTime();
+ while (System.nanoTime() < start + (seconds * 1000 * 1000))
+ ; // wait
+ }
+
// lets set some headers
response.setHeader("Test", "test2");
response.setHeader("Header-Added", new java.util.Date().toString());
Modified: trunk/jwebunit-commons-tests/src/main/resources/testcases/ResponseServletTest/SimpleForm.html
===================================================================
--- trunk/jwebunit-commons-tests/src/main/resources/testcases/ResponseServletTest/SimpleForm.html 2008-11-30 23:17:46 UTC (rev 774)
+++ trunk/jwebunit-commons-tests/src/main/resources/testcases/ResponseServletTest/SimpleForm.html 2008-11-30 23:54:23 UTC (rev 775)
@@ -7,6 +7,7 @@
<ol>
<li>Desired status: <input type="text" name="status" value="" /></li>
<li>Desired content-type: <input type="text" name="content-type" value="" /></li>
+ <li>Desired timeout: <input type="text" name="timeout" value="" /></li>
<li><input type="submit" /></li>
</ol>
</form>
Modified: trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/api/ITestingEngine.java
===================================================================
--- trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/api/ITestingEngine.java 2008-11-30 23:17:46 UTC (rev 774)
+++ trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/api/ITestingEngine.java 2008-11-30 23:54:23 UTC (rev 775)
@@ -903,6 +903,15 @@
/**
* Get all the comments in a document, as a list of strings.
*/
- public List<String> getComments();
-
+ public List<String> getComments();
+
+ /**
+ * Set the timeout for the request. A timeout of 0 means
+ * an infinite timeout.
+ *
+ * @param seconds the seconds in which to timeout, or 0 for infinite
+ * wait (the default).
+ */
+ public void setTimeout(int seconds);
+
}
Modified: trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java
===================================================================
--- trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java 2008-11-30 23:17:46 UTC (rev 774)
+++ trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java 2008-11-30 23:54:23 UTC (rev 775)
@@ -3337,6 +3337,17 @@
public Image getImage(String imageSrc, String imageAlt) {
return validateImage(imageSrc, imageAlt, null);
}
+
+ /**
+ * Set the timeout for the request. A timeout of 0 means
+ * an infinite timeout.
+ *
+ * @param seconds the seconds in which to timeout, or 0 for infinite
+ * wait (the default).
+ */
+ public void setTimeout(int seconds) {
+ getTestingEngine().setTimeout(seconds);
+ }
private Image validateImage(String imageSrc, String imageAlt, File out) {
assertImagePresent(imageSrc, imageAlt);
Modified: trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java
===================================================================
--- trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java 2008-11-30 23:17:46 UTC (rev 774)
+++ trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java 2008-11-30 23:54:23 UTC (rev 775)
@@ -152,6 +152,11 @@
*/
private boolean ignoreFailingStatusCodes = false;
+ /**
+ * Do we provide a timeout limit (in seconds)? Default 0 = unlimited timeout.
+ */
+ private int timeout = 0;
+
// Implementation of IJWebUnitDialog
/**
@@ -739,6 +744,7 @@
wc.setThrowExceptionOnScriptError(true);
wc.setRedirectEnabled(true);
wc.setRefreshHandler(new ImmediateRefreshHandler());
+ wc.setTimeout(timeout);
DefaultCredentialsProvider creds = new DefaultCredentialsProvider();
if (getTestContext().hasAuthorization()) {
creds.addCredentials(getTestContext().getUser(), getTestContext()
@@ -2290,4 +2296,11 @@
this.defaultBrowserVersion = defaultBrowserVersion;
}
+ public void setTimeout(int seconds) {
+ if (wc != null && wc.getWebConnection() != null) {
+ throw new IllegalArgumentException("Cannot set the timeout when the WebConnection has already been created.");
+ }
+ timeout = seconds;
+ }
+
}
Modified: trunk/jwebunit-selenium-plugin/src/main/java/net/sourceforge/jwebunit/selenium/SeleniumTestingEngineImpl.java
===================================================================
--- trunk/jwebunit-selenium-plugin/src/main/java/net/sourceforge/jwebunit/selenium/SeleniumTestingEngineImpl.java 2008-11-30 23:17:46 UTC (rev 774)
+++ trunk/jwebunit-selenium-plugin/src/main/java/net/sourceforge/jwebunit/selenium/SeleniumTestingEngineImpl.java 2008-11-30 23:54:23 UTC (rev 775)
@@ -730,4 +730,9 @@
throw new UnsupportedOperationException("getComments");
}
+ public void setTimeout(int seconds) {
+ // TODO implement method
+ throw new UnsupportedOperationException("setTimeout");
+ }
+
}
Modified: trunk/src/changes/changes.xml
===================================================================
--- trunk/src/changes/changes.xml 2008-11-30 23:17:46 UTC (rev 774)
+++ trunk/src/changes/changes.xml 2008-11-30 23:54:23 UTC (rev 775)
@@ -36,6 +36,9 @@
<action type="add" dev="jevonwright" issue="1277374">
Added assertCommentPresent(text) and assertCommentNotPresent(text) methods.
</action>
+ <action type="add" dev="jevonwright" issue="1674646">
+ Added setTimeout() method.
+ </action>
</release>
<release version="2.0" date="October 27, 2008">
<action type="update" dev="henryju">
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <he...@us...> - 2008-12-07 22:22:13
|
Revision: 777
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=777&view=rev
Author: henryju
Date: 2008-12-07 21:42:49 +0000 (Sun, 07 Dec 2008)
Log Message:
-----------
Fixed setTimeout test:
1) System.nanoTime() seems to not works fine on my computer (Linux)
2) HtmlUnit timeout is expressed in milliseconds
Modified Paths:
--------------
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/ResponseServletTest.java
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/ResponseServlet.java
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/api/ITestingEngine.java
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java
trunk/jwebunit-selenium-plugin/src/main/java/net/sourceforge/jwebunit/selenium/SeleniumTestingEngineImpl.java
Modified: trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/ResponseServletTest.java
===================================================================
--- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/ResponseServletTest.java 2008-12-07 19:30:41 UTC (rev 776)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/ResponseServletTest.java 2008-12-07 21:42:49 UTC (rev 777)
@@ -24,7 +24,6 @@
public void setUp() throws Exception {
super.setUp();
- setTimeout(2); // specify a global timeout of 2 (must be set before the WebConnection is initialised)
setIgnoreFailingStatusCodes(true); // ignore failing status codes
getTestContext().setBaseUrl(HOST_PATH + "/ResponseServletTest");
}
@@ -81,16 +80,30 @@
* Issue 1674646: add support for specifying the timeout of pages
*/
public void testTimeout() {
+ //Test that timeout was fired
+
+ setTimeout(500); // specify a global timeout of 0.5 seconds (must be set before the WebConnection is initialised)
beginAt("/SimpleForm.html");
assertTitleEquals("response form");
- setTextField("timeout", "10"); // server wait for 4 seconds
+ setTextField("timeout", "1"); // server wait for 1 seconds
+ boolean ok = false;
try {
submit();
} catch (RuntimeException e) {
assertTrue("timeout caused by SocketTimeoutException, but was " + e.getCause().getClass(), e.getCause() instanceof SocketTimeoutException);
+ ok = true;
}
- assertTextNotPresent("hello, world!"); // this will only display if the timeout is completed
-
+ assertTrue("Timeout wasn't fired", ok);
+ closeBrowser();
+
+ //Test that timeout wasn't fired
+
+ setTimeout(2000); // specify a global timeout of 2 seconds (must be set before the WebConnection is initialised)
+ beginAt("/SimpleForm.html");
+ assertTitleEquals("response form");
+ setTextField("timeout", "1"); // server wait for 1 seconds
+ submit();
+ assertTextPresent("hello, world!");
}
}
Modified: trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/ResponseServlet.java
===================================================================
--- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/ResponseServlet.java 2008-12-07 19:30:41 UTC (rev 776)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/ResponseServlet.java 2008-12-07 21:42:49 UTC (rev 777)
@@ -37,8 +37,8 @@
// wait for a timeout?
if (request.getParameter("timeout") != null && request.getParameter("timeout").length() > 0) {
int seconds = Integer.parseInt(request.getParameter("timeout"));
- long start = System.nanoTime();
- while (System.nanoTime() < start + (seconds * 1000 * 1000))
+ long start = System.currentTimeMillis();
+ while (System.currentTimeMillis() < start + (seconds * 1000))
; // wait
}
Modified: trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/api/ITestingEngine.java
===================================================================
--- trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/api/ITestingEngine.java 2008-12-07 19:30:41 UTC (rev 776)
+++ trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/api/ITestingEngine.java 2008-12-07 21:42:49 UTC (rev 777)
@@ -909,9 +909,9 @@
* Set the timeout for the request. A timeout of 0 means
* an infinite timeout.
*
- * @param seconds the seconds in which to timeout, or 0 for infinite
+ * @param milliseconds the milliseconds in which to timeout, or 0 for infinite
* wait (the default).
*/
- public void setTimeout(int seconds);
+ public void setTimeout(int milliseconds);
}
Modified: trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java
===================================================================
--- trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java 2008-12-07 19:30:41 UTC (rev 776)
+++ trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java 2008-12-07 21:42:49 UTC (rev 777)
@@ -2296,11 +2296,11 @@
this.defaultBrowserVersion = defaultBrowserVersion;
}
- public void setTimeout(int seconds) {
+ public void setTimeout(int milliseconds) {
if (wc != null && wc.getWebConnection() != null) {
throw new IllegalArgumentException("Cannot set the timeout when the WebConnection has already been created.");
}
- timeout = seconds;
+ timeout = milliseconds;
}
}
Modified: trunk/jwebunit-selenium-plugin/src/main/java/net/sourceforge/jwebunit/selenium/SeleniumTestingEngineImpl.java
===================================================================
--- trunk/jwebunit-selenium-plugin/src/main/java/net/sourceforge/jwebunit/selenium/SeleniumTestingEngineImpl.java 2008-12-07 19:30:41 UTC (rev 776)
+++ trunk/jwebunit-selenium-plugin/src/main/java/net/sourceforge/jwebunit/selenium/SeleniumTestingEngineImpl.java 2008-12-07 21:42:49 UTC (rev 777)
@@ -730,7 +730,7 @@
throw new UnsupportedOperationException("getComments");
}
- public void setTimeout(int seconds) {
+ public void setTimeout(int milliseconds) {
// TODO implement method
throw new UnsupportedOperationException("setTimeout");
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <he...@us...> - 2008-12-07 22:45:18
|
Revision: 778
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=778&view=rev
Author: henryju
Date: 2008-12-07 22:45:13 +0000 (Sun, 07 Dec 2008)
Log Message:
-----------
[2367256] Generated module documentation had broken links
Modified Paths:
--------------
trunk/jwebunit-commons-tests/src/site/site.xml
trunk/jwebunit-core/src/site/site.xml
trunk/jwebunit-htmlunit-plugin/src/site/site.xml
trunk/jwebunit-selenium-plugin/src/site/site.xml
trunk/pom.xml
trunk/src/site/site.xml
Added Paths:
-----------
trunk/jwebunit-webtestcase-generator/src/site/
trunk/jwebunit-webtestcase-generator/src/site/site.xml
Modified: trunk/jwebunit-commons-tests/src/site/site.xml
===================================================================
--- trunk/jwebunit-commons-tests/src/site/site.xml 2008-12-07 21:42:49 UTC (rev 777)
+++ trunk/jwebunit-commons-tests/src/site/site.xml 2008-12-07 22:45:13 UTC (rev 778)
@@ -1,13 +1,6 @@
<?xml version="1.0"?>
<project name="JWebUnit">
<body>
- <menu ref="parent" />
- <menu name="Sourceforge">
- <item name="Project page"
- href="http://sourceforge.net/projects/jwebunit" />
- <item name="Download"
- href="http://sourceforge.net/projects/jwebunit/files" />
- </menu>
<menu ref="reports" />
</body>
</project>
Modified: trunk/jwebunit-core/src/site/site.xml
===================================================================
--- trunk/jwebunit-core/src/site/site.xml 2008-12-07 21:42:49 UTC (rev 777)
+++ trunk/jwebunit-core/src/site/site.xml 2008-12-07 22:45:13 UTC (rev 778)
@@ -1,13 +1,6 @@
<?xml version="1.0"?>
<project name="JWebUnit">
<body>
- <menu ref="parent" />
- <menu name="Sourceforge">
- <item name="Project page"
- href="http://sourceforge.net/projects/jwebunit" />
- <item name="Download"
- href="http://sourceforge.net/projects/jwebunit/files" />
- </menu>
<menu ref="reports" />
</body>
</project>
Modified: trunk/jwebunit-htmlunit-plugin/src/site/site.xml
===================================================================
--- trunk/jwebunit-htmlunit-plugin/src/site/site.xml 2008-12-07 21:42:49 UTC (rev 777)
+++ trunk/jwebunit-htmlunit-plugin/src/site/site.xml 2008-12-07 22:45:13 UTC (rev 778)
@@ -1,13 +1,6 @@
<?xml version="1.0"?>
<project name="JWebUnit">
<body>
- <menu ref="parent" />
- <menu name="Sourceforge">
- <item name="Project page"
- href="http://sourceforge.net/projects/jwebunit" />
- <item name="Download"
- href="http://sourceforge.net/projects/jwebunit/files" />
- </menu>
<menu ref="reports" />
</body>
</project>
Modified: trunk/jwebunit-selenium-plugin/src/site/site.xml
===================================================================
--- trunk/jwebunit-selenium-plugin/src/site/site.xml 2008-12-07 21:42:49 UTC (rev 777)
+++ trunk/jwebunit-selenium-plugin/src/site/site.xml 2008-12-07 22:45:13 UTC (rev 778)
@@ -1,13 +1,6 @@
<?xml version="1.0"?>
<project name="JWebUnit">
<body>
- <menu ref="parent" />
- <menu name="Sourceforge">
- <item name="Project page"
- href="http://sourceforge.net/projects/jwebunit" />
- <item name="Download"
- href="http://sourceforge.net/projects/jwebunit/files" />
- </menu>
<menu ref="reports" />
</body>
</project>
Added: trunk/jwebunit-webtestcase-generator/src/site/site.xml
===================================================================
--- trunk/jwebunit-webtestcase-generator/src/site/site.xml (rev 0)
+++ trunk/jwebunit-webtestcase-generator/src/site/site.xml 2008-12-07 22:45:13 UTC (rev 778)
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<project name="JWebUnit">
+ <body>
+ <menu ref="reports" />
+ </body>
+</project>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2008-12-07 21:42:49 UTC (rev 777)
+++ trunk/pom.xml 2008-12-07 22:45:13 UTC (rev 778)
@@ -251,6 +251,12 @@
<artifactId>exec-maven-plugin</artifactId>
<version>1.1-beta-1</version>
</plugin>
+ <plugin>
+ <inherited>true</inherited>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-site-plugin</artifactId>
+ <version>2.0-beta-7</version>
+ </plugin>
</plugins>
</pluginManagement>
</build>
Modified: trunk/src/site/site.xml
===================================================================
--- trunk/src/site/site.xml 2008-12-07 21:42:49 UTC (rev 777)
+++ trunk/src/site/site.xml 2008-12-07 22:45:13 UTC (rev 778)
@@ -27,14 +27,14 @@
href="http://htmlunit.sourceforge.net" />
<item name="Selenium" href="http://openqa.org/selenium-rc/" />
</links>
- <menu name="JWebUnit">
- <item name="Home" href="/index.html" />
+ <menu name="JWebUnit" inherit="top">
+ <item name="Home" href="index.html" />
</menu>
- <menu name="User documentation">
- <item name="Installation" href="/installation.html"
+ <menu name="User documentation" inherit="top">
+ <item name="Installation" href="installation.html"
collapse="true">
</item>
- <item name="Quick start" href="/quickstart.html"
+ <item name="Quick start" href="quickstart.html"
collapse="true">
<item name="Creating a TestCase"
href="#Creating a TestCase" />
@@ -53,12 +53,12 @@
<item name="Using Property Files"
href="#Using Property Files to Validate Content" />
</item>
- <item name="Articles" href="/articles.html" />
- <item name="FAQ" href="/faq.html" />
+ <item name="Articles" href="articles.html" />
+ <item name="FAQ" href="faq.html" />
</menu>
- <menu name="Developper documentation">
+ <menu name="Developper documentation" inherit="top">
<item name="Building JWebUnit with Maven 2"
- href="/building-maven.html" collapse="true">
+ href="building-maven.html" collapse="true">
<item name="Installing" href="#Installing_Maven" />
<item name="Using" href="#Using_Maven" />
<item name="Building"
@@ -74,16 +74,16 @@
</item>
<item name="How-To contribute"
- href="/how-to-contribute.html" collapse="true">
+ href="how-to-contribute.html" collapse="true">
</item>
</menu>
- <menu name="Sourceforge">
+ <menu name="Sourceforge" inherit="top">
<item name="Project page"
href="http://sourceforge.net/projects/jwebunit" />
<item name="Download"
href="http://sourceforge.net/projects/jwebunit/files" />
</menu>
- <menu ref="modules" />
+ <menu ref="modules" inherit="top"/>
<menu ref="reports" />
</body>
</project>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|