Skip to main content
Version: 2023.1

Custom endpoints - testing

Integration testing

To create integration tests for your custom endpoints, you need to create service tests by extending the AbstractGenesisTestSupport class and specifying the genesis-router.kts as the Script File Name. Provide the package names of genesis-router and the endpoint. Examples of how you would initialise a test extending this class are provided below.

class TestEndpoint : AbstractGenesisTestSupport<GenesisSet>(
GenesisTestConfig {
packageNames = mutableListOf("global.genesis.router", "alpha.custom.endpoint")
genesisHome = "/genesisHome"
scriptFileName = "genesis-router.kts"
parser = { it }
) {
override fun createDictionary(): GenesisDictionary = testDictionary()}

fun testRouterEndPoint() {
val client = HttpClient.newHttpClient()
val request = HttpRequest
.newBuilder(URI("http://localhost:9064/file-handler/upload")) //the second package name should refer to the package of your custom endpoints
val response = client.send(request, HttpResponse.BodyHandlers.ofString())
Assert.assertEquals("{ \"Result\": \"Successful upload\"}", response.body())

Manual testing

Testing with an API client

An API client is a useful way of testing components. As a client, it is effectively a front end seeking information from the server. You can test these endpoints on Postman App/Insomnia App.

Before you can make any calls custom endpoints, you have to permission yourself by obtaining a SESSION_AUTH_TOKEN. The details of how to do this are on our separate Testing page.

Once you have the SESSION_AUTH_TOKEN, keep a copy that you can paste into each request as you make your test call.

In the example below, we use Insomnia as the API client.

In the header, you need to supply:

  • a SOURCE_REF (always), which identifies you; you can use any string value that suits you
  • the SESSION_AUTH_TOKEN that permissions you to access the server

The url consists of:

  • the address or hostname of the server
  • custom-endpoint name