pekko/akka-actor/src/test/scala/akka/dispatch/MailboxConfigSpec.scala

55 lines
1.6 KiB
Scala
Raw Normal View History

package akka.actor.dispatch
import org.scalatest.junit.JUnitSuite
2010-09-21 18:52:41 +02:00
import org.junit.Test
2010-09-21 18:52:41 +02:00
import akka.actor.Actor
import akka.util.Duration
import akka.dispatch._
2010-09-21 18:52:41 +02:00
import Actor._
2010-09-21 18:52:41 +02:00
import java.util.concurrent.{BlockingQueue, CountDownLatch, TimeUnit}
import java.util.concurrent.atomic.AtomicReference
2010-09-21 18:52:41 +02:00
class MailboxTypeSpec extends JUnitSuite {
@Test def shouldDoNothing = assert(true)
2010-09-21 18:52:41 +02:00
/*
private val unit = TimeUnit.MILLISECONDS
@Test def shouldCreateUnboundedQueue = {
2010-09-21 18:52:41 +02:00
val m = UnboundedMailbox(false)
assert(m.newMailbox("uuid").asInstanceOf[BlockingQueue[MessageInvocation]].remainingCapacity === Integer.MAX_VALUE)
}
@Test def shouldCreateBoundedQueue = {
2010-09-21 18:52:41 +02:00
val m = BoundedMailbox(blocking = false, capacity = 1)
assert(m.newMailbox("uuid").asInstanceOf[BlockingQueue[MessageInvocation]].remainingCapacity === 1)
}
@Test(expected = classOf[MessageQueueAppendFailedException]) def shouldThrowMessageQueueAppendFailedExceptionWhenTimeOutEnqueue = {
2010-09-21 18:52:41 +02:00
val m = BoundedMailbox(false, 1, Duration(1, unit))
val testActor = actorOf( new Actor { def receive = { case _ => }} )
2010-09-21 18:52:41 +02:00
val mbox = m.newMailbox("uuid")
(1 to 10000) foreach { i => mbox.enqueue(new MessageInvocation(testActor, i, None, None, None)) }
}
@Test def shouldBeAbleToDequeueUnblocking = {
2010-09-21 18:52:41 +02:00
val m = BoundedMailbox(false, 1, Duration(1, unit))
val mbox = m.newMailbox("uuid")
val latch = new CountDownLatch(1)
val t = new Thread { override def run = {
mbox.dequeue
latch.countDown
}}
t.start
val result = latch.await(5000,unit)
if (!result)
t.interrupt
assert(result === true)
}
2010-09-21 18:52:41 +02:00
*/
}