diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2013-12-18 20:41:20 -0300 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2013-12-18 20:41:20 -0300 |
commit | 705f76aa41ebdf9384530e2e0d850a0ef703a5e6 (patch) | |
tree | d6026b84ca0f59823f5ead10291655b0ec7bf2a5 /kamon-trace/src/test | |
parent | 1d9305dc7a8ad2d6457b5ebe1635eb4838cf13a0 (diff) | |
download | Kamon-705f76aa41ebdf9384530e2e0d850a0ef703a5e6.tar.gz Kamon-705f76aa41ebdf9384530e2e0d850a0ef703a5e6.tar.bz2 Kamon-705f76aa41ebdf9384530e2e0d850a0ef703a5e6.zip |
more reformatted code
Diffstat (limited to 'kamon-trace/src/test')
5 files changed, 58 insertions, 68 deletions
diff --git a/kamon-trace/src/test/scala/kamon/trace/instrumentation/ActorLoggingSpec.scala b/kamon-trace/src/test/scala/kamon/trace/instrumentation/ActorLoggingSpec.scala index ed6acd00..89742651 100644 --- a/kamon-trace/src/test/scala/kamon/trace/instrumentation/ActorLoggingSpec.scala +++ b/kamon-trace/src/test/scala/kamon/trace/instrumentation/ActorLoggingSpec.scala @@ -16,10 +16,10 @@ package kamon.trace.instrumentation import akka.testkit.TestKit -import org.scalatest.{Inspectors, Matchers, WordSpecLike} -import akka.actor.{Props, ActorLogging, Actor, ActorSystem} -import akka.event.Logging.{LogEvent} -import kamon.trace.{ContextAware, TraceContext, Trace} +import org.scalatest.{ Inspectors, Matchers, WordSpecLike } +import akka.actor.{ Props, ActorLogging, Actor, ActorSystem } +import akka.event.Logging.{ LogEvent } +import kamon.trace.{ ContextAware, TraceContext, Trace } class ActorLoggingSpec extends TestKit(ActorSystem("actor-logging-spec")) with WordSpecLike with Matchers with Inspectors { @@ -34,11 +34,11 @@ class ActorLoggingSpec extends TestKit(ActorSystem("actor-logging-spec")) with W } fishForMessage() { - case event: LogEvent if event.message.toString contains "TraceContext =>" => + case event: LogEvent if event.message.toString contains "TraceContext =>" ⇒ val ctxInEvent = event.asInstanceOf[ContextAware].traceContext ctxInEvent === testTraceContext - case event: LogEvent => false + case event: LogEvent ⇒ false } } } @@ -46,6 +46,6 @@ class ActorLoggingSpec extends TestKit(ActorSystem("actor-logging-spec")) with W class LoggerActor extends Actor with ActorLogging { def receive = { - case "info" => log.info("TraceContext => {}", Trace.context()) + case "info" ⇒ log.info("TraceContext => {}", Trace.context()) } } diff --git a/kamon-trace/src/test/scala/kamon/trace/instrumentation/ActorMessagePassingTracingSpec.scala b/kamon-trace/src/test/scala/kamon/trace/instrumentation/ActorMessagePassingTracingSpec.scala index 184953b1..89251bf4 100644 --- a/kamon-trace/src/test/scala/kamon/trace/instrumentation/ActorMessagePassingTracingSpec.scala +++ b/kamon-trace/src/test/scala/kamon/trace/instrumentation/ActorMessagePassingTracingSpec.scala @@ -15,56 +15,55 @@ * ========================================================== */ package kamon.trace.instrumentation -import org.scalatest.{WordSpecLike, Matchers} -import akka.actor.{ActorRef, Actor, Props, ActorSystem} +import org.scalatest.{ WordSpecLike, Matchers } +import akka.actor.{ ActorRef, Actor, Props, ActorSystem } -import akka.testkit.{ImplicitSender, TestKit} +import akka.testkit.{ ImplicitSender, TestKit } import kamon.trace.Trace -import akka.pattern.{pipe, ask} +import akka.pattern.{ pipe, ask } import akka.util.Timeout import scala.concurrent.duration._ -import scala.concurrent.{Await, Future} +import scala.concurrent.{ Await, Future } import akka.routing.RoundRobinRouter import kamon.trace.TraceContext - class ActorMessagePassingTracingSpec extends TestKit(ActorSystem("actor-message-passing-tracing-spec")) with WordSpecLike with ImplicitSender { implicit val executionContext = system.dispatcher "the message passing instrumentation" should { - "propagate the TraceContext using bang" in new TraceContextEchoFixture { - Trace.withContext(testTraceContext) { - ctxEchoActor ! "test" - } - - expectMsg(testTraceContext) + "propagate the TraceContext using bang" in new TraceContextEchoFixture { + Trace.withContext(testTraceContext) { + ctxEchoActor ! "test" } - "propagate the TraceContext using tell" in new TraceContextEchoFixture { - Trace.withContext(testTraceContext) { - ctxEchoActor.tell("test", testActor) - } + expectMsg(testTraceContext) + } - expectMsg(testTraceContext) + "propagate the TraceContext using tell" in new TraceContextEchoFixture { + Trace.withContext(testTraceContext) { + ctxEchoActor.tell("test", testActor) } - "propagate the TraceContext using ask" in new TraceContextEchoFixture { - implicit val timeout = Timeout(1 seconds) - Trace.withContext(testTraceContext) { - // The pipe pattern use Futures internally, so FutureTracing test should cover the underpinnings of it. - (ctxEchoActor ? "test") pipeTo(testActor) - } + expectMsg(testTraceContext) + } - expectMsg(testTraceContext) + "propagate the TraceContext using ask" in new TraceContextEchoFixture { + implicit val timeout = Timeout(1 seconds) + Trace.withContext(testTraceContext) { + // The pipe pattern use Futures internally, so FutureTracing test should cover the underpinnings of it. + (ctxEchoActor ? "test") pipeTo (testActor) } - "propagate the TraceContext to actors behind a router" in new RoutedTraceContextEchoFixture { - Trace.withContext(testTraceContext) { - ctxEchoActor ! "test" - } + expectMsg(testTraceContext) + } - expectMsg(testTraceContext) + "propagate the TraceContext to actors behind a router" in new RoutedTraceContextEchoFixture { + Trace.withContext(testTraceContext) { + ctxEchoActor ! "test" } + + expectMsg(testTraceContext) + } } trait TraceContextEchoFixture { @@ -83,6 +82,3 @@ class TraceContextEcho extends Actor { } } - - - diff --git a/kamon-trace/src/test/scala/kamon/trace/instrumentation/AskPatternTracingSpec.scala b/kamon-trace/src/test/scala/kamon/trace/instrumentation/AskPatternTracingSpec.scala index 10060ff3..a3e43aee 100644 --- a/kamon-trace/src/test/scala/kamon/trace/instrumentation/AskPatternTracingSpec.scala +++ b/kamon-trace/src/test/scala/kamon/trace/instrumentation/AskPatternTracingSpec.scala @@ -16,16 +16,15 @@ package kamon.trace.instrumentation import akka.testkit.TestKit -import akka.actor.{Props, Actor, ActorSystem} -import org.scalatest.{Matchers, WordSpecLike} +import akka.actor.{ Props, Actor, ActorSystem } +import org.scalatest.{ Matchers, WordSpecLike } import akka.event.Logging.Warning import scala.concurrent.duration._ import akka.pattern.ask import akka.util.Timeout -import kamon.trace.{Trace, ContextAware} +import kamon.trace.{ Trace, ContextAware } import org.scalatest.OptionValues._ - class AskPatternTracingSpec extends TestKit(ActorSystem("ask-pattern-tracing-spec")) with WordSpecLike with Matchers { "the AskPatternTracing" should { @@ -40,12 +39,12 @@ class AskPatternTracingSpec extends TestKit(ActorSystem("ask-pattern-tracing-spe noReply ? "hello" val warn = expectMsgPF() { - case warn: Warning if warn.message.toString.contains("Timeout triggered for ask pattern") => warn + case warn: Warning if warn.message.toString.contains("Timeout triggered for ask pattern") ⇒ warn } val capturedCtx = warn.asInstanceOf[ContextAware].traceContext capturedCtx should be('defined) - capturedCtx.value should equal (initialCtx) + capturedCtx.value should equal(initialCtx) } } } @@ -53,6 +52,6 @@ class AskPatternTracingSpec extends TestKit(ActorSystem("ask-pattern-tracing-spe class NoReply extends Actor { def receive = { - case any => + case any ⇒ } } diff --git a/kamon-trace/src/test/scala/kamon/trace/instrumentation/FutureTracingSpec.scala b/kamon-trace/src/test/scala/kamon/trace/instrumentation/FutureTracingSpec.scala index 9989bfca..339fe6be 100644 --- a/kamon-trace/src/test/scala/kamon/trace/instrumentation/FutureTracingSpec.scala +++ b/kamon-trace/src/test/scala/kamon/trace/instrumentation/FutureTracingSpec.scala @@ -15,16 +15,15 @@ * ========================================================== */ package kamon.trace.instrumentation -import scala.concurrent.{ExecutionContext, Await, Promise, Future} -import org.scalatest.{Matchers, OptionValues, WordSpec} -import org.scalatest.concurrent.{ScalaFutures, PatienceConfiguration} +import scala.concurrent.{ ExecutionContext, Await, Promise, Future } +import org.scalatest.{ Matchers, OptionValues, WordSpec } +import org.scalatest.concurrent.{ ScalaFutures, PatienceConfiguration } import java.util.UUID -import scala.util.{Random, Success} +import scala.util.{ Random, Success } import scala.concurrent.duration._ import java.util.concurrent.TimeUnit -import akka.actor.{Actor, ActorSystem} -import kamon.trace.{Trace, TraceContext} - +import akka.actor.{ Actor, ActorSystem } +import kamon.trace.{ Trace, TraceContext } class FutureTracingSpec extends WordSpec with Matchers with ScalaFutures with PatienceConfiguration with OptionValues { @@ -39,9 +38,8 @@ class FutureTracingSpec extends WordSpec with Matchers with ScalaFutures with Pa future = Future(Trace.context) } - whenReady(future)( ctxInFuture => - ctxInFuture should equal(testTraceContext) - ) + whenReady(future)(ctxInFuture ⇒ + ctxInFuture should equal(testTraceContext)) } "must be available when executing callbacks on the future" in new TraceContextFixture { @@ -50,14 +48,13 @@ class FutureTracingSpec extends WordSpec with Matchers with ScalaFutures with Pa Trace.withContext(testTraceContext) { future = Future("Hello Kamon!") // The TraceContext is expected to be available during all intermediate processing. - .map (_.length) - .flatMap(len => Future(len.toString)) - .map (s => Trace.context()) + .map(_.length) + .flatMap(len ⇒ Future(len.toString)) + .map(s ⇒ Trace.context()) } - whenReady(future)( ctxInFuture => - ctxInFuture should equal(testTraceContext) - ) + whenReady(future)(ctxInFuture ⇒ + ctxInFuture should equal(testTraceContext)) } } } @@ -68,4 +65,3 @@ class FutureTracingSpec extends WordSpec with Matchers with ScalaFutures with Pa } } - diff --git a/kamon-trace/src/test/scala/kamon/trace/instrumentation/TraceAggregatorSpec.scala b/kamon-trace/src/test/scala/kamon/trace/instrumentation/TraceAggregatorSpec.scala index a29f6788..3b32f3ac 100644 --- a/kamon-trace/src/test/scala/kamon/trace/instrumentation/TraceAggregatorSpec.scala +++ b/kamon-trace/src/test/scala/kamon/trace/instrumentation/TraceAggregatorSpec.scala @@ -15,12 +15,12 @@ * ========================================================== */ package kamon.trace.instrumentation -import org.scalatest.{WordSpecLike, WordSpec} -import akka.testkit.{TestKitBase, TestKit} +import org.scalatest.{ WordSpecLike, WordSpec } +import akka.testkit.{ TestKitBase, TestKit } import akka.actor.ActorSystem import scala.concurrent.duration._ -import kamon.trace.UowTracing.{Finish, Rename, Start} -import kamon.trace.{UowTrace, UowTraceAggregator} +import kamon.trace.UowTracing.{ Finish, Rename, Start } +import kamon.trace.{ UowTrace, UowTraceAggregator } class TraceAggregatorSpec extends TestKit(ActorSystem("TraceAggregatorSpec")) with WordSpecLike { @@ -45,7 +45,6 @@ class TraceAggregatorSpec extends TestKit(ActorSystem("TraceAggregatorSpec")) wi } } - trait AggregatorFixture { val aggregator = system.actorOf(UowTraceAggregator.props(testActor, 10 seconds)) } |