summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorphaller <hallerp@gmail.com>2012-09-29 18:15:37 +0200
committerphaller <hallerp@gmail.com>2012-09-29 18:19:52 +0200
commitb2211a76a6e537cf2e404d424cb643f171818e92 (patch)
tree0fde859c45025594b7205cffe1c29fc37bf9b483 /test
parentbe49f36154efa78c3dcbeba394aa6ec2b5e764ec (diff)
downloadscala-b2211a76a6e537cf2e404d424cb643f171818e92.tar.gz
scala-b2211a76a6e537cf2e404d424cb643f171818e92.tar.bz2
scala-b2211a76a6e537cf2e404d424cb643f171818e92.zip
SI-6442 - Add ActorDSL object for actor migration kit
Removes MigrationSystem, since ActorDSL replaces it.
Diffstat (limited to 'test')
-rw-r--r--test/files/jvm/actmig-PinS_1.scala21
-rw-r--r--test/files/jvm/actmig-PinS_2.scala23
-rw-r--r--test/files/jvm/actmig-PinS_3.scala24
-rw-r--r--test/files/jvm/actmig-instantiation.check4
-rw-r--r--test/files/jvm/actmig-instantiation.scala33
-rw-r--r--test/files/jvm/actmig-loop-react.scala19
-rw-r--r--test/files/jvm/actmig-public-methods.scala3
-rw-r--r--test/files/jvm/actmig-public-methods_1.scala4
-rw-r--r--test/files/jvm/actmig-react-receive.scala9
-rw-r--r--test/files/jvm/actmig-react-within.scala5
-rw-r--r--test/files/jvm/actmig-receive.scala1
11 files changed, 68 insertions, 78 deletions
diff --git a/test/files/jvm/actmig-PinS_1.scala b/test/files/jvm/actmig-PinS_1.scala
index 876688ca75..495852e812 100644
--- a/test/files/jvm/actmig-PinS_1.scala
+++ b/test/files/jvm/actmig-PinS_1.scala
@@ -9,7 +9,7 @@ import scala.concurrent.{ Promise, Await }
object SillyActor {
val startPromise = Promise[Boolean]()
- val ref = MigrationSystem.actorOf(Props(() => new SillyActor, "akka.actor.default-stash-dispatcher"))
+ val ref = ActorDSL.actor(new SillyActor)
}
/* PinS, Listing 32.1: A simple actor
@@ -27,7 +27,7 @@ class SillyActor extends Actor {
object SeriousActor {
val startPromise = Promise[Boolean]()
- val ref = MigrationSystem.actorOf(Props(() => new SeriousActor, "akka.actor.default-stash-dispatcher"))
+ val ref = ActorDSL.actor(new SeriousActor)
}
class SeriousActor extends Actor {
@@ -72,7 +72,7 @@ object Test extends App {
/* PinS, Listing 32.2: An actor that calls receive
*/
- def makeEchoActor(): ActorRef = MigrationSystem.actorOf(Props(() => new Actor {
+ def makeEchoActor(): ActorRef = ActorDSL.actor(new Actor {
def act() {
while (true) {
receive {
@@ -83,20 +83,20 @@ object Test extends App {
}
}
}
- }, "akka.actor.default-stash-dispatcher"))
+ })
/* PinS, page 696
*/
- def makeIntActor(): ActorRef = MigrationSystem.actorOf(Props(() => new Actor {
+ def makeIntActor(): ActorRef = ActorDSL.actor(new Actor {
def act() {
receive {
case x: Int => // I only want Ints
println("Got an Int: " + x)
}
}
- }, "akka.actor.default-stash-dispatcher"))
+ })
- MigrationSystem.actorOf(Props(() => new Actor {
+ ActorDSL.actor(new Actor {
def act() {
trapExit = true
link(SillyActor.ref)
@@ -109,15 +109,14 @@ object Test extends App {
case Exit(_: SeriousActor, _) =>
val seriousPromise2 = Promise[Boolean]()
// PinS, page 694
- val seriousActor2 = MigrationSystem.actorOf(Props(() =>
+ val seriousActor2 = ActorDSL.actor(
new Actor {
def act() {
for (i <- 1 to 5)
println("That is the question.")
seriousPromise2.success(true)
}
- }
- , "akka.actor.default-stash-dispatcher"))
+ })
Await.ready(seriousPromise2.future, 5 seconds)
val echoActor = makeEchoActor()
@@ -136,5 +135,5 @@ object Test extends App {
}
}
}
- }, "akka.actor.default-stash-dispatcher"))
+ })
}
diff --git a/test/files/jvm/actmig-PinS_2.scala b/test/files/jvm/actmig-PinS_2.scala
index 7d12578f71..508525463f 100644
--- a/test/files/jvm/actmig-PinS_2.scala
+++ b/test/files/jvm/actmig-PinS_2.scala
@@ -9,7 +9,7 @@ import scala.concurrent.{ Promise, Await }
object SillyActor {
val startPromise = Promise[Boolean]()
- val ref = MigrationSystem.actorOf(Props(() => new SillyActor, "default-stash-dispatcher"))
+ val ref = ActorDSL.actor(new SillyActor)
}
/* PinS, Listing 32.1: A simple actor
@@ -29,7 +29,7 @@ class SillyActor extends StashingActor {
object SeriousActor {
val startPromise = Promise[Boolean]()
- val ref = MigrationSystem.actorOf(Props(() => new SeriousActor, "default-stash-dispatcher"))
+ val ref = ActorDSL.actor(new SeriousActor)
}
class SeriousActor extends StashingActor {
@@ -44,7 +44,7 @@ class SeriousActor extends StashingActor {
/* PinS, Listing 32.3: An actor that calls react
*/
object NameResolver {
- val ref = MigrationSystem.actorOf(Props(() => new NameResolver, "default-stash-dispatcher"))
+ val ref = ActorDSL.actor(new NameResolver)
}
class NameResolver extends StashingActor {
@@ -80,7 +80,7 @@ object Test extends App {
/* PinS, Listing 32.2: An actor that calls receive
*/
- def makeEchoActor(): ActorRef = MigrationSystem.actorOf(Props(() =>
+ def makeEchoActor(): ActorRef = ActorDSL.actor(
new StashingActor {
def receive = { case _ => println("Nop") }
@@ -94,11 +94,11 @@ object Test extends App {
}
}
}
- }, "default-stash-dispatcher"))
+ })
/* PinS, page 696
*/
- def makeIntActor(): ActorRef = MigrationSystem.actorOf(Props(() =>new StashingActor {
+ def makeIntActor(): ActorRef = ActorDSL.actor(new StashingActor {
def receive = { case _ => println("Nop") }
@@ -108,9 +108,9 @@ object Test extends App {
println("Got an Int: " + x)
}
}
- }, "default-stash-dispatcher"))
+ })
- MigrationSystem.actorOf(Props(() => new StashingActor {
+ ActorDSL.actor(new StashingActor {
def receive = { case _ => println("Nop") }
@@ -126,7 +126,7 @@ object Test extends App {
case Exit(_: SeriousActor, _) =>
val seriousPromise2 = Promise[Boolean]()
// PinS, page 694
- val seriousActor2 = MigrationSystem.actorOf(Props(() =>{
+ val seriousActor2 = ActorDSL.actor(
new StashingActor {
def receive = { case _ => println("Nop") }
@@ -136,8 +136,7 @@ object Test extends App {
println("That is the question.")
seriousPromise2.success(true)
}
- }
- }, "default-stash-dispatcher"))
+ })
Await.ready(seriousPromise2.future, 5 seconds)
val echoActor = makeEchoActor()
@@ -156,5 +155,5 @@ object Test extends App {
}
}
}
- }, "default-stash-dispatcher"))
+ })
}
diff --git a/test/files/jvm/actmig-PinS_3.scala b/test/files/jvm/actmig-PinS_3.scala
index c2943008b0..6c6ec6789b 100644
--- a/test/files/jvm/actmig-PinS_3.scala
+++ b/test/files/jvm/actmig-PinS_3.scala
@@ -7,10 +7,9 @@ import scala.actors.migration._
import scala.concurrent.duration._
import scala.concurrent.{ Promise, Await }
-
object SillyActor {
val startPromise = Promise[Boolean]()
- val ref = MigrationSystem.actorOf(Props(() => new SillyActor, "default-stash-dispatcher"))
+ val ref = ActorDSL.actor(new SillyActor)
}
/* PinS, Listing 32.1: A simple actor
@@ -32,7 +31,7 @@ class SillyActor extends StashingActor {
object SeriousActor {
val startPromise = Promise[Boolean]()
- val ref = MigrationSystem.actorOf(Props(() => new SeriousActor, "default-stash-dispatcher"))
+ val ref = ActorDSL.actor(new SeriousActor)
}
class SeriousActor extends StashingActor {
@@ -48,7 +47,7 @@ class SeriousActor extends StashingActor {
/* PinS, Listing 32.3: An actor that calls react
*/
object NameResolver {
- val ref = MigrationSystem.actorOf(Props(() => new NameResolver, "default-stash-dispatcher"))
+ val ref = ActorDSL.actor(new NameResolver)
}
class NameResolver extends StashingActor {
@@ -78,7 +77,7 @@ object Test extends App {
/* PinS, Listing 32.2: An actor that calls receive
*/
- def makeEchoActor(): ActorRef = MigrationSystem.actorOf(Props(() => new StashingActor {
+ def makeEchoActor(): ActorRef = ActorDSL.actor(new StashingActor {
def receive = { // how to handle receive
case 'stop =>
@@ -86,11 +85,11 @@ object Test extends App {
case msg =>
println("received message: " + msg)
}
- }, "default-stash-dispatcher"))
+ })
/* PinS, page 696
*/
- def makeIntActor(): ActorRef = MigrationSystem.actorOf(Props(() => new StashingActor {
+ def makeIntActor(): ActorRef = ActorDSL.actor(new StashingActor {
def receive = {
case x: Int => // I only want Ints
@@ -99,9 +98,9 @@ object Test extends App {
context.stop(self)
case _ => stash()
}
- }, "default-stash-dispatcher"))
+ })
- MigrationSystem.actorOf(Props(() => new StashingActor {
+ ActorDSL.actor(new StashingActor {
val silly = SillyActor.ref
override def preStart() {
@@ -119,7 +118,7 @@ object Test extends App {
case Terminated(`serious`) =>
val seriousPromise2 = Promise[Boolean]()
// PinS, page 694
- val seriousActor2 = MigrationSystem.actorOf(Props(() => {
+ val seriousActor2 = ActorDSL.actor(
new StashingActor {
def receive = { case _ => context.stop(self) }
@@ -130,8 +129,7 @@ object Test extends App {
seriousPromise2.success(true)
context.stop(self)
}
- }
- }, "default-stash-dispatcher"))
+ })
Await.ready(seriousPromise2.future, 5 seconds)
val echoActor = makeEchoActor()
@@ -162,5 +160,5 @@ object Test extends App {
println("Stash 3 " + m)
stash(m)
}
- }, "default-stash-dispatcher"))
+ })
}
diff --git a/test/files/jvm/actmig-instantiation.check b/test/files/jvm/actmig-instantiation.check
index 4c13d5c0a1..08ef979794 100644
--- a/test/files/jvm/actmig-instantiation.check
+++ b/test/files/jvm/actmig-instantiation.check
@@ -1,5 +1,5 @@
-OK error: java.lang.RuntimeException: In order to create StashingActor one must use actorOf.
-OK error: java.lang.RuntimeException: Only one actor can be created per actorOf call.
+OK error: java.lang.RuntimeException: In order to create a StashingActor one must use the ActorDSL object
+OK error: java.lang.RuntimeException: Cannot create more than one actor
0
100
200
diff --git a/test/files/jvm/actmig-instantiation.scala b/test/files/jvm/actmig-instantiation.scala
index d54dff9558..2e3ffc3c30 100644
--- a/test/files/jvm/actmig-instantiation.scala
+++ b/test/files/jvm/actmig-instantiation.scala
@@ -2,7 +2,6 @@
* NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change
* code in these tests prior to the 2.10.0 release please send the notification to @vjovanov.
*/
-import scala.actors.migration.MigrationSystem._
import scala.actors.migration._
import scala.actors.Actor._
import scala.actors._
@@ -35,53 +34,53 @@ object Test {
a1 ! 100
// simple instantiation
- val a2 = MigrationSystem.actorOf(Props(() => new TestStashingActor, "akka.actor.default-stash-dispatcher"))
+ val a2 = ActorDSL.actor(new TestStashingActor)
a2 ! 200
toStop += a2
// actor of with scala actor
- val a3 = MigrationSystem.actorOf(Props(() => actor {
+ val a3 = ActorDSL.actor(actor {
react { case v: Int => Test.append(v); Test.latch.countDown() }
- }, "akka.actor.default-stash-dispatcher"))
+ })
a3 ! 300
// using the manifest
- val a4 = MigrationSystem.actorOf(Props(() => new TestStashingActor, "akka.actor.default-stash-dispatcher"))
+ val a4 = ActorDSL.actor(new TestStashingActor)
a4 ! 400
toStop += a4
// deterministic part of a test
- // creation without actorOf
+ // creation without actor
try {
val a3 = new TestStashingActor
a3 ! -1
} catch {
- case e => println("OK error: " + e)
+ case e: Throwable => println("OK error: " + e)
}
- // actorOf double creation
+ // actor double creation
try {
- val a3 = MigrationSystem.actorOf(Props(() => {
+ val a3 = ActorDSL.actor({
new TestStashingActor
new TestStashingActor
- }, "akka.actor.default-stash-dispatcher"))
+ })
a3 ! -1
} catch {
- case e => println("OK error: " + e)
+ case e: Throwable => println("OK error: " + e)
}
- // actorOf nesting
+ // actor nesting
try {
- val a5 = MigrationSystem.actorOf(Props(() => {
- val a6 = MigrationSystem.actorOf(Props(() => new TestStashingActor, "akka.actor.default-stash-dispatcher"))
+ val a5 = ActorDSL.actor({
+ val a6 = ActorDSL.actor(new TestStashingActor)
toStop += a6
new TestStashingActor
- }, "akka.actor.default-stash-dispatcher"))
+ })
a5 ! 500
toStop += a5
} catch {
- case e => println("Should not throw an exception: " + e)
+ case e: Throwable => println("Should not throw an exception: " + e)
}
// output
@@ -93,4 +92,4 @@ object Test {
buff.sorted.foreach(println)
toStop.foreach(_ ! PoisonPill)
}
-} \ No newline at end of file
+}
diff --git a/test/files/jvm/actmig-loop-react.scala b/test/files/jvm/actmig-loop-react.scala
index 7f4c6f96dc..c9a3664526 100644
--- a/test/files/jvm/actmig-loop-react.scala
+++ b/test/files/jvm/actmig-loop-react.scala
@@ -2,7 +2,6 @@
* NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change
* code in these tests prior to the 2.10.0 release please send the notification to @vjovanov.
*/
-import scala.actors.migration.MigrationSystem._
import scala.actors.Actor._
import scala.actors._
import scala.actors.migration._
@@ -40,7 +39,7 @@ object Test {
Await.ready(finishedLWCR1.future, 5 seconds)
// Loop with Condition Snippet - migrated
- val myAkkaActor = MigrationSystem.actorOf(Props(() => new StashingActor {
+ val myAkkaActor = ActorDSL.actor(new StashingActor {
def receive = {
case x: Int =>
@@ -51,7 +50,7 @@ object Test {
context.stop(self)
}
}
- }, "default-stashing-dispatcher"))
+ })
myAkkaActor ! 1
myAkkaActor ! 42
}
@@ -88,7 +87,7 @@ object Test {
Await.ready(finishedTNR1.future, 5 seconds)
// Loop with Condition Snippet - migrated
- val myAkkaActor = MigrationSystem.actorOf(Props(() => new StashingActor {
+ val myAkkaActor = ActorDSL.actor(new StashingActor {
def receive = {
case x: Int =>
@@ -107,7 +106,7 @@ object Test {
context.unbecome()
}).orElse { case x => stash() })
}
- }, "default-stashing-dispatcher"))
+ })
myAkkaActor ! 1
myAkkaActor ! "I am a String"
@@ -117,7 +116,7 @@ object Test {
def exceptionHandling() = {
// Stashing actor with act and exception handler
- val myActor = MigrationSystem.actorOf(Props(() => new StashingActor {
+ val myActor = ActorDSL.actor(new StashingActor {
def receive = { case _ => println("Dummy method.") }
override def act() = {
@@ -138,7 +137,7 @@ object Test {
case x: Exception => println("scala got exception")
}
- }, "default-stashing-dispatcher"))
+ })
myActor ! "work"
myActor ! "fail"
@@ -146,7 +145,7 @@ object Test {
Await.ready(finishedEH1.future, 5 seconds)
// Stashing actor in Akka style
- val myAkkaActor = MigrationSystem.actorOf(Props(() => new StashingActor {
+ val myAkkaActor = ActorDSL.actor(new StashingActor {
def receive = PFCatch({
case "fail" =>
throw new Exception("failed")
@@ -156,14 +155,14 @@ object Test {
finishedEH.success(true)
context.stop(self)
}, { case x: Exception => println("akka got exception") })
- }, "default-stashing-dispatcher"))
+ })
myAkkaActor ! "work"
myAkkaActor ! "fail"
myAkkaActor ! "die"
}
- def main(args: Array[String]) = {
+ def main(args: Array[String]): Unit = {
testLoopWithConditionReact()
Await.ready(finishedLWCR.future, 5 seconds)
exceptionHandling()
diff --git a/test/files/jvm/actmig-public-methods.scala b/test/files/jvm/actmig-public-methods.scala
index 58d7a1a9d4..8891c80668 100644
--- a/test/files/jvm/actmig-public-methods.scala
+++ b/test/files/jvm/actmig-public-methods.scala
@@ -5,7 +5,6 @@
import scala.collection.mutable.ArrayBuffer
import scala.actors.Actor._
import scala.actors._
-import scala.actors.migration.MigrationSystem
import scala.util.continuations._
import java.util.concurrent.{ TimeUnit, CountDownLatch }
@@ -71,4 +70,4 @@ object Test {
buff.sorted.foreach(println)
toStop.foreach(_ ! 'stop)
}
-} \ No newline at end of file
+}
diff --git a/test/files/jvm/actmig-public-methods_1.scala b/test/files/jvm/actmig-public-methods_1.scala
index 15516a5d51..db21ab983c 100644
--- a/test/files/jvm/actmig-public-methods_1.scala
+++ b/test/files/jvm/actmig-public-methods_1.scala
@@ -28,7 +28,7 @@ object Test {
def main(args: Array[String]) = {
- val respActor = MigrationSystem.actorOf(Props(() => actor {
+ val respActor = ActorDSL.actor(actor {
loop {
react {
case (x: String, time: Long) =>
@@ -41,7 +41,7 @@ object Test {
exit()
}
}
- }, "akka.actor.default-stash-dispatcher"))
+ })
toStop += respActor
diff --git a/test/files/jvm/actmig-react-receive.scala b/test/files/jvm/actmig-react-receive.scala
index 6adeac8b52..bf70ce0c46 100644
--- a/test/files/jvm/actmig-react-receive.scala
+++ b/test/files/jvm/actmig-react-receive.scala
@@ -2,7 +2,6 @@
* NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change
* code in these tests prior to the 2.10.0 release please send the notification to @vjovanov.
*/
-import scala.actors.migration.MigrationSystem._
import scala.actors.Actor._
import scala.actors._
import scala.actors.migration._
@@ -39,7 +38,7 @@ object Test {
Await.ready(finishedRSC1.future, 5 seconds)
// React Snippet - migrated
- val myAkkaActor = MigrationSystem.actorOf(Props(() => new StashingActor {
+ val myAkkaActor = ActorDSL.actor(new StashingActor {
override def preStart() = {
println("do before")
}
@@ -63,7 +62,7 @@ object Test {
finishedRSC.success(true)
}
- }, "default-stashing-dispatcher"))
+ })
myAkkaActor ! 1
myAkkaActor ! "1"
Await.ready(finishedRSC.future, 5 seconds)
@@ -88,7 +87,7 @@ object Test {
Await.ready(finishedRS1.future, 5 seconds)
// React Snippet - migrated
- val myAkkaActor = MigrationSystem.actorOf(Props(() => new StashingActor {
+ val myAkkaActor = ActorDSL.actor(new StashingActor {
override def preStart() = {
println("do before")
}
@@ -105,7 +104,7 @@ object Test {
finishedRS.success(true)
}
- }, "default-stashing-dispatcher"))
+ })
myAkkaActor ! 1
Await.ready(finishedRS.future, 5 seconds)
diff --git a/test/files/jvm/actmig-react-within.scala b/test/files/jvm/actmig-react-within.scala
index 43350ef120..3057398cb5 100644
--- a/test/files/jvm/actmig-react-within.scala
+++ b/test/files/jvm/actmig-react-within.scala
@@ -2,7 +2,6 @@
* NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change
* code in these tests prior to the 2.10.0 release please send the notification to @vjovanov.
*/
-import scala.actors.migration.MigrationSystem._
import scala.actors.Actor._
import scala.actors._
import scala.actors.migration._
@@ -27,7 +26,7 @@ object Test {
}
}
- val myActor = MigrationSystem.actorOf(Props(() => new StashingActor {
+ val myActor = ActorDSL.actor(new StashingActor {
context.setReceiveTimeout(1 millisecond)
def receive = {
case ReceiveTimeout =>
@@ -37,7 +36,7 @@ object Test {
case _ =>
println("Should not occur.")
}
- }, "default-stashing-dispatcher"))
+ })
}
def main(args: Array[String]) = {
diff --git a/test/files/jvm/actmig-receive.scala b/test/files/jvm/actmig-receive.scala
index 03dc1be63b..308643cf41 100644
--- a/test/files/jvm/actmig-receive.scala
+++ b/test/files/jvm/actmig-receive.scala
@@ -2,7 +2,6 @@
* NOTE: Code snippets from this test are included in the Actor Migration Guide. In case you change
* code in these tests prior to the 2.10.0 release please send the notification to @vjovanov.
*/
-import scala.actors.migration.MigrationSystem._
import scala.actors.Actor._
import scala.actors._
import scala.actors.migration._