From 134bc1c02b0020f606a5e5efab65f5b1dda3ec55 Mon Sep 17 00:00:00 2001
From: Sylwester Lachiewicz
Date: Sun, 15 Dec 2024 23:27:22 +0100
Subject: [PATCH 1/2] Tests cleanup
---
pom.xml | 7 +-
.../util/xml/PrettyPrintXMLWriterTest.java | 79 ++-
.../plexus/util/xml/XmlStreamReaderTest.java | 30 +-
.../plexus/util/xml/XmlStreamWriterTest.java | 29 +-
.../codehaus/plexus/util/xml/XmlUtilTest.java | 11 +-
.../plexus/util/xml/XmlWriterUtilTest.java | 216 ++++---
.../plexus/util/xml/Xpp3DomBuilderTest.java | 84 +--
.../codehaus/plexus/util/xml/Xpp3DomTest.java | 47 +-
.../plexus/util/xml/Xpp3DomUtilsTest.java | 12 +-
.../plexus/util/xml/Xpp3DomWriterTest.java | 8 +-
...onformanceTestSuite_Production24_Test.java | 21 +-
...ConformanceTestSuite_Production2_Test.java | 71 +--
...onformanceTestSuite_Production32_Test.java | 22 +-
...onformanceTestSuite_Production66_Test.java | 33 +-
...onformanceTestSuite_Production80_Test.java | 15 +-
.../plexus/util/xml/pull/MXParserTest.java | 549 +++++++++---------
.../util/xml/pull/MXSerializerTest.java | 25 +-
..._BjoernHoehrmannviaHST2013_09_18_Test.java | 23 +-
18 files changed, 619 insertions(+), 663 deletions(-)
diff --git a/pom.xml b/pom.xml
index a2cd9f9..1b9dbcc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -48,6 +48,7 @@ limitations under the License.
+ 1.37
2024-05-21T21:12:10Z
@@ -55,18 +56,18 @@ limitations under the License.
org.openjdk.jmh
jmh-core
- 1.37
+ ${jmhVersion}
test
org.openjdk.jmh
jmh-generator-annprocess
- 1.37
+ ${jmhVersion}
test
org.junit.jupiter
- junit-jupiter
+ junit-jupiter-api
test
diff --git a/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java b/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java
index e219e5c..6c7736f 100644
--- a/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java
+++ b/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java
@@ -22,6 +22,7 @@
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.StringWriter;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.NoSuchElementException;
@@ -42,7 +43,7 @@
* @version $Id: $Id
* @since 3.4.0
*/
-public class PrettyPrintXMLWriterTest {
+class PrettyPrintXMLWriterTest {
StringWriter w;
PrettyPrintXMLWriter writer;
@@ -51,7 +52,7 @@ public class PrettyPrintXMLWriterTest {
* setUp.
*/
@BeforeEach
- public void setUp() {
+ void setUp() {
initWriter();
}
@@ -59,7 +60,7 @@ public void setUp() {
* tearDown.
*/
@AfterEach
- public void tearDown() {
+ void tearDown() {
writer = null;
w = null;
}
@@ -73,7 +74,7 @@ private void initWriter() {
* testDefaultPrettyPrintXMLWriter.
*/
@Test
- public void testDefaultPrettyPrintXMLWriter() {
+ void defaultPrettyPrintXMLWriter() {
writer.startElement(Tag.HTML.toString());
writeXhtmlHead(writer);
@@ -89,7 +90,7 @@ public void testDefaultPrettyPrintXMLWriter() {
* testPrettyPrintXMLWriterWithGivenLineSeparator.
*/
@Test
- public void testPrettyPrintXMLWriterWithGivenLineSeparator() {
+ void prettyPrintXMLWriterWithGivenLineSeparator() {
writer.setLineSeparator("\n");
writer.startElement(Tag.HTML.toString());
@@ -107,7 +108,7 @@ public void testPrettyPrintXMLWriterWithGivenLineSeparator() {
* testPrettyPrintXMLWriterWithGivenLineIndenter.
*/
@Test
- public void testPrettyPrintXMLWriterWithGivenLineIndenter() {
+ void prettyPrintXMLWriterWithGivenLineIndenter() {
writer.setLineIndenter(" ");
writer.startElement(Tag.HTML.toString());
@@ -125,7 +126,7 @@ public void testPrettyPrintXMLWriterWithGivenLineIndenter() {
* testEscapeXmlAttribute.
*/
@Test
- public void testEscapeXmlAttribute() {
+ void escapeXmlAttribute() {
// Windows
writer.startElement(Tag.DIV.toString());
writer.addAttribute("class", "sect\r\nion");
@@ -151,7 +152,7 @@ public void testEscapeXmlAttribute() {
* testendElementAlreadyClosed.
*/
@Test
- public void testendElementAlreadyClosed() {
+ void testendElementAlreadyClosed() {
try {
writer.startElement(Tag.DIV.toString());
writer.addAttribute("class", "someattribute");
@@ -164,21 +165,22 @@ public void testendElementAlreadyClosed() {
}
/**
- * Issue #51: https://github.com/codehaus-plexus/plexus-utils/issues/51 Purpose: test if concatenation string
+ * Issue #51: ... Purpose: test if concatenation string
* optimization bug is present. Target environment: Java 7 (u79 and u80 verified) running on Windows. Detection
* strategy: Tries to build a big XML file (~750MB size) and with many nested tags to force the JVM to trigger the
* concatenation string optimization bug that throws a NoSuchElementException when calling endElement() method.
*
- * @throws java.io.IOException if an I/O error occurs
+ * @throws IOException if an I/O error occurs
*/
@Test
- public void testIssue51DetectJava7ConcatenationBug() throws IOException {
+ void issue51DetectJava7ConcatenationBug() throws IOException {
File dir = new File("target/test-xml");
if (!dir.exists()) {
assertTrue(dir.mkdir(), "cannot create directory test-xml");
}
File xmlFile = new File(dir, "test-issue-51.xml");
- OutputStreamWriter osw = new OutputStreamWriter(Files.newOutputStream(xmlFile.toPath()), "UTF-8");
+ OutputStreamWriter osw =
+ new OutputStreamWriter(Files.newOutputStream(xmlFile.toPath()), StandardCharsets.UTF_8);
writer = new PrettyPrintXMLWriter(osw);
int iterations = 20000;
@@ -235,34 +237,29 @@ private String expectedResult(String lineSeparator) {
}
private String expectedResult(String lineIndenter, String lineSeparator) {
- StringBuilder expected = new StringBuilder();
-
- expected.append("").append(lineSeparator);
- expected.append(StringUtils.repeat(lineIndenter, 1)).append("").append(lineSeparator);
- expected.append(StringUtils.repeat(lineIndenter, 2))
- .append("title")
- .append(lineSeparator);
- expected.append(StringUtils.repeat(lineIndenter, 2))
- .append("")
- .append(lineSeparator);
- expected.append(StringUtils.repeat(lineIndenter, 2))
- .append("")
- .append(lineSeparator);
- expected.append(StringUtils.repeat(lineIndenter, 1)).append("").append(lineSeparator);
- expected.append(StringUtils.repeat(lineIndenter, 1)).append("").append(lineSeparator);
- expected.append(StringUtils.repeat(lineIndenter, 2))
- .append("Paragraph 1, line 1. Paragraph 1, line 2.
")
- .append(lineSeparator);
- expected.append(StringUtils.repeat(lineIndenter, 2))
- .append("")
- .append(lineSeparator);
- expected.append(StringUtils.repeat(lineIndenter, 3))
- .append("
Section title
")
- .append(lineSeparator);
- expected.append(StringUtils.repeat(lineIndenter, 2)).append("
").append(lineSeparator);
- expected.append(StringUtils.repeat(lineIndenter, 1)).append("").append(lineSeparator);
- expected.append("");
-
- return expected.toString();
+ return "" + lineSeparator + StringUtils.repeat(lineIndenter, 1)
+ + "" + lineSeparator + StringUtils.repeat(lineIndenter, 2)
+ + "title"
+ + lineSeparator
+ + StringUtils.repeat(lineIndenter, 2)
+ + ""
+ + lineSeparator
+ + StringUtils.repeat(lineIndenter, 2)
+ + ""
+ + lineSeparator
+ + StringUtils.repeat(lineIndenter, 1)
+ + "" + lineSeparator + StringUtils.repeat(lineIndenter, 1)
+ + "" + lineSeparator + StringUtils.repeat(lineIndenter, 2)
+ + "Paragraph 1, line 1. Paragraph 1, line 2.
"
+ + lineSeparator
+ + StringUtils.repeat(lineIndenter, 2)
+ + ""
+ + lineSeparator
+ + StringUtils.repeat(lineIndenter, 3)
+ + "
Section title
"
+ + lineSeparator
+ + StringUtils.repeat(lineIndenter, 2)
+ + "" + lineSeparator + StringUtils.repeat(lineIndenter, 1)
+ + "" + lineSeparator + "";
}
}
diff --git a/src/test/java/org/codehaus/plexus/util/xml/XmlStreamReaderTest.java b/src/test/java/org/codehaus/plexus/util/xml/XmlStreamReaderTest.java
index 4ffe7a9..0ce093e 100644
--- a/src/test/java/org/codehaus/plexus/util/xml/XmlStreamReaderTest.java
+++ b/src/test/java/org/codehaus/plexus/util/xml/XmlStreamReaderTest.java
@@ -35,7 +35,7 @@
* @version $Id: $Id
* @since 3.4.0
*/
-public class XmlStreamReaderTest {
+class XmlStreamReaderTest {
/** french */
private static final String TEXT_LATIN1 = "eacute: \u00E9";
@@ -52,7 +52,7 @@ public class XmlStreamReaderTest {
private static final String TEXT_UNICODE =
TEXT_LATIN1 + ", " + TEXT_LATIN7 + ", " + TEXT_LATIN15 + ", " + TEXT_EUC_JP;
- /** see http://unicode.org/faq/utf_bom.html#BOM */
+ /** see BOM */
private static final byte[] BOM_UTF8 = {(byte) 0xEF, (byte) 0xBB, (byte) 0xBF};
private static final byte[] BOM_UTF16BE = {(byte) 0xFE, (byte) 0xFF};
@@ -115,7 +115,7 @@ private static void checkXmlStreamReader(String text, String encoding, String ef
* @throws java.io.IOException if any.
*/
@Test
- public void testNoXmlHeader() throws IOException {
+ void noXmlHeader() throws IOException {
String xml = "text with no XML header";
checkXmlContent(xml, "UTF-8");
checkXmlContent(xml, "UTF-8", BOM_UTF8);
@@ -127,7 +127,7 @@ public void testNoXmlHeader() throws IOException {
* @throws java.io.IOException if any.
*/
@Test
- public void testDefaultEncoding() throws IOException {
+ void defaultEncoding() throws IOException {
checkXmlStreamReader(TEXT_UNICODE, null, "UTF-8");
checkXmlStreamReader(TEXT_UNICODE, null, "UTF-8", BOM_UTF8);
}
@@ -138,7 +138,7 @@ public void testDefaultEncoding() throws IOException {
* @throws java.io.IOException if any.
*/
@Test
- public void testUTF8Encoding() throws IOException {
+ void utf8Encoding() throws IOException {
checkXmlStreamReader(TEXT_UNICODE, "UTF-8");
checkXmlStreamReader(TEXT_UNICODE, "UTF-8", BOM_UTF8);
}
@@ -149,7 +149,7 @@ public void testUTF8Encoding() throws IOException {
* @throws java.io.IOException if any.
*/
@Test
- public void testUTF16Encoding() throws IOException {
+ void utf16Encoding() throws IOException {
checkXmlStreamReader(TEXT_UNICODE, "UTF-16", "UTF-16BE", null);
checkXmlStreamReader(TEXT_UNICODE, "UTF-16", "UTF-16LE", BOM_UTF16LE);
checkXmlStreamReader(TEXT_UNICODE, "UTF-16", "UTF-16BE", BOM_UTF16BE);
@@ -161,7 +161,7 @@ public void testUTF16Encoding() throws IOException {
* @throws java.io.IOException if any.
*/
@Test
- public void testUTF16BEEncoding() throws IOException {
+ void utf16beEncoding() throws IOException {
checkXmlStreamReader(TEXT_UNICODE, "UTF-16BE");
}
@@ -171,7 +171,7 @@ public void testUTF16BEEncoding() throws IOException {
* @throws java.io.IOException if any.
*/
@Test
- public void testUTF16LEEncoding() throws IOException {
+ void utf16leEncoding() throws IOException {
checkXmlStreamReader(TEXT_UNICODE, "UTF-16LE");
}
@@ -181,7 +181,7 @@ public void testUTF16LEEncoding() throws IOException {
* @throws java.io.IOException if any.
*/
@Test
- public void testLatin1Encoding() throws IOException {
+ void latin1Encoding() throws IOException {
checkXmlStreamReader(TEXT_LATIN1, "ISO-8859-1");
}
@@ -191,7 +191,7 @@ public void testLatin1Encoding() throws IOException {
* @throws java.io.IOException if any.
*/
@Test
- public void testLatin7Encoding() throws IOException {
+ void latin7Encoding() throws IOException {
checkXmlStreamReader(TEXT_LATIN7, "ISO-8859-7");
}
@@ -201,7 +201,7 @@ public void testLatin7Encoding() throws IOException {
* @throws java.io.IOException if any.
*/
@Test
- public void testLatin15Encoding() throws IOException {
+ void latin15Encoding() throws IOException {
checkXmlStreamReader(TEXT_LATIN15, "ISO-8859-15");
}
@@ -211,7 +211,7 @@ public void testLatin15Encoding() throws IOException {
* @throws java.io.IOException if any.
*/
@Test
- public void testEUC_JPEncoding() throws IOException {
+ void euc_jpEncoding() throws IOException {
checkXmlStreamReader(TEXT_EUC_JP, "EUC-JP");
}
@@ -221,7 +221,7 @@ public void testEUC_JPEncoding() throws IOException {
* @throws java.io.IOException if any.
*/
@Test
- public void testEBCDICEncoding() throws IOException {
+ void ebcdicEncoding() throws IOException {
checkXmlStreamReader("simple text in EBCDIC", "CP1047");
}
@@ -231,7 +231,7 @@ public void testEBCDICEncoding() throws IOException {
* @throws java.io.IOException if any.
*/
@Test
- public void testInappropriateEncoding() throws IOException {
+ void inappropriateEncoding() throws IOException {
// expected failure, since the encoding does not contain some characters
assertThrows(
AssertionFailedError.class,
@@ -245,7 +245,7 @@ public void testInappropriateEncoding() throws IOException {
* @throws java.io.IOException if any.
*/
@Test
- public void testEncodingAttribute() throws IOException {
+ void encodingAttribute() throws IOException {
String xml = "";
checkXmlContent(xml, "US-ASCII");
diff --git a/src/test/java/org/codehaus/plexus/util/xml/XmlStreamWriterTest.java b/src/test/java/org/codehaus/plexus/util/xml/XmlStreamWriterTest.java
index c2803b5..6fa531b 100644
--- a/src/test/java/org/codehaus/plexus/util/xml/XmlStreamWriterTest.java
+++ b/src/test/java/org/codehaus/plexus/util/xml/XmlStreamWriterTest.java
@@ -30,7 +30,7 @@
* @version $Id: $Id
* @since 3.4.0
*/
-public class XmlStreamWriterTest {
+class XmlStreamWriterTest {
/** french */
private static final String TEXT_LATIN1 = "eacute: \u00E9";
@@ -61,8 +61,7 @@ private static void checkXmlContent(String xml, String encoding) throws IOExcept
XmlStreamWriter writer = new XmlStreamWriter(out);
writer.write(xml);
writer.close();
- byte[] xmlContent = out.toByteArray();
- String result = new String(xmlContent, encoding);
+ String result = out.toString(encoding);
assertEquals(xml, result);
}
@@ -78,7 +77,7 @@ private static void checkXmlWriter(String text, String encoding) throws IOExcept
* @throws java.io.IOException if any.
*/
@Test
- public void testNoXmlHeader() throws IOException {
+ void noXmlHeader() throws IOException {
String xml = "text with no XML header";
checkXmlContent(xml, "UTF-8");
}
@@ -89,7 +88,7 @@ public void testNoXmlHeader() throws IOException {
* @throws java.io.IOException if any.
*/
@Test
- public void testEmpty() throws IOException {
+ void empty() throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
XmlStreamWriter writer = new XmlStreamWriter(out);
writer.flush();
@@ -106,7 +105,7 @@ public void testEmpty() throws IOException {
* @throws java.io.IOException if any.
*/
@Test
- public void testDefaultEncoding() throws IOException {
+ void defaultEncoding() throws IOException {
checkXmlWriter(TEXT_UNICODE, null);
}
@@ -116,7 +115,7 @@ public void testDefaultEncoding() throws IOException {
* @throws java.io.IOException if any.
*/
@Test
- public void testUTF8Encoding() throws IOException {
+ void utf8Encoding() throws IOException {
checkXmlWriter(TEXT_UNICODE, "UTF-8");
}
@@ -126,7 +125,7 @@ public void testUTF8Encoding() throws IOException {
* @throws java.io.IOException if any.
*/
@Test
- public void testUTF16Encoding() throws IOException {
+ void utf16Encoding() throws IOException {
checkXmlWriter(TEXT_UNICODE, "UTF-16");
}
@@ -136,7 +135,7 @@ public void testUTF16Encoding() throws IOException {
* @throws java.io.IOException if any.
*/
@Test
- public void testUTF16BEEncoding() throws IOException {
+ void utf16beEncoding() throws IOException {
checkXmlWriter(TEXT_UNICODE, "UTF-16BE");
}
@@ -146,7 +145,7 @@ public void testUTF16BEEncoding() throws IOException {
* @throws java.io.IOException if any.
*/
@Test
- public void testUTF16LEEncoding() throws IOException {
+ void utf16leEncoding() throws IOException {
checkXmlWriter(TEXT_UNICODE, "UTF-16LE");
}
@@ -156,7 +155,7 @@ public void testUTF16LEEncoding() throws IOException {
* @throws java.io.IOException if any.
*/
@Test
- public void testLatin1Encoding() throws IOException {
+ void latin1Encoding() throws IOException {
checkXmlWriter(TEXT_LATIN1, "ISO-8859-1");
}
@@ -166,7 +165,7 @@ public void testLatin1Encoding() throws IOException {
* @throws java.io.IOException if any.
*/
@Test
- public void testLatin7Encoding() throws IOException {
+ void latin7Encoding() throws IOException {
checkXmlWriter(TEXT_LATIN7, "ISO-8859-7");
}
@@ -176,7 +175,7 @@ public void testLatin7Encoding() throws IOException {
* @throws java.io.IOException if any.
*/
@Test
- public void testLatin15Encoding() throws IOException {
+ void latin15Encoding() throws IOException {
checkXmlWriter(TEXT_LATIN15, "ISO-8859-15");
}
@@ -186,7 +185,7 @@ public void testLatin15Encoding() throws IOException {
* @throws java.io.IOException if any.
*/
@Test
- public void testEUC_JPEncoding() throws IOException {
+ void euc_jpEncoding() throws IOException {
checkXmlWriter(TEXT_EUC_JP, "EUC-JP");
}
@@ -196,7 +195,7 @@ public void testEUC_JPEncoding() throws IOException {
* @throws java.io.IOException if any.
*/
@Test
- public void testEBCDICEncoding() throws IOException {
+ void ebcdicEncoding() throws IOException {
checkXmlWriter("simple text in EBCDIC", "CP1047");
}
}
diff --git a/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java b/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java
index 302bc28..e6f9f59 100644
--- a/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java
+++ b/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java
@@ -29,7 +29,8 @@
import org.codehaus.plexus.util.StringUtils;
import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test the {@link org.codehaus.plexus.util.xml.XmlUtil} class.
@@ -68,7 +69,7 @@ private File getTestOutputFile(String relPath) throws IOException {
* @throws java.lang.Exception if any.
*/
@Test
- public void testPrettyFormatInputStreamOutputStream() throws Exception {
+ void prettyFormatInputStreamOutputStream() throws Exception {
File testDocument = new File(getBasedir(), "src/test/resources/testDocument.xhtml");
assertTrue(testDocument.exists());
@@ -95,7 +96,7 @@ public void testPrettyFormatInputStreamOutputStream() throws Exception {
* @throws java.lang.Exception if any.
*/
@Test
- public void testPrettyFormatReaderWriter() throws Exception {
+ void prettyFormatReaderWriter() throws Exception {
File testDocument = new File(getBasedir(), "src/test/resources/testDocument.xhtml");
assertTrue(testDocument.exists());
@@ -121,7 +122,7 @@ public void testPrettyFormatReaderWriter() throws Exception {
* @throws java.lang.Exception if any.
*/
@Test
- public void testPrettyFormatString() throws Exception {
+ void prettyFormatString() throws Exception {
File testDocument = new File(getBasedir(), "src/test/resources/testDocument.xhtml");
assertTrue(testDocument.exists());
@@ -152,7 +153,7 @@ public void testPrettyFormatString() throws Exception {
* @throws java.lang.Exception if any.
*/
@Test
- public void testPrettyFormatReaderWriter2() throws Exception {
+ void prettyFormatReaderWriter2() throws Exception {
File testDocument = new File(getBasedir(), "src/test/resources/test.xdoc.xhtml");
assertTrue(testDocument.exists());
diff --git a/src/test/java/org/codehaus/plexus/util/xml/XmlWriterUtilTest.java b/src/test/java/org/codehaus/plexus/util/xml/XmlWriterUtilTest.java
index fb51578..ff078f5 100644
--- a/src/test/java/org/codehaus/plexus/util/xml/XmlWriterUtilTest.java
+++ b/src/test/java/org/codehaus/plexus/util/xml/XmlWriterUtilTest.java
@@ -25,7 +25,8 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* XmlWriterUtilTest class.
@@ -34,7 +35,7 @@
* @version $Id: $Id
* @since 3.4.0
*/
-public class XmlWriterUtilTest {
+class XmlWriterUtilTest {
private OutputStream output;
private Writer writer;
@@ -47,7 +48,7 @@ public class XmlWriterUtilTest {
* @throws java.lang.Exception if any.
*/
@BeforeEach
- public void setUp() throws Exception {
+ void setUp() throws Exception {
output = new ByteArrayOutputStream();
writer = WriterFactory.newXmlWriter(output);
xmlWriter = new PrettyPrintXMLWriter(writer);
@@ -59,7 +60,7 @@ public void setUp() throws Exception {
* @throws java.lang.Exception if any.
*/
@AfterEach
- public void tearDown() throws Exception {
+ void tearDown() throws Exception {
xmlWriter = null;
writer = null;
output = null;
@@ -72,10 +73,10 @@ public void tearDown() throws Exception {
* @throws java.lang.Exception if any
*/
@Test
- public void testWriteLineBreakXMLWriter() throws Exception {
+ void writeLineBreakXMLWriter() throws Exception {
XmlWriterUtil.writeLineBreak(xmlWriter);
writer.close();
- assertTrue(StringUtils.countMatches(output.toString(), XmlWriterUtil.LS) == 1);
+ assertEquals(1, StringUtils.countMatches(output.toString(), XmlWriterUtil.LS));
}
/**
@@ -85,10 +86,10 @@ public void testWriteLineBreakXMLWriter() throws Exception {
* @throws java.lang.Exception if any
*/
@Test
- public void testWriteLineBreakXMLWriterInt() throws Exception {
+ void writeLineBreakXMLWriterInt() throws Exception {
XmlWriterUtil.writeLineBreak(xmlWriter, 10);
writer.close();
- assertTrue(StringUtils.countMatches(output.toString(), XmlWriterUtil.LS) == 10);
+ assertEquals(10, StringUtils.countMatches(output.toString(), XmlWriterUtil.LS));
}
/**
@@ -98,13 +99,14 @@ public void testWriteLineBreakXMLWriterInt() throws Exception {
* @throws java.lang.Exception if any
*/
@Test
- public void testWriteLineBreakXMLWriterIntInt() throws Exception {
+ void writeLineBreakXMLWriterIntInt() throws Exception {
XmlWriterUtil.writeLineBreak(xmlWriter, 10, 2);
writer.close();
- assertTrue(StringUtils.countMatches(output.toString(), XmlWriterUtil.LS) == 10);
- assertTrue(StringUtils.countMatches(
- output.toString(), StringUtils.repeat(" ", 2 * XmlWriterUtil.DEFAULT_INDENTATION_SIZE))
- == 1);
+ assertEquals(10, StringUtils.countMatches(output.toString(), XmlWriterUtil.LS));
+ assertEquals(
+ 1,
+ StringUtils.countMatches(
+ output.toString(), StringUtils.repeat(" ", 2 * XmlWriterUtil.DEFAULT_INDENTATION_SIZE)));
}
/**
@@ -114,11 +116,11 @@ public void testWriteLineBreakXMLWriterIntInt() throws Exception {
* @throws java.lang.Exception if any
*/
@Test
- public void testWriteLineBreakXMLWriterIntIntInt() throws Exception {
+ void writeLineBreakXMLWriterIntIntInt() throws Exception {
XmlWriterUtil.writeLineBreak(xmlWriter, 10, 2, 4);
writer.close();
- assertTrue(StringUtils.countMatches(output.toString(), XmlWriterUtil.LS) == 10);
- assertTrue(StringUtils.countMatches(output.toString(), StringUtils.repeat(" ", 2 * 4)) == 1);
+ assertEquals(10, StringUtils.countMatches(output.toString(), XmlWriterUtil.LS));
+ assertEquals(1, StringUtils.countMatches(output.toString(), StringUtils.repeat(" ", 2 * 4)));
}
/**
@@ -128,14 +130,13 @@ public void testWriteLineBreakXMLWriterIntIntInt() throws Exception {
* @throws java.lang.Exception if any
*/
@Test
- public void testWriteCommentLineBreakXMLWriter() throws Exception {
+ void writeCommentLineBreakXMLWriter() throws Exception {
XmlWriterUtil.writeCommentLineBreak(xmlWriter);
writer.close();
- StringBuilder sb = new StringBuilder();
- sb.append("")
- .append(XmlWriterUtil.LS);
- assertEquals(output.toString(), sb.toString());
- assertTrue(output.toString().length() == XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length());
+ String sb =
+ "" + XmlWriterUtil.LS;
+ assertEquals(output.toString(), sb);
+ assertEquals(output.toString().length(), XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length());
}
/**
@@ -145,10 +146,10 @@ public void testWriteCommentLineBreakXMLWriter() throws Exception {
* @throws java.lang.Exception if any
*/
@Test
- public void testWriteCommentLineBreakXMLWriterInt() throws Exception {
+ void writeCommentLineBreakXMLWriterInt() throws Exception {
XmlWriterUtil.writeCommentLineBreak(xmlWriter, 20);
writer.close();
- assertEquals(output.toString(), "" + XmlWriterUtil.LS);
+ assertEquals("" + XmlWriterUtil.LS, output.toString());
tearDown();
setUp();
@@ -165,14 +166,14 @@ public void testWriteCommentLineBreakXMLWriterInt() throws Exception {
* @throws java.lang.Exception if any
*/
@Test
- public void testWriteCommentXMLWriterString() throws Exception {
+ void writeCommentXMLWriterString() throws Exception {
XmlWriterUtil.writeComment(xmlWriter, "hello");
writer.close();
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append("")
.append(XmlWriterUtil.LS);
assertEquals(output.toString(), sb.toString());
- assertTrue(output.toString().length() == XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length());
+ assertEquals(output.toString().length(), XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length());
tearDown();
setUp();
@@ -180,7 +181,7 @@ public void testWriteCommentXMLWriterString() throws Exception {
XmlWriterUtil.writeComment(
xmlWriter, "hellooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo");
writer.close();
- sb = new StringBuffer();
+ sb = new StringBuilder();
sb.append("")
.append(XmlWriterUtil.LS);
assertEquals(output.toString(), sb.toString());
@@ -191,14 +192,14 @@ public void testWriteCommentXMLWriterString() throws Exception {
XmlWriterUtil.writeComment(xmlWriter, "hello\nworld");
writer.close();
- sb = new StringBuffer();
+ sb = new StringBuilder();
sb.append("")
.append(XmlWriterUtil.LS);
sb.append("")
.append(XmlWriterUtil.LS);
assertEquals(output.toString(), sb.toString());
- assertTrue(
- output.toString().length() == 2 * (XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length()));
+ assertEquals(
+ output.toString().length(), 2 * (XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length()));
}
/**
@@ -208,18 +209,19 @@ public void testWriteCommentXMLWriterString() throws Exception {
* @throws java.lang.Exception if any
*/
@Test
- public void testWriteCommentXMLWriterStringInt() throws Exception {
+ void writeCommentXMLWriterStringInt() throws Exception {
String indent = StringUtils.repeat(" ", 2 * XmlWriterUtil.DEFAULT_INDENTATION_SIZE);
XmlWriterUtil.writeComment(xmlWriter, "hello", 2);
writer.close();
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append(indent);
sb.append("")
.append(XmlWriterUtil.LS);
assertEquals(output.toString(), sb.toString());
- assertTrue(output.toString().length()
- == XmlWriterUtil.DEFAULT_COLUMN_LINE
+ assertEquals(
+ output.toString().length(),
+ XmlWriterUtil.DEFAULT_COLUMN_LINE
- 1
+ XmlWriterUtil.LS.length()
+ 2 * XmlWriterUtil.DEFAULT_INDENTATION_SIZE);
@@ -229,7 +231,7 @@ public void testWriteCommentXMLWriterStringInt() throws Exception {
XmlWriterUtil.writeComment(xmlWriter, "hello\nworld", 2);
writer.close();
- sb = new StringBuffer();
+ sb = new StringBuilder();
sb.append(indent);
sb.append("")
.append(XmlWriterUtil.LS);
@@ -237,8 +239,9 @@ public void testWriteCommentXMLWriterStringInt() throws Exception {
sb.append("")
.append(XmlWriterUtil.LS);
assertEquals(output.toString(), sb.toString());
- assertTrue(output.toString().length()
- == 2 * (XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length()) + 2 * indent.length());
+ assertEquals(
+ output.toString().length(),
+ 2 * (XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length()) + 2 * indent.length());
}
/**
@@ -248,25 +251,25 @@ public void testWriteCommentXMLWriterStringInt() throws Exception {
* @throws java.lang.Exception if any
*/
@Test
- public void testWriteCommentXMLWriterStringIntInt() throws Exception {
+ void writeCommentXMLWriterStringIntInt() throws Exception {
String repeat = StringUtils.repeat(" ", 2 * 4);
XmlWriterUtil.writeComment(xmlWriter, "hello", 2, 4);
writer.close();
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append(repeat);
sb.append("")
.append(XmlWriterUtil.LS);
assertEquals(output.toString(), sb.toString());
- assertTrue(output.toString().length()
- == XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length() + 2 * 4);
+ assertEquals(
+ output.toString().length(), XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length() + 2 * 4);
tearDown();
setUp();
XmlWriterUtil.writeComment(xmlWriter, "hello\nworld", 2, 4);
writer.close();
- sb = new StringBuffer();
+ sb = new StringBuilder();
sb.append(repeat);
sb.append("")
.append(XmlWriterUtil.LS);
@@ -274,8 +277,9 @@ public void testWriteCommentXMLWriterStringIntInt() throws Exception {
sb.append("")
.append(XmlWriterUtil.LS);
assertEquals(output.toString(), sb.toString());
- assertTrue(output.toString().length()
- == 2 * (XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length()) + 2 * repeat.length());
+ assertEquals(
+ output.toString().length(),
+ 2 * (XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length()) + 2 * repeat.length());
}
/**
@@ -285,23 +289,23 @@ public void testWriteCommentXMLWriterStringIntInt() throws Exception {
* @throws java.lang.Exception if any
*/
@Test
- public void testWriteCommentXMLWriterStringIntIntInt() throws Exception {
+ void writeCommentXMLWriterStringIntIntInt() throws Exception {
String indent = StringUtils.repeat(" ", 2 * 4);
XmlWriterUtil.writeComment(xmlWriter, "hello", 2, 4, 50);
writer.close();
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append(indent);
sb.append("").append(XmlWriterUtil.LS);
assertEquals(output.toString(), sb.toString());
- assertTrue(output.toString().length() == 50 - 1 + XmlWriterUtil.LS.length() + 2 * 4);
+ assertEquals(output.toString().length(), 50 - 1 + XmlWriterUtil.LS.length() + 2 * 4);
tearDown();
setUp();
XmlWriterUtil.writeComment(xmlWriter, "hello", 2, 4, 10);
writer.close();
- sb = new StringBuffer();
+ sb = new StringBuilder();
sb.append(indent);
sb.append("").append(XmlWriterUtil.LS);
assertEquals(output.toString(), sb.toString());
@@ -315,10 +319,10 @@ public void testWriteCommentXMLWriterStringIntIntInt() throws Exception {
* @throws java.lang.Exception if any
*/
@Test
- public void testWriteCommentTextXMLWriterStringInt() throws Exception {
+ void writeCommentTextXMLWriterStringInt() throws Exception {
XmlWriterUtil.writeCommentText(xmlWriter, "hello", 0);
writer.close();
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append(XmlWriterUtil.LS);
sb.append("")
.append(XmlWriterUtil.LS);
@@ -328,8 +332,8 @@ public void testWriteCommentTextXMLWriterStringInt() throws Exception {
.append(XmlWriterUtil.LS);
sb.append(XmlWriterUtil.LS);
assertEquals(output.toString(), sb.toString());
- assertTrue(
- output.toString().length() == 3 * (80 - 1 + XmlWriterUtil.LS.length()) + 2 * XmlWriterUtil.LS.length());
+ assertEquals(
+ output.toString().length(), 3 * (80 - 1 + XmlWriterUtil.LS.length()) + 2 * XmlWriterUtil.LS.length());
tearDown();
setUp();
@@ -342,7 +346,7 @@ public void testWriteCommentTextXMLWriterStringInt() throws Exception {
+ "loooooooooooooooooooooooooooooooooooooooooooooooooooooonnnnnnnnnnong line",
2);
writer.close();
- sb = new StringBuffer();
+ sb = new StringBuilder();
sb.append(XmlWriterUtil.LS);
sb.append(indent)
.append("")
@@ -374,27 +378,26 @@ public void testWriteCommentTextXMLWriterStringInt() throws Exception {
* @throws java.lang.Exception if any
*/
@Test
- public void testWriteCommentTextXMLWriterStringIntInt() throws Exception {
+ void writeCommentTextXMLWriterStringIntInt() throws Exception {
String indent = StringUtils.repeat(" ", 2 * 4);
XmlWriterUtil.writeCommentText(xmlWriter, "hello", 2, 4);
writer.close();
- StringBuilder sb = new StringBuilder();
- sb.append(XmlWriterUtil.LS);
- sb.append(indent)
- .append("")
- .append(XmlWriterUtil.LS);
- sb.append(indent)
- .append("")
- .append(XmlWriterUtil.LS);
- sb.append(indent)
- .append("")
- .append(XmlWriterUtil.LS);
- sb.append(XmlWriterUtil.LS);
- sb.append(indent);
- assertEquals(output.toString(), sb.toString());
- assertTrue(output.toString().length()
- == 3 * (80 - 1 + XmlWriterUtil.LS.length()) + 4 * 2 * 4 + 2 * XmlWriterUtil.LS.length());
+ String sb = XmlWriterUtil.LS + indent
+ + ""
+ + XmlWriterUtil.LS
+ + indent
+ + ""
+ + XmlWriterUtil.LS
+ + indent
+ + ""
+ + XmlWriterUtil.LS
+ + XmlWriterUtil.LS
+ + indent;
+ assertEquals(output.toString(), sb);
+ assertEquals(
+ output.toString().length(),
+ 3 * (80 - 1 + XmlWriterUtil.LS.length()) + 4 * 2 * 4 + 2 * XmlWriterUtil.LS.length());
}
/**
@@ -404,27 +407,26 @@ public void testWriteCommentTextXMLWriterStringIntInt() throws Exception {
* @throws java.lang.Exception if any
*/
@Test
- public void testWriteCommentTextXMLWriterStringIntIntInt() throws Exception {
+ void writeCommentTextXMLWriterStringIntIntInt() throws Exception {
String indent = StringUtils.repeat(" ", 2 * 4);
XmlWriterUtil.writeCommentText(xmlWriter, "hello", 2, 4, 50);
writer.close();
- StringBuilder sb = new StringBuilder();
- sb.append(XmlWriterUtil.LS);
- sb.append(indent)
- .append("")
- .append(XmlWriterUtil.LS);
- sb.append(indent)
- .append("")
- .append(XmlWriterUtil.LS);
- sb.append(indent)
- .append("")
- .append(XmlWriterUtil.LS);
- sb.append(XmlWriterUtil.LS);
- sb.append(indent);
- assertEquals(output.toString(), sb.toString());
- assertTrue(output.toString().length()
- == 3 * (50 - 1 + XmlWriterUtil.LS.length()) + 4 * 2 * 4 + 2 * XmlWriterUtil.LS.length());
+ String sb = XmlWriterUtil.LS + indent
+ + ""
+ + XmlWriterUtil.LS
+ + indent
+ + ""
+ + XmlWriterUtil.LS
+ + indent
+ + ""
+ + XmlWriterUtil.LS
+ + XmlWriterUtil.LS
+ + indent;
+ assertEquals(output.toString(), sb);
+ assertEquals(
+ output.toString().length(),
+ 3 * (50 - 1 + XmlWriterUtil.LS.length()) + 4 * 2 * 4 + 2 * XmlWriterUtil.LS.length());
}
/**
@@ -434,13 +436,12 @@ public void testWriteCommentTextXMLWriterStringIntIntInt() throws Exception {
* @throws java.lang.Exception if any
*/
@Test
- public void testWriteCommentNull() throws Exception {
+ void writeCommentNull() throws Exception {
XmlWriterUtil.writeComment(xmlWriter, null);
writer.close();
- StringBuilder sb = new StringBuilder();
- sb.append("")
- .append(XmlWriterUtil.LS);
- assertEquals(output.toString(), sb.toString());
+ String sb =
+ "" + XmlWriterUtil.LS;
+ assertEquals(output.toString(), sb);
}
/**
@@ -450,13 +451,12 @@ public void testWriteCommentNull() throws Exception {
* @throws java.lang.Exception if any
*/
@Test
- public void testWriteCommentShort() throws Exception {
+ void writeCommentShort() throws Exception {
XmlWriterUtil.writeComment(xmlWriter, "This is a short text");
writer.close();
- StringBuilder sb = new StringBuilder();
- sb.append("")
- .append(XmlWriterUtil.LS);
- assertEquals(output.toString(), sb.toString());
+ String sb =
+ "" + XmlWriterUtil.LS;
+ assertEquals(output.toString(), sb);
}
/**
@@ -466,22 +466,20 @@ public void testWriteCommentShort() throws Exception {
* @throws java.lang.Exception if any
*/
@Test
- public void testWriteCommentLong() throws Exception {
+ void writeCommentLong() throws Exception {
XmlWriterUtil.writeComment(
xmlWriter,
"Maven is a software project management and comprehension tool. "
+ "Based on the concept of a project object model (POM), Maven can manage a project's build, reporting "
+ "and documentation from a central piece of information.");
writer.close();
- StringBuilder sb = new StringBuilder();
- sb.append("")
- .append(XmlWriterUtil.LS);
- sb.append("")
- .append(XmlWriterUtil.LS);
- sb.append("")
- .append(XmlWriterUtil.LS);
- sb.append("")
- .append(XmlWriterUtil.LS);
- assertEquals(output.toString(), sb.toString());
+ String sb = "" + XmlWriterUtil.LS
+ + ""
+ + XmlWriterUtil.LS
+ + ""
+ + XmlWriterUtil.LS
+ + ""
+ + XmlWriterUtil.LS;
+ assertEquals(output.toString(), sb);
}
}
diff --git a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomBuilderTest.java b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomBuilderTest.java
index c8db71b..a23eec1 100644
--- a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomBuilderTest.java
+++ b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomBuilderTest.java
@@ -34,7 +34,7 @@
* @version $Id: $Id
* @since 3.4.0
*/
-public class Xpp3DomBuilderTest {
+class Xpp3DomBuilderTest {
private static final String LS = System.lineSeparator();
/**
@@ -43,7 +43,7 @@ public class Xpp3DomBuilderTest {
* @throws java.lang.Exception if any.
*/
@Test
- public void testBuildFromReader() throws Exception {
+ void buildFromReader() throws Exception {
String domString = createDomString();
Xpp3Dom dom = Xpp3DomBuilder.build(new StringReader(domString));
@@ -59,7 +59,7 @@ public void testBuildFromReader() throws Exception {
* @throws java.lang.Exception if any.
*/
@Test
- public void testBuildTrimming() throws Exception {
+ void buildTrimming() throws Exception {
String domString = createDomString();
Xpp3Dom dom = Xpp3DomBuilder.build(new StringReader(domString), true);
@@ -77,7 +77,7 @@ public void testBuildTrimming() throws Exception {
* @throws java.lang.Exception if any.
*/
@Test
- public void testBuildFromXpp3Dom() throws Exception {
+ void buildFromXpp3Dom() throws Exception {
Xpp3Dom expectedDom = createExpectedDom();
Xpp3Dom dom = null;
@@ -123,7 +123,7 @@ public void testBuildFromXpp3Dom() throws Exception {
* Test we get an error from the parser, and don't hit the IllegalStateException.
*/
@Test
- public void testUnclosedXml() {
+ void unclosedXml() {
String domString = "" + createDomString();
try {
Xpp3DomBuilder.build(new StringReader(domString));
@@ -143,7 +143,7 @@ public void testUnclosedXml() {
* @throws org.codehaus.plexus.util.xml.pull.XmlPullParserException if any.
*/
@Test
- public void testEscapingInContent() throws IOException, XmlPullParserException {
+ void escapingInContent() throws IOException, XmlPullParserException {
Xpp3Dom dom = Xpp3DomBuilder.build(new StringReader(getEncodedString()));
assertEquals("\"text\"", dom.getChild("el").getValue(), "Check content value");
@@ -162,7 +162,7 @@ public void testEscapingInContent() throws IOException, XmlPullParserException {
* @throws org.codehaus.plexus.util.xml.pull.XmlPullParserException if any.
*/
@Test
- public void testEscapingInAttributes() throws IOException, XmlPullParserException {
+ void escapingInAttributes() throws IOException, XmlPullParserException {
String s = getAttributeEncodedString();
Xpp3Dom dom = Xpp3DomBuilder.build(new StringReader(s));
@@ -181,12 +181,9 @@ public void testEscapingInAttributes() throws IOException, XmlPullParserExceptio
* @throws org.codehaus.plexus.util.xml.pull.XmlPullParserException if any.
*/
@Test
- public void testInputLocationTracking() throws IOException, XmlPullParserException {
- Xpp3DomBuilder.InputLocationBuilder ilb = new Xpp3DomBuilder.InputLocationBuilder() {
- public Object toInputLocation(XmlPullParser parser) {
- return parser.getLineNumber(); // store only line number as a simple Integer
- }
- };
+ void inputLocationTracking() throws IOException, XmlPullParserException {
+ // store only line number as a simple Integer
+ Xpp3DomBuilder.InputLocationBuilder ilb = XmlPullParser::getLineNumber;
Xpp3Dom dom = Xpp3DomBuilder.build(new StringReader(createDomString()), true, ilb);
Xpp3Dom expectedDom = createExpectedDom();
assertEquals(expectedDom.getInputLocation(), dom.getInputLocation(), "root input location");
@@ -204,40 +201,25 @@ public Object toInputLocation(XmlPullParser parser) {
}
private static String getAttributeEncodedString() {
- StringBuilder domString = new StringBuilder();
- domString.append("");
- domString.append(LS);
- domString.append(" bar");
- domString.append(LS);
- domString.append("");
-
- return domString.toString();
+ return "" + LS + " bar" + LS + "";
}
private static String getEncodedString() {
- StringBuilder domString = new StringBuilder();
- domString.append("\n");
- domString.append(" \"text\"\n");
- domString.append(" \"text\"]]>\n");
- domString.append(" <b>"text"</b>\n");
- domString.append("");
-
- return domString.toString();
+ return "\n" + " \"text\"\n"
+ + " \"text\"]]>\n"
+ + " <b>"text"</b>\n"
+ + "";
}
private static String getExpectedString() {
- StringBuilder domString = new StringBuilder();
- domString.append("");
- domString.append(LS);
- domString.append(" "text"");
- domString.append(LS);
- domString.append(" <b>"text"</b>");
- domString.append(LS);
- domString.append(" <b>"text"</b>");
- domString.append(LS);
- domString.append("");
-
- return domString.toString();
+ return "" + LS
+ + " "text""
+ + LS
+ + " <b>"text"</b>"
+ + LS
+ + " <b>"text"</b>"
+ + LS
+ + "";
}
//
@@ -245,18 +227,14 @@ private static String getExpectedString() {
//
private static String createDomString() {
- StringBuilder buf = new StringBuilder();
- buf.append("\n");
- buf.append(" element1\n \n");
- buf.append(" \n");
- buf.append(" element3\n");
- buf.append(" \n");
- buf.append(" \n");
- buf.append(" \n");
- buf.append(" do not trim \n");
- buf.append("\n");
-
- return buf.toString();
+ return "\n" + " element1\n \n"
+ + " \n"
+ + " element3\n"
+ + " \n"
+ + " \n"
+ + " \n"
+ + " do not trim \n"
+ + "\n";
}
private static Xpp3Dom createExpectedDom() {
diff --git a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomTest.java b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomTest.java
index dd9aea8..fdf19dd 100644
--- a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomTest.java
+++ b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomTest.java
@@ -33,12 +33,12 @@
* @version $Id: $Id
* @since 3.4.0
*/
-public class Xpp3DomTest {
+class Xpp3DomTest {
/**
* testShouldPerformAppendAtFirstSubElementLevel.
*/
@Test
- public void testShouldPerformAppendAtFirstSubElementLevel() {
+ void shouldPerformAppendAtFirstSubElementLevel() {
// create the dominant DOM
Xpp3Dom t1 = new Xpp3Dom("top");
t1.setAttribute(Xpp3Dom.CHILDREN_COMBINATION_MODE_ATTRIBUTE, Xpp3Dom.CHILDREN_COMBINATION_APPEND);
@@ -76,7 +76,7 @@ public void testShouldPerformAppendAtFirstSubElementLevel() {
* testShouldOverrideAppendAndDeepMerge.
*/
@Test
- public void testShouldOverrideAppendAndDeepMerge() {
+ void shouldOverrideAppendAndDeepMerge() {
// create the dominant DOM
Xpp3Dom t1 = new Xpp3Dom("top");
t1.setAttribute(Xpp3Dom.CHILDREN_COMBINATION_MODE_ATTRIBUTE, Xpp3Dom.CHILDREN_COMBINATION_APPEND);
@@ -112,7 +112,7 @@ public void testShouldOverrideAppendAndDeepMerge() {
* testShouldPerformSelfOverrideAtTopLevel.
*/
@Test
- public void testShouldPerformSelfOverrideAtTopLevel() {
+ void shouldPerformSelfOverrideAtTopLevel() {
// create the dominant DOM
Xpp3Dom t1 = new Xpp3Dom("top");
t1.setAttribute("attr", "value");
@@ -138,7 +138,7 @@ public void testShouldPerformSelfOverrideAtTopLevel() {
* testShouldMergeValuesAtTopLevelByDefault.
*/
@Test
- public void testShouldMergeValuesAtTopLevelByDefault() {
+ void shouldMergeValuesAtTopLevelByDefault() {
// create the dominant DOM
Xpp3Dom t1 = new Xpp3Dom("top");
t1.setAttribute("attr", "value");
@@ -164,7 +164,7 @@ public void testShouldMergeValuesAtTopLevelByDefault() {
* testShouldMergeValuesAtTopLevel.
*/
@Test
- public void testShouldMergeValuesAtTopLevel() {
+ void shouldMergeValuesAtTopLevel() {
// create the dominant DOM
Xpp3Dom t1 = new Xpp3Dom("top");
t1.setAttribute("attr", "value");
@@ -187,7 +187,7 @@ public void testShouldMergeValuesAtTopLevel() {
* testNullAttributeNameOrValue.
*/
@Test
- public void testNullAttributeNameOrValue() {
+ void nullAttributeNameOrValue() {
Xpp3Dom t1 = new Xpp3Dom("top");
try {
t1.setAttribute("attr", null);
@@ -207,12 +207,12 @@ public void testNullAttributeNameOrValue() {
* testEquals.
*/
@Test
- public void testEquals() {
+ void equals() {
Xpp3Dom dom = new Xpp3Dom("top");
assertEquals(dom, dom);
- assertFalse(dom.equals(null));
- assertFalse(dom.equals(new Xpp3Dom((String) null)));
+ assertNotEquals(null, dom);
+ assertNotEquals(new Xpp3Dom((String) null), dom);
}
/**
@@ -222,20 +222,20 @@ public void testEquals() {
* @throws java.io.IOException if any.
*/
@Test
- public void testEqualsIsNullSafe() throws XmlPullParserException, IOException {
+ void equalsIsNullSafe() throws XmlPullParserException, IOException {
String testDom = "- one
- two
";
Xpp3Dom dom = Xpp3DomBuilder.build(new StringReader(testDom));
Xpp3Dom dom2 = Xpp3DomBuilder.build(new StringReader(testDom));
try {
- dom2.attributes = new HashMap();
+ dom2.attributes = new HashMap<>();
dom2.attributes.put("nullValue", null);
dom2.attributes.put(null, "nullKey");
dom2.childList.clear();
dom2.childList.add(null);
- assertFalse(dom.equals(dom2));
- assertFalse(dom2.equals(dom));
+ assertNotEquals(dom, dom2);
+ assertNotEquals(dom2, dom);
} catch (NullPointerException ex) {
ex.printStackTrace();
@@ -250,7 +250,7 @@ public void testEqualsIsNullSafe() throws XmlPullParserException, IOException {
* @throws java.io.IOException if any.
*/
@Test
- public void testShouldOverwritePluginConfigurationSubItemsByDefault() throws XmlPullParserException, IOException {
+ void shouldOverwritePluginConfigurationSubItemsByDefault() throws XmlPullParserException, IOException {
String parentConfigStr = "- one
- two
";
Xpp3Dom parentConfig =
Xpp3DomBuilder.build(new StringReader(parentConfigStr), new FixedInputLocationBuilder("parent"));
@@ -276,8 +276,7 @@ public void testShouldOverwritePluginConfigurationSubItemsByDefault() throws Xml
* @throws java.io.IOException if any.
*/
@Test
- public void testShouldMergePluginConfigurationSubItemsWithMergeAttributeSet()
- throws XmlPullParserException, IOException {
+ void shouldMergePluginConfigurationSubItemsWithMergeAttributeSet() throws XmlPullParserException, IOException {
String parentConfigStr = "- one
- two
";
Xpp3Dom parentConfig =
Xpp3DomBuilder.build(new StringReader(parentConfigStr), new FixedInputLocationBuilder("parent"));
@@ -308,7 +307,7 @@ public void testShouldMergePluginConfigurationSubItemsWithMergeAttributeSet()
* @throws java.lang.Exception if any.
*/
@Test
- public void testShouldNotChangeUponMergeWithItselfWhenFirstOrLastSubItemIsEmpty() throws Exception {
+ void shouldNotChangeUponMergeWithItselfWhenFirstOrLastSubItemIsEmpty() throws Exception {
String configStr = "- test
";
Xpp3Dom dominantConfig = Xpp3DomBuilder.build(new StringReader(configStr));
Xpp3Dom recessiveConfig = Xpp3DomBuilder.build(new StringReader(configStr));
@@ -318,9 +317,9 @@ public void testShouldNotChangeUponMergeWithItselfWhenFirstOrLastSubItemIsEmpty(
assertEquals(3, items.getChildCount());
- assertEquals(null, items.getChild(0).getValue());
+ assertNull(items.getChild(0).getValue());
assertEquals("test", items.getChild(1).getValue());
- assertEquals(null, items.getChild(2).getValue());
+ assertNull(items.getChild(2).getValue());
}
/**
@@ -329,7 +328,7 @@ public void testShouldNotChangeUponMergeWithItselfWhenFirstOrLastSubItemIsEmpty(
* @throws java.lang.Exception if any.
*/
@Test
- public void testShouldCopyRecessiveChildrenNotPresentInTarget() throws Exception {
+ void shouldCopyRecessiveChildrenNotPresentInTarget() throws Exception {
String dominantStr = "x";
String recessiveStr = "y";
Xpp3Dom dominantConfig = Xpp3DomBuilder.build(new StringReader(dominantStr));
@@ -351,7 +350,7 @@ public void testShouldCopyRecessiveChildrenNotPresentInTarget() throws Exception
* @throws org.codehaus.plexus.util.xml.pull.XmlPullParserException if any.
*/
@Test
- public void testDupeChildren() throws IOException, XmlPullParserException {
+ void dupeChildren() throws IOException, XmlPullParserException {
String dupes = "xy";
Xpp3Dom dom = Xpp3DomBuilder.build(new StringReader(dupes));
assertNotNull(dom);
@@ -364,7 +363,7 @@ public void testDupeChildren() throws IOException, XmlPullParserException {
* @throws java.lang.Exception if any.
*/
@Test
- public void testShouldRemoveEntireElementWithAttributesAndChildren() throws Exception {
+ void shouldRemoveEntireElementWithAttributesAndChildren() throws Exception {
String dominantStr = "";
String recessiveStr = "parameter";
Xpp3Dom dominantConfig = Xpp3DomBuilder.build(new StringReader(dominantStr));
@@ -382,7 +381,7 @@ public void testShouldRemoveEntireElementWithAttributesAndChildren() throws Exce
* @throws java.lang.Exception if any.
*/
@Test
- public void testShouldRemoveDoNotRemoveTagWhenSwappedInputDOMs() throws Exception {
+ void shouldRemoveDoNotRemoveTagWhenSwappedInputDOMs() throws Exception {
String dominantStr = "";
String recessiveStr = "parameter";
Xpp3Dom dominantConfig = Xpp3DomBuilder.build(new StringReader(dominantStr));
diff --git a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomUtilsTest.java b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomUtilsTest.java
index 6632367..64c3143 100644
--- a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomUtilsTest.java
+++ b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomUtilsTest.java
@@ -32,14 +32,14 @@
* @version $Id: $Id
* @since 3.4.0
*/
-public class Xpp3DomUtilsTest {
+class Xpp3DomUtilsTest {
/**
* testCombineId.
*
* @throws java.lang.Exception if any.
*/
@Test
- public void testCombineId() throws Exception {
+ void combineId() throws Exception {
String lhs = "" + "LHS-ONLYLHS"
+ "TOOVERWRITELHS"
+ "";
@@ -85,7 +85,7 @@ public void testCombineId() throws Exception {
* @throws java.lang.Exception if any.
*/
@Test
- public void testCombineKeys() throws Exception {
+ void combineKeys() throws Exception {
String lhs = ""
+ "LHS-ONLYLHS"
+ "TOOVERWRITELHS" + "";
@@ -126,7 +126,7 @@ public void testCombineKeys() throws Exception {
}
@Test
- public void testPreserveDominantBlankValue() throws XmlPullParserException, IOException {
+ void preserveDominantBlankValue() throws XmlPullParserException, IOException {
String lhs = " ";
String rhs = "recessive";
@@ -139,7 +139,7 @@ public void testPreserveDominantBlankValue() throws XmlPullParserException, IOEx
}
@Test
- public void testPreserveDominantEmptyNode() throws XmlPullParserException, IOException {
+ void preserveDominantEmptyNode() throws XmlPullParserException, IOException {
String lhs = "";
String rhs = "recessive";
@@ -152,7 +152,7 @@ public void testPreserveDominantEmptyNode() throws XmlPullParserException, IOExc
}
@Test
- public void testIsNotEmptyNegatesIsEmpty() {
+ void isNotEmptyNegatesIsEmpty() {
assertEquals(!Xpp3DomUtils.isEmpty(null), Xpp3DomUtils.isNotEmpty(null));
assertEquals(!Xpp3DomUtils.isEmpty(""), Xpp3DomUtils.isNotEmpty(""));
assertEquals(!Xpp3DomUtils.isEmpty(" "), Xpp3DomUtils.isNotEmpty(" "));
diff --git a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomWriterTest.java b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomWriterTest.java
index 233bdd5..cfea0d3 100644
--- a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomWriterTest.java
+++ b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomWriterTest.java
@@ -29,14 +29,14 @@
* @version $Id: $Id
* @since 3.4.0
*/
-public class Xpp3DomWriterTest {
- private static final String LS = System.getProperty("line.separator");
+class Xpp3DomWriterTest {
+ private static final String LS = System.lineSeparator();
/**
* testWriter.
*/
@Test
- public void testWriter() {
+ void writer() {
StringWriter writer = new StringWriter();
Xpp3DomWriter.write(writer, createXpp3Dom());
@@ -48,7 +48,7 @@ public void testWriter() {
* testWriterNoEscape.
*/
@Test
- public void testWriterNoEscape() {
+ void writerNoEscape() {
StringWriter writer = new StringWriter();
Xpp3DomWriter.write(new PrettyPrintXMLWriter(writer), createXpp3Dom(), false);
diff --git a/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production24_Test.java b/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production24_Test.java
index bb1a7e8..2e1fd7f 100644
--- a/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production24_Test.java
+++ b/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production24_Test.java
@@ -20,7 +20,6 @@
* @version $Id: $Id
* @since 3.4.0
*/
-public
class IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production24_Test {
static final File testResourcesDir = new File("src/test/resources/", "xmlconf/ibm/");
@@ -31,7 +30,7 @@ class IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConfo
* setUp.
*/
@BeforeEach
- public void setUp() {
+ void setUp() {
parser = new MXParser();
}
@@ -45,7 +44,7 @@ public void setUp() {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P24_ibm24n01xml() throws IOException {
+ void testibm_not_wf_P24_ibm24n01xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P24/ibm24n01.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -68,7 +67,7 @@ public void testibm_not_wf_P24_ibm24n01xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P24_ibm24n02xml() throws IOException {
+ void testibm_not_wf_P24_ibm24n02xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P24/ibm24n02.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -90,7 +89,7 @@ public void testibm_not_wf_P24_ibm24n02xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P24_ibm24n03xml() throws IOException {
+ void testibm_not_wf_P24_ibm24n03xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P24/ibm24n03.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -112,7 +111,7 @@ public void testibm_not_wf_P24_ibm24n03xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P24_ibm24n04xml() throws IOException {
+ void testibm_not_wf_P24_ibm24n04xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P24/ibm24n04.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -134,7 +133,7 @@ public void testibm_not_wf_P24_ibm24n04xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P24_ibm24n05xml() throws IOException {
+ void testibm_not_wf_P24_ibm24n05xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P24/ibm24n05.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -156,7 +155,7 @@ public void testibm_not_wf_P24_ibm24n05xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P24_ibm24n06xml() throws IOException {
+ void testibm_not_wf_P24_ibm24n06xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P24/ibm24n06.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -177,7 +176,7 @@ public void testibm_not_wf_P24_ibm24n06xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P24_ibm24n07xml() throws IOException {
+ void testibm_not_wf_P24_ibm24n07xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P24/ibm24n07.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -198,7 +197,7 @@ public void testibm_not_wf_P24_ibm24n07xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P24_ibm24n08xml() throws IOException {
+ void testibm_not_wf_P24_ibm24n08xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P24/ibm24n08.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -220,7 +219,7 @@ public void testibm_not_wf_P24_ibm24n08xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P24_ibm24n09xml() throws IOException {
+ void testibm_not_wf_P24_ibm24n09xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P24/ibm24n09.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
diff --git a/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production2_Test.java b/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production2_Test.java
index 49227a4..c4150ed 100644
--- a/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production2_Test.java
+++ b/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production2_Test.java
@@ -13,6 +13,7 @@
import java.nio.file.Paths;
import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -38,7 +39,7 @@ class IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConfo
* setUp.
*/
@BeforeEach
- public void setUp() {
+ void setUp() {
parser = new MXParser();
}
@@ -52,7 +53,7 @@ public void setUp() {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P02_ibm02n01xml() throws IOException {
+ void testibm_not_wf_P02_ibm02n01xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n01.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -73,7 +74,7 @@ public void testibm_not_wf_P02_ibm02n01xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P02_ibm02n02xml() throws IOException {
+ void testibm_not_wf_P02_ibm02n02xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n02.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -94,7 +95,7 @@ public void testibm_not_wf_P02_ibm02n02xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P02_ibm02n03xml() throws IOException {
+ void testibm_not_wf_P02_ibm02n03xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n03.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -115,7 +116,7 @@ public void testibm_not_wf_P02_ibm02n03xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P02_ibm02n04xml() throws IOException {
+ void testibm_not_wf_P02_ibm02n04xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n04.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -136,7 +137,7 @@ public void testibm_not_wf_P02_ibm02n04xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P02_ibm02n05xml() throws IOException {
+ void testibm_not_wf_P02_ibm02n05xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n05.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -157,7 +158,7 @@ public void testibm_not_wf_P02_ibm02n05xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P02_ibm02n06xml() throws IOException {
+ void testibm_not_wf_P02_ibm02n06xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n06.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -178,7 +179,7 @@ public void testibm_not_wf_P02_ibm02n06xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P02_ibm02n07xml() throws IOException {
+ void testibm_not_wf_P02_ibm02n07xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n07.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -199,7 +200,7 @@ public void testibm_not_wf_P02_ibm02n07xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P02_ibm02n08xml() throws IOException {
+ void testibm_not_wf_P02_ibm02n08xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n08.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -220,7 +221,7 @@ public void testibm_not_wf_P02_ibm02n08xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P02_ibm02n09xml() throws IOException {
+ void testibm_not_wf_P02_ibm02n09xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n09.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -241,7 +242,7 @@ public void testibm_not_wf_P02_ibm02n09xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P02_ibm02n10xml() throws IOException {
+ void testibm_not_wf_P02_ibm02n10xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n10.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -262,7 +263,7 @@ public void testibm_not_wf_P02_ibm02n10xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P02_ibm02n11xml() throws IOException {
+ void testibm_not_wf_P02_ibm02n11xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n11.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -283,7 +284,7 @@ public void testibm_not_wf_P02_ibm02n11xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P02_ibm02n12xml() throws IOException {
+ void testibm_not_wf_P02_ibm02n12xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n12.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -304,7 +305,7 @@ public void testibm_not_wf_P02_ibm02n12xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P02_ibm02n13xml() throws IOException {
+ void testibm_not_wf_P02_ibm02n13xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n13.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -325,7 +326,7 @@ public void testibm_not_wf_P02_ibm02n13xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P02_ibm02n14xml() throws IOException {
+ void testibm_not_wf_P02_ibm02n14xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n14.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -346,7 +347,7 @@ public void testibm_not_wf_P02_ibm02n14xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P02_ibm02n15xml() throws IOException {
+ void testibm_not_wf_P02_ibm02n15xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n15.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -367,7 +368,7 @@ public void testibm_not_wf_P02_ibm02n15xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P02_ibm02n16xml() throws IOException {
+ void testibm_not_wf_P02_ibm02n16xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n16.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -388,7 +389,7 @@ public void testibm_not_wf_P02_ibm02n16xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P02_ibm02n17xml() throws IOException {
+ void testibm_not_wf_P02_ibm02n17xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n17.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -409,7 +410,7 @@ public void testibm_not_wf_P02_ibm02n17xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P02_ibm02n18xml() throws IOException {
+ void testibm_not_wf_P02_ibm02n18xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n18.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -430,7 +431,7 @@ public void testibm_not_wf_P02_ibm02n18xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P02_ibm02n19xml() throws IOException {
+ void testibm_not_wf_P02_ibm02n19xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n19.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -451,7 +452,7 @@ public void testibm_not_wf_P02_ibm02n19xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P02_ibm02n20xml() throws IOException {
+ void testibm_not_wf_P02_ibm02n20xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n20.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -472,7 +473,7 @@ public void testibm_not_wf_P02_ibm02n20xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P02_ibm02n21xml() throws IOException {
+ void testibm_not_wf_P02_ibm02n21xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n21.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -493,7 +494,7 @@ public void testibm_not_wf_P02_ibm02n21xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P02_ibm02n22xml() throws IOException {
+ void testibm_not_wf_P02_ibm02n22xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n22.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -514,7 +515,7 @@ public void testibm_not_wf_P02_ibm02n22xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P02_ibm02n23xml() throws IOException {
+ void testibm_not_wf_P02_ibm02n23xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n23.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -535,7 +536,7 @@ public void testibm_not_wf_P02_ibm02n23xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P02_ibm02n24xml() throws IOException {
+ void testibm_not_wf_P02_ibm02n24xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n24.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -556,7 +557,7 @@ public void testibm_not_wf_P02_ibm02n24xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P02_ibm02n25xml() throws IOException {
+ void testibm_not_wf_P02_ibm02n25xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n25.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -577,7 +578,7 @@ public void testibm_not_wf_P02_ibm02n25xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P02_ibm02n26xml() throws IOException {
+ void testibm_not_wf_P02_ibm02n26xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n26.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -598,7 +599,7 @@ public void testibm_not_wf_P02_ibm02n26xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P02_ibm02n27xml() throws IOException {
+ void testibm_not_wf_P02_ibm02n27xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n27.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -619,7 +620,7 @@ public void testibm_not_wf_P02_ibm02n27xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P02_ibm02n28xml() throws IOException {
+ void testibm_not_wf_P02_ibm02n28xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n28.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -640,7 +641,7 @@ public void testibm_not_wf_P02_ibm02n28xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P02_ibm02n29xml() throws IOException {
+ void testibm_not_wf_P02_ibm02n29xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n29.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -662,7 +663,8 @@ public void testibm_not_wf_P02_ibm02n29xml() throws IOException {
*
* NOTE: This test file is malformed into the original test suite, so I skip it.
*/
- // @Test
+ @Test
+ @Disabled
public void testibm_not_wf_P02_ibm02n30xml() throws IOException {
try (BufferedReader reader = Files.newBufferedReader(
Paths.get(testResourcesDir.getCanonicalPath(), "not-wf/P02/ibm02n30.xml"),
@@ -687,7 +689,8 @@ public void testibm_not_wf_P02_ibm02n30xml() throws IOException {
*
* NOTE: This test file is malformed into the original test suite, so I skip it.
*/
- // @Test
+ @Test
+ @Disabled
public void testibm_not_wf_P02_ibm02n31xml() throws IOException {
try (FileInputStream is = new FileInputStream(new File(testResourcesDir, "not-wf/P02/ibm02n31.xml"));
InputStreamReader reader = new InputStreamReader(is, "ISO-8859-15")) {
@@ -710,7 +713,7 @@ public void testibm_not_wf_P02_ibm02n31xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P02_ibm02n32xml() throws IOException {
+ void testibm_not_wf_P02_ibm02n32xml() throws IOException {
try (FileInputStream is = new FileInputStream(new File(testResourcesDir, "not-wf/P02/ibm02n32.xml"));
InputStreamReader reader = new InputStreamReader(is, StandardCharsets.UTF_8)) {
parser.setInput(reader);
@@ -732,7 +735,7 @@ public void testibm_not_wf_P02_ibm02n32xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P02_ibm02n33xml() throws IOException {
+ void testibm_not_wf_P02_ibm02n33xml() throws IOException {
try (FileInputStream is = new FileInputStream(new File(testResourcesDir, "not-wf/P02/ibm02n33.xml"));
InputStreamReader reader = new InputStreamReader(is, StandardCharsets.UTF_8)) {
parser.setInput(reader);
diff --git a/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production32_Test.java b/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production32_Test.java
index f99e1ea..cfc2c53 100644
--- a/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production32_Test.java
+++ b/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production32_Test.java
@@ -6,6 +6,7 @@
import java.io.Reader;
import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -31,7 +32,7 @@ class IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConfo
* setUp.
*/
@BeforeEach
- public void setUp() {
+ void setUp() {
parser = new MXParser();
}
@@ -45,7 +46,7 @@ public void setUp() {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P32_ibm32n01xml() throws IOException {
+ void testibm_not_wf_P32_ibm32n01xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P32/ibm32n01.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -67,7 +68,7 @@ public void testibm_not_wf_P32_ibm32n01xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P32_ibm32n02xml() throws IOException {
+ void testibm_not_wf_P32_ibm32n02xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P32/ibm32n02.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -89,7 +90,7 @@ public void testibm_not_wf_P32_ibm32n02xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P32_ibm32n03xml() throws IOException {
+ void testibm_not_wf_P32_ibm32n03xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P32/ibm32n03.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -110,7 +111,7 @@ public void testibm_not_wf_P32_ibm32n03xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P32_ibm32n04xml() throws IOException {
+ void testibm_not_wf_P32_ibm32n04xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P32/ibm32n04.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -131,7 +132,7 @@ public void testibm_not_wf_P32_ibm32n04xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P32_ibm32n05xml() throws IOException {
+ void testibm_not_wf_P32_ibm32n05xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P32/ibm32n05.xml"))) {
parser.setInput(reader);
@@ -153,7 +154,7 @@ public void testibm_not_wf_P32_ibm32n05xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P32_ibm32n06xml() throws IOException {
+ void testibm_not_wf_P32_ibm32n06xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P32/ibm32n06.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -174,7 +175,7 @@ public void testibm_not_wf_P32_ibm32n06xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P32_ibm32n07xml() throws IOException {
+ void testibm_not_wf_P32_ibm32n07xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P32/ibm32n07.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -195,7 +196,7 @@ public void testibm_not_wf_P32_ibm32n07xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P32_ibm32n08xml() throws IOException {
+ void testibm_not_wf_P32_ibm32n08xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P32/ibm32n08.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -218,7 +219,8 @@ public void testibm_not_wf_P32_ibm32n08xml() throws IOException {
*
* NOTE: This test is SKIPPED as MXParser does not support parsing inside DOCTYPEDECL.
*/
- // @Test
+ @Test
+ @Disabled
public void testibm_not_wf_P32_ibm32n09xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P32/ibm32n09.xml"))) {
parser.setInput(reader);
diff --git a/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production66_Test.java b/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production66_Test.java
index debe597..c08b114 100644
--- a/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production66_Test.java
+++ b/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production66_Test.java
@@ -21,7 +21,6 @@
* @version $Id: $Id
* @since 3.4.0
*/
-public
class IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production66_Test {
static final File testResourcesDir = new File("src/test/resources/", "xmlconf/ibm/");
@@ -32,7 +31,7 @@ class IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConfo
* setUp.
*/
@BeforeEach
- public void setUp() {
+ void setUp() {
parser = new MXParser();
}
@@ -46,7 +45,7 @@ public void setUp() {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P66_ibm66n01xml() throws IOException {
+ void testibm_not_wf_P66_ibm66n01xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P66/ibm66n01.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -68,7 +67,7 @@ public void testibm_not_wf_P66_ibm66n01xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P66_ibm66n02xml() throws IOException {
+ void testibm_not_wf_P66_ibm66n02xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P66/ibm66n02.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -90,7 +89,7 @@ public void testibm_not_wf_P66_ibm66n02xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P66_ibm66n03xml() throws IOException {
+ void testibm_not_wf_P66_ibm66n03xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P66/ibm66n03.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -112,7 +111,7 @@ public void testibm_not_wf_P66_ibm66n03xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P66_ibm66n04xml() throws IOException {
+ void testibm_not_wf_P66_ibm66n04xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P66/ibm66n04.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -136,7 +135,7 @@ public void testibm_not_wf_P66_ibm66n04xml() throws IOException {
* @throws org.codehaus.plexus.util.xml.pull.XmlPullParserException if any.
*/
@Test
- public void testibm_not_wf_P66_ibm66n05xml() throws FileNotFoundException, IOException, XmlPullParserException {
+ void testibm_not_wf_P66_ibm66n05xml() throws FileNotFoundException, IOException, XmlPullParserException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P66/ibm66n05.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -158,7 +157,7 @@ public void testibm_not_wf_P66_ibm66n05xml() throws FileNotFoundException, IOExc
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P66_ibm66n06xml() throws IOException {
+ void testibm_not_wf_P66_ibm66n06xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P66/ibm66n06.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -180,7 +179,7 @@ public void testibm_not_wf_P66_ibm66n06xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P66_ibm66n07xml() throws IOException {
+ void testibm_not_wf_P66_ibm66n07xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P66/ibm66n07.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -202,7 +201,7 @@ public void testibm_not_wf_P66_ibm66n07xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P66_ibm66n08xml() throws IOException {
+ void testibm_not_wf_P66_ibm66n08xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P66/ibm66n08.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -224,7 +223,7 @@ public void testibm_not_wf_P66_ibm66n08xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P66_ibm66n09xml() throws IOException {
+ void testibm_not_wf_P66_ibm66n09xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P66/ibm66n09.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -246,7 +245,7 @@ public void testibm_not_wf_P66_ibm66n09xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P66_ibm66n10xml() throws IOException {
+ void testibm_not_wf_P66_ibm66n10xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P66/ibm66n10.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -268,7 +267,7 @@ public void testibm_not_wf_P66_ibm66n10xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P66_ibm66n11xml() throws IOException {
+ void testibm_not_wf_P66_ibm66n11xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P66/ibm66n11.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -290,7 +289,7 @@ public void testibm_not_wf_P66_ibm66n11xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P66_ibm66n12xml() throws IOException {
+ void testibm_not_wf_P66_ibm66n12xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P66/ibm66n12.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -312,7 +311,7 @@ public void testibm_not_wf_P66_ibm66n12xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P66_ibm66n13xml() throws IOException {
+ void testibm_not_wf_P66_ibm66n13xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P66/ibm66n13.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -334,7 +333,7 @@ public void testibm_not_wf_P66_ibm66n13xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P66_ibm66n14xml() throws IOException {
+ void testibm_not_wf_P66_ibm66n14xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P66/ibm66n14.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -356,7 +355,7 @@ public void testibm_not_wf_P66_ibm66n14xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P66_ibm66n15xml() throws IOException {
+ void testibm_not_wf_P66_ibm66n15xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P66/ibm66n15.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
diff --git a/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production80_Test.java b/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production80_Test.java
index 9581bed..a2b2c16 100644
--- a/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production80_Test.java
+++ b/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production80_Test.java
@@ -20,7 +20,6 @@
* @version $Id: $Id
* @since 3.4.0
*/
-public
class IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production80_Test {
static final File testResourcesDir = new File("src/test/resources/", "xmlconf/ibm/");
@@ -31,7 +30,7 @@ class IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConfo
* setUp.
*/
@BeforeEach
- public void setUp() {
+ void setUp() {
parser = new MXParser();
}
@@ -45,7 +44,7 @@ public void setUp() {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P80_ibm80n01xml() throws IOException {
+ void testibm_not_wf_P80_ibm80n01xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P80/ibm80n01.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -67,7 +66,7 @@ public void testibm_not_wf_P80_ibm80n01xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P80_ibm80n02xml() throws IOException {
+ void testibm_not_wf_P80_ibm80n02xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P80/ibm80n02.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -89,7 +88,7 @@ public void testibm_not_wf_P80_ibm80n02xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P80_ibm80n03xml() throws IOException {
+ void testibm_not_wf_P80_ibm80n03xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P80/ibm80n03.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -112,7 +111,7 @@ public void testibm_not_wf_P80_ibm80n03xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P80_ibm80n04xml() throws IOException {
+ void testibm_not_wf_P80_ibm80n04xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P80/ibm80n04.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -134,7 +133,7 @@ public void testibm_not_wf_P80_ibm80n04xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P80_ibm80n05xml() throws IOException {
+ void testibm_not_wf_P80_ibm80n05xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P80/ibm80n05.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -156,7 +155,7 @@ public void testibm_not_wf_P80_ibm80n05xml() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testibm_not_wf_P80_ibm80n06xml() throws IOException {
+ void testibm_not_wf_P80_ibm80n06xml() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P80/ibm80n06.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
diff --git a/src/test/java/org/codehaus/plexus/util/xml/pull/MXParserTest.java b/src/test/java/org/codehaus/plexus/util/xml/pull/MXParserTest.java
index 2d3ecef..9c3e580 100644
--- a/src/test/java/org/codehaus/plexus/util/xml/pull/MXParserTest.java
+++ b/src/test/java/org/codehaus/plexus/util/xml/pull/MXParserTest.java
@@ -22,11 +22,13 @@
import java.io.InputStream;
import java.io.Reader;
import java.io.StringReader;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.xml.ReaderFactory;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -41,14 +43,14 @@
* @version $Id: $Id
* @since 3.4.0
*/
-public class MXParserTest {
+class MXParserTest {
/**
* testHexadecimalEntities.
*
* @throws java.lang.Exception if any.
*/
@Test
- public void testHexadecimalEntities() throws Exception {
+ void hexadecimalEntities() throws Exception {
MXParser parser = new MXParser();
parser.defineEntityReplacementText("test", "replacement");
@@ -72,7 +74,7 @@ public void testHexadecimalEntities() throws Exception {
* @throws java.lang.Exception if any.
*/
@Test
- public void testDecimalEntities() throws Exception {
+ void decimalEntities() throws Exception {
MXParser parser = new MXParser();
parser.defineEntityReplacementText("test", "replacement");
@@ -96,7 +98,7 @@ public void testDecimalEntities() throws Exception {
* @throws java.lang.Exception if any.
*/
@Test
- public void testPredefinedEntities() throws Exception {
+ void predefinedEntities() throws Exception {
MXParser parser = new MXParser();
parser.defineEntityReplacementText("test", "replacement");
@@ -121,7 +123,7 @@ public void testPredefinedEntities() throws Exception {
* @throws java.io.IOException if any.
*/
@Test
- public void testEntityReplacementMap() throws XmlPullParserException, IOException {
+ void entityReplacementMap() throws XmlPullParserException, IOException {
EntityReplacementMap erm = new EntityReplacementMap(new String[][] {{"abc", "CDE"}, {"EFG", "HIJ"}});
MXParser parser = new MXParser(erm);
@@ -140,7 +142,7 @@ public void testEntityReplacementMap() throws XmlPullParserException, IOExceptio
* @throws java.lang.Exception if any.
*/
@Test
- public void testCustomEntities() throws Exception {
+ void customEntities() throws Exception {
MXParser parser = new MXParser();
String input = "&myentity;";
@@ -168,7 +170,7 @@ public void testCustomEntities() throws Exception {
* @throws java.lang.Exception if any.
*/
@Test
- public void testUnicodeEntities() throws Exception {
+ void unicodeEntities() throws Exception {
MXParser parser = new MXParser();
String input = "𝟭";
parser.setInput(new StringReader(input));
@@ -194,7 +196,7 @@ public void testUnicodeEntities() throws Exception {
* @throws java.lang.Exception if any.
*/
@Test
- public void testInvalidCharacterReferenceHexa() throws Exception {
+ void invalidCharacterReferenceHexa() throws Exception {
MXParser parser = new MXParser();
String input = "";
parser.setInput(new StringReader(input));
@@ -214,42 +216,42 @@ public void testInvalidCharacterReferenceHexa() throws Exception {
* @throws java.lang.Exception if any.
*/
@Test
- public void testValidCharacterReferenceHexa() throws Exception {
+ void validCharacterReferenceHexa() throws Exception {
MXParser parser = new MXParser();
String input =
"
Ȁᄁ�𐀀";
parser.setInput(new StringReader(input));
- try {
- assertEquals(XmlPullParser.START_TAG, parser.nextToken());
- assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
- assertEquals(0x9, parser.getText().codePointAt(0));
- assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
- assertEquals(0xA, parser.getText().codePointAt(0));
- assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
- assertEquals(0xD, parser.getText().codePointAt(0));
- assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
- assertEquals(0x20, parser.getText().codePointAt(0));
- assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
- assertEquals(0x200, parser.getText().codePointAt(0));
- assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
- assertEquals(0xD7FF, parser.getText().codePointAt(0));
- assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
- assertEquals(0xE000, parser.getText().codePointAt(0));
- assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
- assertEquals(0xFFA2, parser.getText().codePointAt(0));
- assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
- assertEquals(0xFFFD, parser.getText().codePointAt(0));
- assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
- assertEquals(0x10000, parser.getText().codePointAt(0));
- assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
- assertEquals(0x10FFFD, parser.getText().codePointAt(0));
- assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
- assertEquals(0x10FFFF, parser.getText().codePointAt(0));
- assertEquals(XmlPullParser.END_TAG, parser.nextToken());
- } catch (XmlPullParserException e) {
- fail("Should success since the input represents all legal character references");
- }
+ Assertions.assertDoesNotThrow(
+ () -> {
+ assertEquals(XmlPullParser.START_TAG, parser.nextToken());
+ assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
+ assertEquals(0x9, parser.getText().codePointAt(0));
+ assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
+ assertEquals(0xA, parser.getText().codePointAt(0));
+ assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
+ assertEquals(0xD, parser.getText().codePointAt(0));
+ assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
+ assertEquals(0x20, parser.getText().codePointAt(0));
+ assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
+ assertEquals(0x200, parser.getText().codePointAt(0));
+ assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
+ assertEquals(0xD7FF, parser.getText().codePointAt(0));
+ assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
+ assertEquals(0xE000, parser.getText().codePointAt(0));
+ assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
+ assertEquals(0xFFA2, parser.getText().codePointAt(0));
+ assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
+ assertEquals(0xFFFD, parser.getText().codePointAt(0));
+ assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
+ assertEquals(0x10000, parser.getText().codePointAt(0));
+ assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
+ assertEquals(0x10FFFD, parser.getText().codePointAt(0));
+ assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
+ assertEquals(0x10FFFF, parser.getText().codePointAt(0));
+ assertEquals(XmlPullParser.END_TAG, parser.nextToken());
+ },
+ "Should success since the input represents all legal character references");
}
/**
@@ -258,7 +260,7 @@ public void testValidCharacterReferenceHexa() throws Exception {
* @throws java.lang.Exception if any.
*/
@Test
- public void testInvalidCharacterReferenceDecimal() throws Exception {
+ void invalidCharacterReferenceDecimal() throws Exception {
MXParser parser = new MXParser();
String input = "";
parser.setInput(new StringReader(input));
@@ -278,42 +280,42 @@ public void testInvalidCharacterReferenceDecimal() throws Exception {
* @throws java.lang.Exception if any.
*/
@Test
- public void testValidCharacterReferenceDecimal() throws Exception {
+ void validCharacterReferenceDecimal() throws Exception {
MXParser parser = new MXParser();
String input =
"
Ȁᄁ�𐀀";
parser.setInput(new StringReader(input));
- try {
- assertEquals(XmlPullParser.START_TAG, parser.nextToken());
- assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
- assertEquals(9, parser.getText().codePointAt(0));
- assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
- assertEquals(10, parser.getText().codePointAt(0));
- assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
- assertEquals(13, parser.getText().codePointAt(0));
- assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
- assertEquals(32, parser.getText().codePointAt(0));
- assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
- assertEquals(512, parser.getText().codePointAt(0));
- assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
- assertEquals(55295, parser.getText().codePointAt(0));
- assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
- assertEquals(57344, parser.getText().codePointAt(0));
- assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
- assertEquals(65442, parser.getText().codePointAt(0));
- assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
- assertEquals(65533, parser.getText().codePointAt(0));
- assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
- assertEquals(65536, parser.getText().codePointAt(0));
- assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
- assertEquals(1114109, parser.getText().codePointAt(0));
- assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
- assertEquals(1114111, parser.getText().codePointAt(0));
- assertEquals(XmlPullParser.END_TAG, parser.nextToken());
- } catch (XmlPullParserException e) {
- fail("Should success since the input represents all legal character references");
- }
+ Assertions.assertDoesNotThrow(
+ () -> {
+ assertEquals(XmlPullParser.START_TAG, parser.nextToken());
+ assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
+ assertEquals(9, parser.getText().codePointAt(0));
+ assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
+ assertEquals(10, parser.getText().codePointAt(0));
+ assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
+ assertEquals(13, parser.getText().codePointAt(0));
+ assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
+ assertEquals(32, parser.getText().codePointAt(0));
+ assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
+ assertEquals(512, parser.getText().codePointAt(0));
+ assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
+ assertEquals(55295, parser.getText().codePointAt(0));
+ assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
+ assertEquals(57344, parser.getText().codePointAt(0));
+ assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
+ assertEquals(65442, parser.getText().codePointAt(0));
+ assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
+ assertEquals(65533, parser.getText().codePointAt(0));
+ assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
+ assertEquals(65536, parser.getText().codePointAt(0));
+ assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
+ assertEquals(1114109, parser.getText().codePointAt(0));
+ assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
+ assertEquals(1114111, parser.getText().codePointAt(0));
+ assertEquals(XmlPullParser.END_TAG, parser.nextToken());
+ },
+ "Should success since the input represents all legal character references");
}
/**
@@ -322,7 +324,7 @@ public void testValidCharacterReferenceDecimal() throws Exception {
* @throws java.lang.Exception if any.
*/
@Test
- public void testParserPosition() throws Exception {
+ void parserPosition() throws Exception {
String input =
" \n \tnnn\n";
@@ -350,7 +352,7 @@ public void testParserPosition() throws Exception {
}
@Test
- public void testProcessingInstruction() throws Exception {
+ void processingInstruction() throws Exception {
String input = "nnn";
MXParser parser = new MXParser();
@@ -368,19 +370,17 @@ public void testProcessingInstruction() throws Exception {
* @throws java.lang.Exception if any.
*/
@Test
- public void testProcessingInstructionsContainingXml() throws Exception {
- StringBuffer sb = new StringBuffer();
+ void processingInstructionsContainingXml() throws Exception {
- sb.append("");
- sb.append("\n");
- sb.append(" \n");
- sb.append(" \n");
- sb.append(" ?>\n");
- sb.append("");
+ String sb = "" + "\n"
+ + " \n"
+ + " \n"
+ + " ?>\n"
+ + "";
MXParser parser = new MXParser();
- parser.setInput(new StringReader(sb.toString()));
+ parser.setInput(new StringReader(sb));
assertEquals(XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken());
assertEquals(XmlPullParser.START_TAG, parser.nextToken());
@@ -396,16 +396,14 @@ public void testProcessingInstructionsContainingXml() throws Exception {
* @throws java.lang.Exception if any.
*/
@Test
- public void testMalformedProcessingInstructionsContainingXmlNoClosingQuestionMark() throws Exception {
- StringBuffer sb = new StringBuffer();
- sb.append("\n");
- sb.append("\n");
- sb.append("\n");
- sb.append(" >\n");
+ void malformedProcessingInstructionsContainingXmlNoClosingQuestionMark() throws Exception {
+ String sb = "\n" + "\n"
+ + "\n"
+ + " >\n";
MXParser parser = new MXParser();
- parser.setInput(new StringReader(sb.toString()));
+ parser.setInput(new StringReader(sb));
try {
assertEquals(XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken());
@@ -423,17 +421,15 @@ public void testMalformedProcessingInstructionsContainingXmlNoClosingQuestionMar
}
@Test
- public void testSubsequentProcessingInstructionShort() throws Exception {
- StringBuffer sb = new StringBuffer();
+ void subsequentProcessingInstructionShort() throws Exception {
- sb.append("");
- sb.append("");
- sb.append("");
- sb.append("");
- sb.append("");
+ String sb = "" + ""
+ + ""
+ + ""
+ + "";
MXParser parser = new MXParser();
- parser.setInput(new StringReader(sb.toString()));
+ parser.setInput(new StringReader(sb));
assertEquals(XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken());
assertEquals(XmlPullParser.START_TAG, parser.nextToken());
@@ -448,8 +444,8 @@ public void testSubsequentProcessingInstructionShort() throws Exception {
* @throws java.lang.Exception if any.
*/
@Test
- public void testSubsequentProcessingInstructionMoreThan8k() throws Exception {
- StringBuffer sb = new StringBuffer();
+ void subsequentProcessingInstructionMoreThan8k() throws Exception {
+ StringBuilder sb = new StringBuilder();
sb.append("");
sb.append("");
@@ -492,18 +488,17 @@ public void testSubsequentProcessingInstructionMoreThan8k() throws Exception {
* @throws java.lang.Exception if any.
*/
@Test
- public void testLargeText_NoOverflow() throws Exception {
- StringBuffer sb = new StringBuffer();
- sb.append("");
- sb.append("");
- // Anything above 33,554,431 would fail without a fix for
- // https://web.archive.org/web/20070831191548/http://www.extreme.indiana.edu/bugzilla/show_bug.cgi?id=228
- // with java.io.IOException: error reading input, returned 0
- sb.append(new String(new char[33554432]));
- sb.append("");
+ void largeTextNoOverflow() throws Exception {
+ String sb = "" + ""
+ +
+ // Anything above 33,554,431 would fail without a fix for
+ // https://web.archive.org/web/20070831191548/http://www.extreme.indiana.edu/bugzilla/show_bug.cgi?id=228
+ // with java.io.IOException: error reading input, returned 0
+ new String(new char[33554432])
+ + "";
MXParser parser = new MXParser();
- parser.setInput(new StringReader(sb.toString()));
+ parser.setInput(new StringReader(sb));
assertEquals(XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken());
assertEquals(XmlPullParser.START_TAG, parser.nextToken());
@@ -517,7 +512,7 @@ public void testLargeText_NoOverflow() throws Exception {
* @throws java.lang.Exception if any.
*/
@Test
- public void testMalformedProcessingInstructionAfterTag() throws Exception {
+ void malformedProcessingInstructionAfterTag() throws Exception {
MXParser parser = new MXParser();
String input = ">";
@@ -543,7 +538,7 @@ public void testMalformedProcessingInstructionAfterTag() throws Exception {
* @throws java.lang.Exception if any.
*/
@Test
- public void testMalformedProcessingInstructionBeforeTag() throws Exception {
+ void malformedProcessingInstructionBeforeTag() throws Exception {
MXParser parser = new MXParser();
String input = ">";
@@ -569,14 +564,12 @@ public void testMalformedProcessingInstructionBeforeTag() throws Exception {
* @throws java.lang.Exception if any.
*/
@Test
- public void testMalformedProcessingInstructionSpaceBeforeName() throws Exception {
+ void malformedProcessingInstructionSpaceBeforeName() throws Exception {
MXParser parser = new MXParser();
- StringBuilder sb = new StringBuilder();
- sb.append(" shouldhavenospace>");
- sb.append("");
+ String sb = " shouldhavenospace>" + "";
- parser.setInput(new StringReader(sb.toString()));
+ parser.setInput(new StringReader(sb));
try {
assertEquals(XmlPullParser.PROCESSING_INSTRUCTION, parser.next());
@@ -599,14 +592,12 @@ public void testMalformedProcessingInstructionSpaceBeforeName() throws Exception
* @throws java.lang.Exception if any.
*/
@Test
- public void testMalformedProcessingInstructionNoClosingQuestionMark() throws Exception {
+ void malformedProcessingInstructionNoClosingQuestionMark() throws Exception {
MXParser parser = new MXParser();
- StringBuilder sb = new StringBuilder();
- sb.append("");
- sb.append("");
+ String sb = "" + "";
- parser.setInput(new StringReader(sb.toString()));
+ parser.setInput(new StringReader(sb));
try {
assertEquals(XmlPullParser.PROCESSING_INSTRUCTION, parser.next());
@@ -628,14 +619,12 @@ public void testMalformedProcessingInstructionNoClosingQuestionMark() throws Exc
* @throws java.lang.Exception if any.
*/
@Test
- public void testSubsequentMalformedProcessingInstructionNoClosingQuestionMark() throws Exception {
+ void subsequentMalformedProcessingInstructionNoClosingQuestionMark() throws Exception {
MXParser parser = new MXParser();
- StringBuilder sb = new StringBuilder();
- sb.append("");
- sb.append("");
+ String sb = "" + "";
- parser.setInput(new StringReader(sb.toString()));
+ parser.setInput(new StringReader(sb));
try {
assertEquals(XmlPullParser.START_TAG, parser.next());
@@ -657,13 +646,11 @@ public void testSubsequentMalformedProcessingInstructionNoClosingQuestionMark()
* @throws java.lang.Exception if any.
*/
@Test
- public void testSubsequentAbortedProcessingInstruction() throws Exception {
+ void subsequentAbortedProcessingInstruction() throws Exception {
MXParser parser = new MXParser();
- StringBuilder sb = new StringBuilder();
- sb.append("");
- sb.append("" + "");
- sb.append(" ";
- try {
- MXParser parser = new MXParser();
- parser.setInput(new StringReader(input));
- parser.defineEntityReplacementText("nbsp", " ");
-
- assertEquals(XmlPullParser.START_TAG, parser.nextToken());
- assertEquals("p", parser.getName());
- assertEquals(XmlPullParser.COMMENT, parser.nextToken());
- assertEquals(" a pagebreak: ", parser.getText());
- assertEquals(XmlPullParser.COMMENT, parser.nextToken());
- assertEquals(" PB ", parser.getText());
- assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
- assertEquals("\u00A0", parser.getText());
- assertEquals("#160", parser.getName());
- assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
- assertEquals(" ", parser.getText());
- assertEquals("nbsp", parser.getName());
- assertEquals(XmlPullParser.START_TAG, parser.nextToken());
- assertEquals("unknown", parser.getName());
- assertEquals(XmlPullParser.END_TAG, parser.nextToken());
- assertEquals("unknown", parser.getName());
- assertEquals(XmlPullParser.END_TAG, parser.nextToken());
- assertEquals("p", parser.getName());
- assertEquals(XmlPullParser.END_DOCUMENT, parser.nextToken());
- } catch (XmlPullParserException e) {
- fail("should not raise exception: " + e);
- }
+ Assertions.assertDoesNotThrow(
+ () -> {
+ MXParser parser = new MXParser();
+ parser.setInput(new StringReader(input));
+ parser.defineEntityReplacementText("nbsp", " ");
+
+ assertEquals(XmlPullParser.START_TAG, parser.nextToken());
+ assertEquals("p", parser.getName());
+ assertEquals(XmlPullParser.COMMENT, parser.nextToken());
+ assertEquals(" a pagebreak: ", parser.getText());
+ assertEquals(XmlPullParser.COMMENT, parser.nextToken());
+ assertEquals(" PB ", parser.getText());
+ assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
+ assertEquals("\u00A0", parser.getText());
+ assertEquals("#160", parser.getName());
+ assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
+ assertEquals(" ", parser.getText());
+ assertEquals("nbsp", parser.getName());
+ assertEquals(XmlPullParser.START_TAG, parser.nextToken());
+ assertEquals("unknown", parser.getName());
+ assertEquals(XmlPullParser.END_TAG, parser.nextToken());
+ assertEquals("unknown", parser.getName());
+ assertEquals(XmlPullParser.END_TAG, parser.nextToken());
+ assertEquals("p", parser.getName());
+ assertEquals(XmlPullParser.END_DOCUMENT, parser.nextToken());
+ },
+ "should not raise exception: ");
}
/**
* Ensures correct replacements inside the internal PC array when the new copied array size is shorter than
* previous ones.
- *
+ *
* Regression test: assure same behavior of MXParser from plexus-utils 3.3.0.
*
* @throws IOException if any.
@@ -1303,50 +1284,50 @@ public void testEntityReplacement() throws IOException {
* @since 3.4.2
*/
@Test
- public void testReplacementInPCArrayWithShorterCharArray() throws IOException {
+ void replacementInPCArrayWithShorterCharArray() throws IOException {
String input = "]>"
+ "";
- try {
- MXParser parser = new MXParser();
- parser.setInput(new StringReader(new String(input.getBytes(), "ISO-8859-1")));
- parser.defineEntityReplacementText("foo", "ř");
- parser.defineEntityReplacementText("tritPos", "𝟭");
-
- assertEquals(XmlPullParser.DOCDECL, parser.nextToken());
- assertEquals(" test []", parser.getText());
- assertEquals(XmlPullParser.START_TAG, parser.nextToken());
- assertEquals("section", parser.getName());
- assertEquals(1, parser.getAttributeCount());
- assertEquals("name", parser.getAttributeName(0));
- assertEquals("&ř𝟭", parser.getAttributeValue(0));
- assertEquals(XmlPullParser.START_TAG, parser.nextToken());
- assertEquals("
", parser.getText());
- assertEquals("p", parser.getName());
- assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
- assertEquals("&", parser.getText());
- assertEquals("amp", parser.getName());
- assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
- assertEquals("ř", parser.getText());
- assertEquals("foo", parser.getName());
- assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
- assertEquals("𝟭", parser.getText());
- assertEquals("tritPos", parser.getName());
- assertEquals(XmlPullParser.END_TAG, parser.nextToken());
- assertEquals("p", parser.getName());
- assertEquals(XmlPullParser.END_TAG, parser.nextToken());
- assertEquals("section", parser.getName());
- assertEquals(XmlPullParser.END_DOCUMENT, parser.nextToken());
- } catch (XmlPullParserException e) {
- fail("should not raise exception: " + e);
- }
+ Assertions.assertDoesNotThrow(
+ () -> {
+ MXParser parser = new MXParser();
+ parser.setInput(new StringReader(new String(input.getBytes(), StandardCharsets.ISO_8859_1)));
+ parser.defineEntityReplacementText("foo", "ř");
+ parser.defineEntityReplacementText("tritPos", "𝟭");
+
+ assertEquals(XmlPullParser.DOCDECL, parser.nextToken());
+ assertEquals(" test []", parser.getText());
+ assertEquals(XmlPullParser.START_TAG, parser.nextToken());
+ assertEquals("section", parser.getName());
+ assertEquals(1, parser.getAttributeCount());
+ assertEquals("name", parser.getAttributeName(0));
+ assertEquals("&ř𝟭", parser.getAttributeValue(0));
+ assertEquals(XmlPullParser.START_TAG, parser.nextToken());
+ assertEquals("
", parser.getText());
+ assertEquals("p", parser.getName());
+ assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
+ assertEquals("&", parser.getText());
+ assertEquals("amp", parser.getName());
+ assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
+ assertEquals("ř", parser.getText());
+ assertEquals("foo", parser.getName());
+ assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
+ assertEquals("𝟭", parser.getText());
+ assertEquals("tritPos", parser.getName());
+ assertEquals(XmlPullParser.END_TAG, parser.nextToken());
+ assertEquals("p", parser.getName());
+ assertEquals(XmlPullParser.END_TAG, parser.nextToken());
+ assertEquals("section", parser.getName());
+ assertEquals(XmlPullParser.END_DOCUMENT, parser.nextToken());
+ },
+ "should not raise exception: ");
}
/**
* Ensures emoji can be parsed correctly
*/
@Test
- public void testUnicode() throws IOException {
+ void unicode() throws IOException {
String input = "";
try {
diff --git a/src/test/java/org/codehaus/plexus/util/xml/pull/MXSerializerTest.java b/src/test/java/org/codehaus/plexus/util/xml/pull/MXSerializerTest.java
index 0b1d3d7..abfcb62 100644
--- a/src/test/java/org/codehaus/plexus/util/xml/pull/MXSerializerTest.java
+++ b/src/test/java/org/codehaus/plexus/util/xml/pull/MXSerializerTest.java
@@ -12,7 +12,7 @@
class MXSerializerTest {
@Test
- void testSerialize() throws Exception {
+ void serialize() throws Exception {
StringWriter writer = new StringWriter();
@@ -33,7 +33,7 @@ void testSerialize() throws Exception {
}
@Test
- void testDeserialize() throws Exception {
+ void deserialize() throws Exception {
MXParser parser = new MXParser();
parser.setInput(new StringReader(expectedOutput()));
int eventType = parser.getEventType();
@@ -44,24 +44,21 @@ void testDeserialize() throws Exception {
}
private String expectedOutput() {
- StringBuilder out = new StringBuilder();
- out.append("");
- out.append("");
- out.append("BACKSPACE: ");
- out.append("CHARACTER TABULATION: \t");
- out.append("LINE FEED (LF): \n");
- out.append("LINE TABULATION: ");
- out.append("CARRIAGE RETURN (CR): \r");
- out.append("SHIFT IN: ");
- out.append("");
- return out.toString();
+ return "" + ""
+ + "BACKSPACE: "
+ + "CHARACTER TABULATION: \t"
+ + "LINE FEED (LF): \n"
+ + "LINE TABULATION: "
+ + "CARRIAGE RETURN (CR): \r"
+ + "SHIFT IN: "
+ + "";
}
/**
* Tests MJAVADOC-793.
*/
@Test
- public void testWriteNullValues() throws IOException {
+ void writeNullValues() throws IOException {
// should be no-ops
new MXSerializer().writeElementContent(null, null);
new MXSerializer().writeAttributeValue(null, null);
diff --git a/src/test/java/org/codehaus/plexus/util/xml/pull/eduni_misc_Test_BjoernHoehrmannviaHST2013_09_18_Test.java b/src/test/java/org/codehaus/plexus/util/xml/pull/eduni_misc_Test_BjoernHoehrmannviaHST2013_09_18_Test.java
index 65286c5..a419ac0 100644
--- a/src/test/java/org/codehaus/plexus/util/xml/pull/eduni_misc_Test_BjoernHoehrmannviaHST2013_09_18_Test.java
+++ b/src/test/java/org/codehaus/plexus/util/xml/pull/eduni_misc_Test_BjoernHoehrmannviaHST2013_09_18_Test.java
@@ -9,6 +9,7 @@
import java.nio.charset.StandardCharsets;
import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -33,7 +34,7 @@ public class eduni_misc_Test_BjoernHoehrmannviaHST2013_09_18_Test {
*
setUp.
*/
@BeforeEach
- public void setUp() {
+ void setUp() {
parser = new MXParser();
}
@@ -47,7 +48,7 @@ public void setUp() {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testhst_bh_001() throws IOException {
+ void testhst_bh_001() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "001.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -68,7 +69,7 @@ public void testhst_bh_001() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testhst_bh_002() throws IOException {
+ void testhst_bh_002() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "002.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -89,7 +90,7 @@ public void testhst_bh_002() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testhst_bh_003() throws IOException {
+ void testhst_bh_003() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "003.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -110,7 +111,7 @@ public void testhst_bh_003() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testhst_bh_004() throws IOException {
+ void testhst_bh_004() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "004.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
@@ -133,7 +134,8 @@ public void testhst_bh_004() throws IOException {
*
* NOTE: This test is SKIPPED as MXParser do not supports DOCDECL parsing.
*/
- // @Test
+ @Test
+ @Disabled
public void testhst_bh_005() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "005.xml"))) {
parser.setInput(reader);
@@ -156,7 +158,8 @@ public void testhst_bh_005() throws IOException {
*
* NOTE: This test is SKIPPED as MXParser do not supports DOCDECL parsing.
*/
- // @Test
+ @Test
+ @Disabled
public void testhst_bh_006() throws IOException {
try (Reader reader = new FileReader(new File(testResourcesDir, "006.xml"))) {
parser.setInput(reader);
@@ -178,7 +181,7 @@ public void testhst_bh_006() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testhst_lhs_007() throws IOException {
+ void testhst_lhs_007() throws IOException {
try (FileInputStream is = new FileInputStream(new File(testResourcesDir, "007.xml"));
InputStreamReader reader = new InputStreamReader(is, StandardCharsets.UTF_8)) {
parser.setInput(reader);
@@ -200,7 +203,7 @@ public void testhst_lhs_007() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testhst_lhs_008() throws IOException {
+ void testhst_lhs_008() throws IOException {
try (FileInputStream is = new FileInputStream(new File(testResourcesDir, "008.xml"));
InputStreamReader reader = new InputStreamReader(is, StandardCharsets.UTF_16)) {
parser.setInput(reader);
@@ -222,7 +225,7 @@ public void testhst_lhs_008() throws IOException {
* @throws java.io.IOException if there is an I/O error
*/
@Test
- public void testhst_lhs_009() throws IOException {
+ void testhst_lhs_009() throws IOException {
try (FileInputStream is = new FileInputStream(new File(testResourcesDir, "009.xml"));
InputStreamReader reader = new InputStreamReader(is, StandardCharsets.UTF_8)) {
parser.setInput(reader);
From d518e1a57670cf9765341de74c0b1b492ae2f335 Mon Sep 17 00:00:00 2001
From: Sylwester Lachiewicz
Date: Mon, 16 Dec 2024 00:25:31 +0100
Subject: [PATCH 2/2] Cleanup tests and drop dependency to plexus-utils
---
pom.xml | 6 --
.../util/xml/PrettyPrintXMLWriterTest.java | 37 +++++-----
.../codehaus/plexus/util/xml/TestUtils.java | 47 +++++++++++++
.../plexus/util/xml/XmlStreamReaderTest.java | 11 ++-
.../plexus/util/xml/XmlStreamWriterTest.java | 3 +-
.../codehaus/plexus/util/xml/XmlUtilTest.java | 68 ++++++-------------
.../plexus/util/xml/XmlWriterUtilTest.java | 28 ++++----
.../codehaus/plexus/util/xml/Xpp3DomTest.java | 37 ++++------
.../plexus/util/xml/pull/MXParserTest.java | 10 +--
9 files changed, 118 insertions(+), 129 deletions(-)
create mode 100644 src/test/java/org/codehaus/plexus/util/xml/TestUtils.java
diff --git a/pom.xml b/pom.xml
index 1b9dbcc..38745b0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -70,12 +70,6 @@ limitations under the License.
junit-jupiter-api
test
-
- org.codehaus.plexus
- plexus-utils
- 4.0.2
- test
-
diff --git a/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java b/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java
index 6c7736f..c5d8bd9 100644
--- a/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java
+++ b/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java
@@ -26,9 +26,9 @@
import java.nio.file.Files;
import java.util.NoSuchElementException;
-import org.codehaus.plexus.util.StringUtils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -172,6 +172,7 @@ void testendElementAlreadyClosed() {
*
* @throws IOException if an I/O error occurs
*/
+ @Disabled("This test is only relevant on JDK 1.7, which is not supported anymore")
@Test
void issue51DetectJava7ConcatenationBug() throws IOException {
File dir = new File("target/test-xml");
@@ -179,13 +180,11 @@ void issue51DetectJava7ConcatenationBug() throws IOException {
assertTrue(dir.mkdir(), "cannot create directory test-xml");
}
File xmlFile = new File(dir, "test-issue-51.xml");
- OutputStreamWriter osw =
- new OutputStreamWriter(Files.newOutputStream(xmlFile.toPath()), StandardCharsets.UTF_8);
- writer = new PrettyPrintXMLWriter(osw);
int iterations = 20000;
-
- try {
+ try (OutputStreamWriter osw =
+ new OutputStreamWriter(Files.newOutputStream(xmlFile.toPath()), StandardCharsets.UTF_8)) {
+ writer = new PrettyPrintXMLWriter(osw);
for (int i = 0; i < iterations; ++i) {
writer.startElement(Tag.DIV.toString() + i);
writer.addAttribute("class", "someattribute");
@@ -195,10 +194,6 @@ void issue51DetectJava7ConcatenationBug() throws IOException {
}
} catch (NoSuchElementException e) {
fail("Should not throw a NoSuchElementException");
- } finally {
- if (osw != null) {
- osw.close();
- }
}
}
@@ -237,29 +232,29 @@ private String expectedResult(String lineSeparator) {
}
private String expectedResult(String lineIndenter, String lineSeparator) {
- return "" + lineSeparator + StringUtils.repeat(lineIndenter, 1)
- + "" + lineSeparator + StringUtils.repeat(lineIndenter, 2)
+ return "" + lineSeparator + lineIndenter
+ + "" + lineSeparator + lineIndenter + lineIndenter
+ "title"
+ lineSeparator
- + StringUtils.repeat(lineIndenter, 2)
+ + lineIndenter + lineIndenter
+ ""
+ lineSeparator
- + StringUtils.repeat(lineIndenter, 2)
+ + lineIndenter + lineIndenter
+ ""
+ lineSeparator
- + StringUtils.repeat(lineIndenter, 1)
- + "" + lineSeparator + StringUtils.repeat(lineIndenter, 1)
- + "" + lineSeparator + StringUtils.repeat(lineIndenter, 2)
+ + lineIndenter
+ + "" + lineSeparator + lineIndenter
+ + "" + lineSeparator + lineIndenter + lineIndenter
+ "Paragraph 1, line 1. Paragraph 1, line 2.
"
+ lineSeparator
- + StringUtils.repeat(lineIndenter, 2)
+ + lineIndenter + lineIndenter
+ ""
+ lineSeparator
- + StringUtils.repeat(lineIndenter, 3)
+ + lineIndenter + lineIndenter + lineIndenter
+ "
Section title
"
+ lineSeparator
- + StringUtils.repeat(lineIndenter, 2)
- + "" + lineSeparator + StringUtils.repeat(lineIndenter, 1)
+ + lineIndenter + lineIndenter
+ + "" + lineSeparator + lineIndenter
+ "" + lineSeparator + "";
}
}
diff --git a/src/test/java/org/codehaus/plexus/util/xml/TestUtils.java b/src/test/java/org/codehaus/plexus/util/xml/TestUtils.java
new file mode 100644
index 0000000..b824d1e
--- /dev/null
+++ b/src/test/java/org/codehaus/plexus/util/xml/TestUtils.java
@@ -0,0 +1,47 @@
+package org.codehaus.plexus.util.xml;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringWriter;
+
+public class TestUtils {
+
+ public static String readAllFrom(Reader input) throws IOException {
+ StringWriter output = new StringWriter();
+ char[] buffer = new char[16384];
+ int n = 0;
+ while (0 <= (n = input.read(buffer))) {
+ output.write(buffer, 0, n);
+ }
+ output.flush();
+ return output.toString();
+ }
+ /**
+ *
+ * How many times is the substring in the larger String.
+ *
+ *
+ * null
returns 0
.
+ *
+ *
+ * @param str the String to check
+ * @param sub the substring to count
+ * @return the number of occurrences, 0 if the String is null
+ * @throws NullPointerException if sub is null
+ */
+ public static int countMatches(String str, String sub) {
+ if (sub.isEmpty()) {
+ return 0;
+ }
+ if (str == null) {
+ return 0;
+ }
+ int count = 0;
+ int idx = 0;
+ while ((idx = str.indexOf(sub, idx)) != -1) {
+ count++;
+ idx += sub.length();
+ }
+ return count;
+ }
+}
diff --git a/src/test/java/org/codehaus/plexus/util/xml/XmlStreamReaderTest.java b/src/test/java/org/codehaus/plexus/util/xml/XmlStreamReaderTest.java
index 0ce093e..438a139 100644
--- a/src/test/java/org/codehaus/plexus/util/xml/XmlStreamReaderTest.java
+++ b/src/test/java/org/codehaus/plexus/util/xml/XmlStreamReaderTest.java
@@ -21,10 +21,10 @@
import java.io.InputStream;
import java.io.SequenceInputStream;
-import org.codehaus.plexus.util.IOUtil;
import org.junit.jupiter.api.Test;
import org.opentest4j.AssertionFailedError;
+import static org.codehaus.plexus.util.xml.TestUtils.readAllFrom;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -68,8 +68,7 @@ private static String createXmlContent(String text, String encoding) {
if (encoding != null) {
xmlDecl = "";
}
- String xml = xmlDecl + "\n" + text + "";
- return xml;
+ return xmlDecl + "\n" + text + "";
}
private static void checkXmlContent(String xml, String encoding) throws IOException {
@@ -86,8 +85,7 @@ private static void checkXmlContent(String xml, String encoding, byte... bom) th
XmlStreamReader reader = new XmlStreamReader(in);
assertEquals(encoding, reader.getEncoding());
- String result = IOUtil.toString(reader);
- assertEquals(xml, result);
+ assertEquals(xml, readAllFrom(reader));
}
private static void checkXmlStreamReader(String text, String encoding, String effectiveEncoding)
@@ -228,10 +226,9 @@ void ebcdicEncoding() throws IOException {
/**
* testInappropriateEncoding.
*
- * @throws java.io.IOException if any.
*/
@Test
- void inappropriateEncoding() throws IOException {
+ void inappropriateEncoding() {
// expected failure, since the encoding does not contain some characters
assertThrows(
AssertionFailedError.class,
diff --git a/src/test/java/org/codehaus/plexus/util/xml/XmlStreamWriterTest.java b/src/test/java/org/codehaus/plexus/util/xml/XmlStreamWriterTest.java
index 6fa531b..2e59ab9 100644
--- a/src/test/java/org/codehaus/plexus/util/xml/XmlStreamWriterTest.java
+++ b/src/test/java/org/codehaus/plexus/util/xml/XmlStreamWriterTest.java
@@ -52,8 +52,7 @@ private static String createXmlContent(String text, String encoding) {
if (encoding != null) {
xmlDecl = "";
}
- String xml = xmlDecl + "\n" + text + "";
- return xml;
+ return xmlDecl + "\n" + text + "";
}
private static void checkXmlContent(String xml, String encoding) throws IOException {
diff --git a/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java b/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java
index e6f9f59..d0361dd 100644
--- a/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java
+++ b/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java
@@ -16,19 +16,12 @@
* limitations under the License.
*/
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.Reader;
-import java.io.StringWriter;
-import java.io.Writer;
+import java.io.*;
import java.nio.file.Files;
-import org.codehaus.plexus.util.IOUtil;
-import org.codehaus.plexus.util.StringUtils;
import org.junit.jupiter.api.Test;
+import static org.codehaus.plexus.util.xml.TestUtils.readAllFrom;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -73,20 +66,14 @@ void prettyFormatInputStreamOutputStream() throws Exception {
File testDocument = new File(getBasedir(), "src/test/resources/testDocument.xhtml");
assertTrue(testDocument.exists());
- InputStream is = null;
- OutputStream os = null;
- try {
- is = Files.newInputStream(testDocument.toPath());
- os = Files.newOutputStream(getTestOutputFile("target/test/prettyFormatTestDocumentOutputStream.xml")
- .toPath());
-
+ try (InputStream is = Files.newInputStream(testDocument.toPath());
+ OutputStream os =
+ Files.newOutputStream(getTestOutputFile("target/test/prettyFormatTestDocumentOutputStream.xml")
+ .toPath())) {
assertNotNull(is);
assertNotNull(os);
XmlUtil.prettyFormat(is, os);
- } finally {
- IOUtil.close(is);
- IOUtil.close(os);
}
}
@@ -100,19 +87,14 @@ void prettyFormatReaderWriter() throws Exception {
File testDocument = new File(getBasedir(), "src/test/resources/testDocument.xhtml");
assertTrue(testDocument.exists());
- Reader reader = null;
- Writer writer = null;
- try {
- reader = ReaderFactory.newXmlReader(testDocument);
- writer = WriterFactory.newXmlWriter(getTestOutputFile("target/test/prettyFormatTestDocumentWriter.xml"));
+ try (Reader reader = ReaderFactory.newXmlReader(testDocument);
+ Writer writer = WriterFactory.newXmlWriter(
+ getTestOutputFile("target/test/prettyFormatTestDocumentWriter.xml"))) {
assertNotNull(reader);
assertNotNull(writer);
XmlUtil.prettyFormat(reader, writer);
- } finally {
- IOUtil.close(reader);
- IOUtil.close(writer);
}
}
@@ -126,25 +108,22 @@ void prettyFormatString() throws Exception {
File testDocument = new File(getBasedir(), "src/test/resources/testDocument.xhtml");
assertTrue(testDocument.exists());
- Reader reader = null;
- Writer writer = null;
String content;
- try {
- reader = ReaderFactory.newXmlReader(testDocument);
- content = IOUtil.toString(reader);
+ try (Reader reader = ReaderFactory.newXmlReader(testDocument)) {
+ content = readAllFrom(reader);
+ }
- reader = ReaderFactory.newXmlReader(testDocument);
- writer = new StringWriter();
+ String contentPretty;
+ try (Reader reader = ReaderFactory.newXmlReader(testDocument)) {
+ Writer writer = new StringWriter();
XmlUtil.prettyFormat(reader, writer);
- } finally {
- IOUtil.close(reader);
- IOUtil.close(writer);
+ contentPretty = writer.toString();
}
assertNotNull(content);
- int countEOL = StringUtils.countMatches(content, XmlUtil.DEFAULT_LINE_SEPARATOR);
- assertTrue(countEOL < StringUtils.countMatches(writer.toString(), XmlUtil.DEFAULT_LINE_SEPARATOR));
+ int countEOL = TestUtils.countMatches(content, XmlUtil.DEFAULT_LINE_SEPARATOR);
+ assertTrue(countEOL < TestUtils.countMatches(contentPretty, XmlUtil.DEFAULT_LINE_SEPARATOR));
}
/**
@@ -157,19 +136,14 @@ void prettyFormatReaderWriter2() throws Exception {
File testDocument = new File(getBasedir(), "src/test/resources/test.xdoc.xhtml");
assertTrue(testDocument.exists());
- Reader reader = null;
- Writer writer = null;
- try {
- reader = ReaderFactory.newXmlReader(testDocument);
- writer = WriterFactory.newXmlWriter(getTestOutputFile("target/test/prettyFormatTestXdocWriter.xml"));
+ try (Reader reader = ReaderFactory.newXmlReader(testDocument);
+ Writer writer =
+ WriterFactory.newXmlWriter(getTestOutputFile("target/test/prettyFormatTestXdocWriter.xml"))) {
assertNotNull(reader);
assertNotNull(writer);
XmlUtil.prettyFormat(reader, writer);
- } finally {
- IOUtil.close(reader);
- IOUtil.close(writer);
}
}
}
diff --git a/src/test/java/org/codehaus/plexus/util/xml/XmlWriterUtilTest.java b/src/test/java/org/codehaus/plexus/util/xml/XmlWriterUtilTest.java
index ff078f5..7a4cea4 100644
--- a/src/test/java/org/codehaus/plexus/util/xml/XmlWriterUtilTest.java
+++ b/src/test/java/org/codehaus/plexus/util/xml/XmlWriterUtilTest.java
@@ -20,7 +20,6 @@
import java.io.OutputStream;
import java.io.Writer;
-import org.codehaus.plexus.util.StringUtils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -76,7 +75,7 @@ void tearDown() throws Exception {
void writeLineBreakXMLWriter() throws Exception {
XmlWriterUtil.writeLineBreak(xmlWriter);
writer.close();
- assertEquals(1, StringUtils.countMatches(output.toString(), XmlWriterUtil.LS));
+ assertEquals(1, TestUtils.countMatches(output.toString(), XmlWriterUtil.LS));
}
/**
@@ -89,7 +88,7 @@ void writeLineBreakXMLWriter() throws Exception {
void writeLineBreakXMLWriterInt() throws Exception {
XmlWriterUtil.writeLineBreak(xmlWriter, 10);
writer.close();
- assertEquals(10, StringUtils.countMatches(output.toString(), XmlWriterUtil.LS));
+ assertEquals(10, TestUtils.countMatches(output.toString(), XmlWriterUtil.LS));
}
/**
@@ -102,11 +101,8 @@ void writeLineBreakXMLWriterInt() throws Exception {
void writeLineBreakXMLWriterIntInt() throws Exception {
XmlWriterUtil.writeLineBreak(xmlWriter, 10, 2);
writer.close();
- assertEquals(10, StringUtils.countMatches(output.toString(), XmlWriterUtil.LS));
- assertEquals(
- 1,
- StringUtils.countMatches(
- output.toString(), StringUtils.repeat(" ", 2 * XmlWriterUtil.DEFAULT_INDENTATION_SIZE)));
+ assertEquals(10, TestUtils.countMatches(output.toString(), XmlWriterUtil.LS));
+ assertEquals(1, TestUtils.countMatches(output.toString(), " ")); //
}
/**
@@ -119,8 +115,8 @@ void writeLineBreakXMLWriterIntInt() throws Exception {
void writeLineBreakXMLWriterIntIntInt() throws Exception {
XmlWriterUtil.writeLineBreak(xmlWriter, 10, 2, 4);
writer.close();
- assertEquals(10, StringUtils.countMatches(output.toString(), XmlWriterUtil.LS));
- assertEquals(1, StringUtils.countMatches(output.toString(), StringUtils.repeat(" ", 2 * 4)));
+ assertEquals(10, TestUtils.countMatches(output.toString(), XmlWriterUtil.LS));
+ assertEquals(1, TestUtils.countMatches(output.toString(), " "));
}
/**
@@ -210,7 +206,7 @@ void writeCommentXMLWriterString() throws Exception {
*/
@Test
void writeCommentXMLWriterStringInt() throws Exception {
- String indent = StringUtils.repeat(" ", 2 * XmlWriterUtil.DEFAULT_INDENTATION_SIZE);
+ String indent = " ";
XmlWriterUtil.writeComment(xmlWriter, "hello", 2);
writer.close();
@@ -252,7 +248,7 @@ void writeCommentXMLWriterStringInt() throws Exception {
*/
@Test
void writeCommentXMLWriterStringIntInt() throws Exception {
- String repeat = StringUtils.repeat(" ", 2 * 4);
+ String repeat = " ";
XmlWriterUtil.writeComment(xmlWriter, "hello", 2, 4);
writer.close();
@@ -290,7 +286,7 @@ void writeCommentXMLWriterStringIntInt() throws Exception {
*/
@Test
void writeCommentXMLWriterStringIntIntInt() throws Exception {
- String indent = StringUtils.repeat(" ", 2 * 4);
+ String indent = " ";
XmlWriterUtil.writeComment(xmlWriter, "hello", 2, 4, 50);
writer.close();
@@ -338,7 +334,7 @@ void writeCommentTextXMLWriterStringInt() throws Exception {
tearDown();
setUp();
- String indent = StringUtils.repeat(" ", 2 * 2);
+ String indent = " ";
XmlWriterUtil.writeCommentText(
xmlWriter,
@@ -379,7 +375,7 @@ void writeCommentTextXMLWriterStringInt() throws Exception {
*/
@Test
void writeCommentTextXMLWriterStringIntInt() throws Exception {
- String indent = StringUtils.repeat(" ", 2 * 4);
+ String indent = " ";
XmlWriterUtil.writeCommentText(xmlWriter, "hello", 2, 4);
writer.close();
@@ -408,7 +404,7 @@ void writeCommentTextXMLWriterStringIntInt() throws Exception {
*/
@Test
void writeCommentTextXMLWriterStringIntIntInt() throws Exception {
- String indent = StringUtils.repeat(" ", 2 * 4);
+ String indent = " ";
XmlWriterUtil.writeCommentText(xmlWriter, "hello", 2, 4, 50);
writer.close();
diff --git a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomTest.java b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomTest.java
index fdf19dd..5b21385 100644
--- a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomTest.java
+++ b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomTest.java
@@ -189,18 +189,11 @@ void shouldMergeValuesAtTopLevel() {
@Test
void nullAttributeNameOrValue() {
Xpp3Dom t1 = new Xpp3Dom("top");
- try {
- t1.setAttribute("attr", null);
- fail("null attribute values shouldn't be allowed");
- } catch (NullPointerException e) {
- }
- t1.toString();
- try {
- t1.setAttribute(null, "value");
- fail("null attribute names shouldn't be allowed");
- } catch (NullPointerException e) {
- }
- t1.toString();
+ assertThrows(NullPointerException.class, () -> t1.setAttribute("attr", null));
+ assertNotNull(t1.toString());
+
+ assertThrows(NullPointerException.class, () -> t1.setAttribute(null, "value"));
+ assertNotNull(t1.toString());
}
/**
@@ -227,20 +220,14 @@ void equalsIsNullSafe() throws XmlPullParserException, IOException {
Xpp3Dom dom = Xpp3DomBuilder.build(new StringReader(testDom));
Xpp3Dom dom2 = Xpp3DomBuilder.build(new StringReader(testDom));
- try {
- dom2.attributes = new HashMap<>();
- dom2.attributes.put("nullValue", null);
- dom2.attributes.put(null, "nullKey");
- dom2.childList.clear();
- dom2.childList.add(null);
+ dom2.attributes = new HashMap<>();
+ dom2.attributes.put("nullValue", null);
+ dom2.attributes.put(null, "nullKey");
+ dom2.childList.clear();
+ dom2.childList.add(null);
- assertNotEquals(dom, dom2);
- assertNotEquals(dom2, dom);
-
- } catch (NullPointerException ex) {
- ex.printStackTrace();
- fail("\nNullPointerExceptions should not be thrown.");
- }
+ assertNotEquals(dom, dom2);
+ assertNotEquals(dom2, dom);
}
/**
diff --git a/src/test/java/org/codehaus/plexus/util/xml/pull/MXParserTest.java b/src/test/java/org/codehaus/plexus/util/xml/pull/MXParserTest.java
index 9c3e580..68a986c 100644
--- a/src/test/java/org/codehaus/plexus/util/xml/pull/MXParserTest.java
+++ b/src/test/java/org/codehaus/plexus/util/xml/pull/MXParserTest.java
@@ -26,11 +26,11 @@
import java.nio.file.Files;
import java.nio.file.Paths;
-import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.xml.ReaderFactory;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+import static org.codehaus.plexus.util.xml.TestUtils.readAllFrom;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -833,7 +833,7 @@ void xmlDeclVersionEncodingStandaloneNoSpace() throws Exception {
}
/**
- * Issue 163: ...
+ * Issue 163: Issue 163
*
* @throws IOException if IO error.
*
@@ -854,7 +854,7 @@ void encodingISO88591setInputReader() throws IOException {
}
/**
- * Issue 163: ...
+ * Issue 163: Issue 163
*
* @throws IOException if IO error.
*
@@ -880,7 +880,7 @@ private static void assertPosition(int row, int col, MXParser parser) {
}
/**
- * Issue 163: ...
+ * Issue 163: Issue 163
*
* Another case of bug #163: File encoding information is lost after the input file is copied to a String.
*
@@ -893,7 +893,7 @@ void encodingISO88591setStringReader() throws IOException {
try (Reader reader =
ReaderFactory.newXmlReader(new File("src/test/resources/xml", "test-encoding-ISO-8859-1.xml"))) {
MXParser parser = new MXParser();
- String xmlFileContents = IOUtil.toString(reader);
+ String xmlFileContents = readAllFrom(reader);
parser.setInput(new StringReader(xmlFileContents));
while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
;