TestRoute and TypeSafe config for unit testing without remoting

I have created a test class that extends (Java) JUnitRouteTest
In the test class I have two unit tests that rely on a TestRoute. The TestRoute is created like this in the body of my test class:

TestRoute appRoute = testRoute(new MyHTTPWithActors(system).createRoute());

Where MyHTTPWithActors has a constructor that needs an ActorSystem passed to it.
My test class builds that ActorSystem with a @BeforeClass annotation (once per test class run, right?) with:

system = ActorSystem.create("test-system", ConfigFactory.load("application-test"));

In trying my tests I noted a few things that I want to solve:

  1. That application-test config does not have remoting specified. It also seems to be ignored. My tests keep firing up an actor system that binds ports, ie. uses remoting. I can put any resourceBasename parameter I want there, it won’t actually use that value in ConfigFactory.load(). If I leave out that ConfigFactory param and use the name only version of ActorSystem.create() my tests fail with a “Address already in use” error.

  2. If I instantiate the ActorSystem as above, I can see that it is being created once for each test. I can’t see how to avoid this behavior?.

How can I make ActorSystem not be created and torn down for each test? How can I make the test ActorSystem load my config and not use remoting? Why is it working with the ConfigFactory param version?

Hi @bentito,

JUnitRouteTest already provides an ActorSystem. If you want to override its configuration you can override the additionalConfig method to set extra options.

To debug config issues in general see the debugging section of the lightbend/config documentation.

Johannes