Twitter Sample Project

NOTE: Twitter sample uses SoapUI events to add OAuth tokens to requests. Events are only available in SoapUI Pro that has been replaced with Ready! API. To try the sample, feel free to download a SoapUI NG Pro 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:

  1. Search Request – Makes sure there at least 5 tweets mentioning “soapui”
  2. Retweet Request – Make sure there are retweets for the current user (identified by the access token)
  3. Mentions Request – Make sure there are mentions of the current user (identified by the access token)
  4. 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:

oauth-handler

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:

soapui-log

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:

raw-request

More details on the Twitter API.

Download Twitter Sample Project