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

Ryan Connolly <[email protected]> Fri, 22 May 2009 13:53:04 -0400
Newsgroups gmane.comp.web.httpunit.devel
Message-ID <[email protected]>
Just wanted to post a follow-up to this issue and bring a couple things to
attention..
I checked out revision 1022 from 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 installed locally 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 on my 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.addFile(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(MimeEncodedMessageBody.java:51)
> at
> com.meterware.httpunit.MessageBodyWebRequest.writeMessageBody(MessageBodyWebRequest.java:107)
> at com.meterware.httpunit.WebClient.writeMessageBody(WebClient.java:434)
> at
> com.meterware.servletunit.ServletUnitClient.getMessageBody(ServletUnitClient.java:88)
> at
> com.meterware.servletunit.ServletUnitClient.newInvocation(ServletUnitClient.java:81)
> at
> com.meterware.servletunit.ServletUnitClient.newResponse(ServletUnitClient.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(UploadServletTest.java:83)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.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.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
>
>
>
> --
> ®¥@N
>



-- 
®¥@N

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com

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