Fixed last persistence issues with new STM, all test pass

This commit is contained in:
Jonas Bonér 2010-03-05 16:07:06 +01:00
parent 36c0266a5d
commit efa0cc0d5a
2 changed files with 11 additions and 18 deletions

View file

@ -1,13 +1,9 @@
package se.scalablesolutions.akka.state package se.scalablesolutions.akka.state
import se.scalablesolutions.akka.actor.Actor import se.scalablesolutions.akka.actor.{Actor, Transactor}
import junit.framework.TestCase
import org.junit.Test import org.junit.Test
import org.junit.Assert._ import org.junit.Assert._
import org.apache.cassandra.service.CassandraDaemon
import org.junit.BeforeClass
import org.junit.Before import org.junit.Before
import org.scalatest.junit.JUnitSuite import org.scalatest.junit.JUnitSuite
@ -28,9 +24,8 @@ case class SetRefStateOneWay(key: String)
case class SuccessOneWay(key: String, value: String) case class SuccessOneWay(key: String, value: String)
case class FailureOneWay(key: String, value: String, failer: Actor) case class FailureOneWay(key: String, value: String, failer: Actor)
class CassandraPersistentActor extends Actor { class CassandraPersistentActor extends Transactor {
timeout = 100000 timeout = 100000
makeTransactionRequired
private lazy val mapState = CassandraStorage.newMap private lazy val mapState = CassandraStorage.newMap
private lazy val vectorState = CassandraStorage.newVector private lazy val vectorState = CassandraStorage.newVector
@ -66,8 +61,7 @@ class CassandraPersistentActor extends Actor {
} }
} }
@serializable class PersistentFailerActor extends Actor { @serializable class PersistentFailerActor extends Transactor {
makeTransactionRequired
def receive = { def receive = {
case "Failure" => case "Failure" =>
throw new RuntimeException("expected") throw new RuntimeException("expected")
@ -76,8 +70,8 @@ class CassandraPersistentActor extends Actor {
class CassandraPersistentActorSpec extends JUnitSuite { class CassandraPersistentActorSpec extends JUnitSuite {
@Before //@Before
def startCassandra = EmbeddedCassandraService.start //def startCassandra = EmbeddedCassandraService.start
@Test @Test
def testMapShouldNotRollbackStateForStatefulServerInCaseOfSuccess = { def testMapShouldNotRollbackStateForStatefulServerInCaseOfSuccess = {

View file

@ -8,7 +8,7 @@ import org.junit.Assert._
import _root_.dispatch.json.{JsNumber, JsValue} import _root_.dispatch.json.{JsNumber, JsValue}
import _root_.dispatch.json.Js._ import _root_.dispatch.json.Js._
import se.scalablesolutions.akka.actor.Actor import se.scalablesolutions.akka.actor.{Transactor, Actor}
/** /**
* A persistent actor based on MongoDB storage. * A persistent actor based on MongoDB storage.
@ -29,10 +29,10 @@ case class MultiDebit(accountNo: String, amounts: List[BigInt], failer: Actor)
case class Credit(accountNo: String, amount: BigInt) case class Credit(accountNo: String, amount: BigInt)
case object LogSize case object LogSize
class BankAccountActor extends Actor { class BankAccountActor extends Transactor {
makeTransactionRequired
private val accountState = MongoStorage.newMap private lazy val accountState = MongoStorage.newMap
private val txnLog = MongoStorage.newVector private lazy val txnLog = MongoStorage.newVector
def receive: PartialFunction[Any, Unit] = { def receive: PartialFunction[Any, Unit] = {
// check balance // check balance
@ -91,8 +91,7 @@ class BankAccountActor extends Actor {
} }
} }
@serializable class PersistentFailerActor extends Actor { @serializable class PersistentFailerActor extends Transactor {
makeTransactionRequired
def receive = { def receive = {
case "Failure" => case "Failure" =>
throw new RuntimeException("expected") throw new RuntimeException("expected")