RoutingDockerRunner extends AbstractRoutingRunner<DockerRunner> implements DockerRunner { @Override public String start(RunState runState, RunSpec runSpec) throws IOException { return runner(runState).start(runState, runSpec); } RoutingDockerRunner(DockerRunnerFactory dockerRunnerFactory, Function<RunState, String> runnerId); @Override String start(RunState runState, RunSpec runSpec); @Override void poll(RunState runState); @Override void cleanup();  }
@Test public void testUsesCreatesRunnerOnStart() throws Exception { dockerRunner.start(runState, runSpec); assertThatCreateCountersContains("default"); verify(createdRunners.get("default")).start(runState, runSpec); }
@Test public void testCreatesOnlyOneRunnerPerDockerId() throws Exception { dockerRunner.start(runState, runSpec); dockerRunner.start(runState, runSpec); assertThatCreateCountersContains("default"); }
@Test public void testSwitchesDockerRunner() throws Exception { when(runnerId.apply(runState)).thenReturn("id-1", "id-2"); dockerRunner.start(runState, runSpec); dockerRunner.start(runState, runSpec); assertThatCreateCountersContains("id-1", "id-2"); }
@Test public void testCreatedRunnersAreClosed() throws Exception { when(runnerId.apply(runState)).thenReturn("id-1", "id-2"); dockerRunner.start(runState, runSpec); dockerRunner.start(runState, runSpec); dockerRunner.close(); assertThatCreateCountersContains("id-1", "id-2"); for (DockerRunner runner : createdRunners.values()) { verify(runner).close(); } }