diff options
author | Diego <diegolparra@gmail.com> | 2014-11-19 22:09:41 -0300 |
---|---|---|
committer | Diego <diegolparra@gmail.com> | 2014-11-19 22:09:41 -0300 |
commit | 827644d92a216172cd587f253c1fc1a0bbdb5eaf (patch) | |
tree | 52883845f601cca03f5e299be536b4d9b013b48a /kamon-core/src/test/scala/kamon/trace | |
parent | d990039c7e0a3b6a909f93dc477fc7aaf4907e42 (diff) | |
download | Kamon-827644d92a216172cd587f253c1fc1a0bbdb5eaf.tar.gz Kamon-827644d92a216172cd587f253c1fc1a0bbdb5eaf.tar.bz2 Kamon-827644d92a216172cd587f253c1fc1a0bbdb5eaf.zip |
+ core: refactor MDC facilities and closes #100
Diffstat (limited to 'kamon-core/src/test/scala/kamon/trace')
-rw-r--r-- | kamon-core/src/test/scala/kamon/trace/TraceLocalSpec.scala | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/kamon-core/src/test/scala/kamon/trace/TraceLocalSpec.scala b/kamon-core/src/test/scala/kamon/trace/TraceLocalSpec.scala index 927573c2..b23c1c03 100644 --- a/kamon-core/src/test/scala/kamon/trace/TraceLocalSpec.scala +++ b/kamon-core/src/test/scala/kamon/trace/TraceLocalSpec.scala @@ -16,13 +16,18 @@ package kamon.trace -import akka.testkit.TestKit import akka.actor.ActorSystem -import org.scalatest.{ OptionValues, Matchers, WordSpecLike } +import akka.testkit.TestKit +import kamon.trace.TraceLocal.AvailableToMdc +import kamon.trace.logging.MdcKeysSupport import org.scalatest.concurrent.PatienceConfiguration +import org.scalatest.{Matchers, OptionValues, WordSpecLike} +import org.slf4j.MDC class TraceLocalSpec extends TestKit(ActorSystem("trace-local-spec")) with WordSpecLike with Matchers - with PatienceConfiguration with OptionValues { + with PatienceConfiguration with OptionValues with MdcKeysSupport { + + val SampleTraceLocalKeyAvailableToMDC = AvailableToMdc("someKey") object SampleTraceLocalKey extends TraceLocal.TraceLocalKey { type ValueType = String } @@ -61,5 +66,31 @@ class TraceLocalSpec extends TestKit(ActorSystem("trace-local-spec")) with WordS TraceLocal.retrieve(SampleTraceLocalKey).value should equal(testString) } } + + "allow retrieve a value from the MDC when was created a key with AvailableToMdc(cool-key)" in { + TraceRecorder.withNewTraceContext("store-and-retrieve-trace-local-and-copy-to-mdc") { + val testString = "Hello MDC" + + TraceLocal.store(SampleTraceLocalKeyAvailableToMDC)(testString) + TraceLocal.retrieve(SampleTraceLocalKeyAvailableToMDC).value should equal(testString) + + withMdc { + MDC.get("someKey") should equal(testString) + } + } + } + + "allow retrieve a value from the MDC when was created a key with AvailableToMdc.storeForMdc(String, String)" in { + TraceRecorder.withNewTraceContext("store-and-retrieve-trace-local-and-copy-to-mdc") { + val testString = "Hello MDC" + + TraceLocal.storeForMdc("someKey", testString) + TraceLocal.retrieve(SampleTraceLocalKeyAvailableToMDC).value should equal(testString) + + withMdc { + MDC.get("someKey") should equal(testString) + } + } + } } } |