From 0f6af6df200c47d3b1f936a09d564ef20309e275 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Thu, 6 Jun 2024 17:42:05 -0700 Subject: [PATCH] Minor style cleanup --- .../fasterxml/aalto/sax/TestSaxWriter.java | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/test/java/com/fasterxml/aalto/sax/TestSaxWriter.java b/src/test/java/com/fasterxml/aalto/sax/TestSaxWriter.java index 799a50a..58c9b9f 100644 --- a/src/test/java/com/fasterxml/aalto/sax/TestSaxWriter.java +++ b/src/test/java/com/fasterxml/aalto/sax/TestSaxWriter.java @@ -5,9 +5,10 @@ import java.io.ByteArrayOutputStream; -public class TestSaxWriter extends base.BaseTestCase { - - public void testSurrogateMemory1() throws Exception { +public class TestSaxWriter extends base.BaseTestCase +{ + public void testSplitSurrogateWithAttributeValue() throws Exception + { // This test aims to produce the // javax.xml.stream.XMLStreamException: Incomplete surrogate pair in content: first char 0xd835, second 0x78 // error message. Before fixing the respective issue, it was provoked by a multi-byte character @@ -16,12 +17,13 @@ public void testSurrogateMemory1() throws Exception { // of the original multi-byte character with the first character in the third buffer because // ByteXmlWriter#_surrogate was not set back to 0 after writing the original multi-byte character. StringBuilder testText = new StringBuilder(); - for (int i = 0; i < 511; i++) + for (int i = 0; i < 511; i++) { testText.append('x'); + } testText.append("\uD835\uDFCE"); - for (int i = 0; i < 512; i++) + for (int i = 0; i < 512; i++) { testText.append('x'); - + } WriterConfig writerConfig = new WriterConfig(); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); Utf8XmlWriter writer = new Utf8XmlWriter(writerConfig, byteArrayOutputStream); @@ -30,10 +32,10 @@ public void testSurrogateMemory1() throws Exception { writer.writeStartTagEnd(); writer.writeEndTag(writer.constructName("testelement")); writer.close(false); - } - public void testSurrogateMemory2() throws Exception { + public void testSplitSurrogateWithAttributeValue2() throws Exception + { // This test aims to produce the // java.io.IOException: Unpaired surrogate character (0xd835) // error message. Before fixing the respective issue, it was provoked by a multi-byte character @@ -41,8 +43,9 @@ public void testSurrogateMemory2() throws Exception { // reading buffer was enough to write all the remaining data. Then, by the missing reset of // ByteXmlWriter#_surrogate, the code expected another multi-byte surrogate that never came. StringBuilder testText = new StringBuilder(); - for (int i = 0; i < 511; i++) + for (int i = 0; i < 511; i++) { testText.append('x'); + } testText.append("\uD835\uDFCE"); WriterConfig writerConfig = new WriterConfig(); @@ -55,18 +58,21 @@ public void testSurrogateMemory2() throws Exception { writer.close(false); } - public void testSurrogateMemory3() throws Exception { + public void testSplitSurrogateWithCData() throws Exception + { // This test aims to produce the // javax.xml.stream.XMLStreamException: Incomplete surrogate pair in content: first char 0xdfce, second 0x78 // error message. The issue was similar to the one described in testSurrogateMemory1(), except it happened in // ByteXmlWriter#writeCDataContents(), where check for existing _surrogate was missing prior to the fix, // as opposed to ByteXmlWriter#writeCharacters(). StringBuilder testText = new StringBuilder(); - for (int i = 0; i < 511; i++) + for (int i = 0; i < 511; i++) { testText.append('x'); + } testText.append("\uD835\uDFCE"); - for (int i = 0; i < 512; i++) + for (int i = 0; i < 512; i++) { testText.append('x'); + } WriterConfig writerConfig = new WriterConfig(); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); @@ -76,7 +82,5 @@ public void testSurrogateMemory3() throws Exception { writer.writeStartTagEnd(); writer.writeEndTag(writer.constructName("testelement")); writer.close(false); - } - }