diff options
author | Bjørn Christian Seime <bjorncs@oath.com> | 2018-01-29 14:54:04 +0100 |
---|---|---|
committer | Bjørn Christian Seime <bjorncs@oath.com> | 2018-01-29 14:58:37 +0100 |
commit | 7af5ec2c5ecbb9d742fc162d19850f3583bbafc1 (patch) | |
tree | ad664b83f8b698c3fa617ed55dcd221c0ff53840 /container-core/src/test | |
parent | c90710ca371546d34023470f08929b4cd73b5ff9 (diff) |
Don't run snapshot thread in StateHandlerTest
Make ThreadFactory configurable in StateMonitor to enable
StateHandlerTest to control the snapshot thread (in this case stop it
from running).
Diffstat (limited to 'container-core/src/test')
-rw-r--r-- | container-core/src/test/java/com/yahoo/container/jdisc/state/StateHandlerTest.java | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/container-core/src/test/java/com/yahoo/container/jdisc/state/StateHandlerTest.java b/container-core/src/test/java/com/yahoo/container/jdisc/state/StateHandlerTest.java index 5d8f885f8d0..a4c993f8c39 100644 --- a/container-core/src/test/java/com/yahoo/container/jdisc/state/StateHandlerTest.java +++ b/container-core/src/test/java/com/yahoo/container/jdisc/state/StateHandlerTest.java @@ -29,6 +29,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.TreeMap; +import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; @@ -36,6 +37,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; /** * @author Simon Thoresen Hult @@ -51,30 +53,20 @@ public class StateHandlerTest { @Before public void startTestDriver() { - driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(new AbstractModule() { - + Timer timer = this.currentTimeMillis::get; + this.driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(new AbstractModule() { @Override protected void configure() { - bind(Timer.class).toInstance(new Timer() { - - @Override - public long currentTimeMillis() { - return currentTimeMillis.get(); - } - }); + bind(Timer.class).toInstance(timer); } }); ContainerBuilder builder = driver.newContainerBuilder(); - builder.guiceModules().install(new AbstractModule() { - - @Override - protected void configure() { - bind(HealthMonitorConfig.class) - .toInstance(new HealthMonitorConfig(new HealthMonitorConfig.Builder().snapshot_interval( - TimeUnit.MILLISECONDS.toSeconds(SNAPSHOT_INTERVAL)))); - } - }); - monitor = builder.guiceModules().getInstance(StateMonitor.class); + HealthMonitorConfig healthMonitorConfig = + new HealthMonitorConfig( + new HealthMonitorConfig.Builder() + .snapshot_interval(TimeUnit.MILLISECONDS.toSeconds(SNAPSHOT_INTERVAL))); + ThreadFactory threadFactory = ignored -> mock(Thread.class); + this.monitor = new StateMonitor(healthMonitorConfig, timer, threadFactory); builder.guiceModules().install(new AbstractModule() { @Override |