public final class ZipkinRule extends Object implements org.junit.rules.TestRule
httpUrl().
This can be used to test instrumentation. For example, you can POST spans directly to this server. See http://openzipkin.github.io/zipkin-api/#/
| Constructor and Description |
|---|
ZipkinRule() |
| Modifier and Type | Method and Description |
|---|---|
org.junit.runners.model.Statement |
apply(org.junit.runners.model.Statement base,
org.junit.runner.Description description) |
InMemoryCollectorMetrics |
collectorMetrics()
Use this to see how many spans or serialized bytes were collected on the http endpoint.
|
ZipkinRule |
enqueueFailure(HttpFailure failure)
Adds a one-time failure to the http endpoint.
|
List<List<Span>> |
getTraces()
Retrieves all traces this zipkin server has received.
|
int |
httpRequestCount()
Use this to see how many requests you've sent to any zipkin http endpoint.
|
String |
httpUrl()
Use this to connect.
|
void |
shutdown()
Used to manually stop the server.
|
void |
start(int httpPort)
Used to manually start the server.
|
ZipkinRule |
storeSpans(List<Span> spans)
Stores the given spans directly, to setup preconditions for a test.
|
public String httpUrl()
public int httpRequestCount()
public InMemoryCollectorMetrics collectorMetrics()
public ZipkinRule storeSpans(List<Span> spans)
For example, if you are testing what happens when instrumentation adds a child to a trace, you'd add the parent here.
public ZipkinRule enqueueFailure(HttpFailure failure)
Ex. If you want to test that you don't repeatedly send bad data, you could send a 400 back.
zipkin.enqueueFailure(sendErrorResponse(400, "bad format"));
failure - type of failure the next call to the http endpoint responds withpublic void start(int httpPort)
throws IOException
httpPort - choose 0 to select an available portIOExceptionpublic void shutdown()
throws IOException
IOExceptionpublic org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base,
org.junit.runner.Description description)
apply in interface org.junit.rules.TestRuleCopyright © 2015–2017 OpenZipkin. All rights reserved.