aboutsummaryrefslogtreecommitdiff
path: root/kamon-core/src/legacy-test/scala/kamon/trace/logging/MdcKeysSupportSpec.scala
diff options
context:
space:
mode:
authorIvan Topolnjak <ivantopo@gmail.com>2017-04-24 13:54:40 +0200
committerIvan Topolnjak <ivantopo@gmail.com>2017-04-24 13:54:40 +0200
commit4d828e1a3195e55365c865aa3a78af9668742643 (patch)
tree07fff2683933c96297a8ba577bbdc89888da16e1 /kamon-core/src/legacy-test/scala/kamon/trace/logging/MdcKeysSupportSpec.scala
parent469c11dc1ddb140f407a33f48033e533bf60611c (diff)
downloadKamon-4d828e1a3195e55365c865aa3a78af9668742643.tar.gz
Kamon-4d828e1a3195e55365c865aa3a78af9668742643.tar.bz2
Kamon-4d828e1a3195e55365c865aa3a78af9668742643.zip
Prepare for the major cleanup
Moved all the original files from src/main to src/legacy-main, same with test files. Also removed the autoweave module, examples and bench as I'm planning to have them in separate repositories.
Diffstat (limited to 'kamon-core/src/legacy-test/scala/kamon/trace/logging/MdcKeysSupportSpec.scala')
-rw-r--r--kamon-core/src/legacy-test/scala/kamon/trace/logging/MdcKeysSupportSpec.scala44
1 files changed, 44 insertions, 0 deletions
diff --git a/kamon-core/src/legacy-test/scala/kamon/trace/logging/MdcKeysSupportSpec.scala b/kamon-core/src/legacy-test/scala/kamon/trace/logging/MdcKeysSupportSpec.scala
new file mode 100644
index 00000000..39374e79
--- /dev/null
+++ b/kamon-core/src/legacy-test/scala/kamon/trace/logging/MdcKeysSupportSpec.scala
@@ -0,0 +1,44 @@
+package kamon.trace.logging
+
+import kamon.testkit.BaseKamonSpec
+import kamon.trace.{EmptyTraceContext, Tracer}
+import org.slf4j.MDC
+
+class MdcKeysSupportSpec extends BaseKamonSpec("mdc-keys-support-spec") {
+
+ "Running code with MDC support" should {
+ "add nothing to the MDC" when {
+ "the trace context is empty" in {
+ // Given an empty trace context.
+ Tracer.withContext(EmptyTraceContext) {
+ // When some code is executed with MDC support.
+ MdcKeysSupport.withMdc {
+ // Then the MDC should not contain the trace token.
+ Option(MDC.get(MdcKeysSupport.traceTokenKey)) should be(None)
+ // Or name
+ Option(MDC.get(MdcKeysSupport.traceNameKey)) should be(None)
+ }
+ }
+ }
+ }
+ "add the trace token and name to the context" when {
+ "the trace context is not empty" in {
+ // Given a trace context.
+ Tracer.withNewContext("name", Some("token")) {
+ // When some code is executed with MDC support.
+ MdcKeysSupport.withMdc {
+ // Then the MDC should contain the trace token.
+ Option(MDC.get(MdcKeysSupport.traceTokenKey)) should be(Some("token"))
+ // And name
+ Option(MDC.get(MdcKeysSupport.traceNameKey)) should be(Some("name"))
+ }
+
+ // Then after code is executed the MDC should have been cleared.
+ Option(MDC.get(MdcKeysSupport.traceTokenKey)) should be(None)
+ Option(MDC.get(MdcKeysSupport.traceNameKey)) should be(None)
+ }
+ }
+ }
+ }
+
+}