Facebook Test Java API release 1.1.5

The Facebook Test Java API framework has been updated. There are two additions to the API and one bugfix:

  1. Bugfix for NPE when calling facebookStore.createTestUser(false,”…”).
  2. Added possibility of using a provided HttpClient instance in HttpClientFacebookTestUserStore.
  3. Added unit test that displays the use of json-path when asserting data.

Here’s a quick reminder of how to create test users for an application. The creation process is handled by an instance of FacebookTestUserStore, e.g. The HttpClientFacebookTestUserStore which uses Apache HttpClient as communication method. The class needs the application ID and the application secret for the application in order to be able to create the users and this is specified in the constructor:

Now you have a choice when creating a test user: You may say that the test user should accept the privileges that you specify for it, which is done by:

If you want to give a choice to the test user whether the privileges should be accepted or not, you do the following:

The accept/decline choice takes part in the web browser, hence you need the login URL for the test user to access the page. This URL is accessible from the FacebookTestUserAccount:

Specifying a HttpClient instance to HttpClientFacebookTestUserStore

There might be occasions where you need a special HttpClient instance for communication, for example one instance with proxy settings configures, or another instance where you have stubbed all the communication that takes place. To provide the instance to HttpClientFacebookTestUserStore, just specify it in the constructor:

Using json-assert to verify application behavior

The json-assert project, which uses json-path can be used to make life a little less verbose when asserting on data from the JSON document representations of the Facebook data streams that are available in the FacebookTestUserAccount. For example, the user details of a test user can be accessed like this:

The result is a java.lang.String containing a JSON Document. To make it easier to assert that the user details actually contain the expected data, you may use json-assert and Hamcrest matchers:

Feel free to test it out, the code is open source an can be found on Maven central or on the
Facebook Test Java API project page.

/Tobias

This Post Has One Comment

  1. This is really attention-grabbing, You’re a very professional blogger. I’ve joined your rss feed and stay up for searching for more of your fantastic post. Also, I’ve shared your web site in my social networks!

Leave a Reply

Close Menu