Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8441655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:37:09+00:00 2026-06-10T08:37:09+00:00

I am trying to write some gwt testcases to upload files using FileUpload and

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T08:37:10+00:00Added an answer on June 10, 2026 at 8:37 am

    No.

    But then one could wonder what is it that you’re actually trying to test?

    • the submit / submit-complete handlers? You’d better fire the events directly at the FormPanel; you could also refactor your code to use some MV* pattern so that the code you’re actually testing is not tied to GWT widgets, then you can use a vanilla JUnit test.
    • the servlet? Then don’t use a GWTTestCase, use HttpClient or anything similar and make a request against your servlet, running in a server (best done as an integration test; have a look at Arquillian to make it easier to setup)
    • the whole interaction between the FormPanel+FileUpload and servlet? Then don’t use a GWTTestCase, use Selenium to drive a browser talking to a running server (best done as an integration test or acceptance test)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write some code that will generate accurate .proto files from
I'm trying to write some microcontroller code using Texas Instruments examples, and it uses
I have a GWT application for which I'm trying to write some tests using
I'm trying to write some LINQ To SQL code that would generate SQL like
I'm trying to write some code to test out the Cartesian product of a
Hello I'm trying to write some tool using code::blocks, wxWidgets and libxml2 on Windows
I am currently trying to write some code that will accept some FTP details,
I am trying to write some simple code which will read a text file
I'm trying to write some C# code to do administration on IIS. I have
I have been trying to write some code in Scala to read a file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.