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

Commit

Permalink
use an empty() config as standard instead of null
Browse files Browse the repository at this point in the history
  • Loading branch information
zapodot committed Aug 18, 2014
1 parent 9262b72 commit 4240951
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public ActorSystemRuleBuilder setConfigFromString(final String configString) {

Config currentConfig() {
if(this.config == null) {
return null;
return ConfigFactory.empty();
} else {
return ConfigFactory.empty().withFallback(config);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import akka.event.slf4j.Slf4jLogger;
import akka.testkit.TestEventListener;
import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
Expand All @@ -18,6 +19,26 @@ public void testEnableEventListener() throws Exception {

}

@Test
public void testEmptyConfig() throws Exception {

assertEquals(ConfigFactory.empty(), ActorSystemRule.builder().currentConfig());
}

@Test
public void testAddExistingConfig() throws Exception {
assertEquals(ConfigFactory.empty(), ActorSystemRule.builder().setConfig(ConfigFactory.empty()).currentConfig());
}

@Test
public void testAddExistingConfigTwice() throws Exception {
assertEquals(ConfigFactory.empty(),
ActorSystemRule.builder()
.setConfig(ConfigFactory.empty())
.setConfig(ConfigFactory.empty())
.currentConfig());
}

@Test
public void testEnableEventLogging() throws Exception {
final ActorSystemRuleBuilder actorSystemRuleBuilder = ActorSystemRule.builder().enableEventLogging();
Expand All @@ -32,9 +53,24 @@ public void testEnableReceiveDebugLogging() throws Exception {
"akka.actor.debug.receive"));
}


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

}

@Test
public void testEnableLifecycleAndReceiveDebugLogging() throws Exception {
final Config config = ActorSystemRule.builder()
.enableLifecycleDebugLogging()
.enableReceiveDebugLogging().currentConfig();
assertEquals("on", config.getString("akka.actor.debug.lifecycle"));
assertEquals("on", config.getString("akka.actor.debug.receive"));

}
}

0 comments on commit 4240951

Please sign in to comment.