use of zipkin2.TestObjects.UTF_8 in project zipkin by openzipkin.
the class ElasticsearchSpanConsumerTest method writesSpanNaturallyWhenNoTimestamp.
@Test
void writesSpanNaturallyWhenNoTimestamp() throws Exception {
server.enqueue(SUCCESS_RESPONSE);
Span span = Span.newBuilder().traceId("1").id("1").name("foo").build();
accept(Span.newBuilder().traceId("1").id("1").name("foo").build());
assertThat(server.takeRequest().request().contentUtf8()).contains("\n" + new String(SpanBytesEncoder.JSON_V2.encode(span), UTF_8) + "\n");
}
use of zipkin2.TestObjects.UTF_8 in project zipkin by openzipkin.
the class JsonSerializersTest method span_specialCharsInJson.
/**
* This isn't a test of what we "should" accept as a span, rather that characters that trip-up
* json don't fail in SPAN_PARSER.
*/
@Test
public void span_specialCharsInJson() {
// service name is surrounded by control characters
Endpoint e = Endpoint.newBuilder().serviceName(new String(new char[] { 0, 'a', 1 })).build();
Span worstSpanInTheWorld = Span.newBuilder().traceId("1").id("1").name(new String(new char[] { '"', '\\', '\t', '\b', '\n', '\r', '\f' })).localEndpoint(e).addAnnotation(1L, "\u2028 and \u2029").putTag("\"foo", "Database error: ORA-00942:\u2028 and \u2029 table or view does not exist\n").build();
assertThat(parse(SPAN_PARSER, new String(SpanBytesEncoder.JSON_V2.encode(worstSpanInTheWorld), UTF_8))).isEqualTo(worstSpanInTheWorld);
}
use of zipkin2.TestObjects.UTF_8 in project zipkin by openzipkin.
the class V1JsonSpanWriterTest method writesEmptyServiceName.
@Test
public void writesEmptyServiceName() {
Span span = CLIENT_SPAN.toBuilder().localEndpoint(Endpoint.newBuilder().ip("127.0.0.1").build()).build();
writer.write(span, buf);
assertThat(new String(bytes, UTF_8)).contains("\"value\":\"foo\",\"endpoint\":{\"serviceName\":\"\",\"ipv4\":\"127.0.0.1\"}");
}
use of zipkin2.TestObjects.UTF_8 in project zipkin by openzipkin.
the class V2SpanWriterTest method omitsEmptySpanName.
@Test
public void omitsEmptySpanName() {
Span span = Span.newBuilder().traceId("7180c278b62e8f6a216a2aea45d08fc9").parentId("6b221d5bc9e6496c").id("5b4185666d50f68b").build();
writer.write(span, buf);
assertThat(new String(bytes, UTF_8)).doesNotContain("name");
}
use of zipkin2.TestObjects.UTF_8 in project zipkin by openzipkin.
the class V1SpanBytesDecoderTest method ignoresNonAddressBooleanBinaryAnnotations.
@Test
public void ignoresNonAddressBooleanBinaryAnnotations() {
String json = "{\n" + " \"traceId\": \"6b221d5bc9e6496c\",\n" + " \"id\": \"6b221d5bc9e6496c\",\n" + " \"binaryAnnotations\": [\n" + " {\n" + " \"key\": \"aa\",\n" + " \"value\": true,\n" + " \"endpoint\": {\n" + " \"serviceName\": \"foo\"\n" + " }\n" + " }\n" + " ]\n" + "}";
Span decoded = SpanBytesDecoder.JSON_V1.decodeOne(json.getBytes(UTF_8));
assertThat(decoded.tags()).isEmpty();
assertThat(decoded.localEndpoint()).isNull();
assertThat(decoded.remoteEndpoint()).isNull();
}
Aggregations