}
});
// Setup the request. It should be a IMultipartWebRequest
RequestCycle requestCycle = tester.createRequestCycle();
MockHttpServletRequest servletRequest = tester.getServletRequest();
servletRequest.setMethod("POST");
servletRequest.setParameter("form2:hf:fs", "");
servletRequest.setParameter("wicketState", "");
File tmp = null;
try {
// Write out a large text file. We need to make this file reasonably sizable,
// because things get handled using input streams, and we want to check to make
// sure they're closed properly if we abort mid-request.
// We create a temp file because we don't want to depend on a file we might not
// know the path of (e.g. the big DTD this test used previously). This enables
// us to run the test out of a JAR file if need be, and also with an unknown
// running directory (e.g. when run from wicket-parent).
tmp = new File(File.createTempFile(this.getClass().getName(), ".txt"));
OutputStream os = new BufferedOutputStream(new FileOutputStream(tmp));
for (int i = 0; i < 1000; i++)
{
os.write("test test test test test\n".getBytes());
}
os.close();
// Let's upload the dtd file. It's large enough to avoid being in memory.
servletRequest.addFile("upload", tmp, "text/plain");
requestCycle.setRequest(new MultipartServletWebRequest(servletRequest, Bytes.MAX));
// attach manually for the test
field.attach();