### Question:
AgentRuntimeLoader { @Nullable static URL getConfigFile() { String customLocation = System.getProperty(CONFIG_FILE_SYS_PROPERTY); if (customLocation != null && !customLocation.isEmpty()) { try { File file = new File(customLocation); if (file.exists()) { return file.toURI().toURL(); } else { return AgentRuntimeLoader.class.getResource(customLocation); } } catch (MalformedURLException e) { log.error("X-Ray agent config file's custom location was malformed. " + "Falling back to default configuration."); return null; } } return AgentRuntimeLoader.class.getResource(CONFIG_FILE_DEFAULT_LOCATION); }  static void init(); static void init(@Nullable String serviceName);  }### Answer:
@Test public void testGetDefaultConfigFile() { URL configFile = AgentRuntimeLoader.getConfigFile(); Assert.assertEquals(CONFIG_FILE_DEFAULT_NAME, FilenameUtils.getName(configFile.getPath())); }
@Test public void testGetCustomConfigFileFromFileSystem() { String fileName = "emptyAgentConfig.json"; System.setProperty(CONFIG_FILE_SYS_PROPERTY, AgentRuntimeLoaderTest.class.getResource("/com/amazonaws/xray/agent/" + fileName).getPath()); URL configFile = AgentRuntimeLoader.getConfigFile(); Assert.assertEquals(fileName, FilenameUtils.getName(configFile.getPath())); }
@Test public void testGetCustomConfigFileFromClassPath() { String fileName = "emptyAgentConfig.json"; System.setProperty(CONFIG_FILE_SYS_PROPERTY, "/com/amazonaws/xray/agent/" + fileName); URL configFile = AgentRuntimeLoader.getConfigFile(); Assert.assertFalse(new File("/com/amazonaws/xray/agent/" + fileName).exists()); Assert.assertEquals(fileName, FilenameUtils.getName(configFile.getPath())); }
@Test public void testNonExistentCustomConfigFile() { System.setProperty(CONFIG_FILE_SYS_PROPERTY, "/some/totally/fake/file"); URL configFile = AgentRuntimeLoader.getConfigFile(); Assert.assertNull(configFile); }