diff options
author | Ivan Topolnak <ivantopo@gmail.com> | 2013-11-05 18:38:39 -0300 |
---|---|---|
committer | Ivan Topolnak <ivantopo@gmail.com> | 2013-11-05 18:38:39 -0300 |
commit | 2b63540e5fffab545d0846cfb3dab5c0e1d0c9e1 (patch) | |
tree | 56c4ad1f025c9144376cd4463ad4d4a23e37b571 /kamon-core/src/test/scala/kamon/instrumentation/RunnableInstrumentationSpec.scala | |
parent | 5127c3bb83cd6fe90e071720d995cfb53d913e6a (diff) | |
download | Kamon-2b63540e5fffab545d0846cfb3dab5c0e1d0c9e1.tar.gz Kamon-2b63540e5fffab545d0846cfb3dab5c0e1d0c9e1.tar.bz2 Kamon-2b63540e5fffab545d0846cfb3dab5c0e1d0c9e1.zip |
basic separation of concerns between sub-projects
Diffstat (limited to 'kamon-core/src/test/scala/kamon/instrumentation/RunnableInstrumentationSpec.scala')
-rw-r--r-- | kamon-core/src/test/scala/kamon/instrumentation/RunnableInstrumentationSpec.scala | 86 |
1 files changed, 0 insertions, 86 deletions
diff --git a/kamon-core/src/test/scala/kamon/instrumentation/RunnableInstrumentationSpec.scala b/kamon-core/src/test/scala/kamon/instrumentation/RunnableInstrumentationSpec.scala deleted file mode 100644 index 570f64dd..00000000 --- a/kamon-core/src/test/scala/kamon/instrumentation/RunnableInstrumentationSpec.scala +++ /dev/null @@ -1,86 +0,0 @@ -package kamon.instrumentation - -import scala.concurrent.{Await, Promise, Future} -import org.scalatest.{Matchers, OptionValues, WordSpec} -import org.scalatest.concurrent.{ScalaFutures, PatienceConfiguration} -import kamon.{Tracer, Kamon} -import java.util.UUID -import scala.util.Success -import scala.concurrent.duration._ -import java.util.concurrent.TimeUnit -import akka.actor.ActorSystem -import kamon.trace.TraceContext - - -class RunnableInstrumentationSpec extends WordSpec with Matchers with ScalaFutures with PatienceConfiguration with OptionValues { - - "a instrumented runnable" when { - "created in a thread that does have a TraceContext" must { - "preserve the TraceContext" which { - "should be available during the run method execution" in new FutureWithContextFixture { - - whenReady(futureWithContext) { result => - result.value should equal(testContext) - } - } - - "should be available during the execution of onComplete callbacks" in new FutureWithContextFixture { - - val onCompleteContext = Promise[Option[TraceContext]]() - - Tracer.traceContext.withValue(Some(testContext)) { - futureWithContext.onComplete({ - case _ => println("Completing second promise from: "+Thread.currentThread().getName + " With Context: " + Tracer.traceContext.value); onCompleteContext.complete(Success(Tracer.traceContext.value)) - }) - } - - whenReady(onCompleteContext.future) { result => - result should equal(Some(testContext)) - } - } - } - } - - "created in a thread that doest have a TraceContext" must { - "not capture any TraceContext for the body execution" in new FutureWithoutContextFixture{ - whenReady(futureWithoutContext) { result => - result should equal(None) - } - } - - "not make any TraceContext available during the onComplete callback" in new FutureWithoutContextFixture { - val onCompleteContext = Promise[Option[TraceContext]]() - - futureWithoutContext.onComplete { - case _ => onCompleteContext.complete(Success(Tracer.traceContext.value)) - } - - whenReady(onCompleteContext.future) { result => - result should equal(None) - } - } - } - } - - - /** - * We are using Futures for the test since they exercise Runnables in the back and also resemble the real use case we have. - */ - implicit val testActorSystem = ActorSystem("test-actorsystem") - implicit val execContext = testActorSystem.dispatcher - - class FutureWithContextFixture { - val testContext = TraceContext() - - var futureWithContext: Future[Option[TraceContext]] = _ - Tracer.traceContext.withValue(Some(testContext)) { - futureWithContext = Future { Tracer.traceContext.value } - } - } - - trait FutureWithoutContextFixture { - val futureWithoutContext = Future { Tracer.traceContext.value } - } -} - - |