Merge branch 'master' into actor-handle
This commit is contained in:
commit
7b1e43c89e
28 changed files with 91 additions and 85 deletions
|
|
@ -1,7 +1,5 @@
|
|||
package se.scalablesolutions.akka.persistence.redis
|
||||
|
||||
import junit.framework.TestCase
|
||||
|
||||
import org.junit.{Test, Before}
|
||||
import org.junit.Assert._
|
||||
|
||||
|
|
@ -25,6 +23,7 @@ case class Balance(accountNo: String)
|
|||
case class Debit(accountNo: String, amount: BigInt, failer: ActorID)
|
||||
case class MultiDebit(accountNo: String, amounts: List[BigInt], failer: ActorID)
|
||||
case class Credit(accountNo: String, amount: BigInt)
|
||||
case class Log(start: Int, finish: Int)
|
||||
case object LogSize
|
||||
|
||||
class AccountActor extends Transactor {
|
||||
|
|
@ -84,6 +83,9 @@ class AccountActor extends Transactor {
|
|||
|
||||
case LogSize =>
|
||||
reply(txnLog.length.asInstanceOf[AnyRef])
|
||||
|
||||
case Log(start, finish) =>
|
||||
reply(txnLog.slice(start, finish))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -95,7 +97,8 @@ class AccountActor extends Transactor {
|
|||
}
|
||||
}
|
||||
|
||||
class RedisPersistentActorSpec extends TestCase {
|
||||
import org.scalatest.junit.JUnitSuite
|
||||
class RedisPersistentActorSpec extends JUnitSuite {
|
||||
@Test
|
||||
def testSuccessfulDebit = {
|
||||
val bactor = newActor[AccountActor]
|
||||
|
|
@ -114,6 +117,12 @@ class RedisPersistentActorSpec extends TestCase {
|
|||
|
||||
val c: Int = (bactor !! LogSize).get
|
||||
assertTrue(7 == c)
|
||||
import scala.collection.mutable.ArrayBuffer
|
||||
assert((bactor !! Log(0, 7)).get.asInstanceOf[ArrayBuffer[String]].size == 7)
|
||||
assert((bactor !! Log(0, 0)).get.asInstanceOf[ArrayBuffer[String]].size == 0)
|
||||
assert((bactor !! Log(1, 2)).get.asInstanceOf[ArrayBuffer[String]].size == 1)
|
||||
assert((bactor !! Log(6, 7)).get.asInstanceOf[ArrayBuffer[String]].size == 1)
|
||||
assert((bactor !! Log(0, 1)).get.asInstanceOf[ArrayBuffer[String]].size == 1)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue