Package jline.streaming
Class MockHttpReceiver
java.lang.Object
jline.streaming.MockHttpReceiver
Mock HTTP receiver for testing streaming functionality.
Uses Java's built-in HttpServer for maximum compatibility.
Receives JSON metrics via HTTP POST and captures them for verification.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the endpoint string for this receiver.intgetPort()Gets the port this receiver is listening on.Gets all metric names received.Gets all received JSON payloads.intGets the total number of POST requests received.intGets the total number of metrics received across all requests.booleanhasReceivedMetric(String metricName) Checks if a specific metric type was received.voidreset()Clears all received data.voidstart()Starts the mock receiver.voidstop()Stops the mock receiver gracefully.
-
Constructor Details
-
MockHttpReceiver
Creates a mock HTTP receiver on a random available port.- Throws:
IOException- if unable to find an available port or start the server
-
-
Method Details
-
start
public void start()Starts the mock receiver. -
stop
public void stop()Stops the mock receiver gracefully. -
getPort
public int getPort()Gets the port this receiver is listening on.- Returns:
- the port number
-
getEndpoint
Gets the endpoint string for this receiver.- Returns:
- endpoint string (e.g., "http://localhost:12345/metrics")
-
getRequestCount
public int getRequestCount()Gets the total number of POST requests received.- Returns:
- number of requests
-
getTotalMetricCount
public int getTotalMetricCount()Gets the total number of metrics received across all requests.- Returns:
- total metric count
-
getReceivedMetricNames
Gets all metric names received.- Returns:
- list of metric names
-
getReceivedPayloads
Gets all received JSON payloads.- Returns:
- list of JSON strings
-
hasReceivedMetric
Checks if a specific metric type was received.- Parameters:
metricName- the metric name to check- Returns:
- true if at least one metric with that name was received
-
reset
public void reset()Clears all received data.
-