Re: java.io.IOException: Read error using file parameter on webform

"Wolfgang Fahl" <[email protected]> Thu, 20 Aug 2009 12:45:40 +0200
Newsgroups gmane.comp.web.httpunit.devel
Organization BITPlan GmbH
Message-ID <[email protected]>
Dear Ryan,

sorry for not getting back to you any sooner.

could you please show your point by adding a test to 
FileUploadTest.
http://httpunit.svn.sourceforge.net/viewvc/httpunit/trunk/httpunit/test/com/meterware/httpunit/FileUploadTest.java?view=log

I'll then look into the issue.

The Cookietest problem should be fixed by now.

Yours
Wolfgang
> 
> Just wanted to post a follow-up to this issue and bring a couple things 
> to attention..
> I checked out revision 1022from trunk and did a fresh build. 
> CookieTest has one failing Test shown below:
> 
> After commenting this test out so I could work on the issue mentioned in 
> my original email, I installedlocally and the issue has up and 
> vanished. I dont know if there have been changes to trunk since the 1.7 
> release that fixed the issue or if it has to do w/ the artifact being 
> built onmy system, but it works for me now.
> 
> My Environment is as follows:
> Maven version: 2.1.0
> Java version: 1.6.0_13
> XP Pro sp3
> 
> Running com.meterware.httpunit.cookies.CookieTest
> Tests run: 13, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0 sec 
> <<< FAILURE!
> testCookieAge(com.meterware.httpunit.cookies.CookieTest) Time elapsed: 
> 0 sec <<< FAILURE!
> junit.framework.AssertionFailedError: cookie2 expiration expect before 
> 1112124645000 but was 1241311387631
> at junit.framework.Assert.fail(Assert.java:47)
> at junit.framework.Assert.assertTrue(Assert.java:20)
> at 
> com.meterware.httpunit.cookies.CookieTest.testCookieAge(CookieTest.java:
> 206)
> 
> 
> 
> On Tue, May 19, 2009 at 3:56 PM, Ryan Connolly <[email protected]> wrote:
>     Hi folks:
>  I posted this message to the help forum and noticed a post 
> regarding low readership by the developers so I thought it best to send 
> this along to the list...
> 
> I have tried just about everything I can think of and am hoping someone 
> has encountered the same issue and is willing to share the solution.
> 
> I am testing a file upload form that submits to a servlet... I've got 
> everything working just fine except for when setting a file parameter or 
> calling request.selectFile. Below is the stacktrace and my unit test 
> code. Any help would be greatly appreciated. BTW: I've tried this with 
> the same results in both 1.6.2 and in the 1.7 release: Always with a 
> java.io.IOException: Read error.
> 
> 
> WebConversation wc = new WebConversation();
> WebRequest req = new GetMethodWebRequest(formFile.toURI().toString());
> 
> WebResponse resp = wc.getResponse(req);
> WebForm form = resp.getFormWithID("uploadForm");
> 
> ServletUnitClient sc = sr.newClient();
> 
> WebRequest request = form.getRequest( "submit", "Upload" );
> request.selectFile("attachment", uploadFile);
> 
> InvocationContext ic = sc.newInvocation(request);
> 
> WebResponse response = sc.getResponse(ic);
> response = sc.getResponse(request);
> 
> 
> 
> java.io.IOException: Read error
> at java.io.FileInputStream.readBytes(Native Method)
> at java.io.FileInputStream.read(FileInputStream.java:199)
> at 
> com.meterware.httpunit.protocol.MimeEncodedMessageBody$MimeEncoding.addF
> ile(MimeEncodedMessageBody.java:137)
> at 
> com.meterware.httpunit.FileSubmitFormControl.addValues(FormControl.java:
> 981)
> at com.meterware.httpunit.WebForm.recordParameters(WebForm.java:604)
> at 
> com.meterware.httpunit.protocol.MimeEncodedMessageBody.writeTo(MimeEncod
> edMessageBody.java:51)
> at 
> com.meterware.httpunit.MessageBodyWebRequest.writeMessageBody(MessageBod
> yWebRequest.java:107)
> at 
> com.meterware.httpunit.WebClient.writeMessageBody(WebClient.java:434)
> at 
> com.meterware.servletunit.ServletUnitClient.getMessageBody(ServletUnitCl
> ient.java:88)
> at 
> com.meterware.servletunit.ServletUnitClient.newInvocation(ServletUnitCli
> ent.java:81)
> at 
> com.meterware.servletunit.ServletUnitClient.newResponse(ServletUnitClien
> t.java:125)
> at com.meterware.httpunit.WebClient.createResponse(WebClient.java:647)
> at com.meterware.httpunit.WebWindow.getResource(WebWindow.java:220)
> at 
> com.meterware.httpunit.WebWindow.getSubframeResponse(WebWindow.java:181)
> 
> at com.meterware.httpunit.WebWindow.getResponse(WebWindow.java:158)
> at com.meterware.httpunit.WebClient.getResponse(WebClient.java:122)
> at 
> gov.vermont.dcf.fsdnet.uploads.UploadServletTest.testForm(UploadServletT
> est.java:83)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
> a:39)
> at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
> Impl.java:25)
> at 
> com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
> a:39)
> at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
> Impl.java:25)
> at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
> 
> 
> --
> ®¥@N
> 
> 
> 
> --
> ®¥@N
> 



BITPlan - smart solutions
Pater-Delp-Str. 1, D-47877 Willich Schiefbahn
Tel. +49 2154 811-480, Fax +49 2154 811-481
Web: http://www.bitplan.de
bitplan GmbH, Willich - HRB 6820 Krefeld, VAT-ID: 10258040548, 
Geschäftsführer: Wolfgang Fahl

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july

_______________________________________________
Httpunit-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/httpunit-develop