migrated over to ScalaTest 1.0

This commit is contained in:
jboner 2009-10-26 11:30:03 +01:00
parent adf3eebe9a
commit 3cc8671100
17 changed files with 196 additions and 351 deletions

View file

@ -134,9 +134,9 @@
<!-- For Testing -->
<dependency>
<groupId>org.scala-tools.testing</groupId>
<groupId>org.scalatest</groupId>
<artifactId>scalatest</artifactId>
<version>0.9.5</version>
<version>1.0</version>
<scope>test</scope>
</dependency>
<dependency>

View file

@ -4,23 +4,24 @@ import junit.framework.Test
import junit.framework.TestCase
import junit.framework.TestSuite
import se.scalablesolutions.akka.actor.{RemoteActorSpec, InMemoryActorSpec, ThreadBasedActorSpec, SupervisorSpec, RemoteSupervisorSpec, SchedulerSpec}
import se.scalablesolutions.akka.actor.{RemoteActorTest, InMemoryActorTest, ThreadBasedActorTest, SupervisorTest, RemoteSupervisorTest, SchedulerTest}
import se.scalablesolutions.akka.dispatch.{EventBasedSingleThreadDispatcherTest, EventBasedThreadPoolDispatcherTest}
object AllTest extends TestCase {
def suite(): Test = {
val suite = new TestSuite("All Scala tests")
suite.addTestSuite(classOf[SupervisorSpec])
suite.addTestSuite(classOf[RemoteSupervisorSpec])
/* suite.addTestSuite(classOf[SupervisorTest])
suite.addTestSuite(classOf[RemoteSupervisorTest])
suite.addTestSuite(classOf[EventBasedSingleThreadDispatcherTest])
suite.addTestSuite(classOf[EventBasedThreadPoolDispatcherTest])
suite.addTestSuite(classOf[ThreadBasedActorSpec])
suite.addTestSuite(classOf[ThreadBasedActorTest])
suite.addTestSuite(classOf[EventBasedSingleThreadDispatcherTest])
suite.addTestSuite(classOf[EventBasedThreadPoolDispatcherTest])
suite.addTestSuite(classOf[RemoteActorSpec])
suite.addTestSuite(classOf[InMemoryActorSpec])
suite.addTestSuite(classOf[SchedulerSpec])
//suite.addTestSuite(classOf[TransactionClasherSpec])
suite.addTestSuite(classOf[RemoteActorTest])
suite.addTestSuite(classOf[InMemoryActorTest])
suite.addTestSuite(classOf[SchedulerTest])
//suite.addTestSuite(classOf[TransactionClasherTest])
*/
suite
}

View file

@ -2,11 +2,12 @@ package se.scalablesolutions.akka.actor
import java.util.concurrent.TimeUnit
import junit.framework.Assert._
import org.scalatest.junit.JUnitSuite
import org.junit.Test
import se.scalablesolutions.akka.dispatch.Dispatchers
class EventBasedSingleThreadActorSpec extends junit.framework.TestCase {
class EventBasedSingleThreadActorTest extends JUnitSuite {
private val unit = TimeUnit.MILLISECONDS
class TestActor extends Actor {
@ -20,7 +21,7 @@ class EventBasedSingleThreadActorSpec extends junit.framework.TestCase {
}
}
def testSendOneWay = {
@Test def shouldSendOneWay = {
implicit val timeout = 5000L
var oneWay = "nada"
val actor = new Actor {
@ -31,29 +32,29 @@ class EventBasedSingleThreadActorSpec extends junit.framework.TestCase {
actor.start
val result = actor ! "OneWay"
Thread.sleep(100)
assertEquals("received", oneWay)
assert("received" === oneWay)
actor.stop
}
def testSendReplySync = {
@Test def shouldSendReplySync = {
implicit val timeout = 5000L
val actor = new TestActor
actor.start
val result: String = actor !? "Hello"
assertEquals("World", result)
assert("World" === result)
actor.stop
}
def testSendReplyAsync = {
@Test def shouldSendReplyAsync = {
implicit val timeout = 5000L
val actor = new TestActor
actor.start
val result = actor !! "Hello"
assertEquals("World", result.get.asInstanceOf[String])
assert("World" === result.get.asInstanceOf[String])
actor.stop
}
def testSendReceiveException = {
@Test def shouldSendReceiveException = {
implicit val timeout = 5000L
val actor = new TestActor
actor.start
@ -62,7 +63,7 @@ class EventBasedSingleThreadActorSpec extends junit.framework.TestCase {
fail("Should have thrown an exception")
} catch {
case e =>
assertEquals("expected", e.getMessage())
assert("expected" === e.getMessage())
}
actor.stop
}

View file

@ -7,12 +7,11 @@ import java.util.concurrent.locks.Lock
import java.util.concurrent.locks.ReentrantLock
import org.junit.{Test, Before}
import org.junit.Assert._
import junit.framework.TestCase
import org.scalatest.junit.JUnitSuite
import se.scalablesolutions.akka.actor.Actor
class EventBasedSingleThreadDispatcherTest extends TestCase {
class EventBasedSingleThreadDispatcherTest extends JUnitSuite {
private var threadingIssueDetected: AtomicBoolean = null
class TestMessageHandle(handleLatch: CountDownLatch) extends MessageInvoker {
@ -35,22 +34,19 @@ class EventBasedSingleThreadDispatcherTest extends TestCase {
}
@Before
override def setUp = {
def setUp = {
threadingIssueDetected = new AtomicBoolean(false)
}
@Test
def testMessagesDispatchedToTheSameHandlerAreExecutedSequentially = {
@Test def shouldMessagesDispatchedToTheSameHandlerAreExecutedSequentially = {
internalTestMessagesDispatchedToTheSameHandlerAreExecutedSequentially
}
@Test
def testMessagesDispatchedToDifferentHandlersAreExecutedSequentially = {
@Test def shouldMessagesDispatchedToDifferentHandlersAreExecutedSequentially = {
internalTestMessagesDispatchedToDifferentHandlersAreExecutedSequentially
}
@Test
def testMessagesDispatchedToHandlersAreExecutedInFIFOOrder = {
@Test def shouldMessagesDispatchedToHandlersAreExecutedInFIFOOrder = {
internalTestMessagesDispatchedToHandlersAreExecutedInFIFOOrder
}
@ -67,8 +63,8 @@ class EventBasedSingleThreadDispatcherTest extends TestCase {
for (i <- 0 until 100) {
dispatcher.messageQueue.append(new MessageInvocation(key1, new Object, None, None))
}
assertTrue(handleLatch.await(5, TimeUnit.SECONDS))
assertFalse(threadingIssueDetected.get)
assert(handleLatch.await(5, TimeUnit.SECONDS))
assert(!threadingIssueDetected.get)
}
private def internalTestMessagesDispatchedToDifferentHandlersAreExecutedSequentially: Unit = {
@ -79,8 +75,8 @@ class EventBasedSingleThreadDispatcherTest extends TestCase {
dispatcher.start
dispatcher.messageQueue.append(new MessageInvocation(key1, new Object, None, None))
dispatcher.messageQueue.append(new MessageInvocation(key2, new Object, None, None))
assertTrue(handleLatch.await(5, TimeUnit.SECONDS))
assertFalse(threadingIssueDetected.get)
assert(handleLatch.await(5, TimeUnit.SECONDS))
assert(!threadingIssueDetected.get)
}
private def internalTestMessagesDispatchedToHandlersAreExecutedInFIFOOrder: Unit = {
@ -113,8 +109,8 @@ class EventBasedSingleThreadDispatcherTest extends TestCase {
dispatcher.messageQueue.append(new MessageInvocation(key1, new java.lang.Integer(i), None, None))
dispatcher.messageQueue.append(new MessageInvocation(key2, new java.lang.Integer(i), None, None))
}
assertTrue(handleLatch.await(5, TimeUnit.SECONDS))
assertFalse(threadingIssueDetected.get)
assert(handleLatch.await(5, TimeUnit.SECONDS))
assert(!threadingIssueDetected.get)
dispatcher.shutdown
}
}

View file

@ -2,9 +2,10 @@ package se.scalablesolutions.akka.actor
import java.util.concurrent.TimeUnit
import junit.framework.Assert._
import org.scalatest.junit.JUnitSuite
import org.junit.Test
class EventBasedThreadPoolActorSpec extends junit.framework.TestCase {
class EventBasedThreadPoolActorTest extends JUnitSuite {
private val unit = TimeUnit.MILLISECONDS
class TestActor extends Actor {
@ -16,7 +17,7 @@ class EventBasedThreadPoolActorSpec extends junit.framework.TestCase {
}
}
def testSendOneWay = {
@Test def shouldSendOneWay = {
implicit val timeout = 5000L
var oneWay = "nada"
val actor = new Actor {
@ -27,29 +28,29 @@ class EventBasedThreadPoolActorSpec extends junit.framework.TestCase {
actor.start
val result = actor ! "OneWay"
Thread.sleep(100)
assertEquals("received", oneWay)
assert("received" === oneWay)
actor.stop
}
def testSendReplySync = {
@Test def shouldSendReplySync = {
implicit val timeout = 5000L
val actor = new TestActor
actor.start
val result: String = actor !? "Hello"
assertEquals("World", result)
assert("World" === result)
actor.stop
}
def testSendReplyAsync = {
@Test def shouldSendReplyAsync = {
implicit val timeout = 5000L
val actor = new TestActor
actor.start
val result = actor !! "Hello"
assertEquals("World", result.get.asInstanceOf[String])
assert("World" === result.get.asInstanceOf[String])
actor.stop
}
def testSendReceiveException = {
@Test def shouldSendReceiveException = {
implicit val timeout = 5000L
val actor = new TestActor
actor.start
@ -58,7 +59,7 @@ class EventBasedThreadPoolActorSpec extends junit.framework.TestCase {
fail("Should have thrown an exception")
} catch {
case e =>
assertEquals("expected", e.getMessage())
assert("expected" === e.getMessage())
}
actor.stop
}

View file

@ -5,35 +5,35 @@ import java.util.concurrent.atomic.AtomicBoolean
import java.util.concurrent.locks.Lock
import java.util.concurrent.locks.ReentrantLock
import java.util.concurrent.{Executors, CountDownLatch, CyclicBarrier, TimeUnit}
import org.junit.Before
import org.junit.Test
import org.junit.Assert._
import junit.framework.TestCase
import org.scalatest.junit.JUnitSuite
import org.junit.{Test, Before}
import se.scalablesolutions.akka.actor.Actor
class EventBasedThreadPoolDispatcherTest extends TestCase {
class EventBasedThreadPoolDispatcherTest extends JUnitSuite {
private var threadingIssueDetected: AtomicBoolean = null
val key1 = new Actor { def receive: PartialFunction[Any, Unit] = { case _ => {}} }
val key2 = new Actor { def receive: PartialFunction[Any, Unit] = { case _ => {}} }
val key3 = new Actor { def receive: PartialFunction[Any, Unit] = { case _ => {}} }
@Before
override def setUp = {
def setUp = {
threadingIssueDetected = new AtomicBoolean(false)
}
@Test
def testMessagesDispatchedToTheSameHandlerAreExecutedSequentially = {
def shouldMessagesDispatchedToTheSameHandlerAreExecutedSequentially = {
internalTestMessagesDispatchedToTheSameHandlerAreExecutedSequentially
}
@Test
def testMessagesDispatchedToDifferentHandlersAreExecutedConcurrently = {
def shouldMessagesDispatchedToDifferentHandlersAreExecutedConcurrently = {
internalTestMessagesDispatchedToDifferentHandlersAreExecutedConcurrently
}
@Test
def testMessagesDispatchedToHandlersAreExecutedInFIFOOrder = {
def shouldMessagesDispatchedToHandlersAreExecutedInFIFOOrder = {
internalTestMessagesDispatchedToHandlersAreExecutedInFIFOOrder
}
@ -69,8 +69,8 @@ class EventBasedThreadPoolDispatcherTest extends TestCase {
for (i <- 0 until 10) {
dispatcher.messageQueue.append(new MessageInvocation(key1, new Object, None, None))
}
assertTrue(handleLatch.await(5, TimeUnit.SECONDS))
assertFalse(threadingIssueDetected.get)
assert(handleLatch.await(5, TimeUnit.SECONDS))
assert(!threadingIssueDetected.get)
}
private def internalTestMessagesDispatchedToDifferentHandlersAreExecutedConcurrently: Unit = {
@ -115,7 +115,7 @@ class EventBasedThreadPoolDispatcherTest extends TestCase {
dispatcher.messageQueue.append(new MessageInvocation(key2, "Sending Message 2.2", None, None))
handlersBarrier.await(5, TimeUnit.SECONDS)
assertFalse(threadingIssueDetected.get)
assert(!threadingIssueDetected.get)
}
private def internalTestMessagesDispatchedToHandlersAreExecutedInFIFOOrder: Unit = {
@ -154,7 +154,7 @@ class EventBasedThreadPoolDispatcherTest extends TestCase {
dispatcher.messageQueue.append(new MessageInvocation(key1, new java.lang.Integer(i), None, None))
dispatcher.messageQueue.append(new MessageInvocation(key2, new java.lang.Integer(i), None, None))
}
assertTrue(handleLatch.await(5, TimeUnit.SECONDS))
assertFalse(threadingIssueDetected.get)
assert(handleLatch.await(5, TimeUnit.SECONDS))
assert(!threadingIssueDetected.get)
}
}

View file

@ -1,9 +1,8 @@
package se.scalablesolutions.akka.actor
import junit.framework.TestCase
import org.scalatest.junit.JUnitSuite
import org.junit.Test
import org.junit.{Test, Before}
import org.junit.Assert._
import se.scalablesolutions.akka.state.{TransactionalState, TransactionalMap, TransactionalRef, TransactionalVector}
case class GetMapState(key: String)
@ -86,31 +85,31 @@ class InMemFailerActor extends Actor {
}
}
class InMemoryActorSpec extends TestCase {
class InMemoryActorTest extends JUnitSuite {
/*
@Test
def testOneWayMapShouldNotRollbackStateForStatefulServerInCaseOfSuccess = {
def shouldOneWayMapShouldNotRollbackStateForStatefulServerInCaseOfSuccess = {
val stateful = new InMemStatefulActor
stateful.start
stateful ! SetMapStateOneWay("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "init") // set init state
Thread.sleep(1000)
stateful ! SuccessOneWay("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state") // transactionrequired
Thread.sleep(1000)
assertEquals("new state", (stateful !! GetMapState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess")).get)
assert("new state" === (stateful !! GetMapState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess")).get)
}
*/
@Test
def testMapShouldNotRollbackStateForStatefulServerInCaseOfSuccess = {
def shouldMapShouldNotRollbackStateForStatefulServerInCaseOfSuccess = {
val stateful = new InMemStatefulActor
stateful.start
stateful !! SetMapState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "init") // set init state
stateful !! Success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state") // transactionrequired
assertEquals("new state", (stateful !! GetMapState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess")).get)
assert("new state" === (stateful !! GetMapState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess")).get)
}
/*
@Test
def testOneWayMapShouldRollbackStateForStatefulServerInCaseOfFailure = {
def shouldOneWayMapShouldRollbackStateForStatefulServerInCaseOfFailure = {
val stateful = new InMemStatefulActor
stateful.start
val failer = new InMemFailerActor
@ -119,11 +118,11 @@ class InMemoryActorSpec extends TestCase {
Thread.sleep(1000)
stateful ! FailureOneWay("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer) // call failing transactionrequired method
Thread.sleep(1000)
assertEquals("init", (stateful !! GetMapState("testShouldRollbackStateForStatefulServerInCaseOfFailure")).get) // check that state is == init state
assert("init" === (stateful !! GetMapState("testShouldRollbackStateForStatefulServerInCaseOfFailure")).get) // check that state is == init state
}
*/
@Test
def testMapShouldRollbackStateForStatefulServerInCaseOfFailure = {
def shouldMapShouldRollbackStateForStatefulServerInCaseOfFailure = {
val stateful = new InMemStatefulActor
stateful.start
stateful !! SetMapState("testShouldRollbackStateForStatefulServerInCaseOfFailure", "init") // set init state
@ -133,31 +132,31 @@ class InMemoryActorSpec extends TestCase {
stateful !! Failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer) // call failing transactionrequired method
fail("should have thrown an exception")
} catch {case e: RuntimeException => {}}
assertEquals("init", (stateful !! GetMapState("testShouldRollbackStateForStatefulServerInCaseOfFailure")).get) // check that state is == init state
assert("init" === (stateful !! GetMapState("testShouldRollbackStateForStatefulServerInCaseOfFailure")).get) // check that state is == init state
}
/*
@Test
def testOneWayVectorShouldNotRollbackStateForStatefulServerInCaseOfSuccess = {
def shouldOneWayVectorShouldNotRollbackStateForStatefulServerInCaseOfSuccess = {
val stateful = new InMemStatefulActor
stateful.start
stateful ! SetVectorStateOneWay("init") // set init state
Thread.sleep(1000)
stateful ! SuccessOneWay("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state") // transactionrequired
Thread.sleep(1000)
assertEquals(2, (stateful !! GetVectorSize).get)
assert(2 === (stateful !! GetVectorSize).get)
}
*/
@Test
def testVectorShouldNotRollbackStateForStatefulServerInCaseOfSuccess = {
def shouldVectorShouldNotRollbackStateForStatefulServerInCaseOfSuccess = {
val stateful = new InMemStatefulActor
stateful.start
stateful !! SetVectorState("init") // set init state
stateful !! Success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state") // transactionrequired
assertEquals(2, (stateful !! GetVectorSize).get)
assert(2 === (stateful !! GetVectorSize).get)
}
/*
@Test
def testOneWayVectorShouldRollbackStateForStatefulServerInCaseOfFailure = {
def shouldOneWayVectorShouldRollbackStateForStatefulServerInCaseOfFailure = {
val stateful = new InMemStatefulActor
stateful.start
stateful ! SetVectorStateOneWay("init") // set init state
@ -166,11 +165,11 @@ class InMemoryActorSpec extends TestCase {
failer.start
stateful ! FailureOneWay("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer) // call failing transactionrequired method
Thread.sleep(1000)
assertEquals(1, (stateful !! GetVectorSize).get)
assert(1 === (stateful !! GetVectorSize).get)
}
*/
@Test
def testVectorShouldRollbackStateForStatefulServerInCaseOfFailure = {
def shouldVectorShouldRollbackStateForStatefulServerInCaseOfFailure = {
val stateful = new InMemStatefulActor
stateful.start
stateful !! SetVectorState("init") // set init state
@ -180,31 +179,31 @@ class InMemoryActorSpec extends TestCase {
stateful !! Failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer) // call failing transactionrequired method
fail("should have thrown an exception")
} catch {case e: RuntimeException => {}}
assertEquals(1, (stateful !! GetVectorSize).get)
assert(1 === (stateful !! GetVectorSize).get)
}
/*
@Test
def testOneWayRefShouldNotRollbackStateForStatefulServerInCaseOfSuccess = {
def shouldOneWayRefShouldNotRollbackStateForStatefulServerInCaseOfSuccess = {
val stateful = new InMemStatefulActor
stateful.start
stateful ! SetRefStateOneWay("init") // set init state
Thread.sleep(1000)
stateful ! SuccessOneWay("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state") // transactionrequired
Thread.sleep(1000)
assertEquals("new state", (stateful !! GetRefState).get)
assert("new state" === (stateful !! GetRefState).get)
}
*/
@Test
def testRefShouldNotRollbackStateForStatefulServerInCaseOfSuccess = {
def shouldRefShouldNotRollbackStateForStatefulServerInCaseOfSuccess = {
val stateful = new InMemStatefulActor
stateful.start
stateful !! SetRefState("init") // set init state
stateful !! Success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state") // transactionrequired
assertEquals("new state", (stateful !! GetRefState).get)
assert("new state" === (stateful !! GetRefState).get)
}
/*
@Test
def testOneWayRefShouldRollbackStateForStatefulServerInCaseOfFailure = {
def shouldOneWayRefShouldRollbackStateForStatefulServerInCaseOfFailure = {
val stateful = new InMemStatefulActor
stateful.start
stateful ! SetRefStateOneWay("init") // set init state
@ -213,11 +212,11 @@ class InMemoryActorSpec extends TestCase {
failer.start
stateful ! FailureOneWay("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer) // call failing transactionrequired method
Thread.sleep(1000)
assertEquals("init", (stateful !! GetRefState).get) // check that state is == init state
assert("init" === (stateful !! GetRefState).get) // check that state is == init state
}
*/
@Test
def testRefShouldRollbackStateForStatefulServerInCaseOfFailure = {
def shouldRefShouldRollbackStateForStatefulServerInCaseOfFailure = {
val stateful = new InMemStatefulActor
stateful.start
stateful !! SetRefState("init") // set init state
@ -227,6 +226,6 @@ class InMemoryActorSpec extends TestCase {
stateful !! Failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer) // call failing transactionrequired method
fail("should have thrown an exception")
} catch {case e: RuntimeException => {}}
assertEquals("init", (stateful !! GetRefState).get) // check that state is == init state
assert("init" === (stateful !! GetRefState).get) // check that state is == init state
}
}

View file

@ -4,8 +4,8 @@ import java.util.concurrent.TimeUnit
import junit.framework.TestCase
import se.scalablesolutions.akka.nio.{RemoteServer, RemoteClient}
import org.junit.{Test, Before}
import org.junit.Assert._
import org.scalatest.junit.JUnitSuite
import org.junit.Test
object Global {
var oneWay = "nada"
@ -26,7 +26,7 @@ class RemoteActorSpecActorBidirectional extends Actor {
}
}
class RemoteActorSpec extends TestCase {
class RemoteActorTest extends JUnitSuite {
akka.Config.config
new Thread(new Runnable() {
def run = {
@ -38,41 +38,41 @@ class RemoteActorSpec extends TestCase {
private val unit = TimeUnit.MILLISECONDS
@Test
def testSendOneWay = {
def shouldSendOneWay = {
implicit val timeout = 500000000L
val actor = new RemoteActorSpecActorUnidirectional
actor.makeRemote(RemoteServer.HOSTNAME, RemoteServer.PORT)
actor.start
val result = actor ! "OneWay"
Thread.sleep(100)
assertEquals("received", Global.oneWay)
assert("received" === Global.oneWay)
actor.stop
}
@Test
def testSendReplySync = {
def shouldSendReplySync = {
implicit val timeout = 500000000L
val actor = new RemoteActorSpecActorBidirectional
actor.makeRemote(RemoteServer.HOSTNAME, RemoteServer.PORT)
actor.start
val result: String = actor !? "Hello"
assertEquals("World", result)
assert("World" === result)
actor.stop
}
@Test
def testSendReplyAsync = {
def shouldSendReplyAsync = {
implicit val timeout = 500000000L
val actor = new RemoteActorSpecActorBidirectional
actor.makeRemote(RemoteServer.HOSTNAME, RemoteServer.PORT)
actor.start
val result = actor !! "Hello"
assertEquals("World", result.get.asInstanceOf[String])
assert("World" === result.get.asInstanceOf[String])
actor.stop
}
@Test
def testSendReceiveException = {
def shouldSendReceiveException = {
implicit val timeout = 500000000L
val actor = new RemoteActorSpecActorBidirectional
actor.makeRemote(RemoteServer.HOSTNAME, RemoteServer.PORT)
@ -82,7 +82,7 @@ class RemoteActorSpec extends TestCase {
fail("Should have thrown an exception")
} catch {
case e =>
assertEquals("expected", e.getMessage())
assert("expected" === e.getMessage())
}
actor.stop
}

View file

@ -8,9 +8,8 @@ import akka.serialization.BinaryString
import nio.{RemoteClient, RemoteServer}
import config.ScalaConfig._
//import com.jteigen.scalatest.JUnit4Runner
import org.junit.runner.RunWith
import org.scalatest.Suite
import org.scalatest.junit.JUnitSuite
import org.junit.Test
object Log {
var messageLog: String = ""
@ -19,8 +18,7 @@ object Log {
/**
* @author <a href="http://jonasboner.com">Jonas Bon&#233;r</a>
*/
//@RunWith(classOf[JUnit4Runner])
class RemoteSupervisorSpec extends junit.framework.TestCase with Suite {
class RemoteSupervisorTest extends JUnitSuite {
akka.Config.config
new Thread(new Runnable() {
@ -34,7 +32,7 @@ class RemoteSupervisorSpec extends junit.framework.TestCase with Suite {
var pingpong2: RemotePingPong2Actor = _
var pingpong3: RemotePingPong3Actor = _
def testStartServer = {
@Test def shouldStartServer = {
Log.messageLog = ""
val sup = getSingleActorAllForOneSupervisor
sup ! StartSupervisor
@ -44,12 +42,12 @@ class RemoteSupervisorSpec extends junit.framework.TestCase with Suite {
}
}
def testKillSingleActorOneForOne = {
@Test def shouldKillSingleActorOneForOne = {
Log.messageLog = ""
val sup = getSingleActorOneForOneSupervisor
sup ! StartSupervisor
Thread.sleep(500)
intercept(classOf[RuntimeException]) {
intercept[RuntimeException] {
pingpong1 !! BinaryString("Die")
}
Thread.sleep(500)
@ -58,7 +56,7 @@ class RemoteSupervisorSpec extends junit.framework.TestCase with Suite {
}
}
def testCallKillCallSingleActorOneForOne = {
@Test def shouldCallKillCallSingleActorOneForOne = {
Log.messageLog = ""
val sup = getSingleActorOneForOneSupervisor
sup ! StartSupervisor
@ -70,7 +68,7 @@ class RemoteSupervisorSpec extends junit.framework.TestCase with Suite {
expect("ping") {
Log.messageLog
}
intercept(classOf[RuntimeException]) {
intercept[RuntimeException] {
pingpong1 !! BinaryString("Die")
}
Thread.sleep(500)
@ -86,12 +84,12 @@ class RemoteSupervisorSpec extends junit.framework.TestCase with Suite {
}
}
def testKillSingleActorAllForOne = {
@Test def shouldKillSingleActorAllForOne = {
Log.messageLog = ""
val sup = getSingleActorAllForOneSupervisor
sup ! StartSupervisor
Thread.sleep(500)
intercept(classOf[RuntimeException]) {
intercept[RuntimeException] {
pingpong1 !! BinaryString("Die")
}
Thread.sleep(500)
@ -100,7 +98,7 @@ class RemoteSupervisorSpec extends junit.framework.TestCase with Suite {
}
}
def testCallKillCallSingleActorAllForOne = {
@Test def shouldCallKillCallSingleActorAllForOne = {
Log.messageLog = ""
val sup = getSingleActorAllForOneSupervisor
sup ! StartSupervisor
@ -112,7 +110,7 @@ class RemoteSupervisorSpec extends junit.framework.TestCase with Suite {
expect("ping") {
Log.messageLog
}
intercept(classOf[RuntimeException]) {
intercept[RuntimeException] {
pingpong1 !! BinaryString("Die")
}
Thread.sleep(500)
@ -128,12 +126,12 @@ class RemoteSupervisorSpec extends junit.framework.TestCase with Suite {
}
}
def testKillMultipleActorsOneForOne = {
@Test def shouldKillMultipleActorsOneForOne = {
Log.messageLog = ""
val sup = getMultipleActorsOneForOneConf
sup ! StartSupervisor
Thread.sleep(500)
intercept(classOf[RuntimeException]) {
intercept[RuntimeException] {
pingpong3 !! BinaryString("Die")
}
Thread.sleep(500)
@ -162,7 +160,7 @@ class RemoteSupervisorSpec extends junit.framework.TestCase with Suite {
expect("pingpingping") {
Log.messageLog
}
intercept(classOf[RuntimeException]) {
intercept[RuntimeException] {
pingpong2 !! BinaryString("Die")
}
Thread.sleep(500)
@ -186,12 +184,12 @@ class RemoteSupervisorSpec extends junit.framework.TestCase with Suite {
}
}
def testKillMultipleActorsAllForOne = {
@Test def shouldKillMultipleActorsAllForOne = {
Log.messageLog = ""
val sup = getMultipleActorsAllForOneConf
sup ! StartSupervisor
Thread.sleep(500)
intercept(classOf[RuntimeException]) {
intercept[RuntimeException] {
pingpong2 !! BinaryString("Die")
}
Thread.sleep(500)
@ -220,7 +218,7 @@ class RemoteSupervisorSpec extends junit.framework.TestCase with Suite {
expect("pingpingping") {
Log.messageLog
}
intercept(classOf[RuntimeException]) {
intercept[RuntimeException] {
pingpong2 !! BinaryString("Die")
}
Thread.sleep(500)
@ -245,7 +243,7 @@ class RemoteSupervisorSpec extends junit.framework.TestCase with Suite {
}
/*
def testOneWayKillSingleActorOneForOne = {
@Test def shouldOneWayKillSingleActorOneForOne = {
Logg.messageLog = ""
val sup = getSingleActorOneForOneSupervisor
sup ! StartSupervisor
@ -257,7 +255,7 @@ class RemoteSupervisorSpec extends junit.framework.TestCase with Suite {
}
}
def testOneWayCallKillCallSingleActorOneForOne = {
@Test def shouldOneWayCallKillCallSingleActorOneForOne = {
Logg.messageLog = ""
val sup = getSingleActorOneForOneSupervisor
sup ! StartSupervisor
@ -281,12 +279,12 @@ class RemoteSupervisorSpec extends junit.framework.TestCase with Suite {
*/
/*
def testOneWayKillSingleActorAllForOne = {
@Test def shouldOneWayKillSingleActorAllForOne = {
Logg.messageLog = ""
val sup = getSingleActorAllForOneSupervisor
sup ! StartSupervisor
Thread.sleep(500)
intercept(classOf[RuntimeException]) {
intercept[RuntimeException] {
pingpong1 ! BinaryString("Die")
}
Thread.sleep(500)
@ -295,7 +293,7 @@ class RemoteSupervisorSpec extends junit.framework.TestCase with Suite {
}
}
def testOneWayCallKillCallSingleActorAllForOne = {
@Test def shouldOneWayCallKillCallSingleActorAllForOne = {
Logg.messageLog = ""
val sup = getSingleActorAllForOneSupervisor
sup ! StartSupervisor
@ -307,7 +305,7 @@ class RemoteSupervisorSpec extends junit.framework.TestCase with Suite {
expect("ping") {
Logg.messageLog
}
intercept(classOf[RuntimeException]) {
intercept[RuntimeException] {
pingpong1 ! BinaryString("Die")
}
Thread.sleep(500)
@ -323,12 +321,12 @@ class RemoteSupervisorSpec extends junit.framework.TestCase with Suite {
}
}
def testOneWayKillMultipleActorsOneForOne = {
@Test def shouldOneWayKillMultipleActorsOneForOne = {
Logg.messageLog = ""
val sup = getMultipleActorsOneForOneConf
sup ! StartSupervisor
Thread.sleep(500)
intercept(classOf[RuntimeException]) {
intercept[RuntimeException] {
pingpong3 ! BinaryString("Die")
}
Thread.sleep(500)
@ -357,7 +355,7 @@ class RemoteSupervisorSpec extends junit.framework.TestCase with Suite {
expect("pingpingping") {
Logg.messageLog
}
intercept(classOf[RuntimeException]) {
intercept[RuntimeException] {
pingpong2 ! BinaryString("Die")
}
Thread.sleep(500)
@ -381,12 +379,12 @@ class RemoteSupervisorSpec extends junit.framework.TestCase with Suite {
}
}
def testOneWayKillMultipleActorsAllForOne = {
@Test def shouldOneWayKillMultipleActorsAllForOne = {
Logg.messageLog = ""
val sup = getMultipleActorsAllForOneConf
sup ! StartSupervisor
Thread.sleep(500)
intercept(classOf[RuntimeException]) {
intercept[RuntimeException] {
pingpong2 ! BinaryString("Die")
}
Thread.sleep(500)
@ -415,7 +413,7 @@ class RemoteSupervisorSpec extends junit.framework.TestCase with Suite {
expect("pingpingping") {
Logg.messageLog
}
intercept(classOf[RuntimeException]) {
intercept[RuntimeException] {
pingpong2 ! BinaryString("Die")
}
Thread.sleep(500)
@ -441,11 +439,11 @@ class RemoteSupervisorSpec extends junit.framework.TestCase with Suite {
*/
/*
def testNestedSupervisorsTerminateFirstLevelActorAllForOne = {
@Test def shouldNestedSupervisorsTerminateFirstLevelActorAllForOne = {
Logg.messageLog = ""
val sup = getNestedSupervisorsAllForOneConf
sup ! StartSupervisor
intercept(classOf[RuntimeException]) {
intercept[RuntimeException] {
pingpong1 !! BinaryString("Die")
}
Thread.sleep(500)

View file

@ -2,11 +2,12 @@ package se.scalablesolutions.akka.actor
import java.util.concurrent.TimeUnit
import org.junit.Assert._
import org.scalatest.junit.JUnitSuite
import org.junit.Test
class SchedulerSpec extends junit.framework.TestCase {
class SchedulerTest extends JUnitSuite {
def testScheduler = {
@Test def schedulerShouldSchedule = {
var count = 0
case object Tick
val actor = new Actor() {
@ -18,6 +19,6 @@ class SchedulerSpec extends junit.framework.TestCase {
Scheduler.schedule(actor, Tick, 0L, 1L, TimeUnit.SECONDS)
Thread.sleep(5000)
Scheduler.shutdown
assertTrue(count > 0)
assert(count > 0)
}
}

View file

@ -6,15 +6,13 @@ package se.scalablesolutions.akka.actor
import config.ScalaConfig._
//import com.jteigen.scalatest.JUnit4Runner
import org.junit.runner.RunWith
import org.scalatest.Suite
import org.scalatest.junit.JUnitSuite
import org.junit.Test
/**
* @author <a href="http://jonasboner.com">Jonas Bon&#233;r</a>
*/
//@RunWith(classOf[JUnit4Runner])
class SupervisorSpec extends junit.framework.TestCase with Suite {
class SupervisorTest extends JUnitSuite {
var messageLog: String = ""
var oneWayLog: String = ""
@ -23,7 +21,7 @@ class SupervisorSpec extends junit.framework.TestCase with Suite {
var pingpong2: PingPong2Actor = _
var pingpong3: PingPong3Actor = _
def testStartServer = {
@Test def shouldStartServer = {
messageLog = ""
val sup = getSingleActorAllForOneSupervisor
sup ! StartSupervisor
@ -33,12 +31,12 @@ class SupervisorSpec extends junit.framework.TestCase with Suite {
}
}
def testKillSingleActorOneForOne = {
@Test def shouldKillSingleActorOneForOne = {
messageLog = ""
val sup = getSingleActorOneForOneSupervisor
sup ! StartSupervisor
Thread.sleep(500)
intercept(classOf[RuntimeException]) {
intercept[RuntimeException] {
pingpong1 !! Die
}
Thread.sleep(500)
@ -47,7 +45,7 @@ class SupervisorSpec extends junit.framework.TestCase with Suite {
}
}
def testCallKillCallSingleActorOneForOne = {
@Test def shouldCallKillCallSingleActorOneForOne = {
messageLog = ""
val sup = getSingleActorOneForOneSupervisor
sup ! StartSupervisor
@ -59,7 +57,7 @@ class SupervisorSpec extends junit.framework.TestCase with Suite {
expect("ping") {
messageLog
}
intercept(classOf[RuntimeException]) {
intercept[RuntimeException] {
pingpong1 !! Die
}
Thread.sleep(500)
@ -75,12 +73,12 @@ class SupervisorSpec extends junit.framework.TestCase with Suite {
}
}
def testKillSingleActorAllForOne = {
@Test def shouldKillSingleActorAllForOne = {
messageLog = ""
val sup = getSingleActorAllForOneSupervisor
sup ! StartSupervisor
Thread.sleep(500)
intercept(classOf[RuntimeException]) {
intercept[RuntimeException] {
pingpong1 !! Die
}
Thread.sleep(500)
@ -89,7 +87,7 @@ class SupervisorSpec extends junit.framework.TestCase with Suite {
}
}
def testCallKillCallSingleActorAllForOne = {
@Test def shouldCallKillCallSingleActorAllForOne = {
messageLog = ""
val sup = getSingleActorAllForOneSupervisor
sup ! StartSupervisor
@ -101,7 +99,7 @@ class SupervisorSpec extends junit.framework.TestCase with Suite {
expect("ping") {
messageLog
}
intercept(classOf[RuntimeException]) {
intercept[RuntimeException] {
pingpong1 !! Die
}
Thread.sleep(500)
@ -117,12 +115,12 @@ class SupervisorSpec extends junit.framework.TestCase with Suite {
}
}
def testKillMultipleActorsOneForOne = {
@Test def shouldKillMultipleActorsOneForOne = {
messageLog = ""
val sup = getMultipleActorsOneForOneConf
sup ! StartSupervisor
Thread.sleep(500)
intercept(classOf[RuntimeException]) {
intercept[RuntimeException] {
pingpong3 !! Die
}
Thread.sleep(500)
@ -151,7 +149,7 @@ class SupervisorSpec extends junit.framework.TestCase with Suite {
expect("pingpingping") {
messageLog
}
intercept(classOf[RuntimeException]) {
intercept[RuntimeException] {
pingpong2 !! Die
}
Thread.sleep(500)
@ -175,12 +173,12 @@ class SupervisorSpec extends junit.framework.TestCase with Suite {
}
}
def testKillMultipleActorsAllForOne = {
@Test def shouldKillMultipleActorsAllForOne = {
messageLog = ""
val sup = getMultipleActorsAllForOneConf
sup ! StartSupervisor
Thread.sleep(500)
intercept(classOf[RuntimeException]) {
intercept[RuntimeException] {
pingpong2 !! Die
}
Thread.sleep(500)
@ -209,7 +207,7 @@ class SupervisorSpec extends junit.framework.TestCase with Suite {
expect("pingpingping") {
messageLog
}
intercept(classOf[RuntimeException]) {
intercept[RuntimeException] {
pingpong2 !! Die
}
Thread.sleep(500)
@ -233,7 +231,7 @@ class SupervisorSpec extends junit.framework.TestCase with Suite {
}
}
def testOneWayKillSingleActorOneForOne = {
@Test def shouldOneWayKillSingleActorOneForOne = {
messageLog = ""
val sup = getSingleActorOneForOneSupervisor
sup ! StartSupervisor
@ -245,7 +243,7 @@ class SupervisorSpec extends junit.framework.TestCase with Suite {
}
}
def testOneWayCallKillCallSingleActorOneForOne = {
@Test def shouldOneWayCallKillCallSingleActorOneForOne = {
messageLog = ""
val sup = getSingleActorOneForOneSupervisor
sup ! StartSupervisor
@ -268,12 +266,12 @@ class SupervisorSpec extends junit.framework.TestCase with Suite {
}
/*
def testOneWayKillSingleActorAllForOne = {
@Test def shouldOneWayKillSingleActorAllForOne = {
messageLog = ""
val sup = getSingleActorAllForOneSupervisor
sup ! StartSupervisor
Thread.sleep(500)
intercept(classOf[RuntimeException]) {
intercept[RuntimeException] {
pingpong1 ! Die
}
Thread.sleep(500)
@ -282,7 +280,7 @@ class SupervisorSpec extends junit.framework.TestCase with Suite {
}
}
def testOneWayCallKillCallSingleActorAllForOne = {
@Test def shouldOneWayCallKillCallSingleActorAllForOne = {
messageLog = ""
val sup = getSingleActorAllForOneSupervisor
sup ! StartSupervisor
@ -294,7 +292,7 @@ class SupervisorSpec extends junit.framework.TestCase with Suite {
expect("ping") {
messageLog
}
intercept(classOf[RuntimeException]) {
intercept[RuntimeException] {
pingpong1 ! Die
}
Thread.sleep(500)
@ -310,12 +308,12 @@ class SupervisorSpec extends junit.framework.TestCase with Suite {
}
}
def testOneWayKillMultipleActorsOneForOne = {
@Test def shouldOneWayKillMultipleActorsOneForOne = {
messageLog = ""
val sup = getMultipleActorsOneForOneConf
sup ! StartSupervisor
Thread.sleep(500)
intercept(classOf[RuntimeException]) {
intercept[RuntimeException] {
pingpong3 ! Die
}
Thread.sleep(500)
@ -344,7 +342,7 @@ class SupervisorSpec extends junit.framework.TestCase with Suite {
expect("pingpingping") {
messageLog
}
intercept(classOf[RuntimeException]) {
intercept[RuntimeException] {
pingpong2 ! Die
}
Thread.sleep(500)
@ -368,12 +366,12 @@ class SupervisorSpec extends junit.framework.TestCase with Suite {
}
}
def testOneWayKillMultipleActorsAllForOne = {
@Test def shouldOneWayKillMultipleActorsAllForOne = {
messageLog = ""
val sup = getMultipleActorsAllForOneConf
sup ! StartSupervisor
Thread.sleep(500)
intercept(classOf[RuntimeException]) {
intercept[RuntimeException] {
pingpong2 ! Die
}
Thread.sleep(500)
@ -402,7 +400,7 @@ class SupervisorSpec extends junit.framework.TestCase with Suite {
expect("pingpingping") {
messageLog
}
intercept(classOf[RuntimeException]) {
intercept[RuntimeException] {
pingpong2 ! Die
}
Thread.sleep(500)
@ -428,11 +426,11 @@ class SupervisorSpec extends junit.framework.TestCase with Suite {
*/
/*
def testNestedSupervisorsTerminateFirstLevelActorAllForOne = {
@Test def shouldNestedSupervisorsTerminateFirstLevelActorAllForOne = {
messageLog = ""
val sup = getNestedSupervisorsAllForOneConf
sup ! StartSupervisor
intercept(classOf[RuntimeException]) {
intercept[RuntimeException] {
pingpong1 !! Die
}
Thread.sleep(500)

View file

@ -2,11 +2,12 @@ package se.scalablesolutions.akka.actor
import java.util.concurrent.TimeUnit
import junit.framework.Assert._
import org.scalatest.junit.JUnitSuite
import org.junit.Test
import se.scalablesolutions.akka.dispatch.Dispatchers
class ThreadBasedActorSpec extends junit.framework.TestCase {
class ThreadBasedActorTest extends JUnitSuite {
private val unit = TimeUnit.MILLISECONDS
class TestActor extends Actor {
@ -20,7 +21,7 @@ class ThreadBasedActorSpec extends junit.framework.TestCase {
}
}
def testSendOneWay = {
@Test def shouldSendOneWay = {
implicit val timeout = 5000L
var oneWay = "nada"
val actor = new Actor {
@ -31,29 +32,29 @@ class ThreadBasedActorSpec extends junit.framework.TestCase {
actor.start
val result = actor ! "OneWay"
Thread.sleep(100)
assertEquals("received", oneWay)
assert("received" === oneWay)
actor.stop
}
def testSendReplySync = {
@Test def shouldSendReplySync = {
implicit val timeout = 5000L
val actor = new TestActor
actor.start
val result: String = actor !? "Hello"
assertEquals("World", result)
assert("World" === result)
actor.stop
}
def testSendReplyAsync = {
@Test def shouldSendReplyAsync = {
implicit val timeout = 5000L
val actor = new TestActor
actor.start
val result = actor !! "Hello"
assertEquals("World", result.get.asInstanceOf[String])
assert("World" === result.get.asInstanceOf[String])
actor.stop
}
def testSendReceiveException = {
@Test def shouldSendReceiveException = {
implicit val timeout = 5000L
val actor = new TestActor
actor.start
@ -62,7 +63,7 @@ class ThreadBasedActorSpec extends junit.framework.TestCase {
fail("Should have thrown an exception")
} catch {
case e =>
assertEquals("expected", e.getMessage())
assert("expected" === e.getMessage())
}
actor.stop
}

View file

@ -5,12 +5,13 @@ import java.util.concurrent.TimeUnit
import java.util.concurrent.atomic.AtomicBoolean
import java.util.concurrent.locks.Lock
import java.util.concurrent.locks.ReentrantLock
import org.scalatest.junit.JUnitSuite
import org.junit.{Test, Before}
import org.junit.Assert._
import junit.framework.TestCase
import se.scalablesolutions.akka.actor.Actor
class ThreadBasedDispatcherTest extends TestCase {
class ThreadBasedDispatcherTest extends JUnitSuite {
private var threadingIssueDetected: AtomicBoolean = null
val key1 = new Actor { def receive: PartialFunction[Any, Unit] = { case _ => {}} }
val key2 = new Actor { def receive: PartialFunction[Any, Unit] = { case _ => {}} }
@ -36,17 +37,17 @@ class ThreadBasedDispatcherTest extends TestCase {
}
@Before
override def setUp = {
def setUp = {
threadingIssueDetected = new AtomicBoolean(false)
}
@Test
def testMessagesDispatchedToTheSameHandlerAreExecutedSequentially = {
def shouldMessagesDispatchedToTheSameHandlerAreExecutedSequentially = {
internalTestMessagesDispatchedToTheSameHandlerAreExecutedSequentially
}
@Test
def testMessagesDispatchedToHandlersAreExecutedInFIFOOrder = {
def shouldMessagesDispatchedToHandlersAreExecutedInFIFOOrder = {
internalTestMessagesDispatchedToHandlersAreExecutedInFIFOOrder
}
@ -58,8 +59,8 @@ class ThreadBasedDispatcherTest extends TestCase {
for (i <- 0 until 100) {
dispatcher.messageQueue.append(new MessageInvocation(key1, new Object, None, None))
}
assertTrue(handleLatch.await(5, TimeUnit.SECONDS))
assertFalse(threadingIssueDetected.get)
assert(handleLatch.await(5, TimeUnit.SECONDS))
assert(!threadingIssueDetected.get)
}
private def internalTestMessagesDispatchedToHandlersAreExecutedInFIFOOrder: Unit = {
@ -79,8 +80,8 @@ class ThreadBasedDispatcherTest extends TestCase {
for (i <- 0 until 100) {
dispatcher.messageQueue.append(new MessageInvocation(key1, new Integer(i), None, None))
}
assertTrue(handleLatch.await(5, TimeUnit.SECONDS))
assertFalse(threadingIssueDetected.get)
assert(handleLatch.await(5, TimeUnit.SECONDS))
assert(!threadingIssueDetected.get)
dispatcher.shutdown
}
}

View file

@ -1,144 +0,0 @@
package se.scalablesolutions.akka.actor
import junit.framework.TestCase
import org.junit.{Test, Before}
import org.junit.Assert._
import state.TransactionalState
class TxActor(clasher: Actor) extends Actor {
timeout = 1000000
makeTransactionRequired
def receive: PartialFunction[Any, Unit] = {
case msg: AnyRef =>
clasher !! msg
reply(msg)
}
}
class TxClasherActor extends Actor {
val vector = TransactionalState.newVector[String]
timeout = 1000000
makeTransactionRequired
var count = 0
def receive: PartialFunction[Any, Unit] = {
case "First" =>
if (count == 0) Thread.sleep(5000)
count += 1
println("FIRST")
vector.add("First")
println("--- VECTOR: " + vector)
reply("First")
case "Second" =>
println("SECOND")
vector.add("Second")
println("--- VECTOR: " + vector)
reply("Second")
case "Index0" =>
reply(vector(0))
case "Index1" =>
reply(vector(1))
}
}
class TxActorOneWay(clasher: Actor) extends Actor {
timeout = 1000000
makeTransactionRequired
def receive: PartialFunction[Any, Unit] = {
case msg: AnyRef =>
clasher ! msg
}
}
class TxClasherActorOneWay extends Actor {
val vector = TransactionalState.newVector[String]
timeout = 1000000
makeTransactionRequired
var count = 0
def receive: PartialFunction[Any, Unit] = {
case "First" =>
if (count == 0) Thread.sleep(5000)
count += 1
println("FIRST")
vector.add("First")
println("--- VECTOR: " + vector)
case "Second" =>
println("SECOND")
vector.add("Second")
println("--- VECTOR: " + vector)
case "Index0" =>
reply(vector(0))
case "Index1" =>
reply(vector(1))
}
}
class TransactionClasherSpec extends TestCase {
@Test
def testBangBangClash = {
val clasher = new TxClasherActor
clasher.start
val txActor1 = new TxActor(clasher)
txActor1.start
val txActor2 = new TxActor(clasher)
txActor2.start
val t1 = new Thread(new Runnable() {
def run = {
txActor1 !! "First"
}
}).start
Thread.sleep(1000)
try {
txActor2 !! "Second"
fail("Expected Exception")
} catch { case e: Exception => {} }
}
@Test
def testBangClash = {
val clasher = new TxClasherActorOneWay
clasher.start
val txActor1 = new TxActorOneWay(clasher)
txActor1.start
val txActor2 = new TxActorOneWay(clasher)
txActor2.start
val t1 = new Thread(new Runnable() {
def run = {
txActor1 ! "First"
}
}).start
Thread.sleep(1000)
try {
txActor2 ! "Second"
fail("Expected Exception")
} catch { case e: Exception => {} }
}
/*
@Test
def testX = {
val clasher = new TxClasherActor
clasher.start
val txActor1 = new TxActor(clasher)
txActor1.start
val txActor2 = new TxActor(clasher)
txActor2.start
val t1 = new Thread(new Runnable() {
def run = {
txActor1 !! "First"
}
}).start
Thread.sleep(1000)
val res2 = txActor2 !! "Second"
Thread.sleep(10000)
assertEquals("Second", (clasher !! "Index0").get)
assertEquals("First", (clasher !! "Index1").get)
}
*/
}

View file

@ -36,14 +36,6 @@
distributed = off # not implemented yet
</stm>
<rest>
service = on
hostname = "localhost"
port = 9998
filters = "se.scalablesolutions.akka.security.AkkaSecurityFilterFactory"
authenticator = "se.scalablesolutions.akka.security.samples.BasicAuthenticationService"
</rest>
<remote>
<server>
service = on
@ -57,6 +49,14 @@
<client>
</remote>
<rest>
service = on
hostname = "localhost"
port = 9998
filters = "se.scalablesolutions.akka.security.AkkaSecurityFilterFactory"
authenticator = "se.scalablesolutions.akka.security.samples.BasicAuthenticationService"
</rest>
<storage>
<cassandra>
hostname = "127.0.0.1" # IP address or hostname of one of the Cassandra cluster's seeds

View file

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.twitter</groupId>
<artifactId>scala-json</artifactId>
<version>0.1</version>
<packaging>jar</packaging>
</project>