Class MockApmServer
java.lang.Object
org.elasticsearch.gradle.testclusters.MockApmServer
This is a server which just accepts lines of JSON code and if the JSON
is valid and the root node is "transaction", then adds that JSON object
to a transaction list which is accessible externally to the class.
The Elastic agent sends lines of JSON code, and so this mock server can be used as a basic APM server for testing.
The HTTP server used is the JDK embedded com.sun.net.httpserver
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
MockApmServer
public MockApmServer(int port)
-
-
Method Details
-
main
Simple main that starts a mock APM server and prints the port it is running on. This is not needed for testing, it is just a convenient template for trying things out if you want play around.- Throws:
IOExceptionInterruptedException
-
start
Start the Mock APM server. Just returns empty JSON structures for every incoming message- Returns:
- - the port the Mock APM server started on
- Throws:
IOException
-
getPort
public int getPort() -
stop
public void stop()Stop the server gracefully if possible
-