diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2013-12-04 00:36:26 -0300 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2013-12-04 00:36:26 -0300 |
commit | 6150d254657fa2c855b2c1825257a7210bdb2654 (patch) | |
tree | 135e174582911ca797ba6ad01cf20d054259fd0d /kamon-spray/src/test/scala/kamon | |
parent | 231b5b0fc61438ec96e309436295e86808abdbb5 (diff) | |
download | Kamon-6150d254657fa2c855b2c1825257a7210bdb2654.tar.gz Kamon-6150d254657fa2c855b2c1825257a7210bdb2654.tar.bz2 Kamon-6150d254657fa2c855b2c1825257a7210bdb2654.zip |
move server tests to a higher level of abstraction
Diffstat (limited to 'kamon-spray/src/test/scala/kamon')
-rw-r--r-- | kamon-spray/src/test/scala/kamon/spray/ServerRequestTracingSpec.scala (renamed from kamon-spray/src/test/scala/kamon/ServerRequestTracingSpec.scala) | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/kamon-spray/src/test/scala/kamon/ServerRequestTracingSpec.scala b/kamon-spray/src/test/scala/kamon/spray/ServerRequestTracingSpec.scala index d598431a..e54fe24f 100644 --- a/kamon-spray/src/test/scala/kamon/ServerRequestTracingSpec.scala +++ b/kamon-spray/src/test/scala/kamon/spray/ServerRequestTracingSpec.scala @@ -13,20 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. * ========================================================== */ -package kamon +package kamon.spray import _root_.spray.httpx.RequestBuilding import _root_.spray.routing.SimpleRoutingApp import akka.testkit.TestKit -import akka.actor.{ActorRef, ActorSystem} +import akka.actor.ActorSystem import org.scalatest.WordSpecLike import scala.concurrent.Await import scala.concurrent.duration._ import _root_.spray.client.pipelining._ import akka.util.Timeout -import kamon.trace.Trace -import kamon.Kamon.Extension -import kamon.trace.UowTracing.{Finish, Start} +import kamon.trace.{UowTrace, Trace} +import kamon.Kamon class ServerRequestTracingSpec extends TestKit(ActorSystem("server-request-tracing-spec")) with WordSpecLike with RequestBuilding with TestServer { @@ -37,8 +36,7 @@ class ServerRequestTracingSpec extends TestKit(ActorSystem("server-request-traci } within(5 seconds) { - val traceId = expectMsgPF() { case Start(id, _) => id} - expectMsgPF() { case Finish(traceId) => } + fishForNamedTrace("ok") } } @@ -48,9 +46,7 @@ class ServerRequestTracingSpec extends TestKit(ActorSystem("server-request-traci } within(5 seconds) { - val traceId = expectMsgPF() { case Start(id, _) => id } - println("Expecting for trace: " + traceId) - expectMsgPF() { case Finish(traceId) => } + fishForNamedTrace("clearcontext") } } @@ -60,19 +56,21 @@ class ServerRequestTracingSpec extends TestKit(ActorSystem("server-request-traci } within(5 seconds) { - expectMsgPF() { case Start(_, "GET: /accounts") => } + fishForNamedTrace("accounts") } } } + + def fishForNamedTrace(traceName: String) = fishForMessage() { + case trace: UowTrace if trace.name.contains(traceName) => true + case _ => false + } } trait TestServer extends SimpleRoutingApp { self: TestKit => - // Nasty, but very helpful for tests. - AkkaExtensionSwap.swap(system, Trace, new Extension { - def manager: ActorRef = testActor - }) + Kamon(Trace).tell(Trace.Register, testActor) implicit val timeout = Timeout(20 seconds) val port: Int = Await.result( |