[JWebUnit-development] SF.net SVN: jwebunit:[914] trunk
Brought to you by:
henryju
|
From: <he...@us...> - 2011-08-22 09:27:45
|
Revision: 914
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=914&view=rev
Author: henryju
Date: 2011-08-22 09:27:38 +0000 (Mon, 22 Aug 2011)
Log Message:
-----------
[3395872] HtmlUnitTestingEngineImpl.gotoPage no longer returns the failing status. Fix and add tests. Thanks to Tim Pizey for reporting.
Modified Paths:
--------------
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/JWebUnitAPITestCase.java
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/NavigationTest.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/JWebUnitAPITestCase.java
===================================================================
--- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/JWebUnitAPITestCase.java 2011-08-18 13:18:44 UTC (rev 913)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/JWebUnitAPITestCase.java 2011-08-22 09:27:38 UTC (rev 914)
@@ -91,17 +91,19 @@
assertException(AssertionError.class, methodName, args);
}
- public void assertException(Class<?> exceptionClass, String methodName,
+ public <G extends Throwable> G assertException(Class<G> exceptionClass, String methodName,
Object[] args) {
StaticMethodInvoker invoker = new StaticMethodInvoker(JWebUnit.class, methodName, args);
try {
invoker.invoke();
fail("Expected test failure did not occur for method: "
+ methodName);
+ return null; //never called
} catch (InvocationTargetException e) {
assertTrue("Expected " + exceptionClass.getName() + "but was "
+ e.getTargetException().getClass().getName(),
exceptionClass.isInstance(e.getTargetException()));
+ return (G) e.getTargetException();
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e.getMessage());
Modified: trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/NavigationTest.java
===================================================================
--- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/NavigationTest.java 2011-08-18 13:18:44 UTC (rev 913)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/NavigationTest.java 2011-08-22 09:27:38 UTC (rev 914)
@@ -76,12 +76,11 @@
@Test
public void testInvalidBeginAt() {
-
//the testing engines should throw an exception if a 404 Error is found.
- assertException(TestingEngineResponseException.class, "beginAt", new Object[] {"/nosuchresource.html"});
-
+ TestingEngineResponseException e = assertException(TestingEngineResponseException.class, "beginAt", new Object[] {"/nosuchresource.html"});
+ assertEquals(404, e.getHttpStatusCode());
}
-
+
@Test
public void testClickLinkWithText() {
beginAt("/pageWithLink.html");
@@ -170,7 +169,7 @@
gotoPage("/targetPage2.html");
assertTitleEquals("targetPage2");
}
-
+
@Test
public void testGotoPageAbsolute() {
beginAt("/targetPage.html");
@@ -179,6 +178,14 @@
assertTitleEquals("targetPage2");
}
+ @Test
+ public void testInvalidGotoPage() {
+ beginAt("/targetPage.html");
+ //the testing engines should throw an exception if a 404 Error is found.
+ TestingEngineResponseException e = assertException(TestingEngineResponseException.class, "gotoPage", new Object[] {"/nosuchresource.html"});
+ assertEquals(404, e.getHttpStatusCode());
+ }
+
//For bug 726143
@Test
public void testLinkWithEscapedText() {
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 2011-08-18 13:18:44 UTC (rev 913)
+++ trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java 2011-08-22 09:27:38 UTC (rev 914)
@@ -259,7 +259,7 @@
} catch (FailingHttpStatusCodeException ex) {
// only throw exception if necessary
if (!ignoreFailingStatusCodes) {
- throw new TestingEngineResponseException(
+ throw new TestingEngineResponseException(ex.getStatusCode(),
"unexpected status code ["+ex.getStatusCode()+"] at URL: ["+initialURL+"]", ex);
}
} catch (IOException ex) {
Modified: trunk/src/changes/changes.xml
===================================================================
--- trunk/src/changes/changes.xml 2011-08-18 13:18:44 UTC (rev 913)
+++ trunk/src/changes/changes.xml 2011-08-22 09:27:38 UTC (rev 914)
@@ -30,6 +30,12 @@
</author>
</properties>
<body>
+ <release version="3.0.1" date="UNKNOW" description="Minor fixes">
+ <action type="fix" dev="henryju" issue="3395872" due-to="Tim Pizey">
+ HtmlUnitTestingEngineImpl.gotoPage no longer returns the failing status. Broken since 2.5 after applying
+ patch from issue 1864365.
+ </action>
+ </release>
<release version="3.0" date="August 18, 2011" description="Updated all internals to JUnit 4. HtmlUnit 2.9.">
<action type="update" dev="henryju">
Updated to HtmlUnit 2.9.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|