@Test public void newInstance_auto() throws Exception { File cmd = putExec("testing/testcmd"); File site = putConf("auto/core-site.xml"); try (PrintWriter writer = new PrintWriter(cmd)) { writer.printf("#/bin/sh\n"); writer.printf("if [ $# -eq 0 ]\n"); writer.printf("then\n"); writer.printf(" exit 0\n"); writer.printf("elif [ $# -ne 2 ]\n"); writer.printf("then\n"); writer.printf(" exit 1\n"); writer.printf("else\n"); writer.printf(" if [ \"$1\" != '%s' ]\n", ConfigurationDetecter.class.getName()); writer.printf(" then\n"); writer.printf(" exit 1\n"); writer.printf(" fi\n"); writer.printf(" echo '%s' > \"$2\"\n", site.getParentFile().getAbsolutePath()); writer.printf(" exit 0\n"); writer.printf("fi\n"); } try { Process proc = new ProcessBuilder(cmd.getAbsolutePath()).start(); try { int exitCode = proc.waitFor(); Assume.assumeThat(exitCode, is(0)); } finally { proc.destroy(); } } catch (Exception e) { System.out.println("Failed to execute bash script"); e.printStackTrace(System.out); Assume.assumeNoException(e); } Map<String, String> envp = new HashMap<>(); envp.put("HADOOP_CMD", cmd.getAbsolutePath()); Configuration conf = new ConfigurationProvider(envp).newInstance(); assertThat(isLoaded(conf), is(true)); }
public Configuration newInstance() { Configuration conf = new Configuration(true); conf.setClassLoader(loader); configure(conf); return conf; }
ConfigurationProvider { public Configuration newInstance() { Configuration conf = new Configuration(true); conf.setClassLoader(loader); configure(conf); return conf; } }
ConfigurationProvider { public Configuration newInstance() { Configuration conf = new Configuration(true); conf.setClassLoader(loader); configure(conf); return conf; } ConfigurationProvider();   ConfigurationProvider(Map<String, String> envp);  ConfigurationProvider(URL defaultConfigPath); }
ConfigurationProvider { public Configuration newInstance() { Configuration conf = new Configuration(true); conf.setClassLoader(loader); configure(conf); return conf; } 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(); }
ConfigurationProvider { public Configuration newInstance() { Configuration conf = new Configuration(true); conf.setClassLoader(loader); configure(conf); return conf; } 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();  }