forked from eXist-db/exist
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[bugfix] Correct an issue with character escaping intoduced in '[opti…
…mise] Namespace and indentation performance fixes (commit c1a5e3e @alanpaxton (Alan Paxton)'
- Loading branch information
1 parent
9676eef
commit 7bcfa93
Showing
2 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
exist-core/src/test/java/org/exist/util/serializer/XMLWriterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright (C) 2014 Evolved Binary Ltd | ||
* | ||
* Changes made by Evolved Binary are proprietary and are not Open Source. | ||
*/ | ||
package org.exist.util.serializer; | ||
|
||
import org.apache.commons.io.output.StringBuilderWriter; | ||
import org.junit.Test; | ||
|
||
import javax.xml.transform.OutputKeys; | ||
import javax.xml.transform.TransformerException; | ||
import java.io.IOException; | ||
import java.util.Properties; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class XMLWriterTest { | ||
|
||
@Test | ||
public void characters() throws IOException, TransformerException { | ||
final String inputText = "Enter Priest, &c. in procession; the Corpse of OPHELIA, LAERTES and Mourners following; KING CLAUDIUS, QUEEN GERTRUDE, their trains, &c"; | ||
final String expectedText = inputText.replace("&", "&"); | ||
|
||
final Properties outputProperties = new Properties(); | ||
outputProperties.getProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); | ||
|
||
try (final StringBuilderWriter writer = new StringBuilderWriter()) { | ||
final XMLWriter xmlWriter = new XMLWriter(writer); | ||
xmlWriter.setOutputProperties(outputProperties); | ||
|
||
xmlWriter.characters(inputText); | ||
|
||
final String actualText = writer.toString(); | ||
assertEquals(expectedText, actualText); | ||
} | ||
} | ||
|
||
@Test | ||
public void writeChars() throws IOException { | ||
final String inputText = "Enter Priest, &c. in procession; the Corpse of OPHELIA, LAERTES and Mourners following; KING CLAUDIUS, QUEEN GERTRUDE, their trains, &c"; | ||
final String expectedText = inputText.replace("&", "&"); | ||
|
||
try (final StringBuilderWriter writer = new StringBuilderWriter()) { | ||
final XMLWriter xmlWriter = new XMLWriter(writer); | ||
|
||
xmlWriter.writeChars(inputText, false); | ||
|
||
final String actualText = writer.toString(); | ||
assertEquals(expectedText, actualText); | ||
} | ||
} | ||
} |