diff --git a/akka-docs/java/typed-actors.rst b/akka-docs/java/typed-actors.rst index 7712622dfe..90bdc5616c 100644 --- a/akka-docs/java/typed-actors.rst +++ b/akka-docs/java/typed-actors.rst @@ -163,7 +163,7 @@ Typed Actor Hierarchies Since you can obtain a contextual Typed Actor Extension by passing in an ``ActorContext`` you can create child Typed Actors by invoking ``typedActorOf(..)`` on that. -.. includecode:: code/akka/docs/actor/TypedActorDocTestBase.java +.. includecode:: code/docs/actor/TypedActorDocTestBase.java :include: typed-actor-hierarchy You can also create a child Typed Actor in regular Akka Actors by giving the ``UntypedActorContext`` diff --git a/akka-docs/scala/code/docs/testkit/Specs2DemoAcceptance.scala b/akka-docs/scala/code/docs/testkit/Specs2DemoAcceptance.scala index a3edb6a093..ab8bac9bf3 100644 --- a/akka-docs/scala/code/docs/testkit/Specs2DemoAcceptance.scala +++ b/akka-docs/scala/code/docs/testkit/Specs2DemoAcceptance.scala @@ -1,7 +1,7 @@ package docs.testkit -import org.specs2._ -import org.specs2.specification.Scope +import org.specs2.Specification +import org.specs2.specification.{ Step, Scope } import akka.actor.{ Props, ActorSystem, Actor } import akka.testkit.{ TestKit, ImplicitSender } @@ -13,10 +13,12 @@ class Specs2DemoAcceptance extends Specification { p ^ "A TestKit should" ^ "work properly with Specs2 acceptance tests" ! e1 ^ - "correctly convert durations" ! e2 + "correctly convert durations" ! e2 ^ + Step(system.shutdown()) ^ end // do not forget to shutdown! val system = ActorSystem() + // an alternative to mixing in NoTimeConversions implicit def d2d(d: org.specs2.time.Duration): akka.util.FiniteDuration = akka.util.Duration(d.inMilliseconds, "millis") diff --git a/akka-docs/scala/code/docs/testkit/Specs2DemoSpec.scala b/akka-docs/scala/code/docs/testkit/Specs2DemoSpec.scala index efe7b6088e..a620c5139b 100644 --- a/akka-docs/scala/code/docs/testkit/Specs2DemoSpec.scala +++ b/akka-docs/scala/code/docs/testkit/Specs2DemoSpec.scala @@ -2,20 +2,19 @@ package docs.testkit import org.specs2.mutable.Specification import org.specs2.specification.Scope +import org.specs2.time.NoTimeConversions import akka.actor.{ Props, ActorSystem, Actor } import akka.testkit.{ TestKit, ImplicitSender } +import akka.util.duration._ -class Specs2DemoUnitSpec extends Specification { +class Specs2DemoUnitSpec extends Specification with NoTimeConversions { val system = ActorSystem() - implicit def d2d(d: org.specs2.time.Duration): akka.util.FiniteDuration = - akka.util.Duration(d.inMilliseconds, "millis") - /* * this is needed if different test cases would clash when run concurrently, - * e.g. when creating specifically named top-level actors + * e.g. when creating specifically named top-level actors; leave out otherwise */ sequential @@ -31,4 +30,6 @@ class Specs2DemoUnitSpec extends Specification { } } } + + step(system.shutdown) // do not forget to shutdown! } diff --git a/akka-docs/scala/testing.rst b/akka-docs/scala/testing.rst index ac27655342..a98ee14917 100644 --- a/akka-docs/scala/testing.rst +++ b/akka-docs/scala/testing.rst @@ -684,11 +684,15 @@ Some `Specs2 `_ users have contributed examples of how to wor with :class:`org.specs2.specification.Scope`. * The Specification traits provide a :class:`Duration` DSL which uses partly the same method names as :class:`akka.util.Duration`, resulting in ambiguous - implicits if ``akka.util.duration._`` is imported. The work-around is to use - the Specification variants and supply an implicit conversion to the Akka - Duration. This conversion is not supplied with the Akka distribution because - that would mean that our JAR files would dependon Specs2, which is not - justified by this little feature. + implicits if ``akka.util.duration._`` is imported. There are two work-arounds: + + * either use the Specification variant of Duration and supply an implicit + conversion to the Akka Duration. This conversion is not supplied with the + Akka distribution because that would mean that our JAR files would dependon + Specs2, which is not justified by this little feature. + + * or mix :class:`org.specs2.time.NoTimeConversions` into the Specification. + * Specifications are by default executed concurrently, which requires some care when writing the tests or alternatively the ``sequential`` keyword. diff --git a/akka-docs/scala/typed-actors.rst b/akka-docs/scala/typed-actors.rst index 7c039a1db6..349b574888 100644 --- a/akka-docs/scala/typed-actors.rst +++ b/akka-docs/scala/typed-actors.rst @@ -163,7 +163,7 @@ Typed Actor Hierarchies Since you can obtain a contextual Typed Actor Extension by passing in an ``ActorContext`` you can create child Typed Actors by invoking ``typedActorOf(..)`` on that: -.. includecode:: code/akka/docs/actor/TypedActorDocSpec.scala +.. includecode:: code/docs/actor/TypedActorDocSpec.scala :include: typed-actor-hierarchy You can also create a child Typed Actor in regular Akka Actors by giving the ``ActorContext``