• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

httpunit: WebForm submitting not working

 
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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???
     
    peter cooke
    Ranch Hand
    Posts: 317
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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"
     
    Ranch Hand
    Posts: 51
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Can you assign some default values for some_param and another_param in the html and test?
     
    peter cooke
    Ranch Hand
    Posts: 317
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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.
     
    Rancher
    Posts: 43081
    77
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Even if the user doesn't enter anything into those fields, they are still being transmitted.
     
    peter cooke
    Ranch Hand
    Posts: 317
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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
    Posts: 51
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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
     
    Don't get me started about those stupid light bulbs.
    reply
      Bookmark Topic Watch Topic
    • New Topic