Skip to content

Instantly share code, notes, and snippets.

@cessationoftime
Created April 28, 2012 16:04
Show Gist options
  • Save cessationoftime/2519979 to your computer and use it in GitHub Desktop.
Save cessationoftime/2519979 to your computer and use it in GitHub Desktop.
Akka MultiJVM testing example with barriers
package sample
import org.scalatest.WordSpec
import org.scalatest.matchers.MustMatchers
import org.scalatest.BeforeAndAfterAll
import akka.remote.AbstractRemoteActorMultiJvmSpec
import akka.remote.AkkaRemoteSpec
object XampleMultiJvmSpec extends AbstractRemoteActorMultiJvmSpec {
override def NrOfNodes = 2
def commonConfig = ConfigFactory.parseString("""
// Declare your configuration here.
""")
}
class XampleMultiJvmNode1 extends AkkaRemoteSpec(XampleMultiJvmSpec.nodeConfigs(0))
with WordSpec with MustMatchers {
import XampleMultiJvmSpec._
val nodes = NrOfNodes
"A cluster" must {
"have config options" in {
config.getString("akka.remote.netty.hostname") must be("localhost")
config.getString("akka.remote.netty.port") must be("1991")
}
"be able to start all nodes" in {
barrier("start")
println("All nodes are started!")
barrier("end")
}
}
}
class XampleMultiJvmNode2 extends AkkaRemoteSpec(XampleMultiJvmSpec.nodeConfigs(1))
with WordSpec with MustMatchers {
import XampleMultiJvmSpec._
val nodes = NrOfNodes
"A cluster" must {
"have config options" in {
config.getString("akka.remote.netty.hostname") must be("localhost")
config.getString("akka.remote.netty.port") must be("1992")
}
"be able to start all nodes" in {
barrier("start")
println("All nodes are started!")
barrier("end")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment