diff options
author | Diego <diegolparra@gmail.com> | 2014-03-08 20:17:15 -0300 |
---|---|---|
committer | Diego <diegolparra@gmail.com> | 2014-03-08 20:17:15 -0300 |
commit | b8a26e0f173a528c700a3d0cfa4ed2f8079a7ae1 (patch) | |
tree | 67e184bf958f2690b69db82a42eb396788e314e2 /kamon-play/src/test | |
parent | 347319f58f7aca927729c5144b3d7d59750be7e4 (diff) | |
download | Kamon-b8a26e0f173a528c700a3d0cfa4ed2f8079a7ae1.tar.gz Kamon-b8a26e0f173a528c700a3d0cfa4ed2f8079a7ae1.tar.bz2 Kamon-b8a26e0f173a528c700a3d0cfa4ed2f8079a7ae1.zip |
WIP:Play integration WebExternal
Diffstat (limited to 'kamon-play/src/test')
-rw-r--r-- | kamon-play/src/test/scala/kamon/play/RequestInstrumentationSpec.scala | 7 | ||||
-rw-r--r-- | kamon-play/src/test/scala/kamon/play/WSInstrumentationSpec.scala | 59 |
2 files changed, 65 insertions, 1 deletions
diff --git a/kamon-play/src/test/scala/kamon/play/RequestInstrumentationSpec.scala b/kamon-play/src/test/scala/kamon/play/RequestInstrumentationSpec.scala index 5b75359f..2dce39f8 100644 --- a/kamon-play/src/test/scala/kamon/play/RequestInstrumentationSpec.scala +++ b/kamon-play/src/test/scala/kamon/play/RequestInstrumentationSpec.scala @@ -75,7 +75,12 @@ class RequestInstrumentationSpec extends PlaySpecification { private val expectedToken = Some(traceTokenValue) private val traceTokenHeader = (traceTokenHeaderName -> traceTokenValue) - "the request instrumentation" should { + "the Request instrumentation" should { + "respond to the asyncResult action with X-Trace-Token" in new WithServer(appWithRoutes) { + val Some(result) = route(FakeRequest(GET, "/asyncResult").withHeaders(traceTokenHeader)) + header(traceTokenHeaderName, result) must equalTo(expectedToken) + } + "respond to the async action with X-Trace-Token" in new WithServer(appWithRoutes) { val Some(result) = route(FakeRequest(GET, "/async").withHeaders(traceTokenHeader)) header(traceTokenHeaderName, result) must equalTo(expectedToken) diff --git a/kamon-play/src/test/scala/kamon/play/WSInstrumentationSpec.scala b/kamon-play/src/test/scala/kamon/play/WSInstrumentationSpec.scala new file mode 100644 index 00000000..2cebfe42 --- /dev/null +++ b/kamon-play/src/test/scala/kamon/play/WSInstrumentationSpec.scala @@ -0,0 +1,59 @@ +/* =================================================== + * Copyright © 2013 2014 the kamon project <http://kamon.io/> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================================================== */ + +package kamon.play + +import play.api.test._ +import play.api.mvc.{ Results, Action } +import play.api.mvc.Results.Ok +import scala.Some +import scala.concurrent.ExecutionContext.Implicits.global +import scala.concurrent.Future +import org.junit.runner.RunWith +import org.specs2.runner.JUnitRunner +import play.api.mvc.AsyncResult +import play.api.test.FakeApplication +import kamon.play.action.TraceName +import play.api.libs.ws.WS + +@RunWith(classOf[JUnitRunner]) +class WSInstrumentationSpec extends PlaySpecification { + + System.setProperty("config.file", "./kamon-play/src/test/resources/conf/application.conf") + + val appWithRoutes = FakeApplication(withRoutes = { + + case ("GET", "/async") ⇒ + Action.async { + WS.url("http://www.google.com").get().map { + response ⇒ + Ok(response.toString()) + } + } + }) + + "the WS instrumentation" should { + "respond to the async action" in new WithServer(appWithRoutes) { + val Some(result) = route(FakeRequest(GET, "/async")) + println("-902425309-53095-5 " + result) + result.onComplete { + case scala.util.Success(r) ⇒ println(r) + case scala.util.Failure(t) ⇒ println(t) + } + Thread.sleep(3000) + } + } +}
\ No newline at end of file |