aboutsummaryrefslogtreecommitdiff
path: root/src/test/scala
diff options
context:
space:
mode:
authorIvan Topolnak <ivantopo@gmail.com>2013-05-31 18:10:15 -0300
committerIvan Topolnak <ivantopo@gmail.com>2013-05-31 18:10:15 -0300
commite88fa503bbe043c0e152290bbd4e68601ab79eb8 (patch)
tree1b28c3d68a874789fcc863e0daf1b52abe6dc0b8 /src/test/scala
parent148827486f116c4196888022f04ad053f4fb6e99 (diff)
downloadKamon-e88fa503bbe043c0e152290bbd4e68601ab79eb8.tar.gz
Kamon-e88fa503bbe043c0e152290bbd4e68601ab79eb8.tar.bz2
Kamon-e88fa503bbe043c0e152290bbd4e68601ab79eb8.zip
wip
Diffstat (limited to 'src/test/scala')
-rw-r--r--src/test/scala/kamon/instrumentation/RunnableInstrumentationSpec.scala17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/test/scala/kamon/instrumentation/RunnableInstrumentationSpec.scala b/src/test/scala/kamon/instrumentation/RunnableInstrumentationSpec.scala
index f2e83824..4fe9e617 100644
--- a/src/test/scala/kamon/instrumentation/RunnableInstrumentationSpec.scala
+++ b/src/test/scala/kamon/instrumentation/RunnableInstrumentationSpec.scala
@@ -1,7 +1,6 @@
package kamon.instrumentation
import scala.concurrent.{Await, Promise, Future}
-import scala.concurrent.ExecutionContext.Implicits.global
import org.scalatest.{OptionValues, WordSpec}
import org.scalatest.matchers.MustMatchers
import org.scalatest.concurrent.PatienceConfiguration
@@ -18,14 +17,14 @@ class RunnableInstrumentationSpec extends WordSpec with MustMatchers with ScalaF
"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 FutureWithContext {
+ "should be available during the run method execution" in { new FutureWithContextFixture {
whenReady(futureWithContext) { result =>
result.value must be === testContext
}
}}
- "should be available during the execution of onComplete callbacks" in { new FutureWithContext {
+ "should be available during the execution of onComplete callbacks" in { new FutureWithContextFixture {
val onCompleteContext = Promise[TraceContext]()
futureWithContext.onComplete({
@@ -40,14 +39,14 @@ class RunnableInstrumentationSpec extends WordSpec with MustMatchers with ScalaF
}
"created in a thread that doest have a TraceContext" must {
- "not capture any TraceContext for the body execution" in { new FutureWithoutContext{
+ "not capture any TraceContext for the body execution" in { new FutureWithoutContextFixture{
whenReady(futureWithoutContext) { result =>
result must be === None
}
}}
- "not make any TraceContext available during the onComplete callback" in { new FutureWithoutContext {
+ "not make any TraceContext available during the onComplete callback" in { new FutureWithoutContextFixture {
val onCompleteContext = Promise[Option[TraceContext]]()
futureWithoutContext.onComplete({
@@ -65,17 +64,17 @@ class RunnableInstrumentationSpec extends WordSpec with MustMatchers with ScalaF
/**
* 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
-
- trait FutureWithContext {
- implicit val as = ActorSystem("test-actorsystem")
+ class FutureWithContextFixture {
val testContext = TraceContext()
Kamon.set(testContext)
val futureWithContext = Future { Kamon.context}
}
- trait FutureWithoutContext {
+ trait FutureWithoutContextFixture {
Kamon.clear // Make sure no TraceContext is available
val futureWithoutContext = Future { Kamon.context }
}