Created
March 29, 2012 16:32
-
-
Save henrikengstrom/2239521 to your computer and use it in GitHub Desktop.
Using specific config settings with TestKit - example 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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