diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java index f6c2d468868..bceae3ce5bc 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java @@ -74,8 +74,8 @@ public class TestConfiguration extends TestCase { final static String CONFIG = new File("./test-config-TestConfiguration.xml").getAbsolutePath(); final static String CONFIG2 = new File("./test-config2-TestConfiguration.xml").getAbsolutePath(); final static String CONFIG_FOR_ENUM = new File("./test-config-enum-TestConfiguration.xml").getAbsolutePath(); - final static String CONFIG_FOR_URI = "file://" - + new File("./test-config-uri-TestConfiguration.xml").getAbsolutePath(); + final static String CONFIG_FOR_URI = new File( + "./test-config-uri-TestConfiguration.xml").toURI().toString(); private static final String CONFIG_MULTI_BYTE = new File( "./test-config-multi-byte-TestConfiguration.xml").getAbsolutePath(); @@ -720,7 +720,8 @@ public class TestConfiguration extends TestCase { out.close(); out=new BufferedWriter(new FileWriter(CONFIG)); writeHeader(); - declareSystemEntity("configuration", "d", CONFIG2); + declareSystemEntity("configuration", "d", + new Path(CONFIG2).toUri().toString()); writeConfiguration(); appendProperty("a", "b"); appendProperty("c", "&d;"); @@ -1448,7 +1449,7 @@ public class TestConfiguration extends TestCase { assertEquals("test.key2", jp1.getKey()); assertEquals("value2", jp1.getValue()); assertEquals(true, jp1.isFinal); - assertEquals(fileResource.toUri().getPath(), jp1.getResource()); + assertEquals(fileResource.toString(), jp1.getResource()); // test xml format outWriter = new StringWriter(); @@ -1459,7 +1460,7 @@ public class TestConfiguration extends TestCase { assertEquals(1, actualConf1.size()); assertEquals("value2", actualConf1.get("test.key2")); assertTrue(actualConf1.getFinalParameters().contains("test.key2")); - assertEquals(fileResource.toUri().getPath(), + assertEquals(fileResource.toString(), actualConf1.getPropertySources("test.key2")[0]); // case 2: dump an non existing property @@ -1914,7 +1915,8 @@ public class TestConfiguration extends TestCase { final File tmpDir = GenericTestUtils.getRandomizedTestDir(); tmpDir.mkdirs(); final String ourUrl = new URI(LocalJavaKeyStoreProvider.SCHEME_NAME, - "file", new File(tmpDir, "test.jks").toString(), null).toString(); + "file", new File(tmpDir, "test.jks").toURI().getPath(), + null).toString(); conf = new Configuration(false); conf.set(CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH, ourUrl); @@ -1941,7 +1943,8 @@ public class TestConfiguration extends TestCase { final File tmpDir = GenericTestUtils.getRandomizedTestDir(); tmpDir.mkdirs(); final String ourUrl = new URI(LocalJavaKeyStoreProvider.SCHEME_NAME, - "file", new File(tmpDir, "test.jks").toString(), null).toString(); + "file", new File(tmpDir, "test.jks").toURI().getPath(), + null).toString(); conf = new Configuration(false); conf.set(CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH, ourUrl);