Test

Test Resource

The Test Resource includes endpoints that can be used to move the clock. Note that the endpoints in this section should only be used in a test environment and never in a production environment. In order to use the endpoints in this section, the org.killbill.server.test.mode=true property needs to be set. See Kill Bill Configuration Guide to know more about setting config properties.

ClockResource

The ClockResource represents the current time. It has the following attributes:

Name Type Generated by Description
currentUtcTime string system Current UTC time
timeZone string system TimeZone corresponding to the the localDate attribute
localDate string user The current date in the timezone specified by the timeZone attribute.

Clock APIs

As mentioned earlier, the APIs in this section can be used to manipulate the KB clock.

Get Current Time

This API can be used to obtain the current time.

HTTP Request

GET http://127.0.0.1:8080/1.0/kb/test/clock

Example Request:

curl -v \
    -u admin:password \
    -H "X-Killbill-ApiKey: bob" \
    -H "X-Killbill-ApiSecret: lazar" \
    -H "Content-Type: application/json" \
    -H 'X-Killbill-CreatedBy: demo' \
    "http://127.0.0.1:8080/1.0/kb/test/clock"   

# with timeZone:
curl -v \
    -u admin:password \
    -H "X-Killbill-ApiKey: bob" \
    -H "X-Killbill-ApiSecret: lazar" \
    -H "Content-Type: application/json" \
    -H 'X-Killbill-CreatedBy: demo' \
    "http://127.0.0.1:8080/1.0/kb/test/clock?timeZone=America/Los_Angeles"  
TODO
TODO
TODO
TODO
TODO

Example Response:

{
  "currentUtcTime": "2025-04-24T10:42:53.000Z",
  "timeZone": "UTC",
  "localDate": "2025-04-24"
}

Query Parameters

Name Type Required Default Description
timeZone string false None The timezone in which to return the localDate

Response

If successful, returns a status code of 200 and a ClockResource object.

Set Time

This API updates the KB clock with the specified time.

HTTP Request

POST http://127.0.0.1:8080/1.0/kb/clock

Example Request:

# With DateTime
curl -v \
    -u admin:password \
    -H "X-Killbill-ApiKey: bob" \
    -H "X-Killbill-ApiSecret: lazar" \
    -H "Content-Type: application/json" \
    -H 'X-Killbill-CreatedBy: demo' \
    -X POST \
    "http://127.0.0.1:8080/1.0/kb/test/clock?requestedDate=2025-03-19T05:54:00"

# With LocalDate
curl -v \
    -u admin:password \
    -H "X-Killbill-ApiKey: bob" \
    -H "X-Killbill-ApiSecret: lazar" \
    -H "Content-Type: application/json" \
    -H 'X-Killbill-CreatedBy: demo' \
    -X POST \
    "http://127.0.0.1:8080/1.0/kb/test/clock?requestedDate=2025-03-19"  
TODO
TODO
TODO
TODO
TODO

Example Response:

{
  "currentUtcTime": "2025-03-19T05:54:00.000Z",
  "timeZone": "UTC",
  "localDate": "2025-03-19"
}

Request Body

None

Query Parameters

Name Type Required Default Description
requestedDate string false Current Date/DateTime Date/DateTime to which the clock should be set.
timeZone string false None The timezone in which to return the localDate
timeoutSec long false 5 Number of seconds for which the system should wait for processing notifications after moving the clock.

Response

If successful, returns a status code of 200 and a ClockResource object.

Update Time

This API moves the KB clock ahead by the specified number of days/weeks/months/years.

HTTP Request

PUT http://127.0.0.1:8080/1.0/kb/clock

Example Request:

# move clock by a week
curl -v \
    -u admin:password \
    -H "X-Killbill-ApiKey: bob" \
    -H "X-Killbill-ApiSecret: lazar" \
    -H "Content-Type: application/json" \
    -H 'X-Killbill-CreatedBy: demo' \
    -X PUT \
    "http://127.0.0.1:8080/1.0/kb/test/clock?weeks=1"

# move clock by 3 days
curl -v \
    -u admin:password \
    -H "X-Killbill-ApiKey: bob" \
    -H "X-Killbill-ApiSecret: lazar" \
    -H "Content-Type: application/json" \
    -H 'X-Killbill-CreatedBy: demo' \
    -X PUT \
    "http://127.0.0.1:8080/1.0/kb/test/clock?days=3"        
TODO
TODO
TODO
TODO
TODO

Example Response:

{
  "currentUtcTime": "2025-03-19T05:54:00.000Z",
  "timeZone": "UTC",
  "localDate": "2025-03-19"
}

Request Body

None

Query Parameters

Name Type Required Default Description
days string false None Number of days by which to move the clock
weeks string false None Number of weeks by which to move the clock
months string false None Number of months by which to move the clock
years string false None Number of years by which to move the clock
timeZone string false None The timezone in which to return the localDate
timeoutSec long false 5 Number of seconds for which the system should wait for processing notifications after moving the clock.

Note that only one query parameter should be specified. So if days is specified as the first query parameter, the API moves the clock ahead by the specified number of days, other query parameters if specified are ignored.

Response

If successful, returns a status code of 200 and a ClockResource object.

Queue APIs

Wait for Queues to Complete

This API can be used to get the system to wait for the specified time for all available bus events and notifications to be processed.

HTTP Request

GET http://127.0.0.1:8080/1.0/kb/test/queues

Example Request:

curl -v \
    -u admin:password \
    -H "X-Killbill-ApiKey: bob" \
    -H "X-Killbill-ApiSecret: lazar" \
    -H "Content-Type: application/json" \
    -H 'X-Killbill-CreatedBy: demo' \
    "http://127.0.0.1:8080/1.0/kb/test/queues"  
TODO
TODO
TODO
TODO
TODO

Query Parameters

Name Type Required Default Description
timeoutSec long false 5 Number of seconds for which the system should wait for processing notifications.

Response

If successful, returns a status code of 200 and an empty body