### Question:
HadoopCredentialProvider { public static void setPath(Configuration conf, String path) { conf.set(CREDENTIAL_PROVIDER_PATH, path); }  static void setPath(Configuration conf, String path); static char[] getValue(Configuration conf, String alias); static List<String> getKeys(Configuration conf); static void createEntry(Configuration conf, String name, char[] credential);  }### Answer:
@Test public void testExtractFromProvider() { String absPath = getKeyStoreUrl(populatedKeyStore); Configuration conf = new Configuration(); HadoopCredentialProvider.setPath(conf, absPath); Map<String,String> expectations = new HashMap<>(); expectations.put("key1", "value1"); expectations.put("key2", "value2"); checkCredentialProviders(conf, expectations); }
@Test public void testEmptyKeyStoreParses() { String absPath = getKeyStoreUrl(emptyKeyStore); Configuration conf = new Configuration(); HadoopCredentialProvider.setPath(conf, absPath); checkCredentialProviders(conf, new HashMap<>()); }
@Test public void testEmptyAndPopulatedKeyStores() { String populatedAbsPath = getKeyStoreUrl(populatedKeyStore), emptyAbsPath = getKeyStoreUrl(emptyKeyStore); Configuration conf = new Configuration(); HadoopCredentialProvider.setPath(conf, populatedAbsPath + "," + emptyAbsPath); Map<String,String> expectations = new HashMap<>(); expectations.put("key1", "value1"); expectations.put("key2", "value2"); checkCredentialProviders(conf, expectations); }
@Test public void testConfigurationCreation() { final String path = "jceks: final Configuration actualConf = hadoopConf; HadoopCredentialProvider.setPath(actualConf, path); assertNotNull(actualConf); assertEquals(path, actualConf.get("hadoop.security.credential.provider.path")); }
@Test public void extractFromHdfs() throws Exception { File target = new File(System.getProperty("user.dir"), "target"); String prevValue = System.setProperty("test.build.data", new File(target, this.getClass().getName() + "_minidfs").toString()); MiniDFSCluster dfsCluster = new MiniDFSCluster.Builder(new Configuration()).build(); try { if (null != prevValue) { System.setProperty("test.build.data", prevValue); } else { System.clearProperty("test.build.data"); } Configuration dfsConfiguration = dfsCluster.getConfiguration(0); Path destPath = new Path("/accumulo.jceks"); FileSystem dfs = dfsCluster.getFileSystem(); dfs.copyFromLocalFile(new Path(populatedKeyStore.toURI()), destPath); Configuration cpConf = dfsConfiguration; HadoopCredentialProvider.setPath(cpConf, "jceks: Map<String,String> expectations = new HashMap<>(); expectations.put("key1", "value1"); expectations.put("key2", "value2"); checkCredentialProviders(cpConf, expectations); } finally { dfsCluster.shutdown(); } }