### Question:
ConfigurationProvider { public static File findHadoopCommand() { return findHadoopCommand(System.getenv()); } ConfigurationProvider();   ConfigurationProvider(Map<String, String> envp);  ConfigurationProvider(URL defaultConfigPath); static URL getConfigurationPath(Map<String, String> environmentVariables); static File findHadoopCommand(); static File findHadoopCommand(Map<String, String> environmentVariables); Configuration newInstance();  }### Answer:
@Test public void findHadoopCommand_explicit() { putExec("bin/hadoop"); Map<String, String> envp = new HashMap<>(); envp.put("HADOOP_HOME", folder.getRoot().getAbsolutePath()); File file = ConfigurationProvider.findHadoopCommand(envp); assertThat(file, is(notNullValue())); assertThat(file.toString(), file.canExecute(), is(true)); }
@Test public void findHadoopCommand_path() { putExec("bin/hadoop"); Map<String, String> envp = new HashMap<>(); envp.put("PATH", new File(folder.getRoot(), "bin").getAbsolutePath()); File file = ConfigurationProvider.findHadoopCommand(envp); assertThat(file, is(notNullValue())); assertThat(file.toString(), file.canExecute(), is(true)); }
@Test public void findHadoopCommand_both() { putExec("home/bin/hadoop"); putExec("path/hadoop"); Map<String, String> envp = new HashMap<>(); envp.put("HADOOP_HOME", new File(folder.getRoot(), "home").getAbsolutePath()); envp.put("PATH", new File(folder.getRoot(), "path").getAbsolutePath()); File file = ConfigurationProvider.findHadoopCommand(envp); assertThat(file, is(notNullValue())); assertThat(file.toString(), file.canExecute(), is(true)); assertThat(file.toString(), file.getParentFile().getName(), is("bin")); }
@Test public void findHadoopCommand_manypath() { putExec("path1/java"); putExec("path2/hadoop"); putExec("path3/ant"); StringBuilder buf = new StringBuilder(); buf.append(File.pathSeparator); buf.append(new File(folder.getRoot(), "path1").getAbsolutePath()); buf.append(File.pathSeparator); buf.append(new File(folder.getRoot(), "path2").getAbsolutePath()); buf.append(File.pathSeparator); buf.append(new File(folder.getRoot(), "path3").getAbsolutePath()); buf.append(File.pathSeparator); Map<String, String> envp = new HashMap<>(); envp.put("PATH", buf.toString()); File file = ConfigurationProvider.findHadoopCommand(envp); assertThat(file, is(notNullValue())); assertThat(file.toString(), file.canExecute(), is(true)); assertThat(file.toString(), file.getParentFile().getName(), is("path2")); }