aspose file tools*
The moose likes Testing and the fly likes httpunit: WebForm submitting not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "httpunit: WebForm submitting not working" Watch "httpunit: WebForm submitting not working" New topic
Author

httpunit: WebForm submitting not working

peter cooke
Ranch Hand

Joined: Mar 16, 2004
Posts: 317
myForm.html



In firefox, I can exectue "http://XXXXXXXXXXXXXX:8080/myapp/INTEGRATIONSERVLETTEST/INTEGRATIONSERVLETTEST?foo=hello&bar=world&action=TESTACTION" All looks ok, I get the response back that I expect.
output from hitting action



my unit test:


stack trace



  • my tcpip monitor is showing that I am pulling myForm.html When I run the unitest.
  • When I add debug statements for any param they show up correctly.
  • my ethernet sniffer shows no request to myapp/INTEGRATIONSERVLETTEST/INTEGRATIONSERVLETTEST
  • I get a null pointer exception at the testform.submit().



  • My reading of the WebForm api is that WebForm.submit() will submit the form to the server at the address in the form action attribute. Any idea what I am doing wrong???


    CIAO Peter M. Cooke
    peter cooke
    Ranch Hand

    Joined: Mar 16, 2004
    Posts: 317
    The test started working when I put in values for all html inputs.
    So if I have a html form and it does not require all inputs to have data. Why does httpunit?
    Is there somehting wrong with the form or my testcode that says "yes I know the form does not have values for all input. submit it anyways"
    Siitesh Hind
    Ranch Hand

    Joined: Sep 06, 2012
    Posts: 51
    Can you assign some default values for some_param and another_param in the html and test?
    peter cooke
    Ranch Hand

    Joined: Mar 16, 2004
    Posts: 317
    the business requirements say that some_param and another_param are completely optional. If user does not put anything in then ... put null in db.
    Ulf Dittmer
    Marshal

    Joined: Mar 22, 2005
    Posts: 42916
        
      68
    Even if the user doesn't enter anything into those fields, they are still being transmitted.
    peter cooke
    Ranch Hand

    Joined: Mar 16, 2004
    Posts: 317
    HMMMM my ethernet sniffer confirms that unless my form has all of it's input elements populated it will not go accross the wire.

    If I have assignments for both everything works and I see the request/response in my ethernet sniffer.

    I remove the assignment of the value from either "some_param" or "another_param" my ethernet sniffer does NOT detect the request from the submit, and submit fails with a null pointer exeception in
    com.meterware.httpunit.protocol.MimeEncodedMessageBody$MimeEncoding.fixLineEndings(MimeEncodedMessageBody.java:113)
    Siitesh Hind
    Ranch Hand

    Joined: Sep 06, 2012
    Posts: 51
    Agree with Ulf that you are passing Null values in these 2 fields which may be the source of the exception.

    I dont see any other reason for throwing this NullPointerException
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: httpunit: WebForm submitting not working