aspose file tools*
The moose likes Web Services and the fly likes Unit Testing Web Services. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Unit Testing Web Services." Watch "Unit Testing Web Services." New topic
Author

Unit Testing Web Services.

Rakesh Jhamb
Ranch Hand

Joined: Jun 18, 2003
Posts: 154
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


SCJP2, SCWCD
Vyas Sanzgiri
Ranch Hand

Joined: Jun 16, 2007
Posts: 686

Try soapUI


===Vyas Sanzgiri===
My Blog
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
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

Joined: Jan 22, 2002
Posts: 16
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

Joined: Jun 01, 2009
Posts: 20
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

Joined: Jun 18, 2003
Posts: 154
Thanks a lot.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Unit Testing Web Services.