HADOOP-13810. Add a test to verify that Configuration handles &-encoded characters. Contributed by Steve Loughran
This closes #158 Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/04014c4c Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/04014c4c Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/04014c4c Branch: refs/heads/YARN-3926 Commit: 04014c4c739bb4e3bc3fdf9299abc0f47521e8fd Parents: 99c2bbd Author: Mingliang Liu <lium...@apache.org> Authored: Mon Nov 14 19:37:50 2016 -0800 Committer: Mingliang Liu <lium...@apache.org> Committed: Mon Nov 14 19:38:10 2016 -0800 ---------------------------------------------------------------------- .../org/apache/hadoop/conf/TestConfiguration.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/04014c4c/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java ---------------------------------------------------------------------- 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 17112f5..8a422f7 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 @@ -70,6 +70,9 @@ public class TestConfiguration extends TestCase { IBM_JAVA?"<?xml version=\"1.0\" encoding=\"UTF-8\"?><configuration>": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><configuration>"; + /** Four apostrophes. */ + public static final String ESCAPED = "''''"; + @Override protected void setUp() throws Exception { super.setUp(); @@ -402,7 +405,18 @@ public class TestConfiguration extends TestCase { //two spaces one after "this", one before "contains" assertEquals("this contains a comment", conf.get("my.comment")); } - + + public void testEscapedCharactersInValue() throws IOException { + out=new BufferedWriter(new FileWriter(CONFIG)); + startConfig(); + appendProperty("my.comment", ESCAPED); + endConfig(); + Path fileResource = new Path(CONFIG); + conf.addResource(fileResource); + //two spaces one after "this", one before "contains" + assertEquals("''''", conf.get("my.comment")); + } + public void testTrim() throws IOException { out=new BufferedWriter(new FileWriter(CONFIG)); startConfig(); --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-commits-h...@hadoop.apache.org