From: Arun G. <aru...@gm...> - 2013-12-13 01:23:36
|
Just starting to replace HttpUnit with HtmlUnit and liking the clean API so far. The original test source is: WebConversation conv = new WebConversation(); GetMethodWebRequest getRequest = new GetMethodWebRequest(base + "/TestServlet"); WebResponse getResponse = conv.getResponse(getRequest); assertTrue(getResponse.getText().contains("<title>Servlet url-pattern in web.xml</title>")); and replacing it with: WebClient webClient = new WebClient(); HtmlPage page = webClient.getPage(base + "/TestServlet"); assertEquals("Servlet url-pattern in web.xml", page.getTitleText()); I've added the following dependency: <dependency> <groupId>net.sourceforge.htmlunit</groupId> <artifactId>htmlunit</artifactId> <version>2.13</version> <scope>test</scope> </dependency> But running this test gives the following error: java.lang.NoSuchMethodError: org.apache.http.impl.client.AbstractHttpClient.execute(Lorg/apache/http/HttpHost;Lorg/apache/http/HttpRequest;Lorg/apache/http/protocol/HttpContext;)Lorg/apache/http/client/methods/CloseableHttpResponse; at com.gargoylesoftware.htmlunit.HttpWebConnection.getResponse(HttpWebConnection.java:167) at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1281) at com.gargoylesoftware.htmlunit.WebClient.loadWebResponse(WebClient.java:1198) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:307) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:376) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:361) Googling asked me to add commons-codec dependency so I also added: <dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> <version>1.8</version> <scope>test</scope> </dependency> No cigar though. The original test is at: https://github.com/javaee-samples/javaee7-samples/blob/master/servlet/metadata-complete/src/test/java/org/javaee7/servlet/metadata/complete/TestServletTest.java What am I missing ? Arun -- http://blog.arungupta.me http://twitter.com/arungupta |