From 6e4aa3231dd0e123505bd0429ae099ffdec3b9ec Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Wed, 3 Apr 2013 20:19:15 +0200 Subject: [PATCH] Adding a MailboxSpec for SingleConsumerOnlyMailbox --- .../scala/akka/dispatch/MailboxConfigSpec.scala | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/akka-actor-tests/src/test/scala/akka/dispatch/MailboxConfigSpec.scala b/akka-actor-tests/src/test/scala/akka/dispatch/MailboxConfigSpec.scala index a79a3c9ab8..65ca5cfb6f 100644 --- a/akka-actor-tests/src/test/scala/akka/dispatch/MailboxConfigSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/dispatch/MailboxConfigSpec.scala @@ -19,6 +19,10 @@ abstract class MailboxSpec extends AkkaSpec with BeforeAndAfterAll with BeforeAn def factory: MailboxType ⇒ MessageQueue + def supportsBeingBounded = true + + def maxConsumers = 4 + name should { "create an unbounded mailbox" in { val config = UnboundedMailbox() @@ -122,7 +126,7 @@ abstract class MailboxSpec extends AkkaSpec with BeforeAndAfterAll with BeforeAn r } - val consumers = for (i ← (1 to 4).toList) yield createConsumer + val consumers = List.fill(maxConsumers)(createConsumer) val ps = producers.map(Await.result(_, within)) val cs = consumers.map(Await.result(_, within)) @@ -187,3 +191,12 @@ class CustomMailboxSpec extends AkkaSpec(CustomMailboxSpec.config) { } } } + +class SingleConsumerOnlyMailboxSpec extends MailboxSpec { + lazy val name = "The single-consumer-only mailbox implementation" + override def maxConsumers = 1 + def factory = { + case u: UnboundedMailbox ⇒ SingleConsumerOnlyUnboundedMailbox().create(None, None) + case b: BoundedMailbox ⇒ pending; null + } +}