• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Testing multipart submit in jsp

 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am very new to jsp and java testing in general. I have written a jsp that will be used as part of a VoiceXML application. This jsp receives some parameters that are strings from a VoiceXML page along with a parameter that is an audio file. The jsp creates a directory structure based upon the values of the string parameter, then it constructs a filename with a date stamp, then it saves the audio using an oreilly multipart bean.
It seems to work well, but now I am wondering how I could have tested it at the unit level? I will need to do this again and I would like to learn how to test jsp code correctly.
Here is the jsp in question:

Thank you for any advice you have about unit testing jsp code!
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could use HttpUnit or Cactus for sending the multipart HTTP POST request and then, somehow, verify that the file appeared in the correct place.
It's not really unit testing but functional testing, though. I would still consider extracting everything you can into helper classes which can be tested in isolation without a web container. Divide and conquer...
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Lasse is correct - your JSP should be as dumb as possible. Put all the logic into POJOs (plain old java objects) and test them using vanilla JUnit.
 
What a show! What atmosphere! What fun! What a tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic