From 0f560ae9c35c5a9f3b65cd95130b316d40c687c8 Mon Sep 17 00:00:00 2001 From: lresende Date: Mon, 22 Feb 2010 20:44:24 +0000 Subject: Moving to most recent release of HtmlUnit (2.6) and adjusting tests based on api changes git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@915053 13f79535-47bb-0310-9956-ffa450edef68 --- .../itest/distribution/webapp-helloworld-bpel/pom.xml | 4 ++-- .../distribution/webapp-helloworld-js-client/pom.xml | 4 ++-- .../itest/distribution/webapp-helloworld-jsf/pom.xml | 4 ++-- .../itest/distribution/webapp-helloworld-jsp/pom.xml | 4 ++-- .../src/test/java/itest/HelloworldTestCase.java | 15 +++++++++------ .../distribution/webapp-helloworld-servlet/pom.xml | 4 ++-- .../src/test/java/itest/HelloworldTestCase.java | 9 ++------- .../distribution/webapp-helloworld-stripes/pom.xml | 4 ++-- .../src/test/java/itest/HelloworldTestCase.java | 18 +++++++++--------- 9 files changed, 32 insertions(+), 34 deletions(-) (limited to 'sca-java-2.x/trunk/itest/distribution') diff --git a/sca-java-2.x/trunk/itest/distribution/webapp-helloworld-bpel/pom.xml b/sca-java-2.x/trunk/itest/distribution/webapp-helloworld-bpel/pom.xml index b03ff03bc7..203cc9efff 100644 --- a/sca-java-2.x/trunk/itest/distribution/webapp-helloworld-bpel/pom.xml +++ b/sca-java-2.x/trunk/itest/distribution/webapp-helloworld-bpel/pom.xml @@ -59,9 +59,9 @@ - htmlunit + net.sourceforge.htmlunit htmlunit - 1.9 + 2.6 test diff --git a/sca-java-2.x/trunk/itest/distribution/webapp-helloworld-js-client/pom.xml b/sca-java-2.x/trunk/itest/distribution/webapp-helloworld-js-client/pom.xml index bb16e5a441..9d3261913e 100644 --- a/sca-java-2.x/trunk/itest/distribution/webapp-helloworld-js-client/pom.xml +++ b/sca-java-2.x/trunk/itest/distribution/webapp-helloworld-js-client/pom.xml @@ -59,9 +59,9 @@ - htmlunit + net.sourceforge.htmlunit htmlunit - 1.9 + 2.6 test diff --git a/sca-java-2.x/trunk/itest/distribution/webapp-helloworld-jsf/pom.xml b/sca-java-2.x/trunk/itest/distribution/webapp-helloworld-jsf/pom.xml index 7d398366ed..7c2c6536b6 100644 --- a/sca-java-2.x/trunk/itest/distribution/webapp-helloworld-jsf/pom.xml +++ b/sca-java-2.x/trunk/itest/distribution/webapp-helloworld-jsf/pom.xml @@ -59,9 +59,9 @@ - htmlunit + net.sourceforge.htmlunit htmlunit - 1.9 + 2.6 test diff --git a/sca-java-2.x/trunk/itest/distribution/webapp-helloworld-jsp/pom.xml b/sca-java-2.x/trunk/itest/distribution/webapp-helloworld-jsp/pom.xml index e7d37fb886..795e709fac 100644 --- a/sca-java-2.x/trunk/itest/distribution/webapp-helloworld-jsp/pom.xml +++ b/sca-java-2.x/trunk/itest/distribution/webapp-helloworld-jsp/pom.xml @@ -59,9 +59,9 @@ - htmlunit + net.sourceforge.htmlunit htmlunit - 1.9 + 2.6 test diff --git a/sca-java-2.x/trunk/itest/distribution/webapp-helloworld-jsp/src/test/java/itest/HelloworldTestCase.java b/sca-java-2.x/trunk/itest/distribution/webapp-helloworld-jsp/src/test/java/itest/HelloworldTestCase.java index 2be60be081..e624cb8411 100644 --- a/sca-java-2.x/trunk/itest/distribution/webapp-helloworld-jsp/src/test/java/itest/HelloworldTestCase.java +++ b/sca-java-2.x/trunk/itest/distribution/webapp-helloworld-jsp/src/test/java/itest/HelloworldTestCase.java @@ -29,6 +29,7 @@ import org.junit.Test; import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException; import com.gargoylesoftware.htmlunit.WebClient; +import com.gargoylesoftware.htmlunit.html.HtmlElement; import com.gargoylesoftware.htmlunit.html.HtmlPage; import com.gargoylesoftware.htmlunit.html.HtmlParagraph; @@ -39,12 +40,14 @@ public class HelloworldTestCase { @Test public void testA() throws FailingHttpStatusCodeException, MalformedURLException, IOException { HtmlPage page = (HtmlPage)new WebClient().getPage("http://localhost:8085/helloworld-jsp"); - Iterator ss = page.getAllHtmlChildElements(); - ss.next(); - ss.next(); - ss.next(); - HtmlParagraph p = (HtmlParagraph)ss.next(); - assertEquals("Hello world", p.asText()); + Iterator ss = page.getAllHtmlChildElements().iterator(); + while(ss.hasNext()) { + HtmlElement htmlElement = (HtmlElement) ss.next(); + if( htmlElement instanceof HtmlParagraph) { + assertEquals("Hello world", htmlElement.asText()); + break; + } + } } } diff --git a/sca-java-2.x/trunk/itest/distribution/webapp-helloworld-servlet/pom.xml b/sca-java-2.x/trunk/itest/distribution/webapp-helloworld-servlet/pom.xml index a0b973e426..c410309d2a 100644 --- a/sca-java-2.x/trunk/itest/distribution/webapp-helloworld-servlet/pom.xml +++ b/sca-java-2.x/trunk/itest/distribution/webapp-helloworld-servlet/pom.xml @@ -59,9 +59,9 @@ - htmlunit + net.sourceforge.htmlunit htmlunit - 1.9 + 2.6 test diff --git a/sca-java-2.x/trunk/itest/distribution/webapp-helloworld-servlet/src/test/java/itest/HelloworldTestCase.java b/sca-java-2.x/trunk/itest/distribution/webapp-helloworld-servlet/src/test/java/itest/HelloworldTestCase.java index bed840b44a..61d722da1f 100644 --- a/sca-java-2.x/trunk/itest/distribution/webapp-helloworld-servlet/src/test/java/itest/HelloworldTestCase.java +++ b/sca-java-2.x/trunk/itest/distribution/webapp-helloworld-servlet/src/test/java/itest/HelloworldTestCase.java @@ -26,7 +26,6 @@ import java.net.MalformedURLException; import org.junit.Test; import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException; -import com.gargoylesoftware.htmlunit.UnexpectedPage; import com.gargoylesoftware.htmlunit.WebClient; import com.gargoylesoftware.htmlunit.html.HtmlButton; import com.gargoylesoftware.htmlunit.html.HtmlForm; @@ -48,13 +47,9 @@ public class HelloworldTestCase { HtmlButton button = (HtmlButton) form.getButtonsByName("submit").get(0); - Object foo = button.click(); + HtmlPage pageResponse = (HtmlPage) button.click(); - // TODO: something up with getting the response but this works: - UnexpectedPage p = (UnexpectedPage) foo; - String s = new String(p.getWebResponse().getResponseBody()); - - assertTrue(s.endsWith("Hello petra")); + assertTrue(pageResponse.getWebResponse().getContentAsString().endsWith("Hello petra")); } } diff --git a/sca-java-2.x/trunk/itest/distribution/webapp-helloworld-stripes/pom.xml b/sca-java-2.x/trunk/itest/distribution/webapp-helloworld-stripes/pom.xml index 7531f1b7b6..a9f7762fd7 100644 --- a/sca-java-2.x/trunk/itest/distribution/webapp-helloworld-stripes/pom.xml +++ b/sca-java-2.x/trunk/itest/distribution/webapp-helloworld-stripes/pom.xml @@ -59,9 +59,9 @@ - htmlunit + net.sourceforge.htmlunit htmlunit - 1.9 + 2.6 test diff --git a/sca-java-2.x/trunk/itest/distribution/webapp-helloworld-stripes/src/test/java/itest/HelloworldTestCase.java b/sca-java-2.x/trunk/itest/distribution/webapp-helloworld-stripes/src/test/java/itest/HelloworldTestCase.java index 743ab054c8..53aaa54aaf 100644 --- a/sca-java-2.x/trunk/itest/distribution/webapp-helloworld-stripes/src/test/java/itest/HelloworldTestCase.java +++ b/sca-java-2.x/trunk/itest/distribution/webapp-helloworld-stripes/src/test/java/itest/HelloworldTestCase.java @@ -29,6 +29,7 @@ import org.junit.Test; import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException; import com.gargoylesoftware.htmlunit.WebClient; +import com.gargoylesoftware.htmlunit.html.HtmlElement; import com.gargoylesoftware.htmlunit.html.HtmlPage; import com.gargoylesoftware.htmlunit.html.HtmlParagraph; @@ -39,15 +40,14 @@ public class HelloworldTestCase { @Test public void testA() throws FailingHttpStatusCodeException, MalformedURLException, IOException { HtmlPage page = (HtmlPage)new WebClient().getPage("http://localhost:8085/helloworld-stripes"); - Iterator ss = page.getAllHtmlChildElements(); - Object o1= ss.next(); - Object o2= ss.next(); - Object o3= ss.next(); - Object o4= ss.next(); - Object o5= ss.next(); - Object o6= ss.next(); - HtmlParagraph p = (HtmlParagraph)ss.next(); - assertEquals("sayHello returns: Hello world", p.asText()); + Iterator ss = page.getAllHtmlChildElements().iterator(); + while(ss.hasNext()) { + HtmlElement htmlElement = (HtmlElement) ss.next(); + if( htmlElement instanceof HtmlParagraph) { + assertEquals("sayHello returns: Hello world", htmlElement.asText()); + break; + } + } } } -- cgit v1.2.3