No description, website, or topics provided.
Switch branches/tags
Clone or download
Patrick König
Latest commit d2d4380 Dec 6, 2018

README.md

BRAVA: IPK BrAPI Validator

Test suite for BrAPI servers. Test your server at http://webapps.ipk-gatersleben.de/brapivalidator/.

Under development, not carefully tested. If you find any errors or bugs, please report them as an issue!

BRAVA currently has two execution modes, simple and advanced mode. Simple mode contains the basic functionality: you can test any BrAPI server and get every endpoint defined in /calls tested.

The advanced mode requires a database (it can be an H2 database) to store test results and resource information. It includes a public repository list and the possibility to register resources to be tested periodically.

Installation

It is a bit of an awkward process right now. We'll migrate to Gradle and make things smoother in the future.

For now, you need to install Maven.

For simple version (just testing, no database required)

  1. Go to pom.xml and search for oracle jdbc driver:
<dependency>
	<groupId>com.oracle.jdbc</groupId>
	<artifactId>ojdbc7</artifactId>
	<version>12.1.0.1</version>
</dependency>

Comment or delete it.

  1. Create an empty file named config.properties in src/main/resources.

  2. If you are behind a proxy, add this to config.properties:

http.proxyHost=
http.proxyPort=
  1. Run it locally for the first time with:
mvn -U clean package jetty:run

Advanced version (includes public repository list and scheduled testing)

WARNING: This procedure is highly dependent on your environment and it hasn't been tested thoroughly. Something is likely to go wrong. DON'T PANIC and create an issue.

  1. If you use oracle, skip this step. Otherwise, go to pom.xml and search for oracle jdbc driver:
<dependency>
	<groupId>com.oracle.jdbc</groupId>
	<artifactId>ojdbc7</artifactId>
	<version>12.1.0.1</version>
</dependency>

Comment or delete it.

  1. In pom.xml search for this line:
<warSourceDirectory>${webappHome}</warSourceDirectory>

and replace it with:

<warSourceDirectory>${webappHome}/advanced</warSourceDirectory>
  1. Go to src/main/resources and rename config.properties.example to config.properties. Fill the fields with your details.

  2. Run it locally for the first time with:

mvn -U clean package jetty:run

Usage

To run locally use:

mvn jetty:run

To deploy to tomcat use:

mvn tomcat7:deploy

The tomcat server location must be defined as maven parameters. For example as a profile in settings.xml:

<profile>
  <id>profileid</id>
  <activation>
    <activeByDefault>true</activeByDefault>
  </activation>
  <properties>
    <appserver.name>production_server</appserver.name>
    <appserver.url>http://website.com:1234/manager/text</appserver.url>
    <appserver.path>/brapivalidator</appserver.path>
  </properties>
</profile>

Also remember to add the server user and encrypted password to settings.xml.

Docs

API

You can send GET requests to the server to test other servers easily, and get a JSON report:

/api/test/call?url={serverURL}&brapiversion={brapiVersion}

For example:

/api/test/call?url=http://brapi.org/server&brapiversion=v1.1

You can also get a report generated by the scheduled report system (either public or private) by using its id:

/api/testreport/{reportID}

Testing

This testing suite uses RestAssured for testing.

To validate the responses, JsonSchema is used. All schemas are located in src/test/resources/schemas.

The test configurations are stored in two ways. For the 'simple' tests, where one resource is tested for status code, content type and response schema, are stored in tests.json.

The complex tests (Test Collections) are stored in the collections/ folder. They roughly follow Postman's collections format. Instead of using JavaScript for the tests, we define them using a few simple commands.

Command Description Example
StatusCode:{int} Check the status code of the response StatusCode:200
ContentType:{String} Check the Content Type of the response ContentType:application/json
Schema:{path} Check the response against a Schema located in src/main/resources/schemas Schema:/metadata
GetValue:{jsonpointer}:{variableName} Stores the value of the response in the pointer location GetValue:/result/data/0/germplasmDbId:germplasmDbId
IsEqual:{jsonpointer}:{variableName} Checks the value of the response in the pointer location with a stored variable IsEqual:/result/germplasmDbId:germplasmDbId
{command}:{value}:breakiffalse This flag stops the current endpoint testing if the test is failed. StatusCode:200:breakiffalse

Adding tests

  • Edit test collection found in /collections/