From 73513660d292e0b837e31d1dbeb021b16965ff74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Mon, 11 Sep 2023 19:52:43 +0200 Subject: [PATCH 01/12] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index e9bbffc..a4920a1 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ limitations under the License. plexus-xml - 3.0.0 + 3.0.1-SNAPSHOT Plexus XML Utilities A collection of various utility classes to ease working with XML in Maven 3. @@ -33,7 +33,7 @@ limitations under the License. scm:git:https://github.com/codehaus-plexus/plexus-xml.git scm:git:https://github.com/codehaus-plexus/plexus-xml.git - plexus-xml-3.0.0 + 3.x https://github.com/codehaus-plexus/plexus-xml/tree/${project.scm.tag}/ @@ -48,7 +48,7 @@ limitations under the License. - 2023-09-11T17:52:31Z + 2023-09-11T17:52:43Z From 09be36bae706a7a12d89d55037102097e4f140de Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Tue, 12 Sep 2023 11:05:59 +0200 Subject: [PATCH 02/12] Switch to shared gh actions setup from master branch --- .github/workflows/maven.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 81f67f6..d9ab1e1 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -22,4 +22,4 @@ on: [push, pull_request] jobs: build: name: Build it - uses: codehaus-plexus/.github/.github/workflows/maven.yml@v0.0.5 + uses: codehaus-plexus/.github/.github/workflows/maven.yml@master From 219f5e0bf05a8990977daeb32d5367556a7fe40d Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 20 May 2024 20:44:56 +0200 Subject: [PATCH 03/12] Bump parent to 17 and updates --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index a4920a1..3bd6bd4 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ limitations under the License. org.codehaus.plexus plexus - 13 + 17 plexus-xml @@ -55,19 +55,19 @@ limitations under the License. org.codehaus.plexus plexus-utils - 4.0.0 + 4.0.1 test org.openjdk.jmh jmh-core - 1.36 + 1.37 test org.openjdk.jmh jmh-generator-annprocess - 1.36 + 1.37 test From 4793c274541c6c8a3d6552e3ca23edabee2a0b4f Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 20 May 2024 20:58:53 +0200 Subject: [PATCH 04/12] Config release-drafter in 3.x --- .github/release-drafter.yml | 5 ++++- .github/workflows/release-drafter.yml | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index c7f5948..1661580 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -1,2 +1,5 @@ _extends: .github -tag-template: plexus-utils-$NEXT_MINOR_VERSION +tag-template: plexus-xml-$NEXT_PATCH_VERSION +version-template: 3.$MINOR.$PATCH +commitish: 3.x +filter-by-commitish: true diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index 4000f8c..5170a1b 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -1,8 +1,8 @@ -name: Release Drafter +name: Release Drafter 3.x on: push: branches: - - master + - 3.x jobs: update_release_draft: runs-on: ubuntu-latest From 55de18a2f6cddf52f91b0f90e3a6a6d2227c5145 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 20 May 2024 21:11:50 +0200 Subject: [PATCH 05/12] Config release-drafter in 3.x --- .github/release-drafter.yml | 5 ----- .github/workflows/release-drafter.yml | 2 ++ 2 files changed, 2 insertions(+), 5 deletions(-) delete mode 100644 .github/release-drafter.yml diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml deleted file mode 100644 index 1661580..0000000 --- a/.github/release-drafter.yml +++ /dev/null @@ -1,5 +0,0 @@ -_extends: .github -tag-template: plexus-xml-$NEXT_PATCH_VERSION -version-template: 3.$MINOR.$PATCH -commitish: 3.x -filter-by-commitish: true diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index 5170a1b..7e523c1 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -8,5 +8,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: release-drafter/release-drafter@v5 + with: + config-name: 'release-drafter-3.x.yml' # located in .github/ in default branch env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 4274b2ef0a525421246edd97e16b94e8e31ffbf4 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 20 May 2024 21:43:13 +0200 Subject: [PATCH 06/12] Switch to junit 5 --- pom.xml | 19 ++++----- .../util/xml/PrettyPrintXMLWriterTest.java | 18 ++++---- .../plexus/util/xml/XmlStreamReaderTest.java | 33 +++++++++++---- .../plexus/util/xml/XmlStreamWriterTest.java | 4 +- .../codehaus/plexus/util/xml/XmlUtilTest.java | 5 +-- .../plexus/util/xml/XmlWriterUtilTest.java | 13 +++--- .../plexus/util/xml/Xpp3DomBuilderTest.java | 41 ++++++++----------- .../codehaus/plexus/util/xml/Xpp3DomTest.java | 11 ++--- .../plexus/util/xml/Xpp3DomUtilsTest.java | 4 +- .../plexus/util/xml/Xpp3DomWriterTest.java | 8 ++-- ...onformanceTestSuite_Production24_Test.java | 10 ++--- ...ConformanceTestSuite_Production2_Test.java | 10 ++--- ...onformanceTestSuite_Production32_Test.java | 10 ++--- ...onformanceTestSuite_Production66_Test.java | 10 ++--- ...onformanceTestSuite_Production80_Test.java | 10 ++--- .../plexus/util/xml/pull/MXParserTest.java | 14 +++---- ..._BjoernHoehrmannviaHST2013_09_18_Test.java | 10 ++--- 17 files changed, 116 insertions(+), 114 deletions(-) diff --git a/pom.xml b/pom.xml index 3bd6bd4..074063c 100644 --- a/pom.xml +++ b/pom.xml @@ -32,7 +32,7 @@ limitations under the License. scm:git:https://github.com/codehaus-plexus/plexus-xml.git - scm:git:https://github.com/codehaus-plexus/plexus-xml.git + ${project.scm.connection} 3.x https://github.com/codehaus-plexus/plexus-xml/tree/${project.scm.tag}/ @@ -52,12 +52,6 @@ limitations under the License. - - org.codehaus.plexus - plexus-utils - 4.0.1 - test - org.openjdk.jmh jmh-core @@ -71,9 +65,14 @@ limitations under the License. test - junit - junit - 4.13.2 + org.junit.jupiter + junit-jupiter + test + + + org.codehaus.plexus + plexus-utils + 4.0.1 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 b03e831..e219e5c 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java @@ -26,13 +26,13 @@ import java.util.NoSuchElementException; import org.codehaus.plexus.util.StringUtils; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * Test of {@link org.codehaus.plexus.util.xml.PrettyPrintXMLWriter} @@ -50,7 +50,7 @@ public class PrettyPrintXMLWriterTest { /** *

setUp.

*/ - @Before + @BeforeEach public void setUp() { initWriter(); } @@ -58,7 +58,7 @@ public void setUp() { /** *

tearDown.

*/ - @After + @AfterEach public void tearDown() { writer = null; w = null; @@ -175,7 +175,7 @@ public void testendElementAlreadyClosed() { public void testIssue51DetectJava7ConcatenationBug() throws IOException { File dir = new File("target/test-xml"); if (!dir.exists()) { - assertTrue("cannot create directory test-xml", dir.mkdir()); + 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"); 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 93f4eac..4ffe7a9 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/XmlStreamReaderTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/XmlStreamReaderTest.java @@ -21,9 +21,12 @@ import java.io.InputStream; import java.io.SequenceInputStream; -import junit.framework.ComparisonFailure; -import junit.framework.TestCase; import org.codehaus.plexus.util.IOUtil; +import org.junit.jupiter.api.Test; +import org.opentest4j.AssertionFailedError; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; /** *

XmlStreamReaderTest class.

@@ -32,7 +35,7 @@ * @version $Id: $Id * @since 3.4.0 */ -public class XmlStreamReaderTest extends TestCase { +public class XmlStreamReaderTest { /** french */ private static final String TEXT_LATIN1 = "eacute: \u00E9"; @@ -111,6 +114,7 @@ private static void checkXmlStreamReader(String text, String encoding, String ef * * @throws java.io.IOException if any. */ + @Test public void testNoXmlHeader() throws IOException { String xml = "text with no XML header"; checkXmlContent(xml, "UTF-8"); @@ -122,6 +126,7 @@ public void testNoXmlHeader() throws IOException { * * @throws java.io.IOException if any. */ + @Test public void testDefaultEncoding() throws IOException { checkXmlStreamReader(TEXT_UNICODE, null, "UTF-8"); checkXmlStreamReader(TEXT_UNICODE, null, "UTF-8", BOM_UTF8); @@ -132,6 +137,7 @@ public void testDefaultEncoding() throws IOException { * * @throws java.io.IOException if any. */ + @Test public void testUTF8Encoding() throws IOException { checkXmlStreamReader(TEXT_UNICODE, "UTF-8"); checkXmlStreamReader(TEXT_UNICODE, "UTF-8", BOM_UTF8); @@ -142,6 +148,7 @@ public void testUTF8Encoding() throws IOException { * * @throws java.io.IOException if any. */ + @Test public void testUTF16Encoding() throws IOException { checkXmlStreamReader(TEXT_UNICODE, "UTF-16", "UTF-16BE", null); checkXmlStreamReader(TEXT_UNICODE, "UTF-16", "UTF-16LE", BOM_UTF16LE); @@ -153,6 +160,7 @@ public void testUTF16Encoding() throws IOException { * * @throws java.io.IOException if any. */ + @Test public void testUTF16BEEncoding() throws IOException { checkXmlStreamReader(TEXT_UNICODE, "UTF-16BE"); } @@ -162,6 +170,7 @@ public void testUTF16BEEncoding() throws IOException { * * @throws java.io.IOException if any. */ + @Test public void testUTF16LEEncoding() throws IOException { checkXmlStreamReader(TEXT_UNICODE, "UTF-16LE"); } @@ -171,6 +180,7 @@ public void testUTF16LEEncoding() throws IOException { * * @throws java.io.IOException if any. */ + @Test public void testLatin1Encoding() throws IOException { checkXmlStreamReader(TEXT_LATIN1, "ISO-8859-1"); } @@ -180,6 +190,7 @@ public void testLatin1Encoding() throws IOException { * * @throws java.io.IOException if any. */ + @Test public void testLatin7Encoding() throws IOException { checkXmlStreamReader(TEXT_LATIN7, "ISO-8859-7"); } @@ -189,6 +200,7 @@ public void testLatin7Encoding() throws IOException { * * @throws java.io.IOException if any. */ + @Test public void testLatin15Encoding() throws IOException { checkXmlStreamReader(TEXT_LATIN15, "ISO-8859-15"); } @@ -198,6 +210,7 @@ public void testLatin15Encoding() throws IOException { * * @throws java.io.IOException if any. */ + @Test public void testEUC_JPEncoding() throws IOException { checkXmlStreamReader(TEXT_EUC_JP, "EUC-JP"); } @@ -207,6 +220,7 @@ public void testEUC_JPEncoding() throws IOException { * * @throws java.io.IOException if any. */ + @Test public void testEBCDICEncoding() throws IOException { checkXmlStreamReader("simple text in EBCDIC", "CP1047"); } @@ -216,13 +230,13 @@ public void testEBCDICEncoding() throws IOException { * * @throws java.io.IOException if any. */ + @Test public void testInappropriateEncoding() throws IOException { - try { - checkXmlStreamReader(TEXT_UNICODE, "ISO-8859-2"); - fail("Check should have failed, since some characters are not available in the specified encoding"); - } catch (ComparisonFailure cf) { - // expected failure, since the encoding does not contain some characters - } + // expected failure, since the encoding does not contain some characters + assertThrows( + AssertionFailedError.class, + () -> checkXmlStreamReader(TEXT_UNICODE, "ISO-8859-2"), + "Check should have failed, since some characters are not available in the specified encoding"); } /** @@ -230,6 +244,7 @@ public void testInappropriateEncoding() throws IOException { * * @throws java.io.IOException if any. */ + @Test public void testEncodingAttribute() 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 26e131c..c2803b5 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/XmlStreamWriterTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/XmlStreamWriterTest.java @@ -19,9 +19,9 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** *

XmlStreamWriterTest class.

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 bdfd76c..302bc28 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java @@ -27,10 +27,9 @@ import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.StringUtils; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; /** * Test the {@link org.codehaus.plexus.util.xml.XmlUtil} class. 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 8b0e397..fb51578 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/XmlWriterUtilTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/XmlWriterUtilTest.java @@ -21,12 +21,11 @@ import java.io.Writer; import org.codehaus.plexus.util.StringUtils; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; /** *

XmlWriterUtilTest class.

@@ -47,7 +46,7 @@ public class XmlWriterUtilTest { * * @throws java.lang.Exception if any. */ - @Before + @BeforeEach public void setUp() throws Exception { output = new ByteArrayOutputStream(); writer = WriterFactory.newXmlWriter(output); @@ -59,7 +58,7 @@ public void setUp() throws Exception { * * @throws java.lang.Exception if any. */ - @After + @AfterEach public void tearDown() throws Exception { xmlWriter = null; writer = null; 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 f9faac4..c8db71b 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomBuilderTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomBuilderTest.java @@ -23,11 +23,9 @@ import org.codehaus.plexus.util.xml.pull.MXParser; import org.codehaus.plexus.util.xml.pull.XmlPullParser; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; /** * Test the Xpp3DomBuilder. @@ -52,7 +50,7 @@ public void testBuildFromReader() throws Exception { Xpp3Dom expectedDom = createExpectedDom(); - assertEquals("check DOMs match", expectedDom, dom); + assertEquals(expectedDom, dom, "check DOMs match"); } /** @@ -66,12 +64,11 @@ public void testBuildTrimming() throws Exception { Xpp3Dom dom = Xpp3DomBuilder.build(new StringReader(domString), true); - assertEquals("test with trimming on", "element1", dom.getChild("el1").getValue()); + assertEquals("element1", dom.getChild("el1").getValue(), "test with trimming on"); dom = Xpp3DomBuilder.build(new StringReader(domString), false); - assertEquals( - "test with trimming off", " element1\n ", dom.getChild("el1").getValue()); + assertEquals(" element1\n ", dom.getChild("el1").getValue(), "test with trimming off"); } /** @@ -116,10 +113,10 @@ public void testBuildFromXpp3Dom() throws Exception { eventType = parser.next(); } - assertEquals("Check DOM matches", expectedDom, dom); - assertFalse("Check closing root was consumed", rootClosed); - assertTrue("Check continued to parse configuration", configurationClosed); - assertTrue("Check continued to parse newRoot", newRootClosed); + assertEquals(expectedDom, dom, "Check DOM matches"); + assertFalse(rootClosed, "Check closing root was consumed"); + assertTrue(configurationClosed, "Check continued to parse configuration"); + assertTrue(newRootClosed, "Check continued to parse newRoot"); } /** @@ -149,15 +146,13 @@ public void testUnclosedXml() { public void testEscapingInContent() throws IOException, XmlPullParserException { Xpp3Dom dom = Xpp3DomBuilder.build(new StringReader(getEncodedString())); - assertEquals("Check content value", "\"text\"", dom.getChild("el").getValue()); - assertEquals( - "Check content value", "\"text\"", dom.getChild("ela").getValue()); - assertEquals( - "Check content value", "\"text\"", dom.getChild("elb").getValue()); + assertEquals("\"text\"", dom.getChild("el").getValue(), "Check content value"); + assertEquals("\"text\"", dom.getChild("ela").getValue(), "Check content value"); + assertEquals("\"text\"", dom.getChild("elb").getValue(), "Check content value"); StringWriter w = new StringWriter(); Xpp3DomWriter.write(w, dom); - assertEquals("Compare stringified DOMs", getExpectedString(), w.toString()); + assertEquals(getExpectedString(), w.toString(), "Compare stringified DOMs"); } /** @@ -171,12 +166,12 @@ public void testEscapingInAttributes() throws IOException, XmlPullParserExceptio String s = getAttributeEncodedString(); Xpp3Dom dom = Xpp3DomBuilder.build(new StringReader(s)); - assertEquals("Check attribute value", "", dom.getChild("el").getAttribute("att")); + assertEquals("", dom.getChild("el").getAttribute("att"), "Check attribute value"); StringWriter w = new StringWriter(); Xpp3DomWriter.write(w, dom); String newString = w.toString(); - assertEquals("Compare stringified DOMs", newString, s); + assertEquals(newString, s, "Compare stringified DOMs"); } /** @@ -194,16 +189,16 @@ public Object toInputLocation(XmlPullParser parser) { }; Xpp3Dom dom = Xpp3DomBuilder.build(new StringReader(createDomString()), true, ilb); Xpp3Dom expectedDom = createExpectedDom(); - assertEquals("root input location", expectedDom.getInputLocation(), dom.getInputLocation()); + assertEquals(expectedDom.getInputLocation(), dom.getInputLocation(), "root input location"); for (int i = 0; i < dom.getChildCount(); i++) { Xpp3Dom elt = dom.getChild(i); Xpp3Dom expectedElt = expectedDom.getChild(i); - assertEquals(elt.getName() + " input location", expectedElt.getInputLocation(), elt.getInputLocation()); + assertEquals(expectedElt.getInputLocation(), elt.getInputLocation(), elt.getName() + " input location"); if ("el2".equals(elt.getName())) { Xpp3Dom el3 = elt.getChild(0); Xpp3Dom expectedEl3 = expectedElt.getChild(0); - assertEquals(el3.getName() + " input location", expectedEl3.getInputLocation(), el3.getInputLocation()); + assertEquals(expectedEl3.getInputLocation(), el3.getInputLocation(), el3.getName() + " input location"); } } } 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 c4f2102..dd9aea8 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomTest.java @@ -22,14 +22,9 @@ import org.codehaus.plexus.util.xml.pull.XmlPullParser; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; /** *

Xpp3DomTest class.

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 ea21509..6632367 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomUtilsTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomUtilsTest.java @@ -21,9 +21,9 @@ import org.codehaus.plexus.util.xml.pull.XmlPullParser; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** *

Xpp3DomUtilsTest class.

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 55853d0..7f7f321 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomWriterTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomWriterTest.java @@ -18,9 +18,9 @@ import java.io.StringWriter; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** *

Xpp3DomWriterTest class.

@@ -41,7 +41,7 @@ public void testWriter() { Xpp3DomWriter.write(writer, createXpp3Dom()); - assertEquals("Check if output matches", createExpectedXML(true), writer.toString()); + assertEquals(createExpectedXML(true), writer.toString(), "Check if output matches"); } /** @@ -53,7 +53,7 @@ public void testWriterNoEscape() { Xpp3DomWriter.write(new PrettyPrintXMLWriter(writer), createXpp3Dom(), false); - assertEquals("Check if output matches", createExpectedXML(false), writer.toString()); + assertEquals(createExpectedXML(false), writer.toString(), "Check if output matches"); } private String createExpectedXML(boolean escape) { 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 becde36..bb1a7e8 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 @@ -5,11 +5,11 @@ import java.io.IOException; import java.io.Reader; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * Test class that execute a particular set of tests associated to a TESCASES tag from the XML W3C Conformance Tests. @@ -30,7 +30,7 @@ class IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConfo /** *

setUp.

*/ - @Before + @BeforeEach public void setUp() { parser = new MXParser(); } 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 71a342a..49227a4 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 @@ -12,11 +12,11 @@ import java.nio.file.Files; import java.nio.file.Paths; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * Test class that execute a particular set of tests associated to a TESCASES tag from the XML W3C Conformance Tests. @@ -37,7 +37,7 @@ class IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConfo /** *

setUp.

*/ - @Before + @BeforeEach public void setUp() { parser = new MXParser(); } 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 91effa9..f99e1ea 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 @@ -5,11 +5,11 @@ import java.io.IOException; import java.io.Reader; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * Test class that execute a particular set of tests associated to a TESCASES tag from the XML W3C Conformance Tests. @@ -30,7 +30,7 @@ class IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConfo /** *

setUp.

*/ - @Before + @BeforeEach public void setUp() { parser = new MXParser(); } 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 3266b72..debe597 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 @@ -6,11 +6,11 @@ import java.io.IOException; import java.io.Reader; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * Test class that execute a particular set of tests associated to a TESCASES tag from the XML W3C Conformance Tests. @@ -31,7 +31,7 @@ class IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConfo /** *

setUp.

*/ - @Before + @BeforeEach public void setUp() { parser = new MXParser(); } 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 9b109a6..9581bed 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 @@ -5,11 +5,11 @@ import java.io.IOException; import java.io.Reader; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * Test class that execute a particular set of tests associated to a TESCASES tag from the XML W3C Conformance Tests. @@ -30,7 +30,7 @@ class IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConfo /** *

setUp.

*/ - @Before + @BeforeEach public void setUp() { parser = new MXParser(); } 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 1833f73..2d3ecef 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 org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.xml.ReaderFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** *

MXParserTest class.

@@ -890,8 +890,8 @@ public void testEncodingISO_8859_1_setInputStream() throws IOException { } private static void assertPosition(int row, int col, MXParser parser) { - assertEquals("Current line", row, parser.getLineNumber()); - assertEquals("Current column", col, parser.getColumnNumber()); + assertEquals(row, parser.getLineNumber(), "Current line"); + assertEquals(col, parser.getColumnNumber(), "Current column"); } /** 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 2ae6de3..65286c5 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 @@ -8,11 +8,11 @@ import java.io.Reader; import java.nio.charset.StandardCharsets; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * Test class that execute a particular set of tests associated to a TESCASES tag from the XML W3C Conformance Tests. @@ -32,7 +32,7 @@ public class eduni_misc_Test_BjoernHoehrmannviaHST2013_09_18_Test { /** *

setUp.

*/ - @Before + @BeforeEach public void setUp() { parser = new MXParser(); } From be6885bef0ecf9e3636e93d8eb7863d48986a053 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 20 May 2024 16:09:36 +0200 Subject: [PATCH 07/12] Remove special chars from xml output --------- Co-authored-by: Michael Osipov <1983-01-06@gmx.net> (cherry picked from commit c9d72affa12e1109be3003911af1b12e6d79026a) --- .../plexus/util/xml/PrettyPrintXMLWriter.java | 25 ++++++-- .../plexus/util/xml/pull/MXSerializer.java | 17 ++---- .../plexus/util/xml/Xpp3DomWriterTest.java | 12 +++- .../util/xml/pull/MXSerializerTest.java | 58 +++++++++++++++++++ 4 files changed, 93 insertions(+), 19 deletions(-) create mode 100644 src/test/java/org/codehaus/plexus/util/xml/pull/MXSerializerTest.java diff --git a/src/main/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriter.java b/src/main/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriter.java index 332bdaf..f602668 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriter.java +++ b/src/main/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriter.java @@ -23,9 +23,9 @@ import java.util.regex.Pattern; /** - * Implementation of XMLWriter which emits nicely formatted documents. - * + *

Implementation of XMLWriter which emits nicely formatted documents.

* + *

C0n control characters except \n, \r, and \t are omitted from output

*/ public class PrettyPrintXMLWriter implements XMLWriter { /** Line separator ("\n" on UNIX) */ @@ -185,7 +185,7 @@ private void writeText(String text, boolean escapeXml) { finishTag(); if (escapeXml) { - text = escapeXml(text); + text = escapeXmlText(text); } write(StringUtils.unifyLineSeparators(text, lineSeparator)); @@ -225,10 +225,12 @@ private static String escapeXml(String text) { private static final Pattern crlf = Pattern.compile(crlf_str); - private static final Pattern lowers = Pattern.compile("([\000-\037])"); + private static final Pattern lowers = Pattern.compile("([\\x00-\\x1F])"); + + private static final Pattern illegalC0Characters = Pattern.compile("([\\x00-\\x08\\x0B-\\x0C\\x0E-\\x1F])"); private static String escapeXmlAttribute(String text) { - text = escapeXml(text); + text = escapeXmlText(text); // Windows Matcher crlfmatcher = crlf.matcher(text); @@ -246,6 +248,19 @@ private static String escapeXmlAttribute(String text) { return b.toString(); } + private static String escapeXmlText(String text) { + text = escapeXml(text); + + Matcher matcher = illegalC0Characters.matcher(text); + StringBuffer b = new StringBuffer(); + while (matcher.find()) { + matcher = matcher.appendReplacement(b, ""); + } + matcher.appendTail(b); + + return b.toString(); + } + /** {@inheritDoc} */ @Override public void addAttribute(String key, String value) { diff --git a/src/main/java/org/codehaus/plexus/util/xml/pull/MXSerializer.java b/src/main/java/org/codehaus/plexus/util/xml/pull/MXSerializer.java index e69d28f..ffd0ede 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/pull/MXSerializer.java +++ b/src/main/java/org/codehaus/plexus/util/xml/pull/MXSerializer.java @@ -24,6 +24,7 @@ *
  • PROPERTY_SERIALIZER_INDENTATION *
  • PROPERTY_SERIALIZER_LINE_SEPARATOR * + *

    C0n control characters except \n, \r, and \t are omitted from output

    */ public class MXSerializer implements XmlSerializer { protected static final String XML_URI = "http://www.w3.org/XML/1998/namespace"; @@ -943,19 +944,9 @@ protected void writeElementContent(String text, Writer out) throws IOException { // out.write(';'); // pos = i + 1; } else { - throw new IllegalStateException( - "character " + Integer.toString(ch) + " is not allowed in output" + getLocation()); - // in XML 1.1 legal are [#x1-#xD7FF] - // if(ch > 0) { - // if(i > pos) out.write(text.substring(pos, i)); - // out.write("&#"); - // out.write(Integer.toString(ch)); - // out.write(';'); - // pos = i + 1; - // } else { - // throw new IllegalStateException( - // "character zero is not allowed in XML 1.1 output"+getLocation()); - // } + // skip special char + if (i > pos) out.write(text.substring(pos, i)); + pos = i + 1; } } if (seenBracket) { 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 7f7f321..233bdd5 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomWriterTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomWriterTest.java @@ -82,6 +82,12 @@ private String createExpectedXML(boolean escape) { buf.append(LS); buf.append(" "); buf.append(LS); + if (escape) { + buf.append(" special-char-"); + } else { + buf.append(" special-char-" + (char) 7 + ""); + } + buf.append(LS); buf.append(""); return buf.toString(); @@ -95,7 +101,7 @@ private Xpp3Dom createXpp3Dom() { dom.addChild(el1); Xpp3Dom el2 = new Xpp3Dom("el2"); - el2.setAttribute("att2", "attribute2\nnextline"); + el2.setAttribute("att2", "attribute2\nnextline" + (char) 7); dom.addChild(el2); Xpp3Dom el3 = new Xpp3Dom("el3"); @@ -119,6 +125,10 @@ private Xpp3Dom createXpp3Dom() { el7.setValue("element7\n&\"\'<>"); el6.addChild(el7); + Xpp3Dom el8 = new Xpp3Dom("el8"); + el8.setValue("special-char-" + (char) 7); + + dom.addChild(el8); return dom; } } 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 new file mode 100644 index 0000000..8b66c23 --- /dev/null +++ b/src/test/java/org/codehaus/plexus/util/xml/pull/MXSerializerTest.java @@ -0,0 +1,58 @@ +package org.codehaus.plexus.util.xml.pull; + +import java.io.StringReader; +import java.io.StringWriter; +import java.util.Arrays; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +class MXSerializerTest { + + @Test + void testSerialize() throws Exception { + + StringWriter writer = new StringWriter(); + + MXSerializer sr = new MXSerializer(); + sr.setOutput(writer); + + sr.startDocument(null, Boolean.TRUE); + sr.startTag(null, "root"); + for (int i : Arrays.asList(8, 9, 10, 11, 13, 15)) { + sr.startTag(null, "char"); + sr.text(Character.getName(i) + ": " + ((char) i)); + sr.endTag(null, "char"); + } + + sr.endTag(null, "root"); + sr.endDocument(); + assertEquals(expectedOutput(), writer.toString()); + } + + @Test + void testDeserialize() throws Exception { + MXParser parser = new MXParser(); + parser.setInput(new StringReader(expectedOutput())); + int eventType = parser.getEventType(); + + while (eventType != XmlPullParser.END_DOCUMENT) { + eventType = parser.next(); + } + } + + 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(); + } +} From 214263a915ec254fab3cd12e01d4d3d940d741b2 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 20 May 2024 23:20:21 +0200 Subject: [PATCH 08/12] Deploy snapshots for 3.x branch --- .github/workflows/maven.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index d9ab1e1..dc57b74 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -23,3 +23,11 @@ jobs: build: name: Build it uses: codehaus-plexus/.github/.github/workflows/maven.yml@master + + deploy: + name: Deploy + needs: build + uses: codehaus-plexus/.github/.github/workflows/maven-deploy.yml@master + with: + branch-to-deploy: 'refs/heads/3.x' + secrets: inherit From 70b83b15592a5711a5f629591af90f87e1bbfe20 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 23:39:10 +0200 Subject: [PATCH 09/12] Bump release-drafter/release-drafter from 5 to 6 (#33) updated-dependencies: - dependency-name: release-drafter/release-drafter dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/release-drafter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index 7e523c1..21edf4c 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -7,7 +7,7 @@ jobs: update_release_draft: runs-on: ubuntu-latest steps: - - uses: release-drafter/release-drafter@v5 + - uses: release-drafter/release-drafter@v6 with: config-name: 'release-drafter-3.x.yml' # located in .github/ in default branch env: From af8cbad164e6ac4839d10d894a39e9d18f0eddb9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 21 May 2024 22:42:54 +0200 Subject: [PATCH 10/12] Bump org.codehaus.plexus:plexus from 17 to 18 (#40) updated-dependencies: - dependency-name: org.codehaus.plexus:plexus dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 074063c..882eb97 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ limitations under the License. org.codehaus.plexus plexus - 17 + 18 plexus-xml From b55ce82f298d5658d45a61611d4dad297ee2d524 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Mon, 20 May 2024 10:33:23 -0400 Subject: [PATCH 11/12] Allow nulls for write elements in MXSerializer https://issues.apache.org/jira/browse/MJAVADOC-793 (cherry picked from commit 43dbdca6780fd60371e63f7e94d938b482e2edc9) --- .../plexus/util/xml/pull/MXSerializer.java | 6 ++++++ .../plexus/util/xml/pull/MXSerializerTest.java | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/main/java/org/codehaus/plexus/util/xml/pull/MXSerializer.java b/src/main/java/org/codehaus/plexus/util/xml/pull/MXSerializer.java index ffd0ede..54e48dc 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/pull/MXSerializer.java +++ b/src/main/java/org/codehaus/plexus/util/xml/pull/MXSerializer.java @@ -854,6 +854,9 @@ public void flush() throws IOException { // --- utility methods protected void writeAttributeValue(String value, Writer out) throws IOException { + if (value == null) { + return; + } // .[apostrophe and <, & escaped], final char quot = attributeUseApostrophe ? '\'' : '"'; final String quotEntity = attributeUseApostrophe ? "'" : """; @@ -908,6 +911,9 @@ protected void writeAttributeValue(String value, Writer out) throws IOException } protected void writeElementContent(String text, Writer out) throws IOException { + if (text == null) { + return; + } // escape '<', '&', ']]>', <32 if necessary int pos = 0; for (int i = 0; i < text.length(); i++) { 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 8b66c23..0b1d3d7 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 @@ -1,5 +1,6 @@ package org.codehaus.plexus.util.xml.pull; +import java.io.IOException; import java.io.StringReader; import java.io.StringWriter; import java.util.Arrays; @@ -55,4 +56,19 @@ private String expectedOutput() { out.append(""); return out.toString(); } + + /** + * Tests MJAVADOC-793. + */ + @Test + public void testWriteNullValues() throws IOException { + // should be no-ops + new MXSerializer().writeElementContent(null, null); + new MXSerializer().writeAttributeValue(null, null); + final StringWriter stringWriter = new StringWriter(); + new MXSerializer().writeElementContent(null, stringWriter); + assertEquals("", stringWriter.toString()); + new MXSerializer().writeAttributeValue(null, stringWriter); + assertEquals("", stringWriter.toString()); + } } From 86d35785396e1e8a02ce231c6aa9a7042f2ebd66 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Tue, 21 May 2024 23:12:07 +0200 Subject: [PATCH 12/12] [maven-release-plugin] prepare release plexus-xml-3.0.1 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 882eb97..730973a 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ limitations under the License. plexus-xml - 3.0.1-SNAPSHOT + 3.0.1 Plexus XML Utilities A collection of various utility classes to ease working with XML in Maven 3. @@ -33,7 +33,7 @@ limitations under the License. scm:git:https://github.com/codehaus-plexus/plexus-xml.git ${project.scm.connection} - 3.x + plexus-xml-3.0.1 https://github.com/codehaus-plexus/plexus-xml/tree/${project.scm.tag}/ @@ -48,7 +48,7 @@ limitations under the License. - 2023-09-11T17:52:43Z + 2024-05-21T21:11:54Z