### Question:
ChromeLauncher implements AutoCloseable { public Path getChromeBinaryPath() { String envChrome = environment.getEnv(ENV_CHROME_PATH); if (envChrome != null) { boolean isExecutable = processLauncher.isExecutable(envChrome); if (isExecutable) { return Paths.get(envChrome).toAbsolutePath(); } throw new RuntimeException("CHROME_PATH environment value is not an executable file."); } for (String binary : CHROME_BINARIES) { boolean isExecutable = processLauncher.isExecutable(binary); if (isExecutable) { return Paths.get(binary).toAbsolutePath(); } } throw new RuntimeException( "Could not find chrome binary! Try setting CHROME_PATH env to chrome binary path."); } ChromeLauncher();  ChromeLauncher(ChromeLauncherConfiguration configuration);  ChromeLauncher(
      ProcessLauncher processLauncher,
      Environment environment,
      ShutdownHookRegistry shutdownHookRegistry,
      ChromeLauncherConfiguration configuration); ChromeService launch(Path chromeBinaryPath, ChromeArguments chromeArguments); ChromeService launch(ChromeArguments chromeArguments); ChromeService launch(boolean headless); ChromeService launch(); Path getChromeBinaryPath(); @Override void close(); int exitValue(); boolean isAlive(); static final String ENV_CHROME_PATH; }### Answer:
@Test(expected = RuntimeException.class) public void testGetChromeBinaryPathThrowsExceptionWhenNoBinaryFoundOnChromePath() { expect(environment.getEnv("CHROME_PATH")).andReturn("test"); expect(processLauncher.isExecutable("test")).andReturn(false); replayAll(); launcher.getChromeBinaryPath(); }
@Test(expected = RuntimeException.class) public void testGetChromeBinaryPathThrowsExceptionWhenNoBinaryFound() { expect(environment.getEnv("CHROME_PATH")).andReturn(null); expect(processLauncher.isExecutable("/usr/bin/chromium")).andReturn(false); expect(processLauncher.isExecutable("/usr/bin/chromium-browser")).andReturn(false); expect(processLauncher.isExecutable("/usr/bin/google-chrome-stable")).andReturn(false); expect(processLauncher.isExecutable("/usr/bin/google-chrome")).andReturn(false); expect(processLauncher.isExecutable("/Applications/Chromium.app/Contents/MacOS/Chromium")) .andReturn(false); expect( processLauncher.isExecutable( "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome")) .andReturn(false); expect( processLauncher.isExecutable( "/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary")) .andReturn(false); expect( processLauncher.isExecutable( "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe")) .andReturn(false); replayAll(); launcher.getChromeBinaryPath(); }
@Test public void testGetChromeBinaryPathReturnsSomePath() { expect(environment.getEnv("CHROME_PATH")).andReturn(null); expect(processLauncher.isExecutable("/usr/bin/chromium")).andReturn(false); expect(processLauncher.isExecutable("/usr/bin/chromium-browser")).andReturn(false); expect(processLauncher.isExecutable("/usr/bin/google-chrome-stable")).andReturn(false); expect(processLauncher.isExecutable("/usr/bin/google-chrome")).andReturn(true); replayAll(); Path chromeBinaryPath = launcher.getChromeBinaryPath(); assertNotNull(chromeBinaryPath); assertNotNull("/usr/bin/google-chrome", chromeBinaryPath.toString()); verifyAll(); }
@Test public void testGetChromeBinaryPathReturnsPathFromEnv() { expect(environment.getEnv("CHROME_PATH")).andReturn("test/env/path"); expect(processLauncher.isExecutable("test/env/path")).andReturn(true); replayAll(); Path chromeBinaryPath = launcher.getChromeBinaryPath(); assertNotNull(chromeBinaryPath); assertNotNull("test/env/path", chromeBinaryPath.toString()); verifyAll(); }