From b2b5113877ca6505db8286b47bcda57e85ecaff3 Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Wed, 26 Jan 2011 14:06:40 +0100 Subject: [PATCH] Porting the tests from wip-628-629 --- .../typed-actor/TypedActorLifecycleSpec.scala | 58 ++++++++++--------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/akka-typed-actor/src/test/scala/actor/typed-actor/TypedActorLifecycleSpec.scala b/akka-typed-actor/src/test/scala/actor/typed-actor/TypedActorLifecycleSpec.scala index 1e38e7034b..0946aa26c0 100644 --- a/akka-typed-actor/src/test/scala/actor/typed-actor/TypedActorLifecycleSpec.scala +++ b/akka-typed-actor/src/test/scala/actor/typed-actor/TypedActorLifecycleSpec.scala @@ -99,15 +99,21 @@ class TypedActorLifecycleSpec extends Spec with ShouldMatchers with BeforeAndAft val conf = new TypedActorConfigurator().configure(OneForOneStrategy(Nil, 3, 500000), Array(actorSupervision)).inject.supervise try { val first = conf.getInstance(classOf[TypedActorFailer]) - intercept[RuntimeException] { + try { first.fail + fail("shouldn't get here") + } catch { + case r: RuntimeException if r.getMessage == "expected" => //expected } val second = conf.getInstance(classOf[TypedActorFailer]) first should be (second) - intercept[ActorInitializationException] { + try { second.fail + fail("shouldn't get here") + } catch { + case r: ActorInitializationException if r.getMessage == "Actor has not been started, you need to invoke 'actor.start' before using it" => //expected } } finally { conf.stop @@ -115,29 +121,29 @@ class TypedActorLifecycleSpec extends Spec with ShouldMatchers with BeforeAndAft } it("should be restarted when supervision handles the problem in") { - val actorSupervision = new SuperviseTypedActor(classOf[TypedActorFailer],classOf[TypedActorFailerImpl],permanent(),30000) - val conf = new TypedActorConfigurator().configure(OneForOneStrategy(classOf[Throwable] :: Nil, 3, 500000), Array(actorSupervision)).inject.supervise - try { - val first = conf.getInstance(classOf[TypedActorFailer]) - try { - first.fail - fail("shouldn't get here") - } catch { - case r: RuntimeException if r.getMessage == "expected" => //expected - } - val second = conf.getInstance(classOf[TypedActorFailer]) + val actorSupervision = new SuperviseTypedActor(classOf[TypedActorFailer],classOf[TypedActorFailerImpl],permanent(),30000) + val conf = new TypedActorConfigurator().configure(OneForOneStrategy(classOf[Throwable] :: Nil, 3, 500000), Array(actorSupervision)).inject.supervise + try { + val first = conf.getInstance(classOf[TypedActorFailer]) + try { + first.fail + fail("shouldn't get here") + } catch { + case r: RuntimeException if r.getMessage == "expected" => //expected + } + val second = conf.getInstance(classOf[TypedActorFailer]) - first should be (second) + first should be (second) - try { - first.fail - fail("shouldn't get here") - } catch { - case r: RuntimeException if r.getMessage == "expected" => //expected - } - } finally { - conf.stop - } - } - } -} + try { + second.fail + fail("shouldn't get here") + } catch { + case r: RuntimeException if r.getMessage == "expected" => //expected + } + } finally { + conf.stop + } + } + } +} \ No newline at end of file