diff --git a/pom.xml b/pom.xml
index 3443aec..f0fc7da 100644
--- a/pom.xml
+++ b/pom.xml
@@ -49,6 +49,7 @@ limitations under the License.
setUp.
*/ @BeforeEach - public void setUp() { + void setUp() { initWriter(); } @@ -62,7 +61,7 @@ public void setUp() { *tearDown.
*/ @AfterEach - public void tearDown() { + void tearDown() { writer = null; w = null; } @@ -76,7 +75,7 @@ private void initWriter() { *testDefaultPrettyPrintXMLWriter.
*/ @Test - public void testDefaultPrettyPrintXMLWriter() { + void defaultPrettyPrintXMLWriter() { writer.startElement(Tag.HTML.toString()); writeXhtmlHead(writer); @@ -92,7 +91,7 @@ public void testDefaultPrettyPrintXMLWriter() { *testPrettyPrintXMLWriterWithGivenLineSeparator.
*/ @Test - public void testPrettyPrintXMLWriterWithGivenLineSeparator() { + void prettyPrintXMLWriterWithGivenLineSeparator() { writer.setLineSeparator("\n"); writer.startElement(Tag.HTML.toString()); @@ -110,7 +109,7 @@ public void testPrettyPrintXMLWriterWithGivenLineSeparator() { *testPrettyPrintXMLWriterWithGivenLineIndenter.
*/ @Test - public void testPrettyPrintXMLWriterWithGivenLineIndenter() { + void prettyPrintXMLWriterWithGivenLineIndenter() { writer.setLineIndenter(" "); writer.startElement(Tag.HTML.toString()); @@ -128,7 +127,7 @@ public void testPrettyPrintXMLWriterWithGivenLineIndenter() { *testEscapeXmlAttribute.
*/ @Test - public void testEscapeXmlAttribute() { + void escapeXmlAttribute() { // Windows writer.startElement(Tag.DIV.toString()); writer.addAttribute("class", "sect\r\nion"); @@ -154,17 +153,18 @@ public void testEscapeXmlAttribute() { *testendElementAlreadyClosed.
*/ @Test - public void testendElementAlreadyClosed() { - assertThrows(NoSuchElementException.class, () -> { - writer.startElement(Tag.DIV.toString()); - writer.addAttribute("class", "someattribute"); - writer.endElement(); // Tag.DIV closed - writer.endElement(); // Tag.DIV already closed, and there is no other outer tag! - }); + void testendElementAlreadyClosed() { + writer.startElement(Tag.DIV.toString()); + writer.addAttribute("class", "someattribute"); + writer.endElement(); + assertThrows( + NoSuchElementException.class, + () -> // Tag.DIV closed + writer.endElement()); } /** - * Issue #51: https://github.com/codehaus-plexus/plexus-utils/issues/51 Purpose: test if concatenation string + * Issue #51: 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. @@ -173,7 +173,7 @@ public void testendElementAlreadyClosed() { */ @Disabled("This test is only relevant on JDK 1.7, which is not supported anymore") @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"); @@ -231,34 +231,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("Paragraph 1, line 1. Paragraph 1, line 2.
") - .append(lineSeparator); - expected.append(StringUtils.repeat(lineIndenter, 2)) - .append("Paragraph 1, line 1. Paragraph 1, line 2.
" + + lineSeparator + + lineIndenter + + lineIndenter + "+ * How many times is the substring in the larger String. + *
+ *
+ * null
returns 0
.
+ *
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 4ffe7a9..0390ac2 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;
@@ -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";
@@ -68,8 +68,7 @@ private static String createXmlContent(String text, String encoding) {
if (encoding != null) {
xmlDecl = "";
}
- String xml = xmlDecl + "\ntestInappropriateEncoding.
* - * @throws java.io.IOException if any. */ @Test - public void testInappropriateEncoding() throws IOException { + void inappropriateEncoding() { // expected failure, since the encoding does not contain some characters assertThrows( AssertionFailedError.class, @@ -245,7 +242,7 @@ public void testInappropriateEncoding() throws IOException { * @throws java.io.IOException if any. */ @Test - public void testEncodingAttribute() throws IOException { + void encodingAttribute() throws IOException { String xml = "XmlWriterUtilTest class.
@@ -34,7 +34,7 @@ * @version $Id: $Id * @since 3.4.0 */ -public class XmlWriterUtilTest { +class XmlWriterUtilTest { private OutputStream output; private Writer writer; @@ -47,7 +47,7 @@ public class XmlWriterUtilTest { * @throws java.lang.Exception if any. */ @BeforeEach - public void setUp() throws Exception { + void setUp() throws Exception { output = new ByteArrayOutputStream(); writer = new XmlStreamWriter(output); xmlWriter = new PrettyPrintXMLWriter(writer); @@ -59,7 +59,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 +72,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, TestUtils.countMatches(output.toString(), XmlWriterUtil.LS)); } /** @@ -85,10 +85,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, TestUtils.countMatches(output.toString(), XmlWriterUtil.LS)); } /** @@ -98,13 +98,11 @@ 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, TestUtils.countMatches(output.toString(), XmlWriterUtil.LS)); + assertEquals(1, TestUtils.countMatches(output.toString(), " ")); // } /** @@ -114,11 +112,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, TestUtils.countMatches(output.toString(), XmlWriterUtil.LS)); + assertEquals(1, TestUtils.countMatches(output.toString(), " ")); } /** @@ -128,14 +126,14 @@ 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()); + assertEquals(output.toString().length(), XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length()); } /** @@ -145,7 +143,7 @@ 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); @@ -165,14 +163,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(); 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(); @@ -197,8 +195,8 @@ public void testWriteCommentXMLWriterString() 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())); + assertEquals( + output.toString().length(), 2 * (XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length())); } /** @@ -208,8 +206,8 @@ public void testWriteCommentXMLWriterString() throws Exception { * @throws java.lang.Exception if any */ @Test - public void testWriteCommentXMLWriterStringInt() throws Exception { - String indent = StringUtils.repeat(" ", 2 * XmlWriterUtil.DEFAULT_INDENTATION_SIZE); + void writeCommentXMLWriterStringInt() throws Exception { + String indent = " "; XmlWriterUtil.writeComment(xmlWriter, "hello", 2); writer.close(); @@ -218,8 +216,9 @@ public void testWriteCommentXMLWriterStringInt() throws Exception { 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); @@ -237,8 +236,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,8 +248,8 @@ public void testWriteCommentXMLWriterStringInt() throws Exception { * @throws java.lang.Exception if any */ @Test - public void testWriteCommentXMLWriterStringIntInt() throws Exception { - String repeat = StringUtils.repeat(" ", 2 * 4); + void writeCommentXMLWriterStringIntInt() throws Exception { + String repeat = " "; XmlWriterUtil.writeComment(xmlWriter, "hello", 2, 4); writer.close(); @@ -258,8 +258,8 @@ public void testWriteCommentXMLWriterStringIntInt() throws Exception { 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(); @@ -274,8 +274,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,8 +286,8 @@ public void testWriteCommentXMLWriterStringIntInt() throws Exception { * @throws java.lang.Exception if any */ @Test - public void testWriteCommentXMLWriterStringIntIntInt() throws Exception { - String indent = StringUtils.repeat(" ", 2 * 4); + void writeCommentXMLWriterStringIntIntInt() throws Exception { + String indent = " "; XmlWriterUtil.writeComment(xmlWriter, "hello", 2, 4, 50); writer.close(); @@ -294,7 +295,7 @@ public void testWriteCommentXMLWriterStringIntIntInt() throws Exception { 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(); @@ -315,7 +316,7 @@ 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(); @@ -328,13 +329,13 @@ 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(); - String indent = StringUtils.repeat(" ", 2 * 2); + String indent = " "; XmlWriterUtil.writeCommentText( xmlWriter, @@ -374,8 +375,8 @@ public void testWriteCommentTextXMLWriterStringInt() throws Exception { * @throws java.lang.Exception if any */ @Test - public void testWriteCommentTextXMLWriterStringIntInt() throws Exception { - String indent = StringUtils.repeat(" ", 2 * 4); + void writeCommentTextXMLWriterStringIntInt() throws Exception { + String indent = " "; XmlWriterUtil.writeCommentText(xmlWriter, "hello", 2, 4); writer.close(); @@ -393,8 +394,9 @@ public void testWriteCommentTextXMLWriterStringIntInt() throws Exception { 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()); + assertEquals( + output.toString().length(), + 3 * (80 - 1 + XmlWriterUtil.LS.length()) + 4 * 2 * 4 + 2 * XmlWriterUtil.LS.length()); } /** @@ -404,8 +406,8 @@ public void testWriteCommentTextXMLWriterStringIntInt() throws Exception { * @throws java.lang.Exception if any */ @Test - public void testWriteCommentTextXMLWriterStringIntIntInt() throws Exception { - String indent = StringUtils.repeat(" ", 2 * 4); + void writeCommentTextXMLWriterStringIntIntInt() throws Exception { + String indent = " "; XmlWriterUtil.writeCommentText(xmlWriter, "hello", 2, 4, 50); writer.close(); @@ -423,8 +425,9 @@ public void testWriteCommentTextXMLWriterStringIntIntInt() throws Exception { 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()); + assertEquals( + output.toString().length(), + 3 * (50 - 1 + XmlWriterUtil.LS.length()) + 4 * 2 * 4 + 2 * XmlWriterUtil.LS.length()); } /** @@ -434,7 +437,7 @@ 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(); @@ -450,7 +453,7 @@ 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(); @@ -466,7 +469,7 @@ 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. " 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..a490540 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 = "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); @@ -81,7 +81,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); @@ -117,7 +117,7 @@ public void testShouldOverrideAppendAndDeepMerge() { *testShouldPerformSelfOverrideAtTopLevel.
*/ @Test - public void testShouldPerformSelfOverrideAtTopLevel() { + void shouldPerformSelfOverrideAtTopLevel() { // create the dominant DOM Xpp3Dom t1 = new Xpp3Dom("top"); t1.setAttribute("attr", "value"); @@ -143,7 +143,7 @@ public void testShouldPerformSelfOverrideAtTopLevel() { *testShouldMergeValuesAtTopLevelByDefault.
*/ @Test - public void testShouldNotMergeValuesAtTopLevelByDefault() { + void shouldNotMergeValuesAtTopLevelByDefault() { // create the dominant DOM Xpp3Dom t1 = new Xpp3Dom("top"); t1.setAttribute("attr", "value"); @@ -169,7 +169,7 @@ public void testShouldNotMergeValuesAtTopLevelByDefault() { *testShouldMergeValuesAtTopLevel.
*/ @Test - public void testShouldNotMergeValues() { + void shouldNotMergeValues() { // create the dominant DOM Xpp3Dom t1 = new Xpp3Dom("top"); t1.setAttribute("attr", "value"); @@ -192,32 +192,25 @@ public void testShouldNotMergeValues() { *testNullAttributeNameOrValue.
*/ @Test - public void testNullAttributeNameOrValue() { + 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()); } /** *testEquals.
*/ @Test - public void testEquals() { + void equals() { Xpp3Dom dom = new Xpp3Dom("top"); assertEquals(dom, dom); - assertFalse(dom.equals(null)); - assertFalse(dom.equals(new Xpp3Dom(""))); + assertNotEquals(null, dom); + assertNotEquals(new Xpp3Dom(""), dom); } /** @@ -227,7 +220,7 @@ public void testEquals() { * @throws java.io.IOException if any. */ @Test - public void testEqualsIsNullSafe() throws XmlPullParserException, IOException { + void equalsIsNullSafe() throws XmlPullParserException, IOException { String testDom = "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..43279b8 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 @@ -38,7 +38,7 @@ class IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConfo *setUp.
*/ @BeforeEach - public void setUp() { + void setUp() { parser = new MXParser(); } @@ -52,7 +52,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 +73,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 +94,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 +115,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 +136,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 +157,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 +178,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 +199,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 +220,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 +241,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 +262,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 +283,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 +304,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 +325,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 +346,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 +367,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 +388,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 +409,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 +430,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 +451,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 +472,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 +493,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 +514,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 +535,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 +556,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 +577,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 +598,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 +619,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 +640,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) @@ -710,7 +710,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 +732,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..cda5f99 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 @@ -31,7 +31,7 @@ class IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConfo *setUp.
*/ @BeforeEach - public void setUp() { + void setUp() { parser = new MXParser(); } @@ -45,7 +45,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 +67,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 +89,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 +110,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 +131,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 +153,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 +174,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 +195,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) 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 0359b8c..7a817b9 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 @@ -27,12 +27,12 @@ import java.nio.file.Files; import java.nio.file.Paths; -import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.xml.XmlStreamReader; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; +import static org.codehaus.plexus.util.xml.TestUtils.readAllFrom; import static org.junit.jupiter.api.Assertions.*; /** @@ -42,14 +42,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"); @@ -73,7 +73,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"); @@ -97,7 +97,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"); @@ -122,7 +122,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); @@ -141,7 +141,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 = "
* Another case of bug #163: File encoding information is lost after the input file is copied to a String.
*
* @throws IOException if IO error.
@@ -899,25 +899,25 @@ public void testEncodingISO_8859_1_InputStream() throws IOException {
* @since 3.4.2
*/
@Test
- public void testEncodingISO_8859_1_StringReader() throws IOException {
+ void encodingISO88591StringReader() throws IOException {
String xmlFileContents;
try (Reader reader = new XmlStreamReader(Paths.get("src/test/resources/xml", "test-encoding-ISO-8859-1.xml"))) {
- xmlFileContents = IOUtil.toString(reader);
+ xmlFileContents = readAllFrom(reader);
}
- try {
- MXParser parser = new MXParser();
- parser.setInput(new StringReader(xmlFileContents));
- while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
- ;
- assertTrue(true);
- } catch (XmlPullParserException e) {
- fail("should not raise exception: " + e);
- }
+ assertDoesNotThrow(
+ () -> {
+ MXParser parser = new MXParser();
+ parser.setInput(new StringReader(xmlFileContents));
+ while (parser.nextToken() != XmlPullParser.END_DOCUMENT)
+ ;
+ assertTrue(true);
+ },
+ "should not raise exception: ");
}
/**
- * Issue 163: https://github.com/codehaus-plexus/plexus-utils/issues/163
+ * Issue 163: Issue 163
*
* Another case of bug #163: Reader generated with ReaderFactory.newReader and the right file encoding.
*
@@ -926,7 +926,7 @@ public void testEncodingISO_8859_1_StringReader() throws IOException {
* @since 3.5.2
*/
@Test
- public void testEncodingISO_8859_1_newReader() throws IOException {
+ void encodingISO88591NewReader() throws IOException {
// NOTE: if using Files.newBufferedReader(path, StandardCharsets.UTF-8), the reader will throw an exception
// because the decoder created by new InputStreamReader() is lenient while the one created by
// Files.newBufferedReader() is not.
@@ -944,7 +944,7 @@ public void testEncodingISO_8859_1_newReader() throws IOException {
}
/**
- * Issue 163: https://github.com/codehaus-plexus/plexus-utils/issues/163
+ * Issue 163: Issue 163
*
* Another case of bug #163: InputStream supplied with the right file encoding.
*
@@ -953,7 +953,7 @@ public void testEncodingISO_8859_1_newReader() throws IOException {
* @since 3.5.2
*/
@Test
- public void testEncodingISO_8859_1_InputStream_encoded() throws IOException {
+ void encodingISO88591InputStreamEncoded() throws IOException {
try (InputStream input =
Files.newInputStream(Paths.get("src/test/resources/xml", "test-encoding-ISO-8859-1.xml"))) {
MXParser parser = new MXParser();
@@ -967,14 +967,14 @@ public void testEncodingISO_8859_1_InputStream_encoded() throws IOException {
}
/**
- * Issue 163: https://github.com/codehaus-plexus/plexus-utils/issues/163
+ * Issue 163: Issue 163
*
* @throws IOException if IO error.
*
* @since 3.4.1
*/
@Test
- public void testEncodingUTF8_newXmlReader() throws IOException {
+ void encodingUTF8NewXmlReader() throws IOException {
try (Reader reader = new XmlStreamReader(Paths.get("src/test/resources/xml", "test-encoding-ISO-8859-1.xml"))) {
MXParser parser = new MXParser();
parser.setInput(reader);
@@ -1003,7 +1003,7 @@ private static void assertPosition(int row, int col, MXParser parser) {
* @since 3.4.2
*/
@Test
- public void testCustomEntityNotFoundInText() throws Exception {
+ void customEntityNotFoundInText() throws Exception {
MXParser parser = new MXParser();
String input = "
&&foo;&tritPos;
", 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); - } + assertDoesNotThrow( + () -> { + 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());
+ },
+ "should not raise exception: ");
}
/**
* Ensures emoji can be parsed correctly
*/
@Test
- public void testUnicode() throws IOException {
+ void unicode() throws IOException {
String input = "
setUp.
*/ @BeforeEach - public void setUp() { + void setUp() { parser = new MXParser(); } @@ -46,7 +46,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) @@ -67,7 +67,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) @@ -88,7 +88,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) @@ -109,7 +109,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) @@ -177,7 +177,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 (InputStream is = new FileInputStream(new File(testResourcesDir, "007.xml"))) { parser.setInput(is, null); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -198,7 +198,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 (InputStream is = new FileInputStream(new File(testResourcesDir, "008.xml"))) { parser.setInput(is, null); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -219,7 +219,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 (InputStream is = new FileInputStream(new File(testResourcesDir, "009.xml"))) { parser.setInput(is, null); while (parser.nextToken() != XmlPullParser.END_DOCUMENT)