From 04014c4c739bb4e3bc3fdf9299abc0f47521e8fd Mon Sep 17 00:00:00 2001 From: Mingliang Liu Date: Mon, 14 Nov 2016 19:37:50 -0800 Subject: [PATCH] HADOOP-13810. Add a test to verify that Configuration handles &-encoded characters. Contributed by Steve Loughran This closes #158 --- .../apache/hadoop/conf/TestConfiguration.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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 17112f5c9f..8a422f7536 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?"": ""; + /** Four apostrophes. */ + public static final String ESCAPED = "''''"; + @Override protected void setUp() throws Exception { super.setUp(); @@ -402,7 +405,18 @@ public void testCommentsInValue() throws IOException { //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();