NOTE: Twitter sample uses SoapUI events to add OAuth tokens to requests. Events are only available in standalone ReadyAPI that has been replaced with ReadyAPI. To try the sample, feel free to download a ReadyAPI trial from our website.
The Twitter API Sample Project is equally simple but has a somewhat more elaborate authentication setup since Twitter uses OAuth for authentication (see below). The project structure is as follows, containing a number of resources for statuses, search and account information.
The TestCase performs a number of straight-forward requests:
- Search Request – Makes sure there at least 5 tweets mentioning “soapui”
- Retweet Request – Make sure there are retweets for the current user (identified by the access token)
- Mentions Request – Make sure there are mentions of the current user (identified by the access token)
- User Timeline Request – Make sure there are at least 3 entries in the current users timeline.
Setting up OAuth 1.0
To be able to run the requests in the project they need to contain valid OAuth tokens. In this sample project this is achieved by an EventHandler that uses the google signpost libraries to sign the outgoing requests:
To get this working you need to download the signpost-core and signpost-commonshttp4 jars from https://code.google.com/p/oauth-signpost/downloads/list and save them to the SoapUI/bin/ext folder. When starting SoapUI you should see them getting picked up in the soapui log at the bottom of the main window:
Next, you need set the required OAuth properties at the project level (see the bottom left table of properties in the screen-shot); the event-handler uses these to sign the request. To get these you need to register an app at https://dev.twitter.com/apps/new - the keys will be made available in the web console.
When you send a request you can see the outgoing OAuth headers in the Raw view request view:
More details on the Twitter API.
Download Twitter Sample Project