[JWebUnit-users] JWebUnit connection error
Brought to you by:
henryju
From: yabing c. <che...@gm...> - 2011-05-20 09:34:07
|
I have problem to use JWebUnit to connect to URL from eclipse. in the first line of the testSearch, it already failed. how to overcome this connection error? thanks. Below is my sample code: public class GoogleTest extends WebTestCase { static String searchLink = "HttpUnit"; public static void main(String[] args){ junit.textui.TestRunner.run(new TestSuite(GoogleTest.class)); } @Before public void setUp() throws Exception{ super.setUp(); // setTestingEngineKey(TestingEngineRegistry.TESTING_ENGINE_HTMLUNIT); // System.setProperty("proxyHost", "10.138.10.15"); // System.setProperty("proxyPort", "8080"); // System.setProperty("proxySet", "true"); setBaseUrl("http://www.google.com"); // getTestContext().setProxyAuthorization(null, null, "10.138.10.15", 8080); } public void testSearch(){ beginAt("/"); // assertFormElementPresent("q"); // setFormElement("q", "HttpUnit"); // submit("btnG"); // assertLinkPresentWithText(searchLink); // clickLinkWithText(searchLink); } } and the error output is: 17:32:04.919 [main] DEBUG c.g.htmlunit.WebClient - Get page for window named '', using WebRequest[<url="http://www.google.com/", GET, EncodingType[name=application/x-www-form-urlencoded], [], {Accept=*/*}, null>] 17:32:04.935 [main] DEBUG c.g.htmlunit.WebClient - Load response for GET http://www.google.com/ 17:32:05.169 [main] DEBUG o.a.h.i.c.t.ThreadSafeClientConnManager - ThreadSafeClientConnManager.getConnection: HttpRoute[{}-> http://www.google.com], timeout = 0 17:32:05.169 [main] DEBUG o.a.h.i.conn.tsccm.ConnPoolByRoute - Total connections kept alive: 0 17:32:05.169 [main] DEBUG o.a.h.i.conn.tsccm.ConnPoolByRoute - Total issued connections: 0 17:32:05.169 [main] DEBUG o.a.h.i.conn.tsccm.ConnPoolByRoute - Total allocated connection: 0 out of 20 17:32:05.169 [main] DEBUG o.a.h.i.conn.tsccm.ConnPoolByRoute - No free connections [HttpRoute[{}->http://www.google.com]][null] 17:32:05.169 [main] DEBUG o.a.h.i.conn.tsccm.ConnPoolByRoute - Available capacity: 2 out of 2 [HttpRoute[{}->http://www.google.com]][null] 17:32:05.169 [main] DEBUG o.a.h.i.conn.tsccm.ConnPoolByRoute - Creating new connection [HttpRoute[{}->http://www.google.com]] 17:32:26.388 [main] DEBUG o.a.h.i.conn.DefaultClientConnection - Connection shut down 17:32:26.388 [main] DEBUG o.a.h.i.c.t.ThreadSafeClientConnManager - Released connection is not reusable. 17:32:26.388 [main] DEBUG o.a.h.i.conn.tsccm.ConnPoolByRoute - Releasing connection [HttpRoute[{}->http://www.google.com]][null] 17:32:26.388 [main] DEBUG o.a.h.i.conn.tsccm.ConnPoolByRoute - Notifying no-one, there are no waiting threads 17:32:26.388 [main] DEBUG c.g.htmlunit.WebWindowImpl - destroyChildren 17:32:26.403 [main] DEBUG n.s.j.h.HtmlUnitTestingEngineImpl - Window closed : no_html 17:32:26.403 [main] DEBUG o.a.h.i.c.t.ThreadSafeClientConnManager - Shutting down and the jwebunit error stack: java.lang.RuntimeException: org.apache.http.conn.HttpHostConnectException: Connection to http://www.google.com refused at net.sourceforge.jwebunit.htmlunit.HtmlUnitTestingEngineImpl.gotoPage(HtmlUnitTestingEngineImpl.java:263) at net.sourceforge.jwebunit.htmlunit.HtmlUnitTestingEngineImpl.beginAt(HtmlUnitTestingEngineImpl.java:212) at net.sourceforge.jwebunit.junit.WebTester.beginAt(WebTester.java:228) at net.sourceforge.jwebunit.junit.WebTestCase.beginAt(WebTestCase.java:193) at com.test.GoogleTest.testSearch(GoogleTest.java:34) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at junit.framework.TestCase.runTest(TestCase.java:168) at junit.framework.TestCase.runBare(TestCase.java:134) at net.sourceforge.jwebunit.junit.WebTestCase.runBare(WebTestCase.java:93) at junit.framework.TestResult$1.protect(TestResult.java:110) at junit.framework.TestResult.runProtected(TestResult.java:128) at junit.framework.TestResult.run(TestResult.java:113) at junit.framework.TestCase.run(TestCase.java:124) at junit.framework.TestSuite.runTest(TestSuite.java:243) at junit.framework.TestSuite.run(TestSuite.java:238) at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: org.apache.http.conn.HttpHostConnectException: Connection to http://www.google.com refused at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:127) at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:147) at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:108) at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:415) at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:641) at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:597) at com.gargoylesoftware.htmlunit.HttpWebConnection.getResponse(HttpWebConnection.java:133) at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1405) at com.gargoylesoftware.htmlunit.WebClient.loadWebResponse(WebClient.java:1324) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:303) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:369) at net.sourceforge.jwebunit.htmlunit.HtmlUnitTestingEngineImpl.gotoPage(HtmlUnitTestingEngineImpl.java:253) ... 24 more Caused by: java.net.ConnectException: Connection timed out: connect at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(Unknown Source) at java.net.PlainSocketImpl.connectToAddress(Unknown Source) at java.net.PlainSocketImpl.connect(Unknown Source) at java.net.SocksSocketImpl.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at com.gargoylesoftware.htmlunit.SocksSocketFactory.connectSocket(SocksSocketFactory.java:88) at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:123) ... 35 more |