Changed Akka config file syntax to JSON-style instead of XML style
Plus added missing test classes for ActiveObjectContextSpec
This commit is contained in:
parent
48ec67d754
commit
6c0503ea51
4 changed files with 108 additions and 38 deletions
|
|
@ -0,0 +1,20 @@
|
|||
package se.scalablesolutions.akka.actor;
|
||||
|
||||
import se.scalablesolutions.akka.dispatch.CompletableFuture;
|
||||
|
||||
public class SimpleJavaPojoCaller {
|
||||
|
||||
SimpleJavaPojo pojo;
|
||||
|
||||
public void setPojo(SimpleJavaPojo pojo) {
|
||||
this.pojo = pojo;
|
||||
}
|
||||
|
||||
public Object getSenderFromSimpleJavaPojo() {
|
||||
return pojo.getSender();
|
||||
}
|
||||
|
||||
public CompletableFuture<Object> getSenderFutureFromSimpleJavaPojo() {
|
||||
return pojo.getSenderFuture();
|
||||
}
|
||||
}
|
||||
45
akka-core/src/test/scala/ActiveObjectContextSpec.scala
Normal file
45
akka-core/src/test/scala/ActiveObjectContextSpec.scala
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/**
|
||||
* Copyright (C) 2009-2010 Scalable Solutions AB <http://scalablesolutions.se>
|
||||
*/
|
||||
|
||||
package se.scalablesolutions.akka.actor
|
||||
|
||||
import org.scalatest.Spec
|
||||
import org.scalatest.Assertions
|
||||
import org.scalatest.matchers.ShouldMatchers
|
||||
import org.scalatest.BeforeAndAfterAll
|
||||
import org.scalatest.junit.JUnitRunner
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
import se.scalablesolutions.akka.dispatch.DefaultCompletableFuture;
|
||||
|
||||
@RunWith(classOf[JUnitRunner])
|
||||
class ActiveObjectContextSpec extends
|
||||
Spec with
|
||||
ShouldMatchers with
|
||||
BeforeAndAfterAll {
|
||||
|
||||
describe("ActiveObjectContext") {
|
||||
it("context.sender should return the sender Active Object reference") {
|
||||
val pojo = ActiveObject.newInstance(classOf[SimpleJavaPojo])
|
||||
val pojoCaller = ActiveObject.newInstance(classOf[SimpleJavaPojoCaller])
|
||||
pojoCaller.setPojo(pojo)
|
||||
try {
|
||||
pojoCaller.getSenderFromSimpleJavaPojo should equal (pojoCaller)
|
||||
} catch {
|
||||
case e => fail("no sender available")
|
||||
}
|
||||
}
|
||||
|
||||
it("context.senderFuture should return the senderFuture Active Object reference") {
|
||||
val pojo = ActiveObject.newInstance(classOf[SimpleJavaPojo])
|
||||
val pojoCaller = ActiveObject.newInstance(classOf[SimpleJavaPojoCaller])
|
||||
pojoCaller.setPojo(pojo)
|
||||
try {
|
||||
pojoCaller.getSenderFutureFromSimpleJavaPojo.getClass.getName should equal (classOf[DefaultCompletableFuture[_]].getName)
|
||||
} catch {
|
||||
case e => fail("no sender future available", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -44,7 +44,7 @@ class StatefulTransactor(expectedInvocationCount: Int) extends Transactor {
|
|||
self.reply(notifier)
|
||||
case GetMapState(key) =>
|
||||
self.reply(mapState.get(key).get)
|
||||
// notifier.countDown
|
||||
notifier.countDown
|
||||
case GetVectorSize =>
|
||||
self.reply(vectorState.length.asInstanceOf[AnyRef])
|
||||
notifier.countDown
|
||||
|
|
@ -80,7 +80,7 @@ class StatefulTransactor(expectedInvocationCount: Int) extends Transactor {
|
|||
case SetMapStateOneWay(key, msg) =>
|
||||
println("------- SetMapStateOneWay")
|
||||
mapState.put(key, msg)
|
||||
// notifier.countDown
|
||||
notifier.countDown
|
||||
case SetVectorStateOneWay(msg) =>
|
||||
vectorState.add(msg)
|
||||
notifier.countDown
|
||||
|
|
@ -97,7 +97,7 @@ class StatefulTransactor(expectedInvocationCount: Int) extends Transactor {
|
|||
mapState.put(key, msg)
|
||||
vectorState.add(msg)
|
||||
refState.swap(msg)
|
||||
// notifier.countDown
|
||||
notifier.countDown
|
||||
failer ! "Failure"
|
||||
}
|
||||
}
|
||||
|
|
@ -133,7 +133,7 @@ class TransactorSpec extends JUnitSuite {
|
|||
stateful !! Success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state") // transactionrequired
|
||||
assert("new state" === (stateful !! GetMapState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess")).get)
|
||||
}
|
||||
*/
|
||||
|
||||
@Test
|
||||
def shouldOneWayMapShouldRollbackStateForStatefulServerInCaseOfFailure = {
|
||||
val stateful = actorOf(new StatefulTransactor(4))
|
||||
|
|
@ -145,11 +145,11 @@ class TransactorSpec extends JUnitSuite {
|
|||
stateful ! FailureOneWay("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer) // call failing transactionrequired method
|
||||
println("------- sending FailureOneWay")
|
||||
Thread.sleep(100)
|
||||
// val notifier = (stateful !! GetNotifier).as[CountDownLatch]
|
||||
// assert(notifier.get.await(5, TimeUnit.SECONDS))
|
||||
val notifier = (stateful !! GetNotifier).as[CountDownLatch]
|
||||
assert(notifier.get.await(5, TimeUnit.SECONDS))
|
||||
assert("init" === (stateful !! GetMapState("testShouldRollbackStateForStatefulServerInCaseOfFailure")).get) // check that state is == init state
|
||||
}
|
||||
/*
|
||||
|
||||
@Test
|
||||
def shouldMapShouldRollbackStateForStatefulServerInCaseOfFailure = {
|
||||
val stateful = actorOf[StatefulTransactor]
|
||||
|
|
|
|||
|
|
@ -5,16 +5,21 @@
|
|||
# This file has all the default settings, so all these could be removed with no visible effect.
|
||||
# Modify as needed.
|
||||
|
||||
<log>
|
||||
log {
|
||||
filename = "./logs/akka.log"
|
||||
roll = "daily" # Options: never, hourly, daily, sunday/monday/...
|
||||
level = "trace" # Options: fatal, critical, error, warning, info, debug, trace
|
||||
level = "debug" # Options: fatal, critical, error, warning, info, debug, trace
|
||||
console = on
|
||||
# syslog_host = ""
|
||||
# syslog_server_name = ""
|
||||
</log>
|
||||
|
||||
<akka>
|
||||
akka {
|
||||
node = "se.scalablesolutions.akka"
|
||||
level = "info"
|
||||
}
|
||||
}
|
||||
|
||||
akka {
|
||||
version = "0.10"
|
||||
|
||||
# FQN (Fully Qualified Name) to the class doing initial active object/actor
|
||||
|
|
@ -24,26 +29,26 @@
|
|||
"sample.rest.scala.Boot",
|
||||
"sample.security.Boot"]
|
||||
|
||||
<actor>
|
||||
actor {
|
||||
timeout = 5000 # default timeout for future based invocations
|
||||
serialize-messages = off # does a deep clone of (non-primitive) messages to ensure immutability
|
||||
throughput = 5 # default throughput for ExecutorBasedEventDrivenDispatcher
|
||||
</actor>
|
||||
}
|
||||
|
||||
<stm>
|
||||
stm {
|
||||
fair = on # should global transactions be fair or non-fair (non fair yield better performance)
|
||||
jta-aware = off # 'on' means that if there JTA Transaction Manager available then the STM will
|
||||
# begin (or join), commit or rollback the JTA transaction. Default is 'off'.
|
||||
</stm>
|
||||
}
|
||||
|
||||
<jta>
|
||||
jta {
|
||||
provider = "from-jndi" # Options: "from-jndi" (means that Akka will try to detect a TransactionManager in the JNDI)
|
||||
# "atomikos" (means that Akka will use the Atomikos based JTA impl in 'akka-jta',
|
||||
# e.g. you need the akka-jta JARs on classpath).
|
||||
timeout = 60000
|
||||
</jta>
|
||||
}
|
||||
|
||||
<rest>
|
||||
rest {
|
||||
service = on
|
||||
hostname = "localhost"
|
||||
port = 9998
|
||||
|
|
@ -52,53 +57,53 @@
|
|||
authenticator = "sample.security.BasicAuthenticationService" # The authentication service to use. Need to be overridden (uses sample now)
|
||||
|
||||
#IF you are using a KerberosAuthenticationActor
|
||||
# <kerberos>
|
||||
# kerberos {
|
||||
# servicePrincipal = "HTTP/localhost@EXAMPLE.COM"
|
||||
# keyTabLocation = "URL to keytab"
|
||||
# kerberosDebug = "true"
|
||||
# realm = "EXAMPLE.COM"
|
||||
# </kerberos>
|
||||
</rest>
|
||||
# }
|
||||
}
|
||||
|
||||
<remote>
|
||||
remote {
|
||||
compression-scheme = "zlib" # Options: "zlib" (lzf to come), leave out for no compression
|
||||
zlib-compression-level = 6 # Options: 0-9 (1 being fastest and 9 being the most compressed), default is 6
|
||||
|
||||
<cluster>
|
||||
cluster {
|
||||
service = on
|
||||
name = "default" # The name of the cluster
|
||||
serializer = "se.scalablesolutions.akka.serialization.Serializer$Java$" # FQN of the serializer class
|
||||
</cluster>
|
||||
}
|
||||
|
||||
<server>
|
||||
server {
|
||||
service = on
|
||||
hostname = "localhost"
|
||||
port = 9999
|
||||
connection-timeout = 1000 # in millis (1 sec default)
|
||||
</server>
|
||||
}
|
||||
|
||||
<client>
|
||||
client {
|
||||
reconnect-delay = 5000 # in millis (5 sec default)
|
||||
read-timeout = 10000 # in millis (10 sec default)
|
||||
</client>
|
||||
</remote>
|
||||
}
|
||||
}
|
||||
|
||||
<storage>
|
||||
<cassandra>
|
||||
storage {
|
||||
cassandra {
|
||||
hostname = "127.0.0.1" # IP address or hostname of one of the Cassandra cluster's seeds
|
||||
port = 9160
|
||||
consistency-level = "QUORUM" # Options: ZERO, ONE, QUORUM, DCQUORUM, DCQUORUMSYNC, ALL, ANY
|
||||
</cassandra>
|
||||
}
|
||||
|
||||
<mongodb>
|
||||
mongodb {
|
||||
hostname = "127.0.0.1" # IP address or hostname of the MongoDB DB instance
|
||||
port = 27017
|
||||
dbname = "mydb"
|
||||
</mongodb>
|
||||
}
|
||||
|
||||
<redis>
|
||||
redis {
|
||||
hostname = "127.0.0.1" # IP address or hostname of the Redis instance
|
||||
port = 6379
|
||||
</redis>
|
||||
</storage>
|
||||
</akka>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue