Skip to content
This repository has been archived by the owner on Aug 17, 2022. It is now read-only.

Commit

Permalink
improve test coverage for the builder
Browse files Browse the repository at this point in the history
  • Loading branch information
zapodot committed Aug 14, 2014
1 parent ca06bfa commit 9262b72
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ public ActorSystemRuleBuilder setConfigFromString(final String configString) {
return setConfig(ConfigFactory.parseString(configString));
}

Config currentConfig() {
if(this.config == null) {
return null;
} else {
return ConfigFactory.empty().withFallback(config);
}
}

public ActorSystemRule build() {

return config == null ? new ActorSystemRule(name) : new ActorSystemRule(name, config);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package org.zapodot.akka.junit;

import akka.event.slf4j.Slf4jLogger;
import akka.testkit.TestEventListener;
import com.typesafe.config.Config;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class ActorSystemRuleBuilderTest {

@Test
public void testEnableEventListener() throws Exception {
final ActorSystemRuleBuilder actorSystemRuleBuilder = ActorSystemRule.builder().enableEventTestListener();
final Config config = actorSystemRuleBuilder.currentConfig();

assertEquals(TestEventListener.class.getName(), config.getStringList("akka.loggers").get(0));

}

@Test
public void testEnableEventLogging() throws Exception {
final ActorSystemRuleBuilder actorSystemRuleBuilder = ActorSystemRule.builder().enableEventLogging();
final Config config = actorSystemRuleBuilder.currentConfig();
assertEquals(Slf4jLogger.class.getName(), config.getStringList("akka.loggers").get(0));
assertEquals("DEBUG", config.getString("akka.loglevel"));
}

@Test
public void testEnableReceiveDebugLogging() throws Exception {
assertEquals("on", ActorSystemRule.builder().enableReceiveDebugLogging().currentConfig().getString(
"akka.actor.debug.receive"));
}

@Test
public void testEnableLifecycleDebugLogging() throws Exception {
assertEquals("on", ActorSystemRule.builder().enableLifecycleDebugLogging().currentConfig().getString("akka.actor.debug.lifecycle"));

}
}

0 comments on commit 9262b72

Please sign in to comment.