Testing REST webservices

JavaWeb ServicesRestTestingRest Client

Java Problem Overview


My organization is working on building RESTful webservices on JBoss appserver. The QA team is used to testing SOAP webservices so far using SoapUI. SoapUI has a new version that has REST capabilities. We're considering using that.

  1. Are there any publicly available RESTful services available on the net for free that someone could test ?
  2. What tools are available(and used) for testing RESTful web services ?

Java Solutions


Solution 1 - Java

soapUI will do the job as well, check out this blog post to get started.

Solution 2 - Java

Please try Firefox addon Poster , which is simple to use and gets you up nd running quickly

Solution 3 - Java

You can exercise web services using fairly trivial bits of Python. Depending on your security, you may be able to simply use Python's urllib or urllib2 to do do you REST requests and examine your answers.

Additionally, you might want to use Python unittest to control the execution of the Python tests of your REST services.

class TestSomeREST( unittest.TestCase ):
    def setUp(self):
        REALM = "[email protected]"
        self.client= RESTClient( "localhost", 18000, "tester", "tester", REALM )
    def test_1_get(self):
        response = self.client.get('/this/that/other/2/')
        self.failUnlessEqual(200, response.status_code)
        j1= JSONDecoder().decode(response.content)
        self.assertEquals(2, j1[0]['pk'] )
        entity= j1[0]['fields']
        self.assertEquals('Some Other Group', entity['name'])
        self.assertEquals('E1G2', entity['customer_id'])

The RESTClient class uses urllib2 to pass through digest authentication for each request. It's rather complex, but I can share the essence if it's of interest.

Solution 4 - Java

Check out Fiddler

Solution 5 - Java

CURL Gets you halfway there. The other half is checking the headers, response codes and entity content to make sure its good. You could use a variety of tools for that (in shell scripting land, piping the header and contents to files, and diffing them might just do the trick). It wouldn't be that difficult to further refine the toolset, maybe stacking curl up with the unit-testing framework of your choice.

I built a rest webservice testing panel with AJAX. It wasn't that difficult at all actually. You have some security issues to work out (i.e. making sure that you have the test suite on the same server, or maybe signed Javascript.)

Solution 6 - Java

To test a REST service you can try http://code.google.com/p/rest-assured/">REST Assured which makes it very simple to test REST services and validating the response in Java (using JUnit or TestNG).

Solution 7 - Java

Check out Postman - https://chrome.google.com/webstore/detail/fdmmgilgnpjigdojojpjoooidkmcomcm/. This is a tool I have been working on over the past several months and lately from the feedback that I have been getting it's becoming quite useful for large REST projects while helping with basic REST endpoint testing.

The code for this is available on Github as well. https://github.com/a85/POSTMan-Chrome-Extension

Solution 8 - Java

The simplest way to test REST web service is using curl in terminal.

There are some codes I used to test my web service of rails. You may modify them to fit your services.

GET

curl http://localhost:3000/courses.json

POST

curl -H "Content-Type:application/json"  -d '{"courseCode":"55555","courseName":"SEEEE","courseYr":999}' http://localhost:3000/courses.json

PUT in Raills: eg1(with all fields) :

curl -H "X-Http-Method-Override: put" -H "Content-Type:application/json"  -d '{"courseCode":"123456","courseName":"AAAAAAAA","courseYr":12345}' http://localhost:3000/courses/5.json

eg2(with the field only be edited) :

curl -H "X-Http-Method-Override: put" -H "Content-Type:application/json"  -d '{"courseYr":999999999}' http://localhost:3000/courses/3.json

DELETE in rails with id provided

 curl -H "X-Http-Method-Override: delete" -H "Content-Type:application/json"  -d '{"id":4}' http://localhost:3000/courses/5.json

Solution 9 - Java

I don't have tested it yet but this Java app seems to be nice to test REST services. There is also a tutorial on Javalobby about it.

Java App: http://code.google.com/p/rest-client/

Tuto: http://java.dzone.com/announcements/wiztoolsorg-restclient-21-rele

Solution 10 - Java

you can use the Simple REST Client is an extension for Google Chrome too https://chrome.google.com/webstore/detail/fhjcajmcbmldlhcimfajhfbgofnpcjmb

Solution 11 - Java

SOA Cleaner, is a test tool that tests both soap and rest (also WCF, but it seems you don't need that feature). It's very intuative, and usable. Written in .NET. A free version is also available. can be downloaded from http://xyrow.com. Good luck!

Solution 12 - Java

I'm using REST console extension for Google Chrome and It's by far the best i've tried. It also supports various security mechanisms like OAuth

(update 2: fix link)

Solution 13 - Java

I'm testing RESTful services with an in house .NET framework (no problem porting it in Java). Basic principles:

  • build client (to make the calls)
  • build type classes (XML and JSON)
  • deserialize response
  • assert stuff

If you want more info, I'm glad to talk.

Solution 14 - Java

For java, there also exists RESTFuse, which allows to develop unit tests which may look like this:

@Rule
public Destination destination = new Destination("http://localhost:8080/rest/");


@HttpTest( method = Method.GET, path = "/status" ,authentications =
   @Authentication(type = AuthenticationType.BASIC, user = "joe", password = "doe")
)
public void testAuthRhqadmin() {
    com.eclipsesource.restfuse.Assert.assertOk(response);
}

This test runs against http://localhost:8080/rest/status and authenticates as user joe with password doe. The body of the method then checks that the GET call returns a 200 status code.

Solution 15 - Java

Try Python's httplib. It's very easy, you specify the method, url, and use urllib.urlencode for the parameters/POST body.

This can be combined with the builtin unittest module if you like, for reporting of errors.

Solution 16 - Java

I've been using JMeter for this, especially for stuff like load testing. It's similar to SoapUI (which I've also used), but geared more toward testing web pages, which makes it pretty decent at testing RESTful services, too.

Solution 17 - Java

I've written a program specifically for testing REST Web Services. Its a pretty simple application written in .NET 2.0 (I've only tested it on Windows Vista, but should work on XP also). The application uses HttpWebRequest to make requests, and displays the resulting response, as well as the headers for the request and response. I've done a bit of testing, but I thought it might help you test your web services.

REST Test

Solution 18 - Java

I'm currently investigating wsclient CLI app for this purpose (http://wso2.org/library/3362). It is quite promising, and can be used to hack a quick test from a bash shell. Of course, as many mentioned here, many of the tools that come with a *nix system will do the job with a tidbit of coding/scripting

Solution 19 - Java

If you like using Ruby there's a REST-Client gem for it

For testers I find ruby is a really easy language to learn, and it has some excecllent tools like Cucumber for doing BDD style acceptance tests.

Solution 20 - Java

I've tried numerous REST clients and by far the best I've used is the Chrome app: DHC.

> DHC (aka Dev HTTP Client) is designed and developed by a developer for developers to make direct HTTP resource discovery, manipulation and testing more easily. Beside the main function, sending/receiving custom HTTP requests/responses, it allows permanently to save a request to a local repository for later reuse and moreover the request declaration can include variables that are context specific. With the use of contexts you can easily switch between various environments without modifying request declaration. (e.g. from a test environment to production)

Solution 21 - Java

Testing REST full web services is a easy task to do. Free ad-ons are available on the browsers as REST Client from where you have to send a web service with expected/required method type: GET/POST/PUT/DELETE If the parameters are matched then output will get generated in the body of browser.enter image description here

Solution 22 - Java

I know it is very old question, but could be helpful to others. Just to answer your first question you can check here to get some REST webservices to test.

Fiddler and Poster plug in Firefox can be use to test any REST web services. SoapUI also comes with RESTful webservices support.

Solution 23 - Java

For advanced REST testing you can try [HttpMaster][1].
It supports dynamic parameters, friendly viewers for XML/JSON, and various types of response data validations that can be combined into logical expressions.
For basic http requests some browser plugin will be sufficient.

[1]: http://www.httpmaster.net "HttpMaster"

Solution 24 - Java

OnionTest still beta , but quite useful

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionanjanbView Question on Stackoverflow
Solution 1 - JavaOle LensmarView Answer on Stackoverflow
Solution 2 - Javauser28192View Answer on Stackoverflow
Solution 3 - JavaS.LottView Answer on Stackoverflow
Solution 4 - JavaTheSoftwareJediView Answer on Stackoverflow
Solution 5 - JavaJonathan ArkellView Answer on Stackoverflow
Solution 6 - JavaJohanView Answer on Stackoverflow
Solution 7 - JavaAbhinavView Answer on Stackoverflow
Solution 8 - Javacode4jView Answer on Stackoverflow
Solution 9 - JavaValentin JacqueminView Answer on Stackoverflow
Solution 10 - JavaChuck MahView Answer on Stackoverflow
Solution 11 - JavaClangonView Answer on Stackoverflow
Solution 12 - JavaMichael BavinView Answer on Stackoverflow
Solution 13 - JavaAndrei MarfieviciView Answer on Stackoverflow
Solution 14 - JavaHeiko RuppView Answer on Stackoverflow
Solution 15 - JavaAndyView Answer on Stackoverflow
Solution 16 - JavaMike DesjardinsView Answer on Stackoverflow
Solution 17 - JavaIan HopkinsView Answer on Stackoverflow
Solution 18 - JavaverbozeView Answer on Stackoverflow
Solution 19 - JavaChuck van der LindenView Answer on Stackoverflow
Solution 20 - JavaAndarisView Answer on Stackoverflow
Solution 21 - Javamohit sarsarView Answer on Stackoverflow
Solution 22 - JavaManojView Answer on Stackoverflow
Solution 23 - JavaJoxiView Answer on Stackoverflow
Solution 24 - JavakoosView Answer on Stackoverflow