For up-to-date product documentation, see the IBM MobileFirst Foundation Developer Center.


Tools for testing and debugging adapters

MobileFirst Java™ adapters expose a full REST API that enables you to test functionality by issuing HTTP requests.

We can test adapters using MobileFirst Platform CLI, as well as third-party tools such as Swagger and Postman.

The base URL for an adapter is:

<server-address>/<context-root>/api/adapters/<adaptername>.

Testing adapters with MobileFirst Platform CLI

To test an adapter by using CLI, you call it by running the mfpdev adapter call command.

For more information on the command, see Command-line interface (CLI) summary, or run the mfpdev help adapter call command.

Testing adapters with Swagger UI
MobileFirst Development Server ships with a built-in Swagger UI which displays a graphical representation of the Swagger document for the endpoints that are exposed by adapters. From the MobileFirst Operations Console, display the Swagger UI by clicking View Swagger Docs in the Resources tab of the adapter.

Figure 1. Viewing a Swagger Document

The image shows how to display a Swagger doc for the adapter.

Swagger-UI provides a convenient way of testing adapters, by letting you specify the appropriate parameters for every adapter endpoint. In addition, it is able to implicitly obtain a token for any scope that is used by the adapter, thus avoiding the need to manually obtain the token.

Testing adapters with external Swagger tools

MobileFirst Server exposes an endpoint that provides Swagger 2.0 documentation so that we can test adapters with any tool that parses Swagger 2.0 JSON format. The URL of the endpoint is: <server-ip>:<server-port>/<context-root>/api/adapterdoc/<adaptername>

Testing adapters with REST clients such as Postman

We can use Postman or similar tools to test HTTP requests and pass the following parameters:

  • URL parameters
  • Path parameters
  • Body parameters
  • Headers

If your resource is protected by a security scope, perform the necessary steps for acquiring an access token and accessing the protected resource. See Acquiring access tokens and Accessing protected resources.

Debugging Java adapters
You debug the Java code in an adapter just as you do in any remote Java debug. Connect to MobileFirst Server on the debug port using your favorite IDE. The debug port varies from server to server. In a MobileFirst Server that is based onWebSphere® Application Server Liberty profile, it is 10777 by default.

Parent topic: Developing the server side of a MobileFirst application