How to Test MarkLogic Rest APIs in Roxy?

130 Views Asked by At

How can I test the MarkLogic REST APIs using the Roxy framework? The default Roxy test framework is used to test the legacy application, and we have recently introduced the REST APIs; So looking for some custom solution to test the REST APIs.

The directory structure:

|   ml.bat
+---data
+---deploy
+---project-files
+---rest-api  -------------> Newly introduced REST APIs source code
\---src       -------------> legacy application source code

Any help would be appreciated.

2

There are 2 best solutions below

0
On

If you import modules that do the actual work, you can test those as part of the 'legacy' application code.

For testing REST extensions (you might also want to look at Data Services which is more light-weight) I'd personally just use an ordinary REST/HTTP test tool, like Postman, Raygun, JMeters, etc.

Out of curiosity, are you using Roxy-MVC, or Roxy-Hybrid? Or basically Roxy as deployment tool to work on a REST-api application? I am asking since not much has happened with Roxy for over a year now, so would be best to move over to ml-gradle.

0
On

Marklogic workflow has tests of this type: https://github.com/marklogic-community/marklogicworkflow/tree/develop/src/test/ml-modules/root/test - examples in suites start e2e-rest and use the xdmp:http-X functions

They're not for the faint of heart though as the endpoints need to be copied into the test database by the suite setup (see workflow-deploy-rest-resources.xqy), and be careful not to remove until all tests have been run.