Skip to content

Commit 58acb53

Browse files
authored
Add test that shows how context keys are special (#7330)
1 parent 18548f4 commit 58acb53

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

context/src/test/java/io/opentelemetry/context/ContextTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import static org.assertj.core.api.Assertions.assertThat;
99
import static org.awaitility.Awaitility.await;
10+
import static org.junit.jupiter.api.Assertions.assertNull;
1011
import static org.mockito.ArgumentMatchers.any;
1112
import static org.mockito.ArgumentMatchers.anyLong;
1213
import static org.mockito.Mockito.doNothing;
@@ -108,6 +109,12 @@ void attachSameTwice() {
108109
assertThat(Context.current().get(ANIMAL)).isNull();
109110
}
110111

112+
@Test
113+
void keyEqualityIsInstanceCheck() {
114+
Context context = Context.current().with(ContextKey.named("animal"), "cat");
115+
assertNull(context.get(ContextKey.named("animal"))); // yup
116+
}
117+
111118
@Test
112119
void newThreadStartsWithRoot() throws Exception {
113120
Context context = Context.current().with(ANIMAL, "cat");

0 commit comments

Comments
 (0)