diff options
author | Ivan Topolnak <ivantopo@gmail.com> | 2013-06-17 17:32:03 -0300 |
---|---|---|
committer | Ivan Topolnak <ivantopo@gmail.com> | 2013-06-17 17:32:03 -0300 |
commit | 062894d8429088b154db9cc25c42337956c25a4e (patch) | |
tree | 4ac8a0f97d0e0442641712efeaa8ea66a2e769cf /src | |
parent | 658bdd03a3b549cf7225197388e1e18b01723f1f (diff) | |
download | Kamon-062894d8429088b154db9cc25c42337956c25a4e.tar.gz Kamon-062894d8429088b154db9cc25c42337956c25a4e.tar.bz2 Kamon-062894d8429088b154db9cc25c42337956c25a4e.zip |
Updated to scalatest 2.0-M6 with scala.concurrent.Future support
Diffstat (limited to 'src')
4 files changed, 11 insertions, 46 deletions
diff --git a/src/main/resources/META-INF/aop.xml b/src/main/resources/META-INF/aop.xml index 8619b2c8..3911af1b 100644 --- a/src/main/resources/META-INF/aop.xml +++ b/src/main/resources/META-INF/aop.xml @@ -2,7 +2,7 @@ <aspectj> <weaver options="-verbose -showWeaveInfo"> - <!--<dump within="*"/>--> + <dump within="*" beforeandafter="true"/> </weaver> <aspects> diff --git a/src/test/scala/akka/instrumentation/ActorInstrumentationSpec.scala b/src/test/scala/akka/instrumentation/ActorInstrumentationSpec.scala index 15e967f2..1a0e509f 100644 --- a/src/test/scala/akka/instrumentation/ActorInstrumentationSpec.scala +++ b/src/test/scala/akka/instrumentation/ActorInstrumentationSpec.scala @@ -1,14 +1,13 @@ package akka.instrumentation -import org.scalatest.WordSpec -import org.scalatest.matchers.{ShouldMatchers, MustMatchers} +import org.scalatest.{Matchers, WordSpec} import akka.actor.{Actor, Props, ActorSystem} import kamon.metric.Metrics._ import scala.collection.JavaConverters._ import akka.testkit.TestActorRef -class ActorInstrumentationSpec extends WordSpec with MustMatchers with ShouldMatchers { +class ActorInstrumentationSpec extends WordSpec with Matchers { implicit val system = ActorSystem() import system._ @@ -27,7 +26,6 @@ class ActorInstrumentationSpec extends WordSpec with MustMatchers with ShouldMat echoActor ! s"Message ${x}" } - println("After all") //val messages = registry.getMeters.asScala.get(meterForEchoActor).get.getCount //messages should equal(totalMessages) @@ -38,7 +36,7 @@ class ActorInstrumentationSpec extends WordSpec with MustMatchers with ShouldMat class EchoActor extends Actor { def receive = { - case msg ⇒ println("SOME"); sender ! msg + case msg ⇒ sender ! msg } } diff --git a/src/test/scala/kamon/instrumentation/RunnableInstrumentationSpec.scala b/src/test/scala/kamon/instrumentation/RunnableInstrumentationSpec.scala index 359766b6..de65aaca 100644 --- a/src/test/scala/kamon/instrumentation/RunnableInstrumentationSpec.scala +++ b/src/test/scala/kamon/instrumentation/RunnableInstrumentationSpec.scala @@ -1,9 +1,8 @@ package kamon.instrumentation import scala.concurrent.{Await, Promise, Future} -import org.scalatest.{OptionValues, WordSpec} -import org.scalatest.matchers.MustMatchers -import org.scalatest.concurrent.PatienceConfiguration +import org.scalatest.{Matchers, OptionValues, WordSpec} +import org.scalatest.concurrent.{ScalaFutures, PatienceConfiguration} import kamon.{Kamon, TraceContext} import java.util.UUID import scala.util.Success @@ -12,7 +11,7 @@ import java.util.concurrent.TimeUnit import akka.actor.ActorSystem -class RunnableInstrumentationSpec extends WordSpec with MustMatchers with ScalaFuturesSupport with PatienceConfiguration with OptionValues { +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 { @@ -20,7 +19,7 @@ class RunnableInstrumentationSpec extends WordSpec with MustMatchers with ScalaF "should be available during the run method execution" in { new FutureWithContextFixture { whenReady(futureWithContext) { result => - result.value must be === testContext + result.value should equal(testContext) } }} @@ -32,7 +31,7 @@ class RunnableInstrumentationSpec extends WordSpec with MustMatchers with ScalaF }) whenReady(onCompleteContext.future) { result => - result must be === testContext + result should equal(testContext) } }} } @@ -42,7 +41,7 @@ class RunnableInstrumentationSpec extends WordSpec with MustMatchers with ScalaF "not capture any TraceContext for the body execution" in { new FutureWithoutContextFixture{ whenReady(futureWithoutContext) { result => - result must be === None + result should equal(None) } }} @@ -54,7 +53,7 @@ class RunnableInstrumentationSpec extends WordSpec with MustMatchers with ScalaF }) whenReady(onCompleteContext.future) { result => - result must be === None + result should equal(None) } }} } diff --git a/src/test/scala/kamon/instrumentation/ScalaFuturesSupport.scala b/src/test/scala/kamon/instrumentation/ScalaFuturesSupport.scala deleted file mode 100644 index cc87a7c8..00000000 --- a/src/test/scala/kamon/instrumentation/ScalaFuturesSupport.scala +++ /dev/null @@ -1,32 +0,0 @@ -package kamon.instrumentation - -import scala.concurrent.{Await, Future} -import scala.concurrent.duration.Duration -import scala.util.{Failure, Success} -import org.scalatest.concurrent.Futures -import java.util.concurrent.TimeUnit - -trait ScalaFuturesSupport extends Futures { - implicit def scalaFutureToFutureConcept[T](future: Future[T]): FutureConcept[T] = new FutureConcept[T] { - def eitherValue: Option[Either[Throwable, T]] = { - if(!future.isCompleted) - None - else - future.value match { - case None => None - case Some(t) => t match { - case Success(v) => Some(Right(v)) - case Failure(e) => Some(Left(e)) - } - } - } - - def isExpired: Boolean = false // Scala futures cant expire - - def isCanceled: Boolean = false // Scala futures cannot be cancelled - - override def futureValue(implicit config: PatienceConfig): T = { - Await.result(future, Duration(config.timeout.totalNanos, TimeUnit.NANOSECONDS)) - } - } -} |