### Question:
AgentConfigLocator { public static File locateConfig() { List<String> explicitLocations = Arrays.asList(System.getProperty(SYSPROP_CONFIG), System.getenv(ENVVAR_CODEKVAST_CONFIG)); for (String location : explicitLocations) { if (location != null) { File file = tryLocation(location); if (file != null) { return file; } logger.warning( String.format( "Invalid value of -D%s or %s: %s, Codekvast will not start.", SYSPROP_CONFIG, ENVVAR_CODEKVAST_CONFIG, location)); return null; } } List<String> automaticLocations = Arrays.asList( "./codekvast.conf", "./conf/codekvast.conf", constructLocation(System.getProperty(SYSPROP_CATALINA_HOME), "conf"), constructLocation(System.getenv(ENVVAR_CATALINA_HOME), "conf"), constructLocation(System.getProperty(SYSPROP_CATALINA_BASE), "conf"), constructLocation(System.getenv(ENVVAR_CATALINA_BASE), "conf"), constructLocation(System.getenv(ENVVAR_HOME), ".config"), "/etc/codekvast/codekvast.conf", "/etc/codekvast.conf"); for (String location : automaticLocations) { if (location != null) { File file = tryLocation(location); if (file != null) { return file; } } } logger.warning("No configuration file found, Codekvast will not start."); return null; } private  AgentConfigLocator(); static File locateConfig();  }### Answer:
@Test public void should_handle_valid_file() { System.setProperty(AgentConfigLocator.SYSPROP_CONFIG, "src/test/resources/codekvast1.conf"); assertThat(AgentConfigLocator.locateConfig(), not(nullValue())); outputCapture.expect(containsString("Found src/test/resources/codekvast1.conf")); }
@Test public void should_handle_invalid_file() { String location = "src/test/resources/codekvast1.conf-FOOBAR"; System.setProperty(AgentConfigLocator.SYSPROP_CONFIG, location); assertThat(AgentConfigLocator.locateConfig(), nullValue()); outputCapture.expect(containsString("Invalid value of")); outputCapture.expect(containsString(location)); }
@Test public void should_handle_no_explicits_given() { assertThat(AgentConfigLocator.locateConfig(), nullValue()); outputCapture.expect(containsString("[WARNING] " + AgentConfigLocator.class.getName())); outputCapture.expect(containsString("No configuration file found")); }