wood burning stoves 2.0*
The moose likes Testing and the fly likes HttpUnit Exception stack trace Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "HttpUnit Exception stack trace" Watch "HttpUnit Exception stack trace" New topic
Author

HttpUnit Exception stack trace

Arundhathi Menon
Ranch Hand

Joined: Jan 14, 2004
Posts: 113
Hi!
Have installed HttpUnit...
The following exception trace stack , Why do I get the following exceptions?


--------------------------------------------------------
.java.io.IOException
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:593)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:272)
at com.meterware.httpunit.HttpWebResponse.readResponseHeader(HttpWebResponse.java:162)
at com.meterware.httpunit.HttpWebResponse.readHeaders(HttpWebResponse.java:200)
at com.meterware.httpunit.HttpWebResponse.<init>(HttpWebResponse.java:56)
at com.meterware.httpunit.HttpWebResponse.<init>(HttpWebResponse.java:67)
at com.meterware.httpunit.WebConversation.newResponse(WebConversation.java:76)
at com.meterware.httpunit.WebWindow.getResource(WebWindow.java:164)
at com.meterware.httpunit.WebWindow.getSubframeResponse(WebWindow.java:128)
at com.meterware.httpunit.WebWindow.getResponse(WebWindow.java:121)
at com.meterware.httpunit.WebClient.getResponse(WebClient.java:113)
at HttpUnitDemoTest.testDice(HttpUnitDemoTest.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at junit.textui.TestRunner.doRun(TestRunner.java:116)
at junit.textui.TestRunner.doRun(TestRunner.java:109)
at junit.textui.TestRunner.run(TestRunner.java:72)
at HttpUnitDemoTest1.main(HttpUnitDemoTest1.java:26)
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
at java.net.Socket.connect(Socket.java:452)
at java.net.Socket.connect(Socket.java:402)
at sun.net.NetworkClient.doConnect(NetworkClient.java:139)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:402)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:618)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:306)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:267)
at sun.net.www.http.HttpClient.New(HttpClient.java:339)
at sun.net.www.http.HttpClient.New(HttpClient.java:320)
at sun.net.www.http.HttpClient.New(HttpClient.java:315)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:512)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:489)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:617)
at sun.net.www.protocol.http.HttpURLConnection.getHeaderFieldKey(HttpURLConnection.java:1490)
at com.meterware.httpunit.HttpWebResponse.loadHeaders(HttpWebResponse.java:216)
at com.meterware.httpunit.HttpWebResponse.readHeaders(HttpWebResponse.java:198)
... 24 more
F
Time: 22.391
There was 1 failure:
1) testDice(HttpUnitDemoTest)junit.framework.AssertionFailedError
at HttpUnitDemoTest.testDice(HttpUnitDemoTest.java:109)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at HttpUnitDemoTest1.main(HttpUnitDemoTest1.java:26)

FAILURES!!!
Tests run: 1, Failures: 1, Errors: 0


SCJP , SCWCD , SCBCD , SCDJWS
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
The problem seems to indicate that HttpUnit has trouble accessing the Internet. Are you behind a proxy server? If you are, see the FAQ for help in configuring your tests.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Arundhathi Menon
Ranch Hand

Joined: Jan 14, 2004
Posts: 113
Hi again!
Yes am using a proxy server..

"Call WebClient.setProxyServer( host, port )before sending your request, or if you need to specify a username and password, call WebClient.setProxyServer( host, port, username, password ). "

1)WebClient is an abstract class hence the below way of calling the metod fails as setProxyServer is not a static function either.
2)I cannot extend my testcase class from WebClient as it already extends TestCase
So how else can i possible invoke this method?

regards
Menon
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by Arundhathi Menon:
1)WebClient is an abstract class hence the below way of calling the metod fails as setProxyServer is not a static function either.
2)I cannot extend my testcase class from WebClient as it already extends TestCase

WebClient is abstract but WebConversation (which extends WebClient) is not... As I showed you in the previous thread, you don't need to extend WebClient. Take a look at the documentation and the javadocs for more help on how to use WebConversation.
Arundhathi Menon
Ranch Hand

Joined: Jan 14, 2004
Posts: 113
Hello again!
I inclided the proxy server part ... but the exception trace that i get is still the same...
Here is the code where I included it in

protected void setUp() throws Exception
{
WebConversation conversation = new WebConversation();

conversation.setProxyServer("10.237.3.28",6050);
WebRequest request = new GetMethodWebRequest("http://www.google.com");
frontPage = conversation.getResponse(request);
}


Any idea what could be the problem?
regards
Menon
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Hmm. If you point your test to some locally running web application (as in "download and unzip Tomcat, start it up, and use http://localhost:8080/ in your test"), does HttpUnit still give you the same error?
Arundhathi Menon
Ranch Hand

Joined: Jan 14, 2004
Posts: 113
Hi,
Problem persists
regards
Menon
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HttpUnit Exception stack trace
 
Similar Threads
HttpURLConnection
java.net.ConnectionException
HttpUnit-Net Connection Error
how to read files from internet
Problems trying to get struts-config.xml in JBoss 3.2.1