I am trying to write some gwt testcases to upload files using FileUpload and FormPanel.
My code (unttested) looks like:
@Test
public void testImportXml() {
delayTestFinish(10000);
FormPanel fileForm=new FormPanel();
fileForm.setEncoding(FormPanel.ENCODING_MULTIPART);
fileForm.setMethod(FormPanel.METHOD_POST);
fileForm.setAction(GWT.getModuleBaseURL()+"/xmlupload");
URL myFile=this.getClass().getClassLoader().getResource("myfile.xml");
// FileUpload uploadField; ??
fileForm.addSubmitHandler(new SubmitHandler() {
@Override
public void onSubmit(SubmitEvent event) {
logger.info("submit handler pushed");
}
});
fileForm.submit();
}
I could not find a method to configure FileUpload to use “myFile”.
I understood that this is done for browser-security reasons, but it is a massive obstacle when writing testcases.
Does there exist a way to specify filenames for FileUpload for testcases within gwt?
No.
But then one could wonder what is it that you’re actually trying to test?