Skip to content

Instantly share code, notes, and snippets.

@henrikengstrom
Created March 29, 2012 16:32
Show Gist options
  • Save henrikengstrom/2239521 to your computer and use it in GitHub Desktop.
Save henrikengstrom/2239521 to your computer and use it in GitHub Desktop.
Using specific config settings with TestKit - example 1
import akka.testkit.{TestActorRef, TestKit}
import com.typesafe.config.ConfigFactory
import org.scalatest.matchers.MustMatchers
import org.scalatest.WordSpec
import akka.actor.{Actor, ActorSystem}
@org.junit.runner.RunWith(classOf[org.scalatest.junit.JUnitRunner])
class Example1 extends TestKit(
ActorSystem("TestSystem", ConfigFactory.parseString("""{ test.value = "Hey, it works!" }""")))
with WordSpec
with MustMatchers {
"TestKit" must {
"allow for specific values in actor systems" in {
val theActor = TestActorRef[TestActor].underlyingActor
theActor.retrieveValue must equal("Hey, it works!")
}
}
}
class TestActor extends Actor {
def receive = {
case _ => println("Status: " + retrieveValue)
}
def retrieveValue: String = {
context.system.settings.config.getString("test.value")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment