This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unit Testing Web Services.

 
Rakesh Jhamb
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

we are working on a web services project using JAX-WS and JAXB. All is fine and we are able to consume as well as publish our web services. The problem is in unit testing these web services using Junit.

Is there a standard generic approach to Unit Test Web Services, please share the names / URLs of any tools or articles on the same regard.

Thanks
 
Vyas Sanzgiri
Ranch Hand
Posts: 686
Chrome Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try soapUI
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
As before, soapUI is a nice tool. Take a look at the following links:
http://www.soapui.org/gettingstarted/functional.html
http://www.soapui.org/gettingstarted/mocking.html
Finally, this page talks about how unit tests created in soapUI can be run from your own JUnit tests:
http://www.soapui.org/userguide/commandline/testcaserunner.html
Best wishes!
 
Don Schaefer
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The approach we have generally taken for testing web services has been to write the tests on the pojos used by the webservice instead of the services themselves. The impl code merely calls the pojo with the document after applying security and transaction policy. This allows separation between the webservice implementation and our logic. This also allows for much quicker unit testing.

If you want to be a purist about it, testing through the webservice is more of an integration test. For those tests you also have to account for security, transaction policies etc. Much more that a simple junit test. For that testing we build the docs, execute the service and check the results using relative xpath expressions.

Thanks,
Don.
 
Jeff. Davis
Author
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree, soapUI is a very nice open source product for testing both SOAP and RESTful web services. You can construct test cases/suites in it, and even use it to act as a server for mock-requests (they offer a commercial alternative that has a few more bells-and-whistles). In many of my examples in the book I have soapUI integrated in with ANT for testing of the example services (i.e., you run an ant target that will automatically launch soapUI along with the appropriate project).
 
Rakesh Jhamb
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic