Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions hadoop-hdds/common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,21 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.jaegertracing</groupId>
<artifactId>jaeger-client</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
Expand All @@ -23,7 +23,7 @@
import org.apache.ozone.test.LambdaTestUtils;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;

class TestStringCodec {

Expand All @@ -44,9 +44,17 @@ void testExtract() throws Exception {
"String does not match tracer state format",
() -> codec.extract(sb));
sb.append(":66");

JaegerSpanContext context = codec.extract(sb);
String expectedContextString = "123:456:789:66";
assertTrue(context.getTraceId().equals("123"));
assertTrue(context.toString().equals(expectedContextString));
StringBuilder injected = new StringBuilder();
codec.inject(context, injected);

String expectedTraceId = pad("123");
assertEquals(expectedTraceId, context.getTraceId());
assertEquals(expectedTraceId + ":456:789:66", injected.toString());
}

private static String pad(String s) {
return "0000000000000000".substring(s.length()) + s;
}
}