Skip to content

Commit 04014c4

Browse files
committed
HADOOP-13810. Add a test to verify that Configuration handles &-encoded characters. Contributed by Steve Loughran
This closes #158
1 parent 99c2bbd commit 04014c4

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ public class TestConfiguration extends TestCase {
7070
IBM_JAVA?"<?xml version=\"1.0\" encoding=\"UTF-8\"?><configuration>":
7171
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><configuration>";
7272

73+
/** Four apostrophes. */
74+
public static final String ESCAPED = "&apos;&#39;&#0039;&#x27;";
75+
7376
@Override
7477
protected void setUp() throws Exception {
7578
super.setUp();
@@ -402,7 +405,18 @@ public void testCommentsInValue() throws IOException {
402405
//two spaces one after "this", one before "contains"
403406
assertEquals("this contains a comment", conf.get("my.comment"));
404407
}
405-
408+
409+
public void testEscapedCharactersInValue() throws IOException {
410+
out=new BufferedWriter(new FileWriter(CONFIG));
411+
startConfig();
412+
appendProperty("my.comment", ESCAPED);
413+
endConfig();
414+
Path fileResource = new Path(CONFIG);
415+
conf.addResource(fileResource);
416+
//two spaces one after "this", one before "contains"
417+
assertEquals("''''", conf.get("my.comment"));
418+
}
419+
406420
public void testTrim() throws IOException {
407421
out=new BufferedWriter(new FileWriter(CONFIG));
408422
startConfig();

0 commit comments

Comments
 (0)