From e46be58307e5e2fe6606d3233d4b15c074566adb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Sun, 10 Sep 2023 12:39:03 +0200 Subject: [PATCH 01/36] create 3.x branch keeping Maven 3 XML parser implementation --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 61e81547..cd99adb7 100644 --- a/pom.xml +++ b/pom.xml @@ -26,16 +26,16 @@ limitations under the License. plexus-xml - 4.0.0-SNAPSHOT + 3.0.0-SNAPSHOT Plexus XML Utilities - A collection of various utility classes to ease working with XML. + A collection of various utility classes to ease working with XML in Maven 3. scm:git:git@github.com:codehaus-plexus/plexus-xml.git scm:git:git@github.com:codehaus-plexus/plexus-xml.git http://github.com/codehaus-plexus/plexus-xml - master + 3.x github @@ -56,7 +56,7 @@ limitations under the License. org.codehaus.plexus plexus-utils - 4.0.0-SNAPSHOT + 4.0.0 test From 882a2e3c5b5f2b7eb4471c4d5e9ef7f85387f0e1 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Thu, 6 Apr 2023 22:37:07 +0200 Subject: [PATCH 02/36] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 054e151b..379ac1e9 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Plexus-Xml [![Build Status](https://github.com/codehaus-plexus/plexus-xml/actions/workflows/maven.yml/badge.svg)](https://github.com/codehaus-plexus/plexus-xml/actions) [![Maven Central](https://img.shields.io/maven-central/v/org.codehaus.plexus/plexus-xml.svg?label=Maven%20Central)](https://search.maven.org/artifact/org.codehaus.plexus/plexus-xml) -This library consists of XML classes (`org.codehaus.plexus.util.xml`, and `ReaderFactory`/`WriterFactory` moved from `org.codehaus.plexus.util`) that have been extracted from `plexus-utils` 4. +This library consists of XML classes (`org.codehaus.plexus.util.xml`, and `ReaderFactory`/`WriterFactory` moved from `org.codehaus.plexus.util`) that have been extracted from [`plexus-utils`](https://github.com/codehaus-plexus/plexus-utils/) 4. For publishing [the site](https://codehaus-plexus.github.io/plexus-xml/) do the following: From 6b57e0c2bfa305b9c466e8fc88511f8546a15817 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Thu, 20 Apr 2023 08:25:25 +0200 Subject: [PATCH 03/36] fix javadoc typo --- .../org/codehaus/plexus/util/xml/pull/MXParserTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 0c393c6b..d793c341 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 @@ -1185,7 +1185,7 @@ public void testCustomEntityNotFoundInAttrTokenize() throws Exception } /** - *

Issue #194: Incorrect getText() after parsing the DOCDECL section + *

Issue #194: Incorrect getText() after parsing the DOCDECL section

* *

test DOCDECL text with myCustomEntity that cannot be resolved, Unix line separator.

* @@ -1203,7 +1203,7 @@ public void testDocdeclTextWithEntitiesUnix() } /** - *

Issue #194: Incorrect getText() after parsing the DOCDECL section + *

Issue #194: Incorrect getText() after parsing the DOCDECL section

* *

test DOCDECL text with myCustomEntity that cannot be resolved, DOS line separator.

* @@ -1248,7 +1248,7 @@ private void testDocdeclTextWithEntities( String filename ) } /** - *

Issue #194: Incorrect getText() after parsing the DOCDECL section + *

Issue #194: Incorrect getText() after parsing the DOCDECL section

* *

test DOCDECL text with entities appearing in attributes, Unix line separator.

* @@ -1266,7 +1266,7 @@ public void testDocdeclTextWithEntitiesInAttributesUnix() } /** - *

Issue #194: Incorrect getText() after parsing the DOCDECL section + *

Issue #194: Incorrect getText() after parsing the DOCDECL section

* *

test DOCDECL text with entities appearing in attributes, DOS line separator.

* From 8f7b7eceaeb8115b3d2abe649bd17410500a4c74 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Wed, 10 May 2023 13:40:42 +0200 Subject: [PATCH 04/36] Upgrade plugins and clean build warnings (#4) --- pom.xml | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index cd99adb7..1e1dd066 100644 --- a/pom.xml +++ b/pom.xml @@ -82,14 +82,54 @@ limitations under the License. + + org.apache.maven.plugins + maven-enforcer-plugin + 3.3.0 + org.apache.maven.plugins maven-resources-plugin 3.3.1 + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0 + + + org.apache.maven.plugins + maven-site-plugin + 4.0.0-M7 + + + org.apache.maven.plugins + maven-compiler-plugin + 3.11.0 + + + org.apache.maven.plugins + maven-enforcer-plugin + + + enforce-maven + + enforce + + + + + 3.2.5 + This project requires at least Maven 3.2.5 + + + + + + maven-compiler-plugin @@ -127,7 +167,7 @@ limitations under the License. true - + JAVA_HOME ${JAVA_HOME} @@ -136,7 +176,7 @@ limitations under the License. M2_HOME ${M2_HOME} - + From b299205ba3934718943f2317ec0ab2e893996178 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Mon, 22 May 2023 16:42:59 +0200 Subject: [PATCH 05/36] Fix site generation (#15) --- pom.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pom.xml b/pom.xml index 1e1dd066..4813395f 100644 --- a/pom.xml +++ b/pom.xml @@ -97,11 +97,6 @@ limitations under the License. maven-surefire-plugin 3.0.0 - - org.apache.maven.plugins - maven-site-plugin - 4.0.0-M7 - org.apache.maven.plugins maven-compiler-plugin From 539c8ba1144d66801d6140ccafac9f63c5f4037e Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Mon, 22 May 2023 15:34:51 +0200 Subject: [PATCH 06/36] Upgrade to plexus 13 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4813395f..3f255242 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ limitations under the License. org.codehaus.plexus plexus - 10 + 13 plexus-xml From 7da7c1b085b856a12e09ea450f9a51598c0edefa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Mon, 11 Sep 2023 19:26:01 +0200 Subject: [PATCH 07/36] Reformat using spotless --- pom.xml | 10 +- .../plexus/util/xml/CompactXMLWriter.java | 17 +- .../plexus/util/xml/PrettyPrintXMLWriter.java | 284 +- .../plexus/util/xml/ReaderFactory.java | 70 +- .../plexus/util/xml/SerializerXMLWriter.java | 95 +- .../codehaus/plexus/util/xml/StringUtils.java | 116 +- .../plexus/util/xml/WriterFactory.java | 52 +- .../codehaus/plexus/util/xml/XMLWriter.java | 12 +- .../codehaus/plexus/util/xml/XmlReader.java | 568 ++- .../plexus/util/xml/XmlReaderException.java | 36 +- .../plexus/util/xml/XmlStreamReader.java | 72 +- .../util/xml/XmlStreamReaderException.java | 16 +- .../plexus/util/xml/XmlStreamWriter.java | 109 +- .../org/codehaus/plexus/util/xml/XmlUtil.java | 231 +- .../plexus/util/xml/XmlWriterUtil.java | 189 +- .../org/codehaus/plexus/util/xml/Xpp3Dom.java | 395 +- .../plexus/util/xml/Xpp3DomBuilder.java | 194 +- .../plexus/util/xml/Xpp3DomUtils.java | 153 +- .../plexus/util/xml/Xpp3DomWriter.java | 48 +- .../util/xml/pull/EntityReplacementMap.java | 358 +- .../plexus/util/xml/pull/MXParser.java | 3362 +++++++---------- .../plexus/util/xml/pull/MXSerializer.java | 1116 ++---- .../plexus/util/xml/pull/XmlPullParser.java | 118 +- .../util/xml/pull/XmlPullParserException.java | 48 +- .../plexus/util/xml/pull/XmlSerializer.java | 75 +- .../util/xml/PrettyPrintXMLWriterTest.java | 233 +- .../plexus/util/xml/XmlStreamReaderTest.java | 187 +- .../plexus/util/xml/XmlStreamWriterTest.java | 113 +- .../codehaus/plexus/util/xml/XmlUtilTest.java | 154 +- .../plexus/util/xml/XmlWriterUtilTest.java | 405 +- .../plexus/util/xml/Xpp3DomBuilderTest.java | 279 +- .../plexus/util/xml/Xpp3DomPerfTest.java | 35 +- .../codehaus/plexus/util/xml/Xpp3DomTest.java | 368 +- .../plexus/util/xml/Xpp3DomUtilsTest.java | 181 +- .../plexus/util/xml/Xpp3DomWriterTest.java | 124 +- ...onformanceTestSuite_Production24_Test.java | 403 +- ...ConformanceTestSuite_Production2_Test.java | 647 ++-- ...onformanceTestSuite_Production32_Test.java | 431 +-- ...onformanceTestSuite_Production66_Test.java | 711 ++-- ...onformanceTestSuite_Production80_Test.java | 293 +- .../util/xml/pull/MXParserPerfTest.java | 29 +- .../plexus/util/xml/pull/MXParserTest.java | 1479 ++++---- ..._BjoernHoehrmannviaHST2013_09_18_Test.java | 193 +- 43 files changed, 5826 insertions(+), 8183 deletions(-) diff --git a/pom.xml b/pom.xml index 3f255242..48106965 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,4 @@ - - 4.0.0 @@ -34,8 +32,8 @@ limitations under the License. scm:git:git@github.com:codehaus-plexus/plexus-xml.git scm:git:git@github.com:codehaus-plexus/plexus-xml.git - http://github.com/codehaus-plexus/plexus-xml 3.x + http://github.com/codehaus-plexus/plexus-xml github @@ -144,15 +142,17 @@ limitations under the License. org.apache.maven.plugins maven-scm-publish-plugin - ${project.reporting.outputDirectory} + ${project.reporting.outputDirectory} + scm-publish - site-deploy + publish-scm + site-deploy diff --git a/src/main/java/org/codehaus/plexus/util/xml/CompactXMLWriter.java b/src/main/java/org/codehaus/plexus/util/xml/CompactXMLWriter.java index 85835210..d7ceaa05 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/CompactXMLWriter.java +++ b/src/main/java/org/codehaus/plexus/util/xml/CompactXMLWriter.java @@ -22,23 +22,18 @@ /** * */ -public class CompactXMLWriter - extends PrettyPrintXMLWriter -{ +public class CompactXMLWriter extends PrettyPrintXMLWriter { - public CompactXMLWriter( PrintWriter writer ) - { - super( writer ); + public CompactXMLWriter(PrintWriter writer) { + super(writer); } - public CompactXMLWriter( Writer writer ) - { - super( writer ); + public CompactXMLWriter(Writer writer) { + super(writer); } @Override - protected void endOfLine() - { + protected void endOfLine() { // override parent: don't write anything at end of line } } 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 8977534f..332bdaf0 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriter.java +++ b/src/main/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriter.java @@ -27,11 +27,9 @@ * * */ -public class PrettyPrintXMLWriter - implements XMLWriter -{ +public class PrettyPrintXMLWriter implements XMLWriter { /** Line separator ("\n" on UNIX) */ - protected static final String LS = System.getProperty( "line.separator" ); + protected static final String LS = System.getProperty("line.separator"); private PrintWriter writer; @@ -57,34 +55,30 @@ public class PrettyPrintXMLWriter * @param writer not null * @param lineIndenter could be null, but the normal way is some spaces. */ - public PrettyPrintXMLWriter( PrintWriter writer, String lineIndenter ) - { - this( writer, lineIndenter, null, null ); + public PrettyPrintXMLWriter(PrintWriter writer, String lineIndenter) { + this(writer, lineIndenter, null, null); } /** * @param writer not null * @param lineIndenter could be null, but the normal way is some spaces. */ - public PrettyPrintXMLWriter( Writer writer, String lineIndenter ) - { - this( new PrintWriter( writer ), lineIndenter ); + public PrettyPrintXMLWriter(Writer writer, String lineIndenter) { + this(new PrintWriter(writer), lineIndenter); } /** * @param writer not null */ - public PrettyPrintXMLWriter( PrintWriter writer ) - { - this( writer, null, null ); + public PrettyPrintXMLWriter(PrintWriter writer) { + this(writer, null, null); } /** * @param writer not null */ - public PrettyPrintXMLWriter( Writer writer ) - { - this( new PrintWriter( writer ) ); + public PrettyPrintXMLWriter(Writer writer) { + this(new PrintWriter(writer)); } /** @@ -93,9 +87,8 @@ public PrettyPrintXMLWriter( Writer writer ) * @param encoding could be null or invalid. * @param doctype could be null. */ - public PrettyPrintXMLWriter( PrintWriter writer, String lineIndenter, String encoding, String doctype ) - { - this( writer, lineIndenter, LS, encoding, doctype ); + public PrettyPrintXMLWriter(PrintWriter writer, String lineIndenter, String encoding, String doctype) { + this(writer, lineIndenter, LS, encoding, doctype); } /** @@ -104,9 +97,8 @@ public PrettyPrintXMLWriter( PrintWriter writer, String lineIndenter, String enc * @param encoding could be null or invalid. * @param doctype could be null. */ - public PrettyPrintXMLWriter( Writer writer, String lineIndenter, String encoding, String doctype ) - { - this( new PrintWriter( writer ), lineIndenter, encoding, doctype ); + public PrettyPrintXMLWriter(Writer writer, String lineIndenter, String encoding, String doctype) { + this(new PrintWriter(writer), lineIndenter, encoding, doctype); } /** @@ -114,9 +106,8 @@ public PrettyPrintXMLWriter( Writer writer, String lineIndenter, String encoding * @param encoding could be null or invalid. * @param doctype could be null. */ - public PrettyPrintXMLWriter( PrintWriter writer, String encoding, String doctype ) - { - this( writer, " ", encoding, doctype ); + public PrettyPrintXMLWriter(PrintWriter writer, String encoding, String doctype) { + this(writer, " ", encoding, doctype); } /** @@ -124,9 +115,8 @@ public PrettyPrintXMLWriter( PrintWriter writer, String encoding, String doctype * @param encoding could be null or invalid. * @param doctype could be null. */ - public PrettyPrintXMLWriter( Writer writer, String encoding, String doctype ) - { - this( new PrintWriter( writer ), encoding, doctype ); + public PrettyPrintXMLWriter(Writer writer, String encoding, String doctype) { + this(new PrintWriter(writer), encoding, doctype); } /** @@ -136,42 +126,39 @@ public PrettyPrintXMLWriter( Writer writer, String encoding, String doctype ) * @param encoding could be null or invalid. * @param doctype could be null. */ - public PrettyPrintXMLWriter( PrintWriter writer, String lineIndenter, String lineSeparator, String encoding, - String doctype ) - { - setWriter( writer ); + public PrettyPrintXMLWriter( + PrintWriter writer, String lineIndenter, String lineSeparator, String encoding, String doctype) { + setWriter(writer); - setLineIndenter( lineIndenter ); + setLineIndenter(lineIndenter); - setLineSeparator( lineSeparator ); + setLineSeparator(lineSeparator); - setEncoding( encoding ); + setEncoding(encoding); - setDocType( doctype ); + setDocType(doctype); - if ( doctype != null || encoding != null ) - { + if (doctype != null || encoding != null) { writeDocumentHeaders(); } } /** {@inheritDoc} */ @Override - public void startElement( String name ) - { + public void startElement(String name) { tagIsEmpty = false; finishTag(); - write( "<" ); + write("<"); - write( name ); + write(name); - elementStack.addLast( name ); + elementStack.addLast(name); tagInProgress = true; - setDepth( getDepth() + 1 ); + setDepth(getDepth() + 1); readyForNewLine = true; @@ -180,65 +167,55 @@ public void startElement( String name ) /** {@inheritDoc} */ @Override - public void writeText( String text ) - { - writeText( text, true ); + public void writeText(String text) { + writeText(text, true); } /** {@inheritDoc} */ @Override - public void writeMarkup( String text ) - { - writeText( text, false ); + public void writeMarkup(String text) { + writeText(text, false); } - private void writeText( String text, boolean escapeXml ) - { + private void writeText(String text, boolean escapeXml) { readyForNewLine = false; tagIsEmpty = false; finishTag(); - if ( escapeXml ) - { - text = escapeXml( text ); + if (escapeXml) { + text = escapeXml(text); } - write( StringUtils.unifyLineSeparators( text, lineSeparator ) ); + write(StringUtils.unifyLineSeparators(text, lineSeparator)); } - private static final Pattern amp = Pattern.compile( "&" ); + private static final Pattern amp = Pattern.compile("&"); - private static final Pattern lt = Pattern.compile( "<" ); + private static final Pattern lt = Pattern.compile("<"); - private static final Pattern gt = Pattern.compile( ">" ); + private static final Pattern gt = Pattern.compile(">"); - private static final Pattern dqoute = Pattern.compile( "\"" ); + private static final Pattern dqoute = Pattern.compile("\""); - private static final Pattern sqoute = Pattern.compile( "\'" ); + private static final Pattern sqoute = Pattern.compile("\'"); - private static String escapeXml( String text ) - { - if ( text.indexOf( '&' ) >= 0 ) - { - text = amp.matcher( text ).replaceAll( "&" ); + private static String escapeXml(String text) { + if (text.indexOf('&') >= 0) { + text = amp.matcher(text).replaceAll("&"); } - if ( text.indexOf( '<' ) >= 0 ) - { - text = lt.matcher( text ).replaceAll( "<" ); + if (text.indexOf('<') >= 0) { + text = lt.matcher(text).replaceAll("<"); } - if ( text.indexOf( '>' ) >= 0 ) - { - text = gt.matcher( text ).replaceAll( ">" ); + if (text.indexOf('>') >= 0) { + text = gt.matcher(text).replaceAll(">"); } - if ( text.indexOf( '"' ) >= 0 ) - { - text = dqoute.matcher( text ).replaceAll( """ ); + if (text.indexOf('"') >= 0) { + text = dqoute.matcher(text).replaceAll("""); } - if ( text.indexOf( '\'' ) >= 0 ) - { - text = sqoute.matcher( text ).replaceAll( "'" ); + if (text.indexOf('\'') >= 0) { + text = sqoute.matcher(text).replaceAll("'"); } return text; @@ -246,65 +223,57 @@ private static String escapeXml( String text ) private static final String crlf_str = "\r\n"; - private static final Pattern crlf = Pattern.compile( crlf_str ); + 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("([\000-\037])"); - private static String escapeXmlAttribute( String text ) - { - text = escapeXml( text ); + private static String escapeXmlAttribute(String text) { + text = escapeXml(text); // Windows - Matcher crlfmatcher = crlf.matcher( text ); - if ( text.contains( crlf_str ) ) - { - text = crlfmatcher.replaceAll( " " ); + Matcher crlfmatcher = crlf.matcher(text); + if (text.contains(crlf_str)) { + text = crlfmatcher.replaceAll(" "); } - Matcher m = lowers.matcher( text ); + Matcher m = lowers.matcher(text); StringBuffer b = new StringBuffer(); - while ( m.find() ) - { - m = m.appendReplacement( b, "&#" + Integer.toString( m.group( 1 ).charAt( 0 ) ) + ";" ); + while (m.find()) { + m = m.appendReplacement(b, "&#" + Integer.toString(m.group(1).charAt(0)) + ";"); } - m.appendTail( b ); + m.appendTail(b); return b.toString(); } /** {@inheritDoc} */ @Override - public void addAttribute( String key, String value ) - { - write( " " ); + public void addAttribute(String key, String value) { + write(" "); - write( key ); + write(key); - write( "=\"" ); + write("=\""); - write( escapeXmlAttribute( value ) ); + write(escapeXmlAttribute(value)); - write( "\"" ); + write("\""); } /** {@inheritDoc} */ @Override - public void endElement() - { - setDepth( getDepth() - 1 ); + public void endElement() { + setDepth(getDepth() - 1); - if ( tagIsEmpty ) - { - write( "/" ); + if (tagIsEmpty) { + write("/"); readyForNewLine = false; finishTag(); elementStack.removeLast(); - } - else - { + } else { finishTag(); // see issue #51: https://github.com/codehaus-plexus/plexus-utils/issues/51 @@ -312,9 +281,9 @@ public void endElement() // (this avoids the string concatenation optimization bug detected in Java 7) // TODO: change the below code to a more efficient expression when the library // be ready to target Java 8. - write( "" ); + write(""); } readyForNewLine = true; @@ -322,25 +291,21 @@ public void endElement() /** * Write a string to the underlying writer - * + * * @param str */ - private void write( String str ) - { - getWriter().write( str ); + private void write(String str) { + getWriter().write(str); } - private void finishTag() - { - if ( tagInProgress ) - { - write( ">" ); + private void finishTag() { + if (tagInProgress) { + write(">"); } tagInProgress = false; - if ( readyForNewLine ) - { + if (readyForNewLine) { endOfLine(); } readyForNewLine = false; @@ -353,8 +318,7 @@ private void finishTag() * * @return the line indenter */ - protected String getLineIndenter() - { + protected String getLineIndenter() { return lineIndenter; } @@ -363,8 +327,7 @@ protected String getLineIndenter() * * @param lineIndenter new line indenter, could be null, but the normal way is some spaces. */ - protected void setLineIndenter( String lineIndenter ) - { + protected void setLineIndenter(String lineIndenter) { this.lineIndenter = lineIndenter; } @@ -374,8 +337,7 @@ protected void setLineIndenter( String lineIndenter ) * @return the line separator * @see #LS */ - protected String getLineSeparator() - { + protected String getLineSeparator() { return lineSeparator; } @@ -384,8 +346,7 @@ protected String getLineSeparator() * * @param lineSeparator new line separator, could be null but the normal way is valid line separator ("\n" on UNIX). */ - protected void setLineSeparator( String lineSeparator ) - { + protected void setLineSeparator(String lineSeparator) { this.lineSeparator = lineSeparator; } @@ -395,36 +356,31 @@ protected void setLineSeparator( String lineSeparator ) * @see #getLineIndenter() * @see #getLineSeparator() */ - protected void endOfLine() - { - write( getLineSeparator() ); + protected void endOfLine() { + write(getLineSeparator()); - for ( int i = 0; i < getDepth(); i++ ) - { - write( getLineIndenter() ); + for (int i = 0; i < getDepth(); i++) { + write(getLineIndenter()); } } - private void writeDocumentHeaders() - { - write( "" ); + write("?>"); endOfLine(); - if ( getDocType() != null ) - { - write( "" ); + write(">"); endOfLine(); } @@ -435,11 +391,9 @@ private void writeDocumentHeaders() * * @param writer not null writer */ - protected void setWriter( PrintWriter writer ) - { - if ( writer == null ) - { - throw new IllegalArgumentException( "writer could not be null" ); + protected void setWriter(PrintWriter writer) { + if (writer == null) { + throw new IllegalArgumentException("writer could not be null"); } this.writer = writer; @@ -450,8 +404,7 @@ protected void setWriter( PrintWriter writer ) * * @return the underlying writer */ - protected PrintWriter getWriter() - { + protected PrintWriter getWriter() { return writer; } @@ -460,8 +413,7 @@ protected PrintWriter getWriter() * * @param depth new depth */ - protected void setDepth( int depth ) - { + protected void setDepth(int depth) { this.depth = depth; } @@ -470,8 +422,7 @@ protected void setDepth( int depth ) * * @return the current depth */ - protected int getDepth() - { + protected int getDepth() { return depth; } @@ -480,8 +431,7 @@ protected int getDepth() * * @param encoding new encoding */ - protected void setEncoding( String encoding ) - { + protected void setEncoding(String encoding) { this.encoding = encoding; } @@ -490,8 +440,7 @@ protected void setEncoding( String encoding ) * * @return the current encoding */ - protected String getEncoding() - { + protected String getEncoding() { return encoding; } @@ -500,8 +449,7 @@ protected String getEncoding() * * @param docType new docType */ - protected void setDocType( String docType ) - { + protected void setDocType(String docType) { this.docType = docType; } @@ -510,16 +458,14 @@ protected void setDocType( String docType ) * * @return the current docType */ - protected String getDocType() - { + protected String getDocType() { return docType; } /** * @return the current elementStack; */ - protected LinkedList getElementStack() - { + protected LinkedList getElementStack() { return elementStack; } } diff --git a/src/main/java/org/codehaus/plexus/util/xml/ReaderFactory.java b/src/main/java/org/codehaus/plexus/util/xml/ReaderFactory.java index c8c35e18..6ad3a295 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/ReaderFactory.java +++ b/src/main/java/org/codehaus/plexus/util/xml/ReaderFactory.java @@ -35,12 +35,11 @@ * * @since 1.4.3 */ -public class ReaderFactory -{ +public class ReaderFactory { /** * ISO Latin Alphabet #1, also known as ISO-LATIN-1. Every implementation of the Java platform is required to * support this character encoding. - * + * * @see Charset */ public static final String ISO_8859_1 = "ISO-8859-1"; @@ -48,7 +47,7 @@ public class ReaderFactory /** * Seven-bit ASCII, also known as ISO646-US, also known as the Basic Latin block of the Unicode character set. Every * implementation of the Java platform is required to support this character encoding. - * + * * @see Charset */ public static final String US_ASCII = "US-ASCII"; @@ -57,7 +56,7 @@ public class ReaderFactory * Sixteen-bit Unicode Transformation Format, byte order specified by a mandatory initial byte-order mark (either * order accepted on input, big-endian used on output). Every implementation of the Java platform is required to * support this character encoding. - * + * * @see Charset */ public static final String UTF_16 = "UTF-16"; @@ -65,7 +64,7 @@ public class ReaderFactory /** * Sixteen-bit Unicode Transformation Format, big-endian byte order. Every implementation of the Java platform is * required to support this character encoding. - * + * * @see Charset */ public static final String UTF_16BE = "UTF-16BE"; @@ -73,7 +72,7 @@ public class ReaderFactory /** * Sixteen-bit Unicode Transformation Format, little-endian byte order. Every implementation of the Java platform is * required to support this character encoding. - * + * * @see Charset */ public static final String UTF_16LE = "UTF-16LE"; @@ -81,7 +80,7 @@ public class ReaderFactory /** * Eight-bit Unicode Transformation Format. Every implementation of the Java platform is required to support this * character encoding. - * + * * @see Charset */ public static final String UTF_8 = "UTF-8"; @@ -89,7 +88,7 @@ public class ReaderFactory /** * The file.encoding System Property. */ - public static final String FILE_ENCODING = System.getProperty( "file.encoding" ); + public static final String FILE_ENCODING = System.getProperty("file.encoding"); /** * Create a new Reader with XML encoding detection rules. @@ -99,10 +98,8 @@ public class ReaderFactory * @throws IOException if any. * @see XmlStreamReader */ - public static XmlStreamReader newXmlReader( InputStream in ) - throws IOException - { - return new XmlStreamReader( in ); + public static XmlStreamReader newXmlReader(InputStream in) throws IOException { + return new XmlStreamReader(in); } /** @@ -113,10 +110,8 @@ public static XmlStreamReader newXmlReader( InputStream in ) * @throws IOException if any. * @see XmlStreamReader */ - public static XmlStreamReader newXmlReader( File file ) - throws IOException - { - return new XmlStreamReader( file ); + public static XmlStreamReader newXmlReader(File file) throws IOException { + return new XmlStreamReader(file); } /** @@ -127,10 +122,8 @@ public static XmlStreamReader newXmlReader( File file ) * @throws IOException if any. * @see XmlStreamReader */ - public static XmlStreamReader newXmlReader( URL url ) - throws IOException - { - return new XmlStreamReader( url ); + public static XmlStreamReader newXmlReader(URL url) throws IOException { + return new XmlStreamReader(url); } /** @@ -140,9 +133,8 @@ public static XmlStreamReader newXmlReader( URL url ) * @return a reader instance for the input stream using the default platform charset. * @see Charset#defaultCharset() */ - public static Reader newPlatformReader( InputStream in ) - { - return new InputStreamReader( in ); + public static Reader newPlatformReader(InputStream in) { + return new InputStreamReader(in); } /** @@ -153,10 +145,8 @@ public static Reader newPlatformReader( InputStream in ) * @throws IOException if any. * @see Charset#defaultCharset() */ - public static Reader newPlatformReader( File file ) - throws IOException - { - return Files.newBufferedReader( file.toPath() ); + public static Reader newPlatformReader(File file) throws IOException { + return Files.newBufferedReader(file.toPath()); } /** @@ -167,10 +157,8 @@ public static Reader newPlatformReader( File file ) * @throws IOException if any. * @see Charset#defaultCharset() */ - public static Reader newPlatformReader( URL url ) - throws IOException - { - return new InputStreamReader( url.openStream() ); + public static Reader newPlatformReader(URL url) throws IOException { + return new InputStreamReader(url.openStream()); } /** @@ -182,10 +170,8 @@ public static Reader newPlatformReader( URL url ) * @throws UnsupportedEncodingException if any. * @see Supported encodings */ - public static Reader newReader( InputStream in, String encoding ) - throws UnsupportedEncodingException - { - return new InputStreamReader( in, encoding ); + public static Reader newReader(InputStream in, String encoding) throws UnsupportedEncodingException { + return new InputStreamReader(in, encoding); } /** @@ -198,10 +184,8 @@ public static Reader newReader( InputStream in, String encoding ) * @throws IOException if any. * @see Supported encodings */ - public static Reader newReader( File file, String encoding ) - throws IOException - { - return new InputStreamReader( Files.newInputStream( file.toPath() ), encoding ); + public static Reader newReader(File file, String encoding) throws IOException { + return new InputStreamReader(Files.newInputStream(file.toPath()), encoding); } /** @@ -213,9 +197,7 @@ public static Reader newReader( File file, String encoding ) * @throws IOException if any. * @see Supported encodings */ - public static Reader newReader( URL url, String encoding ) - throws IOException - { - return new InputStreamReader( url.openStream(), encoding ); + public static Reader newReader(URL url, String encoding) throws IOException { + return new InputStreamReader(url.openStream(), encoding); } } diff --git a/src/main/java/org/codehaus/plexus/util/xml/SerializerXMLWriter.java b/src/main/java/org/codehaus/plexus/util/xml/SerializerXMLWriter.java index 488103d4..6309b165 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/SerializerXMLWriter.java +++ b/src/main/java/org/codehaus/plexus/util/xml/SerializerXMLWriter.java @@ -16,23 +16,21 @@ * limitations under the License. */ -import org.codehaus.plexus.util.xml.pull.XmlSerializer; - import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Stack; +import org.codehaus.plexus.util.xml.pull.XmlSerializer; + /** * Write to an MXSerializer. * * @author Brett Porter * */ -public class SerializerXMLWriter - implements XMLWriter -{ +public class SerializerXMLWriter implements XMLWriter { private final XmlSerializer serializer; private final String namespace; @@ -41,93 +39,68 @@ public class SerializerXMLWriter private List exceptions; - public SerializerXMLWriter( String namespace, XmlSerializer serializer ) - { + public SerializerXMLWriter(String namespace, XmlSerializer serializer) { this.serializer = serializer; this.namespace = namespace; } @Override - public void startElement( String name ) - { - try - { - serializer.startTag( namespace, name ); - elements.push( name ); - } - catch ( IOException e ) - { - storeException( e ); + public void startElement(String name) { + try { + serializer.startTag(namespace, name); + elements.push(name); + } catch (IOException e) { + storeException(e); } } @Override - public void addAttribute( String key, String value ) - { - try - { - serializer.attribute( namespace, key, value ); - } - catch ( IOException e ) - { - storeException( e ); + public void addAttribute(String key, String value) { + try { + serializer.attribute(namespace, key, value); + } catch (IOException e) { + storeException(e); } } @Override - public void writeText( String text ) - { - try - { - serializer.text( text ); - } - catch ( IOException e ) - { - storeException( e ); + public void writeText(String text) { + try { + serializer.text(text); + } catch (IOException e) { + storeException(e); } } @Override - public void writeMarkup( String text ) - { - try - { - serializer.cdsect( text ); - } - catch ( IOException e ) - { - storeException( e ); + public void writeMarkup(String text) { + try { + serializer.cdsect(text); + } catch (IOException e) { + storeException(e); } } @Override - public void endElement() - { - try - { - serializer.endTag( namespace, elements.pop() ); - } - catch ( IOException e ) - { - storeException( e ); + public void endElement() { + try { + serializer.endTag(namespace, elements.pop()); + } catch (IOException e) { + storeException(e); } } /** * @todo Maybe the interface should allow IOExceptions on each? */ - private void storeException( IOException e ) - { - if ( exceptions == null ) - { + private void storeException(IOException e) { + if (exceptions == null) { exceptions = new ArrayList(); } - exceptions.add( e ); + exceptions.add(e); } - public List getExceptions() - { + public List getExceptions() { return exceptions == null ? Collections.emptyList() : exceptions; } - } diff --git a/src/main/java/org/codehaus/plexus/util/xml/StringUtils.java b/src/main/java/org/codehaus/plexus/util/xml/StringUtils.java index 8a4f1944..0e851f27 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/StringUtils.java +++ b/src/main/java/org/codehaus/plexus/util/xml/StringUtils.java @@ -77,8 +77,7 @@ * @since 1.0 * */ -class StringUtils -{ +class StringUtils { /** *

* StringUtils instances should NOT be constructed in standard programming. Instead, the class should @@ -88,9 +87,7 @@ class StringUtils * This constructor is public to permit tools that require a JavaBean manager to operate. *

*/ - private StringUtils() - { - } + private StringUtils() {} /** * Checks if a String is null or empty. @@ -102,9 +99,8 @@ private StringUtils() * @param str the String to check * @return true if the String is null, or length zero */ - public static boolean isEmpty( String str ) - { - return ( ( str == null ) || ( str.isEmpty() ) ); + public static boolean isEmpty(String str) { + return ((str == null) || (str.isEmpty())); } // Splitting @@ -115,9 +111,8 @@ public static boolean isEmpty( String str ) * @param separator Characters used as the delimiters. If null, splits on whitespace. * @return an array of parsed Strings */ - public static String[] split( String text, String separator ) - { - return split( text, separator, -1 ); + public static String[] split(String text, String separator) { + return split(text, separator, -1); } /** @@ -138,23 +133,18 @@ public static String[] split( String text, String separator ) * @param max The maximum number of elements to include in the array. A zero or negative value implies no limit. * @return an array of parsed Strings */ - private static String[] split( String str, String separator, int max ) - { + private static String[] split(String str, String separator, int max) { StringTokenizer tok; - if ( separator == null ) - { + if (separator == null) { // Null separator means we're using StringTokenizer's default // delimiter, which comprises all whitespace characters. - tok = new StringTokenizer( str ); - } - else - { - tok = new StringTokenizer( str, separator ); + tok = new StringTokenizer(str); + } else { + tok = new StringTokenizer(str, separator); } int listSize = tok.countTokens(); - if ( ( max > 0 ) && ( listSize > max ) ) - { + if ((max > 0) && (listSize > max)) { listSize = max; } @@ -162,22 +152,18 @@ private static String[] split( String str, String separator, int max ) int i = 0; int lastTokenBegin; int lastTokenEnd = 0; - while ( tok.hasMoreTokens() ) - { - if ( ( max > 0 ) && ( i == listSize - 1 ) ) - { + while (tok.hasMoreTokens()) { + if ((max > 0) && (i == listSize - 1)) { // In the situation where we hit the max yet have // tokens left over in our input, the last list // element gets all remaining text. String endToken = tok.nextToken(); - lastTokenBegin = str.indexOf( endToken, lastTokenEnd ); - list[i] = str.substring( lastTokenBegin ); + lastTokenBegin = str.indexOf(endToken, lastTokenEnd); + list[i] = str.substring(lastTokenBegin); break; - } - else - { + } else { list[i] = tok.nextToken(); - lastTokenBegin = str.indexOf( list[i], lastTokenEnd ); + lastTokenBegin = str.indexOf(list[i], lastTokenEnd); lastTokenEnd = lastTokenBegin + list[i].length(); } i++; @@ -196,12 +182,10 @@ private static String[] split( String str, String separator, int max ) * @throws NegativeArraySizeException if repeat < 0 * @throws NullPointerException if str is null */ - public static String repeat( String str, int repeat ) - { - StringBuilder buffer = new StringBuilder( repeat * str.length() ); - for ( int i = 0; i < repeat; i++ ) - { - buffer.append( str ); + public static String repeat(String str, int repeat) { + StringBuilder buffer = new StringBuilder(repeat * str.length()); + for (int i = 0; i < repeat; i++) { + buffer.append(str); } return buffer.toString(); } @@ -213,18 +197,15 @@ public static String repeat( String str, int repeat ) * @return a string with unique whitespace. * @since 1.5.7 */ - public static String removeDuplicateWhitespace( String s ) - { + public static String removeDuplicateWhitespace(String s) { StringBuilder result = new StringBuilder(); int length = s.length(); boolean isPreviousWhiteSpace = false; - for ( int i = 0; i < length; i++ ) - { - char c = s.charAt( i ); - boolean thisCharWhiteSpace = Character.isWhitespace( c ); - if ( !( isPreviousWhiteSpace && thisCharWhiteSpace ) ) - { - result.append( c ); + for (int i = 0; i < length; i++) { + char c = s.charAt(i); + boolean thisCharWhiteSpace = Character.isWhitespace(c); + if (!(isPreviousWhiteSpace && thisCharWhiteSpace)) { + result.append(c); } isPreviousWhiteSpace = thisCharWhiteSpace; } @@ -240,44 +221,33 @@ public static String removeDuplicateWhitespace( String s ) * @throws IllegalArgumentException if ls is not '\n', '\r' and '\r\n' characters. * @since 1.5.7 */ - public static String unifyLineSeparators( String s, String ls ) - { - if ( s == null ) - { + public static String unifyLineSeparators(String s, String ls) { + if (s == null) { return null; } - if ( ls == null ) - { - ls = System.getProperty( "line.separator" ); + if (ls == null) { + ls = System.getProperty("line.separator"); } - if ( !( ls.equals( "\n" ) || ls.equals( "\r" ) || ls.equals( "\r\n" ) ) ) - { - throw new IllegalArgumentException( "Requested line separator is invalid." ); + if (!(ls.equals("\n") || ls.equals("\r") || ls.equals("\r\n"))) { + throw new IllegalArgumentException("Requested line separator is invalid."); } int length = s.length(); - StringBuilder buffer = new StringBuilder( length ); - for ( int i = 0; i < length; i++ ) - { - if ( s.charAt( i ) == '\r' ) - { - if ( ( i + 1 ) < length && s.charAt( i + 1 ) == '\n' ) - { + StringBuilder buffer = new StringBuilder(length); + for (int i = 0; i < length; i++) { + if (s.charAt(i) == '\r') { + if ((i + 1) < length && s.charAt(i + 1) == '\n') { i++; } - buffer.append( ls ); - } - else if ( s.charAt( i ) == '\n' ) - { - buffer.append( ls ); - } - else - { - buffer.append( s.charAt( i ) ); + buffer.append(ls); + } else if (s.charAt(i) == '\n') { + buffer.append(ls); + } else { + buffer.append(s.charAt(i)); } } diff --git a/src/main/java/org/codehaus/plexus/util/xml/WriterFactory.java b/src/main/java/org/codehaus/plexus/util/xml/WriterFactory.java index 9978bfa4..dc09b8ad 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/WriterFactory.java +++ b/src/main/java/org/codehaus/plexus/util/xml/WriterFactory.java @@ -34,12 +34,11 @@ * * @since 1.4.4 */ -public class WriterFactory -{ +public class WriterFactory { /** * ISO Latin Alphabet #1, also known as ISO-LATIN-1. Every implementation of the Java platform is required to * support this character encoding. - * + * * @see Charset */ public static final String ISO_8859_1 = "ISO-8859-1"; @@ -47,7 +46,7 @@ public class WriterFactory /** * Seven-bit ASCII, also known as ISO646-US, also known as the Basic Latin block of the Unicode character set. Every * implementation of the Java platform is required to support this character encoding. - * + * * @see Charset */ public static final String US_ASCII = "US-ASCII"; @@ -56,7 +55,7 @@ public class WriterFactory * Sixteen-bit Unicode Transformation Format, byte order specified by a mandatory initial byte-order mark (either * order accepted on input, big-endian used on output). Every implementation of the Java platform is required to * support this character encoding. - * + * * @see Charset */ public static final String UTF_16 = "UTF-16"; @@ -64,7 +63,7 @@ public class WriterFactory /** * Sixteen-bit Unicode Transformation Format, big-endian byte order. Every implementation of the Java platform is * required to support this character encoding. - * + * * @see Charset */ public static final String UTF_16BE = "UTF-16BE"; @@ -72,7 +71,7 @@ public class WriterFactory /** * Sixteen-bit Unicode Transformation Format, little-endian byte order. Every implementation of the Java platform is * required to support this character encoding. - * + * * @see Charset */ public static final String UTF_16LE = "UTF-16LE"; @@ -80,7 +79,7 @@ public class WriterFactory /** * Eight-bit Unicode Transformation Format. Every implementation of the Java platform is required to support this * character encoding. - * + * * @see Charset */ public static final String UTF_8 = "UTF-8"; @@ -88,7 +87,7 @@ public class WriterFactory /** * The file.encoding System Property. */ - public static final String FILE_ENCODING = System.getProperty( "file.encoding" ); + public static final String FILE_ENCODING = System.getProperty("file.encoding"); /** * Create a new Writer with XML encoding detection rules. @@ -98,10 +97,8 @@ public class WriterFactory * @throws IOException if any. * @see XmlStreamWriter */ - public static XmlStreamWriter newXmlWriter( OutputStream out ) - throws IOException - { - return new XmlStreamWriter( out ); + public static XmlStreamWriter newXmlWriter(OutputStream out) throws IOException { + return new XmlStreamWriter(out); } /** @@ -112,10 +109,8 @@ public static XmlStreamWriter newXmlWriter( OutputStream out ) * @throws IOException if any. * @see XmlStreamWriter */ - public static XmlStreamWriter newXmlWriter( File file ) - throws IOException - { - return new XmlStreamWriter( file ); + public static XmlStreamWriter newXmlWriter(File file) throws IOException { + return new XmlStreamWriter(file); } /** @@ -125,9 +120,8 @@ public static XmlStreamWriter newXmlWriter( File file ) * @return a writer instance for the output stream using the default platform charset. * @see Charset#defaultCharset() */ - public static Writer newPlatformWriter( OutputStream out ) - { - return new OutputStreamWriter( out ); + public static Writer newPlatformWriter(OutputStream out) { + return new OutputStreamWriter(out); } /** @@ -138,10 +132,8 @@ public static Writer newPlatformWriter( OutputStream out ) * @throws IOException if any. * @see Charset#defaultCharset() */ - public static Writer newPlatformWriter( File file ) - throws IOException - { - return Files.newBufferedWriter( file.toPath() ); + public static Writer newPlatformWriter(File file) throws IOException { + return Files.newBufferedWriter(file.toPath()); } /** @@ -153,10 +145,8 @@ public static Writer newPlatformWriter( File file ) * @throws UnsupportedEncodingException if any. * @see Supported encodings */ - public static Writer newWriter( OutputStream out, String encoding ) - throws UnsupportedEncodingException - { - return new OutputStreamWriter( out, encoding ); + public static Writer newWriter(OutputStream out, String encoding) throws UnsupportedEncodingException { + return new OutputStreamWriter(out, encoding); } /** @@ -168,9 +158,7 @@ public static Writer newWriter( OutputStream out, String encoding ) * @throws IOException if any. * @see Supported encodings */ - public static Writer newWriter( File file, String encoding ) - throws IOException - { - return newWriter( Files.newOutputStream( file.toPath() ), encoding ); + public static Writer newWriter(File file, String encoding) throws IOException { + return newWriter(Files.newOutputStream(file.toPath()), encoding); } } diff --git a/src/main/java/org/codehaus/plexus/util/xml/XMLWriter.java b/src/main/java/org/codehaus/plexus/util/xml/XMLWriter.java index 364849ba..c8bcbc2b 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/XMLWriter.java +++ b/src/main/java/org/codehaus/plexus/util/xml/XMLWriter.java @@ -19,16 +19,14 @@ /** * */ -public interface XMLWriter -{ - void startElement( String name ); +public interface XMLWriter { + void startElement(String name); - void addAttribute( String key, String value ); + void addAttribute(String key, String value); - void writeText( String text ); + void writeText(String text); - void writeMarkup( String text ); + void writeMarkup(String text); void endElement(); - } diff --git a/src/main/java/org/codehaus/plexus/util/xml/XmlReader.java b/src/main/java/org/codehaus/plexus/util/xml/XmlReader.java index e7c7cc47..71fba5dd 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/XmlReader.java +++ b/src/main/java/org/codehaus/plexus/util/xml/XmlReader.java @@ -24,28 +24,28 @@ import java.io.InputStreamReader; import java.io.Reader; import java.io.StringReader; +import java.net.HttpURLConnection; import java.net.URL; import java.net.URLConnection; import java.nio.file.Files; -import java.net.HttpURLConnection; +import java.text.MessageFormat; import java.util.Locale; -import java.util.regex.Pattern; import java.util.regex.Matcher; -import java.text.MessageFormat; +import java.util.regex.Pattern; /** *

Character stream that handles (or at least attempts to) all the necessary Voodo to figure out the charset encoding of * the XML document within the stream.

- * + * *

IMPORTANT: This class is not related in any way to the org.xml.sax.XMLReader. This one IS a character stream.

- * + * *

All this has to be done without consuming characters from the stream, if not the XML parser will not recognized the * document as a valid XML. This is not 100% true, but it's close enough (UTF-8 BOM is not handled by all parsers right * now, XmlReader handles it and things work in all parsers).

- * + * *

The XmlReader class handles the charset encoding of XML documents in Files, raw streams and HTTP streams by offering * a wide set of constructors.

- * + * *

By default the charset encoding detection is lenient, the constructor with the lenient flag can be used for an script * (following HTTP MIME and XML specifications). All this is nicely explained by Mark Pilgrim in his blog, * Determining the character encoding of a @@ -58,9 +58,7 @@ * @since 1.4.3 */ @Deprecated -public class XmlReader - extends Reader -{ +public class XmlReader extends Reader { private static final int BUFFER_SIZE = 4096; private static final String UTF_8 = "UTF-8"; @@ -86,28 +84,26 @@ public class XmlReader /** *

Sets the default encoding to use if none is set in HTTP content-type, XML prolog and the rules based on * content-type are not adequate.

- * + * *

If it is set to NULL the content-type based rules are used.

- * + * *

By default it is NULL.

* * @param encoding charset encoding to default to. */ - public static void setDefaultEncoding( String encoding ) - { + public static void setDefaultEncoding(String encoding) { _staticDefaultEncoding = encoding; } /** *

Returns the default encoding to use if none is set in HTTP content-type, XML prolog and the rules based on * content-type are not adequate.

- * + * *

If it is NULL the content-type based rules are used.

* * @return the default encoding to use. */ - public static String getDefaultEncoding() - { + public static String getDefaultEncoding() { return _staticDefaultEncoding; } @@ -123,10 +119,8 @@ public static String getDefaultEncoding() * @param file File to create a Reader from. * @throws IOException thrown if there is a problem reading the file. */ - public XmlReader( File file ) - throws IOException - { - this( Files.newInputStream( file.toPath() ) ); + public XmlReader(File file) throws IOException { + this(Files.newInputStream(file.toPath())); } /** @@ -140,10 +134,8 @@ public XmlReader( File file ) * @param is InputStream to create a Reader from. * @throws IOException thrown if there is a problem reading the stream. */ - public XmlReader( InputStream is ) - throws IOException - { - this( is, true ); + public XmlReader(InputStream is) throws IOException { + this(is, true); } /** @@ -170,23 +162,15 @@ public XmlReader( InputStream is ) * @throws IOException thrown if there is a problem reading the stream. * @throws XmlStreamReaderException thrown if the charset encoding could not be determined according to the specs. */ - public XmlReader( InputStream is, boolean lenient ) - throws IOException, XmlStreamReaderException - { + public XmlReader(InputStream is, boolean lenient) throws IOException, XmlStreamReaderException { _defaultEncoding = _staticDefaultEncoding; - try - { - doRawStream( is, lenient ); - } - catch ( XmlStreamReaderException ex ) - { - if ( !lenient ) - { + try { + doRawStream(is, lenient); + } catch (XmlStreamReaderException ex) { + if (!lenient) { throw ex; - } - else - { - doLenientDetection( null, ex ); + } else { + doLenientDetection(null, ex); } } } @@ -206,10 +190,8 @@ public XmlReader( InputStream is, boolean lenient ) * @param url URL to create a Reader from. * @throws IOException thrown if there is a problem reading the stream of the URL. */ - public XmlReader( URL url ) - throws IOException - { - this( url.openConnection() ); + public XmlReader(URL url) throws IOException { + this(url.openConnection()); } /** @@ -227,42 +209,26 @@ public XmlReader( URL url ) * @param conn URLConnection to create a Reader from. * @throws IOException thrown if there is a problem reading the stream of the URLConnection. */ - public XmlReader( URLConnection conn ) - throws IOException - { + public XmlReader(URLConnection conn) throws IOException { _defaultEncoding = _staticDefaultEncoding; boolean lenient = true; - if ( conn instanceof HttpURLConnection ) - { - try - { - doHttpStream( conn.getInputStream(), conn.getContentType(), lenient ); - } - catch ( XmlStreamReaderException ex ) - { - doLenientDetection( conn.getContentType(), ex ); + if (conn instanceof HttpURLConnection) { + try { + doHttpStream(conn.getInputStream(), conn.getContentType(), lenient); + } catch (XmlStreamReaderException ex) { + doLenientDetection(conn.getContentType(), ex); } - } - else if ( conn.getContentType() != null ) - { - try - { - doHttpStream( conn.getInputStream(), conn.getContentType(), lenient ); + } else if (conn.getContentType() != null) { + try { + doHttpStream(conn.getInputStream(), conn.getContentType(), lenient); + } catch (XmlStreamReaderException ex) { + doLenientDetection(conn.getContentType(), ex); } - catch ( XmlStreamReaderException ex ) - { - doLenientDetection( conn.getContentType(), ex ); - } - } - else - { - try - { - doRawStream( conn.getInputStream(), lenient ); - } - catch ( XmlStreamReaderException ex ) - { - doLenientDetection( null, ex ); + } else { + try { + doRawStream(conn.getInputStream(), lenient); + } catch (XmlStreamReaderException ex) { + doLenientDetection(null, ex); } } } @@ -281,10 +247,8 @@ else if ( conn.getContentType() != null ) * @param httpContentType content-type header to use for the resolution of the charset encoding. * @throws IOException thrown if there is a problem reading the file. */ - public XmlReader( InputStream is, String httpContentType ) - throws IOException - { - this( is, httpContentType, true ); + public XmlReader(InputStream is, String httpContentType) throws IOException { + this(is, httpContentType, true); } /** @@ -316,23 +280,16 @@ public XmlReader( InputStream is, String httpContentType ) * @throws IOException thrown if there is a problem reading the file. * @throws XmlStreamReaderException thrown if the charset encoding could not be determined according to the specs. */ - public XmlReader( InputStream is, String httpContentType, boolean lenient, String defaultEncoding ) - throws IOException, XmlStreamReaderException - { - _defaultEncoding = ( defaultEncoding == null ) ? _staticDefaultEncoding : defaultEncoding; - try - { - doHttpStream( is, httpContentType, lenient ); - } - catch ( XmlStreamReaderException ex ) - { - if ( !lenient ) - { + public XmlReader(InputStream is, String httpContentType, boolean lenient, String defaultEncoding) + throws IOException, XmlStreamReaderException { + _defaultEncoding = (defaultEncoding == null) ? _staticDefaultEncoding : defaultEncoding; + try { + doHttpStream(is, httpContentType, lenient); + } catch (XmlStreamReaderException ex) { + if (!lenient) { throw ex; - } - else - { - doLenientDetection( httpContentType, ex ); + } else { + doLenientDetection(httpContentType, ex); } } } @@ -365,44 +322,33 @@ public XmlReader( InputStream is, String httpContentType, boolean lenient, Strin * @throws IOException thrown if there is a problem reading the file. * @throws XmlStreamReaderException thrown if the charset encoding could not be determined according to the specs. */ - public XmlReader( InputStream is, String httpContentType, boolean lenient ) - throws IOException, XmlStreamReaderException - { - this( is, httpContentType, lenient, null ); + public XmlReader(InputStream is, String httpContentType, boolean lenient) + throws IOException, XmlStreamReaderException { + this(is, httpContentType, lenient, null); } - private void doLenientDetection( String httpContentType, XmlStreamReaderException ex ) - throws IOException - { - if ( httpContentType != null ) - { - if ( httpContentType.startsWith( "text/html" ) ) - { - httpContentType = httpContentType.substring( "text/html".length() ); + private void doLenientDetection(String httpContentType, XmlStreamReaderException ex) throws IOException { + if (httpContentType != null) { + if (httpContentType.startsWith("text/html")) { + httpContentType = httpContentType.substring("text/html".length()); httpContentType = "text/xml" + httpContentType; - try - { - doHttpStream( ex.getInputStream(), httpContentType, true ); + try { + doHttpStream(ex.getInputStream(), httpContentType, true); ex = null; - } - catch ( XmlStreamReaderException ex2 ) - { + } catch (XmlStreamReaderException ex2) { ex = ex2; } } } - if ( ex != null ) - { + if (ex != null) { String encoding = ex.getXmlEncoding(); - if ( encoding == null ) - { + if (encoding == null) { encoding = ex.getContentTypeEncoding(); } - if ( encoding == null ) - { - encoding = ( _defaultEncoding == null ) ? UTF_8 : _defaultEncoding; + if (encoding == null) { + encoding = (_defaultEncoding == null) ? UTF_8 : _defaultEncoding; } - prepareReader( ex.getInputStream(), encoding ); + prepareReader(ex.getInputStream(), encoding); } } @@ -412,16 +358,13 @@ private void doLenientDetection( String httpContentType, XmlStreamReaderExceptio * * @return charset encoding. */ - public String getEncoding() - { + public String getEncoding() { return _encoding; } @Override - public int read( char[] buf, int offset, int len ) - throws IOException - { - return _reader.read( buf, offset, len ); + public int read(char[] buf, int offset, int len) throws IOException { + return _reader.read(buf, offset, len); } /** @@ -431,183 +374,157 @@ public int read( char[] buf, int offset, int len ) * @throws IOException thrown if there was a problem closing the stream. */ @Override - public void close() - throws IOException - { + public void close() throws IOException { _reader.close(); } - private void doRawStream( InputStream is, boolean lenient ) - throws IOException - { - BufferedInputStream pis = new BufferedInputStream( is, BUFFER_SIZE ); - String bomEnc = getBOMEncoding( pis ); - String xmlGuessEnc = getXMLGuessEncoding( pis ); - String xmlEnc = getXmlProlog( pis, xmlGuessEnc ); - String encoding = calculateRawEncoding( bomEnc, xmlGuessEnc, xmlEnc, pis ); - prepareReader( pis, encoding ); + private void doRawStream(InputStream is, boolean lenient) throws IOException { + BufferedInputStream pis = new BufferedInputStream(is, BUFFER_SIZE); + String bomEnc = getBOMEncoding(pis); + String xmlGuessEnc = getXMLGuessEncoding(pis); + String xmlEnc = getXmlProlog(pis, xmlGuessEnc); + String encoding = calculateRawEncoding(bomEnc, xmlGuessEnc, xmlEnc, pis); + prepareReader(pis, encoding); } - private void doHttpStream( InputStream is, String httpContentType, boolean lenient ) - throws IOException - { - BufferedInputStream pis = new BufferedInputStream( is, BUFFER_SIZE ); - String cTMime = getContentTypeMime( httpContentType ); - String cTEnc = getContentTypeEncoding( httpContentType ); - String bomEnc = getBOMEncoding( pis ); - String xmlGuessEnc = getXMLGuessEncoding( pis ); - String xmlEnc = getXmlProlog( pis, xmlGuessEnc ); - String encoding = calculateHttpEncoding( cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc, pis, lenient ); - prepareReader( pis, encoding ); + private void doHttpStream(InputStream is, String httpContentType, boolean lenient) throws IOException { + BufferedInputStream pis = new BufferedInputStream(is, BUFFER_SIZE); + String cTMime = getContentTypeMime(httpContentType); + String cTEnc = getContentTypeEncoding(httpContentType); + String bomEnc = getBOMEncoding(pis); + String xmlGuessEnc = getXMLGuessEncoding(pis); + String xmlEnc = getXmlProlog(pis, xmlGuessEnc); + String encoding = calculateHttpEncoding(cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc, pis, lenient); + prepareReader(pis, encoding); } - private void prepareReader( InputStream is, String encoding ) - throws IOException - { - _reader = new InputStreamReader( is, encoding ); + private void prepareReader(InputStream is, String encoding) throws IOException { + _reader = new InputStreamReader(is, encoding); _encoding = encoding; } // InputStream is passed for XmlStreamReaderException creation only - private String calculateRawEncoding( String bomEnc, String xmlGuessEnc, String xmlEnc, InputStream is ) - throws IOException - { + private String calculateRawEncoding(String bomEnc, String xmlGuessEnc, String xmlEnc, InputStream is) + throws IOException { String encoding; - if ( bomEnc == null ) - { - if ( xmlGuessEnc == null || xmlEnc == null ) - { - encoding = ( _defaultEncoding == null ) ? UTF_8 : _defaultEncoding; - } - else if ( xmlEnc.equals( UTF_16 ) && ( xmlGuessEnc.equals( UTF_16BE ) || xmlGuessEnc.equals( UTF_16LE ) ) ) - { + if (bomEnc == null) { + if (xmlGuessEnc == null || xmlEnc == null) { + encoding = (_defaultEncoding == null) ? UTF_8 : _defaultEncoding; + } else if (xmlEnc.equals(UTF_16) && (xmlGuessEnc.equals(UTF_16BE) || xmlGuessEnc.equals(UTF_16LE))) { encoding = xmlGuessEnc; - } - else - { + } else { encoding = xmlEnc; } - } - else if ( bomEnc.equals( UTF_8 ) ) - { - if ( xmlGuessEnc != null && !xmlGuessEnc.equals( UTF_8 ) ) - { - throw new XmlStreamReaderException( RAW_EX_1.format( new Object[] { bomEnc, xmlGuessEnc, xmlEnc } ), - bomEnc, xmlGuessEnc, xmlEnc, is ); + } else if (bomEnc.equals(UTF_8)) { + if (xmlGuessEnc != null && !xmlGuessEnc.equals(UTF_8)) { + throw new XmlStreamReaderException( + RAW_EX_1.format(new Object[] {bomEnc, xmlGuessEnc, xmlEnc}), bomEnc, xmlGuessEnc, xmlEnc, is); } - if ( xmlEnc != null && !xmlEnc.equals( UTF_8 ) ) - { - throw new XmlStreamReaderException( RAW_EX_1.format( new Object[] { bomEnc, xmlGuessEnc, xmlEnc } ), - bomEnc, xmlGuessEnc, xmlEnc, is ); + if (xmlEnc != null && !xmlEnc.equals(UTF_8)) { + throw new XmlStreamReaderException( + RAW_EX_1.format(new Object[] {bomEnc, xmlGuessEnc, xmlEnc}), bomEnc, xmlGuessEnc, xmlEnc, is); } encoding = UTF_8; - } - else if ( bomEnc.equals( UTF_16BE ) || bomEnc.equals( UTF_16LE ) ) - { - if ( xmlGuessEnc != null && !xmlGuessEnc.equals( bomEnc ) ) - { - throw new IOException( RAW_EX_1.format( new Object[] { bomEnc, xmlGuessEnc, xmlEnc } ) ); + } else if (bomEnc.equals(UTF_16BE) || bomEnc.equals(UTF_16LE)) { + if (xmlGuessEnc != null && !xmlGuessEnc.equals(bomEnc)) { + throw new IOException(RAW_EX_1.format(new Object[] {bomEnc, xmlGuessEnc, xmlEnc})); } - if ( xmlEnc != null && !xmlEnc.equals( UTF_16 ) && !xmlEnc.equals( bomEnc ) ) - { - throw new XmlStreamReaderException( RAW_EX_1.format( new Object[] { bomEnc, xmlGuessEnc, xmlEnc } ), - bomEnc, xmlGuessEnc, xmlEnc, is ); + if (xmlEnc != null && !xmlEnc.equals(UTF_16) && !xmlEnc.equals(bomEnc)) { + throw new XmlStreamReaderException( + RAW_EX_1.format(new Object[] {bomEnc, xmlGuessEnc, xmlEnc}), bomEnc, xmlGuessEnc, xmlEnc, is); } encoding = bomEnc; - } - else - { - throw new XmlStreamReaderException( RAW_EX_2.format( new Object[] { bomEnc, xmlGuessEnc, xmlEnc } ), bomEnc, - xmlGuessEnc, xmlEnc, is ); + } else { + throw new XmlStreamReaderException( + RAW_EX_2.format(new Object[] {bomEnc, xmlGuessEnc, xmlEnc}), bomEnc, xmlGuessEnc, xmlEnc, is); } return encoding; } // InputStream is passed for XmlStreamReaderException creation only - private String calculateHttpEncoding( String cTMime, String cTEnc, String bomEnc, String xmlGuessEnc, String xmlEnc, - InputStream is, boolean lenient ) - throws IOException - { + private String calculateHttpEncoding( + String cTMime, + String cTEnc, + String bomEnc, + String xmlGuessEnc, + String xmlEnc, + InputStream is, + boolean lenient) + throws IOException { String encoding; - if ( lenient & xmlEnc != null ) - { + if (lenient & xmlEnc != null) { encoding = xmlEnc; - } - else - { - boolean appXml = isAppXml( cTMime ); - boolean textXml = isTextXml( cTMime ); - if ( appXml || textXml ) - { - if ( cTEnc == null ) - { - if ( appXml ) - { - encoding = calculateRawEncoding( bomEnc, xmlGuessEnc, xmlEnc, is ); - } - else - { - encoding = ( _defaultEncoding == null ) ? US_ASCII : _defaultEncoding; + } else { + boolean appXml = isAppXml(cTMime); + boolean textXml = isTextXml(cTMime); + if (appXml || textXml) { + if (cTEnc == null) { + if (appXml) { + encoding = calculateRawEncoding(bomEnc, xmlGuessEnc, xmlEnc, is); + } else { + encoding = (_defaultEncoding == null) ? US_ASCII : _defaultEncoding; } - } - else if ( bomEnc != null && ( cTEnc.equals( UTF_16BE ) || cTEnc.equals( UTF_16LE ) ) ) - { - throw new XmlStreamReaderException( HTTP_EX_1.format( new Object[] { cTMime, cTEnc, bomEnc, - xmlGuessEnc, xmlEnc } ), cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc, is ); - } - else if ( cTEnc.equals( UTF_16 ) ) - { - if ( bomEnc != null && bomEnc.startsWith( UTF_16 ) ) - { + } else if (bomEnc != null && (cTEnc.equals(UTF_16BE) || cTEnc.equals(UTF_16LE))) { + throw new XmlStreamReaderException( + HTTP_EX_1.format(new Object[] {cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc}), + cTMime, + cTEnc, + bomEnc, + xmlGuessEnc, + xmlEnc, + is); + } else if (cTEnc.equals(UTF_16)) { + if (bomEnc != null && bomEnc.startsWith(UTF_16)) { encoding = bomEnc; + } else { + throw new XmlStreamReaderException( + HTTP_EX_2.format(new Object[] {cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc}), + cTMime, + cTEnc, + bomEnc, + xmlGuessEnc, + xmlEnc, + is); } - else - { - throw new XmlStreamReaderException( HTTP_EX_2.format( new Object[] { cTMime, cTEnc, bomEnc, - xmlGuessEnc, xmlEnc } ), cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc, is ); - } - } - else - { + } else { encoding = cTEnc; } - } - else - { - throw new XmlStreamReaderException( HTTP_EX_3.format( new Object[] { cTMime, cTEnc, bomEnc, xmlGuessEnc, - xmlEnc } ), cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc, is ); + } else { + throw new XmlStreamReaderException( + HTTP_EX_3.format(new Object[] {cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc}), + cTMime, + cTEnc, + bomEnc, + xmlGuessEnc, + xmlEnc, + is); } } return encoding; } // returns MIME type or NULL if httpContentType is NULL - private static String getContentTypeMime( String httpContentType ) - { + private static String getContentTypeMime(String httpContentType) { String mime = null; - if ( httpContentType != null ) - { - int i = httpContentType.indexOf( ";" ); - mime = ( ( i == -1 ) ? httpContentType : httpContentType.substring( 0, i ) ).trim(); + if (httpContentType != null) { + int i = httpContentType.indexOf(";"); + mime = ((i == -1) ? httpContentType : httpContentType.substring(0, i)).trim(); } return mime; } - private static final Pattern CHARSET_PATTERN = Pattern.compile( "charset=([.[^; ]]*)" ); + private static final Pattern CHARSET_PATTERN = Pattern.compile("charset=([.[^; ]]*)"); // returns charset parameter value, NULL if not present, NULL if httpContentType is NULL - private static String getContentTypeEncoding( String httpContentType ) - { + private static String getContentTypeEncoding(String httpContentType) { String encoding = null; - if ( httpContentType != null ) - { - int i = httpContentType.indexOf( ";" ); - if ( i > -1 ) - { - String postMime = httpContentType.substring( i + 1 ); - Matcher m = CHARSET_PATTERN.matcher( postMime ); - encoding = ( m.find() ) ? m.group( 1 ) : null; - encoding = ( encoding != null ) ? encoding.toUpperCase( Locale.ENGLISH ) : null; + if (httpContentType != null) { + int i = httpContentType.indexOf(";"); + if (i > -1) { + String postMime = httpContentType.substring(i + 1); + Matcher m = CHARSET_PATTERN.matcher(postMime); + encoding = (m.find()) ? m.group(1) : null; + encoding = (encoding != null) ? encoding.toUpperCase(Locale.ENGLISH) : null; } } return encoding; @@ -615,127 +532,97 @@ private static String getContentTypeEncoding( String httpContentType ) // returns the BOM in the stream, NULL if not present, // if there was BOM the in the stream it is consumed - private static String getBOMEncoding( BufferedInputStream is ) - throws IOException - { + private static String getBOMEncoding(BufferedInputStream is) throws IOException { String encoding = null; int[] bytes = new int[3]; - is.mark( 3 ); + is.mark(3); bytes[0] = is.read(); bytes[1] = is.read(); bytes[2] = is.read(); - if ( bytes[0] == 0xFE && bytes[1] == 0xFF ) - { + if (bytes[0] == 0xFE && bytes[1] == 0xFF) { encoding = UTF_16BE; is.reset(); is.read(); is.read(); - } - else if ( bytes[0] == 0xFF && bytes[1] == 0xFE ) - { + } else if (bytes[0] == 0xFF && bytes[1] == 0xFE) { encoding = UTF_16LE; is.reset(); is.read(); is.read(); - } - else if ( bytes[0] == 0xEF && bytes[1] == 0xBB && bytes[2] == 0xBF ) - { + } else if (bytes[0] == 0xEF && bytes[1] == 0xBB && bytes[2] == 0xBF) { encoding = UTF_8; - } - else - { + } else { is.reset(); } return encoding; } // returns the best guess for the encoding by looking the first bytes of the stream, ', NULL if none - private static String getXmlProlog( BufferedInputStream is, String guessedEnc ) - throws IOException - { + private static String getXmlProlog(BufferedInputStream is, String guessedEnc) throws IOException { String encoding = null; - if ( guessedEnc != null ) - { + if (guessedEnc != null) { byte[] bytes = new byte[BUFFER_SIZE]; - is.mark( BUFFER_SIZE ); + is.mark(BUFFER_SIZE); int offset = 0; int max = BUFFER_SIZE; - int c = is.read( bytes, offset, max ); + int c = is.read(bytes, offset, max); int firstGT = -1; String xmlProlog = null; - while ( c != -1 && firstGT == -1 && offset < BUFFER_SIZE ) - { + while (c != -1 && firstGT == -1 && offset < BUFFER_SIZE) { offset += c; max -= c; - c = is.read( bytes, offset, max ); - xmlProlog = new String( bytes, 0, offset, guessedEnc ); - firstGT = xmlProlog.indexOf( '>' ); + c = is.read(bytes, offset, max); + xmlProlog = new String(bytes, 0, offset, guessedEnc); + firstGT = xmlProlog.indexOf('>'); } - if ( firstGT == -1 ) - { - if ( c == -1 ) - { - throw new IOException( "Unexpected end of XML stream" ); - } - else - { - throw new IOException( "XML prolog or ROOT element not found on first " + offset + " bytes" ); + if (firstGT == -1) { + if (c == -1) { + throw new IOException("Unexpected end of XML stream"); + } else { + throw new IOException("XML prolog or ROOT element not found on first " + offset + " bytes"); } } int bytesRead = offset; - if ( bytesRead > 0 ) - { + if (bytesRead > 0) { is.reset(); - BufferedReader bReader = - new BufferedReader( new StringReader( xmlProlog.substring( 0, firstGT + 1 ) ) ); + BufferedReader bReader = new BufferedReader(new StringReader(xmlProlog.substring(0, firstGT + 1))); StringBuilder prolog = new StringBuilder(); String line = bReader.readLine(); - while ( line != null ) - { - prolog.append( line ); + while (line != null) { + prolog.append(line); line = bReader.readLine(); } - Matcher m = ENCODING_PATTERN.matcher( prolog ); - if ( m.find() ) - { - encoding = m.group( 1 ).toUpperCase( Locale.ENGLISH ); - encoding = encoding.substring( 1, encoding.length() - 1 ); + Matcher m = ENCODING_PATTERN.matcher(prolog); + if (m.find()) { + encoding = m.group(1).toUpperCase(Locale.ENGLISH); + encoding = encoding.substring(1, encoding.length() - 1); } } } @@ -743,33 +630,34 @@ private static String getXmlProlog( BufferedInputStream is, String guessedEnc ) } // indicates if the MIME type belongs to the APPLICATION XML family - private static boolean isAppXml( String mime ) - { - return mime != null && ( mime.equals( "application/xml" ) || mime.equals( "application/xml-dtd" ) - || mime.equals( "application/xml-external-parsed-entity" ) - || ( mime.startsWith( "application/" ) && mime.endsWith( "+xml" ) ) ); + private static boolean isAppXml(String mime) { + return mime != null + && (mime.equals("application/xml") + || mime.equals("application/xml-dtd") + || mime.equals("application/xml-external-parsed-entity") + || (mime.startsWith("application/") && mime.endsWith("+xml"))); } // indicates if the MIME type belongs to the TEXT XML family - private static boolean isTextXml( String mime ) - { - return mime != null && ( mime.equals( "text/xml" ) || mime.equals( "text/xml-external-parsed-entity" ) - || ( mime.startsWith( "text/" ) && mime.endsWith( "+xml" ) ) ); + private static boolean isTextXml(String mime) { + return mime != null + && (mime.equals("text/xml") + || mime.equals("text/xml-external-parsed-entity") + || (mime.startsWith("text/") && mime.endsWith("+xml"))); } private static final MessageFormat RAW_EX_1 = - new MessageFormat( "Invalid encoding, BOM [{0}] XML guess [{1}] XML prolog [{2}] encoding mismatch" ); + new MessageFormat("Invalid encoding, BOM [{0}] XML guess [{1}] XML prolog [{2}] encoding mismatch"); private static final MessageFormat RAW_EX_2 = - new MessageFormat( "Invalid encoding, BOM [{0}] XML guess [{1}] XML prolog [{2}] unknown BOM" ); - - private static final MessageFormat HTTP_EX_1 = - new MessageFormat( "Invalid encoding, CT-MIME [{0}] CT-Enc [{1}] BOM [{2}] XML guess [{3}] XML prolog [{4}], BOM must be NULL" ); + new MessageFormat("Invalid encoding, BOM [{0}] XML guess [{1}] XML prolog [{2}] unknown BOM"); - private static final MessageFormat HTTP_EX_2 = - new MessageFormat( "Invalid encoding, CT-MIME [{0}] CT-Enc [{1}] BOM [{2}] XML guess [{3}] XML prolog [{4}], encoding mismatch" ); + private static final MessageFormat HTTP_EX_1 = new MessageFormat( + "Invalid encoding, CT-MIME [{0}] CT-Enc [{1}] BOM [{2}] XML guess [{3}] XML prolog [{4}], BOM must be NULL"); - private static final MessageFormat HTTP_EX_3 = - new MessageFormat( "Invalid encoding, CT-MIME [{0}] CT-Enc [{1}] BOM [{2}] XML guess [{3}] XML prolog [{4}], Invalid MIME" ); + private static final MessageFormat HTTP_EX_2 = new MessageFormat( + "Invalid encoding, CT-MIME [{0}] CT-Enc [{1}] BOM [{2}] XML guess [{3}] XML prolog [{4}], encoding mismatch"); + private static final MessageFormat HTTP_EX_3 = new MessageFormat( + "Invalid encoding, CT-MIME [{0}] CT-Enc [{1}] BOM [{2}] XML guess [{3}] XML prolog [{4}], Invalid MIME"); } diff --git a/src/main/java/org/codehaus/plexus/util/xml/XmlReaderException.java b/src/main/java/org/codehaus/plexus/util/xml/XmlReaderException.java index 1e015506..5fb2dcab 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/XmlReaderException.java +++ b/src/main/java/org/codehaus/plexus/util/xml/XmlReaderException.java @@ -16,8 +16,8 @@ */ package org.codehaus.plexus.util.xml; -import java.io.InputStream; import java.io.IOException; +import java.io.InputStream; /** * The XmlReaderException is thrown by the XmlReader constructors if the charset encoding can not be determined @@ -31,9 +31,7 @@ * @version revision 1.1 taken on 26/06/2007 from Rome (see * https://rome.dev.java.net/source/browse/rome/src/java/com/sun/syndication/io/XmlReaderException.java) */ -public class XmlReaderException - extends IOException -{ +public class XmlReaderException extends IOException { private String _bomEncoding; private String _xmlGuessEncoding; @@ -58,9 +56,8 @@ public class XmlReaderException * @param xmlEnc XML prolog encoding. * @param is the unconsumed InputStream. */ - public XmlReaderException( String msg, String bomEnc, String xmlGuessEnc, String xmlEnc, InputStream is ) - { - this( msg, null, null, bomEnc, xmlGuessEnc, xmlEnc, is ); + public XmlReaderException(String msg, String bomEnc, String xmlGuessEnc, String xmlEnc, InputStream is) { + this(msg, null, null, bomEnc, xmlGuessEnc, xmlEnc, is); } /** @@ -77,10 +74,9 @@ public XmlReaderException( String msg, String bomEnc, String xmlGuessEnc, String * @param xmlEnc XML prolog encoding. * @param is the unconsumed InputStream. */ - public XmlReaderException( String msg, String ctMime, String ctEnc, String bomEnc, String xmlGuessEnc, - String xmlEnc, InputStream is ) - { - super( msg ); + public XmlReaderException( + String msg, String ctMime, String ctEnc, String bomEnc, String xmlGuessEnc, String xmlEnc, InputStream is) { + super(msg); _contentTypeMime = ctMime; _contentTypeEncoding = ctEnc; _bomEncoding = bomEnc; @@ -95,8 +91,7 @@ public XmlReaderException( String msg, String ctMime, String ctEnc, String bomEn * * @return the BOM encoding, null if none. */ - public String getBomEncoding() - { + public String getBomEncoding() { return _bomEncoding; } @@ -106,8 +101,7 @@ public String getBomEncoding() * * @return the encoding guess, null if it couldn't be guessed. */ - public String getXmlGuessEncoding() - { + public String getXmlGuessEncoding() { return _xmlGuessEncoding; } @@ -117,8 +111,7 @@ public String getXmlGuessEncoding() * * @return the encoding of the XML prolog, null if none. */ - public String getXmlEncoding() - { + public String getXmlEncoding() { return _xmlEncoding; } @@ -129,8 +122,7 @@ public String getXmlEncoding() * @return the MIME type in the content-type, null if there was not content-type or the encoding detection did not * involve HTTP. */ - public String getContentTypeMime() - { + public String getContentTypeMime() { return _contentTypeMime; } @@ -141,8 +133,7 @@ public String getContentTypeMime() * @return the encoding in the content-type, null if there was not content-type, no encoding in it or the encoding * detection did not involve HTTP. */ - public String getContentTypeEncoding() - { + public String getContentTypeEncoding() { return _contentTypeEncoding; } @@ -153,8 +144,7 @@ public String getContentTypeEncoding() * * @return the unconsumed InputStream. */ - public InputStream getInputStream() - { + public InputStream getInputStream() { return _is; } } diff --git a/src/main/java/org/codehaus/plexus/util/xml/XmlStreamReader.java b/src/main/java/org/codehaus/plexus/util/xml/XmlStreamReader.java index 5c26aa98..1520481a 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/XmlStreamReader.java +++ b/src/main/java/org/codehaus/plexus/util/xml/XmlStreamReader.java @@ -40,15 +40,13 @@ *
Determining the character encoding of a * feed. *

- * + * * @author Alejandro Abdelnur * @version revision 1.17 taken on 26/06/2007 from Rome (see * https://rome.dev.java.net/source/browse/rome/src/java/com/sun/syndication/io/XmlReader.java) * @since 1.4.4 */ -public class XmlStreamReader - extends XmlReader -{ +public class XmlStreamReader extends XmlReader { /** * Creates a Reader for a File. *

@@ -57,14 +55,12 @@ public class XmlStreamReader *

* It does a lenient charset encoding detection, check the constructor with the lenient parameter for details. *

- * + * * @param file File to create a Reader from. * @throws IOException thrown if there is a problem reading the file. */ - public XmlStreamReader( File file ) - throws IOException - { - super( file ); + public XmlStreamReader(File file) throws IOException { + super(file); } /** @@ -74,14 +70,12 @@ public XmlStreamReader( File file ) *

* It does a lenient charset encoding detection, check the constructor with the lenient parameter for details. *

- * + * * @param is InputStream to create a Reader from. * @throws IOException thrown if there is a problem reading the stream. */ - public XmlStreamReader( InputStream is ) - throws IOException - { - super( is ); + public XmlStreamReader(InputStream is) throws IOException { + super(is); } /** @@ -102,16 +96,14 @@ public XmlStreamReader( InputStream is ) *

* If lenient detection is indicated an XmlStreamReaderException is never thrown. *

- * + * * @param is InputStream to create a Reader from. * @param lenient indicates if the charset encoding detection should be relaxed. * @throws IOException thrown if there is a problem reading the stream. * @throws XmlStreamReaderException thrown if the charset encoding could not be determined according to the specs. */ - public XmlStreamReader( InputStream is, boolean lenient ) - throws IOException, XmlStreamReaderException - { - super( is, lenient ); + public XmlStreamReader(InputStream is, boolean lenient) throws IOException, XmlStreamReaderException { + super(is, lenient); } /** @@ -125,14 +117,12 @@ public XmlStreamReader( InputStream is, boolean lenient ) *

* It does a lenient charset encoding detection, check the constructor with the lenient parameter for details. *

- * + * * @param url URL to create a Reader from. * @throws IOException thrown if there is a problem reading the stream of the URL. */ - public XmlStreamReader( URL url ) - throws IOException - { - super( url ); + public XmlStreamReader(URL url) throws IOException { + super(url); } /** @@ -146,14 +136,12 @@ public XmlStreamReader( URL url ) *

* It does a lenient charset encoding detection, check the constructor with the lenient parameter for details. *

- * + * * @param conn URLConnection to create a Reader from. * @throws IOException thrown if there is a problem reading the stream of the URLConnection. */ - public XmlStreamReader( URLConnection conn ) - throws IOException - { - super( conn ); + public XmlStreamReader(URLConnection conn) throws IOException { + super(conn); } /** @@ -165,15 +153,13 @@ public XmlStreamReader( URLConnection conn ) *

* It does a lenient charset encoding detection, check the constructor with the lenient parameter for details. *

- * + * * @param is InputStream to create the reader from. * @param httpContentType content-type header to use for the resolution of the charset encoding. * @throws IOException thrown if there is a problem reading the file. */ - public XmlStreamReader( InputStream is, String httpContentType ) - throws IOException - { - super( is, httpContentType ); + public XmlStreamReader(InputStream is, String httpContentType) throws IOException { + super(is, httpContentType); } /** @@ -197,7 +183,7 @@ public XmlStreamReader( InputStream is, String httpContentType ) *

* If lenient detection is indicated an XmlStreamReaderException is never thrown. *

- * + * * @param is InputStream to create the reader from. * @param httpContentType content-type header to use for the resolution of the charset encoding. * @param lenient indicates if the charset encoding detection should be relaxed. @@ -205,10 +191,9 @@ public XmlStreamReader( InputStream is, String httpContentType ) * @throws IOException thrown if there is a problem reading the file. * @throws XmlStreamReaderException thrown if the charset encoding could not be determined according to the specs. */ - public XmlStreamReader( InputStream is, String httpContentType, boolean lenient, String defaultEncoding ) - throws IOException, XmlStreamReaderException - { - super( is, httpContentType, lenient, defaultEncoding ); + public XmlStreamReader(InputStream is, String httpContentType, boolean lenient, String defaultEncoding) + throws IOException, XmlStreamReaderException { + super(is, httpContentType, lenient, defaultEncoding); } /** @@ -232,16 +217,15 @@ public XmlStreamReader( InputStream is, String httpContentType, boolean lenient, *

* If lenient detection is indicated an XmlStreamReaderException is never thrown. *

- * + * * @param is InputStream to create the reader from. * @param httpContentType content-type header to use for the resolution of the charset encoding. * @param lenient indicates if the charset encoding detection should be relaxed. * @throws IOException thrown if there is a problem reading the file. * @throws XmlStreamReaderException thrown if the charset encoding could not be determined according to the specs. */ - public XmlStreamReader( InputStream is, String httpContentType, boolean lenient ) - throws IOException, XmlStreamReaderException - { - super( is, httpContentType, lenient ); + public XmlStreamReader(InputStream is, String httpContentType, boolean lenient) + throws IOException, XmlStreamReaderException { + super(is, httpContentType, lenient); } } diff --git a/src/main/java/org/codehaus/plexus/util/xml/XmlStreamReaderException.java b/src/main/java/org/codehaus/plexus/util/xml/XmlStreamReaderException.java index dc919981..1901c40c 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/XmlStreamReaderException.java +++ b/src/main/java/org/codehaus/plexus/util/xml/XmlStreamReaderException.java @@ -31,9 +31,7 @@ * @version revision 1.1 taken on 26/06/2007 from Rome (see * https://rome.dev.java.net/source/browse/rome/src/java/com/sun/syndication/io/XmlReaderException.java) */ -public class XmlStreamReaderException - extends XmlReaderException -{ +public class XmlStreamReaderException extends XmlReaderException { /** * Creates an exception instance if the charset encoding could not be determined. *

@@ -46,9 +44,8 @@ public class XmlStreamReaderException * @param xmlEnc XML prolog encoding. * @param is the unconsumed InputStream. */ - public XmlStreamReaderException( String msg, String bomEnc, String xmlGuessEnc, String xmlEnc, InputStream is ) - { - super( msg, bomEnc, xmlGuessEnc, xmlEnc, is ); + public XmlStreamReaderException(String msg, String bomEnc, String xmlGuessEnc, String xmlEnc, InputStream is) { + super(msg, bomEnc, xmlGuessEnc, xmlEnc, is); } /** @@ -65,9 +62,8 @@ public XmlStreamReaderException( String msg, String bomEnc, String xmlGuessEnc, * @param xmlEnc XML prolog encoding. * @param is the unconsumed InputStream. */ - public XmlStreamReaderException( String msg, String ctMime, String ctEnc, String bomEnc, String xmlGuessEnc, - String xmlEnc, InputStream is ) - { - super( msg, ctMime, ctEnc, bomEnc, xmlGuessEnc, xmlEnc, is ); + public XmlStreamReaderException( + String msg, String ctMime, String ctEnc, String bomEnc, String xmlGuessEnc, String xmlEnc, InputStream is) { + super(msg, ctMime, ctEnc, bomEnc, xmlGuessEnc, xmlEnc, is); } } diff --git a/src/main/java/org/codehaus/plexus/util/xml/XmlStreamWriter.java b/src/main/java/org/codehaus/plexus/util/xml/XmlStreamWriter.java index 9b5f0a92..aec451aa 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/XmlStreamWriter.java +++ b/src/main/java/org/codehaus/plexus/util/xml/XmlStreamWriter.java @@ -30,17 +30,15 @@ /** * Character stream that handles (or at least attempts to) all the necessary Voodo to figure out the charset encoding of * the XML document written to the stream. - * + * * @author Herve Boutemy * * @since 1.4.4 */ -public class XmlStreamWriter - extends Writer -{ +public class XmlStreamWriter extends Writer { private static final int BUFFER_SIZE = 4096; - private StringWriter xmlPrologWriter = new StringWriter( BUFFER_SIZE ); + private StringWriter xmlPrologWriter = new StringWriter(BUFFER_SIZE); private OutputStream out; @@ -48,117 +46,86 @@ public class XmlStreamWriter private String encoding; - public XmlStreamWriter( OutputStream out ) - { + public XmlStreamWriter(OutputStream out) { this.out = out; } - public XmlStreamWriter( File file ) - throws IOException - { - this( Files.newOutputStream( file.toPath() ) ); + public XmlStreamWriter(File file) throws IOException { + this(Files.newOutputStream(file.toPath())); } - public String getEncoding() - { + public String getEncoding() { return encoding; } @Override - public void close() - throws IOException - { - if ( writer == null ) - { + public void close() throws IOException { + if (writer == null) { encoding = "UTF-8"; - writer = new OutputStreamWriter( out, encoding ); - writer.write( xmlPrologWriter.toString() ); + writer = new OutputStreamWriter(out, encoding); + writer.write(xmlPrologWriter.toString()); } writer.close(); } @Override - public void flush() - throws IOException - { - if ( writer != null ) - { + public void flush() throws IOException { + if (writer != null) { writer.flush(); } } - private void detectEncoding( char[] cbuf, int off, int len ) - throws IOException - { + private void detectEncoding(char[] cbuf, int off, int len) throws IOException { int size = len; StringBuffer xmlProlog = xmlPrologWriter.getBuffer(); - if ( xmlProlog.length() + len > BUFFER_SIZE ) - { + if (xmlProlog.length() + len > BUFFER_SIZE) { size = BUFFER_SIZE - xmlProlog.length(); } - xmlPrologWriter.write( cbuf, off, size ); + xmlPrologWriter.write(cbuf, off, size); // try to determine encoding - if ( xmlProlog.length() >= 5 ) - { - if ( xmlProlog.substring( 0, 5 ).equals( "= 5) { + if (xmlProlog.substring(0, 5).equals("" ); - if ( xmlPrologEnd > 0 ) - { + int xmlPrologEnd = xmlProlog.indexOf("?>"); + if (xmlPrologEnd > 0) { // ok, full XML prolog written: let's extract encoding - Matcher m = ENCODING_PATTERN.matcher( xmlProlog.substring( 0, xmlPrologEnd ) ); - if ( m.find() ) - { - encoding = m.group( 1 ).toUpperCase( Locale.ENGLISH ); - encoding = encoding.substring( 1, encoding.length() - 1 ); - } - else - { + Matcher m = ENCODING_PATTERN.matcher(xmlProlog.substring(0, xmlPrologEnd)); + if (m.find()) { + encoding = m.group(1).toUpperCase(Locale.ENGLISH); + encoding = encoding.substring(1, encoding.length() - 1); + } else { // no encoding found in XML prolog: using default encoding encoding = "UTF-8"; } - } - else - { - if ( xmlProlog.length() >= BUFFER_SIZE ) - { + } else { + if (xmlProlog.length() >= BUFFER_SIZE) { // no encoding found in first characters: using default encoding encoding = "UTF-8"; } } - } - else - { + } else { // no XML prolog: using default encoding encoding = "UTF-8"; } - if ( encoding != null ) - { + if (encoding != null) { // encoding has been chosen: let's do it xmlPrologWriter = null; - writer = new OutputStreamWriter( out, encoding ); - writer.write( xmlProlog.toString() ); - if ( len > size ) - { - writer.write( cbuf, off + size, len - size ); + writer = new OutputStreamWriter(out, encoding); + writer.write(xmlProlog.toString()); + if (len > size) { + writer.write(cbuf, off + size, len - size); } } } } @Override - public void write( char[] cbuf, int off, int len ) - throws IOException - { - if ( xmlPrologWriter != null ) - { - detectEncoding( cbuf, off, len ); - } - else - { - writer.write( cbuf, off, len ); + public void write(char[] cbuf, int off, int len) throws IOException { + if (xmlPrologWriter != null) { + detectEncoding(cbuf, off, len); + } else { + writer.write(cbuf, off, len); } } diff --git a/src/main/java/org/codehaus/plexus/util/xml/XmlUtil.java b/src/main/java/org/codehaus/plexus/util/xml/XmlUtil.java index c6742747..2a08b5e4 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/XmlUtil.java +++ b/src/main/java/org/codehaus/plexus/util/xml/XmlUtil.java @@ -35,13 +35,12 @@ * * @since 1.5.7 */ -public class XmlUtil -{ +public class XmlUtil { /** The default line indenter size i.e. 2. */ public static final int DEFAULT_INDENTATION_SIZE = 2; /** The default line separator ("\n" on UNIX) */ - public static final String DEFAULT_LINE_SEPARATOR = System.getProperty( "line.separator" ); + public static final String DEFAULT_LINE_SEPARATOR = System.getProperty("line.separator"); /** * Determines if a given File shall be handled as XML. @@ -49,40 +48,34 @@ public class XmlUtil * @param f not null file * @return true if the given file has XML content, false otherwise. */ - public static boolean isXml( File f ) - { - if ( f == null ) - { - throw new IllegalArgumentException( "f could not be null." ); + public static boolean isXml(File f) { + if (f == null) { + throw new IllegalArgumentException("f could not be null."); } - if ( !f.isFile() ) - { - throw new IllegalArgumentException( "The file '" + f.getAbsolutePath() + "' is not a file." ); + if (!f.isFile()) { + throw new IllegalArgumentException("The file '" + f.getAbsolutePath() + "' is not a file."); } - try ( Reader reader = ReaderFactory.newXmlReader( f ) ) - { + try (Reader reader = ReaderFactory.newXmlReader(f)) { XmlPullParser parser = new MXParser(); - parser.setInput( reader ); + parser.setInput(reader); parser.nextToken(); return true; - } - catch ( Exception e ) - { + } catch (Exception e) { return false; } } /** * Pretty format the input reader. For instance, the following input: - * + * *

      * <div><b>content</b></div>
      * 
- * + * * becomes - * + * *
      * <div>
      *   <b>content</b>
@@ -96,21 +89,19 @@ public static boolean isXml( File f )
      * @see ReaderFactory to read an xml content
      * @see WriterFactory to write an xml content
      */
-    public static void prettyFormat( Reader reader, Writer writer )
-        throws IOException
-    {
-        prettyFormat( reader, writer, DEFAULT_INDENTATION_SIZE, DEFAULT_LINE_SEPARATOR );
+    public static void prettyFormat(Reader reader, Writer writer) throws IOException {
+        prettyFormat(reader, writer, DEFAULT_INDENTATION_SIZE, DEFAULT_LINE_SEPARATOR);
     }
 
     /**
      * Pretty format the input reader. For instance, the following input:
-     * 
+     *
      * 
      * <div><b>content</b></div>
      * 
- * + * * becomes - * + * *
      * <div>
      *   <b>content</b>
@@ -125,48 +116,41 @@ public static void prettyFormat( Reader reader, Writer writer )
      * @see ReaderFactory to read an xml content
      * @see WriterFactory to write an xml content
      */
-    public static void prettyFormat( Reader reader, Writer writer, int indentSize, String lineSeparator )
-        throws IOException
-    {
-        if ( reader == null )
-        {
-            throw new IllegalArgumentException( "The reader is null" );
+    public static void prettyFormat(Reader reader, Writer writer, int indentSize, String lineSeparator)
+            throws IOException {
+        if (reader == null) {
+            throw new IllegalArgumentException("The reader is null");
         }
-        if ( writer == null )
-        {
-            throw new IllegalArgumentException( "The writer is null" );
+        if (writer == null) {
+            throw new IllegalArgumentException("The writer is null");
         }
-        if ( indentSize < 0 )
-        {
+        if (indentSize < 0) {
             indentSize = 0;
         }
 
-        PrettyPrintXMLWriter xmlWriter = new PrettyPrintXMLWriter( writer );
-        xmlWriter.setLineIndenter( StringUtils.repeat( " ", indentSize ) );
-        xmlWriter.setLineSeparator( lineSeparator );
+        PrettyPrintXMLWriter xmlWriter = new PrettyPrintXMLWriter(writer);
+        xmlWriter.setLineIndenter(StringUtils.repeat(" ", indentSize));
+        xmlWriter.setLineSeparator(lineSeparator);
 
         XmlPullParser parser = new MXParser();
-        try
-        {
-            parser.setInput( reader );
+        try {
+            parser.setInput(reader);
 
-            prettyFormatInternal( parser, xmlWriter );
-        }
-        catch ( XmlPullParserException e )
-        {
-            throw new IOException( "Unable to parse the XML: " + e.getMessage() );
+            prettyFormatInternal(parser, xmlWriter);
+        } catch (XmlPullParserException e) {
+            throw new IOException("Unable to parse the XML: " + e.getMessage());
         }
     }
 
     /**
      * Pretty format the input stream. For instance, the following input:
-     * 
+     *
      * 
      * <div><b>content</b></div>
      * 
- * + * * becomes - * + * *
      * <div>
      *   <b>content</b>
@@ -178,21 +162,19 @@ public static void prettyFormat( Reader reader, Writer writer, int indentSize, S
      * @throws IOException if any or invalid xml content
      * @see #prettyFormat(InputStream, OutputStream, int, String)
      */
-    public static void prettyFormat( InputStream is, OutputStream os )
-        throws IOException
-    {
-        prettyFormat( is, os, DEFAULT_INDENTATION_SIZE, DEFAULT_LINE_SEPARATOR );
+    public static void prettyFormat(InputStream is, OutputStream os) throws IOException {
+        prettyFormat(is, os, DEFAULT_INDENTATION_SIZE, DEFAULT_LINE_SEPARATOR);
     }
 
     /**
      * Pretty format the input stream. For instance, the following input:
-     * 
+     *
      * 
      * <div><b>content</b></div>
      * 
- * + * * becomes - * + * *
      * <div>
      *   <b>content</b>
@@ -205,37 +187,30 @@ public static void prettyFormat( InputStream is, OutputStream os )
      * @param lineSeparator the wanted line separator
      * @throws IOException if any or invalid xml content
      */
-    public static void prettyFormat( InputStream is, OutputStream os, int indentSize, String lineSeparator )
-        throws IOException
-    {
-        if ( is == null )
-        {
-            throw new IllegalArgumentException( "The is is null" );
+    public static void prettyFormat(InputStream is, OutputStream os, int indentSize, String lineSeparator)
+            throws IOException {
+        if (is == null) {
+            throw new IllegalArgumentException("The is is null");
         }
-        if ( os == null )
-        {
-            throw new IllegalArgumentException( "The os is null" );
+        if (os == null) {
+            throw new IllegalArgumentException("The os is null");
         }
-        if ( indentSize < 0 )
-        {
+        if (indentSize < 0) {
             indentSize = 0;
         }
 
-        try ( Reader reader = ReaderFactory.newXmlReader( is );
-              Writer writer = new OutputStreamWriter( os ) )
-        {
-            final PrettyPrintXMLWriter xmlWriter = new PrettyPrintXMLWriter( writer );
-            xmlWriter.setLineIndenter( StringUtils.repeat( " ", indentSize ) );
-            xmlWriter.setLineSeparator( lineSeparator );
+        try (Reader reader = ReaderFactory.newXmlReader(is);
+                Writer writer = new OutputStreamWriter(os)) {
+            final PrettyPrintXMLWriter xmlWriter = new PrettyPrintXMLWriter(writer);
+            xmlWriter.setLineIndenter(StringUtils.repeat(" ", indentSize));
+            xmlWriter.setLineSeparator(lineSeparator);
 
             final XmlPullParser parser = new MXParser();
-            parser.setInput( reader );
+            parser.setInput(reader);
 
-            prettyFormatInternal( parser, xmlWriter );
-        }
-        catch ( XmlPullParserException e )
-        {
-            throw new IOException( "Unable to parse the XML: " + e.getMessage() );
+            prettyFormatInternal(parser, xmlWriter);
+        } catch (XmlPullParserException e) {
+            throw new IOException("Unable to parse the XML: " + e.getMessage());
         }
     }
 
@@ -245,82 +220,58 @@ public static void prettyFormat( InputStream is, OutputStream os, int indentSize
      * @throws XmlPullParserException if any
      * @throws IOException if any
      */
-    private static void prettyFormatInternal( XmlPullParser parser, PrettyPrintXMLWriter writer )
-        throws XmlPullParserException, IOException
-    {
+    private static void prettyFormatInternal(XmlPullParser parser, PrettyPrintXMLWriter writer)
+            throws XmlPullParserException, IOException {
         boolean hasTag = false;
         boolean hasComment = false;
         int eventType = parser.getEventType();
-        while ( eventType != XmlPullParser.END_DOCUMENT )
-        {
-            if ( eventType == XmlPullParser.START_TAG )
-            {
+        while (eventType != XmlPullParser.END_DOCUMENT) {
+            if (eventType == XmlPullParser.START_TAG) {
                 hasTag = true;
-                if ( hasComment )
-                {
-                    writer.writeText( writer.getLineIndenter() );
+                if (hasComment) {
+                    writer.writeText(writer.getLineIndenter());
                     hasComment = false;
                 }
-                writer.startElement( parser.getName() );
-                for ( int i = 0; i < parser.getAttributeCount(); i++ )
-                {
-                    String key = parser.getAttributeName( i );
-                    String value = parser.getAttributeValue( i );
-                    writer.addAttribute( key, value );
+                writer.startElement(parser.getName());
+                for (int i = 0; i < parser.getAttributeCount(); i++) {
+                    String key = parser.getAttributeName(i);
+                    String value = parser.getAttributeValue(i);
+                    writer.addAttribute(key, value);
                 }
-            }
-            else if ( eventType == XmlPullParser.TEXT )
-            {
+            } else if (eventType == XmlPullParser.TEXT) {
                 String text = parser.getText();
-                if ( !text.trim().equals( "" ) )
-                {
-                    text = StringUtils.removeDuplicateWhitespace( text );
-                    writer.writeText( text );
+                if (!text.trim().equals("")) {
+                    text = StringUtils.removeDuplicateWhitespace(text);
+                    writer.writeText(text);
                 }
-            }
-            else if ( eventType == XmlPullParser.END_TAG )
-            {
+            } else if (eventType == XmlPullParser.END_TAG) {
                 hasTag = false;
                 writer.endElement();
-            }
-            else if ( eventType == XmlPullParser.COMMENT )
-            {
+            } else if (eventType == XmlPullParser.COMMENT) {
                 hasComment = true;
-                if ( !hasTag )
-                {
-                    writer.writeMarkup( writer.getLineSeparator() );
-                    for ( int i = 0; i < writer.getDepth(); i++ )
-                    {
-                        writer.writeMarkup( writer.getLineIndenter() );
+                if (!hasTag) {
+                    writer.writeMarkup(writer.getLineSeparator());
+                    for (int i = 0; i < writer.getDepth(); i++) {
+                        writer.writeMarkup(writer.getLineIndenter());
                     }
                 }
-                writer.writeMarkup( "" );
-                if ( !hasTag )
-                {
-                    writer.writeMarkup( writer.getLineSeparator() );
-                    for ( int i = 0; i < writer.getDepth() - 1; i++ )
-                    {
-                        writer.writeMarkup( writer.getLineIndenter() );
+                writer.writeMarkup("");
+                if (!hasTag) {
+                    writer.writeMarkup(writer.getLineSeparator());
+                    for (int i = 0; i < writer.getDepth() - 1; i++) {
+                        writer.writeMarkup(writer.getLineIndenter());
                     }
                 }
-            }
-            else if ( eventType == XmlPullParser.DOCDECL )
-            {
-                writer.writeMarkup( "" );
+            } else if (eventType == XmlPullParser.DOCDECL) {
+                writer.writeMarkup("");
                 writer.endOfLine();
-            }
-            else if ( eventType == XmlPullParser.PROCESSING_INSTRUCTION )
-            {
-                writer.writeMarkup( "" );
+            } else if (eventType == XmlPullParser.PROCESSING_INSTRUCTION) {
+                writer.writeMarkup("");
                 writer.endOfLine();
-            }
-            else if ( eventType == XmlPullParser.CDSECT )
-            {
-                writer.writeMarkup( "" );
-            }
-            else if ( eventType == XmlPullParser.ENTITY_REF )
-            {
-                writer.writeMarkup( "&" + parser.getName() + ";" );
+            } else if (eventType == XmlPullParser.CDSECT) {
+                writer.writeMarkup("");
+            } else if (eventType == XmlPullParser.ENTITY_REF) {
+                writer.writeMarkup("&" + parser.getName() + ";");
             }
 
             eventType = parser.nextToken();
diff --git a/src/main/java/org/codehaus/plexus/util/xml/XmlWriterUtil.java b/src/main/java/org/codehaus/plexus/util/xml/XmlWriterUtil.java
index 515ff75e..01870e51 100644
--- a/src/main/java/org/codehaus/plexus/util/xml/XmlWriterUtil.java
+++ b/src/main/java/org/codehaus/plexus/util/xml/XmlWriterUtil.java
@@ -22,10 +22,9 @@
  * @author Vincent Siveton
  *
  */
-public class XmlWriterUtil
-{
+public class XmlWriterUtil {
     /** The vm line separator */
-    public static final String LS = System.getProperty( "line.separator" );
+    public static final String LS = System.getProperty("line.separator");
 
     /** The default line indenter size i.e. 2. */
     public static final int DEFAULT_INDENTATION_SIZE = 2;
@@ -38,9 +37,8 @@ public class XmlWriterUtil
      *
      * @param writer not null writer
      */
-    public static void writeLineBreak( XMLWriter writer )
-    {
-        writeLineBreak( writer, 1 );
+    public static void writeLineBreak(XMLWriter writer) {
+        writeLineBreak(writer, 1);
     }
 
     /**
@@ -49,11 +47,9 @@ public static void writeLineBreak( XMLWriter writer )
      * @param writer not null
      * @param repeat positive number
      */
-    public static void writeLineBreak( XMLWriter writer, int repeat )
-    {
-        for ( int i = 0; i < repeat; i++ )
-        {
-            writer.writeMarkup( LS );
+    public static void writeLineBreak(XMLWriter writer, int repeat) {
+        for (int i = 0; i < repeat; i++) {
+            writer.writeMarkup(LS);
         }
     }
 
@@ -66,9 +62,8 @@ public static void writeLineBreak( XMLWriter writer, int repeat )
      * @see #DEFAULT_INDENTATION_SIZE
      * @see #writeLineBreak(XMLWriter, int, int, int)
      */
-    public static void writeLineBreak( XMLWriter writer, int repeat, int indent )
-    {
-        writeLineBreak( writer, repeat, indent, DEFAULT_INDENTATION_SIZE );
+    public static void writeLineBreak(XMLWriter writer, int repeat, int indent) {
+        writeLineBreak(writer, repeat, indent, DEFAULT_INDENTATION_SIZE);
     }
 
     /**
@@ -79,21 +74,18 @@ public static void writeLineBreak( XMLWriter writer, int repeat, int indent )
      * @param indent positive number
      * @param indentSize positive number
      */
-    public static void writeLineBreak( XMLWriter writer, int repeat, int indent, int indentSize )
-    {
-        writeLineBreak( writer, repeat );
+    public static void writeLineBreak(XMLWriter writer, int repeat, int indent, int indentSize) {
+        writeLineBreak(writer, repeat);
 
-        if ( indent < 0 )
-        {
+        if (indent < 0) {
             indent = 0;
         }
 
-        if ( indentSize < 0 )
-        {
+        if (indentSize < 0) {
             indentSize = 0;
         }
 
-        writer.writeText( StringUtils.repeat( " ", indent * indentSize ) );
+        writer.writeText(StringUtils.repeat(" ", indent * indentSize));
     }
 
     /**
@@ -103,9 +95,8 @@ public static void writeLineBreak( XMLWriter writer, int repeat, int indent, int
      * @see #DEFAULT_COLUMN_LINE
      * @see #writeCommentLineBreak(XMLWriter, int)
      */
-    public static void writeCommentLineBreak( XMLWriter writer )
-    {
-        writeCommentLineBreak( writer, DEFAULT_COLUMN_LINE );
+    public static void writeCommentLineBreak(XMLWriter writer) {
+        writeCommentLineBreak(writer, DEFAULT_COLUMN_LINE);
     }
 
     /**
@@ -114,14 +105,12 @@ public static void writeCommentLineBreak( XMLWriter writer )
      * @param writer not null
      * @param columnSize positive number
      */
-    public static void writeCommentLineBreak( XMLWriter writer, int columnSize )
-    {
-        if ( columnSize < 10 )
-        {
+    public static void writeCommentLineBreak(XMLWriter writer, int columnSize) {
+        if (columnSize < 10) {
             columnSize = DEFAULT_COLUMN_LINE;
         }
 
-        writer.writeMarkup( "" + LS );
+        writer.writeMarkup("" + LS);
     }
 
     /**
@@ -133,9 +122,8 @@ public static void writeCommentLineBreak( XMLWriter writer, int columnSize )
      * @see #DEFAULT_INDENTATION_SIZE
      * @see #writeComment(XMLWriter, String, int, int)
      */
-    public static void writeComment( XMLWriter writer, String comment )
-    {
-        writeComment( writer, comment, 0, DEFAULT_INDENTATION_SIZE );
+    public static void writeComment(XMLWriter writer, String comment) {
+        writeComment(writer, comment, 0, DEFAULT_INDENTATION_SIZE);
     }
 
     /**
@@ -148,9 +136,8 @@ public static void writeComment( XMLWriter writer, String comment )
      * @see #DEFAULT_INDENTATION_SIZE
      * @see #writeComment(XMLWriter, String, int, int)
      */
-    public static void writeComment( XMLWriter writer, String comment, int indent )
-    {
-        writeComment( writer, comment, indent, DEFAULT_INDENTATION_SIZE );
+    public static void writeComment(XMLWriter writer, String comment, int indent) {
+        writeComment(writer, comment, indent, DEFAULT_INDENTATION_SIZE);
     }
 
     /**
@@ -164,9 +151,8 @@ public static void writeComment( XMLWriter writer, String comment, int indent )
      * @see #DEFAULT_COLUMN_LINE
      * @see #writeComment(XMLWriter, String, int, int, int)
      */
-    public static void writeComment( XMLWriter writer, String comment, int indent, int indentSize )
-    {
-        writeComment( writer, comment, indent, indentSize, DEFAULT_COLUMN_LINE );
+    public static void writeComment(XMLWriter writer, String comment, int indent, int indentSize) {
+        writeComment(writer, comment, indent, indentSize, DEFAULT_COLUMN_LINE);
     }
 
     /**
@@ -179,85 +165,69 @@ public static void writeComment( XMLWriter writer, String comment, int indent, i
      * @param indentSize positive number
      * @param columnSize positive number
      */
-    public static void writeComment( XMLWriter writer, String comment, int indent, int indentSize, int columnSize )
-    {
-        if ( comment == null )
-        {
+    public static void writeComment(XMLWriter writer, String comment, int indent, int indentSize, int columnSize) {
+        if (comment == null) {
             comment = "null";
         }
 
-        while ( comment.contains( "" ) )
-        {
-            comment = comment.replace( "-->", "" );
+        while (comment.contains("-->")) {
+            comment = comment.replace("-->", "");
         }
 
-        if ( indent < 0 )
-        {
+        if (indent < 0) {
             indent = 0;
         }
 
-        if ( indentSize < 0 )
-        {
+        if (indentSize < 0) {
             indentSize = 0;
         }
 
-        if ( columnSize < 0 )
-        {
+        if (columnSize < 0) {
             columnSize = DEFAULT_COLUMN_LINE;
         }
 
-        String indentation = StringUtils.repeat( " ", indent * indentSize );
+        String indentation = StringUtils.repeat(" ", indent * indentSize);
         int magicNumber = indentation.length() + columnSize - "-->".length() - 1;
-        String[] sentences = StringUtils.split( comment, LS );
-
-        StringBuffer line = new StringBuffer( indentation + "" ).append( LS );
-                        writer.writeMarkup( line.toString() );
+                        line.append("-->").append(LS);
+                        writer.writeMarkup(line.toString());
                     }
-                    line = new StringBuffer( indentation + "" ).append( LS );
+        line.append("-->").append(LS);
 
-        writer.writeMarkup( line.toString() );
+        writer.writeMarkup(line.toString());
     }
 
     /**
@@ -268,9 +238,8 @@ public static void writeComment( XMLWriter writer, String comment, int indent, i
      * @see #DEFAULT_INDENTATION_SIZE
      * @see #writeCommentText(XMLWriter, String, int, int)
      */
-    public static void writeCommentText( XMLWriter writer, String comment )
-    {
-        writeCommentText( writer, comment, 0, DEFAULT_INDENTATION_SIZE );
+    public static void writeCommentText(XMLWriter writer, String comment) {
+        writeCommentText(writer, comment, 0, DEFAULT_INDENTATION_SIZE);
     }
 
     /**
@@ -283,9 +252,8 @@ public static void writeCommentText( XMLWriter writer, String comment )
      * @see #DEFAULT_INDENTATION_SIZE
      * @see #writeCommentText(XMLWriter, String, int, int)
      */
-    public static void writeCommentText( XMLWriter writer, String comment, int indent )
-    {
-        writeCommentText( writer, comment, indent, DEFAULT_INDENTATION_SIZE );
+    public static void writeCommentText(XMLWriter writer, String comment, int indent) {
+        writeCommentText(writer, comment, indent, DEFAULT_INDENTATION_SIZE);
     }
 
     /**
@@ -299,9 +267,8 @@ public static void writeCommentText( XMLWriter writer, String comment, int inden
      * @see #DEFAULT_COLUMN_LINE
      * @see #writeCommentText(XMLWriter, String, int, int, int)
      */
-    public static void writeCommentText( XMLWriter writer, String comment, int indent, int indentSize )
-    {
-        writeCommentText( writer, comment, indent, indentSize, DEFAULT_COLUMN_LINE );
+    public static void writeCommentText(XMLWriter writer, String comment, int indent, int indentSize) {
+        writeCommentText(writer, comment, indent, indentSize, DEFAULT_COLUMN_LINE);
     }
 
     /**
@@ -314,33 +281,29 @@ public static void writeCommentText( XMLWriter writer, String comment, int inden
      * @param indentSize positive number
      * @param columnSize positive number
      */
-    public static void writeCommentText( XMLWriter writer, String comment, int indent, int indentSize, int columnSize )
-    {
-        if ( indent < 0 )
-        {
+    public static void writeCommentText(XMLWriter writer, String comment, int indent, int indentSize, int columnSize) {
+        if (indent < 0) {
             indent = 0;
         }
 
-        if ( indentSize < 0 )
-        {
+        if (indentSize < 0) {
             indentSize = 0;
         }
 
-        if ( columnSize < 0 )
-        {
+        if (columnSize < 0) {
             columnSize = DEFAULT_COLUMN_LINE;
         }
 
-        writeLineBreak( writer, 1 );
+        writeLineBreak(writer, 1);
 
-        writer.writeMarkup( StringUtils.repeat( " ", indent * indentSize ) );
-        writeCommentLineBreak( writer, columnSize );
+        writer.writeMarkup(StringUtils.repeat(" ", indent * indentSize));
+        writeCommentLineBreak(writer, columnSize);
 
-        writeComment( writer, comment, indent, indentSize, columnSize );
+        writeComment(writer, comment, indent, indentSize, columnSize);
 
-        writer.writeMarkup( StringUtils.repeat( " ", indent * indentSize ) );
-        writeCommentLineBreak( writer, columnSize );
+        writer.writeMarkup(StringUtils.repeat(" ", indent * indentSize));
+        writeCommentLineBreak(writer, columnSize);
 
-        writeLineBreak( writer, 1, indent, indentSize );
+        writeLineBreak(writer, 1, indent, indentSize);
     }
 }
diff --git a/src/main/java/org/codehaus/plexus/util/xml/Xpp3Dom.java b/src/main/java/org/codehaus/plexus/util/xml/Xpp3Dom.java
index 5650f14c..89885d11 100644
--- a/src/main/java/org/codehaus/plexus/util/xml/Xpp3Dom.java
+++ b/src/main/java/org/codehaus/plexus/util/xml/Xpp3Dom.java
@@ -16,8 +16,6 @@
  * limitations under the License.
  */
 
-import org.codehaus.plexus.util.xml.pull.XmlSerializer;
-
 import java.io.IOException;
 import java.io.Serializable;
 import java.io.StringWriter;
@@ -29,12 +27,12 @@
 import java.util.ListIterator;
 import java.util.Map;
 
+import org.codehaus.plexus.util.xml.pull.XmlSerializer;
+
 /**
  *  NOTE: remove all the util code in here when separated, this class should be pure data.
  */
-public class Xpp3Dom
-    implements Serializable
-{
+public class Xpp3Dom implements Serializable {
     private static final long serialVersionUID = 2567894443061173996L;
 
     protected String name;
@@ -85,8 +83,7 @@ public class Xpp3Dom
      */
     public static final String DEFAULT_SELF_COMBINATION_MODE = SELF_COMBINATION_MERGE;
 
-    public Xpp3Dom( String name )
-    {
+    public Xpp3Dom(String name) {
         this.name = name;
         childList = new ArrayList<>();
     }
@@ -96,9 +93,8 @@ public Xpp3Dom( String name )
      * @param inputLocation The input location.
      * @param name The name of the Dom.
      */
-    public Xpp3Dom( String name, Object inputLocation )
-    {
-        this( name );
+    public Xpp3Dom(String name, Object inputLocation) {
+        this(name);
         this.inputLocation = inputLocation;
     }
 
@@ -106,9 +102,8 @@ public Xpp3Dom( String name, Object inputLocation )
      * Copy constructor.
      * @param src The source Dom.
      */
-    public Xpp3Dom( Xpp3Dom src )
-    {
-        this( src, src.getName() );
+    public Xpp3Dom(Xpp3Dom src) {
+        this(src, src.getName());
     }
 
     /**
@@ -116,26 +111,23 @@ public Xpp3Dom( Xpp3Dom src )
      * @param src The source Dom.
      * @param name The name of the Dom.
      */
-    public Xpp3Dom( Xpp3Dom src, String name )
-    {
+    public Xpp3Dom(Xpp3Dom src, String name) {
         this.name = name;
         this.inputLocation = src.inputLocation;
 
         int childCount = src.getChildCount();
 
-        childList = new ArrayList( childCount );
+        childList = new ArrayList(childCount);
 
-        setValue( src.getValue() );
+        setValue(src.getValue());
 
         String[] attributeNames = src.getAttributeNames();
-        for ( String attributeName : attributeNames )
-        {
-            setAttribute( attributeName, src.getAttribute( attributeName ) );
+        for (String attributeName : attributeNames) {
+            setAttribute(attributeName, src.getAttribute(attributeName));
         }
 
-        for ( int i = 0; i < childCount; i++ )
-        {
-            addChild( new Xpp3Dom( src.getChild( i ) ) );
+        for (int i = 0; i < childCount; i++) {
+            addChild(new Xpp3Dom(src.getChild(i)));
         }
     }
 
@@ -143,8 +135,7 @@ public Xpp3Dom( Xpp3Dom src, String name )
     // Name handling
     // ----------------------------------------------------------------------
 
-    public String getName()
-    {
+    public String getName() {
         return name;
     }
 
@@ -152,13 +143,11 @@ public String getName()
     // Value handling
     // ----------------------------------------------------------------------
 
-    public String getValue()
-    {
+    public String getValue() {
         return value;
     }
 
-    public void setValue( String value )
-    {
+    public void setValue(String value) {
         this.value = value;
     }
 
@@ -166,21 +155,16 @@ public void setValue( String value )
     // Attribute handling
     // ----------------------------------------------------------------------
 
-    public String[] getAttributeNames()
-    {
-        if ( null == attributes || attributes.isEmpty() )
-        {
+    public String[] getAttributeNames() {
+        if (null == attributes || attributes.isEmpty()) {
             return EMPTY_STRING_ARRAY;
-        }
-        else
-        {
-            return attributes.keySet().toArray( EMPTY_STRING_ARRAY );
+        } else {
+            return attributes.keySet().toArray(EMPTY_STRING_ARRAY);
         }
     }
 
-    public String getAttribute( String name )
-    {
-        return ( null != attributes ) ? attributes.get( name ) : null;
+    public String getAttribute(String name) {
+        return (null != attributes) ? attributes.get(name) : null;
     }
 
     /**
@@ -189,54 +173,44 @@ public String getAttribute( String name )
      * @return true if the attribute has been removed
      * @since 3.4.0
      */
-    public boolean removeAttribute( String name )
-    {
-        return StringUtils.isEmpty( name ) ? false: attributes.remove( name ) == null;
+    public boolean removeAttribute(String name) {
+        return StringUtils.isEmpty(name) ? false : attributes.remove(name) == null;
     }
 
     /**
      * Set the attribute value
-     * 
+     *
      * @param name String not null
      * @param value String not null
      */
-    public void setAttribute( String name, String value )
-    {
-        if ( null == value )
-        {
-            throw new NullPointerException( "Attribute value can not be null" );
+    public void setAttribute(String name, String value) {
+        if (null == value) {
+            throw new NullPointerException("Attribute value can not be null");
         }
-        if ( null == name )
-        {
-            throw new NullPointerException( "Attribute name can not be null" );
+        if (null == name) {
+            throw new NullPointerException("Attribute name can not be null");
         }
-        if ( null == attributes )
-        {
+        if (null == attributes) {
             attributes = new HashMap();
         }
 
-        attributes.put( name, value );
+        attributes.put(name, value);
     }
 
     // ----------------------------------------------------------------------
     // Child handling
     // ----------------------------------------------------------------------
 
-    public Xpp3Dom getChild( int i )
-    {
-        return childList.get( i );
+    public Xpp3Dom getChild(int i) {
+        return childList.get(i);
     }
 
-    public Xpp3Dom getChild( String name )
-    {
-        if ( name != null )
-        {
-            ListIterator it = childList.listIterator( childList.size() );
-            while ( it.hasPrevious() )
-            {
+    public Xpp3Dom getChild(String name) {
+        if (name != null) {
+            ListIterator it = childList.listIterator(childList.size());
+            while (it.hasPrevious()) {
                 Xpp3Dom child = it.previous();
-                if ( name.equals( child.getName() ) )
-                {
+                if (name.equals(child.getName())) {
                     return child;
                 }
             }
@@ -244,98 +218,76 @@ public Xpp3Dom getChild( String name )
         return null;
     }
 
-    public void addChild( Xpp3Dom xpp3Dom )
-    {
-        xpp3Dom.setParent( this );
-        childList.add( xpp3Dom );
+    public void addChild(Xpp3Dom xpp3Dom) {
+        xpp3Dom.setParent(this);
+        childList.add(xpp3Dom);
     }
 
-    public Xpp3Dom[] getChildren()
-    {
-        if ( null == childList || childList.isEmpty() )
-        {
+    public Xpp3Dom[] getChildren() {
+        if (null == childList || childList.isEmpty()) {
             return EMPTY_DOM_ARRAY;
-        }
-        else
-        {
-            return childList.toArray( EMPTY_DOM_ARRAY );
+        } else {
+            return childList.toArray(EMPTY_DOM_ARRAY);
         }
     }
 
-    public Xpp3Dom[] getChildren( String name )
-    {
-        return getChildrenAsList( name ).toArray( EMPTY_DOM_ARRAY );
+    public Xpp3Dom[] getChildren(String name) {
+        return getChildrenAsList(name).toArray(EMPTY_DOM_ARRAY);
     }
 
-    private List getChildrenAsList( String name )
-    {
-        if ( null == childList )
-        {
+    private List getChildrenAsList(String name) {
+        if (null == childList) {
             return Collections.emptyList();
-        }
-        else
-        {
+        } else {
             ArrayList children = null;
 
-            for ( Xpp3Dom configuration : childList )
-            {
-                if ( name.equals( configuration.getName() ) )
-                {
-                    if ( children == null )
-                    {
+            for (Xpp3Dom configuration : childList) {
+                if (name.equals(configuration.getName())) {
+                    if (children == null) {
                         children = new ArrayList();
                     }
-                    children.add( configuration );
+                    children.add(configuration);
                 }
             }
 
-            if ( children != null )
-            {
+            if (children != null) {
                 return children;
-            }
-            else
-            {
+            } else {
                 return Collections.emptyList();
             }
         }
     }
 
-    public int getChildCount()
-    {
-        if ( null == childList )
-        {
+    public int getChildCount() {
+        if (null == childList) {
             return 0;
         }
 
         return childList.size();
     }
 
-    public void removeChild( int i )
-    {
-        Xpp3Dom child = getChild( i );
-        childList.remove( i );
+    public void removeChild(int i) {
+        Xpp3Dom child = getChild(i);
+        childList.remove(i);
         // In case of any dangling references
-        child.setParent( null );
+        child.setParent(null);
     }
 
-    public void removeChild( Xpp3Dom child )
-    {
-        childList.remove( child );
+    public void removeChild(Xpp3Dom child) {
+        childList.remove(child);
         // In case of any dangling references
-        child.setParent( null );
+        child.setParent(null);
     }
 
     // ----------------------------------------------------------------------
     // Parent handling
     // ----------------------------------------------------------------------
 
-    public Xpp3Dom getParent()
-    {
+    public Xpp3Dom getParent() {
         return parent;
     }
 
-    public void setParent( Xpp3Dom parent )
-    {
+    public void setParent(Xpp3Dom parent) {
         this.parent = parent;
     }
 
@@ -347,8 +299,7 @@ public void setParent( Xpp3Dom parent )
      * @since 3.2.0
      * @return input location
      */
-    public Object getInputLocation()
-    {
+    public Object getInputLocation() {
         return inputLocation;
     }
 
@@ -356,8 +307,7 @@ public Object getInputLocation()
      * @since 3.2.0
      * @param inputLocation input location to set
      */
-    public void setInputLocation( Object inputLocation )
-    {
+    public void setInputLocation(Object inputLocation) {
         this.inputLocation = inputLocation;
     }
 
@@ -365,16 +315,13 @@ public void setInputLocation( Object inputLocation )
     // Helpers
     // ----------------------------------------------------------------------
 
-    public void writeToSerializer( String namespace, XmlSerializer serializer )
-        throws IOException
-    {
+    public void writeToSerializer(String namespace, XmlSerializer serializer) throws IOException {
         // TODO: WARNING! Later versions of plexus-utils psit out an  header due to thinking this is a new
         // document - not the desired behaviour!
-        SerializerXMLWriter xmlWriter = new SerializerXMLWriter( namespace, serializer );
-        Xpp3DomWriter.write( xmlWriter, this );
-        if ( xmlWriter.getExceptions().size() > 0 )
-        {
-            throw (IOException) xmlWriter.getExceptions().get( 0 );
+        SerializerXMLWriter xmlWriter = new SerializerXMLWriter(namespace, serializer);
+        Xpp3DomWriter.write(xmlWriter, this);
+        if (xmlWriter.getExceptions().size() > 0) {
+            throw (IOException) xmlWriter.getExceptions().get(0);
         }
     }
 
@@ -415,116 +362,88 @@ public void writeToSerializer( String namespace, XmlSerializer serializer )
      *   
      * 
      */
-    private static void mergeIntoXpp3Dom( Xpp3Dom dominant, Xpp3Dom recessive, Boolean childMergeOverride )
-    {
+    private static void mergeIntoXpp3Dom(Xpp3Dom dominant, Xpp3Dom recessive, Boolean childMergeOverride) {
         // TODO: share this as some sort of assembler, implement a walk interface?
-        if ( recessive == null )
-        {
+        if (recessive == null) {
             return;
         }
 
         boolean mergeSelf = true;
 
-        String selfMergeMode = dominant.getAttribute( SELF_COMBINATION_MODE_ATTRIBUTE );
+        String selfMergeMode = dominant.getAttribute(SELF_COMBINATION_MODE_ATTRIBUTE);
 
-        if ( SELF_COMBINATION_OVERRIDE.equals( selfMergeMode ) )
-        {
+        if (SELF_COMBINATION_OVERRIDE.equals(selfMergeMode)) {
             mergeSelf = false;
         }
 
-        if ( mergeSelf )
-        {
-            if ( isEmpty( dominant.getValue() ) && !isEmpty( recessive.getValue() ) )
-            {
-                dominant.setValue( recessive.getValue() );
-                dominant.setInputLocation( recessive.getInputLocation() );
+        if (mergeSelf) {
+            if (isEmpty(dominant.getValue()) && !isEmpty(recessive.getValue())) {
+                dominant.setValue(recessive.getValue());
+                dominant.setInputLocation(recessive.getInputLocation());
             }
 
-            if ( recessive.attributes != null )
-            {
-                for ( String attr : recessive.attributes.keySet() )
-                {
-                    if ( isEmpty( dominant.getAttribute( attr ) ) )
-                    {
-                        dominant.setAttribute( attr, recessive.getAttribute( attr ) );
+            if (recessive.attributes != null) {
+                for (String attr : recessive.attributes.keySet()) {
+                    if (isEmpty(dominant.getAttribute(attr))) {
+                        dominant.setAttribute(attr, recessive.getAttribute(attr));
                     }
                 }
             }
 
-            if ( recessive.getChildCount() > 0 )
-            {
+            if (recessive.getChildCount() > 0) {
                 boolean mergeChildren = true;
 
-                if ( childMergeOverride != null )
-                {
+                if (childMergeOverride != null) {
                     mergeChildren = childMergeOverride;
-                }
-                else
-                {
-                    String childMergeMode = dominant.getAttribute( CHILDREN_COMBINATION_MODE_ATTRIBUTE );
+                } else {
+                    String childMergeMode = dominant.getAttribute(CHILDREN_COMBINATION_MODE_ATTRIBUTE);
 
-                    if ( CHILDREN_COMBINATION_APPEND.equals( childMergeMode ) )
-                    {
+                    if (CHILDREN_COMBINATION_APPEND.equals(childMergeMode)) {
                         mergeChildren = false;
                     }
                 }
 
-                if ( !mergeChildren )
-                {
+                if (!mergeChildren) {
                     Xpp3Dom[] dominantChildren = dominant.getChildren();
                     // remove these now, so we can append them to the recessive list later.
                     dominant.childList.clear();
 
-                    for ( int i = 0, recessiveChildCount = recessive.getChildCount(); i < recessiveChildCount; i++ )
-                    {
-                        Xpp3Dom recessiveChild = recessive.getChild( i );
-                        dominant.addChild( new Xpp3Dom( recessiveChild ) );
+                    for (int i = 0, recessiveChildCount = recessive.getChildCount(); i < recessiveChildCount; i++) {
+                        Xpp3Dom recessiveChild = recessive.getChild(i);
+                        dominant.addChild(new Xpp3Dom(recessiveChild));
                     }
 
                     // now, re-add these children so they'll be appended to the recessive list.
-                    for ( Xpp3Dom aDominantChildren : dominantChildren )
-                    {
-                        dominant.addChild( aDominantChildren );
+                    for (Xpp3Dom aDominantChildren : dominantChildren) {
+                        dominant.addChild(aDominantChildren);
                     }
-                }
-                else
-                {
+                } else {
                     Map> commonChildren = new HashMap>();
 
-                    for ( Xpp3Dom recChild : recessive.childList )
-                    {
-                        if ( commonChildren.containsKey( recChild.name ) )
-                        {
+                    for (Xpp3Dom recChild : recessive.childList) {
+                        if (commonChildren.containsKey(recChild.name)) {
                             continue;
                         }
-                        List dominantChildren = dominant.getChildrenAsList( recChild.name );
-                        if ( dominantChildren.size() > 0 )
-                        {
-                            commonChildren.put( recChild.name, dominantChildren.iterator() );
+                        List dominantChildren = dominant.getChildrenAsList(recChild.name);
+                        if (dominantChildren.size() > 0) {
+                            commonChildren.put(recChild.name, dominantChildren.iterator());
                         }
                     }
 
-                    for ( int i = 0, recessiveChildCount = recessive.getChildCount(); i < recessiveChildCount; i++ )
-                    {
-                        Xpp3Dom recessiveChild = recessive.getChild( i );
-                        Iterator it = commonChildren.get( recessiveChild.getName() );
-                        if ( it == null )
-                        {
-                            dominant.addChild( new Xpp3Dom( recessiveChild ) );
-                        }
-                        else if ( it.hasNext() )
-                        {
+                    for (int i = 0, recessiveChildCount = recessive.getChildCount(); i < recessiveChildCount; i++) {
+                        Xpp3Dom recessiveChild = recessive.getChild(i);
+                        Iterator it = commonChildren.get(recessiveChild.getName());
+                        if (it == null) {
+                            dominant.addChild(new Xpp3Dom(recessiveChild));
+                        } else if (it.hasNext()) {
                             Xpp3Dom dominantChild = it.next();
 
                             String dominantChildCombinationMode =
-                                dominantChild.getAttribute( SELF_COMBINATION_MODE_ATTRIBUTE );
-                            if ( SELF_COMBINATION_REMOVE.equals( dominantChildCombinationMode ) )
-                            {
-                                dominant.removeChild( dominantChild );
-                            }
-                            else
-                            {
-                                mergeIntoXpp3Dom( dominantChild, recessiveChild, childMergeOverride );
+                                    dominantChild.getAttribute(SELF_COMBINATION_MODE_ATTRIBUTE);
+                            if (SELF_COMBINATION_REMOVE.equals(dominantChildCombinationMode)) {
+                                dominant.removeChild(dominantChild);
+                            } else {
+                                mergeIntoXpp3Dom(dominantChild, recessiveChild, childMergeOverride);
                             }
                         }
                     }
@@ -544,11 +463,9 @@ else if ( it.hasNext() )
      *            dominant DOM
      * @return merged DOM
      */
-    public static Xpp3Dom mergeXpp3Dom( Xpp3Dom dominant, Xpp3Dom recessive, Boolean childMergeOverride )
-    {
-        if ( dominant != null )
-        {
-            mergeIntoXpp3Dom( dominant, recessive, childMergeOverride );
+    public static Xpp3Dom mergeXpp3Dom(Xpp3Dom dominant, Xpp3Dom recessive, Boolean childMergeOverride) {
+        if (dominant != null) {
+            mergeIntoXpp3Dom(dominant, recessive, childMergeOverride);
             return dominant;
         }
         return recessive;
@@ -564,11 +481,9 @@ public static Xpp3Dom mergeXpp3Dom( Xpp3Dom dominant, Xpp3Dom recessive, Boolean
      * @param recessive The recessive DOM, which will be merged into the dominant DOM
      * @return merged DOM
      */
-    public static Xpp3Dom mergeXpp3Dom( Xpp3Dom dominant, Xpp3Dom recessive )
-    {
-        if ( dominant != null )
-        {
-            mergeIntoXpp3Dom( dominant, recessive, null );
+    public static Xpp3Dom mergeXpp3Dom(Xpp3Dom dominant, Xpp3Dom recessive) {
+        if (dominant != null) {
+            mergeIntoXpp3Dom(dominant, recessive, null);
             return dominant;
         }
         return recessive;
@@ -579,82 +494,64 @@ public static Xpp3Dom mergeXpp3Dom( Xpp3Dom dominant, Xpp3Dom recessive )
     // ----------------------------------------------------------------------
 
     @Override
-    public boolean equals( Object obj )
-    {
-        if ( obj == this )
-        {
+    public boolean equals(Object obj) {
+        if (obj == this) {
             return true;
         }
 
-        if ( !( obj instanceof Xpp3Dom ) )
-        {
+        if (!(obj instanceof Xpp3Dom)) {
             return false;
         }
 
         Xpp3Dom dom = (Xpp3Dom) obj;
 
-        if ( name == null ? dom.name != null : !name.equals( dom.name ) )
-        {
+        if (name == null ? dom.name != null : !name.equals(dom.name)) {
             return false;
-        }
-        else if ( value == null ? dom.value != null : !value.equals( dom.value ) )
-        {
+        } else if (value == null ? dom.value != null : !value.equals(dom.value)) {
             return false;
-        }
-        else if ( attributes == null ? dom.attributes != null : !attributes.equals( dom.attributes ) )
-        {
+        } else if (attributes == null ? dom.attributes != null : !attributes.equals(dom.attributes)) {
             return false;
-        }
-        else if ( childList == null ? dom.childList != null : !childList.equals( dom.childList ) )
-        {
+        } else if (childList == null ? dom.childList != null : !childList.equals(dom.childList)) {
             return false;
-        }
-        else
-        {
+        } else {
             return true;
         }
     }
 
     @Override
-    public int hashCode()
-    {
+    public int hashCode() {
         int result = 17;
-        result = 37 * result + ( name != null ? name.hashCode() : 0 );
-        result = 37 * result + ( value != null ? value.hashCode() : 0 );
-        result = 37 * result + ( attributes != null ? attributes.hashCode() : 0 );
-        result = 37 * result + ( childList != null ? childList.hashCode() : 0 );
+        result = 37 * result + (name != null ? name.hashCode() : 0);
+        result = 37 * result + (value != null ? value.hashCode() : 0);
+        result = 37 * result + (attributes != null ? attributes.hashCode() : 0);
+        result = 37 * result + (childList != null ? childList.hashCode() : 0);
         return result;
     }
 
     @Override
-    public String toString()
-    {
+    public String toString() {
         // TODO: WARNING! Later versions of plexus-utils psit out an  header due to thinking this is a new
         // document - not the desired behaviour!
         StringWriter writer = new StringWriter();
-        XMLWriter xmlWriter = new PrettyPrintXMLWriter( writer, "UTF-8", null );
-        Xpp3DomWriter.write( xmlWriter, this );
+        XMLWriter xmlWriter = new PrettyPrintXMLWriter(writer, "UTF-8", null);
+        Xpp3DomWriter.write(xmlWriter, this);
         return writer.toString();
     }
 
-    public String toUnescapedString()
-    {
+    public String toUnescapedString() {
         // TODO: WARNING! Later versions of plexus-utils psit out an  header due to thinking this is a new
         // document - not the desired behaviour!
         StringWriter writer = new StringWriter();
-        XMLWriter xmlWriter = new PrettyPrintXMLWriter( writer, "UTF-8", null );
-        Xpp3DomWriter.write( xmlWriter, this, false );
+        XMLWriter xmlWriter = new PrettyPrintXMLWriter(writer, "UTF-8", null);
+        Xpp3DomWriter.write(xmlWriter, this, false);
         return writer.toString();
     }
 
-    public static boolean isNotEmpty( String str )
-    {
-        return ( ( str != null ) && ( str.length() > 0 ) );
+    public static boolean isNotEmpty(String str) {
+        return ((str != null) && (str.length() > 0));
     }
 
-    public static boolean isEmpty( String str )
-    {
-        return ( ( str == null ) || ( str.trim().length() == 0 ) );
+    public static boolean isEmpty(String str) {
+        return ((str == null) || (str.trim().length() == 0));
     }
-
 }
diff --git a/src/main/java/org/codehaus/plexus/util/xml/Xpp3DomBuilder.java b/src/main/java/org/codehaus/plexus/util/xml/Xpp3DomBuilder.java
index 623b8399..8f5a525a 100644
--- a/src/main/java/org/codehaus/plexus/util/xml/Xpp3DomBuilder.java
+++ b/src/main/java/org/codehaus/plexus/util/xml/Xpp3DomBuilder.java
@@ -16,27 +16,24 @@
  * limitations under the License.
  */
 
-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 java.io.IOException;
 import java.io.InputStream;
 import java.io.Reader;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.codehaus.plexus.util.xml.pull.MXParser;
+import org.codehaus.plexus.util.xml.pull.XmlPullParser;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
 /**
  *
  */
-public class Xpp3DomBuilder
-{
+public class Xpp3DomBuilder {
     private static final boolean DEFAULT_TRIM = true;
 
-    public static Xpp3Dom build( Reader reader )
-        throws XmlPullParserException, IOException
-    {
-        return build( reader, null );
+    public static Xpp3Dom build(Reader reader) throws XmlPullParserException, IOException {
+        return build(reader, null);
     }
 
     /**
@@ -47,52 +44,39 @@ public static Xpp3Dom build( Reader reader )
      * @throws XmlPullParserException xml exception
      * @throws IOException io
      */
-    public static Xpp3Dom build( Reader reader, InputLocationBuilder locationBuilder )
-        throws XmlPullParserException, IOException
-    {
-        return build( reader, DEFAULT_TRIM, locationBuilder );
+    public static Xpp3Dom build(Reader reader, InputLocationBuilder locationBuilder)
+            throws XmlPullParserException, IOException {
+        return build(reader, DEFAULT_TRIM, locationBuilder);
     }
 
-    public static Xpp3Dom build( InputStream is, String encoding )
-        throws XmlPullParserException, IOException
-    {
-        return build( is, encoding, DEFAULT_TRIM );
+    public static Xpp3Dom build(InputStream is, String encoding) throws XmlPullParserException, IOException {
+        return build(is, encoding, DEFAULT_TRIM);
     }
 
-    public static Xpp3Dom build( InputStream is, String encoding, boolean trim )
-        throws XmlPullParserException, IOException
-    {
-        try
-        {
+    public static Xpp3Dom build(InputStream is, String encoding, boolean trim)
+            throws XmlPullParserException, IOException {
+        try {
             final XmlPullParser parser = new MXParser();
-            parser.setInput( is, encoding );
+            parser.setInput(is, encoding);
 
-            final Xpp3Dom xpp3Dom = build( parser, trim );
+            final Xpp3Dom xpp3Dom = build(parser, trim);
             is.close();
             is = null;
 
             return xpp3Dom;
-        }
-        finally
-        {
-            if ( is != null )
-            {
-                try
-                {
+        } finally {
+            if (is != null) {
+                try {
                     is.close();
-                }
-                catch ( IOException ioe )
-                {
+                } catch (IOException ioe) {
                     // ignore
                 }
             }
         }
     }
 
-    public static Xpp3Dom build( Reader reader, boolean trim )
-        throws XmlPullParserException, IOException
-    {
-        return build( reader, trim, null );
+    public static Xpp3Dom build(Reader reader, boolean trim) throws XmlPullParserException, IOException {
+        return build(reader, trim, null);
     }
 
     /**
@@ -104,46 +88,34 @@ public static Xpp3Dom build( Reader reader, boolean trim )
      * @throws XmlPullParserException xml exception
      * @throws IOException io
      */
-    public static Xpp3Dom build( Reader reader, boolean trim, InputLocationBuilder locationBuilder )
-        throws XmlPullParserException, IOException
-    {
-        try
-        {
+    public static Xpp3Dom build(Reader reader, boolean trim, InputLocationBuilder locationBuilder)
+            throws XmlPullParserException, IOException {
+        try {
             final XmlPullParser parser = new MXParser();
-            parser.setInput( reader );
+            parser.setInput(reader);
 
-            final Xpp3Dom xpp3Dom = build( parser, trim, locationBuilder );
+            final Xpp3Dom xpp3Dom = build(parser, trim, locationBuilder);
             reader.close();
             reader = null;
 
             return xpp3Dom;
-        }
-        finally
-        {
-            if ( reader != null )
-            {
-                try
-                {
+        } finally {
+            if (reader != null) {
+                try {
                     reader.close();
-                }
-                catch ( IOException ioe )
-                {
+                } catch (IOException ioe) {
                     // ignore
                 }
             }
         }
     }
 
-    public static Xpp3Dom build( XmlPullParser parser )
-        throws XmlPullParserException, IOException
-    {
-        return build( parser, DEFAULT_TRIM );
+    public static Xpp3Dom build(XmlPullParser parser) throws XmlPullParserException, IOException {
+        return build(parser, DEFAULT_TRIM);
     }
 
-    public static Xpp3Dom build( XmlPullParser parser, boolean trim )
-        throws XmlPullParserException, IOException
-    {
-        return build( parser, trim, null );
+    public static Xpp3Dom build(XmlPullParser parser, boolean trim) throws XmlPullParserException, IOException {
+        return build(parser, trim, null);
     }
 
     /**
@@ -155,9 +127,8 @@ public static Xpp3Dom build( XmlPullParser parser, boolean trim )
      * @throws XmlPullParserException xml exception
      * @throws IOException io
      */
-    public static Xpp3Dom build( XmlPullParser parser, boolean trim, InputLocationBuilder locationBuilder )
-        throws XmlPullParserException, IOException
-    {
+    public static Xpp3Dom build(XmlPullParser parser, boolean trim, InputLocationBuilder locationBuilder)
+            throws XmlPullParserException, IOException {
         List elements = new ArrayList<>();
 
         List values = new ArrayList<>();
@@ -166,93 +137,75 @@ public static Xpp3Dom build( XmlPullParser parser, boolean trim, InputLocationBu
 
         boolean spacePreserve = false;
 
-        while ( eventType != XmlPullParser.END_DOCUMENT )
-        {
-            if ( eventType == XmlPullParser.START_TAG )
-            {
+        while (eventType != XmlPullParser.END_DOCUMENT) {
+            if (eventType == XmlPullParser.START_TAG) {
                 spacePreserve = false;
 
                 String rawName = parser.getName();
 
-                Xpp3Dom childConfiguration = new Xpp3Dom( rawName );
+                Xpp3Dom childConfiguration = new Xpp3Dom(rawName);
 
-                if ( locationBuilder != null )
-                {
-                    childConfiguration.setInputLocation( locationBuilder.toInputLocation( parser ) );
+                if (locationBuilder != null) {
+                    childConfiguration.setInputLocation(locationBuilder.toInputLocation(parser));
                 }
 
                 int depth = elements.size();
 
-                if ( depth > 0 )
-                {
-                    Xpp3Dom parent = elements.get( depth - 1 );
+                if (depth > 0) {
+                    Xpp3Dom parent = elements.get(depth - 1);
 
-                    parent.addChild( childConfiguration );
+                    parent.addChild(childConfiguration);
                 }
 
-                elements.add( childConfiguration );
+                elements.add(childConfiguration);
 
-                if ( parser.isEmptyElementTag() )
-                {
-                    values.add( null );
-                }
-                else
-                {
-                    values.add( new StringBuilder() );
+                if (parser.isEmptyElementTag()) {
+                    values.add(null);
+                } else {
+                    values.add(new StringBuilder());
                 }
 
                 int attributesSize = parser.getAttributeCount();
 
-                for ( int i = 0; i < attributesSize; i++ )
-                {
-                    String name = parser.getAttributeName( i );
+                for (int i = 0; i < attributesSize; i++) {
+                    String name = parser.getAttributeName(i);
 
-                    String value = parser.getAttributeValue( i );
+                    String value = parser.getAttributeValue(i);
 
-                    childConfiguration.setAttribute( name, value );
+                    childConfiguration.setAttribute(name, value);
 
-                    spacePreserve = spacePreserve || ( "xml:space".equals( name ) && "preserve".equals( value ) );
+                    spacePreserve = spacePreserve || ("xml:space".equals(name) && "preserve".equals(value));
                 }
-            }
-            else if ( eventType == XmlPullParser.TEXT )
-            {
+            } else if (eventType == XmlPullParser.TEXT) {
                 int depth = values.size() - 1;
 
-                @SuppressWarnings( "MismatchedQueryAndUpdateOfStringBuilder" )
-                StringBuilder valueBuffer = values.get( depth );
+                @SuppressWarnings("MismatchedQueryAndUpdateOfStringBuilder")
+                StringBuilder valueBuffer = values.get(depth);
 
                 String text = parser.getText();
 
-                if ( trim && !spacePreserve )
-                {
+                if (trim && !spacePreserve) {
                     text = text.trim();
                 }
 
-                valueBuffer.append( text );
-            }
-            else if ( eventType == XmlPullParser.END_TAG )
-            {
+                valueBuffer.append(text);
+            } else if (eventType == XmlPullParser.END_TAG) {
                 int depth = elements.size() - 1;
 
-                Xpp3Dom finishedConfiguration = elements.remove( depth );
+                Xpp3Dom finishedConfiguration = elements.remove(depth);
 
                 /* this Object could be null if it is a singleton tag */
-                Object accumulatedValue = values.remove( depth );
+                Object accumulatedValue = values.remove(depth);
 
-                if ( finishedConfiguration.getChildCount() == 0 )
-                {
-                    if ( accumulatedValue == null )
-                    {
-                        finishedConfiguration.setValue( null );
-                    }
-                    else
-                    {
-                        finishedConfiguration.setValue( accumulatedValue.toString() );
+                if (finishedConfiguration.getChildCount() == 0) {
+                    if (accumulatedValue == null) {
+                        finishedConfiguration.setValue(null);
+                    } else {
+                        finishedConfiguration.setValue(accumulatedValue.toString());
                     }
                 }
 
-                if ( depth == 0 )
-                {
+                if (depth == 0) {
                     return finishedConfiguration;
                 }
             }
@@ -260,7 +213,7 @@ else if ( eventType == XmlPullParser.END_TAG )
             eventType = parser.next();
         }
 
-        throw new IllegalStateException( "End of document found before returning to 0 depth" );
+        throw new IllegalStateException("End of document found before returning to 0 depth");
     }
 
     /**
@@ -268,8 +221,7 @@ else if ( eventType == XmlPullParser.END_TAG )
      *
      * @since 3.2.0
      */
-    public static interface InputLocationBuilder
-    {
-        Object toInputLocation( XmlPullParser parser );
+    public static interface InputLocationBuilder {
+        Object toInputLocation(XmlPullParser parser);
     }
 }
diff --git a/src/main/java/org/codehaus/plexus/util/xml/Xpp3DomUtils.java b/src/main/java/org/codehaus/plexus/util/xml/Xpp3DomUtils.java
index 555f481e..768f622a 100644
--- a/src/main/java/org/codehaus/plexus/util/xml/Xpp3DomUtils.java
+++ b/src/main/java/org/codehaus/plexus/util/xml/Xpp3DomUtils.java
@@ -1,9 +1,5 @@
 package org.codehaus.plexus.util.xml;
 
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
 /*
  * Copyright The Codehaus Foundation.
  *
@@ -20,11 +16,14 @@
  * limitations under the License.
  */
 
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
 import org.codehaus.plexus.util.xml.pull.XmlSerializer;
 
 /** @author Jason van Zyl */
-public class Xpp3DomUtils
-{
+public class Xpp3DomUtils {
     public static final String CHILDREN_COMBINATION_MODE_ATTRIBUTE = "combine.children";
 
     public static final String CHILDREN_COMBINATION_MERGE = "merge";
@@ -46,15 +45,15 @@ public class Xpp3DomUtils
 
     /**
      * In case of complex XML structures, combining can be done based on id.
-     * 
+     *
      * @since 3.0.22
      */
     public static final String ID_COMBINATION_MODE_ATTRIBUTE = "combine.id";
-    
+
     /**
      * In case of complex XML structures, combining can be done based on keys.
      * This is a comma separated list of attribute names.
-     * 
+     *
      * @since 3.4.0
      */
     public static final String KEYS_COMBINATION_MODE_ATTRIBUTE = "combine.keys";
@@ -67,16 +66,13 @@ public class Xpp3DomUtils
      */
     public static final String DEFAULT_SELF_COMBINATION_MODE = SELF_COMBINATION_MERGE;
 
-    public void writeToSerializer( String namespace, XmlSerializer serializer, Xpp3Dom dom )
-        throws IOException
-    {
+    public void writeToSerializer(String namespace, XmlSerializer serializer, Xpp3Dom dom) throws IOException {
         // TODO: WARNING! Later versions of plexus-utils psit out an  header due to thinking this is a new
         // document - not the desired behaviour!
-        SerializerXMLWriter xmlWriter = new SerializerXMLWriter( namespace, serializer );
-        Xpp3DomWriter.write( xmlWriter, dom );
-        if ( xmlWriter.getExceptions().size() > 0 )
-        {
-            throw (IOException) xmlWriter.getExceptions().get( 0 );
+        SerializerXMLWriter xmlWriter = new SerializerXMLWriter(namespace, serializer);
+        Xpp3DomWriter.write(xmlWriter, dom);
+        if (xmlWriter.getExceptions().size() > 0) {
+            throw (IOException) xmlWriter.getExceptions().get(0);
         }
     }
 
@@ -119,108 +115,83 @@ public void writeToSerializer( String namespace, XmlSerializer serializer, Xpp3D
      *   
      * 
      */
-    private static void mergeIntoXpp3Dom( Xpp3Dom dominant, Xpp3Dom recessive, Boolean childMergeOverride )
-    {
+    private static void mergeIntoXpp3Dom(Xpp3Dom dominant, Xpp3Dom recessive, Boolean childMergeOverride) {
         // TODO: share this as some sort of assembler, implement a walk interface?
-        if ( recessive == null )
-        {
+        if (recessive == null) {
             return;
         }
 
         boolean mergeSelf = true;
 
-        String selfMergeMode = dominant.getAttribute( SELF_COMBINATION_MODE_ATTRIBUTE );
+        String selfMergeMode = dominant.getAttribute(SELF_COMBINATION_MODE_ATTRIBUTE);
 
-        if ( isNotEmpty( selfMergeMode ) && SELF_COMBINATION_OVERRIDE.equals( selfMergeMode ) )
-        {
+        if (isNotEmpty(selfMergeMode) && SELF_COMBINATION_OVERRIDE.equals(selfMergeMode)) {
             mergeSelf = false;
         }
 
-        if ( mergeSelf )
-        {
+        if (mergeSelf) {
             String[] recessiveAttrs = recessive.getAttributeNames();
-            for ( String attr : recessiveAttrs )
-            {
-                if ( isEmpty( dominant.getAttribute( attr ) ) )
-                {
-                    dominant.setAttribute( attr, recessive.getAttribute( attr ) );
+            for (String attr : recessiveAttrs) {
+                if (isEmpty(dominant.getAttribute(attr))) {
+                    dominant.setAttribute(attr, recessive.getAttribute(attr));
                 }
             }
 
             boolean mergeChildren = true;
 
-            if ( childMergeOverride != null )
-            {
+            if (childMergeOverride != null) {
                 mergeChildren = childMergeOverride;
-            }
-            else
-            {
-                String childMergeMode = dominant.getAttribute( CHILDREN_COMBINATION_MODE_ATTRIBUTE );
+            } else {
+                String childMergeMode = dominant.getAttribute(CHILDREN_COMBINATION_MODE_ATTRIBUTE);
 
-                if ( isNotEmpty( childMergeMode ) && CHILDREN_COMBINATION_APPEND.equals( childMergeMode ) )
-                {
+                if (isNotEmpty(childMergeMode) && CHILDREN_COMBINATION_APPEND.equals(childMergeMode)) {
                     mergeChildren = false;
                 }
             }
 
-            final String keysValue = recessive.getAttribute( KEYS_COMBINATION_MODE_ATTRIBUTE );
+            final String keysValue = recessive.getAttribute(KEYS_COMBINATION_MODE_ATTRIBUTE);
 
             Xpp3Dom[] children = recessive.getChildren();
-            for ( Xpp3Dom recessiveChild : children )
-            {
-                String idValue = recessiveChild.getAttribute( ID_COMBINATION_MODE_ATTRIBUTE );
+            for (Xpp3Dom recessiveChild : children) {
+                String idValue = recessiveChild.getAttribute(ID_COMBINATION_MODE_ATTRIBUTE);
 
                 Xpp3Dom childDom = null;
-                if ( isNotEmpty( idValue ) )
-                {
-                    for ( Xpp3Dom dominantChild : dominant.getChildren() )
-                    {
-                        if ( idValue.equals( dominantChild.getAttribute( ID_COMBINATION_MODE_ATTRIBUTE ) ) )
-                        {
+                if (isNotEmpty(idValue)) {
+                    for (Xpp3Dom dominantChild : dominant.getChildren()) {
+                        if (idValue.equals(dominantChild.getAttribute(ID_COMBINATION_MODE_ATTRIBUTE))) {
                             childDom = dominantChild;
                             // we have a match, so don't append but merge
                             mergeChildren = true;
                         }
                     }
-                }
-                else if ( isNotEmpty( keysValue ) ) 
-                {
-                    String[] keys = keysValue.split( "," );
-                    Map recessiveKeyValues = new HashMap<>( keys.length );
-                    for ( String key : keys )
-                    {
-                        recessiveKeyValues.put( key, recessiveChild.getAttribute( key ) );
+                } else if (isNotEmpty(keysValue)) {
+                    String[] keys = keysValue.split(",");
+                    Map recessiveKeyValues = new HashMap<>(keys.length);
+                    for (String key : keys) {
+                        recessiveKeyValues.put(key, recessiveChild.getAttribute(key));
                     }
-                    
-                    for ( Xpp3Dom dominantChild : dominant.getChildren() )
-                    {
-                        Map dominantKeyValues = new HashMap<>( keys.length );
-                        for ( String key : keys )
-                        {
-                            dominantKeyValues.put( key, dominantChild.getAttribute( key ) );
+
+                    for (Xpp3Dom dominantChild : dominant.getChildren()) {
+                        Map dominantKeyValues = new HashMap<>(keys.length);
+                        for (String key : keys) {
+                            dominantKeyValues.put(key, dominantChild.getAttribute(key));
                         }
 
-                        if ( recessiveKeyValues.equals( dominantKeyValues ) )
-                        {
+                        if (recessiveKeyValues.equals(dominantKeyValues)) {
                             childDom = dominantChild;
                             // we have a match, so don't append but merge
                             mergeChildren = true;
                         }
                     }
-                    
-                }
-                else
-                {
-                    childDom = dominant.getChild( recessiveChild.getName() );
-                }
 
-                if ( mergeChildren && childDom != null )
-                {
-                    mergeIntoXpp3Dom( childDom, recessiveChild, childMergeOverride );
+                } else {
+                    childDom = dominant.getChild(recessiveChild.getName());
                 }
-                else
-                {
-                    dominant.addChild( new Xpp3Dom( recessiveChild ) );
+
+                if (mergeChildren && childDom != null) {
+                    mergeIntoXpp3Dom(childDom, recessiveChild, childMergeOverride);
+                } else {
+                    dominant.addChild(new Xpp3Dom(recessiveChild));
                 }
             }
         }
@@ -237,11 +208,9 @@ else if ( isNotEmpty( keysValue ) )
      *            dominant DOM
      * @return merged DOM
      */
-    public static Xpp3Dom mergeXpp3Dom( Xpp3Dom dominant, Xpp3Dom recessive, Boolean childMergeOverride )
-    {
-        if ( dominant != null )
-        {
-            mergeIntoXpp3Dom( dominant, recessive, childMergeOverride );
+    public static Xpp3Dom mergeXpp3Dom(Xpp3Dom dominant, Xpp3Dom recessive, Boolean childMergeOverride) {
+        if (dominant != null) {
+            mergeIntoXpp3Dom(dominant, recessive, childMergeOverride);
             return dominant;
         }
         return recessive;
@@ -257,11 +226,9 @@ public static Xpp3Dom mergeXpp3Dom( Xpp3Dom dominant, Xpp3Dom recessive, Boolean
      * @param recessive The recessive DOM, which will be merged into the dominant DOM
      * @return merged DOM
      */
-    public static Xpp3Dom mergeXpp3Dom( Xpp3Dom dominant, Xpp3Dom recessive )
-    {
-        if ( dominant != null )
-        {
-            mergeIntoXpp3Dom( dominant, recessive, null );
+    public static Xpp3Dom mergeXpp3Dom(Xpp3Dom dominant, Xpp3Dom recessive) {
+        if (dominant != null) {
+            mergeIntoXpp3Dom(dominant, recessive, null);
             return dominant;
         }
         return recessive;
@@ -271,17 +238,15 @@ public static Xpp3Dom mergeXpp3Dom( Xpp3Dom dominant, Xpp3Dom recessive )
      * @deprecated Use {@link org.codehaus.plexus.util.StringUtils#isNotEmpty(String)} instead
      */
     @Deprecated
-    public static boolean isNotEmpty( String str )
-    {
-        return ( str != null && str.length() > 0 );
+    public static boolean isNotEmpty(String str) {
+        return (str != null && str.length() > 0);
     }
 
     /**
      * @deprecated Use {@link org.codehaus.plexus.util.StringUtils#isEmpty(String)} instead
      */
     @Deprecated
-    public static boolean isEmpty( String str )
-    {
-        return ( str == null || str.length() == 0 );
+    public static boolean isEmpty(String str) {
+        return (str == null || str.length() == 0);
     }
 }
diff --git a/src/main/java/org/codehaus/plexus/util/xml/Xpp3DomWriter.java b/src/main/java/org/codehaus/plexus/util/xml/Xpp3DomWriter.java
index 91770cab..35ecec33 100644
--- a/src/main/java/org/codehaus/plexus/util/xml/Xpp3DomWriter.java
+++ b/src/main/java/org/codehaus/plexus/util/xml/Xpp3DomWriter.java
@@ -22,52 +22,40 @@
 /**
  *
  */
-public class Xpp3DomWriter
-{
-    public static void write( Writer writer, Xpp3Dom dom )
-    {
-        write( new PrettyPrintXMLWriter( writer ), dom );
+public class Xpp3DomWriter {
+    public static void write(Writer writer, Xpp3Dom dom) {
+        write(new PrettyPrintXMLWriter(writer), dom);
     }
 
-    public static void write( PrintWriter writer, Xpp3Dom dom )
-    {
-        write( new PrettyPrintXMLWriter( writer ), dom );
+    public static void write(PrintWriter writer, Xpp3Dom dom) {
+        write(new PrettyPrintXMLWriter(writer), dom);
     }
 
-    public static void write( XMLWriter xmlWriter, Xpp3Dom dom )
-    {
-        write( xmlWriter, dom, true );
+    public static void write(XMLWriter xmlWriter, Xpp3Dom dom) {
+        write(xmlWriter, dom, true);
     }
 
-    public static void write( XMLWriter xmlWriter, Xpp3Dom dom, boolean escape )
-    {
+    public static void write(XMLWriter xmlWriter, Xpp3Dom dom, boolean escape) {
         // TODO: move to XMLWriter?
-        xmlWriter.startElement( dom.getName() );
+        xmlWriter.startElement(dom.getName());
         String[] attributeNames = dom.getAttributeNames();
-        for ( String attributeName : attributeNames )
-        {
-            xmlWriter.addAttribute( attributeName, dom.getAttribute( attributeName ) );
+        for (String attributeName : attributeNames) {
+            xmlWriter.addAttribute(attributeName, dom.getAttribute(attributeName));
         }
         Xpp3Dom[] children = dom.getChildren();
-        for ( Xpp3Dom aChildren : children )
-        {
-            write( xmlWriter, aChildren, escape );
+        for (Xpp3Dom aChildren : children) {
+            write(xmlWriter, aChildren, escape);
         }
 
         String value = dom.getValue();
-        if ( value != null )
-        {
-            if ( escape )
-            {
-                xmlWriter.writeText( value );
-            }
-            else
-            {
-                xmlWriter.writeMarkup( value );
+        if (value != null) {
+            if (escape) {
+                xmlWriter.writeText(value);
+            } else {
+                xmlWriter.writeMarkup(value);
             }
         }
 
         xmlWriter.endElement();
     }
-
 }
diff --git a/src/main/java/org/codehaus/plexus/util/xml/pull/EntityReplacementMap.java b/src/main/java/org/codehaus/plexus/util/xml/pull/EntityReplacementMap.java
index 476cb774..8af68d3a 100644
--- a/src/main/java/org/codehaus/plexus/util/xml/pull/EntityReplacementMap.java
+++ b/src/main/java/org/codehaus/plexus/util/xml/pull/EntityReplacementMap.java
@@ -15,8 +15,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-public class EntityReplacementMap
-{
+public class EntityReplacementMap {
     final String entityName[];
 
     final char[] entityNameBuf[];
@@ -29,8 +28,7 @@ public class EntityReplacementMap
 
     final int entityNameHash[];
 
-    public EntityReplacementMap( String[][] replacements )
-    {
+    public EntityReplacementMap(String[][] replacements) {
         int length = replacements.length;
         entityName = new String[length];
         entityNameBuf = new char[length][];
@@ -38,21 +36,16 @@ public EntityReplacementMap( String[][] replacements )
         entityReplacementBuf = new char[length][];
         entityNameHash = new int[length];
 
-        for ( String[] replacement : replacements )
-        {
-            defineEntityReplacementText( replacement[0], replacement[1] );
+        for (String[] replacement : replacements) {
+            defineEntityReplacementText(replacement[0], replacement[1]);
         }
     }
 
-    private void defineEntityReplacementText( String entityName, String replacementText )
-    {
-        if ( !replacementText.startsWith( "&#" ) && this.entityName != null && replacementText.length() > 1 )
-        {
-            String tmp = replacementText.substring( 1, replacementText.length() - 1 );
-            for ( int i = 0; i < this.entityName.length; i++ )
-            {
-                if ( this.entityName[i] != null && this.entityName[i].equals( tmp ) )
-                {
+    private void defineEntityReplacementText(String entityName, String replacementText) {
+        if (!replacementText.startsWith("&#") && this.entityName != null && replacementText.length() > 1) {
+            String tmp = replacementText.substring(1, replacementText.length() - 1);
+            for (int i = 0; i < this.entityName.length; i++) {
+                if (this.entityName[i] != null && this.entityName[i].equals(tmp)) {
                     replacementText = this.entityReplacement[i];
                 }
             }
@@ -61,116 +54,301 @@ private void defineEntityReplacementText( String entityName, String replacementT
         // this is to make sure that if interning works we will take advantage of it ...
         char[] entityNameCharData = entityName.toCharArray();
         // noinspection ConstantConditions
-        this.entityName[entityEnd] = newString( entityNameCharData, 0, entityName.length() );
+        this.entityName[entityEnd] = newString(entityNameCharData, 0, entityName.length());
         entityNameBuf[entityEnd] = entityNameCharData;
 
         entityReplacement[entityEnd] = replacementText;
         entityReplacementBuf[entityEnd] = replacementText.toCharArray();
-        entityNameHash[entityEnd] = fastHash( entityNameBuf[entityEnd], 0, entityNameBuf[entityEnd].length );
+        entityNameHash[entityEnd] = fastHash(entityNameBuf[entityEnd], 0, entityNameBuf[entityEnd].length);
         ++entityEnd;
         // TODO disallow < or & in entity replacement text (or ]]>???)
         // TODO keepEntityNormalizedForAttributeValue cached as well ...
     }
 
-    private String newString( char[] cbuf, int off, int len )
-    {
-        return new String( cbuf, off, len );
+    private String newString(char[] cbuf, int off, int len) {
+        return new String(cbuf, off, len);
     }
 
     /**
      * simplistic implementation of hash function that has constant time to compute - so it also means
      * diminishing hash quality for long strings but for XML parsing it should be good enough ...
      */
-    private static int fastHash( char ch[], int off, int len )
-    {
-        if ( len == 0 )
-            return 0;
+    private static int fastHash(char ch[], int off, int len) {
+        if (len == 0) return 0;
         // assert len >0
         int hash = ch[off]; // hash at beginning
         // try {
-        hash = ( hash << 7 ) + ch[off + len - 1]; // hash at the end
+        hash = (hash << 7) + ch[off + len - 1]; // hash at the end
         // } catch(ArrayIndexOutOfBoundsException aie) {
         // aie.printStackTrace(); //should never happen ...
         // throw new RuntimeException("this is violation of pre-condition");
         // }
-        if ( len > 16 )
-            hash = ( hash << 7 ) + ch[off + ( len / 4 )]; // 1/4 from beginning
-        if ( len > 8 )
-            hash = ( hash << 7 ) + ch[off + ( len / 2 )]; // 1/2 of string size ...
+        if (len > 16) hash = (hash << 7) + ch[off + (len / 4)]; // 1/4 from beginning
+        if (len > 8) hash = (hash << 7) + ch[off + (len / 2)]; // 1/2 of string size ...
         // notice that hash is at most done 3 times <<7 so shifted by 21 bits 8 bit value
         // so max result == 29 bits so it is quite just below 31 bits for long (2^32) ...
         // assert hash >= 0;
         return hash;
     }
 
-    public static final EntityReplacementMap defaultEntityReplacementMap = new EntityReplacementMap( new String[][] {
-        { "nbsp", "\u00a0" }, { "iexcl", "\u00a1" }, { "cent", "\u00a2" }, { "pound", "\u00a3" },
-        { "curren", "\u00a4" }, { "yen", "\u00a5" }, { "brvbar", "\u00a6" }, { "sect", "\u00a7" }, { "uml", "\u00a8" },
-        { "copy", "\u00a9" }, { "ordf", "\u00aa" }, { "laquo", "\u00ab" }, { "not", "\u00ac" }, { "shy", "\u00ad" },
-        { "reg", "\u00ae" }, { "macr", "\u00af" }, { "deg", "\u00b0" }, { "plusmn", "\u00b1" }, { "sup2", "\u00b2" },
-        { "sup3", "\u00b3" }, { "acute", "\u00b4" }, { "micro", "\u00b5" }, { "para", "\u00b6" },
-        { "middot", "\u00b7" }, { "cedil", "\u00b8" }, { "sup1", "\u00b9" }, { "ordm", "\u00ba" },
-        { "raquo", "\u00bb" }, { "frac14", "\u00bc" }, { "frac12", "\u00bd" }, { "frac34", "\u00be" },
-        { "iquest", "\u00bf" }, { "Agrave", "\u00c0" }, { "Aacute", "\u00c1" }, { "Acirc", "\u00c2" },
-        { "Atilde", "\u00c3" }, { "Auml", "\u00c4" }, { "Aring", "\u00c5" }, { "AElig", "\u00c6" },
-        { "Ccedil", "\u00c7" }, { "Egrave", "\u00c8" }, { "Eacute", "\u00c9" }, { "Ecirc", "\u00ca" },
-        { "Euml", "\u00cb" }, { "Igrave", "\u00cc" }, { "Iacute", "\u00cd" }, { "Icirc", "\u00ce" },
-        { "Iuml", "\u00cf" }, { "ETH", "\u00d0" }, { "Ntilde", "\u00d1" }, { "Ograve", "\u00d2" },
-        { "Oacute", "\u00d3" }, { "Ocirc", "\u00d4" }, { "Otilde", "\u00d5" }, { "Ouml", "\u00d6" },
-        { "times", "\u00d7" }, { "Oslash", "\u00d8" }, { "Ugrave", "\u00d9" }, { "Uacute", "\u00da" },
-        { "Ucirc", "\u00db" }, { "Uuml", "\u00dc" }, { "Yacute", "\u00dd" }, { "THORN", "\u00de" },
-        { "szlig", "\u00df" }, { "agrave", "\u00e0" }, { "aacute", "\u00e1" }, { "acirc", "\u00e2" },
-        { "atilde", "\u00e3" }, { "auml", "\u00e4" }, { "aring", "\u00e5" }, { "aelig", "\u00e6" },
-        { "ccedil", "\u00e7" }, { "egrave", "\u00e8" }, { "eacute", "\u00e9" }, { "ecirc", "\u00ea" },
-        { "euml", "\u00eb" }, { "igrave", "\u00ec" }, { "iacute", "\u00ed" }, { "icirc", "\u00ee" },
-        { "iuml", "\u00ef" }, { "eth", "\u00f0" }, { "ntilde", "\u00f1" }, { "ograve", "\u00f2" },
-        { "oacute", "\u00f3" }, { "ocirc", "\u00f4" }, { "otilde", "\u00f5" }, { "ouml", "\u00f6" },
-        { "divide", "\u00f7" }, { "oslash", "\u00f8" }, { "ugrave", "\u00f9" }, { "uacute", "\u00fa" },
-        { "ucirc", "\u00fb" }, { "uuml", "\u00fc" }, { "yacute", "\u00fd" }, { "thorn", "\u00fe" },
-        { "yuml", "\u00ff" },
+    public static final EntityReplacementMap defaultEntityReplacementMap = new EntityReplacementMap(new String[][] {
+        {"nbsp", "\u00a0"},
+        {"iexcl", "\u00a1"},
+        {"cent", "\u00a2"},
+        {"pound", "\u00a3"},
+        {"curren", "\u00a4"},
+        {"yen", "\u00a5"},
+        {"brvbar", "\u00a6"},
+        {"sect", "\u00a7"},
+        {"uml", "\u00a8"},
+        {"copy", "\u00a9"},
+        {"ordf", "\u00aa"},
+        {"laquo", "\u00ab"},
+        {"not", "\u00ac"},
+        {"shy", "\u00ad"},
+        {"reg", "\u00ae"},
+        {"macr", "\u00af"},
+        {"deg", "\u00b0"},
+        {"plusmn", "\u00b1"},
+        {"sup2", "\u00b2"},
+        {"sup3", "\u00b3"},
+        {"acute", "\u00b4"},
+        {"micro", "\u00b5"},
+        {"para", "\u00b6"},
+        {"middot", "\u00b7"},
+        {"cedil", "\u00b8"},
+        {"sup1", "\u00b9"},
+        {"ordm", "\u00ba"},
+        {"raquo", "\u00bb"},
+        {"frac14", "\u00bc"},
+        {"frac12", "\u00bd"},
+        {"frac34", "\u00be"},
+        {"iquest", "\u00bf"},
+        {"Agrave", "\u00c0"},
+        {"Aacute", "\u00c1"},
+        {"Acirc", "\u00c2"},
+        {"Atilde", "\u00c3"},
+        {"Auml", "\u00c4"},
+        {"Aring", "\u00c5"},
+        {"AElig", "\u00c6"},
+        {"Ccedil", "\u00c7"},
+        {"Egrave", "\u00c8"},
+        {"Eacute", "\u00c9"},
+        {"Ecirc", "\u00ca"},
+        {"Euml", "\u00cb"},
+        {"Igrave", "\u00cc"},
+        {"Iacute", "\u00cd"},
+        {"Icirc", "\u00ce"},
+        {"Iuml", "\u00cf"},
+        {"ETH", "\u00d0"},
+        {"Ntilde", "\u00d1"},
+        {"Ograve", "\u00d2"},
+        {"Oacute", "\u00d3"},
+        {"Ocirc", "\u00d4"},
+        {"Otilde", "\u00d5"},
+        {"Ouml", "\u00d6"},
+        {"times", "\u00d7"},
+        {"Oslash", "\u00d8"},
+        {"Ugrave", "\u00d9"},
+        {"Uacute", "\u00da"},
+        {"Ucirc", "\u00db"},
+        {"Uuml", "\u00dc"},
+        {"Yacute", "\u00dd"},
+        {"THORN", "\u00de"},
+        {"szlig", "\u00df"},
+        {"agrave", "\u00e0"},
+        {"aacute", "\u00e1"},
+        {"acirc", "\u00e2"},
+        {"atilde", "\u00e3"},
+        {"auml", "\u00e4"},
+        {"aring", "\u00e5"},
+        {"aelig", "\u00e6"},
+        {"ccedil", "\u00e7"},
+        {"egrave", "\u00e8"},
+        {"eacute", "\u00e9"},
+        {"ecirc", "\u00ea"},
+        {"euml", "\u00eb"},
+        {"igrave", "\u00ec"},
+        {"iacute", "\u00ed"},
+        {"icirc", "\u00ee"},
+        {"iuml", "\u00ef"},
+        {"eth", "\u00f0"},
+        {"ntilde", "\u00f1"},
+        {"ograve", "\u00f2"},
+        {"oacute", "\u00f3"},
+        {"ocirc", "\u00f4"},
+        {"otilde", "\u00f5"},
+        {"ouml", "\u00f6"},
+        {"divide", "\u00f7"},
+        {"oslash", "\u00f8"},
+        {"ugrave", "\u00f9"},
+        {"uacute", "\u00fa"},
+        {"ucirc", "\u00fb"},
+        {"uuml", "\u00fc"},
+        {"yacute", "\u00fd"},
+        {"thorn", "\u00fe"},
+        {"yuml", "\u00ff"},
 
         // ----------------------------------------------------------------------
         // Special entities
         // ----------------------------------------------------------------------
 
-        { "OElig", "\u0152" }, { "oelig", "\u0153" }, { "Scaron", "\u0160" }, { "scaron", "\u0161" },
-        { "Yuml", "\u0178" }, { "circ", "\u02c6" }, { "tilde", "\u02dc" }, { "ensp", "\u2002" }, { "emsp", "\u2003" },
-        { "thinsp", "\u2009" }, { "zwnj", "\u200c" }, { "zwj", "\u200d" }, { "lrm", "\u200e" }, { "rlm", "\u200f" },
-        { "ndash", "\u2013" }, { "mdash", "\u2014" }, { "lsquo", "\u2018" }, { "rsquo", "\u2019" },
-        { "sbquo", "\u201a" }, { "ldquo", "\u201c" }, { "rdquo", "\u201d" }, { "bdquo", "\u201e" },
-        { "dagger", "\u2020" }, { "Dagger", "\u2021" }, { "permil", "\u2030" }, { "lsaquo", "\u2039" },
-        { "rsaquo", "\u203a" }, { "euro", "\u20ac" },
+        {"OElig", "\u0152"},
+        {"oelig", "\u0153"},
+        {"Scaron", "\u0160"},
+        {"scaron", "\u0161"},
+        {"Yuml", "\u0178"},
+        {"circ", "\u02c6"},
+        {"tilde", "\u02dc"},
+        {"ensp", "\u2002"},
+        {"emsp", "\u2003"},
+        {"thinsp", "\u2009"},
+        {"zwnj", "\u200c"},
+        {"zwj", "\u200d"},
+        {"lrm", "\u200e"},
+        {"rlm", "\u200f"},
+        {"ndash", "\u2013"},
+        {"mdash", "\u2014"},
+        {"lsquo", "\u2018"},
+        {"rsquo", "\u2019"},
+        {"sbquo", "\u201a"},
+        {"ldquo", "\u201c"},
+        {"rdquo", "\u201d"},
+        {"bdquo", "\u201e"},
+        {"dagger", "\u2020"},
+        {"Dagger", "\u2021"},
+        {"permil", "\u2030"},
+        {"lsaquo", "\u2039"},
+        {"rsaquo", "\u203a"},
+        {"euro", "\u20ac"},
 
         // ----------------------------------------------------------------------
         // Symbol entities
         // ----------------------------------------------------------------------
 
-        { "fnof", "\u0192" }, { "Alpha", "\u0391" }, { "Beta", "\u0392" }, { "Gamma", "\u0393" }, { "Delta", "\u0394" },
-        { "Epsilon", "\u0395" }, { "Zeta", "\u0396" }, { "Eta", "\u0397" }, { "Theta", "\u0398" }, { "Iota", "\u0399" },
-        { "Kappa", "\u039a" }, { "Lambda", "\u039b" }, { "Mu", "\u039c" }, { "Nu", "\u039d" }, { "Xi", "\u039e" },
-        { "Omicron", "\u039f" }, { "Pi", "\u03a0" }, { "Rho", "\u03a1" }, { "Sigma", "\u03a3" }, { "Tau", "\u03a4" },
-        { "Upsilon", "\u03a5" }, { "Phi", "\u03a6" }, { "Chi", "\u03a7" }, { "Psi", "\u03a8" }, { "Omega", "\u03a9" },
-        { "alpha", "\u03b1" }, { "beta", "\u03b2" }, { "gamma", "\u03b3" }, { "delta", "\u03b4" },
-        { "epsilon", "\u03b5" }, { "zeta", "\u03b6" }, { "eta", "\u03b7" }, { "theta", "\u03b8" }, { "iota", "\u03b9" },
-        { "kappa", "\u03ba" }, { "lambda", "\u03bb" }, { "mu", "\u03bc" }, { "nu", "\u03bd" }, { "xi", "\u03be" },
-        { "omicron", "\u03bf" }, { "pi", "\u03c0" }, { "rho", "\u03c1" }, { "sigmaf", "\u03c2" }, { "sigma", "\u03c3" },
-        { "tau", "\u03c4" }, { "upsilon", "\u03c5" }, { "phi", "\u03c6" }, { "chi", "\u03c7" }, { "psi", "\u03c8" },
-        { "omega", "\u03c9" }, { "thetasym", "\u03d1" }, { "upsih", "\u03d2" }, { "piv", "\u03d6" },
-        { "bull", "\u2022" }, { "hellip", "\u2026" }, { "prime", "\u2032" }, { "Prime", "\u2033" },
-        { "oline", "\u203e" }, { "frasl", "\u2044" }, { "weierp", "\u2118" }, { "image", "\u2111" },
-        { "real", "\u211c" }, { "trade", "\u2122" }, { "alefsym", "\u2135" }, { "larr", "\u2190" },
-        { "uarr", "\u2191" }, { "rarr", "\u2192" }, { "darr", "\u2193" }, { "harr", "\u2194" }, { "crarr", "\u21b5" },
-        { "lArr", "\u21d0" }, { "uArr", "\u21d1" }, { "rArr", "\u21d2" }, { "dArr", "\u21d3" }, { "hArr", "\u21d4" },
-        { "forall", "\u2200" }, { "part", "\u2202" }, { "exist", "\u2203" }, { "empty", "\u2205" },
-        { "nabla", "\u2207" }, { "isin", "\u2208" }, { "notin", "\u2209" }, { "ni", "\u220b" }, { "prod", "\u220f" },
-        { "sum", "\u2211" }, { "minus", "\u2212" }, { "lowast", "\u2217" }, { "radic", "\u221a" }, { "prop", "\u221d" },
-        { "infin", "\u221e" }, { "ang", "\u2220" }, { "and", "\u2227" }, { "or", "\u2228" }, { "cap", "\u2229" },
-        { "cup", "\u222a" }, { "int", "\u222b" }, { "there4", "\u2234" }, { "sim", "\u223c" }, { "cong", "\u2245" },
-        { "asymp", "\u2248" }, { "ne", "\u2260" }, { "equiv", "\u2261" }, { "le", "\u2264" }, { "ge", "\u2265" },
-        { "sub", "\u2282" }, { "sup", "\u2283" }, { "nsub", "\u2284" }, { "sube", "\u2286" }, { "supe", "\u2287" },
-        { "oplus", "\u2295" }, { "otimes", "\u2297" }, { "perp", "\u22a5" }, { "sdot", "\u22c5" },
-        { "lceil", "\u2308" }, { "rceil", "\u2309" }, { "lfloor", "\u230a" }, { "rfloor", "\u230b" },
-        { "lang", "\u2329" }, { "rang", "\u232a" }, { "loz", "\u25ca" }, { "spades", "\u2660" }, { "clubs", "\u2663" },
-        { "hearts", "\u2665" }, { "diams", "\u2666" } } );
-
+        {"fnof", "\u0192"},
+        {"Alpha", "\u0391"},
+        {"Beta", "\u0392"},
+        {"Gamma", "\u0393"},
+        {"Delta", "\u0394"},
+        {"Epsilon", "\u0395"},
+        {"Zeta", "\u0396"},
+        {"Eta", "\u0397"},
+        {"Theta", "\u0398"},
+        {"Iota", "\u0399"},
+        {"Kappa", "\u039a"},
+        {"Lambda", "\u039b"},
+        {"Mu", "\u039c"},
+        {"Nu", "\u039d"},
+        {"Xi", "\u039e"},
+        {"Omicron", "\u039f"},
+        {"Pi", "\u03a0"},
+        {"Rho", "\u03a1"},
+        {"Sigma", "\u03a3"},
+        {"Tau", "\u03a4"},
+        {"Upsilon", "\u03a5"},
+        {"Phi", "\u03a6"},
+        {"Chi", "\u03a7"},
+        {"Psi", "\u03a8"},
+        {"Omega", "\u03a9"},
+        {"alpha", "\u03b1"},
+        {"beta", "\u03b2"},
+        {"gamma", "\u03b3"},
+        {"delta", "\u03b4"},
+        {"epsilon", "\u03b5"},
+        {"zeta", "\u03b6"},
+        {"eta", "\u03b7"},
+        {"theta", "\u03b8"},
+        {"iota", "\u03b9"},
+        {"kappa", "\u03ba"},
+        {"lambda", "\u03bb"},
+        {"mu", "\u03bc"},
+        {"nu", "\u03bd"},
+        {"xi", "\u03be"},
+        {"omicron", "\u03bf"},
+        {"pi", "\u03c0"},
+        {"rho", "\u03c1"},
+        {"sigmaf", "\u03c2"},
+        {"sigma", "\u03c3"},
+        {"tau", "\u03c4"},
+        {"upsilon", "\u03c5"},
+        {"phi", "\u03c6"},
+        {"chi", "\u03c7"},
+        {"psi", "\u03c8"},
+        {"omega", "\u03c9"},
+        {"thetasym", "\u03d1"},
+        {"upsih", "\u03d2"},
+        {"piv", "\u03d6"},
+        {"bull", "\u2022"},
+        {"hellip", "\u2026"},
+        {"prime", "\u2032"},
+        {"Prime", "\u2033"},
+        {"oline", "\u203e"},
+        {"frasl", "\u2044"},
+        {"weierp", "\u2118"},
+        {"image", "\u2111"},
+        {"real", "\u211c"},
+        {"trade", "\u2122"},
+        {"alefsym", "\u2135"},
+        {"larr", "\u2190"},
+        {"uarr", "\u2191"},
+        {"rarr", "\u2192"},
+        {"darr", "\u2193"},
+        {"harr", "\u2194"},
+        {"crarr", "\u21b5"},
+        {"lArr", "\u21d0"},
+        {"uArr", "\u21d1"},
+        {"rArr", "\u21d2"},
+        {"dArr", "\u21d3"},
+        {"hArr", "\u21d4"},
+        {"forall", "\u2200"},
+        {"part", "\u2202"},
+        {"exist", "\u2203"},
+        {"empty", "\u2205"},
+        {"nabla", "\u2207"},
+        {"isin", "\u2208"},
+        {"notin", "\u2209"},
+        {"ni", "\u220b"},
+        {"prod", "\u220f"},
+        {"sum", "\u2211"},
+        {"minus", "\u2212"},
+        {"lowast", "\u2217"},
+        {"radic", "\u221a"},
+        {"prop", "\u221d"},
+        {"infin", "\u221e"},
+        {"ang", "\u2220"},
+        {"and", "\u2227"},
+        {"or", "\u2228"},
+        {"cap", "\u2229"},
+        {"cup", "\u222a"},
+        {"int", "\u222b"},
+        {"there4", "\u2234"},
+        {"sim", "\u223c"},
+        {"cong", "\u2245"},
+        {"asymp", "\u2248"},
+        {"ne", "\u2260"},
+        {"equiv", "\u2261"},
+        {"le", "\u2264"},
+        {"ge", "\u2265"},
+        {"sub", "\u2282"},
+        {"sup", "\u2283"},
+        {"nsub", "\u2284"},
+        {"sube", "\u2286"},
+        {"supe", "\u2287"},
+        {"oplus", "\u2295"},
+        {"otimes", "\u2297"},
+        {"perp", "\u22a5"},
+        {"sdot", "\u22c5"},
+        {"lceil", "\u2308"},
+        {"rceil", "\u2309"},
+        {"lfloor", "\u230a"},
+        {"rfloor", "\u230b"},
+        {"lang", "\u2329"},
+        {"rang", "\u232a"},
+        {"loz", "\u25ca"},
+        {"spades", "\u2660"},
+        {"clubs", "\u2663"},
+        {"hearts", "\u2665"},
+        {"diams", "\u2666"}
+    });
 }
diff --git a/src/main/java/org/codehaus/plexus/util/xml/pull/MXParser.java b/src/main/java/org/codehaus/plexus/util/xml/pull/MXParser.java
index 98387238..6de5974c 100644
--- a/src/main/java/org/codehaus/plexus/util/xml/pull/MXParser.java
+++ b/src/main/java/org/codehaus/plexus/util/xml/pull/MXParser.java
@@ -18,14 +18,14 @@
 import org.codehaus.plexus.util.xml.ReaderFactory;
 import org.codehaus.plexus.util.xml.XmlReader;
 
-//import java.util.Hashtable;
+// import java.util.Hashtable;
 
-//TODO best handling of interning issues
+// TODO best handling of interning issues
 //   have isAllNewStringInterned ???
 
-//TODO handling surrogate pairs: http://www.unicode.org/unicode/faq/utf_bom.html#6
+// TODO handling surrogate pairs: http://www.unicode.org/unicode/faq/utf_bom.html#6
 
-//TODO review code for use of bufAbsoluteStart when keeping pos between next()/fillBuf()
+// TODO review code for use of bufAbsoluteStart when keeping pos between next()/fillBuf()
 
 /**
  * Absolutely minimal implementation of XMLPULL V1 API. Encoding handling done with XmlReader
@@ -33,31 +33,26 @@
  * @see org.codehaus.plexus.util.xml.XmlReader
  * @author Aleksander Slominski
  */
-
-public class MXParser
-    implements XmlPullParser
-{
+public class MXParser implements XmlPullParser {
     // NOTE: no interning of those strings --> by Java leng spec they MUST be already interned
-    private final static String XML_URI = "http://www.w3.org/XML/1998/namespace";
+    private static final String XML_URI = "http://www.w3.org/XML/1998/namespace";
 
-    private final static String XMLNS_URI = "http://www.w3.org/2000/xmlns/";
+    private static final String XMLNS_URI = "http://www.w3.org/2000/xmlns/";
 
-    private final static String FEATURE_XML_ROUNDTRIP =
-        // "http://xmlpull.org/v1/doc/features.html#xml-roundtrip";
-        "http://xmlpull.org/v1/doc/features.html#xml-roundtrip";
+    private static final String FEATURE_XML_ROUNDTRIP =
+            // "http://xmlpull.org/v1/doc/features.html#xml-roundtrip";
+            "http://xmlpull.org/v1/doc/features.html#xml-roundtrip";
 
-    private final static String FEATURE_NAMES_INTERNED = "http://xmlpull.org/v1/doc/features.html#names-interned";
+    private static final String FEATURE_NAMES_INTERNED = "http://xmlpull.org/v1/doc/features.html#names-interned";
 
-    private final static String PROPERTY_XMLDECL_VERSION =
-        "http://xmlpull.org/v1/doc/properties.html#xmldecl-version";
+    private static final String PROPERTY_XMLDECL_VERSION = "http://xmlpull.org/v1/doc/properties.html#xmldecl-version";
 
-    private final static String PROPERTY_XMLDECL_STANDALONE =
-        "http://xmlpull.org/v1/doc/properties.html#xmldecl-standalone";
+    private static final String PROPERTY_XMLDECL_STANDALONE =
+            "http://xmlpull.org/v1/doc/properties.html#xmldecl-standalone";
 
-    private final static String PROPERTY_XMLDECL_CONTENT =
-        "http://xmlpull.org/v1/doc/properties.html#xmldecl-content";
+    private static final String PROPERTY_XMLDECL_CONTENT = "http://xmlpull.org/v1/doc/properties.html#xmldecl-content";
 
-    private final static String PROPERTY_LOCATION = "http://xmlpull.org/v1/doc/properties.html#location";
+    private static final String PROPERTY_LOCATION = "http://xmlpull.org/v1/doc/properties.html#location";
 
     /**
      * Implementation notice: the is instance variable that controls if newString() is interning.
@@ -69,19 +64,16 @@ public class MXParser
      */
     private boolean allStringsInterned;
 
-    private void resetStringCache()
-    {
+    private void resetStringCache() {
         // System.out.println("resetStringCache() minimum called");
     }
 
-    private String newString( char[] cbuf, int off, int len )
-    {
-        return new String( cbuf, off, len );
+    private String newString(char[] cbuf, int off, int len) {
+        return new String(cbuf, off, len);
     }
 
-    private String newStringIntern( char[] cbuf, int off, int len )
-    {
-        return ( new String( cbuf, off, len ) ).intern();
+    private String newStringIntern(char[] cbuf, int off, int len) {
+        return (new String(cbuf, off, len)).intern();
     }
 
     private static final boolean TRACE_SIZING = false;
@@ -130,40 +122,31 @@ private String newStringIntern( char[] cbuf, int off, int len )
      * Make sure that we have enough space to keep element stack if passed size. It will always create one additional
      * slot then current depth
      */
-    private void ensureElementsCapacity()
-    {
+    private void ensureElementsCapacity() {
         final int elStackSize = elName != null ? elName.length : 0;
-        if ( ( depth + 1 ) >= elStackSize )
-        {
+        if ((depth + 1) >= elStackSize) {
             // we add at least one extra slot ...
-            final int newSize = ( depth >= 7 ? 2 * depth : 8 ) + 2; // = lucky 7 + 1 //25
-            if ( TRACE_SIZING )
-            {
-                System.err.println( "TRACE_SIZING elStackSize " + elStackSize + " ==> " + newSize );
+            final int newSize = (depth >= 7 ? 2 * depth : 8) + 2; // = lucky 7 + 1 //25
+            if (TRACE_SIZING) {
+                System.err.println("TRACE_SIZING elStackSize " + elStackSize + " ==> " + newSize);
             }
             final boolean needsCopying = elStackSize > 0;
             String[] arr = null;
             // resue arr local variable slot
             arr = new String[newSize];
-            if ( needsCopying )
-                System.arraycopy( elName, 0, arr, 0, elStackSize );
+            if (needsCopying) System.arraycopy(elName, 0, arr, 0, elStackSize);
             elName = arr;
             arr = new String[newSize];
-            if ( needsCopying )
-                System.arraycopy( elPrefix, 0, arr, 0, elStackSize );
+            if (needsCopying) System.arraycopy(elPrefix, 0, arr, 0, elStackSize);
             elPrefix = arr;
             arr = new String[newSize];
-            if ( needsCopying )
-                System.arraycopy( elUri, 0, arr, 0, elStackSize );
+            if (needsCopying) System.arraycopy(elUri, 0, arr, 0, elStackSize);
             elUri = arr;
 
             int[] iarr = new int[newSize];
-            if ( needsCopying )
-            {
-                System.arraycopy( elNamespaceCount, 0, iarr, 0, elStackSize );
-            }
-            else
-            {
+            if (needsCopying) {
+                System.arraycopy(elNamespaceCount, 0, iarr, 0, elStackSize);
+            } else {
                 // special initialization
                 iarr[0] = 0;
             }
@@ -171,23 +154,20 @@ private void ensureElementsCapacity()
 
             // TODO: avoid using element raw name ...
             iarr = new int[newSize];
-            if ( needsCopying )
-            {
-                System.arraycopy( elRawNameEnd, 0, iarr, 0, elStackSize );
+            if (needsCopying) {
+                System.arraycopy(elRawNameEnd, 0, iarr, 0, elStackSize);
             }
             elRawNameEnd = iarr;
 
             iarr = new int[newSize];
-            if ( needsCopying )
-            {
-                System.arraycopy( elRawNameLine, 0, iarr, 0, elStackSize );
+            if (needsCopying) {
+                System.arraycopy(elRawNameLine, 0, iarr, 0, elStackSize);
             }
             elRawNameLine = iarr;
 
             final char[][] carr = new char[newSize][];
-            if ( needsCopying )
-            {
-                System.arraycopy( elRawName, 0, carr, 0, elStackSize );
+            if (needsCopying) {
+                System.arraycopy(elRawName, 0, carr, 0, elStackSize);
             }
             elRawName = carr;
             // arr = new String[newSize];
@@ -225,44 +205,35 @@ private void ensureElementsCapacity()
     // private int attributeValueEnd[];
 
     // Make sure that in attributes temporary array is enough space.
-    private void ensureAttributesCapacity( int size )
-    {
+    private void ensureAttributesCapacity(int size) {
         final int attrPosSize = attributeName != null ? attributeName.length : 0;
-        if ( size >= attrPosSize )
-        {
+        if (size >= attrPosSize) {
             final int newSize = size > 7 ? 2 * size : 8; // = lucky 7 + 1 //25
-            if ( TRACE_SIZING )
-            {
-                System.err.println( "TRACE_SIZING attrPosSize " + attrPosSize + " ==> " + newSize );
+            if (TRACE_SIZING) {
+                System.err.println("TRACE_SIZING attrPosSize " + attrPosSize + " ==> " + newSize);
             }
             final boolean needsCopying = attrPosSize > 0;
             String[] arr = null;
 
             arr = new String[newSize];
-            if ( needsCopying )
-                System.arraycopy( attributeName, 0, arr, 0, attrPosSize );
+            if (needsCopying) System.arraycopy(attributeName, 0, arr, 0, attrPosSize);
             attributeName = arr;
 
             arr = new String[newSize];
-            if ( needsCopying )
-                System.arraycopy( attributePrefix, 0, arr, 0, attrPosSize );
+            if (needsCopying) System.arraycopy(attributePrefix, 0, arr, 0, attrPosSize);
             attributePrefix = arr;
 
             arr = new String[newSize];
-            if ( needsCopying )
-                System.arraycopy( attributeUri, 0, arr, 0, attrPosSize );
+            if (needsCopying) System.arraycopy(attributeUri, 0, arr, 0, attrPosSize);
             attributeUri = arr;
 
             arr = new String[newSize];
-            if ( needsCopying )
-                System.arraycopy( attributeValue, 0, arr, 0, attrPosSize );
+            if (needsCopying) System.arraycopy(attributeValue, 0, arr, 0, attrPosSize);
             attributeValue = arr;
 
-            if ( !allStringsInterned )
-            {
+            if (!allStringsInterned) {
                 final int[] iarr = new int[newSize];
-                if ( needsCopying )
-                    System.arraycopy( attributeNameHash, 0, iarr, 0, attrPosSize );
+                if (needsCopying) System.arraycopy(attributeNameHash, 0, iarr, 0, attrPosSize);
                 attributeNameHash = iarr;
             }
 
@@ -280,32 +251,26 @@ private void ensureAttributesCapacity( int size )
 
     private String namespaceUri[];
 
-    private void ensureNamespacesCapacity( int size )
-    {
+    private void ensureNamespacesCapacity(int size) {
         final int namespaceSize = namespacePrefix != null ? namespacePrefix.length : 0;
-        if ( size >= namespaceSize )
-        {
+        if (size >= namespaceSize) {
             final int newSize = size > 7 ? 2 * size : 8; // = lucky 7 + 1 //25
-            if ( TRACE_SIZING )
-            {
-                System.err.println( "TRACE_SIZING namespaceSize " + namespaceSize + " ==> " + newSize );
+            if (TRACE_SIZING) {
+                System.err.println("TRACE_SIZING namespaceSize " + namespaceSize + " ==> " + newSize);
             }
             final String[] newNamespacePrefix = new String[newSize];
             final String[] newNamespaceUri = new String[newSize];
-            if ( namespacePrefix != null )
-            {
-                System.arraycopy( namespacePrefix, 0, newNamespacePrefix, 0, namespaceEnd );
-                System.arraycopy( namespaceUri, 0, newNamespaceUri, 0, namespaceEnd );
+            if (namespacePrefix != null) {
+                System.arraycopy(namespacePrefix, 0, newNamespacePrefix, 0, namespaceEnd);
+                System.arraycopy(namespaceUri, 0, newNamespaceUri, 0, namespaceEnd);
             }
             namespacePrefix = newNamespacePrefix;
             namespaceUri = newNamespaceUri;
 
-            if ( !allStringsInterned )
-            {
+            if (!allStringsInterned) {
                 final int[] newNamespacePrefixHash = new int[newSize];
-                if ( namespacePrefixHash != null )
-                {
-                    System.arraycopy( namespacePrefixHash, 0, newNamespacePrefixHash, 0, namespaceEnd );
+                if (namespacePrefixHash != null) {
+                    System.arraycopy(namespacePrefixHash, 0, newNamespacePrefixHash, 0, namespaceEnd);
                 }
                 namespacePrefixHash = newNamespacePrefixHash;
             }
@@ -314,26 +279,21 @@ private void ensureNamespacesCapacity( int size )
         }
     }
 
+    // simplistic implementation of hash function that has constant time to compute - so it also means
+    // diminishing hash quality for long strings but for XML parsing it should be good enough ...
 
-     // simplistic implementation of hash function that has constant time to compute - so it also means
-     // diminishing hash quality for long strings but for XML parsing it should be good enough ...
-
-    private static final int fastHash( char ch[], int off, int len )
-    {
-        if ( len == 0 )
-            return 0;
+    private static final int fastHash(char ch[], int off, int len) {
+        if (len == 0) return 0;
         // assert len >0
         int hash = ch[off]; // hash at beginning
         // try {
-        hash = ( hash << 7 ) + ch[off + len - 1]; // hash at the end
+        hash = (hash << 7) + ch[off + len - 1]; // hash at the end
         // } catch(ArrayIndexOutOfBoundsException aie) {
         // aie.printStackTrace(); //should never happen ...
         // throw new RuntimeException("this is violation of pre-condition");
         // }
-        if ( len > 16 )
-            hash = ( hash << 7 ) + ch[off + ( len / 4 )]; // 1/4 from beginning
-        if ( len > 8 )
-            hash = ( hash << 7 ) + ch[off + ( len / 2 )]; // 1/2 of string size ...
+        if (len > 16) hash = (hash << 7) + ch[off + (len / 4)]; // 1/4 from beginning
+        if (len > 8) hash = (hash << 7) + ch[off + (len / 2)]; // 1/2 of string size ...
         // notice that hash is at most done 3 times <<7 so shifted by 21 bits 8 bit value
         // so max result == 29 bits so it is quite just below 31 bits for long (2^32) ...
         // assert hash >= 0;
@@ -355,38 +315,32 @@ private static final int fastHash( char ch[], int off, int len )
 
     private final EntityReplacementMap replacementMapTemplate;
 
-    private void ensureEntityCapacity()
-    {
+    private void ensureEntityCapacity() {
         final int entitySize = entityReplacementBuf != null ? entityReplacementBuf.length : 0;
-        if ( entityEnd >= entitySize )
-        {
+        if (entityEnd >= entitySize) {
             final int newSize = entityEnd > 7 ? 2 * entityEnd : 8; // = lucky 7 + 1 //25
-            if ( TRACE_SIZING )
-            {
-                System.err.println( "TRACE_SIZING entitySize " + entitySize + " ==> " + newSize );
+            if (TRACE_SIZING) {
+                System.err.println("TRACE_SIZING entitySize " + entitySize + " ==> " + newSize);
             }
             final String[] newEntityName = new String[newSize];
             final char[] newEntityNameBuf[] = new char[newSize][];
             final String[] newEntityReplacement = new String[newSize];
             final char[] newEntityReplacementBuf[] = new char[newSize][];
-            if ( entityName != null )
-            {
-                System.arraycopy( entityName, 0, newEntityName, 0, entityEnd );
-                System.arraycopy( entityNameBuf, 0, newEntityNameBuf, 0, entityEnd );
-                System.arraycopy( entityReplacement, 0, newEntityReplacement, 0, entityEnd );
-                System.arraycopy( entityReplacementBuf, 0, newEntityReplacementBuf, 0, entityEnd );
+            if (entityName != null) {
+                System.arraycopy(entityName, 0, newEntityName, 0, entityEnd);
+                System.arraycopy(entityNameBuf, 0, newEntityNameBuf, 0, entityEnd);
+                System.arraycopy(entityReplacement, 0, newEntityReplacement, 0, entityEnd);
+                System.arraycopy(entityReplacementBuf, 0, newEntityReplacementBuf, 0, entityEnd);
             }
             entityName = newEntityName;
             entityNameBuf = newEntityNameBuf;
             entityReplacement = newEntityReplacement;
             entityReplacementBuf = newEntityReplacementBuf;
 
-            if ( !allStringsInterned )
-            {
+            if (!allStringsInterned) {
                 final int[] newEntityNameHash = new int[newSize];
-                if ( entityNameHash != null )
-                {
-                    System.arraycopy( entityNameHash, 0, newEntityNameHash, 0, entityEnd );
+                if (entityNameHash != null) {
+                    System.arraycopy(entityNameHash, 0, newEntityNameHash, 0, entityEnd);
                 }
                 entityNameHash = newEntityNameHash;
             }
@@ -405,9 +359,9 @@ private void ensureEntityCapacity()
 
     private float bufferLoadFactor = bufLoadFactor / 100f;
 
-	private char buf[] = new char[Runtime.getRuntime().freeMemory() > 1000000L ? READ_CHUNK_SIZE : 256];
+    private char buf[] = new char[Runtime.getRuntime().freeMemory() > 1000000L ? READ_CHUNK_SIZE : 256];
 
-	private int bufSoftLimit = (int) ( bufferLoadFactor * buf.length ); // desirable size of buffer
+    private int bufSoftLimit = (int) (bufferLoadFactor * buf.length); // desirable size of buffer
 
     private boolean preventBufferCompaction;
 
@@ -459,8 +413,7 @@ private void ensureEntityCapacity()
 
     private String xmlDeclContent;
 
-    private void reset()
-    {
+    private void reset() {
         // System.out.println("reset() called");
         location = null;
         lineNumber = 1;
@@ -505,20 +458,16 @@ private void reset()
         resetStringCache();
     }
 
-    public MXParser()
-    {
+    public MXParser() {
         replacementMapTemplate = null;
     }
 
-    public MXParser( EntityReplacementMap entityReplacementMap )
-    {
+    public MXParser(EntityReplacementMap entityReplacementMap) {
         this.replacementMapTemplate = entityReplacementMap;
     }
 
-    public void setupFromTemplate()
-    {
-        if ( replacementMapTemplate != null )
-        {
+    public void setupFromTemplate() {
+        if (replacementMapTemplate != null) {
             int length = replacementMapTemplate.entityEnd;
 
             // This is a bit cheeky, since the EntityReplacementMap contains exact-sized arrays,
@@ -541,49 +490,35 @@ public void setupFromTemplate()
      * @throws XmlPullParserException issue
      */
     @Override
-    public void setFeature( String name, boolean state )
-        throws XmlPullParserException
-    {
-        if ( name == null )
-            throw new IllegalArgumentException( "feature name should not be null" );
-        if ( FEATURE_PROCESS_NAMESPACES.equals( name ) )
-        {
-            if ( eventType != START_DOCUMENT )
-                throw new XmlPullParserException( "namespace processing feature can only be changed before parsing",
-                                                  this, null );
+    public void setFeature(String name, boolean state) throws XmlPullParserException {
+        if (name == null) throw new IllegalArgumentException("feature name should not be null");
+        if (FEATURE_PROCESS_NAMESPACES.equals(name)) {
+            if (eventType != START_DOCUMENT)
+                throw new XmlPullParserException(
+                        "namespace processing feature can only be changed before parsing", this, null);
             processNamespaces = state;
             // } else if(FEATURE_REPORT_NAMESPACE_ATTRIBUTES.equals(name)) {
             // if(type != START_DOCUMENT) throw new XmlPullParserException(
             // "namespace reporting feature can only be changed before parsing", this, null);
             // reportNsAttribs = state;
-        }
-        else if ( FEATURE_NAMES_INTERNED.equals( name ) )
-        {
-            if ( state != false )
-            {
-                throw new XmlPullParserException( "interning names in this implementation is not supported" );
+        } else if (FEATURE_NAMES_INTERNED.equals(name)) {
+            if (state != false) {
+                throw new XmlPullParserException("interning names in this implementation is not supported");
             }
-        }
-        else if ( FEATURE_PROCESS_DOCDECL.equals( name ) )
-        {
-            if ( state != false )
-            {
-                throw new XmlPullParserException( "processing DOCDECL is not supported" );
+        } else if (FEATURE_PROCESS_DOCDECL.equals(name)) {
+            if (state != false) {
+                throw new XmlPullParserException("processing DOCDECL is not supported");
             }
             // } else if(REPORT_DOCDECL.equals(name)) {
             // paramNotifyDoctype = state;
-        }
-        else if ( FEATURE_XML_ROUNDTRIP.equals( name ) )
-        {
+        } else if (FEATURE_XML_ROUNDTRIP.equals(name)) {
             // if(state == false) {
             // throw new XmlPullParserException(
             // "roundtrip feature can not be switched off");
             // }
             roundtripSupported = state;
-        }
-        else
-        {
-            throw new XmlPullParserException( "unsupported feature " + name );
+        } else {
+            throw new XmlPullParserException("unsupported feature " + name);
         }
     }
 
@@ -591,28 +526,19 @@ else if ( FEATURE_XML_ROUNDTRIP.equals( name ) )
      * Unknown properties are always returned as false
      */
     @Override
-    public boolean getFeature( String name )
-    {
-        if ( name == null )
-            throw new IllegalArgumentException( "feature name should not be null" );
-        if ( FEATURE_PROCESS_NAMESPACES.equals( name ) )
-        {
+    public boolean getFeature(String name) {
+        if (name == null) throw new IllegalArgumentException("feature name should not be null");
+        if (FEATURE_PROCESS_NAMESPACES.equals(name)) {
             return processNamespaces;
             // } else if(FEATURE_REPORT_NAMESPACE_ATTRIBUTES.equals(name)) {
             // return reportNsAttribs;
-        }
-        else if ( FEATURE_NAMES_INTERNED.equals( name ) )
-        {
+        } else if (FEATURE_NAMES_INTERNED.equals(name)) {
             return false;
-        }
-        else if ( FEATURE_PROCESS_DOCDECL.equals( name ) )
-        {
+        } else if (FEATURE_PROCESS_DOCDECL.equals(name)) {
             return false;
             // } else if(REPORT_DOCDECL.equals(name)) {
             // return paramNotifyDoctype;
-        }
-        else if ( FEATURE_XML_ROUNDTRIP.equals( name ) )
-        {
+        } else if (FEATURE_XML_ROUNDTRIP.equals(name)) {
             // return true;
             return roundtripSupported;
         }
@@ -620,118 +546,82 @@ else if ( FEATURE_XML_ROUNDTRIP.equals( name ) )
     }
 
     @Override
-    public void setProperty( String name, Object value )
-        throws XmlPullParserException
-    {
-        if ( PROPERTY_LOCATION.equals( name ) )
-        {
+    public void setProperty(String name, Object value) throws XmlPullParserException {
+        if (PROPERTY_LOCATION.equals(name)) {
             location = (String) value;
-        }
-        else
-        {
-            throw new XmlPullParserException( "unsupported property: '" + name + "'" );
+        } else {
+            throw new XmlPullParserException("unsupported property: '" + name + "'");
         }
     }
 
     @Override
-    public Object getProperty( String name )
-    {
-        if ( name == null )
-            throw new IllegalArgumentException( "property name should not be null" );
-        if ( PROPERTY_XMLDECL_VERSION.equals( name ) )
-        {
+    public Object getProperty(String name) {
+        if (name == null) throw new IllegalArgumentException("property name should not be null");
+        if (PROPERTY_XMLDECL_VERSION.equals(name)) {
             return xmlDeclVersion;
-        }
-        else if ( PROPERTY_XMLDECL_STANDALONE.equals( name ) )
-        {
+        } else if (PROPERTY_XMLDECL_STANDALONE.equals(name)) {
             return xmlDeclStandalone;
-        }
-        else if ( PROPERTY_XMLDECL_CONTENT.equals( name ) )
-        {
+        } else if (PROPERTY_XMLDECL_CONTENT.equals(name)) {
             return xmlDeclContent;
-        }
-        else if ( PROPERTY_LOCATION.equals( name ) )
-        {
+        } else if (PROPERTY_LOCATION.equals(name)) {
             return location;
         }
         return null;
     }
 
     @Override
-    public void setInput( Reader in )
-        throws XmlPullParserException
-    {
+    public void setInput(Reader in) throws XmlPullParserException {
         reset();
         reader = in;
 
-        if ( reader instanceof XmlReader ) {
+        if (reader instanceof XmlReader) {
             // encoding already detected
             XmlReader xsr = (XmlReader) reader;
             fileEncoding = xsr.getEncoding();
-        }
-        else if ( reader instanceof InputStreamReader )
-        {
+        } else if (reader instanceof InputStreamReader) {
             InputStreamReader isr = (InputStreamReader) reader;
-            if ( isr.getEncoding() != null )
-            {
+            if (isr.getEncoding() != null) {
                 fileEncoding = isr.getEncoding().toUpperCase();
             }
         }
     }
 
     @Override
-    public void setInput( java.io.InputStream inputStream, String inputEncoding )
-        throws XmlPullParserException
-    {
-        if ( inputStream == null )
-        {
-            throw new IllegalArgumentException( "input stream can not be null" );
+    public void setInput(java.io.InputStream inputStream, String inputEncoding) throws XmlPullParserException {
+        if (inputStream == null) {
+            throw new IllegalArgumentException("input stream can not be null");
         }
         Reader reader;
-        try
-        {
-            if ( inputEncoding != null )
-            {
-                reader = ReaderFactory.newReader( inputStream, inputEncoding );
-            }
-            else
-            {
-                reader = ReaderFactory.newXmlReader( inputStream );
-            }
-        }
-        catch ( UnsupportedEncodingException une )
-        {
-            throw new XmlPullParserException( "could not create reader for encoding " + inputEncoding + " : " + une,
-                                              this, une );
-        }
-        catch ( IOException e )
-        {
-            throw new XmlPullParserException( "could not create reader : " + e, this, e );
-        }
-        setInput( reader );
+        try {
+            if (inputEncoding != null) {
+                reader = ReaderFactory.newReader(inputStream, inputEncoding);
+            } else {
+                reader = ReaderFactory.newXmlReader(inputStream);
+            }
+        } catch (UnsupportedEncodingException une) {
+            throw new XmlPullParserException(
+                    "could not create reader for encoding " + inputEncoding + " : " + une, this, une);
+        } catch (IOException e) {
+            throw new XmlPullParserException("could not create reader : " + e, this, e);
+        }
+        setInput(reader);
         // must be here as reset() was called in setInput() and has set this.inputEncoding to null ...
         this.inputEncoding = inputEncoding;
     }
 
     @Override
-    public String getInputEncoding()
-    {
+    public String getInputEncoding() {
         return inputEncoding;
     }
 
     @Override
-    public void defineEntityReplacementText( String entityName, String replacementText )
-        throws XmlPullParserException
-    {
+    public void defineEntityReplacementText(String entityName, String replacementText) throws XmlPullParserException {
         // throw new XmlPullParserException("not allowed");
 
-        if ( !replacementText.startsWith( "&#" ) && this.entityName != null && replacementText.length() > 1 )
-        {
-            String tmp = replacementText.substring( 1, replacementText.length() - 1 );
-            for ( int i = 0; i < this.entityName.length; i++ )
-            {
-                if ( this.entityName[i] != null && this.entityName[i].equals( tmp ) )
-                {
+        if (!replacementText.startsWith("&#") && this.entityName != null && replacementText.length() > 1) {
+            String tmp = replacementText.substring(1, replacementText.length() - 1);
+            for (int i = 0; i < this.entityName.length; i++) {
+                if (this.entityName[i] != null && this.entityName[i].equals(tmp)) {
                     replacementText = this.entityReplacement[i];
                 }
             }
@@ -742,14 +632,13 @@ public void defineEntityReplacementText( String entityName, String replacementTe
 
         // this is to make sure that if interning works we will take advantage of it ...
         char[] entityNameCharData = entityName.toCharArray();
-        this.entityName[entityEnd] = newString( entityNameCharData, 0, entityName.length() );
+        this.entityName[entityEnd] = newString(entityNameCharData, 0, entityName.length());
         entityNameBuf[entityEnd] = entityNameCharData;
 
         entityReplacement[entityEnd] = replacementText;
         entityReplacementBuf[entityEnd] = replacementText.toCharArray();
-        if ( !allStringsInterned )
-        {
-            entityNameHash[entityEnd] = fastHash( entityNameBuf[entityEnd], 0, entityNameBuf[entityEnd].length );
+        if (!allStringsInterned) {
+            entityNameHash[entityEnd] = fastHash(entityNameBuf[entityEnd], 0, entityNameBuf[entityEnd].length);
         }
         ++entityEnd;
         // TODO disallow < or & in entity replacement text (or ]]>???)
@@ -757,121 +646,89 @@ public void defineEntityReplacementText( String entityName, String replacementTe
     }
 
     @Override
-    public int getNamespaceCount( int depth )
-        throws XmlPullParserException
-    {
-        if ( !processNamespaces || depth == 0 )
-        {
+    public int getNamespaceCount(int depth) throws XmlPullParserException {
+        if (!processNamespaces || depth == 0) {
             return 0;
         }
         // int maxDepth = eventType == END_TAG ? this.depth + 1 : this.depth;
         // if(depth < 0 || depth > maxDepth) throw new IllegalArgumentException(
-        if ( depth < 0 || depth > this.depth )
-            throw new IllegalArgumentException( "namespace count may be for depth 0.." + this.depth + " not " + depth );
+        if (depth < 0 || depth > this.depth)
+            throw new IllegalArgumentException("namespace count may be for depth 0.." + this.depth + " not " + depth);
         return elNamespaceCount[depth];
     }
 
     @Override
-    public String getNamespacePrefix( int pos )
-        throws XmlPullParserException
-    {
+    public String getNamespacePrefix(int pos) throws XmlPullParserException {
 
         // int end = eventType == END_TAG ? elNamespaceCount[ depth + 1 ] : namespaceEnd;
         // if(pos < end) {
-        if ( pos < namespaceEnd )
-        {
+        if (pos < namespaceEnd) {
             return namespacePrefix[pos];
-        }
-        else
-        {
-            throw new XmlPullParserException( "position " + pos + " exceeded number of available namespaces "
-                + namespaceEnd );
+        } else {
+            throw new XmlPullParserException(
+                    "position " + pos + " exceeded number of available namespaces " + namespaceEnd);
         }
     }
 
     @Override
-    public String getNamespaceUri( int pos )
-        throws XmlPullParserException
-    {
+    public String getNamespaceUri(int pos) throws XmlPullParserException {
         // int end = eventType == END_TAG ? elNamespaceCount[ depth + 1 ] : namespaceEnd;
         // if(pos < end) {
-        if ( pos < namespaceEnd )
-        {
+        if (pos < namespaceEnd) {
             return namespaceUri[pos];
-        }
-        else
-        {
-            throw new XmlPullParserException( "position " + pos + " exceeded number of available namespaces "
-                + namespaceEnd );
+        } else {
+            throw new XmlPullParserException(
+                    "position " + pos + " exceeded number of available namespaces " + namespaceEnd);
         }
     }
 
     @Override
-    public String getNamespace( String prefix )
-    // throws XmlPullParserException
-    {
-        // int count = namespaceCount[ depth ];
-        if ( prefix != null )
-        {
-            for ( int i = namespaceEnd - 1; i >= 0; i-- )
+    public String getNamespace(String prefix)
+                // throws XmlPullParserException
             {
-                if ( prefix.equals( namespacePrefix[i] ) )
-                {
+        // int count = namespaceCount[ depth ];
+        if (prefix != null) {
+            for (int i = namespaceEnd - 1; i >= 0; i--) {
+                if (prefix.equals(namespacePrefix[i])) {
                     return namespaceUri[i];
                 }
             }
-            if ( "xml".equals( prefix ) )
-            {
+            if ("xml".equals(prefix)) {
                 return XML_URI;
-            }
-            else if ( "xmlns".equals( prefix ) )
-            {
+            } else if ("xmlns".equals(prefix)) {
                 return XMLNS_URI;
             }
-        }
-        else
-        {
-            for ( int i = namespaceEnd - 1; i >= 0; i-- )
-            {
-                if ( namespacePrefix[i] == null )
-                { // "") { //null ) { //TODO check FIXME Alek
+        } else {
+            for (int i = namespaceEnd - 1; i >= 0; i--) {
+                if (namespacePrefix[i] == null) { // "") { //null ) { //TODO check FIXME Alek
                     return namespaceUri[i];
                 }
             }
-
         }
         return null;
     }
 
     @Override
-    public int getDepth()
-    {
+    public int getDepth() {
         return depth;
     }
 
-    private static int findFragment( int bufMinPos, char[] b, int start, int end )
-    {
+    private static int findFragment(int bufMinPos, char[] b, int start, int end) {
         // System.err.println("bufStart="+bufStart+" b="+printable(new String(b, start, end - start))+" start="+start+"
         // end="+end);
-        if ( start < bufMinPos )
-        {
+        if (start < bufMinPos) {
             start = bufMinPos;
-            if ( start > end )
-                start = end;
+            if (start > end) start = end;
             return start;
         }
-        if ( end - start > 65 )
-        {
+        if (end - start > 65) {
             start = end - 10; // try to find good location
         }
         int i = start + 1;
-        while ( --i > bufMinPos )
-        {
-            if ( ( end - i ) > 65 )
-                break;
+        while (--i > bufMinPos) {
+            if ((end - i) > 65) break;
             final char c = b[i];
-            if ( c == '<' && ( start - i ) > 10 )
-                break;
+            if (c == '<' && (start - i) > 10) break;
         }
         return i;
     }
@@ -880,137 +737,104 @@ private static int findFragment( int bufMinPos, char[] b, int start, int end )
      * Return string describing current position of parsers as text 'STATE [seen %s...] @line:column'.
      */
     @Override
-    public String getPositionDescription()
-    {
+    public String getPositionDescription() {
         String fragment = null;
-        if ( posStart <= pos )
-        {
-            final int start = findFragment( 0, buf, posStart, pos );
+        if (posStart <= pos) {
+            final int start = findFragment(0, buf, posStart, pos);
             // System.err.println("start="+start);
-            if ( start < pos )
-            {
-                fragment = new String( buf, start, pos - start );
+            if (start < pos) {
+                fragment = new String(buf, start, pos - start);
             }
-            if ( bufAbsoluteStart > 0 || start > 0 )
-                fragment = "..." + fragment;
+            if (bufAbsoluteStart > 0 || start > 0) fragment = "..." + fragment;
         }
         // return " at line "+tokenizerPosRow
         // +" and column "+(tokenizerPosCol-1)
         // +(fragment != null ? " seen "+printable(fragment)+"..." : "");
-        return " " + TYPES[eventType] + ( fragment != null ? " seen " + printable( fragment ) + "..." : "" ) + " "
-            + ( location != null ? location : "" ) + "@" + getLineNumber() + ":" + getColumnNumber();
+        return " " + TYPES[eventType] + (fragment != null ? " seen " + printable(fragment) + "..." : "") + " "
+                + (location != null ? location : "") + "@" + getLineNumber() + ":" + getColumnNumber();
     }
 
     @Override
-    public int getLineNumber()
-    {
+    public int getLineNumber() {
         return lineNumber;
     }
 
     @Override
-    public int getColumnNumber()
-    {
+    public int getColumnNumber() {
         return columnNumber;
     }
 
     @Override
-    public boolean isWhitespace()
-        throws XmlPullParserException
-    {
-        if ( eventType == TEXT || eventType == CDSECT )
-        {
-            if ( usePC )
-            {
-                for ( int i = pcStart; i < pcEnd; i++ )
-                {
-                    if ( !isS( pc[i] ) )
-                        return false;
+    public boolean isWhitespace() throws XmlPullParserException {
+        if (eventType == TEXT || eventType == CDSECT) {
+            if (usePC) {
+                for (int i = pcStart; i < pcEnd; i++) {
+                    if (!isS(pc[i])) return false;
                 }
                 return true;
-            }
-            else
-            {
-                for ( int i = posStart; i < posEnd; i++ )
-                {
-                    if ( !isS( buf[i] ) )
-                        return false;
+            } else {
+                for (int i = posStart; i < posEnd; i++) {
+                    if (!isS(buf[i])) return false;
                 }
                 return true;
             }
-        }
-        else if ( eventType == IGNORABLE_WHITESPACE )
-        {
+        } else if (eventType == IGNORABLE_WHITESPACE) {
             return true;
         }
-        throw new XmlPullParserException( "no content available to check for whitespaces" );
+        throw new XmlPullParserException("no content available to check for whitespaces");
     }
 
     @Override
-    public String getText()
-    {
-        if ( eventType == START_DOCUMENT || eventType == END_DOCUMENT )
-        {
+    public String getText() {
+        if (eventType == START_DOCUMENT || eventType == END_DOCUMENT) {
             // throw new XmlPullParserException("no content available to read");
             // if(roundtripSupported) {
             // text = new String(buf, posStart, posEnd - posStart);
             // } else {
             return null;
             // }
-        }
-        else if ( eventType == ENTITY_REF )
-        {
+        } else if (eventType == ENTITY_REF) {
             return text;
         }
-        if ( text == null )
-        {
-            if ( !usePC || eventType == START_TAG || eventType == END_TAG )
-            {
-                text = new String( buf, posStart, posEnd - posStart );
-            }
-            else
-            {
-                text = new String( pc, pcStart, pcEnd - pcStart );
+        if (text == null) {
+            if (!usePC || eventType == START_TAG || eventType == END_TAG) {
+                text = new String(buf, posStart, posEnd - posStart);
+            } else {
+                text = new String(pc, pcStart, pcEnd - pcStart);
             }
         }
         return text;
     }
 
     @Override
-    public char[] getTextCharacters( int[] holderForStartAndLength )
-    {
-        if ( eventType == TEXT )
-        {
-            if ( usePC )
-            {
+    public char[] getTextCharacters(int[] holderForStartAndLength) {
+        if (eventType == TEXT) {
+            if (usePC) {
                 holderForStartAndLength[0] = pcStart;
                 holderForStartAndLength[1] = pcEnd - pcStart;
                 return pc;
-            }
-            else
-            {
+            } else {
                 holderForStartAndLength[0] = posStart;
                 holderForStartAndLength[1] = posEnd - posStart;
                 return buf;
-
             }
-        }
-        else if ( eventType == START_TAG || eventType == END_TAG || eventType == CDSECT || eventType == COMMENT
-            || eventType == ENTITY_REF || eventType == PROCESSING_INSTRUCTION || eventType == IGNORABLE_WHITESPACE
-            || eventType == DOCDECL )
-        {
+        } else if (eventType == START_TAG
+                || eventType == END_TAG
+                || eventType == CDSECT
+                || eventType == COMMENT
+                || eventType == ENTITY_REF
+                || eventType == PROCESSING_INSTRUCTION
+                || eventType == IGNORABLE_WHITESPACE
+                || eventType == DOCDECL) {
             holderForStartAndLength[0] = posStart;
             holderForStartAndLength[1] = posEnd - posStart;
             return buf;
-        }
-        else if ( eventType == START_DOCUMENT || eventType == END_DOCUMENT )
-        {
+        } else if (eventType == START_DOCUMENT || eventType == END_DOCUMENT) {
             // throw new XmlPullParserException("no content available to read");
             holderForStartAndLength[0] = holderForStartAndLength[1] = -1;
             return null;
-        }
-        else
-        {
-            throw new IllegalArgumentException( "unknown text eventType: " + eventType );
+        } else {
+            throw new IllegalArgumentException("unknown text eventType: " + eventType);
         }
         // String s = getText();
         // char[] cb = null;
@@ -1024,15 +848,11 @@ else if ( eventType == START_DOCUMENT || eventType == END_DOCUMENT )
     }
 
     @Override
-    public String getNamespace()
-    {
-        if ( eventType == START_TAG )
-        {
+    public String getNamespace() {
+        if (eventType == START_TAG) {
             // return processNamespaces ? elUri[ depth - 1 ] : NO_NAMESPACE;
             return processNamespaces ? elUri[depth] : NO_NAMESPACE;
-        }
-        else if ( eventType == END_TAG )
-        {
+        } else if (eventType == END_TAG) {
             return processNamespaces ? elUri[depth] : NO_NAMESPACE;
         }
         return null;
@@ -1055,41 +875,28 @@ else if ( eventType == END_TAG )
     }
 
     @Override
-    public String getName()
-    {
-        if ( eventType == START_TAG )
-        {
+    public String getName() {
+        if (eventType == START_TAG) {
             // return elName[ depth - 1 ] ;
             return elName[depth];
-        }
-        else if ( eventType == END_TAG )
-        {
+        } else if (eventType == END_TAG) {
             return elName[depth];
-        }
-        else if ( eventType == ENTITY_REF )
-        {
-            if ( entityRefName == null )
-            {
-                entityRefName = newString( buf, posStart, posEnd - posStart );
+        } else if (eventType == ENTITY_REF) {
+            if (entityRefName == null) {
+                entityRefName = newString(buf, posStart, posEnd - posStart);
             }
             return entityRefName;
-        }
-        else
-        {
+        } else {
             return null;
         }
     }
 
     @Override
-    public String getPrefix()
-    {
-        if ( eventType == START_TAG )
-        {
+    public String getPrefix() {
+        if (eventType == START_TAG) {
             // return elPrefix[ depth - 1 ] ;
             return elPrefix[depth];
-        }
-        else if ( eventType == END_TAG )
-        {
+        } else if (eventType == END_TAG) {
             return elPrefix[depth];
         }
         return null;
@@ -1099,132 +906,104 @@ else if ( eventType == END_TAG )
     }
 
     @Override
-    public boolean isEmptyElementTag()
-        throws XmlPullParserException
-    {
-        if ( eventType != START_TAG )
-            throw new XmlPullParserException( "parser must be on START_TAG to check for empty element", this, null );
+    public boolean isEmptyElementTag() throws XmlPullParserException {
+        if (eventType != START_TAG)
+            throw new XmlPullParserException("parser must be on START_TAG to check for empty element", this, null);
         return emptyElementTag;
     }
 
     @Override
-    public int getAttributeCount()
-    {
-        if ( eventType != START_TAG )
-            return -1;
+    public int getAttributeCount() {
+        if (eventType != START_TAG) return -1;
         return attributeCount;
     }
 
     @Override
-    public String getAttributeNamespace( int index )
-    {
-        if ( eventType != START_TAG )
-            throw new IndexOutOfBoundsException( "only START_TAG can have attributes" );
-        if ( !processNamespaces )
-            return NO_NAMESPACE;
-        if ( index < 0 || index >= attributeCount )
-            throw new IndexOutOfBoundsException( "attribute position must be 0.." + ( attributeCount - 1 ) + " and not "
-                + index );
+    public String getAttributeNamespace(int index) {
+        if (eventType != START_TAG) throw new IndexOutOfBoundsException("only START_TAG can have attributes");
+        if (!processNamespaces) return NO_NAMESPACE;
+        if (index < 0 || index >= attributeCount)
+            throw new IndexOutOfBoundsException(
+                    "attribute position must be 0.." + (attributeCount - 1) + " and not " + index);
         return attributeUri[index];
     }
 
     @Override
-    public String getAttributeName( int index )
-    {
-        if ( eventType != START_TAG )
-            throw new IndexOutOfBoundsException( "only START_TAG can have attributes" );
-        if ( index < 0 || index >= attributeCount )
-            throw new IndexOutOfBoundsException( "attribute position must be 0.." + ( attributeCount - 1 ) + " and not "
-                + index );
+    public String getAttributeName(int index) {
+        if (eventType != START_TAG) throw new IndexOutOfBoundsException("only START_TAG can have attributes");
+        if (index < 0 || index >= attributeCount)
+            throw new IndexOutOfBoundsException(
+                    "attribute position must be 0.." + (attributeCount - 1) + " and not " + index);
         return attributeName[index];
     }
 
     @Override
-    public String getAttributePrefix( int index )
-    {
-        if ( eventType != START_TAG )
-            throw new IndexOutOfBoundsException( "only START_TAG can have attributes" );
-        if ( !processNamespaces )
-            return null;
-        if ( index < 0 || index >= attributeCount )
-            throw new IndexOutOfBoundsException( "attribute position must be 0.." + ( attributeCount - 1 ) + " and not "
-                + index );
+    public String getAttributePrefix(int index) {
+        if (eventType != START_TAG) throw new IndexOutOfBoundsException("only START_TAG can have attributes");
+        if (!processNamespaces) return null;
+        if (index < 0 || index >= attributeCount)
+            throw new IndexOutOfBoundsException(
+                    "attribute position must be 0.." + (attributeCount - 1) + " and not " + index);
         return attributePrefix[index];
     }
 
     @Override
-    public String getAttributeType( int index )
-    {
-        if ( eventType != START_TAG )
-            throw new IndexOutOfBoundsException( "only START_TAG can have attributes" );
-        if ( index < 0 || index >= attributeCount )
-            throw new IndexOutOfBoundsException( "attribute position must be 0.." + ( attributeCount - 1 ) + " and not "
-                + index );
+    public String getAttributeType(int index) {
+        if (eventType != START_TAG) throw new IndexOutOfBoundsException("only START_TAG can have attributes");
+        if (index < 0 || index >= attributeCount)
+            throw new IndexOutOfBoundsException(
+                    "attribute position must be 0.." + (attributeCount - 1) + " and not " + index);
         return "CDATA";
     }
 
     @Override
-    public boolean isAttributeDefault( int index )
-    {
-        if ( eventType != START_TAG )
-            throw new IndexOutOfBoundsException( "only START_TAG can have attributes" );
-        if ( index < 0 || index >= attributeCount )
-            throw new IndexOutOfBoundsException( "attribute position must be 0.." + ( attributeCount - 1 ) + " and not "
-                + index );
+    public boolean isAttributeDefault(int index) {
+        if (eventType != START_TAG) throw new IndexOutOfBoundsException("only START_TAG can have attributes");
+        if (index < 0 || index >= attributeCount)
+            throw new IndexOutOfBoundsException(
+                    "attribute position must be 0.." + (attributeCount - 1) + " and not " + index);
         return false;
     }
 
     @Override
-    public String getAttributeValue( int index )
-    {
-        if ( eventType != START_TAG )
-            throw new IndexOutOfBoundsException( "only START_TAG can have attributes" );
-        if ( index < 0 || index >= attributeCount )
-            throw new IndexOutOfBoundsException( "attribute position must be 0.." + ( attributeCount - 1 ) + " and not "
-                + index );
+    public String getAttributeValue(int index) {
+        if (eventType != START_TAG) throw new IndexOutOfBoundsException("only START_TAG can have attributes");
+        if (index < 0 || index >= attributeCount)
+            throw new IndexOutOfBoundsException(
+                    "attribute position must be 0.." + (attributeCount - 1) + " and not " + index);
         return attributeValue[index];
     }
 
     @Override
-    public String getAttributeValue( String namespace, String name )
-    {
-        if ( eventType != START_TAG )
-            throw new IndexOutOfBoundsException( "only START_TAG can have attributes" + getPositionDescription() );
-        if ( name == null )
-        {
-            throw new IllegalArgumentException( "attribute name can not be null" );
+    public String getAttributeValue(String namespace, String name) {
+        if (eventType != START_TAG)
+            throw new IndexOutOfBoundsException("only START_TAG can have attributes" + getPositionDescription());
+        if (name == null) {
+            throw new IllegalArgumentException("attribute name can not be null");
         }
         // TODO make check if namespace is interned!!! etc. for names!!!
-        if ( processNamespaces )
-        {
-            if ( namespace == null )
-            {
+        if (processNamespaces) {
+            if (namespace == null) {
                 namespace = "";
             }
 
-            for ( int i = 0; i < attributeCount; ++i )
-            {
-                if ( ( namespace == attributeUri[i] || namespace.equals( attributeUri[i] ) )
-                    // (namespace != null && namespace.equals(attributeUri[ i ]))
-                    // taking advantage of String.intern()
-                    && name.equals( attributeName[i] ) )
-                {
+            for (int i = 0; i < attributeCount; ++i) {
+                if ((namespace == attributeUri[i] || namespace.equals(attributeUri[i]))
+                        // (namespace != null && namespace.equals(attributeUri[ i ]))
+                        // taking advantage of String.intern()
+                        && name.equals(attributeName[i])) {
                     return attributeValue[i];
                 }
             }
-        }
-        else
-        {
-            if ( namespace != null && namespace.length() == 0 )
-            {
+        } else {
+            if (namespace != null && namespace.length() == 0) {
                 namespace = null;
             }
-            if ( namespace != null )
-                throw new IllegalArgumentException( "when namespaces processing is disabled attribute namespace must be null" );
-            for ( int i = 0; i < attributeCount; ++i )
-            {
-                if ( name.equals( attributeName[i] ) )
-                {
+            if (namespace != null)
+                throw new IllegalArgumentException(
+                        "when namespaces processing is disabled attribute namespace must be null");
+            for (int i = 0; i < attributeCount; ++i) {
+                if (name.equals(attributeName[i])) {
                     return attributeValue[i];
                 }
             }
@@ -1233,37 +1012,38 @@ public String getAttributeValue( String namespace, String name )
     }
 
     @Override
-    public int getEventType()
-        throws XmlPullParserException
-    {
+    public int getEventType() throws XmlPullParserException {
         return eventType;
     }
 
     @Override
-    public void require( int type, String namespace, String name )
-        throws XmlPullParserException, IOException
-    {
-        if ( !processNamespaces && namespace != null )
-        {
-            throw new XmlPullParserException( "processing namespaces must be enabled on parser (or factory)"
-                + " to have possible namespaces declared on elements" + ( " (position:" + getPositionDescription() )
-                + ")" );
-        }
-        if ( type != getEventType() || ( namespace != null && !namespace.equals( getNamespace() ) )
-            || ( name != null && !name.equals( getName() ) ) )
-        {
-            throw new XmlPullParserException( "expected event " + TYPES[type]
-                + ( name != null ? " with name '" + name + "'" : "" )
-                + ( namespace != null && name != null ? " and" : "" )
-                + ( namespace != null ? " with namespace '" + namespace + "'" : "" ) + " but got"
-                + ( type != getEventType() ? " " + TYPES[getEventType()] : "" )
-                + ( name != null && getName() != null && !name.equals( getName() ) ? " name '" + getName() + "'" : "" )
-                + ( namespace != null && name != null && getName() != null && !name.equals( getName() )
-                    && getNamespace() != null && !namespace.equals( getNamespace() ) ? " and" : "" )
-                + ( namespace != null && getNamespace() != null && !namespace.equals( getNamespace() )
-                                ? " namespace '" + getNamespace() + "'"
-                                : "" )
-                + ( " (position:" + getPositionDescription() ) + ")" );
+    public void require(int type, String namespace, String name) throws XmlPullParserException, IOException {
+        if (!processNamespaces && namespace != null) {
+            throw new XmlPullParserException("processing namespaces must be enabled on parser (or factory)"
+                    + " to have possible namespaces declared on elements" + (" (position:" + getPositionDescription())
+                    + ")");
+        }
+        if (type != getEventType()
+                || (namespace != null && !namespace.equals(getNamespace()))
+                || (name != null && !name.equals(getName()))) {
+            throw new XmlPullParserException("expected event " + TYPES[type]
+                    + (name != null ? " with name '" + name + "'" : "")
+                    + (namespace != null && name != null ? " and" : "")
+                    + (namespace != null ? " with namespace '" + namespace + "'" : "") + " but got"
+                    + (type != getEventType() ? " " + TYPES[getEventType()] : "")
+                    + (name != null && getName() != null && !name.equals(getName()) ? " name '" + getName() + "'" : "")
+                    + (namespace != null
+                                    && name != null
+                                    && getName() != null
+                                    && !name.equals(getName())
+                                    && getNamespace() != null
+                                    && !namespace.equals(getNamespace())
+                            ? " and"
+                            : "")
+                    + (namespace != null && getNamespace() != null && !namespace.equals(getNamespace())
+                            ? " namespace '" + getNamespace() + "'"
+                            : "")
+                    + (" (position:" + getPositionDescription()) + ")");
         }
     }
 
@@ -1273,20 +1053,14 @@ && getNamespace() != null && !namespace.equals( getNamespace() ) ? " and" : "" )
      * @throws XmlPullParserException issue
      * @throws IOException io
      */
-    public void skipSubTree()
-        throws XmlPullParserException, IOException
-    {
-        require( START_TAG, null, null );
+    public void skipSubTree() throws XmlPullParserException, IOException {
+        require(START_TAG, null, null);
         int level = 1;
-        while ( level > 0 )
-        {
+        while (level > 0) {
             int eventType = next();
-            if ( eventType == END_TAG )
-            {
+            if (eventType == END_TAG) {
                 --level;
-            }
-            else if ( eventType == START_TAG )
-            {
+            } else if (eventType == START_TAG) {
                 ++level;
             }
         }
@@ -1301,9 +1075,7 @@ else if ( eventType == START_TAG )
     // }
 
     @Override
-    public String nextText()
-        throws XmlPullParserException, IOException
-    {
+    public String nextText() throws XmlPullParserException, IOException {
         // String result = null;
         // boolean onStartTag = false;
         // if(eventType == START_TAG) {
@@ -1324,96 +1096,73 @@ public String nextText()
         // "event TEXT it must be immediately followed by END_TAG", this, null);
         // }
         // return result;
-        if ( getEventType() != START_TAG )
-        {
-            throw new XmlPullParserException( "parser must be on START_TAG to read next text", this, null );
+        if (getEventType() != START_TAG) {
+            throw new XmlPullParserException("parser must be on START_TAG to read next text", this, null);
         }
         int eventType = next();
-        if ( eventType == TEXT )
-        {
+        if (eventType == TEXT) {
             final String result = getText();
             eventType = next();
-            if ( eventType != END_TAG )
-            {
-                throw new XmlPullParserException( "TEXT must be immediately followed by END_TAG and not "
-                    + TYPES[getEventType()], this, null );
+            if (eventType != END_TAG) {
+                throw new XmlPullParserException(
+                        "TEXT must be immediately followed by END_TAG and not " + TYPES[getEventType()], this, null);
             }
             return result;
-        }
-        else if ( eventType == END_TAG )
-        {
+        } else if (eventType == END_TAG) {
             return "";
-        }
-        else
-        {
-            throw new XmlPullParserException( "parser must be on START_TAG or TEXT to read text", this, null );
+        } else {
+            throw new XmlPullParserException("parser must be on START_TAG or TEXT to read text", this, null);
         }
     }
 
     @Override
-    public int nextTag()
-        throws XmlPullParserException, IOException
-    {
+    public int nextTag() throws XmlPullParserException, IOException {
         next();
-        if ( eventType == TEXT && isWhitespace() )
-        { // skip whitespace
+        if (eventType == TEXT && isWhitespace()) { // skip whitespace
             next();
         }
-        if ( eventType != START_TAG && eventType != END_TAG )
-        {
-            throw new XmlPullParserException( "expected START_TAG or END_TAG not " + TYPES[getEventType()], this,
-                                              null );
+        if (eventType != START_TAG && eventType != END_TAG) {
+            throw new XmlPullParserException("expected START_TAG or END_TAG not " + TYPES[getEventType()], this, null);
         }
         return eventType;
     }
 
     @Override
-    public int next()
-        throws XmlPullParserException, IOException
-    {
+    public int next() throws XmlPullParserException, IOException {
         tokenize = false;
         return nextImpl();
     }
 
     @Override
-    public int nextToken()
-        throws XmlPullParserException, IOException
-    {
+    public int nextToken() throws XmlPullParserException, IOException {
         tokenize = true;
         return nextImpl();
     }
 
-    private int nextImpl()
-        throws XmlPullParserException, IOException
-    {
+    private int nextImpl() throws XmlPullParserException, IOException {
         text = null;
         pcEnd = pcStart = 0;
         usePC = false;
         bufStart = posEnd;
-        if ( pastEndTag )
-        {
+        if (pastEndTag) {
             pastEndTag = false;
             --depth;
             namespaceEnd = elNamespaceCount[depth]; // less namespaces available
         }
-        if ( emptyElementTag )
-        {
+        if (emptyElementTag) {
             emptyElementTag = false;
             pastEndTag = true;
             return eventType = END_TAG;
         }
 
         // [1] document ::= prolog element Misc*
-        if ( depth > 0 )
-        {
+        if (depth > 0) {
 
-            if ( seenStartTag )
-            {
+            if (seenStartTag) {
                 seenStartTag = false;
                 return eventType = parseStartTag();
             }
-            if ( seenEndTag )
-            {
+            if (seenEndTag) {
                 seenEndTag = false;
                 return eventType = parseEndTag();
             }
@@ -1421,18 +1170,13 @@ private int nextImpl()
             // ASSUMPTION: we are _on_ first character of content or markup!!!!
             // [43] content ::= CharData? ((element | Reference | CDSect | PI | Comment) CharData?)*
             char ch;
-            if ( seenMarkup )
-            { // we have read ahead ...
+            if (seenMarkup) { // we have read ahead ...
                 seenMarkup = false;
                 ch = '<';
-            }
-            else if ( seenAmpersand )
-            {
+            } else if (seenAmpersand) {
                 seenAmpersand = false;
                 ch = '&';
-            }
-            else
-            {
+            } else {
                 ch = more();
             }
             posStart = pos - 1; // VERY IMPORTANT: this is correct start of event!!!
@@ -1443,67 +1187,50 @@ else if ( seenAmpersand )
             // when true TEXT data is not continuous (like ) and requires PC merging
             boolean needsMerging = false;
 
-            MAIN_LOOP: while ( true )
-            {
+            MAIN_LOOP:
+            while (true) {
                 // work on MARKUP
-                if ( ch == '<' )
-                {
-                    if ( hadCharData )
-                    {
+                if (ch == '<') {
+                    if (hadCharData) {
                         // posEnd = pos - 1;
-                        if ( tokenize )
-                        {
+                        if (tokenize) {
                             seenMarkup = true;
                             return eventType = TEXT;
                         }
                     }
                     ch = more();
-                    if ( ch == '/' )
-                    {
-                        if ( !tokenize && hadCharData )
-                        {
+                    if (ch == '/') {
+                        if (!tokenize && hadCharData) {
                             seenEndTag = true;
                             // posEnd = pos - 2;
                             return eventType = TEXT;
                         }
                         return eventType = parseEndTag();
-                    }
-                    else if ( ch == '!' )
-                    {
+                    } else if (ch == '!') {
                         ch = more();
-                        if ( ch == '-' )
-                        {
+                        if (ch == '-') {
                             // note: if(tokenize == false) posStart/End is NOT changed!!!!
                             parseComment();
-                            if ( tokenize )
-                                return eventType = COMMENT;
-                            if ( !usePC && hadCharData )
-                            {
+                            if (tokenize) return eventType = COMMENT;
+                            if (!usePC && hadCharData) {
                                 needsMerging = true;
-                            }
-                            else
-                            {
+                            } else {
                                 posStart = pos; // completely ignore comment
                             }
-                        }
-                        else if ( ch == '[' )
-                        {
+                        } else if (ch == '[') {
                             // posEnd = pos - 3;
                             // must remember previous posStart/End as it merges with content of CDATA
                             // int oldStart = posStart + bufAbsoluteStart;
                             // int oldEnd = posEnd + bufAbsoluteStart;
-                            parseCDSect( hadCharData );
-                            if ( tokenize )
-                                return eventType = CDSECT;
+                            parseCDSect(hadCharData);
+                            if (tokenize) return eventType = CDSECT;
                             final int cdStart = posStart;
                             final int cdEnd = posEnd;
                             final int cdLen = cdEnd - cdStart;
 
-                            if ( cdLen > 0 )
-                            { // was there anything inside CDATA section?
+                            if (cdLen > 0) { // was there anything inside CDATA section?
                                 hadCharData = true;
-                                if ( !usePC )
-                                {
+                                if (!usePC) {
                                     needsMerging = true;
                                 }
                             }
@@ -1545,106 +1272,76 @@ else if ( ch == '[' )
                             // needsMerging = true;
                             // }
                             // }
+                        } else {
+                            throw new XmlPullParserException(
+                                    "unexpected character in markup " + printable(ch), this, null);
                         }
-                        else
-                        {
-                            throw new XmlPullParserException( "unexpected character in markup " + printable( ch ), this,
-                                                              null );
-                        }
-                    }
-                    else if ( ch == '?' )
-                    {
+                    } else if (ch == '?') {
                         parsePI();
-                        if ( tokenize )
-                            return eventType = PROCESSING_INSTRUCTION;
-                        if ( !usePC && hadCharData )
-                        {
+                        if (tokenize) return eventType = PROCESSING_INSTRUCTION;
+                        if (!usePC && hadCharData) {
                             needsMerging = true;
-                        }
-                        else
-                        {
+                        } else {
                             posStart = pos; // completely ignore PI
                         }
 
-                    }
-                    else if ( isNameStartChar( ch ) )
-                    {
-                        if ( !tokenize && hadCharData )
-                        {
+                    } else if (isNameStartChar(ch)) {
+                        if (!tokenize && hadCharData) {
                             seenStartTag = true;
                             // posEnd = pos - 2;
                             return eventType = TEXT;
                         }
                         return eventType = parseStartTag();
-                    }
-                    else
-                    {
-                        throw new XmlPullParserException( "unexpected character in markup " + printable( ch ), this,
-                                                          null );
+                    } else {
+                        throw new XmlPullParserException("unexpected character in markup " + printable(ch), this, null);
                     }
                     // do content compaction if it makes sense!!!!
 
-                }
-                else if ( ch == '&' )
-                {
+                } else if (ch == '&') {
                     // work on ENTITY
                     // posEnd = pos - 1;
-                    if ( tokenize && hadCharData )
-                    {
+                    if (tokenize && hadCharData) {
                         seenAmpersand = true;
                         return eventType = TEXT;
                     }
                     final int oldStart = posStart + bufAbsoluteStart;
                     final int oldEnd = posEnd + bufAbsoluteStart;
                     parseEntityRef();
-                    if ( tokenize )
-                        return eventType = ENTITY_REF;
+                    if (tokenize) return eventType = ENTITY_REF;
                     // check if replacement text can be resolved !!!
-                    if ( resolvedEntityRefCharBuf == BUF_NOT_RESOLVED )
-                    {
-                        if ( entityRefName == null )
-                        {
-                            entityRefName = newString( buf, posStart, posEnd - posStart );
+                    if (resolvedEntityRefCharBuf == BUF_NOT_RESOLVED) {
+                        if (entityRefName == null) {
+                            entityRefName = newString(buf, posStart, posEnd - posStart);
                         }
-                        throw new XmlPullParserException( "could not resolve entity named '"
-                            + printable( entityRefName ) + "'", this, null );
+                        throw new XmlPullParserException(
+                                "could not resolve entity named '" + printable(entityRefName) + "'", this, null);
                     }
                     // int entStart = posStart;
                     // int entEnd = posEnd;
                     posStart = oldStart - bufAbsoluteStart;
                     posEnd = oldEnd - bufAbsoluteStart;
-                    if ( !usePC )
-                    {
-                        if ( hadCharData )
-                        {
+                    if (!usePC) {
+                        if (hadCharData) {
                             joinPC(); // posEnd is already set correctly!!!
                             needsMerging = false;
-                        }
-                        else
-                        {
+                        } else {
                             usePC = true;
                             pcStart = pcEnd = 0;
                         }
                     }
                     // assert usePC == true;
                     // write into PC replacement text - do merge for replacement text!!!!
-                    for ( char aResolvedEntity : resolvedEntityRefCharBuf )
-                    {
-                        if ( pcEnd >= pc.length )
-                        {
-                            ensurePC( pcEnd );
+                    for (char aResolvedEntity : resolvedEntityRefCharBuf) {
+                        if (pcEnd >= pc.length) {
+                            ensurePC(pcEnd);
                         }
                         pc[pcEnd++] = aResolvedEntity;
-
                     }
                     hadCharData = true;
                     // assert needsMerging == false;
-                }
-                else
-                {
+                } else {
 
-                    if ( needsMerging )
-                    {
+                    if (needsMerging) {
                         // assert usePC == false;
                         joinPC(); // posEnd is already set correctly!!!
                         // posStart = pos - 1;
@@ -1662,75 +1359,50 @@ else if ( ch == '&' )
                     // use loop locality here!!!!
                     boolean seenBracket = false;
                     boolean seenBracketBracket = false;
-                    do
-                    {
+                    do {
 
                         // check that ]]> does not show in
-                        if ( ch == ']' )
-                        {
-                            if ( seenBracket )
-                            {
+                        if (ch == ']') {
+                            if (seenBracket) {
                                 seenBracketBracket = true;
-                            }
-                            else
-                            {
+                            } else {
                                 seenBracket = true;
                             }
-                        }
-                        else if ( seenBracketBracket && ch == '>' )
-                        {
-                            throw new XmlPullParserException( "characters ]]> are not allowed in content", this, null );
-                        }
-                        else
-                        {
-                            if ( seenBracket )
-                            {
+                        } else if (seenBracketBracket && ch == '>') {
+                            throw new XmlPullParserException("characters ]]> are not allowed in content", this, null);
+                        } else {
+                            if (seenBracket) {
                                 seenBracketBracket = seenBracket = false;
                             }
                             // assert seenTwoBrackets == seenBracket == false;
                         }
-                        if ( normalizeInput )
-                        {
+                        if (normalizeInput) {
                             // deal with normalization issues ...
-                            if ( ch == '\r' )
-                            {
+                            if (ch == '\r') {
                                 normalizedCR = true;
                                 posEnd = pos - 1;
                                 // posEnd is already set
-                                if ( !usePC )
-                                {
-                                    if ( posEnd > posStart )
-                                    {
+                                if (!usePC) {
+                                    if (posEnd > posStart) {
                                         joinPC();
-                                    }
-                                    else
-                                    {
+                                    } else {
                                         usePC = true;
                                         pcStart = pcEnd = 0;
                                     }
                                 }
                                 // assert usePC == true;
-                                if ( pcEnd >= pc.length )
-                                    ensurePC( pcEnd );
+                                if (pcEnd >= pc.length) ensurePC(pcEnd);
                                 pc[pcEnd++] = '\n';
-                            }
-                            else if ( ch == '\n' )
-                            {
+                            } else if (ch == '\n') {
                                 // if(!usePC) { joinPC(); } else { if(pcEnd >= pc.length) ensurePC(); }
-                                if ( !normalizedCR && usePC )
-                                {
-                                    if ( pcEnd >= pc.length )
-                                        ensurePC( pcEnd );
+                                if (!normalizedCR && usePC) {
+                                    if (pcEnd >= pc.length) ensurePC(pcEnd);
                                     pc[pcEnd++] = '\n';
                                 }
                                 normalizedCR = false;
-                            }
-                            else
-                            {
-                                if ( usePC )
-                                {
-                                    if ( pcEnd >= pc.length )
-                                        ensurePC( pcEnd );
+                            } else {
+                                if (usePC) {
+                                    if (pcEnd >= pc.length) ensurePC(pcEnd);
                                     pc[pcEnd++] = ch;
                                 }
                                 normalizedCR = false;
@@ -1738,66 +1410,50 @@ else if ( ch == '\n' )
                         }
 
                         ch = more();
-                    }
-                    while ( ch != '<' && ch != '&' );
+                    } while (ch != '<' && ch != '&');
                     posEnd = pos - 1;
                     continue MAIN_LOOP; // skip ch = more() from below - we are already ahead ...
                 }
                 ch = more();
             } // endless while(true)
-        }
-        else
-        {
-            if ( seenRoot )
-            {
+        } else {
+            if (seenRoot) {
                 return parseEpilog();
-            }
-            else
-            {
+            } else {
                 return parseProlog();
             }
         }
     }
 
-    private int parseProlog()
-        throws XmlPullParserException, IOException
-    {
+    private int parseProlog() throws XmlPullParserException, IOException {
         // [2] prolog: ::= XMLDecl? Misc* (doctypedecl Misc*)? and look for [39] element
 
         char ch;
-        if ( seenMarkup )
-        {
+        if (seenMarkup) {
             ch = buf[pos - 1];
-        }
-        else
-        {
+        } else {
             ch = more();
         }
 
-        if ( eventType == START_DOCUMENT )
-        {
+        if (eventType == START_DOCUMENT) {
             // bootstrap parsing with getting first character input!
             // deal with BOM
             // detect BOM and crop it (Unicode int Order Mark)
-            if ( ch == '\uFFFE' )
-            {
-                throw new XmlPullParserException( "first character in input was UNICODE noncharacter (0xFFFE)"
-                    + "- input requires int swapping", this, null );
+            if (ch == '\uFFFE') {
+                throw new XmlPullParserException(
+                        "first character in input was UNICODE noncharacter (0xFFFE)" + "- input requires int swapping",
+                        this,
+                        null);
             }
-            if ( ch == '\uFEFF' )
-            {
+            if (ch == '\uFEFF') {
                 // skipping UNICODE int Order Mark (so called BOM)
                 ch = more();
-            }
-            else if ( ch == '\uFFFD' )
-            {
+            } else if (ch == '\uFFFD') {
                 // UTF-16 BOM in an UTF-8 encoded file?
                 // This is a hack...not the best way to check for BOM in UTF-16
                 ch = more();
-                if ( ch == '\uFFFD' )
-                {
-                    throw new XmlPullParserException( "UTF-16 BOM in a UTF-8 encoded file is incompatible", this,
-                                                      null );
+                if (ch == '\uFFFD') {
+                    throw new XmlPullParserException("UTF-16 BOM in a UTF-8 encoded file is incompatible", this, null);
                 }
             }
         }
@@ -1806,331 +1462,227 @@ else if ( ch == '\uFFFD' )
         posStart = pos - 1;
         final boolean normalizeIgnorableWS = tokenize && !roundtripSupported;
         boolean normalizedCR = false;
-        while ( true )
-        {
+        while (true) {
             // deal with Misc
             // [27] Misc ::= Comment | PI | S
             // deal with docdecl --> mark it!
             // else parseStartTag seen <[^/]
-            if ( ch == '<' )
-            {
-                if ( gotS && tokenize )
-                {
+            if (ch == '<') {
+                if (gotS && tokenize) {
                     posEnd = pos - 1;
                     seenMarkup = true;
                     return eventType = IGNORABLE_WHITESPACE;
                 }
                 ch = more();
-                if ( ch == '?' )
-                {
+                if (ch == '?') {
                     // check if it is 'xml'
                     // deal with XMLDecl
                     boolean isXMLDecl = parsePI();
-                    if ( tokenize )
-                    {
-                        if ( isXMLDecl )
-                        {
+                    if (tokenize) {
+                        if (isXMLDecl) {
                             return eventType = START_DOCUMENT;
                         }
                         return eventType = PROCESSING_INSTRUCTION;
                     }
-                }
-                else if ( ch == '!' )
-                {
+                } else if (ch == '!') {
                     ch = more();
-                    if ( ch == 'D' )
-                    {
-                        if ( seenDocdecl )
-                        {
-                            throw new XmlPullParserException( "only one docdecl allowed in XML document", this, null );
+                    if (ch == 'D') {
+                        if (seenDocdecl) {
+                            throw new XmlPullParserException("only one docdecl allowed in XML document", this, null);
                         }
                         seenDocdecl = true;
                         parseDocdecl();
-                        if ( tokenize )
-                            return eventType = DOCDECL;
-                    }
-                    else if ( ch == '-' )
-                    {
+                        if (tokenize) return eventType = DOCDECL;
+                    } else if (ch == '-') {
                         parseComment();
-                        if ( tokenize )
-                            return eventType = COMMENT;
-                    }
-                    else
-                    {
-                        throw new XmlPullParserException( "unexpected markup  posStart )
-                            {
+                            if (posEnd > posStart) {
                                 joinPC();
-                            }
-                            else
-                            {
+                            } else {
                                 usePC = true;
                                 pcStart = pcEnd = 0;
                             }
                         }
                         // assert usePC == true;
-                        if ( pcEnd >= pc.length )
-                            ensurePC( pcEnd );
+                        if (pcEnd >= pc.length) ensurePC(pcEnd);
                         pc[pcEnd++] = '\n';
-                    }
-                    else if ( ch == '\n' )
-                    {
-                        if ( !normalizedCR && usePC )
-                        {
-                            if ( pcEnd >= pc.length )
-                                ensurePC( pcEnd );
+                    } else if (ch == '\n') {
+                        if (!normalizedCR && usePC) {
+                            if (pcEnd >= pc.length) ensurePC(pcEnd);
                             pc[pcEnd++] = '\n';
                         }
                         normalizedCR = false;
-                    }
-                    else
-                    {
-                        if ( usePC )
-                        {
-                            if ( pcEnd >= pc.length )
-                                ensurePC( pcEnd );
+                    } else {
+                        if (usePC) {
+                            if (pcEnd >= pc.length) ensurePC(pcEnd);
                             pc[pcEnd++] = ch;
                         }
                         normalizedCR = false;
                     }
                 }
-            }
-            else
-            {
-                throw new XmlPullParserException( "only whitespace content allowed before start tag and not "
-                    + printable( ch ), this, null );
+            } else {
+                throw new XmlPullParserException(
+                        "only whitespace content allowed before start tag and not " + printable(ch), this, null);
             }
             ch = more();
         }
     }
 
-    private int parseEpilog()
-        throws XmlPullParserException, IOException
-    {
-        if ( eventType == END_DOCUMENT )
-        {
-            throw new XmlPullParserException( "already reached end of XML input", this, null );
+    private int parseEpilog() throws XmlPullParserException, IOException {
+        if (eventType == END_DOCUMENT) {
+            throw new XmlPullParserException("already reached end of XML input", this, null);
         }
-        if ( reachedEnd )
-        {
+        if (reachedEnd) {
             return eventType = END_DOCUMENT;
         }
         boolean gotS = false;
         final boolean normalizeIgnorableWS = tokenize && !roundtripSupported;
         boolean normalizedCR = false;
-        try
-        {
+        try {
             // epilog: Misc*
             char ch;
-            if ( seenMarkup )
-            {
+            if (seenMarkup) {
                 ch = buf[pos - 1];
-            }
-            else
-            {
+            } else {
                 ch = more();
             }
             seenMarkup = false;
             posStart = pos - 1;
-            if ( !reachedEnd )
-            {
-                while ( true )
-                {
+            if (!reachedEnd) {
+                while (true) {
                     // deal with Misc
                     // [27] Misc ::= Comment | PI | S
-                    if ( ch == '<' )
-                    {
-                        if ( gotS && tokenize )
-                        {
+                    if (ch == '<') {
+                        if (gotS && tokenize) {
                             posEnd = pos - 1;
                             seenMarkup = true;
                             return eventType = IGNORABLE_WHITESPACE;
                         }
                         ch = more();
-                        if ( reachedEnd )
-                        {
+                        if (reachedEnd) {
                             break;
                         }
-                        if ( ch == '?' )
-                        {
+                        if (ch == '?') {
                             // check if it is 'xml'
                             // deal with XMLDecl
                             parsePI();
-                            if ( tokenize )
-                                return eventType = PROCESSING_INSTRUCTION;
+                            if (tokenize) return eventType = PROCESSING_INSTRUCTION;
 
-                        }
-                        else if ( ch == '!' )
-                        {
+                        } else if (ch == '!') {
                             ch = more();
-                            if ( reachedEnd )
-                            {
+                            if (reachedEnd) {
                                 break;
                             }
-                            if ( ch == 'D' )
-                            {
+                            if (ch == 'D') {
                                 parseDocdecl(); // FIXME
-                                if ( tokenize )
-                                    return eventType = DOCDECL;
-                            }
-                            else if ( ch == '-' )
-                            {
+                                if (tokenize) return eventType = DOCDECL;
+                            } else if (ch == '-') {
                                 parseComment();
-                                if ( tokenize )
-                                    return eventType = COMMENT;
+                                if (tokenize) return eventType = COMMENT;
+                            } else {
+                                throw new XmlPullParserException("unexpected markup  posStart )
-                                    {
+                                    if (posEnd > posStart) {
                                         joinPC();
-                                    }
-                                    else
-                                    {
+                                    } else {
                                         usePC = true;
                                         pcStart = pcEnd = 0;
                                     }
                                 }
                                 // assert usePC == true;
-                                if ( pcEnd >= pc.length )
-                                    ensurePC( pcEnd );
+                                if (pcEnd >= pc.length) ensurePC(pcEnd);
                                 pc[pcEnd++] = '\n';
-                            }
-                            else if ( ch == '\n' )
-                            {
-                                if ( !normalizedCR && usePC )
-                                {
-                                    if ( pcEnd >= pc.length )
-                                        ensurePC( pcEnd );
+                            } else if (ch == '\n') {
+                                if (!normalizedCR && usePC) {
+                                    if (pcEnd >= pc.length) ensurePC(pcEnd);
                                     pc[pcEnd++] = '\n';
                                 }
                                 normalizedCR = false;
-                            }
-                            else
-                            {
-                                if ( usePC )
-                                {
-                                    if ( pcEnd >= pc.length )
-                                        ensurePC( pcEnd );
+                            } else {
+                                if (usePC) {
+                                    if (pcEnd >= pc.length) ensurePC(pcEnd);
                                     pc[pcEnd++] = ch;
                                 }
                                 normalizedCR = false;
                             }
                         }
-                    }
-                    else
-                    {
-                        throw new XmlPullParserException( "in epilog non whitespace content is not allowed but got "
-                            + printable( ch ), this, null );
+                    } else {
+                        throw new XmlPullParserException(
+                                "in epilog non whitespace content is not allowed but got " + printable(ch), this, null);
                     }
                     ch = more();
-                    if ( reachedEnd )
-                    {
+                    if (reachedEnd) {
                         break;
                     }
-
                 }
             }
 
             // throw Exception("unexpected content in epilog
             // catch EOFException return END_DOCUMENT
             // try {
-        }
-        catch ( EOFException ex )
-        {
+        } catch (EOFException ex) {
             reachedEnd = true;
         }
-        if ( tokenize && gotS )
-        {
+        if (tokenize && gotS) {
             posEnd = pos; // well - this is LAST available character pos
             return eventType = IGNORABLE_WHITESPACE;
         }
         return eventType = END_DOCUMENT;
     }
 
-    public int parseEndTag()
-        throws XmlPullParserException, IOException
-    {
+    public int parseEndTag() throws XmlPullParserException, IOException {
         // ASSUMPTION ch is past "'
         char ch = more();
-        if ( !isNameStartChar( ch ) )
-        {
-            throw new XmlPullParserException( "expected name start and not " + printable( ch ), this, null );
+        if (!isNameStartChar(ch)) {
+            throw new XmlPullParserException("expected name start and not " + printable(ch), this, null);
         }
         posStart = pos - 3;
         final int nameStart = pos - 1 + bufAbsoluteStart;
-        do
-        {
+        do {
             ch = more();
-        }
-        while ( isNameChar( ch ) );
+        } while (isNameChar(ch));
 
         // now we go one level down -- do checks
         // --depth; //FIXME
@@ -2141,36 +1693,39 @@ public int parseEndTag()
         // int last = pos - 1;
         int off = nameStart - bufAbsoluteStart;
         // final int len = last - off;
-        final int len = ( pos - 1 ) - off;
+        final int len = (pos - 1) - off;
         final char[] cbuf = elRawName[depth];
-        if ( elRawNameEnd[depth] != len )
-        {
+        if (elRawNameEnd[depth] != len) {
             // construct strings for exception
-            final String startname = new String( cbuf, 0, elRawNameEnd[depth] );
-            final String endname = new String( buf, off, len );
-            throw new XmlPullParserException( "end tag name  must match start tag name <" + startname
-                + ">" + " from line " + elRawNameLine[depth], this, null );
-        }
-        for ( int i = 0; i < len; i++ )
-        {
-            if ( buf[off++] != cbuf[i] )
-            {
+            final String startname = new String(cbuf, 0, elRawNameEnd[depth]);
+            final String endname = new String(buf, off, len);
+            throw new XmlPullParserException(
+                    "end tag name  must match start tag name <" + startname + ">" + " from line "
+                            + elRawNameLine[depth],
+                    this,
+                    null);
+        }
+        for (int i = 0; i < len; i++) {
+            if (buf[off++] != cbuf[i]) {
                 // construct strings for exception
-                final String startname = new String( cbuf, 0, len );
-                final String endname = new String( buf, off - i - 1, len );
-                throw new XmlPullParserException( "end tag name  must be the same as start tag <"
-                    + startname + ">" + " from line " + elRawNameLine[depth], this, null );
+                final String startname = new String(cbuf, 0, len);
+                final String endname = new String(buf, off - i - 1, len);
+                throw new XmlPullParserException(
+                        "end tag name  must be the same as start tag <" + startname + ">"
+                                + " from line " + elRawNameLine[depth],
+                        this,
+                        null);
             }
         }
 
-        while ( isS( ch ) )
-        {
+        while (isS(ch)) {
             ch = more();
         } // skip additional white spaces
-        if ( ch != '>' )
-        {
-            throw new XmlPullParserException( "expected > to finsh end tag not " + printable( ch ) + " from line "
-                + elRawNameLine[depth], this, null );
+        if (ch != '>') {
+            throw new XmlPullParserException(
+                    "expected > to finsh end tag not " + printable(ch) + " from line " + elRawNameLine[depth],
+                    this,
+                    null);
         }
 
         // namespaceEnd = elNamespaceCount[ depth ]; //FIXME
@@ -2180,9 +1735,7 @@ public int parseEndTag()
         return eventType = END_TAG;
     }
 
-    public int parseStartTag()
-        throws XmlPullParserException, IOException
-    {
+    public int parseStartTag() throws XmlPullParserException, IOException {
         // ASSUMPTION ch is past '
         // [44] EmptyElemTag ::= '<' Name (S Attribute)* S? '/>'
@@ -2196,19 +1749,16 @@ public int parseStartTag()
         final int nameStart = pos - 1 + bufAbsoluteStart;
         int colonPos = -1;
         char ch = buf[pos - 1];
-        if ( ch == ':' && processNamespaces )
-            throw new XmlPullParserException( "when namespaces processing enabled colon can not be at element name start",
-                                              this, null );
-        while ( true )
-        {
+        if (ch == ':' && processNamespaces)
+            throw new XmlPullParserException(
+                    "when namespaces processing enabled colon can not be at element name start", this, null);
+        while (true) {
             ch = more();
-            if ( !isNameChar( ch ) )
-                break;
-            if ( ch == ':' && processNamespaces )
-            {
-                if ( colonPos != -1 )
-                    throw new XmlPullParserException( "only one colon is allowed in name of element when namespaces are enabled",
-                                                      this, null );
+            if (!isNameChar(ch)) break;
+            if (ch == ':' && processNamespaces) {
+                if (colonPos != -1)
+                    throw new XmlPullParserException(
+                            "only one colon is allowed in name of element when namespaces are enabled", this, null);
                 colonPos = pos - 1 + bufAbsoluteStart;
             }
         }
@@ -2218,12 +1768,11 @@ public int parseStartTag()
 
         // TODO check for efficient interning and then use elRawNameInterned!!!!
 
-        int elLen = ( pos - 1 ) - ( nameStart - bufAbsoluteStart );
-        if ( elRawName[depth] == null || elRawName[depth].length < elLen )
-        {
+        int elLen = (pos - 1) - (nameStart - bufAbsoluteStart);
+        if (elRawName[depth] == null || elRawName[depth].length < elLen) {
             elRawName[depth] = new char[2 * elLen];
         }
-        System.arraycopy( buf, nameStart - bufAbsoluteStart, elRawName[depth], 0, elLen );
+        System.arraycopy(buf, nameStart - bufAbsoluteStart, elRawName[depth], 0, elLen);
         elRawNameEnd[depth] = elLen;
         elRawNameLine[depth] = lineNumber;
 
@@ -2231,79 +1780,57 @@ public int parseStartTag()
 
         // work on prefixes and namespace URI
         String prefix = null;
-        if ( processNamespaces )
-        {
-            if ( colonPos != -1 )
-            {
-                prefix = elPrefix[depth] = newString( buf, nameStart - bufAbsoluteStart, colonPos - nameStart );
-                name = elName[depth] = newString( buf, colonPos + 1 - bufAbsoluteStart,
-                                                  // (pos -1) - (colonPos + 1));
-                                                  pos - 2 - ( colonPos - bufAbsoluteStart ) );
-            }
-            else
-            {
+        if (processNamespaces) {
+            if (colonPos != -1) {
+                prefix = elPrefix[depth] = newString(buf, nameStart - bufAbsoluteStart, colonPos - nameStart);
+                name = elName[depth] = newString(
+                        buf,
+                        colonPos + 1 - bufAbsoluteStart,
+                        // (pos -1) - (colonPos + 1));
+                        pos - 2 - (colonPos - bufAbsoluteStart));
+            } else {
                 prefix = elPrefix[depth] = null;
-                name = elName[depth] = newString( buf, nameStart - bufAbsoluteStart, elLen );
+                name = elName[depth] = newString(buf, nameStart - bufAbsoluteStart, elLen);
             }
-        }
-        else
-        {
-
-            name = elName[depth] = newString( buf, nameStart - bufAbsoluteStart, elLen );
+        } else {
 
+            name = elName[depth] = newString(buf, nameStart - bufAbsoluteStart, elLen);
         }
 
-        while ( true )
-        {
+        while (true) {
 
-            while ( isS( ch ) )
-            {
+            while (isS(ch)) {
                 ch = more();
             } // skip additional white spaces
 
-            if ( ch == '>' )
-            {
+            if (ch == '>') {
                 break;
-            }
-            else if ( ch == '/' )
-            {
-                if ( emptyElementTag )
-                    throw new XmlPullParserException( "repeated / in tag declaration", this, null );
+            } else if (ch == '/') {
+                if (emptyElementTag) throw new XmlPullParserException("repeated / in tag declaration", this, null);
                 emptyElementTag = true;
                 ch = more();
-                if ( ch != '>' )
-                    throw new XmlPullParserException( "expected > to end empty tag not " + printable( ch ), this,
-                                                      null );
+                if (ch != '>')
+                    throw new XmlPullParserException("expected > to end empty tag not " + printable(ch), this, null);
                 break;
-            }
-            else if ( isNameStartChar( ch ) )
-            {
+            } else if (isNameStartChar(ch)) {
                 ch = parseAttribute();
                 ch = more();
-            }
-            else
-            {
-                throw new XmlPullParserException( "start tag unexpected character " + printable( ch ), this, null );
+            } else {
+                throw new XmlPullParserException("start tag unexpected character " + printable(ch), this, null);
             }
             // ch = more(); // skip space
         }
 
         // now when namespaces were declared we can resolve them
-        if ( processNamespaces )
-        {
-            String uri = getNamespace( prefix );
-            if ( uri == null )
-            {
-                if ( prefix == null )
-                { // no prefix and no uri => use default namespace
+        if (processNamespaces) {
+            String uri = getNamespace(prefix);
+            if (uri == null) {
+                if (prefix == null) { // no prefix and no uri => use default namespace
                     uri = NO_NAMESPACE;
+                } else {
+                    throw new XmlPullParserException(
+                            "could not determine namespace bound to element prefix " + prefix, this, null);
                 }
-                else
-                {
-                    throw new XmlPullParserException( "could not determine namespace bound to element prefix " + prefix,
-                                                      this, null );
-                }
-
             }
             elUri[depth] = uri;
 
@@ -2312,22 +1839,16 @@ else if ( isNameStartChar( ch ) )
             // uri = "";
             // }
             // resolve attribute namespaces
-            for ( int i = 0; i < attributeCount; i++ )
-            {
+            for (int i = 0; i < attributeCount; i++) {
                 final String attrPrefix = attributePrefix[i];
-                if ( attrPrefix != null )
-                {
-                    final String attrUri = getNamespace( attrPrefix );
-                    if ( attrUri == null )
-                    {
-                        throw new XmlPullParserException( "could not determine namespace bound to attribute prefix "
-                            + attrPrefix, this, null );
-
+                if (attrPrefix != null) {
+                    final String attrUri = getNamespace(attrPrefix);
+                    if (attrUri == null) {
+                        throw new XmlPullParserException(
+                                "could not determine namespace bound to attribute prefix " + attrPrefix, this, null);
                     }
                     attributeUri[i] = attrUri;
-                }
-                else
-                {
+                } else {
                     attributeUri[i] = NO_NAMESPACE;
                 }
             }
@@ -2336,51 +1857,41 @@ else if ( isNameStartChar( ch ) )
             // [ WFC: Unique Att Spec ]
             // check namespaced attribute uniqueness constraint!!!
 
-            for ( int i = 1; i < attributeCount; i++ )
-            {
-                for ( int j = 0; j < i; j++ )
-                {
-                    if ( attributeUri[j] == attributeUri[i]
-                        && ( allStringsInterned && attributeName[j].equals( attributeName[i] )
-                            || ( !allStringsInterned && attributeNameHash[j] == attributeNameHash[i]
-                                && attributeName[j].equals( attributeName[i] ) ) )
-
-                    )
-                    {
+            for (int i = 1; i < attributeCount; i++) {
+                for (int j = 0; j < i; j++) {
+                    if (attributeUri[j] == attributeUri[i]
+                            && (allStringsInterned && attributeName[j].equals(attributeName[i])
+                                    || (!allStringsInterned
+                                            && attributeNameHash[j] == attributeNameHash[i]
+                                            && attributeName[j].equals(attributeName[i])))) {
+
                         // prepare data for nice error message?
                         String attr1 = attributeName[j];
-                        if ( attributeUri[j] != null )
-                            attr1 = attributeUri[j] + ":" + attr1;
+                        if (attributeUri[j] != null) attr1 = attributeUri[j] + ":" + attr1;
                         String attr2 = attributeName[i];
-                        if ( attributeUri[i] != null )
-                            attr2 = attributeUri[i] + ":" + attr2;
-                        throw new XmlPullParserException( "duplicated attributes " + attr1 + " and " + attr2, this,
-                                                          null );
+                        if (attributeUri[i] != null) attr2 = attributeUri[i] + ":" + attr2;
+                        throw new XmlPullParserException(
+                                "duplicated attributes " + attr1 + " and " + attr2, this, null);
                     }
                 }
             }
 
-        }
-        else
-        { // ! processNamespaces
+        } else { // ! processNamespaces
 
             // [ WFC: Unique Att Spec ]
             // check raw attribute uniqueness constraint!!!
-            for ( int i = 1; i < attributeCount; i++ )
-            {
-                for ( int j = 0; j < i; j++ )
-                {
-                    if ( ( allStringsInterned && attributeName[j].equals( attributeName[i] )
-                        || ( !allStringsInterned && attributeNameHash[j] == attributeNameHash[i]
-                            && attributeName[j].equals( attributeName[i] ) ) )
-
-                    )
-                    {
+            for (int i = 1; i < attributeCount; i++) {
+                for (int j = 0; j < i; j++) {
+                    if ((allStringsInterned && attributeName[j].equals(attributeName[i])
+                            || (!allStringsInterned
+                                    && attributeNameHash[j] == attributeNameHash[i]
+                                    && attributeName[j].equals(attributeName[i])))) {
+
                         // prepare data for nice error message?
                         final String attr1 = attributeName[j];
                         final String attr2 = attributeName[i];
-                        throw new XmlPullParserException( "duplicated attributes " + attr1 + " and " + attr2, this,
-                                                          null );
+                        throw new XmlPullParserException(
+                                "duplicated attributes " + attr1 + " and " + attr2, this, null);
                     }
                 }
             }
@@ -2391,9 +1902,7 @@ else if ( isNameStartChar( ch ) )
         return eventType = START_TAG;
     }
 
-    private char parseAttribute()
-        throws XmlPullParserException, IOException
-    {
+    private char parseAttribute() throws XmlPullParserException, IOException {
         // parse attribute
         // [41] Attribute ::= Name Eq AttValue
         // [WFC: No External Entity References]
@@ -2402,144 +1911,115 @@ private char parseAttribute()
         final int nameStart = pos - 1 + bufAbsoluteStart;
         int colonPos = -1;
         char ch = buf[pos - 1];
-        if ( ch == ':' && processNamespaces )
-            throw new XmlPullParserException( "when namespaces processing enabled colon can not be at attribute name start",
-                                              this, null );
+        if (ch == ':' && processNamespaces)
+            throw new XmlPullParserException(
+                    "when namespaces processing enabled colon can not be at attribute name start", this, null);
 
         boolean startsWithXmlns = processNamespaces && ch == 'x';
         int xmlnsPos = 0;
 
         ch = more();
-        while ( isNameChar( ch ) )
-        {
-            if ( processNamespaces )
-            {
-                if ( startsWithXmlns && xmlnsPos < 5 )
-                {
+        while (isNameChar(ch)) {
+            if (processNamespaces) {
+                if (startsWithXmlns && xmlnsPos < 5) {
                     ++xmlnsPos;
-                    if ( xmlnsPos == 1 )
-                    {
-                        if ( ch != 'm' )
-                            startsWithXmlns = false;
-                    }
-                    else if ( xmlnsPos == 2 )
-                    {
-                        if ( ch != 'l' )
-                            startsWithXmlns = false;
-                    }
-                    else if ( xmlnsPos == 3 )
-                    {
-                        if ( ch != 'n' )
-                            startsWithXmlns = false;
-                    }
-                    else if ( xmlnsPos == 4 )
-                    {
-                        if ( ch != 's' )
-                            startsWithXmlns = false;
-                    }
-                    else if ( xmlnsPos == 5 )
-                    {
-                        if ( ch != ':' )
-                            throw new XmlPullParserException( "after xmlns in attribute name must be colon"
-                                + "when namespaces are enabled", this, null );
+                    if (xmlnsPos == 1) {
+                        if (ch != 'm') startsWithXmlns = false;
+                    } else if (xmlnsPos == 2) {
+                        if (ch != 'l') startsWithXmlns = false;
+                    } else if (xmlnsPos == 3) {
+                        if (ch != 'n') startsWithXmlns = false;
+                    } else if (xmlnsPos == 4) {
+                        if (ch != 's') startsWithXmlns = false;
+                    } else if (xmlnsPos == 5) {
+                        if (ch != ':')
+                            throw new XmlPullParserException(
+                                    "after xmlns in attribute name must be colon" + "when namespaces are enabled",
+                                    this,
+                                    null);
                         // colonPos = pos - 1 + bufAbsoluteStart;
                     }
                 }
-                if ( ch == ':' )
-                {
-                    if ( colonPos != -1 )
-                        throw new XmlPullParserException( "only one colon is allowed in attribute name"
-                            + " when namespaces are enabled", this, null );
+                if (ch == ':') {
+                    if (colonPos != -1)
+                        throw new XmlPullParserException(
+                                "only one colon is allowed in attribute name" + " when namespaces are enabled",
+                                this,
+                                null);
                     colonPos = pos - 1 + bufAbsoluteStart;
                 }
             }
             ch = more();
         }
 
-        ensureAttributesCapacity( attributeCount );
+        ensureAttributesCapacity(attributeCount);
 
         // --- start processing attributes
         String name = null;
         String prefix = null;
         // work on prefixes and namespace URI
-        if ( processNamespaces )
-        {
-            if ( xmlnsPos < 4 )
-                startsWithXmlns = false;
-            if ( startsWithXmlns )
-            {
-                if ( colonPos != -1 )
-                {
+        if (processNamespaces) {
+            if (xmlnsPos < 4) startsWithXmlns = false;
+            if (startsWithXmlns) {
+                if (colonPos != -1) {
                     // prefix = attributePrefix[ attributeCount ] = null;
-                    final int nameLen = pos - 2 - ( colonPos - bufAbsoluteStart );
-                    if ( nameLen == 0 )
-                    {
-                        throw new XmlPullParserException( "namespace prefix is required after xmlns: "
-                            + " when namespaces are enabled", this, null );
+                    final int nameLen = pos - 2 - (colonPos - bufAbsoluteStart);
+                    if (nameLen == 0) {
+                        throw new XmlPullParserException(
+                                "namespace prefix is required after xmlns: " + " when namespaces are enabled",
+                                this,
+                                null);
                     }
                     name = // attributeName[ attributeCount ] =
-                        newString( buf, colonPos - bufAbsoluteStart + 1, nameLen );
+                            newString(buf, colonPos - bufAbsoluteStart + 1, nameLen);
                     // pos - 1 - (colonPos + 1 - bufAbsoluteStart)
                 }
-            }
-            else
-            {
-                if ( colonPos != -1 )
-                {
+            } else {
+                if (colonPos != -1) {
                     int prefixLen = colonPos - nameStart;
-                    prefix =
-                        attributePrefix[attributeCount] = newString( buf, nameStart - bufAbsoluteStart, prefixLen );
+                    prefix = attributePrefix[attributeCount] = newString(buf, nameStart - bufAbsoluteStart, prefixLen);
                     // colonPos - (nameStart - bufAbsoluteStart));
-                    int nameLen = pos - 2 - ( colonPos - bufAbsoluteStart );
-                    name = attributeName[attributeCount] = newString( buf, colonPos - bufAbsoluteStart + 1, nameLen );
+                    int nameLen = pos - 2 - (colonPos - bufAbsoluteStart);
+                    name = attributeName[attributeCount] = newString(buf, colonPos - bufAbsoluteStart + 1, nameLen);
                     // pos - 1 - (colonPos + 1 - bufAbsoluteStart));
 
                     // name.substring(0, colonPos-nameStart);
-                }
-                else
-                {
+                } else {
                     prefix = attributePrefix[attributeCount] = null;
                     name = attributeName[attributeCount] =
-                        newString( buf, nameStart - bufAbsoluteStart, pos - 1 - ( nameStart - bufAbsoluteStart ) );
+                            newString(buf, nameStart - bufAbsoluteStart, pos - 1 - (nameStart - bufAbsoluteStart));
                 }
-                if ( !allStringsInterned )
-                {
+                if (!allStringsInterned) {
                     attributeNameHash[attributeCount] = name.hashCode();
                 }
             }
 
-        }
-        else
-        {
+        } else {
             // retrieve name
             name = attributeName[attributeCount] =
-                newString( buf, nameStart - bufAbsoluteStart, pos - 1 - ( nameStart - bufAbsoluteStart ) );
+                    newString(buf, nameStart - bufAbsoluteStart, pos - 1 - (nameStart - bufAbsoluteStart));
             //// assert name != null;
-            if ( !allStringsInterned )
-            {
+            if (!allStringsInterned) {
                 attributeNameHash[attributeCount] = name.hashCode();
             }
         }
 
         // [25] Eq ::= S? '=' S?
-        while ( isS( ch ) )
-        {
+        while (isS(ch)) {
             ch = more();
         } // skip additional spaces
-        if ( ch != '=' )
-            throw new XmlPullParserException( "expected = after attribute name", this, null );
+        if (ch != '=') throw new XmlPullParserException("expected = after attribute name", this, null);
         ch = more();
-        while ( isS( ch ) )
-        {
+        while (isS(ch)) {
             ch = more();
         } // skip additional spaces
 
         // [10] AttValue ::= '"' ([^<&"] | Reference)* '"'
         // | "'" ([^<&'] | Reference)* "'"
         final char delimit = ch;
-        if ( delimit != '"' && delimit != '\'' )
-            throw new XmlPullParserException( "attribute value must start with quotation or apostrophe not "
-                + printable( delimit ), this, null );
+        if (delimit != '"' && delimit != '\'')
+            throw new XmlPullParserException(
+                    "attribute value must start with quotation or apostrophe not " + printable(delimit), this, null);
         // parse until delimit or < and resolve Reference
         // [67] Reference ::= EntityRef | CharRef
         // int valueStart = pos + bufAbsoluteStart;
@@ -2549,95 +2029,68 @@ else if ( xmlnsPos == 5 )
         pcStart = pcEnd;
         posStart = pos;
 
-        while ( true )
-        {
+        while (true) {
             ch = more();
-            if ( ch == delimit )
-            {
+            if (ch == delimit) {
                 break;
             }
-            if ( ch == '<' )
-            {
-                throw new XmlPullParserException( "markup not allowed inside attribute value - illegal < ", this,
-                                                  null );
+            if (ch == '<') {
+                throw new XmlPullParserException("markup not allowed inside attribute value - illegal < ", this, null);
             }
-            if ( ch == '&' )
-            {
+            if (ch == '&') {
                 extractEntityRef();
-            }
-            else if ( ch == '\t' || ch == '\n' || ch == '\r' )
-            {
+            } else if (ch == '\t' || ch == '\n' || ch == '\r') {
                 // do attribute value normalization
                 // as described in http://www.w3.org/TR/REC-xml#AVNormalize
                 // TODO add test for it form spec ...
                 // handle EOL normalization ...
-                if ( !usePC )
-                {
+                if (!usePC) {
                     posEnd = pos - 1;
-                    if ( posEnd > posStart )
-                    {
+                    if (posEnd > posStart) {
                         joinPC();
-                    }
-                    else
-                    {
+                    } else {
                         usePC = true;
                         pcEnd = pcStart = 0;
                     }
                 }
                 // assert usePC == true;
-                if ( pcEnd >= pc.length )
-                    ensurePC( pcEnd );
-                if ( ch != '\n' || !normalizedCR )
-                {
+                if (pcEnd >= pc.length) ensurePC(pcEnd);
+                if (ch != '\n' || !normalizedCR) {
                     pc[pcEnd++] = ' '; // '\n';
                 }
 
-            }
-            else
-            {
-                if ( usePC )
-                {
-                    if ( pcEnd >= pc.length )
-                        ensurePC( pcEnd );
+            } else {
+                if (usePC) {
+                    if (pcEnd >= pc.length) ensurePC(pcEnd);
                     pc[pcEnd++] = ch;
                 }
             }
             normalizedCR = ch == '\r';
         }
 
-        if ( processNamespaces && startsWithXmlns )
-        {
+        if (processNamespaces && startsWithXmlns) {
             String ns = null;
-            if ( !usePC )
-            {
-                ns = newStringIntern( buf, posStart, pos - 1 - posStart );
+            if (!usePC) {
+                ns = newStringIntern(buf, posStart, pos - 1 - posStart);
+            } else {
+                ns = newStringIntern(pc, pcStart, pcEnd - pcStart);
             }
-            else
-            {
-                ns = newStringIntern( pc, pcStart, pcEnd - pcStart );
-            }
-            ensureNamespacesCapacity( namespaceEnd );
+            ensureNamespacesCapacity(namespaceEnd);
             int prefixHash = -1;
-            if ( colonPos != -1 )
-            {
-                if ( ns.length() == 0 )
-                {
-                    throw new XmlPullParserException( "non-default namespace can not be declared to be empty string",
-                                                      this, null );
+            if (colonPos != -1) {
+                if (ns.length() == 0) {
+                    throw new XmlPullParserException(
+                            "non-default namespace can not be declared to be empty string", this, null);
                 }
                 // declare new namespace
                 namespacePrefix[namespaceEnd] = name;
-                if ( !allStringsInterned )
-                {
+                if (!allStringsInterned) {
                     prefixHash = namespacePrefixHash[namespaceEnd] = name.hashCode();
                 }
-            }
-            else
-            {
+            } else {
                 // declare new default namespace...
                 namespacePrefix[namespaceEnd] = null; // ""; //null; //TODO check FIXME Alek
-                if ( !allStringsInterned )
-                {
+                if (!allStringsInterned) {
                     prefixHash = namespacePrefixHash[namespaceEnd] = -1;
                 }
             }
@@ -2645,29 +2098,25 @@ else if ( ch == '\t' || ch == '\n' || ch == '\r' )
 
             // detect duplicate namespace declarations!!!
             final int startNs = elNamespaceCount[depth - 1];
-            for ( int i = namespaceEnd - 1; i >= startNs; --i )
-            {
-                if ( ( ( allStringsInterned || name == null ) && namespacePrefix[i] == name ) || ( !allStringsInterned
-                    && name != null && namespacePrefixHash[i] == prefixHash && name.equals( namespacePrefix[i] ) ) )
-                {
+            for (int i = namespaceEnd - 1; i >= startNs; --i) {
+                if (((allStringsInterned || name == null) && namespacePrefix[i] == name)
+                        || (!allStringsInterned
+                                && name != null
+                                && namespacePrefixHash[i] == prefixHash
+                                && name.equals(namespacePrefix[i]))) {
                     final String s = name == null ? "default" : "'" + name + "'";
-                    throw new XmlPullParserException( "duplicated namespace declaration for " + s + " prefix", this,
-                                                      null );
+                    throw new XmlPullParserException(
+                            "duplicated namespace declaration for " + s + " prefix", this, null);
                 }
             }
 
             ++namespaceEnd;
 
-        }
-        else
-        {
-            if ( !usePC )
-            {
-                attributeValue[attributeCount] = new String( buf, posStart, pos - 1 - posStart );
-            }
-            else
-            {
-                attributeValue[attributeCount] = new String( pc, pcStart, pcEnd - pcStart );
+        } else {
+            if (!usePC) {
+                attributeValue[attributeCount] = new String(buf, posStart, pos - 1 - posStart);
+            } else {
+                attributeValue[attributeCount] = new String(pc, pcStart, pcEnd - pcStart);
             }
             ++attributeCount;
         }
@@ -2679,11 +2128,11 @@ else if ( ch == '\t' || ch == '\n' || ch == '\r' )
     private static final char[] BUF_NOT_RESOLVED = new char[0];
 
     // predefined entity refs
-    private static final char[] BUF_LT = new char[] { '<' };
-    private static final char[] BUF_AMP = new char[] { '&' };
-    private static final char[] BUF_GT = new char[] { '>' };
-    private static final char[] BUF_APO = new char[] { '\'' };
-    private static final char[] BUF_QUOT = new char[] { '"' };
+    private static final char[] BUF_LT = new char[] {'<'};
+    private static final char[] BUF_AMP = new char[] {'&'};
+    private static final char[] BUF_GT = new char[] {'>'};
+    private static final char[] BUF_APO = new char[] {'\''};
+    private static final char[] BUF_QUOT = new char[] {'"'};
 
     private char[] resolvedEntityRefCharBuf = BUF_NOT_RESOLVED;
 
@@ -2696,9 +2145,7 @@ else if ( ch == '\t' || ch == '\n' || ch == '\r' )
      * @throws XmlPullParserException if invalid XML is detected.
      * @throws IOException if an I/O error is found.
      */
-    private int parseCharOrPredefinedEntityRef()
-        throws XmlPullParserException, IOException
-    {
+    private int parseCharOrPredefinedEntityRef() throws XmlPullParserException, IOException {
         // entity reference http://www.w3.org/TR/2000/REC-xml-20001006#NT-Reference
         // [67] Reference ::= EntityRef | CharRef
 
@@ -2708,125 +2155,96 @@ private int parseCharOrPredefinedEntityRef()
         int len = 0;
         resolvedEntityRefCharBuf = BUF_NOT_RESOLVED;
         char ch = more();
-        if ( ch == '#' )
-        {
+        if (ch == '#') {
             // parse character reference
 
             char charRef = 0;
             ch = more();
             StringBuilder sb = new StringBuilder();
-            boolean isHex = ( ch == 'x' );
+            boolean isHex = (ch == 'x');
 
-            if ( isHex )
-            {
+            if (isHex) {
                 // encoded in hex
-                while ( true )
-                {
+                while (true) {
                     ch = more();
-                    if ( ch >= '0' && ch <= '9' )
-                    {
-                        charRef = (char) ( charRef * 16 + ( ch - '0' ) );
-                        sb.append( ch );
-                    }
-                    else if ( ch >= 'a' && ch <= 'f' )
-                    {
-                        charRef = (char) ( charRef * 16 + ( ch - ( 'a' - 10 ) ) );
-                        sb.append( ch );
-                    }
-                    else if ( ch >= 'A' && ch <= 'F' )
-                    {
-                        charRef = (char) ( charRef * 16 + ( ch - ( 'A' - 10 ) ) );
-                        sb.append( ch );
-                    }
-                    else if ( ch == ';' )
-                    {
+                    if (ch >= '0' && ch <= '9') {
+                        charRef = (char) (charRef * 16 + (ch - '0'));
+                        sb.append(ch);
+                    } else if (ch >= 'a' && ch <= 'f') {
+                        charRef = (char) (charRef * 16 + (ch - ('a' - 10)));
+                        sb.append(ch);
+                    } else if (ch >= 'A' && ch <= 'F') {
+                        charRef = (char) (charRef * 16 + (ch - ('A' - 10)));
+                        sb.append(ch);
+                    } else if (ch == ';') {
                         break;
-                    }
-                    else
-                    {
-                        throw new XmlPullParserException( "character reference (with hex value) may not contain "
-                            + printable( ch ), this, null );
+                    } else {
+                        throw new XmlPullParserException(
+                                "character reference (with hex value) may not contain " + printable(ch), this, null);
                     }
                 }
-            }
-            else
-            {
+            } else {
                 // encoded in decimal
-                while ( true )
-                {
-                    if ( ch >= '0' && ch <= '9' )
-                    {
-                        charRef = (char) ( charRef * 10 + ( ch - '0' ) );
-                        sb.append( ch );
-                    }
-                    else if ( ch == ';' )
-                    {
+                while (true) {
+                    if (ch >= '0' && ch <= '9') {
+                        charRef = (char) (charRef * 10 + (ch - '0'));
+                        sb.append(ch);
+                    } else if (ch == ';') {
                         break;
-                    }
-                    else
-                    {
-                        throw new XmlPullParserException( "character reference (with decimal value) may not contain "
-                            + printable( ch ), this, null );
+                    } else {
+                        throw new XmlPullParserException(
+                                "character reference (with decimal value) may not contain " + printable(ch),
+                                this,
+                                null);
                     }
                     ch = more();
                 }
             }
 
             boolean isValidCodePoint = true;
-            try
-            {
-                int codePoint = Integer.parseInt( sb.toString(), isHex ? 16 : 10 );
-                isValidCodePoint = isValidCodePoint( codePoint );
-                if ( isValidCodePoint )
-                {
-                    resolvedEntityRefCharBuf = Character.toChars( codePoint );
+            try {
+                int codePoint = Integer.parseInt(sb.toString(), isHex ? 16 : 10);
+                isValidCodePoint = isValidCodePoint(codePoint);
+                if (isValidCodePoint) {
+                    resolvedEntityRefCharBuf = Character.toChars(codePoint);
                 }
-            }
-            catch ( IllegalArgumentException e )
-            {
+            } catch (IllegalArgumentException e) {
                 isValidCodePoint = false;
             }
 
-            if ( !isValidCodePoint )
-            {
-                throw new XmlPullParserException( "character reference (with " + ( isHex ? "hex" : "decimal" )
-                    + " value " + sb.toString() + ") is invalid", this, null );
+            if (!isValidCodePoint) {
+                throw new XmlPullParserException(
+                        "character reference (with " + (isHex ? "hex" : "decimal") + " value " + sb.toString()
+                                + ") is invalid",
+                        this,
+                        null);
             }
 
-            if ( tokenize )
-            {
-                text = newString( resolvedEntityRefCharBuf, 0, resolvedEntityRefCharBuf.length );
+            if (tokenize) {
+                text = newString(resolvedEntityRefCharBuf, 0, resolvedEntityRefCharBuf.length);
             }
             len = resolvedEntityRefCharBuf.length;
-        }
-        else
-        {
+        } else {
             // [68] EntityRef ::= '&' Name ';'
             // scan name until ;
-            if ( !isNameStartChar( ch ) )
-            {
-                throw new XmlPullParserException( "entity reference names can not start with character '"
-                    + printable( ch ) + "'", this, null );
+            if (!isNameStartChar(ch)) {
+                throw new XmlPullParserException(
+                        "entity reference names can not start with character '" + printable(ch) + "'", this, null);
             }
-            while ( true )
-            {
+            while (true) {
                 ch = more();
-                if ( ch == ';' )
-                {
+                if (ch == ';') {
                     break;
                 }
-                if ( !isNameChar( ch ) )
-                {
-                    throw new XmlPullParserException( "entity reference name can not contain character "
-                        + printable( ch ) + "'", this, null );
+                if (!isNameChar(ch)) {
+                    throw new XmlPullParserException(
+                            "entity reference name can not contain character " + printable(ch) + "'", this, null);
                 }
             }
             // determine what name maps to
-            len = ( pos - 1 ) - posStart;
-            if ( len == 2 && buf[posStart] == 'l' && buf[posStart + 1] == 't' )
-            {
-                if ( tokenize )
-                {
+            len = (pos - 1) - posStart;
+            if (len == 2 && buf[posStart] == 'l' && buf[posStart + 1] == 't') {
+                if (tokenize) {
                     text = "<";
                 }
                 resolvedEntityRefCharBuf = BUF_LT;
@@ -2834,37 +2252,31 @@ else if ( ch >= 'A' && ch <= 'F' )
                 // if(pcEnd >= pc.length) ensurePC();
                 // pc[pcEnd++] = '<';
                 // }
-            }
-            else if ( len == 3 && buf[posStart] == 'a' && buf[posStart + 1] == 'm' && buf[posStart + 2] == 'p' )
-            {
-                if ( tokenize )
-                {
+            } else if (len == 3 && buf[posStart] == 'a' && buf[posStart + 1] == 'm' && buf[posStart + 2] == 'p') {
+                if (tokenize) {
                     text = "&";
                 }
                 resolvedEntityRefCharBuf = BUF_AMP;
-            }
-            else if ( len == 2 && buf[posStart] == 'g' && buf[posStart + 1] == 't' )
-            {
-                if ( tokenize )
-                {
+            } else if (len == 2 && buf[posStart] == 'g' && buf[posStart + 1] == 't') {
+                if (tokenize) {
                     text = ">";
                 }
                 resolvedEntityRefCharBuf = BUF_GT;
-            }
-            else if ( len == 4 && buf[posStart] == 'a' && buf[posStart + 1] == 'p' && buf[posStart + 2] == 'o'
-                && buf[posStart + 3] == 's' )
-            {
-                if ( tokenize )
-                {
+            } else if (len == 4
+                    && buf[posStart] == 'a'
+                    && buf[posStart + 1] == 'p'
+                    && buf[posStart + 2] == 'o'
+                    && buf[posStart + 3] == 's') {
+                if (tokenize) {
                     text = "'";
                 }
                 resolvedEntityRefCharBuf = BUF_APO;
-            }
-            else if ( len == 4 && buf[posStart] == 'q' && buf[posStart + 1] == 'u' && buf[posStart + 2] == 'o'
-                && buf[posStart + 3] == 't' )
-            {
-                if ( tokenize )
-                {
+            } else if (len == 4
+                    && buf[posStart] == 'q'
+                    && buf[posStart + 1] == 'u'
+                    && buf[posStart + 2] == 'o'
+                    && buf[posStart + 3] == 't') {
+                if (tokenize) {
                     text = "\"";
                 }
                 resolvedEntityRefCharBuf = BUF_QUOT;
@@ -2882,19 +2294,15 @@ else if ( len == 4 && buf[posStart] == 'q' && buf[posStart + 1] == 'u' && buf[po
      * @throws XmlPullParserException if invalid XML is detected.
      * @throws IOException if an I/O error is found.
      */
-    private void parseEntityRefInDocDecl()
-        throws XmlPullParserException, IOException
-    {
+    private void parseEntityRefInDocDecl() throws XmlPullParserException, IOException {
         parseCharOrPredefinedEntityRef();
         if (usePC) {
             posStart--; // include in PC the starting '&' of the entity
             joinPC();
         }
 
-        if ( resolvedEntityRefCharBuf != BUF_NOT_RESOLVED )
-            return;
-        if ( tokenize )
-            text = null;
+        if (resolvedEntityRefCharBuf != BUF_NOT_RESOLVED) return;
+        if (tokenize) text = null;
     }
 
     /**
@@ -2903,24 +2311,20 @@ private void parseEntityRefInDocDecl()
      * @throws XmlPullParserException if invalid XML is detected.
      * @throws IOException if an I/O error is found.
      */
-    private void parseEntityRef()
-        throws XmlPullParserException, IOException
-    {
+    private void parseEntityRef() throws XmlPullParserException, IOException {
         final int len = parseCharOrPredefinedEntityRef();
 
         posEnd--; // don't involve the final ';' from the entity in the search
 
-        if ( resolvedEntityRefCharBuf != BUF_NOT_RESOLVED ) {
+        if (resolvedEntityRefCharBuf != BUF_NOT_RESOLVED) {
             return;
         }
 
-        resolvedEntityRefCharBuf = lookuEntityReplacement( len );
-        if ( resolvedEntityRefCharBuf != BUF_NOT_RESOLVED )
-        {
+        resolvedEntityRefCharBuf = lookuEntityReplacement(len);
+        if (resolvedEntityRefCharBuf != BUF_NOT_RESOLVED) {
             return;
         }
-        if ( tokenize )
-            text = null;
+        if (tokenize) text = null;
     }
 
     /**
@@ -2930,44 +2334,36 @@ private void parseEntityRef()
      * @param codePoint the numeric value to check
      * @return true if it is a valid numeric character reference. False otherwise.
      */
-    private static boolean isValidCodePoint( int codePoint )
-    {
+    private static boolean isValidCodePoint(int codePoint) {
         // Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
-        return codePoint == 0x9 || codePoint == 0xA || codePoint == 0xD || ( 0x20 <= codePoint && codePoint <= 0xD7FF )
-            || ( 0xE000 <= codePoint && codePoint <= 0xFFFD ) || ( 0x10000 <= codePoint && codePoint <= 0x10FFFF );
-    }
-
-    private char[] lookuEntityReplacement( int entityNameLen )
-    {
-        if ( !allStringsInterned )
-        {
-            final int hash = fastHash( buf, posStart, posEnd - posStart );
-            LOOP: for ( int i = entityEnd - 1; i >= 0; --i )
-            {
-                if ( hash == entityNameHash[i] && entityNameLen == entityNameBuf[i].length )
-                {
+        return codePoint == 0x9
+                || codePoint == 0xA
+                || codePoint == 0xD
+                || (0x20 <= codePoint && codePoint <= 0xD7FF)
+                || (0xE000 <= codePoint && codePoint <= 0xFFFD)
+                || (0x10000 <= codePoint && codePoint <= 0x10FFFF);
+    }
+
+    private char[] lookuEntityReplacement(int entityNameLen) {
+        if (!allStringsInterned) {
+            final int hash = fastHash(buf, posStart, posEnd - posStart);
+            LOOP:
+            for (int i = entityEnd - 1; i >= 0; --i) {
+                if (hash == entityNameHash[i] && entityNameLen == entityNameBuf[i].length) {
                     final char[] entityBuf = entityNameBuf[i];
-                    for ( int j = 0; j < entityNameLen; j++ )
-                    {
-                        if ( buf[posStart + j] != entityBuf[j] )
-                            continue LOOP;
+                    for (int j = 0; j < entityNameLen; j++) {
+                        if (buf[posStart + j] != entityBuf[j]) continue LOOP;
                     }
-                    if ( tokenize )
-                        text = entityReplacement[i];
+                    if (tokenize) text = entityReplacement[i];
                     return entityReplacementBuf[i];
                 }
             }
-        }
-        else
-        {
-            entityRefName = newString( buf, posStart, posEnd - posStart );
-            for ( int i = entityEnd - 1; i >= 0; --i )
-            {
+        } else {
+            entityRefName = newString(buf, posStart, posEnd - posStart);
+            for (int i = entityEnd - 1; i >= 0; --i) {
                 // take advantage that interning for newString is enforced
-                if ( entityRefName == entityName[i] )
-                {
-                    if ( tokenize )
-                        text = entityReplacement[i];
+                if (entityRefName == entityName[i]) {
+                    if (tokenize) text = entityReplacement[i];
                     return entityReplacementBuf[i];
                 }
             }
@@ -2975,120 +2371,86 @@ private char[] lookuEntityReplacement( int entityNameLen )
         return BUF_NOT_RESOLVED;
     }
 
-    private void parseComment()
-        throws XmlPullParserException, IOException
-    {
+    private void parseComment() throws XmlPullParserException, IOException {
         // implements XML 1.0 Section 2.5 Comments
 
         // ASSUMPTION: seen 
                 cch = more();
                 int ch;
                 char cch2;
-                if ( Character.isHighSurrogate( cch ) )
-                {
+                if (Character.isHighSurrogate(cch)) {
                     cch2 = more();
-                    ch = Character.toCodePoint( cch, cch2 );
-                }
-                else
-                {
+                    ch = Character.toCodePoint(cch, cch2);
+                } else {
                     cch2 = 0;
                     ch = cch;
                 }
-                if ( seenDashDash && ch != '>' )
-                {
-                    throw new XmlPullParserException( "in comment after two dashes (--) next character must be >"
-                        + " not " + printable( ch ), this, null );
+                if (seenDashDash && ch != '>') {
+                    throw new XmlPullParserException(
+                            "in comment after two dashes (--) next character must be >" + " not " + printable(ch),
+                            this,
+                            null);
                 }
-                if ( ch == '-' )
-                {
-                    if ( !seenDash )
-                    {
+                if (ch == '-') {
+                    if (!seenDash) {
                         seenDash = true;
-                    }
-                    else
-                    {
+                    } else {
                         seenDashDash = true;
                     }
-                }
-                else if ( ch == '>' )
-                {
-                    if ( seenDashDash )
-                    {
+                } else if (ch == '>') {
+                    if (seenDashDash) {
                         break; // found end sequence!!!!
                     }
                     seenDash = false;
-                }
-                else if (isValidCodePoint( ch ))
-                {
+                } else if (isValidCodePoint(ch)) {
                     seenDash = false;
+                } else {
+                    throw new XmlPullParserException(
+                            "Illegal character 0x" + Integer.toHexString(ch) + " found in comment", this, null);
                 }
-                else
-                {
-                    throw new XmlPullParserException( "Illegal character 0x" + Integer.toHexString(ch) + " found in comment", this, null );
-                }
-                if ( normalizeIgnorableWS )
-                {
-                    if ( ch == '\r' )
-                    {
+                if (normalizeIgnorableWS) {
+                    if (ch == '\r') {
                         normalizedCR = true;
                         // posEnd = pos -1;
                         // joinPC();
                         // posEnd is alreadys set
-                        if ( !usePC )
-                        {
+                        if (!usePC) {
                             posEnd = pos - 1;
-                            if ( posEnd > posStart )
-                            {
+                            if (posEnd > posStart) {
                                 joinPC();
-                            }
-                            else
-                            {
+                            } else {
                                 usePC = true;
                                 pcStart = pcEnd = 0;
                             }
                         }
                         // assert usePC == true;
-                        if ( pcEnd >= pc.length )
-                            ensurePC( pcEnd );
+                        if (pcEnd >= pc.length) ensurePC(pcEnd);
                         pc[pcEnd++] = '\n';
-                    }
-                    else if ( ch == '\n' )
-                    {
-                        if ( !normalizedCR && usePC )
-                        {
-                            if ( pcEnd >= pc.length )
-                                ensurePC( pcEnd );
+                    } else if (ch == '\n') {
+                        if (!normalizedCR && usePC) {
+                            if (pcEnd >= pc.length) ensurePC(pcEnd);
                             pc[pcEnd++] = '\n';
                         }
                         normalizedCR = false;
-                    }
-                    else
-                    {
-                        if ( usePC )
-                        {
-                            if ( pcEnd >= pc.length )
-                                ensurePC( pcEnd );
+                    } else {
+                        if (usePC) {
+                            if (pcEnd >= pc.length) ensurePC(pcEnd);
                             pc[pcEnd++] = cch;
-                            if ( cch2 != 0 )
-                            {
+                            if (cch2 != 0) {
                                 pc[pcEnd++] = cch2;
                             }
                         }
@@ -3097,33 +2459,26 @@ else if ( ch == '\n' )
                 }
             }
 
-        }
-        catch ( EOFException ex )
-        {
+        } catch (EOFException ex) {
             // detect EOF and create meaningful error ...
-            throw new XmlPullParserException( "comment started on line " + curLine + " and column " + curColumn
-                + " was not closed", this, ex );
+            throw new XmlPullParserException(
+                    "comment started on line " + curLine + " and column " + curColumn + " was not closed", this, ex);
         }
-        if ( tokenize )
-        {
+        if (tokenize) {
             posEnd = pos - 3;
-            if ( usePC )
-            {
+            if (usePC) {
                 pcEnd -= 2;
             }
         }
     }
 
-    private boolean parsePI()
-        throws XmlPullParserException, IOException
-    {
+    private boolean parsePI() throws XmlPullParserException, IOException {
         // implements XML 1.0 Section 2.6 Processing Instructions
 
         // [16] PI ::= '' Char*)))? '?>'
         // [17] PITarget ::= Name - (('X' | 'x') ('M' | 'm') ('L' | 'l'))
         // ASSUMPTION: seen 
                 // ch = more();
 
-                if ( ch == '?' )
-                {
-                    if ( !seenPITarget )
-                    {
-                        throw new XmlPullParserException( "processing instruction PITarget name not found", this,
-                                                          null );
+                if (ch == '?') {
+                    if (!seenPITarget) {
+                        throw new XmlPullParserException("processing instruction PITarget name not found", this, null);
                     }
                     seenQ = true;
-                }
-                else if ( ch == '>' )
-                {
-                    if ( seenQ )
-                    {
+                } else if (ch == '>') {
+                    if (seenQ) {
                         break; // found end sequence!!!!
                     }
 
-                    if ( !seenPITarget )
-                    {
-                        throw new XmlPullParserException( "processing instruction PITarget name not found", this,
-                                                          null );
-                    }
-                    else if ( !seenInnerTag )
-                    {
+                    if (!seenPITarget) {
+                        throw new XmlPullParserException("processing instruction PITarget name not found", this, null);
+                    } else if (!seenInnerTag) {
                         // seenPITarget && !seenQ
-                        throw new XmlPullParserException( "processing instruction started on line " + curLine
-                            + " and column " + curColumn + " was not closed", this, null );
-                    }
-                    else
-                    {
+                        throw new XmlPullParserException(
+                                "processing instruction started on line " + curLine + " and column " + curColumn
+                                        + " was not closed",
+                                this,
+                                null);
+                    } else {
                         seenInnerTag = false;
                     }
-                }
-                else if ( ch == '<' )
-                {
+                } else if (ch == '<') {
                     seenInnerTag = true;
-                }
-                else
-                {
-                    if ( piTargetEnd == -1 && isS( ch ) )
-                    {
+                } else {
+                    if (piTargetEnd == -1 && isS(ch)) {
                         piTargetEnd = pos - 1;
 
                         // [17] PITarget ::= Name - (('X' | 'x') ('M' | 'm') ('L' | 'l'))
-                        if ( ( piTargetEnd - piTargetStart ) >= 3 )
-                        {
-                            if ( ( buf[piTargetStart] == 'x' || buf[piTargetStart] == 'X' )
-                                && ( buf[piTargetStart + 1] == 'm' || buf[piTargetStart + 1] == 'M' )
-                                && ( buf[piTargetStart + 2] == 'l' || buf[piTargetStart + 2] == 'L' ) )
-                            {
-                                if ( piTargetStart > 3 )
-                                { // = 3) {
+                            if ((buf[piTargetStart] == 'x' || buf[piTargetStart] == 'X')
+                                    && (buf[piTargetStart + 1] == 'm' || buf[piTargetStart + 1] == 'M')
+                                    && (buf[piTargetStart + 2] == 'l' || buf[piTargetStart + 2] == 'L')) {
+                                if (piTargetStart > 3) { //  posStart )
-                            {
+                            if (posEnd > posStart) {
                                 joinPC();
-                            }
-                            else
-                            {
+                            } else {
                                 usePC = true;
                                 pcStart = pcEnd = 0;
                             }
                         }
                         // assert usePC == true;
-                        if ( pcEnd >= pc.length )
-                            ensurePC( pcEnd );
+                        if (pcEnd >= pc.length) ensurePC(pcEnd);
                         pc[pcEnd++] = '\n';
-                    }
-                    else if ( ch == '\n' )
-                    {
-                        if ( !normalizedCR && usePC )
-                        {
-                            if ( pcEnd >= pc.length )
-                                ensurePC( pcEnd );
+                    } else if (ch == '\n') {
+                        if (!normalizedCR && usePC) {
+                            if (pcEnd >= pc.length) ensurePC(pcEnd);
                             pc[pcEnd++] = '\n';
                         }
                         normalizedCR = false;
-                    }
-                    else
-                    {
-                        if ( usePC )
-                        {
-                            if ( pcEnd >= pc.length )
-                                ensurePC( pcEnd );
+                    } else {
+                        if (usePC) {
+                            if (pcEnd >= pc.length) ensurePC(pcEnd);
                             pc[pcEnd++] = ch;
                         }
                         normalizedCR = false;
@@ -3273,24 +2594,22 @@ else if ( ch == '\n' )
                 seenPITarget = true;
                 ch = more();
             }
-        }
-        catch ( EOFException ex )
-        {
+        } catch (EOFException ex) {
             // detect EOF and create meaningful error ...
-            throw new XmlPullParserException( "processing instruction started on line " + curLine + " and column "
-                + curColumn + " was not closed", this, ex );
+            throw new XmlPullParserException(
+                    "processing instruction started on line " + curLine + " and column " + curColumn
+                            + " was not closed",
+                    this,
+                    ex);
         }
-        if ( piTargetEnd == -1 )
-        {
+        if (piTargetEnd == -1) {
             piTargetEnd = pos - 2 + bufAbsoluteStart;
             // throw new XmlPullParserException(
             // "processing instruction must have PITarget name", this, null);
         }
-        if ( tokenize )
-        {
+        if (tokenize) {
             posEnd = pos - 2;
-            if ( normalizeIgnorableWS )
-            {
+            if (normalizeIgnorableWS) {
                 --pcEnd;
             }
         }
@@ -3303,19 +2622,17 @@ else if ( ch == '\n' )
     // protected final static char[] YES = {'y','e','s'};
     // protected final static char[] NO = {'n','o'};
 
-    private final static char[] VERSION = "version".toCharArray();
+    private static final char[] VERSION = "version".toCharArray();
 
-    private final static char[] NCODING = "ncoding".toCharArray();
+    private static final char[] NCODING = "ncoding".toCharArray();
 
-    private final static char[] TANDALONE = "tandalone".toCharArray();
+    private static final char[] TANDALONE = "tandalone".toCharArray();
 
-    private final static char[] YES = "yes".toCharArray();
+    private static final char[] YES = "yes".toCharArray();
 
-    private final static char[] NO = "no".toCharArray();
+    private static final char[] NO = "no".toCharArray();
 
-    private void parseXmlDecl( char ch )
-        throws XmlPullParserException, IOException
-    {
+    private void parseXmlDecl(char ch) throws XmlPullParserException, IOException {
         // [23] XMLDecl ::= ''
 
         // first make sure that relative positions will stay OK
@@ -3326,218 +2643,203 @@ private void parseXmlDecl( char ch )
 
         // [24] VersionInfo ::= S 'version' Eq ("'" VersionNum "'" | '"' VersionNum '"')
         // parse is positioned just on first S past  'z' ) && ( ch < 'A' || ch > 'Z' ) && ( ch < '0' || ch > '9' ) && ch != '_'
-                && ch != '.' && ch != ':' && ch != '-' )
-            {
-                throw new XmlPullParserException( " 'z')
+                    && (ch < 'A' || ch > 'Z')
+                    && (ch < '0' || ch > '9')
+                    && ch != '_'
+                    && ch != '.'
+                    && ch != ':'
+                    && ch != '-') {
+                throw new XmlPullParserException(
+                        "' )
-        {
-            throw new XmlPullParserException( "unexpected character " + printable( ch ), this, null );
+        if (ch != 'e' && ch != 's' && ch != '?' && ch != '>') {
+            throw new XmlPullParserException("unexpected character " + printable(ch), this, null);
         }
 
-        if ( ch == 'e' )
-        {
-            if ( !isS( prevCh ) )
-            {
-                throw new XmlPullParserException( "expected a space after " + lastParsedAttr + " and not "
-                    + printable( ch ), this, null );
+        if (ch == 'e') {
+            if (!isS(prevCh)) {
+                throw new XmlPullParserException(
+                        "expected a space after " + lastParsedAttr + " and not " + printable(ch), this, null);
             }
             ch = more();
-            ch = requireInput( ch, NCODING );
-            ch = skipS( ch );
-            if ( ch != '=' )
-            {
-                throw new XmlPullParserException( "expected equals sign (=) after encoding and not " + printable( ch ),
-                                                  this, null );
+            ch = requireInput(ch, NCODING);
+            ch = skipS(ch);
+            if (ch != '=') {
+                throw new XmlPullParserException(
+                        "expected equals sign (=) after encoding and not " + printable(ch), this, null);
             }
             ch = more();
-            ch = skipS( ch );
-            if ( ch != '\'' && ch != '"' )
-            {
-                throw new XmlPullParserException( "expected apostrophe (') or quotation mark (\") after encoding and not "
-                    + printable( ch ), this, null );
+            ch = skipS(ch);
+            if (ch != '\'' && ch != '"') {
+                throw new XmlPullParserException(
+                        "expected apostrophe (') or quotation mark (\") after encoding and not " + printable(ch),
+                        this,
+                        null);
             }
             final char quotChar = ch;
             final int encodingStart = pos;
             ch = more();
             // [81] EncName ::= [A-Za-z] ([A-Za-z0-9._] | '-')*
-            if ( ( ch < 'a' || ch > 'z' ) && ( ch < 'A' || ch > 'Z' ) )
-            {
-                throw new XmlPullParserException( " 'z') && (ch < 'A' || ch > 'Z')) {
+                throw new XmlPullParserException(
+                        " 'z' ) && ( ch < 'A' || ch > 'Z' ) && ( ch < '0' || ch > '9' ) && ch != '.'
-                    && ch != '_' && ch != '-' )
-                {
-                    throw new XmlPullParserException( " 'z')
+                        && (ch < 'A' || ch > 'Z')
+                        && (ch < '0' || ch > '9')
+                        && ch != '.'
+                        && ch != '_'
+                        && ch != '-') {
+                    throw new XmlPullParserException(
+                            " as last part of  as last part of ' )
-        {
-            throw new XmlPullParserException( "expected ?> as last part of ') {
+            throw new XmlPullParserException("expected ?> as last part of ' && bracketLevel == 0 )
-                break;
-            else if ( ch == '&' )
-            {
+            if (ch == '[') ++bracketLevel;
+            else if (ch == ']') --bracketLevel;
+            else if (ch == '>' && bracketLevel == 0) break;
+            else if (ch == '&') {
                 extractEntityRefInDocDecl();
                 continue;
             }
-            if ( normalizeIgnorableWS )
-            {
-                if ( ch == '\r' )
-                {
+            if (normalizeIgnorableWS) {
+                if (ch == '\r') {
                     normalizedCR = true;
                     // posEnd = pos -1;
                     // joinPC();
                     // posEnd is alreadys set
-                    if ( !usePC )
-                    {
+                    if (!usePC) {
                         posEnd = pos - 1;
-                        if ( posEnd > posStart )
-                        {
+                        if (posEnd > posStart) {
                             joinPC();
-                        }
-                        else
-                        {
+                        } else {
                             usePC = true;
                             pcStart = pcEnd = 0;
                         }
                     }
                     // assert usePC == true;
-                    if ( pcEnd >= pc.length )
-                        ensurePC( pcEnd );
+                    if (pcEnd >= pc.length) ensurePC(pcEnd);
                     pc[pcEnd++] = '\n';
-                }
-                else if ( ch == '\n' )
-                {
-                    if ( !normalizedCR && usePC )
-                    {
-                        if ( pcEnd >= pc.length )
-                            ensurePC( pcEnd );
+                } else if (ch == '\n') {
+                    if (!normalizedCR && usePC) {
+                        if (pcEnd >= pc.length) ensurePC(pcEnd);
                         pc[pcEnd++] = '\n';
                     }
                     normalizedCR = false;
-                }
-                else
-                {
-                    if ( usePC )
-                    {
-                        if ( pcEnd >= pc.length )
-                            ensurePC( pcEnd );
+                } else {
+                    if (usePC) {
+                        if (pcEnd >= pc.length) ensurePC(pcEnd);
                         pc[pcEnd++] = ch;
                     }
                     normalizedCR = false;
                 }
             }
-
         }
         posEnd = pos - 1;
         text = null;
     }
 
-    private void extractEntityRefInDocDecl()
-        throws XmlPullParserException, IOException
-    {
+    private void extractEntityRefInDocDecl() throws XmlPullParserException, IOException {
         // extractEntityRef
         posEnd = pos - 1;
 
@@ -3625,21 +2904,15 @@ private void extractEntityRefInDocDecl()
         posStart = prevPosStart;
     }
 
-    private void extractEntityRef()
-        throws XmlPullParserException, IOException
-    {
+    private void extractEntityRef() throws XmlPullParserException, IOException {
         // extractEntityRef
         posEnd = pos - 1;
-        if ( !usePC )
-        {
+        if (!usePC) {
             final boolean hadCharData = posEnd > posStart;
-            if ( hadCharData )
-            {
+            if (hadCharData) {
                 // posEnd is already set correctly!!!
                 joinPC();
-            }
-            else
-            {
+            } else {
                 usePC = true;
                 pcStart = pcEnd = 0;
             }
@@ -3648,29 +2921,23 @@ private void extractEntityRef()
 
         parseEntityRef();
         // check if replacement text can be resolved !!!
-        if ( resolvedEntityRefCharBuf == BUF_NOT_RESOLVED )
-        {
-            if ( entityRefName == null )
-            {
-                entityRefName = newString( buf, posStart, posEnd - posStart );
+        if (resolvedEntityRefCharBuf == BUF_NOT_RESOLVED) {
+            if (entityRefName == null) {
+                entityRefName = newString(buf, posStart, posEnd - posStart);
             }
-            throw new XmlPullParserException( "could not resolve entity named '" + printable( entityRefName )
-                + "'", this, null );
+            throw new XmlPullParserException(
+                    "could not resolve entity named '" + printable(entityRefName) + "'", this, null);
         }
         // write into PC replacement text - do merge for replacement text!!!!
-        for ( char aResolvedEntity : resolvedEntityRefCharBuf )
-        {
-            if ( pcEnd >= pc.length )
-            {
-                ensurePC( pcEnd );
+        for (char aResolvedEntity : resolvedEntityRefCharBuf) {
+            if (pcEnd >= pc.length) {
+                ensurePC(pcEnd);
             }
             pc[pcEnd++] = aResolvedEntity;
         }
     }
 
-    private void parseCDSect( boolean hadCharData )
-        throws XmlPullParserException, IOException
-    {
+    private void parseCDSect(boolean hadCharData) throws XmlPullParserException, IOException {
         // implements XML 1.0 Section 2.7 CDATA Sections
 
         // [18] CDSect ::= CDStart CData CDEnd
@@ -3680,44 +2947,31 @@ private void parseCDSect( boolean hadCharData )
 
         // ASSUMPTION: seen  posStart )
-                        {
+                        if (posEnd > posStart) {
                             joinPC();
-                        }
-                        else
-                        {
+                        } else {
                             usePC = true;
                             pcStart = pcEnd = 0;
                         }
@@ -3727,99 +2981,69 @@ private void parseCDSect( boolean hadCharData )
             boolean seenBracket = false;
             boolean seenBracketBracket = false;
             boolean normalizedCR = false;
-            while ( true )
-            {
+            while (true) {
                 // scan until it hits "]]>"
                 ch = more();
-                if ( ch == ']' )
-                {
-                    if ( !seenBracket )
-                    {
+                if (ch == ']') {
+                    if (!seenBracket) {
                         seenBracket = true;
-                    }
-                    else
-                    {
+                    } else {
                         seenBracketBracket = true;
                         // seenBracket = false;
                     }
-                }
-                else if ( ch == '>' )
-                {
-                    if ( seenBracket && seenBracketBracket )
-                    {
+                } else if (ch == '>') {
+                    if (seenBracket && seenBracketBracket) {
                         break; // found end sequence!!!!
-                    }
-                    else
-                    {
+                    } else {
                         seenBracketBracket = false;
                     }
                     seenBracket = false;
-                }
-                else
-                {
-                    if ( seenBracket )
-                    {
+                } else {
+                    if (seenBracket) {
                         seenBracket = false;
                     }
                 }
-                if ( normalizeInput )
-                {
+                if (normalizeInput) {
                     // deal with normalization issues ...
-                    if ( ch == '\r' )
-                    {
+                    if (ch == '\r') {
                         normalizedCR = true;
                         posStart = cdStart - bufAbsoluteStart;
                         posEnd = pos - 1; // posEnd is alreadys set
-                        if ( !usePC )
-                        {
-                            if ( posEnd > posStart )
-                            {
+                        if (!usePC) {
+                            if (posEnd > posStart) {
                                 joinPC();
-                            }
-                            else
-                            {
+                            } else {
                                 usePC = true;
                                 pcStart = pcEnd = 0;
                             }
                         }
                         // assert usePC == true;
-                        if ( pcEnd >= pc.length )
-                            ensurePC( pcEnd );
+                        if (pcEnd >= pc.length) ensurePC(pcEnd);
                         pc[pcEnd++] = '\n';
-                    }
-                    else if ( ch == '\n' )
-                    {
-                        if ( !normalizedCR && usePC )
-                        {
-                            if ( pcEnd >= pc.length )
-                                ensurePC( pcEnd );
+                    } else if (ch == '\n') {
+                        if (!normalizedCR && usePC) {
+                            if (pcEnd >= pc.length) ensurePC(pcEnd);
                             pc[pcEnd++] = '\n';
                         }
                         normalizedCR = false;
-                    }
-                    else
-                    {
-                        if ( usePC )
-                        {
-                            if ( pcEnd >= pc.length )
-                                ensurePC( pcEnd );
+                    } else {
+                        if (usePC) {
+                            if (pcEnd >= pc.length) ensurePC(pcEnd);
                             pc[pcEnd++] = ch;
                         }
                         normalizedCR = false;
                     }
                 }
             }
-        }
-        catch ( EOFException ex )
-        {
+        } catch (EOFException ex) {
             // detect EOF and create meaningful error ...
-            throw new XmlPullParserException( "CDATA section started on line " + curLine + " and column " + curColumn
-                + " was not closed", this, ex );
+            throw new XmlPullParserException(
+                    "CDATA section started on line " + curLine + " and column " + curColumn + " was not closed",
+                    this,
+                    ex);
         }
-        if ( normalizeInput )
-        {
-            if ( usePC )
-            {
+        if (normalizeInput) {
+            if (usePC) {
                 pcEnd = pcEnd - 2;
             }
         }
@@ -3827,46 +3051,36 @@ else if ( ch == '\n' )
         posEnd = pos - 3;
     }
 
-    private void fillBuf()
-        throws IOException, XmlPullParserException
-    {
-        if ( reader == null )
-            throw new XmlPullParserException( "reader must be set before parsing is started" );
+    private void fillBuf() throws IOException, XmlPullParserException {
+        if (reader == null) throw new XmlPullParserException("reader must be set before parsing is started");
 
         // see if we are in compaction area
-        if ( bufEnd > bufSoftLimit )
-        {
+        if (bufEnd > bufSoftLimit) {
 
             // check if we need to compact or expand the buffer
-            boolean compact = !preventBufferCompaction
-                    && ( bufStart > bufSoftLimit || bufStart >= buf.length / 2 );
+            boolean compact = !preventBufferCompaction && (bufStart > bufSoftLimit || bufStart >= buf.length / 2);
 
             // if buffer almost full then compact it
-            if ( compact )
-            {
+            if (compact) {
                 // TODO: look on trashing
                 // //assert bufStart > 0
-                System.arraycopy( buf, bufStart, buf, 0, bufEnd - bufStart );
-                if ( TRACE_SIZING )
-                    System.out.println( "TRACE_SIZING fillBuf() compacting " + bufStart + " bufEnd=" + bufEnd + " pos="
-                        + pos + " posStart=" + posStart + " posEnd=" + posEnd + " buf first 100 chars:"
-                        + new String( buf, bufStart, Math.min(bufEnd - bufStart, 100)) );
+                System.arraycopy(buf, bufStart, buf, 0, bufEnd - bufStart);
+                if (TRACE_SIZING)
+                    System.out.println("TRACE_SIZING fillBuf() compacting " + bufStart + " bufEnd=" + bufEnd + " pos="
+                            + pos + " posStart=" + posStart + " posEnd=" + posEnd + " buf first 100 chars:"
+                            + new String(buf, bufStart, Math.min(bufEnd - bufStart, 100)));
 
-            }
-            else
-            {
+            } else {
                 final int newSize = 2 * buf.length;
                 final char[] newBuf = new char[newSize];
-                if ( TRACE_SIZING )
-                    System.out.println( "TRACE_SIZING fillBuf() " + buf.length + " => " + newSize );
-                System.arraycopy( buf, bufStart, newBuf, 0, bufEnd - bufStart );
+                if (TRACE_SIZING) System.out.println("TRACE_SIZING fillBuf() " + buf.length + " => " + newSize);
+                System.arraycopy(buf, bufStart, newBuf, 0, bufEnd - bufStart);
                 buf = newBuf;
-                if ( bufLoadFactor > 0 )
-                {
-                    // Include a fix for https://web.archive.org/web/20070831191548/http://www.extreme.indiana.edu/bugzilla/show_bug.cgi?id=228
-					bufSoftLimit = (int) ( bufferLoadFactor * buf.length );
+                if (bufLoadFactor > 0) {
+                    // Include a fix for
+                    // https://web.archive.org/web/20070831191548/http://www.extreme.indiana.edu/bugzilla/show_bug.cgi?id=228
+                    bufSoftLimit = (int) (bufferLoadFactor * buf.length);
                 }
-
             }
             bufEnd -= bufStart;
             pos -= bufStart;
@@ -3874,123 +3088,107 @@ private void fillBuf()
             posEnd -= bufStart;
             bufAbsoluteStart += bufStart;
             bufStart = 0;
-            if ( TRACE_SIZING )
-                System.out.println( "TRACE_SIZING fillBuf() after bufEnd=" + bufEnd + " pos=" + pos + " posStart="
-                    + posStart + " posEnd=" + posEnd + " buf first 100 chars:"
-                    + new String( buf, 0, Math.min(bufEnd, 100)) );
+            if (TRACE_SIZING)
+                System.out.println("TRACE_SIZING fillBuf() after bufEnd=" + bufEnd + " pos=" + pos + " posStart="
+                        + posStart + " posEnd=" + posEnd + " buf first 100 chars:"
+                        + new String(buf, 0, Math.min(bufEnd, 100)));
         }
         // at least one character must be read or error
         final int len = Math.min(buf.length - bufEnd, READ_CHUNK_SIZE);
-        final int ret = reader.read( buf, bufEnd, len );
-        if ( ret > 0 )
-        {
+        final int ret = reader.read(buf, bufEnd, len);
+        if (ret > 0) {
             bufEnd += ret;
-            if ( TRACE_SIZING )
-                System.out.println( "TRACE_SIZING fillBuf() after filling in buffer" + " buf first 100 chars:"
-                    + new String( buf, 0, Math.min(bufEnd, 100)) );
+            if (TRACE_SIZING)
+                System.out.println("TRACE_SIZING fillBuf() after filling in buffer" + " buf first 100 chars:"
+                        + new String(buf, 0, Math.min(bufEnd, 100)));
 
             return;
         }
-        if ( ret == -1 )
-        {
-            if ( bufAbsoluteStart == 0 && pos == 0 )
-            {
-                throw new EOFException( "input contained no data" );
-            }
-            else
-            {
-                if ( seenRoot && depth == 0 )
-                { // inside parsing epilog!!!
+        if (ret == -1) {
+            if (bufAbsoluteStart == 0 && pos == 0) {
+                throw new EOFException("input contained no data");
+            } else {
+                if (seenRoot && depth == 0) { // inside parsing epilog!!!
                     reachedEnd = true;
                     return;
-                }
-                else
-                {
+                } else {
                     StringBuilder expectedTagStack = new StringBuilder();
-                    if ( depth > 0 )
-                    {
-                        if ( elRawName == null || elRawName[depth] == null )
-                        {
-                            String tagName = new String( buf, posStart + 1, pos - posStart - 1 );
-                            expectedTagStack.append( " - expected the opening tag <" ).append( tagName ).append( "...>" );
-                        }
-                        else
-                        {
+                    if (depth > 0) {
+                        if (elRawName == null || elRawName[depth] == null) {
+                            String tagName = new String(buf, posStart + 1, pos - posStart - 1);
+                            expectedTagStack
+                                    .append(" - expected the opening tag <")
+                                    .append(tagName)
+                                    .append("...>");
+                        } else {
                             // final char[] cbuf = elRawName[depth];
                             // final String startname = new String(cbuf, 0, elRawNameEnd[depth]);
-                            expectedTagStack.append( " - expected end tag" );
-                            if ( depth > 1 )
-                            {
-                                expectedTagStack.append( "s" ); // more than one end tag
+                            expectedTagStack.append(" - expected end tag");
+                            if (depth > 1) {
+                                expectedTagStack.append("s"); // more than one end tag
                             }
-                            expectedTagStack.append( " " );
-
-                            for ( int i = depth; i > 0; i-- )
-                            {
-                                if ( elRawName == null || elRawName[i] == null )
-                                {
-                                    String tagName = new String( buf, posStart + 1, pos - posStart - 1 );
-                                    expectedTagStack.append( " - expected the opening tag <" ).append( tagName ).append( "...>" );
-                                }
-                                else
-                                {
-                                    String tagName = new String( elRawName[i], 0, elRawNameEnd[i] );
-                                    expectedTagStack.append( "' );
+                            expectedTagStack.append(" ");
+
+                            for (int i = depth; i > 0; i--) {
+                                if (elRawName == null || elRawName[i] == null) {
+                                    String tagName = new String(buf, posStart + 1, pos - posStart - 1);
+                                    expectedTagStack
+                                            .append(" - expected the opening tag <")
+                                            .append(tagName)
+                                            .append("...>");
+                                } else {
+                                    String tagName = new String(elRawName[i], 0, elRawNameEnd[i]);
+                                    expectedTagStack
+                                            .append("');
                                 }
                             }
-                            expectedTagStack.append( " to close" );
-                            for ( int i = depth; i > 0; i-- )
-                            {
-                                if ( i != depth )
-                                {
-                                    expectedTagStack.append( " and" ); // more than one end tag
-                                }
-                                if ( elRawName == null || elRawName[i] == null )
-                                {
-                                    String tagName = new String( buf, posStart + 1, pos - posStart - 1 );
-                                    expectedTagStack.append( " start tag <" ).append( tagName ).append( ">" );
-                                    expectedTagStack.append( " from line " ).append( elRawNameLine[i] );
+                            expectedTagStack.append(" to close");
+                            for (int i = depth; i > 0; i--) {
+                                if (i != depth) {
+                                    expectedTagStack.append(" and"); // more than one end tag
                                 }
-                                else
-                                {
-                                String tagName = new String( elRawName[i], 0, elRawNameEnd[i] );
-                                expectedTagStack.append( " start tag <" ).append( tagName ).append( ">" );
-                                expectedTagStack.append( " from line " ).append( elRawNameLine[i] );
+                                if (elRawName == null || elRawName[i] == null) {
+                                    String tagName = new String(buf, posStart + 1, pos - posStart - 1);
+                                    expectedTagStack
+                                            .append(" start tag <")
+                                            .append(tagName)
+                                            .append(">");
+                                    expectedTagStack.append(" from line ").append(elRawNameLine[i]);
+                                } else {
+                                    String tagName = new String(elRawName[i], 0, elRawNameEnd[i]);
+                                    expectedTagStack
+                                            .append(" start tag <")
+                                            .append(tagName)
+                                            .append(">");
+                                    expectedTagStack.append(" from line ").append(elRawNameLine[i]);
                                 }
                             }
-                            expectedTagStack.append( ", parser stopped on" );
+                            expectedTagStack.append(", parser stopped on");
                         }
                     }
-                    throw new EOFException( "no more data available" + expectedTagStack.toString()
-                        + getPositionDescription() );
+                    throw new EOFException(
+                            "no more data available" + expectedTagStack.toString() + getPositionDescription());
                 }
             }
-        }
-        else
-        {
-            throw new IOException( "error reading input, returned " + ret );
+        } else {
+            throw new IOException("error reading input, returned " + ret);
         }
     }
 
-    private char more()
-        throws IOException, XmlPullParserException
-    {
-        if ( pos >= bufEnd )
-        {
+    private char more() throws IOException, XmlPullParserException {
+        if (pos >= bufEnd) {
             fillBuf();
             // this return value should be ignored as it is used in epilog parsing ...
-            if ( reachedEnd )
-                throw new EOFException( "no more data available" + getPositionDescription() );
+            if (reachedEnd) throw new EOFException("no more data available" + getPositionDescription());
         }
         final char ch = buf[pos++];
         // line/columnNumber
-        if ( ch == '\n' )
-        {
+        if (ch == '\n') {
             ++lineNumber;
             columnNumber = 1;
-        }
-        else
-        {
+        } else {
             ++columnNumber;
         }
         // System.out.print(ch);
@@ -4007,53 +3205,44 @@ private char more()
     // return pos + bufAbsoluteStart;
     // }
 
-    private void ensurePC( int end )
-    {
+    private void ensurePC(int end) {
         // assert end >= pc.length;
         final int newSize = end > READ_CHUNK_SIZE ? 2 * end : 2 * READ_CHUNK_SIZE;
         final char[] newPC = new char[newSize];
-        if ( TRACE_SIZING )
-            System.out.println( "TRACE_SIZING ensurePC() " + pc.length + " ==> " + newSize + " end=" + end );
-        System.arraycopy( pc, 0, newPC, 0, pcEnd );
+        if (TRACE_SIZING)
+            System.out.println("TRACE_SIZING ensurePC() " + pc.length + " ==> " + newSize + " end=" + end);
+        System.arraycopy(pc, 0, newPC, 0, pcEnd);
         pc = newPC;
         // assert end < pc.length;
     }
 
-    private void joinPC()
-    {
+    private void joinPC() {
         // assert usePC == false;
         // assert posEnd > posStart;
         final int len = posEnd - posStart;
         final int newEnd = pcEnd + len + 1;
-        if ( newEnd >= pc.length )
-            ensurePC( newEnd ); // add 1 for extra space for one char
+        if (newEnd >= pc.length) ensurePC(newEnd); // add 1 for extra space for one char
         // assert newEnd < pc.length;
-        System.arraycopy( buf, posStart, pc, pcEnd, len );
+        System.arraycopy(buf, posStart, pc, pcEnd, len);
         pcEnd += len;
         usePC = true;
-
     }
 
-    private char requireInput( char ch, char[] input )
-        throws XmlPullParserException, IOException
-    {
-        for ( char anInput : input )
-        {
-            if ( ch != anInput )
-            {
-                throw new XmlPullParserException( "expected " + printable( anInput ) + " in " + new String( input )
-                    + " and not " + printable( ch ), this, null );
+    private char requireInput(char ch, char[] input) throws XmlPullParserException, IOException {
+        for (char anInput : input) {
+            if (ch != anInput) {
+                throw new XmlPullParserException(
+                        "expected " + printable(anInput) + " in " + new String(input) + " and not " + printable(ch),
+                        this,
+                        null);
             }
             ch = more();
         }
         return ch;
     }
 
-    private char skipS( char ch )
-        throws XmlPullParserException, IOException
-    {
-        while ( isS( ch ) )
-        {
+    private char skipS(char ch) throws XmlPullParserException, IOException {
+        while (isS(ch)) {
             ch = more();
         } // skip additional spaces
         return ch;
@@ -4070,48 +3259,40 @@ private char skipS( char ch )
 
     private static final boolean[] lookupNameChar = new boolean[LOOKUP_MAX];
 
-    private static void setName( char ch )
-    // { lookupNameChar[ (int)ch / 32 ] |= (1 << (ch % 32)); }
-    {
+    private static void setName(char ch)
+                // { lookupNameChar[ (int)ch / 32 ] |= (1 << (ch % 32)); }
+            {
         lookupNameChar[ch] = true;
     }
 
-    private static void setNameStart( char ch )
-    // { lookupNameStartChar[ (int)ch / 32 ] |= (1 << (ch % 32)); setName(ch); }
-    {
+    private static void setNameStart(char ch)
+                // { lookupNameStartChar[ (int)ch / 32 ] |= (1 << (ch % 32)); setName(ch); }
+            {
         lookupNameStartChar[ch] = true;
-        setName( ch );
+        setName(ch);
     }
 
-    static
-    {
-        setNameStart( ':' );
-        for ( char ch = 'A'; ch <= 'Z'; ++ch )
-            setNameStart( ch );
-        setNameStart( '_' );
-        for ( char ch = 'a'; ch <= 'z'; ++ch )
-            setNameStart( ch );
-        for ( char ch = '\u00c0'; ch <= '\u02FF'; ++ch )
-            setNameStart( ch );
-        for ( char ch = '\u0370'; ch <= '\u037d'; ++ch )
-            setNameStart( ch );
-        for ( char ch = '\u037f'; ch < '\u0400'; ++ch )
-            setNameStart( ch );
-
-        setName( '-' );
-        setName( '.' );
-        for ( char ch = '0'; ch <= '9'; ++ch )
-            setName( ch );
-        setName( '\u00b7' );
-        for ( char ch = '\u0300'; ch <= '\u036f'; ++ch )
-            setName( ch );
+    static {
+        setNameStart(':');
+        for (char ch = 'A'; ch <= 'Z'; ++ch) setNameStart(ch);
+        setNameStart('_');
+        for (char ch = 'a'; ch <= 'z'; ++ch) setNameStart(ch);
+        for (char ch = '\u00c0'; ch <= '\u02FF'; ++ch) setNameStart(ch);
+        for (char ch = '\u0370'; ch <= '\u037d'; ++ch) setNameStart(ch);
+        for (char ch = '\u037f'; ch < '\u0400'; ++ch) setNameStart(ch);
+
+        setName('-');
+        setName('.');
+        for (char ch = '0'; ch <= '9'; ++ch) setName(ch);
+        setName('\u00b7');
+        for (char ch = '\u0300'; ch <= '\u036f'; ++ch) setName(ch);
     }
 
     // protected boolean isNameStartChar( char ch )
-    private static boolean isNameStartChar( char ch )
-    {
-        return ch < LOOKUP_MAX_CHAR ? lookupNameStartChar[ch] : ( ch <= '\u2027' )
-            || ( ch >= '\u202A' && ch <= '\u218F' ) || ( ch >= '\u2800' && ch <= '\uFFEF' );
+    private static boolean isNameStartChar(char ch) {
+        return ch < LOOKUP_MAX_CHAR
+                ? lookupNameStartChar[ch]
+                : (ch <= '\u2027') || (ch >= '\u202A' && ch <= '\u218F') || (ch >= '\u2800' && ch <= '\uFFEF');
 
         // if(ch < LOOKUP_MAX_CHAR) return lookupNameStartChar[ ch ];
         // else return ch <= '\u2027'
@@ -4135,14 +3316,14 @@ private static boolean isNameStartChar( char ch )
     }
 
     // protected boolean isNameChar( char ch )
-    private static boolean isNameChar( char ch )
-    {
+    private static boolean isNameChar(char ch) {
         // return isNameStartChar(ch);
 
         // if(ch < LOOKUP_MAX_CHAR) return (lookupNameChar[ (int)ch / 32 ] & (1 << (ch % 32))) != 0;
 
-        return ch < LOOKUP_MAX_CHAR ? lookupNameChar[ch] : ( ch <= '\u2027' )
-            || ( ch >= '\u202A' && ch <= '\u218F' ) || ( ch >= '\u2800' && ch <= '\uFFEF' );
+        return ch < LOOKUP_MAX_CHAR
+                ? lookupNameChar[ch]
+                : (ch <= '\u2027') || (ch >= '\u202A' && ch <= '\u218F') || (ch >= '\u2800' && ch <= '\uFFEF');
         // return false;
         // return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || ch == ':'
         // || (ch >= '0' && ch <= '9');
@@ -4159,9 +3340,8 @@ private static boolean isNameChar( char ch )
         // else return false;
     }
 
-    private static boolean isS( char ch )
-    {
-        return ( ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t' );
+    private static boolean isS(char ch) {
+        return (ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t');
         // || (supportXml11 && (ch == '\u0085' || ch == '\u2028');
     }
 
@@ -4169,52 +3349,36 @@ private static boolean isS( char ch )
     // ch != '\u0000' ch < '\uFFFE'
 
     // private char printable(char ch) { return ch; }
-    private static String printable( int ch )
-    {
-        if ( ch == '\n' )
-        {
+    private static String printable(int ch) {
+        if (ch == '\n') {
             return "\\n";
-        }
-        else if ( ch == '\r' )
-        {
+        } else if (ch == '\r') {
             return "\\r";
-        }
-        else if ( ch == '\t' )
-        {
+        } else if (ch == '\t') {
             return "\\t";
-        }
-        else if ( ch == '\'' )
-        {
+        } else if (ch == '\'') {
             return "\\'";
         }
-        if ( ch > 127 || ch < 32 )
-        {
-            return "\\u" + Integer.toHexString( ch );
-        }
-        if ( Character.isBmpCodePoint( ch ) )
-        {
-            return Character.toString( ( char ) ch );
+        if (ch > 127 || ch < 32) {
+            return "\\u" + Integer.toHexString(ch);
         }
-        else
-        {
-            return new String( new char[] { Character.highSurrogate( ch ), Character.lowSurrogate( ch ) } );
+        if (Character.isBmpCodePoint(ch)) {
+            return Character.toString((char) ch);
+        } else {
+            return new String(new char[] {Character.highSurrogate(ch), Character.lowSurrogate(ch)});
         }
     }
 
-    private static String printable( String s )
-    {
-        if ( s == null )
-            return null;
+    private static String printable(String s) {
+        if (s == null) return null;
         final int sLen = s.codePointCount(0, s.length());
-        StringBuilder buf = new StringBuilder( sLen + 10 );
-        for ( int i = 0; i < sLen; ++i )
-        {
-            buf.append( printable( s.codePointAt( i ) ) );
+        StringBuilder buf = new StringBuilder(sLen + 10);
+        for (int i = 0; i < sLen; ++i) {
+            buf.append(printable(s.codePointAt(i)));
         }
         s = buf.toString();
         return s;
     }
-
 }
 
 /*
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 c69db3f4..e69d28f8 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
@@ -25,27 +25,25 @@
  * 
  • PROPERTY_SERIALIZER_LINE_SEPARATOR * */ -public class MXSerializer - implements XmlSerializer -{ - protected final static String XML_URI = "http://www.w3.org/XML/1998/namespace"; +public class MXSerializer implements XmlSerializer { + protected static final String XML_URI = "http://www.w3.org/XML/1998/namespace"; - protected final static String XMLNS_URI = "http://www.w3.org/2000/xmlns/"; + protected static final String XMLNS_URI = "http://www.w3.org/2000/xmlns/"; private static final boolean TRACE_SIZING = false; protected final String FEATURE_SERIALIZER_ATTVALUE_USE_APOSTROPHE = - "http://xmlpull.org/v1/doc/features.html#serializer-attvalue-use-apostrophe"; + "http://xmlpull.org/v1/doc/features.html#serializer-attvalue-use-apostrophe"; protected final String FEATURE_NAMES_INTERNED = "http://xmlpull.org/v1/doc/features.html#names-interned"; protected final String PROPERTY_SERIALIZER_INDENTATION = - "http://xmlpull.org/v1/doc/properties.html#serializer-indentation"; + "http://xmlpull.org/v1/doc/properties.html#serializer-indentation"; protected final String PROPERTY_SERIALIZER_LINE_SEPARATOR = - "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator"; + "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator"; - protected final static String PROPERTY_LOCATION = "http://xmlpull.org/v1/doc/properties.html#location"; + protected static final String PROPERTY_LOCATION = "http://xmlpull.org/v1/doc/properties.html#location"; // properties/features protected boolean namesInterned; @@ -101,36 +99,30 @@ public class MXSerializer protected static final String precomputedPrefixes[]; - static - { + static { precomputedPrefixes = new String[32]; // arbitrary number ... - for ( int i = 0; i < precomputedPrefixes.length; i++ ) - { - precomputedPrefixes[i] = ( "n" + i ).intern(); + for (int i = 0; i < precomputedPrefixes.length; i++) { + precomputedPrefixes[i] = ("n" + i).intern(); } } private boolean checkNamesInterned = false; - private void checkInterning( String name ) - { - if ( namesInterned && name != name.intern() ) - { - throw new IllegalArgumentException( "all names passed as arguments must be interned" - + "when NAMES INTERNED feature is enabled" ); + private void checkInterning(String name) { + if (namesInterned && name != name.intern()) { + throw new IllegalArgumentException( + "all names passed as arguments must be interned" + "when NAMES INTERNED feature is enabled"); } } - protected void reset() - { + protected void reset() { location = null; out = null; autoDeclaredPrefixes = 0; depth = 0; // nullify references on all levels to allow it to be GCed - for ( int i = 0; i < elNamespaceCount.length; i++ ) - { + for (int i = 0; i < elNamespaceCount.length; i++) { elName[i] = null; elNamespace[i] = null; elNamespaceCount[i] = 2; @@ -165,59 +157,49 @@ protected void reset() seenBracketBracket = false; } - protected void ensureElementsCapacity() - { + protected void ensureElementsCapacity() { final int elStackSize = elName.length; // assert (depth + 1) >= elName.length; // we add at least one extra slot ... - final int newSize = ( depth >= 7 ? 2 * depth : 8 ) + 2; // = lucky 7 + 1 //25 - if ( TRACE_SIZING ) - { - System.err.println( getClass().getName() + " elStackSize " + elStackSize + " ==> " + newSize ); + final int newSize = (depth >= 7 ? 2 * depth : 8) + 2; // = lucky 7 + 1 //25 + if (TRACE_SIZING) { + System.err.println(getClass().getName() + " elStackSize " + elStackSize + " ==> " + newSize); } final boolean needsCopying = elStackSize > 0; String[] arr = null; // reuse arr local variable slot arr = new String[newSize]; - if ( needsCopying ) - System.arraycopy( elName, 0, arr, 0, elStackSize ); + if (needsCopying) System.arraycopy(elName, 0, arr, 0, elStackSize); elName = arr; arr = new String[newSize]; - if ( needsCopying ) - System.arraycopy( elNamespace, 0, arr, 0, elStackSize ); + if (needsCopying) System.arraycopy(elNamespace, 0, arr, 0, elStackSize); elNamespace = arr; final int[] iarr = new int[newSize]; - if ( needsCopying ) - { - System.arraycopy( elNamespaceCount, 0, iarr, 0, elStackSize ); - } - else - { + if (needsCopying) { + System.arraycopy(elNamespaceCount, 0, iarr, 0, elStackSize); + } else { // special initialization iarr[0] = 0; } elNamespaceCount = iarr; } - protected void ensureNamespacesCapacity() - { // int size) { + protected void ensureNamespacesCapacity() { // int size) { // int namespaceSize = namespacePrefix != null ? namespacePrefix.length : 0; // assert (namespaceEnd >= namespacePrefix.length); // if(size >= namespaceSize) { // int newSize = size > 7 ? 2 * size : 8; // = lucky 7 + 1 //25 final int newSize = namespaceEnd > 7 ? 2 * namespaceEnd : 8; - if ( TRACE_SIZING ) - { - System.err.println( getClass().getName() + " namespaceSize " + namespacePrefix.length + " ==> " + newSize ); + if (TRACE_SIZING) { + System.err.println(getClass().getName() + " namespaceSize " + namespacePrefix.length + " ==> " + newSize); } final String[] newNamespacePrefix = new String[newSize]; final String[] newNamespaceUri = new String[newSize]; - if ( namespacePrefix != null ) - { - System.arraycopy( namespacePrefix, 0, newNamespacePrefix, 0, namespaceEnd ); - System.arraycopy( namespaceUri, 0, newNamespaceUri, 0, namespaceEnd ); + if (namespacePrefix != null) { + System.arraycopy(namespacePrefix, 0, newNamespacePrefix, 0, namespaceEnd); + System.arraycopy(namespaceUri, 0, newNamespaceUri, 0, namespaceEnd); } namespacePrefix = newNamespacePrefix; namespaceUri = newNamespaceUri; @@ -237,45 +219,29 @@ protected void ensureNamespacesCapacity() } @Override - public void setFeature( String name, boolean state ) - throws IllegalArgumentException, IllegalStateException - { - if ( name == null ) - { - throw new IllegalArgumentException( "feature name can not be null" ); + public void setFeature(String name, boolean state) throws IllegalArgumentException, IllegalStateException { + if (name == null) { + throw new IllegalArgumentException("feature name can not be null"); } - if ( FEATURE_NAMES_INTERNED.equals( name ) ) - { + if (FEATURE_NAMES_INTERNED.equals(name)) { namesInterned = state; - } - else if ( FEATURE_SERIALIZER_ATTVALUE_USE_APOSTROPHE.equals( name ) ) - { + } else if (FEATURE_SERIALIZER_ATTVALUE_USE_APOSTROPHE.equals(name)) { attributeUseApostrophe = state; - } - else - { - throw new IllegalStateException( "unsupported feature " + name ); + } else { + throw new IllegalStateException("unsupported feature " + name); } } @Override - public boolean getFeature( String name ) - throws IllegalArgumentException - { - if ( name == null ) - { - throw new IllegalArgumentException( "feature name can not be null" ); + public boolean getFeature(String name) throws IllegalArgumentException { + if (name == null) { + throw new IllegalArgumentException("feature name can not be null"); } - if ( FEATURE_NAMES_INTERNED.equals( name ) ) - { + if (FEATURE_NAMES_INTERNED.equals(name)) { return namesInterned; - } - else if ( FEATURE_SERIALIZER_ATTVALUE_USE_APOSTROPHE.equals( name ) ) - { + } else if (FEATURE_SERIALIZER_ATTVALUE_USE_APOSTROPHE.equals(name)) { return attributeUseApostrophe; - } - else - { + } else { return false; } } @@ -297,86 +263,64 @@ else if ( FEATURE_SERIALIZER_ATTVALUE_USE_APOSTROPHE.equals( name ) ) * For maximum efficiency when writing indents the required output is pre-computed This is internal function that * recomputes buffer after user requested changes. */ - protected void rebuildIndentationBuf() - { - if ( doIndent == false ) - return; + protected void rebuildIndentationBuf() { + if (doIndent == false) return; final int maxIndent = 65; // hardcoded maximum indentation size in characters int bufSize = 0; offsetNewLine = 0; - if ( writeLineSeparator ) - { + if (writeLineSeparator) { offsetNewLine = lineSeparator.length(); bufSize += offsetNewLine; } maxIndentLevel = 0; - if ( writeIndentation ) - { + if (writeIndentation) { indentationJump = indentationString.length(); maxIndentLevel = maxIndent / indentationJump; bufSize += maxIndentLevel * indentationJump; } - if ( indentationBuf == null || indentationBuf.length < bufSize ) - { + if (indentationBuf == null || indentationBuf.length < bufSize) { indentationBuf = new char[bufSize + 8]; } int bufPos = 0; - if ( writeLineSeparator ) - { - for ( int i = 0; i < lineSeparator.length(); i++ ) - { - indentationBuf[bufPos++] = lineSeparator.charAt( i ); + if (writeLineSeparator) { + for (int i = 0; i < lineSeparator.length(); i++) { + indentationBuf[bufPos++] = lineSeparator.charAt(i); } } - if ( writeIndentation ) - { - for ( int i = 0; i < maxIndentLevel; i++ ) - { - for ( int j = 0; j < indentationString.length(); j++ ) - { - indentationBuf[bufPos++] = indentationString.charAt( j ); + if (writeIndentation) { + for (int i = 0; i < maxIndentLevel; i++) { + for (int j = 0; j < indentationString.length(); j++) { + indentationBuf[bufPos++] = indentationString.charAt(j); } } } } // if(doIndent) writeIndent(); - protected void writeIndent() - throws IOException - { + protected void writeIndent() throws IOException { final int start = writeLineSeparator ? 0 : offsetNewLine; - final int level = ( depth > maxIndentLevel ) ? maxIndentLevel : depth; - out.write( indentationBuf, start, ( level * indentationJump ) + offsetNewLine ); + final int level = (depth > maxIndentLevel) ? maxIndentLevel : depth; + out.write(indentationBuf, start, (level * indentationJump) + offsetNewLine); } @Override - public void setProperty( String name, Object value ) - throws IllegalArgumentException, IllegalStateException - { - if ( name == null ) - { - throw new IllegalArgumentException( "property name can not be null" ); + public void setProperty(String name, Object value) throws IllegalArgumentException, IllegalStateException { + if (name == null) { + throw new IllegalArgumentException("property name can not be null"); } - if ( PROPERTY_SERIALIZER_INDENTATION.equals( name ) ) - { + if (PROPERTY_SERIALIZER_INDENTATION.equals(name)) { indentationString = (String) value; - } - else if ( PROPERTY_SERIALIZER_LINE_SEPARATOR.equals( name ) ) - { + } else if (PROPERTY_SERIALIZER_LINE_SEPARATOR.equals(name)) { lineSeparator = (String) value; - } - else if ( PROPERTY_LOCATION.equals( name ) ) - { + } else if (PROPERTY_LOCATION.equals(name)) { location = (String) value; - } - else - { - throw new IllegalStateException( "unsupported property " + name ); + } else { + throw new IllegalStateException("unsupported property " + name); } writeLineSeparator = lineSeparator != null && lineSeparator.length() > 0; writeIndentation = indentationString != null && indentationString.length() > 0; // optimize - do not write when nothing to write ... - doIndent = indentationString != null && ( writeLineSeparator || writeIndentation ); + doIndent = indentationString != null && (writeLineSeparator || writeIndentation); // NOTE: when indentationString == null there is no indentation // (even though writeLineSeparator may be true ...) rebuildIndentationBuf(); @@ -384,125 +328,91 @@ else if ( PROPERTY_LOCATION.equals( name ) ) } @Override - public Object getProperty( String name ) - throws IllegalArgumentException - { - if ( name == null ) - { - throw new IllegalArgumentException( "property name can not be null" ); + public Object getProperty(String name) throws IllegalArgumentException { + if (name == null) { + throw new IllegalArgumentException("property name can not be null"); } - if ( PROPERTY_SERIALIZER_INDENTATION.equals( name ) ) - { + if (PROPERTY_SERIALIZER_INDENTATION.equals(name)) { return indentationString; - } - else if ( PROPERTY_SERIALIZER_LINE_SEPARATOR.equals( name ) ) - { + } else if (PROPERTY_SERIALIZER_LINE_SEPARATOR.equals(name)) { return lineSeparator; - } - else if ( PROPERTY_LOCATION.equals( name ) ) - { + } else if (PROPERTY_LOCATION.equals(name)) { return location; - } - else - { + } else { return null; } } - private String getLocation() - { + private String getLocation() { return location != null ? " @" + location : ""; } // this is special method that can be accessed directly to retrieve Writer serializer is using - public Writer getWriter() - { + public Writer getWriter() { return out; } @Override - public void setOutput( Writer writer ) - { + public void setOutput(Writer writer) { reset(); out = writer; } @Override - public void setOutput( OutputStream os, String encoding ) - throws IOException - { - if ( os == null ) - throw new IllegalArgumentException( "output stream can not be null" ); + public void setOutput(OutputStream os, String encoding) throws IOException { + if (os == null) throw new IllegalArgumentException("output stream can not be null"); reset(); - if ( encoding != null ) - { - out = new OutputStreamWriter( os, encoding ); - } - else - { - out = new OutputStreamWriter( os ); + if (encoding != null) { + out = new OutputStreamWriter(os, encoding); + } else { + out = new OutputStreamWriter(os); } } @Override - public void startDocument( String encoding, Boolean standalone ) - throws IOException - { + public void startDocument(String encoding, Boolean standalone) throws IOException { char apos = attributeUseApostrophe ? '\'' : '"'; - if ( attributeUseApostrophe ) - { - out.write( "" ); - if ( writeLineSeparator ) - { - out.write( lineSeparator ); + out.write("?>"); + if (writeLineSeparator) { + out.write(lineSeparator); } } @Override - public void endDocument() - throws IOException - { + public void endDocument() throws IOException { // close all unclosed tag; - while ( depth > 0 ) - { - endTag( elNamespace[depth], elName[depth] ); + while (depth > 0) { + endTag(elNamespace[depth], elName[depth]); } - if ( writeLineSeparator ) - { - out.write( lineSeparator ); + if (writeLineSeparator) { + out.write(lineSeparator); } // assert depth == 0; // assert startTagIncomplete == false; @@ -511,54 +421,37 @@ public void endDocument() } @Override - public void setPrefix( String prefix, String namespace ) - throws IOException - { - if ( startTagIncomplete ) - closeStartTag(); + public void setPrefix(String prefix, String namespace) throws IOException { + if (startTagIncomplete) closeStartTag(); // assert prefix != null; // assert namespace != null; - if ( prefix == null ) - { + if (prefix == null) { prefix = ""; } - if ( !namesInterned ) - { + if (!namesInterned) { prefix = prefix.intern(); // will throw NPE if prefix==null - } - else if ( checkNamesInterned ) - { - checkInterning( prefix ); - } - else if ( prefix == null ) - { - throw new IllegalArgumentException( "prefix must be not null" + getLocation() ); + } else if (checkNamesInterned) { + checkInterning(prefix); + } else if (prefix == null) { + throw new IllegalArgumentException("prefix must be not null" + getLocation()); } // check that prefix is not duplicated ... - for ( int i = elNamespaceCount[depth]; i < namespaceEnd; i++ ) - { - if ( prefix == namespacePrefix[i] ) - { - throw new IllegalStateException( "duplicated prefix " + printable( prefix ) + getLocation() ); + for (int i = elNamespaceCount[depth]; i < namespaceEnd; i++) { + if (prefix == namespacePrefix[i]) { + throw new IllegalStateException("duplicated prefix " + printable(prefix) + getLocation()); } } - if ( !namesInterned ) - { + if (!namesInterned) { namespace = namespace.intern(); - } - else if ( checkNamesInterned ) - { - checkInterning( namespace ); - } - else if ( namespace == null ) - { - throw new IllegalArgumentException( "namespace must be not null" + getLocation() ); + } else if (checkNamesInterned) { + checkInterning(namespace); + } else if (namespace == null) { + throw new IllegalArgumentException("namespace must be not null" + getLocation()); } - if ( namespaceEnd >= namespacePrefix.length ) - { + if (namespaceEnd >= namespacePrefix.length) { ensureNamespacesCapacity(); } namespacePrefix[namespaceEnd] = prefix; @@ -567,44 +460,33 @@ else if ( namespace == null ) setPrefixCalled = true; } - protected String lookupOrDeclarePrefix( String namespace ) - { - return getPrefix( namespace, true ); + protected String lookupOrDeclarePrefix(String namespace) { + return getPrefix(namespace, true); } @Override - public String getPrefix( String namespace, boolean generatePrefix ) - { + public String getPrefix(String namespace, boolean generatePrefix) { // assert namespace != null; - if ( !namesInterned ) - { + if (!namesInterned) { // when String is interned we can do much faster namespace stack lookups ... namespace = namespace.intern(); - } - else if ( checkNamesInterned ) - { - checkInterning( namespace ); + } else if (checkNamesInterned) { + checkInterning(namespace); // assert namespace != namespace.intern(); } - if ( namespace == null ) - { - throw new IllegalArgumentException( "namespace must be not null" + getLocation() ); - } - else if ( namespace.length() == 0 ) - { - throw new IllegalArgumentException( "default namespace cannot have prefix" + getLocation() ); + if (namespace == null) { + throw new IllegalArgumentException("namespace must be not null" + getLocation()); + } else if (namespace.length() == 0) { + throw new IllegalArgumentException("default namespace cannot have prefix" + getLocation()); } // first check if namespace is already in scope - for ( int i = namespaceEnd - 1; i >= 0; --i ) - { - if ( namespace == namespaceUri[i] ) - { + for (int i = namespaceEnd - 1; i >= 0; --i) { + if (namespace == namespaceUri[i]) { final String prefix = namespacePrefix[i]; // now check that prefix is still in scope - for ( int p = namespaceEnd - 1; p > i; --p ) - { - if ( prefix == namespacePrefix[p] ) + for (int p = namespaceEnd - 1; p > i; --p) { + if (prefix == namespacePrefix[p]) continue; // too bad - prefix is redeclared with different namespace } return prefix; @@ -612,35 +494,29 @@ else if ( namespace.length() == 0 ) } // so not found it ... - if ( !generatePrefix ) - { + if (!generatePrefix) { return null; } - return generatePrefix( namespace ); + return generatePrefix(namespace); } - private String generatePrefix( String namespace ) - { + private String generatePrefix(String namespace) { // assert namespace == namespace.intern(); - while ( true ) - { + while (true) { ++autoDeclaredPrefixes; // fast lookup uses table that was pre-initialized in static{} .... - final String prefix = - autoDeclaredPrefixes < precomputedPrefixes.length ? precomputedPrefixes[autoDeclaredPrefixes] - : ( "n" + autoDeclaredPrefixes ).intern(); + final String prefix = autoDeclaredPrefixes < precomputedPrefixes.length + ? precomputedPrefixes[autoDeclaredPrefixes] + : ("n" + autoDeclaredPrefixes).intern(); // make sure this prefix is not declared in any scope (avoid hiding in-scope prefixes)! - for ( int i = namespaceEnd - 1; i >= 0; --i ) - { - if ( prefix == namespacePrefix[i] ) - { + for (int i = namespaceEnd - 1; i >= 0; --i) { + if (prefix == namespacePrefix[i]) { continue; // prefix is already declared - generate new and try again } } // declare prefix - if ( namespaceEnd >= namespacePrefix.length ) - { + if (namespaceEnd >= namespacePrefix.length) { ensureNamespacesCapacity(); } namespacePrefix[namespaceEnd] = prefix; @@ -652,84 +528,66 @@ private String generatePrefix( String namespace ) } @Override - public int getDepth() - { + public int getDepth() { return depth; } @Override - public String getNamespace() - { + public String getNamespace() { return elNamespace[depth]; } @Override - public String getName() - { + public String getName() { return elName[depth]; } @Override - public XmlSerializer startTag( String namespace, String name ) - throws IOException - { + public XmlSerializer startTag(String namespace, String name) throws IOException { - if ( startTagIncomplete ) - { + if (startTagIncomplete) { closeStartTag(); } seenBracket = seenBracketBracket = false; - if ( doIndent && depth > 0 && seenTag ) - { + if (doIndent && depth > 0 && seenTag) { writeIndent(); } seenTag = true; setPrefixCalled = false; startTagIncomplete = true; ++depth; - if ( ( depth + 1 ) >= elName.length ) - { + if ((depth + 1) >= elName.length) { ensureElementsCapacity(); } //// assert namespace != null; - if ( checkNamesInterned && namesInterned ) - checkInterning( namespace ); - elNamespace[depth] = ( namesInterned || namespace == null ) ? namespace : namespace.intern(); + if (checkNamesInterned && namesInterned) checkInterning(namespace); + elNamespace[depth] = (namesInterned || namespace == null) ? namespace : namespace.intern(); // assert name != null; // elName[ depth ] = name; - if ( checkNamesInterned && namesInterned ) - checkInterning( name ); - elName[depth] = ( namesInterned || name == null ) ? name : name.intern(); - if ( out == null ) - { - throw new IllegalStateException( "setOutput() must called set before serialization can start" ); + if (checkNamesInterned && namesInterned) checkInterning(name); + elName[depth] = (namesInterned || name == null) ? name : name.intern(); + if (out == null) { + throw new IllegalStateException("setOutput() must called set before serialization can start"); } - out.write( '<' ); - if ( namespace != null ) - { + out.write('<'); + if (namespace != null) { - if ( namespace.length() > 0 ) - { + if (namespace.length() > 0) { // ALEK: in future make it as feature on serializer String prefix = null; - if ( depth > 0 && ( namespaceEnd - elNamespaceCount[depth - 1] ) == 1 ) - { + if (depth > 0 && (namespaceEnd - elNamespaceCount[depth - 1]) == 1) { // if only one prefix was declared un-declare it if prefix is already declared on parent el with the // same URI String uri = namespaceUri[namespaceEnd - 1]; - if ( uri == namespace || uri.equals( namespace ) ) - { + if (uri == namespace || uri.equals(namespace)) { String elPfx = namespacePrefix[namespaceEnd - 1]; // 2 == to skip predefined namespaces (xml and xmlns ...) - for ( int pos = elNamespaceCount[depth - 1] - 1; pos >= 2; --pos ) - { + for (int pos = elNamespaceCount[depth - 1] - 1; pos >= 2; --pos) { String pf = namespacePrefix[pos]; - if ( pf == elPfx || pf.equals( elPfx ) ) - { + if (pf == elPfx || pf.equals(elPfx)) { String n = namespaceUri[pos]; - if ( n == uri || n.equals( uri ) ) - { + if (n == uri || n.equals(uri)) { --namespaceEnd; // un-declare namespace prefix = elPfx; } @@ -738,224 +596,175 @@ public XmlSerializer startTag( String namespace, String name ) } } } - if ( prefix == null ) - { - prefix = lookupOrDeclarePrefix( namespace ); + if (prefix == null) { + prefix = lookupOrDeclarePrefix(namespace); } // assert prefix != null; // make sure that default ("") namespace to not print ":" - if ( prefix.length() > 0 ) - { - out.write( prefix ); - out.write( ':' ); + if (prefix.length() > 0) { + out.write(prefix); + out.write(':'); } - } - else - { + } else { // make sure that default namespace can be declared - for ( int i = namespaceEnd - 1; i >= 0; --i ) - { - if ( namespacePrefix[i] == "" ) - { + for (int i = namespaceEnd - 1; i >= 0; --i) { + if (namespacePrefix[i] == "") { final String uri = namespaceUri[i]; - if ( uri == null ) - { + if (uri == null) { // declare default namespace - setPrefix( "", "" ); - } - else if ( uri.length() > 0 ) - { - throw new IllegalStateException( "start tag can not be written in empty default namespace " - + "as default namespace is currently bound to '" + uri + "'" + getLocation() ); + setPrefix("", ""); + } else if (uri.length() > 0) { + throw new IllegalStateException("start tag can not be written in empty default namespace " + + "as default namespace is currently bound to '" + uri + "'" + getLocation()); } break; } } } - } - out.write( name ); + out.write(name); return this; } @Override - public XmlSerializer attribute( String namespace, String name, String value ) - throws IOException - { - if ( !startTagIncomplete ) - { - throw new IllegalArgumentException( "startTag() must be called before attribute()" + getLocation() ); + public XmlSerializer attribute(String namespace, String name, String value) throws IOException { + if (!startTagIncomplete) { + throw new IllegalArgumentException("startTag() must be called before attribute()" + getLocation()); } // assert setPrefixCalled == false; - out.write( ' ' ); + out.write(' '); //// assert namespace != null; - if ( namespace != null && namespace.length() > 0 ) - { + if (namespace != null && namespace.length() > 0) { // namespace = namespace.intern(); - if ( !namesInterned ) - { + if (!namesInterned) { namespace = namespace.intern(); + } else if (checkNamesInterned) { + checkInterning(namespace); } - else if ( checkNamesInterned ) - { - checkInterning( namespace ); - } - String prefix = lookupOrDeclarePrefix( namespace ); + String prefix = lookupOrDeclarePrefix(namespace); // assert( prefix != null); - if ( prefix.length() == 0 ) - { + if (prefix.length() == 0) { // needs to declare prefix to hold default namespace // NOTE: attributes such as a='b' are in NO namespace - prefix = generatePrefix( namespace ); + prefix = generatePrefix(namespace); } - out.write( prefix ); - out.write( ':' ); + out.write(prefix); + out.write(':'); // if(prefix.length() > 0) { // out.write(prefix); // out.write(':'); // } } // assert name != null; - out.write( name ); - out.write( '=' ); + out.write(name); + out.write('='); // assert value != null; - out.write( attributeUseApostrophe ? '\'' : '"' ); - writeAttributeValue( value, out ); - out.write( attributeUseApostrophe ? '\'' : '"' ); + out.write(attributeUseApostrophe ? '\'' : '"'); + writeAttributeValue(value, out); + out.write(attributeUseApostrophe ? '\'' : '"'); return this; } - protected void closeStartTag() - throws IOException - { - if ( finished ) - { - throw new IllegalArgumentException( "trying to write past already finished output" + getLocation() ); + protected void closeStartTag() throws IOException { + if (finished) { + throw new IllegalArgumentException("trying to write past already finished output" + getLocation()); } - if ( seenBracket ) - { + if (seenBracket) { seenBracket = seenBracketBracket = false; } - if ( startTagIncomplete || setPrefixCalled ) - { - if ( setPrefixCalled ) - { - throw new IllegalArgumentException( "startTag() must be called immediately after setPrefix()" - + getLocation() ); + if (startTagIncomplete || setPrefixCalled) { + if (setPrefixCalled) { + throw new IllegalArgumentException( + "startTag() must be called immediately after setPrefix()" + getLocation()); } - if ( !startTagIncomplete ) - { - throw new IllegalArgumentException( "trying to close start tag that is not opened" + getLocation() ); + if (!startTagIncomplete) { + throw new IllegalArgumentException("trying to close start tag that is not opened" + getLocation()); } // write all namespace declarations! writeNamespaceDeclarations(); - out.write( '>' ); + out.write('>'); elNamespaceCount[depth] = namespaceEnd; startTagIncomplete = false; } } - private void writeNamespaceDeclarations() - throws IOException - { + private void writeNamespaceDeclarations() throws IOException { // int start = elNamespaceCount[ depth - 1 ]; - for ( int i = elNamespaceCount[depth - 1]; i < namespaceEnd; i++ ) - { - if ( doIndent && namespaceUri[i].length() > 40 ) - { + for (int i = elNamespaceCount[depth - 1]; i < namespaceEnd; i++) { + if (doIndent && namespaceUri[i].length() > 40) { writeIndent(); - out.write( " " ); + out.write(" "); } - if ( namespacePrefix[i] != "" ) - { - out.write( " xmlns:" ); - out.write( namespacePrefix[i] ); - out.write( '=' ); + if (namespacePrefix[i] != "") { + out.write(" xmlns:"); + out.write(namespacePrefix[i]); + out.write('='); + } else { + out.write(" xmlns="); } - else - { - out.write( " xmlns=" ); - } - out.write( attributeUseApostrophe ? '\'' : '"' ); + out.write(attributeUseApostrophe ? '\'' : '"'); // NOTE: escaping of namespace value the same way as attributes!!!! - writeAttributeValue( namespaceUri[i], out ); + writeAttributeValue(namespaceUri[i], out); - out.write( attributeUseApostrophe ? '\'' : '"' ); + out.write(attributeUseApostrophe ? '\'' : '"'); } } @Override - public XmlSerializer endTag( String namespace, String name ) - throws IOException - { + public XmlSerializer endTag(String namespace, String name) throws IOException { // check that level is valid //// assert namespace != null; // if(namespace != null) { // namespace = namespace.intern(); // } seenBracket = seenBracketBracket = false; - if ( namespace != null ) - { - if ( !namesInterned ) - { + if (namespace != null) { + if (!namesInterned) { namespace = namespace.intern(); - } - else if ( checkNamesInterned ) - { - checkInterning( namespace ); + } else if (checkNamesInterned) { + checkInterning(namespace); } } - if ( namespace != elNamespace[depth] ) - { - throw new IllegalArgumentException( "expected namespace " + printable( elNamespace[depth] ) + " and not " - + printable( namespace ) + getLocation() ); + if (namespace != elNamespace[depth]) { + throw new IllegalArgumentException("expected namespace " + printable(elNamespace[depth]) + " and not " + + printable(namespace) + getLocation()); } - if ( name == null ) - { - throw new IllegalArgumentException( "end tag name can not be null" + getLocation() ); + if (name == null) { + throw new IllegalArgumentException("end tag name can not be null" + getLocation()); } - if ( checkNamesInterned && namesInterned ) - { - checkInterning( name ); + if (checkNamesInterned && namesInterned) { + checkInterning(name); } - if ( ( !namesInterned && !name.equals( elName[depth] ) ) || ( namesInterned && name != elName[depth] ) ) - { - throw new IllegalArgumentException( "expected element name " + printable( elName[depth] ) + " and not " - + printable( name ) + getLocation() ); + if ((!namesInterned && !name.equals(elName[depth])) || (namesInterned && name != elName[depth])) { + throw new IllegalArgumentException("expected element name " + printable(elName[depth]) + " and not " + + printable(name) + getLocation()); } - if ( startTagIncomplete ) - { + if (startTagIncomplete) { writeNamespaceDeclarations(); - out.write( " />" ); // space is added to make it easier to work in XHTML!!! + out.write(" />"); // space is added to make it easier to work in XHTML!!! --depth; - } - else - { + } else { --depth; // assert startTagIncomplete == false; - if ( doIndent && seenTag ) - { + if (doIndent && seenTag) { writeIndent(); } - out.write( " 0 ) - { + out.write(" 0) { // TODO prefix should be already known from matching start tag ... - final String prefix = lookupOrDeclarePrefix( namespace ); + final String prefix = lookupOrDeclarePrefix(namespace); // assert( prefix != null); - if ( prefix.length() > 0 ) - { - out.write( prefix ); - out.write( ':' ); + if (prefix.length() > 0) { + out.write(prefix); + out.write(':'); } } - out.write( name ); - out.write( '>' ); - + out.write(name); + out.write('>'); } namespaceEnd = elNamespaceCount[depth]; startTagIncomplete = false; @@ -964,171 +773,118 @@ else if ( checkNamesInterned ) } @Override - public XmlSerializer text( String text ) - throws IOException - { + public XmlSerializer text(String text) throws IOException { // assert text != null; - if ( startTagIncomplete || setPrefixCalled ) - closeStartTag(); - if ( doIndent && seenTag ) - seenTag = false; - writeElementContent( text, out ); + if (startTagIncomplete || setPrefixCalled) closeStartTag(); + if (doIndent && seenTag) seenTag = false; + writeElementContent(text, out); return this; } @Override - public XmlSerializer text( char[] buf, int start, int len ) - throws IOException - { - if ( startTagIncomplete || setPrefixCalled ) - closeStartTag(); - if ( doIndent && seenTag ) - seenTag = false; - writeElementContent( buf, start, len, out ); + public XmlSerializer text(char[] buf, int start, int len) throws IOException { + if (startTagIncomplete || setPrefixCalled) closeStartTag(); + if (doIndent && seenTag) seenTag = false; + writeElementContent(buf, start, len, out); return this; } @Override - public void cdsect( String text ) - throws IOException - { - if ( startTagIncomplete || setPrefixCalled || seenBracket ) - closeStartTag(); - if ( doIndent && seenTag ) - seenTag = false; - out.write( "" ); + public void cdsect(String text) throws IOException { + if (startTagIncomplete || setPrefixCalled || seenBracket) closeStartTag(); + if (doIndent && seenTag) seenTag = false; + out.write(""); } @Override - public void entityRef( String text ) - throws IOException - { - if ( startTagIncomplete || setPrefixCalled || seenBracket ) - closeStartTag(); - if ( doIndent && seenTag ) - seenTag = false; - out.write( '&' ); - out.write( text ); // escape? - out.write( ';' ); + public void entityRef(String text) throws IOException { + if (startTagIncomplete || setPrefixCalled || seenBracket) closeStartTag(); + if (doIndent && seenTag) seenTag = false; + out.write('&'); + out.write(text); // escape? + out.write(';'); } @Override - public void processingInstruction( String text ) - throws IOException - { - if ( startTagIncomplete || setPrefixCalled || seenBracket ) - closeStartTag(); - if ( doIndent && seenTag ) - seenTag = false; - out.write( "" ); + public void processingInstruction(String text) throws IOException { + if (startTagIncomplete || setPrefixCalled || seenBracket) closeStartTag(); + if (doIndent && seenTag) seenTag = false; + out.write(""); } @Override - public void comment( String text ) - throws IOException - { - if ( startTagIncomplete || setPrefixCalled || seenBracket ) - closeStartTag(); - if ( doIndent && seenTag ) - seenTag = false; - out.write( "" ); + public void comment(String text) throws IOException { + if (startTagIncomplete || setPrefixCalled || seenBracket) closeStartTag(); + if (doIndent && seenTag) seenTag = false; + out.write(""); } @Override - public void docdecl( String text ) - throws IOException - { - if ( startTagIncomplete || setPrefixCalled || seenBracket ) - closeStartTag(); - if ( doIndent && seenTag ) - seenTag = false; - out.write( "" ); + public void docdecl(String text) throws IOException { + if (startTagIncomplete || setPrefixCalled || seenBracket) closeStartTag(); + if (doIndent && seenTag) seenTag = false; + out.write(""); } @Override - public void ignorableWhitespace( String text ) - throws IOException - { - if ( startTagIncomplete || setPrefixCalled || seenBracket ) - closeStartTag(); - if ( doIndent && seenTag ) - seenTag = false; - if ( text.length() == 0 ) - { - throw new IllegalArgumentException( "empty string is not allowed for ignorable whitespace" - + getLocation() ); + public void ignorableWhitespace(String text) throws IOException { + if (startTagIncomplete || setPrefixCalled || seenBracket) closeStartTag(); + if (doIndent && seenTag) seenTag = false; + if (text.length() == 0) { + throw new IllegalArgumentException("empty string is not allowed for ignorable whitespace" + getLocation()); } - out.write( text ); // no escape? + out.write(text); // no escape? } @Override - public void flush() - throws IOException - { - if ( !finished && startTagIncomplete ) - closeStartTag(); + public void flush() throws IOException { + if (!finished && startTagIncomplete) closeStartTag(); out.flush(); } // --- utility methods - protected void writeAttributeValue( String value, Writer out ) - throws IOException - { + protected void writeAttributeValue(String value, Writer out) throws IOException { // .[apostrophe and <, & escaped], final char quot = attributeUseApostrophe ? '\'' : '"'; final String quotEntity = attributeUseApostrophe ? "'" : """; int pos = 0; - for ( int i = 0; i < value.length(); i++ ) - { - char ch = value.charAt( i ); - if ( ch == '&' ) - { - if ( i > pos ) - out.write( value.substring( pos, i ) ); - out.write( "&" ); + for (int i = 0; i < value.length(); i++) { + char ch = value.charAt(i); + if (ch == '&') { + if (i > pos) out.write(value.substring(pos, i)); + out.write("&"); pos = i + 1; } - if ( ch == '<' ) - { - if ( i > pos ) - out.write( value.substring( pos, i ) ); - out.write( "<" ); + if (ch == '<') { + if (i > pos) out.write(value.substring(pos, i)); + out.write("<"); pos = i + 1; - } - else if ( ch == quot ) - { - if ( i > pos ) - out.write( value.substring( pos, i ) ); - out.write( quotEntity ); + } else if (ch == quot) { + if (i > pos) out.write(value.substring(pos, i)); + out.write(quotEntity); pos = i + 1; - } - else if ( ch < 32 ) - { + } else if (ch < 32) { // in XML 1.0 only legal character are #x9 | #xA | #xD // and they must be escaped otherwise in attribute value they are normalized to spaces - if ( ch == 13 || ch == 10 || ch == 9 ) - { - if ( i > pos ) - out.write( value.substring( pos, i ) ); - out.write( "&#" ); - out.write( Integer.toString( ch ) ); - out.write( ';' ); + if (ch == 13 || ch == 10 || ch == 9) { + if (i > pos) out.write(value.substring(pos, i)); + out.write("&#"); + out.write(Integer.toString(ch)); + out.write(';'); pos = i + 1; - } - else - { - throw new IllegalStateException( "character " + Integer.toString( ch ) + " is not allowed in output" - + getLocation() ); + } 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)); @@ -1143,65 +899,41 @@ else if ( ch < 32 ) } } } - if ( pos > 0 ) - { - out.write( value.substring( pos ) ); - } - else - { - out.write( value ); // this is shortcut to the most common case + if (pos > 0) { + out.write(value.substring(pos)); + } else { + out.write(value); // this is shortcut to the most common case } - } - protected void writeElementContent( String text, Writer out ) - throws IOException - { + protected void writeElementContent(String text, Writer out) throws IOException { // escape '<', '&', ']]>', <32 if necessary int pos = 0; - for ( int i = 0; i < text.length(); i++ ) - { + for (int i = 0; i < text.length(); i++) { // TODO: check if doing char[] text.getChars() would be faster than getCharAt(i) ... - char ch = text.charAt( i ); - if ( ch == ']' ) - { - if ( seenBracket ) - { + char ch = text.charAt(i); + if (ch == ']') { + if (seenBracket) { seenBracketBracket = true; - } - else - { + } else { seenBracket = true; } - } - else - { - if ( ch == '&' ) - { - if ( i > pos ) - out.write( text.substring( pos, i ) ); - out.write( "&" ); + } else { + if (ch == '&') { + if (i > pos) out.write(text.substring(pos, i)); + out.write("&"); pos = i + 1; - } - else if ( ch == '<' ) - { - if ( i > pos ) - out.write( text.substring( pos, i ) ); - out.write( "<" ); + } else if (ch == '<') { + if (i > pos) out.write(text.substring(pos, i)); + out.write("<"); pos = i + 1; - } - else if ( seenBracketBracket && ch == '>' ) - { - if ( i > pos ) - out.write( text.substring( pos, i ) ); - out.write( ">" ); + } else if (seenBracketBracket && ch == '>') { + if (i > pos) out.write(text.substring(pos, i)); + out.write(">"); pos = i + 1; - } - else if ( ch < 32 ) - { + } else if (ch < 32) { // in XML 1.0 only legal character are #x9 | #xA | #xD - if ( ch == 9 || ch == 10 || ch == 13 ) - { + if (ch == 9 || ch == 10 || ch == 13) { // pass through // } else if(ch == 13) { //escape @@ -1210,11 +942,9 @@ else if ( ch < 32 ) // out.write(Integer.toString(ch)); // out.write(';'); // pos = i + 1; - } - else - { - throw new IllegalStateException( "character " + Integer.toString( ch ) - + " is not allowed in output" + getLocation() ); + } 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)); @@ -1228,79 +958,53 @@ else if ( ch < 32 ) // } } } - if ( seenBracket ) - { + if (seenBracket) { seenBracketBracket = seenBracket = false; } - } } - if ( pos > 0 ) - { - out.write( text.substring( pos ) ); - } - else - { - out.write( text ); // this is shortcut to the most common case + if (pos > 0) { + out.write(text.substring(pos)); + } else { + out.write(text); // this is shortcut to the most common case } - } - protected void writeElementContent( char[] buf, int off, int len, Writer out ) - throws IOException - { + protected void writeElementContent(char[] buf, int off, int len, Writer out) throws IOException { // escape '<', '&', ']]>' final int end = off + len; int pos = off; - for ( int i = off; i < end; i++ ) - { + for (int i = off; i < end; i++) { final char ch = buf[i]; - if ( ch == ']' ) - { - if ( seenBracket ) - { + if (ch == ']') { + if (seenBracket) { seenBracketBracket = true; - } - else - { + } else { seenBracket = true; } - } - else - { - if ( ch == '&' ) - { - if ( i > pos ) - { - out.write( buf, pos, i - pos ); + } else { + if (ch == '&') { + if (i > pos) { + out.write(buf, pos, i - pos); } - out.write( "&" ); + out.write("&"); pos = i + 1; - } - else if ( ch == '<' ) - { - if ( i > pos ) - { - out.write( buf, pos, i - pos ); + } else if (ch == '<') { + if (i > pos) { + out.write(buf, pos, i - pos); } - out.write( "<" ); + out.write("<"); pos = i + 1; - } - else if ( seenBracketBracket && ch == '>' ) - { - if ( i > pos ) - { - out.write( buf, pos, i - pos ); + } else if (seenBracketBracket && ch == '>') { + if (i > pos) { + out.write(buf, pos, i - pos); } - out.write( ">" ); + out.write(">"); pos = i + 1; - } - else if ( ch < 32 ) - { + } else if (ch < 32) { // in XML 1.0 only legal character are #x9 | #xA | #xD - if ( ch == 9 || ch == 10 || ch == 13 ) - { + if (ch == 9 || ch == 10 || ch == 13) { // pass through // } else if(ch == 13 ) { //if(ch == '\r') { @@ -1311,11 +1015,9 @@ else if ( ch < 32 ) // out.write(Integer.toString(ch)); // out.write(';'); // pos = i + 1; - } - else - { - throw new IllegalStateException( "character " + Integer.toString( ch ) - + " is not allowed in output" + getLocation() ); + } 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)); @@ -1329,81 +1031,69 @@ else if ( ch < 32 ) // } } } - if ( seenBracket ) - { + if (seenBracket) { seenBracketBracket = seenBracket = false; } // assert seenBracketBracket == seenBracket == false; } } - if ( end > pos ) - { - out.write( buf, pos, end - pos ); + if (end > pos) { + out.write(buf, pos, end - pos); } } // simple utility method -- good for debugging - protected static final String printable( String s ) - { - if ( s == null ) - return "null"; - StringBuilder retval = new StringBuilder( s.length() + 16 ); - retval.append( "'" ); + protected static final String printable(String s) { + if (s == null) return "null"; + StringBuilder retval = new StringBuilder(s.length() + 16); + retval.append("'"); char ch; - for ( int i = 0; i < s.length(); i++ ) - { - addPrintable( retval, s.charAt( i ) ); + for (int i = 0; i < s.length(); i++) { + addPrintable(retval, s.charAt(i)); } - retval.append( "'" ); + retval.append("'"); return retval.toString(); } - protected static final String printable( char ch ) - { + protected static final String printable(char ch) { StringBuilder retval = new StringBuilder(); - addPrintable( retval, ch ); + addPrintable(retval, ch); return retval.toString(); } - private static void addPrintable( StringBuilder retval, char ch ) - { - switch ( ch ) - { + private static void addPrintable(StringBuilder retval, char ch) { + switch (ch) { case '\b': - retval.append( "\\b" ); + retval.append("\\b"); break; case '\t': - retval.append( "\\t" ); + retval.append("\\t"); break; case '\n': - retval.append( "\\n" ); + retval.append("\\n"); break; case '\f': - retval.append( "\\f" ); + retval.append("\\f"); break; case '\r': - retval.append( "\\r" ); + retval.append("\\r"); break; case '\"': - retval.append( "\\\"" ); + retval.append("\\\""); break; case '\'': - retval.append( "\\\'" ); + retval.append("\\\'"); break; case '\\': - retval.append( "\\\\" ); + retval.append("\\\\"); break; default: - if ( ch < 0x20 || ch > 0x7e ) - { - final String ss = "0000" + Integer.toString( ch, 16 ); - retval.append( "\\u" ).append( ss, ss.length() - 4, ss.length() ); - } - else - { - retval.append( ch ); + if (ch < 0x20 || ch > 0x7e) { + final String ss = "0000" + Integer.toString(ch, 16); + retval.append("\\u").append(ss, ss.length() - 4, ss.length()); + } else { + retval.append(ch); } } } - } diff --git a/src/main/java/org/codehaus/plexus/util/xml/pull/XmlPullParser.java b/src/main/java/org/codehaus/plexus/util/xml/pull/XmlPullParser.java index a5f06c14..1e574485 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/pull/XmlPullParser.java +++ b/src/main/java/org/codehaus/plexus/util/xml/pull/XmlPullParser.java @@ -3,8 +3,8 @@ package org.codehaus.plexus.util.xml.pull; -import java.io.InputStream; import java.io.IOException; +import java.io.InputStream; import java.io.Reader; /** @@ -60,7 +60,7 @@ * and it was not declared in XMLDecl * * A minimal example for using this API may look as follows: - * + * *
      * import java.io.IOException;
      * import java.io.StringReader;
    @@ -100,14 +100,14 @@
      * 
    *

    * The above example will generate the following output: - * + * *

      * Start document
      * Start tag foo
      * Text Hello World!
      * End tag foo
      * 
    - * + * * For more details on API usage, please refer to the quick Introduction available at * http://www.xmlpull.org * @@ -128,9 +128,7 @@ * @author Stefan Haustein * @author Aleksander Slominski */ - -public interface XmlPullParser -{ +public interface XmlPullParser { /** This constant represents the default namespace (empty string "") */ String NO_NAMESPACE = ""; @@ -252,7 +250,7 @@ public interface XmlPullParser * An XML processing instruction declaration was just read. This event type is available only via * nextToken(). getText() will return text that is inside the processing instruction. * Calls to next() will skip processing instructions automatically. - * + * * @see #nextToken * @see #getText */ @@ -284,8 +282,19 @@ public interface XmlPullParser * only. Relying on the contents of the array may be dangerous since malicious applications may alter the array, * although it is final, due to limitations of the Java language. */ - String[] TYPES = { "START_DOCUMENT", "END_DOCUMENT", "START_TAG", "END_TAG", "TEXT", "CDSECT", "ENTITY_REF", - "IGNORABLE_WHITESPACE", "PROCESSING_INSTRUCTION", "COMMENT", "DOCDECL" }; + String[] TYPES = { + "START_DOCUMENT", + "END_DOCUMENT", + "START_TAG", + "END_TAG", + "TEXT", + "CDSECT", + "ENTITY_REF", + "IGNORABLE_WHITESPACE", + "PROCESSING_INSTRUCTION", + "COMMENT", + "DOCDECL" + }; // ---------------------------------------------------------------------------- // namespace related features @@ -348,8 +357,7 @@ public interface XmlPullParser * @exception XmlPullParserException If the feature is not supported or can not be set * @exception IllegalArgumentException If string with the feature name is null */ - void setFeature( String name, boolean state ) - throws XmlPullParserException; + void setFeature(String name, boolean state) throws XmlPullParserException; /** * Returns the current value of the given feature. @@ -360,7 +368,7 @@ void setFeature( String name, boolean state ) * @return The value of the feature. * @exception IllegalArgumentException if string the feature name is null */ - boolean getFeature( String name ); + boolean getFeature(String name); /** * Set the value of a property. The property name is any fully-qualified URI. @@ -370,8 +378,7 @@ void setFeature( String name, boolean state ) * @exception IllegalArgumentException If string with the property name is null * @throws XmlPullParserException parsing issue */ - void setProperty( String name, Object value ) - throws XmlPullParserException; + void setProperty(String name, Object value) throws XmlPullParserException; /** * Look up the value of a property. The property name is any fully-qualified URI. @@ -381,7 +388,7 @@ void setProperty( String name, Object value ) * @param name The name of property to be retrieved. * @return The value of named property. */ - Object getProperty( String name ); + Object getProperty(String name); /** * Set the input source for parser to the given reader and resets the parser. The event type is set to the initial @@ -390,8 +397,7 @@ void setProperty( String name, Object value ) * @param in the Reader * @throws XmlPullParserException parsing issue */ - void setInput( Reader in ) - throws XmlPullParserException; + void setInput(Reader in) throws XmlPullParserException; /** * Sets the input stream the parser is going to process. This call resets the parser state and sets the event type @@ -407,8 +413,7 @@ void setInput( Reader in ) * @param inputEncoding if not null it MUST be used as encoding for inputStream * @throws XmlPullParserException parsing issue */ - void setInput( InputStream inputStream, String inputEncoding ) - throws XmlPullParserException; + void setInput(InputStream inputStream, String inputEncoding) throws XmlPullParserException; /** * @return the input encoding if known, null otherwise. If setInput(InputStream, inputEncoding) was called with an @@ -448,8 +453,7 @@ void setInput( InputStream inputStream, String inputEncoding ) * @see #FEATURE_VALIDATION * @throws XmlPullParserException parsing issue */ - void defineEntityReplacementText( String entityName, String replacementText ) - throws XmlPullParserException; + void defineEntityReplacementText(String entityName, String replacementText) throws XmlPullParserException; /** * @return the numbers of elements in the namespace stack for the given depth. If namespaces are not enabled, 0 is @@ -459,7 +463,7 @@ void defineEntityReplacementText( String entityName, String replacementText ) * retrieve position of namespace prefixes and URIs that were declared on corresponding START_TAG. *

    * NOTE: to retrieve lsit of namespaces declared in current element: - * + * *

          *       XmlPullParser pp = ...
          *       int nsStart = pp.getNamespaceCount(pp.getDepth()-1);
    @@ -478,8 +482,7 @@ void defineEntityReplacementText( String entityName, String replacementText )
          * @param depth depth
          * @throws XmlPullParserException parsing issue
          */
    -    int getNamespaceCount( int depth )
    -        throws XmlPullParserException;
    +    int getNamespaceCount(int depth) throws XmlPullParserException;
     
         /**
          * @return Returns the namespace prefix for the given position in the namespace stack. Default namespace declaration
    @@ -491,8 +494,7 @@ int getNamespaceCount( int depth )
          * @param pos namespace stack position
          * @throws XmlPullParserException parsing issue
          */
    -    String getNamespacePrefix( int pos )
    -        throws XmlPullParserException;
    +    String getNamespacePrefix(int pos) throws XmlPullParserException;
     
         /**
          * @return Returns the namespace URI for the given position in the namespace stack If the position is out of range, an
    @@ -503,8 +505,7 @@ String getNamespacePrefix( int pos )
          * @throws XmlPullParserException parsing issue
          * @param pos namespace stack position
          */
    -    String getNamespaceUri( int pos )
    -        throws XmlPullParserException;
    +    String getNamespaceUri(int pos) throws XmlPullParserException;
     
         /**
          * @return the URI corresponding to the given prefix, depending on current state of the parser.
    @@ -534,7 +535,7 @@ String getNamespaceUri( int pos )
          * @see #getNamespacePrefix
          * @see #getNamespaceUri
          */
    -    String getNamespace( String prefix );
    +    String getNamespace(String prefix);
     
         // --------------------------------------------------------------------------
         // miscellaneous reporting methods
    @@ -591,8 +592,7 @@ String getNamespaceUri( int pos )
          * exposed via nextToken only.
          * @throws XmlPullParserException parsing issue
          */
    -    boolean isWhitespace()
    -        throws XmlPullParserException;
    +    boolean isWhitespace() throws XmlPullParserException;
     
         /**
          * @return  the text content of the current event as String. The value returned depends on current event type, for
    @@ -626,7 +626,7 @@ boolean isWhitespace()
          * @return char buffer that contains the text of the current event (null if the current event has no text
          *         associated).
          */
    -    char[] getTextCharacters( int[] holderForStartAndLength );
    +    char[] getTextCharacters(int[] holderForStartAndLength);
     
         // --------------------------------------------------------------------------
         // START_TAG / END_TAG shared methods
    @@ -660,8 +660,7 @@ boolean isWhitespace()
          * NOTE: if the parser is not on START_TAG, an exception will be thrown.
          * @throws XmlPullParserException parsing issue
          */
    -    boolean isEmptyElementTag()
    -        throws XmlPullParserException;
    +    boolean isEmptyElementTag() throws XmlPullParserException;
     
         // --------------------------------------------------------------------------
         // START_TAG Attributes retrieval methods
    @@ -693,7 +692,7 @@ boolean isEmptyElementTag()
          * @return attribute namespace, empty string ("") is returned if namespaces processing is not enabled or namespaces
          *         processing is enabled but attribute has no namespace (it has no prefix).
          */
    -    String getAttributeNamespace( int index );
    +    String getAttributeNamespace(int index);
     
         /**
          * Returns the local name of the specified attribute if namespaces are enabled or just attribute name if namespaces
    @@ -703,7 +702,7 @@ boolean isEmptyElementTag()
          * @param index zero based index of attribute
          * @return attribute name (null is never returned)
          */
    -    String getAttributeName( int index );
    +    String getAttributeName(int index);
     
         /**
          * Returns the prefix of the specified attribute Returns null if the element has no prefix. If namespaces are
    @@ -713,7 +712,7 @@ boolean isEmptyElementTag()
          * @param index zero based index of attribute
          * @return attribute prefix or null if namespaces processing is not enabled.
          */
    -    String getAttributePrefix( int index );
    +    String getAttributePrefix(int index);
     
         /**
          * Returns the type of the specified attribute If parser is non-validating it MUST return CDATA.
    @@ -721,7 +720,7 @@ boolean isEmptyElementTag()
          * @param index zero based index of attribute
          * @return attribute type (null is never returned)
          */
    -    String getAttributeType( int index );
    +    String getAttributeType(int index);
     
         /**
          * Returns if the specified attribute was not in input was declared in XML. If parser is non-validating it MUST
    @@ -730,7 +729,7 @@ boolean isEmptyElementTag()
          * @param index zero based index of attribute
          * @return false if attribute was in input
          */
    -    boolean isAttributeDefault( int index );
    +    boolean isAttributeDefault(int index);
     
         /**
          * Returns the given attributes value. Throws an IndexOutOfBoundsException if the index is out of range or current
    @@ -744,7 +743,7 @@ boolean isEmptyElementTag()
          * @param index zero based index of attribute
          * @return value of attribute (null is never returned)
          */
    -    String getAttributeValue( int index );
    +    String getAttributeValue(int index);
     
         /**
          * Returns the attributes value identified by namespace URI and namespace localName. If namespaces are disabled
    @@ -759,7 +758,7 @@ boolean isEmptyElementTag()
          * @param name If namespaces enabled local name of attribute otherwise just attribute name
          * @return value of attribute or null if attribute with given name does not exist
          */
    -    String getAttributeValue( String namespace, String name );
    +    String getAttributeValue(String namespace, String name);
     
         // --------------------------------------------------------------------------
         // actual parsing methods
    @@ -771,8 +770,7 @@ boolean isEmptyElementTag()
          * @see #nextToken()
          * @throws XmlPullParserException parsing issue
          */
    -    int getEventType()
    -        throws XmlPullParserException;
    +    int getEventType() throws XmlPullParserException;
     
         /**
          * @return Get next parsing event - element content wil be coalesced and only one TEXT event must be returned for whole
    @@ -791,8 +789,7 @@ int getEventType()
          * @throws XmlPullParserException parsing issue
          * @throws IOException io issue
          */
    -    int next()
    -        throws XmlPullParserException, IOException;
    +    int next() throws XmlPullParserException, IOException;
     
         /**
          * This method works similarly to next() but will expose additional event types (COMMENT, CDSECT, DOCDECL,
    @@ -846,19 +843,19 @@ int next()
          * 
    DOCDECL *
    if FEATURE_XML_ROUNDTRIP is true or PROCESS_DOCDECL is false then return what is inside of DOCDECL for * example it returns: - * + * *
          * " titlepage SYSTEM "http://www.foo.bar/dtds/typo.dtd"
          * [<!ENTITY % active.links "INCLUDE">]"
          * 
    *

    * for input document that contained: - * + * *

          * <!DOCTYPE titlepage SYSTEM "http://www.foo.bar/dtds/typo.dtd"
          * [<!ENTITY % active.links "INCLUDE">]>
          * 
    - * + * * otherwise if FEATURE_XML_ROUNDTRIP is false and PROCESS_DOCDECL is true then what is returned is undefined (it * may be even null)
    * @@ -885,8 +882,7 @@ int next() * @see #ENTITY_REF * @see #IGNORABLE_WHITESPACE */ - int nextToken() - throws XmlPullParserException, IOException; + int nextToken() throws XmlPullParserException, IOException; // ----------------------------------------------------------------------------- // utility methods to mak XML parsing easier ... @@ -897,7 +893,7 @@ int nextToken() * parser position, the expected event and the current event that is not meeting the requirement. *

    * Essentially it does this - * + * *

          * if ( type != getEventType() || ( namespace != null && !namespace.equals( getNamespace() ) )
          *     || ( name != null && !name.equals( getName() ) ) )
    @@ -909,8 +905,7 @@ int nextToken()
          * @throws XmlPullParserException parsing issue
          * @throws IOException io issue
          */
    -    void require( int type, String namespace, String name )
    -        throws XmlPullParserException, IOException;
    +    void require(int type, String namespace, String name) throws XmlPullParserException, IOException;
     
         /**
          * If current event is START_TAG then if next element is TEXT then element content is returned or if next event is
    @@ -922,18 +917,18 @@ void require( int type, String namespace, String name )
          * 
      *
    1. <tag>foo</tag> *
    2. <tag></tag> (which is equivalent to <tag/> both input can be parsed with the same code: - * + * *
            *   p.nextTag()
            *   p.requireEvent(p.START_TAG, "", "tag");
            *   String content = p.nextText();
            *   p.requireEvent(p.END_TAG, "", "tag");
            * 
    - * + * * This function together with nextTag make it very easy to parse XML that has no mixed content. *

    * Essentially it does this - * + * *

          * if ( getEventType() != START_TAG )
          * {
    @@ -963,15 +958,14 @@ void require( int type, String namespace, String name )
          * @throws XmlPullParserException parsing issue
          * @throws IOException io issue
          */
    -    String nextText()
    -        throws XmlPullParserException, IOException;
    +    String nextText() throws XmlPullParserException, IOException;
     
         /**
          * Call next() and return event if it is START_TAG or END_TAG otherwise throw an exception. It will skip whitespace
          * TEXT before actual tag if any.
          * 

    * essentially it does this - * + * *

          * int eventType = next();
          * if ( eventType == TEXT && isWhitespace() )
    @@ -989,7 +983,5 @@ String nextText()
          * @throws
          * IOException io issue
          */
    -    int nextTag()
    -        throws XmlPullParserException, IOException;
    -
    +    int nextTag() throws XmlPullParserException, IOException;
     }
    diff --git a/src/main/java/org/codehaus/plexus/util/xml/pull/XmlPullParserException.java b/src/main/java/org/codehaus/plexus/util/xml/pull/XmlPullParserException.java
    index ff23754f..198977c5 100644
    --- a/src/main/java/org/codehaus/plexus/util/xml/pull/XmlPullParserException.java
    +++ b/src/main/java/org/codehaus/plexus/util/xml/pull/XmlPullParserException.java
    @@ -8,9 +8,7 @@
      *
      * @author Aleksander Slominski
      */
    -public class XmlPullParserException
    -    extends Exception
    -{
    +public class XmlPullParserException extends Exception {
         /**
          * @deprecated use generic getCause() method
          */
    @@ -25,9 +23,8 @@ public class XmlPullParserException
          * public XmlPullParserException() { }
          */
     
    -    public XmlPullParserException( String s )
    -    {
    -        super( s );
    +    public XmlPullParserException(String s) {
    +        super(s);
         }
     
         /*
    @@ -35,14 +32,14 @@ public XmlPullParserException( String s )
          * XmlPullParserException(String s, int row, int column) { super(s); this.row = row; this.column = column; }
          */
     
    -    public XmlPullParserException( String msg, XmlPullParser parser, Throwable chain )
    -    {
    -        super( ( msg == null ? "" : msg + " " )
    -            + ( parser == null ? "" : "(position:" + parser.getPositionDescription() + ") " )
    -            + ( chain == null ? "" : "caused by: " + chain ), chain );
    +    public XmlPullParserException(String msg, XmlPullParser parser, Throwable chain) {
    +        super(
    +                (msg == null ? "" : msg + " ")
    +                        + (parser == null ? "" : "(position:" + parser.getPositionDescription() + ") ")
    +                        + (chain == null ? "" : "caused by: " + chain),
    +                chain);
     
    -        if ( parser != null )
    -        {
    +        if (parser != null) {
                 this.row = parser.getLineNumber();
                 this.column = parser.getColumnNumber();
             }
    @@ -54,19 +51,16 @@ public XmlPullParserException( String msg, XmlPullParser parser, Throwable chain
          * @return the cause
          */
         @Deprecated
    -    public Throwable getDetail()
    -    {
    +    public Throwable getDetail() {
             return getCause();
         }
     
         // public void setDetail(Throwable cause) { this.detail = cause; }
    -    public int getLineNumber()
    -    {
    +    public int getLineNumber() {
             return row;
         }
     
    -    public int getColumnNumber()
    -    {
    +    public int getColumnNumber() {
             return column;
         }
     
    @@ -77,20 +71,14 @@ public int getColumnNumber()
     
         // NOTE: code that prints this and detail is difficult in J2ME
         @Override
    -    public void printStackTrace()
    -    {
    -        if ( getCause() == null )
    -        {
    +    public void printStackTrace() {
    +        if (getCause() == null) {
                 super.printStackTrace();
    -        }
    -        else
    -        {
    -            synchronized ( System.err )
    -            {
    -                System.err.println( super.getMessage() + "; nested exception is:" );
    +        } else {
    +            synchronized (System.err) {
    +                System.err.println(super.getMessage() + "; nested exception is:");
                     getCause().printStackTrace();
                 }
             }
         }
    -
     }
    diff --git a/src/main/java/org/codehaus/plexus/util/xml/pull/XmlSerializer.java b/src/main/java/org/codehaus/plexus/util/xml/pull/XmlSerializer.java
    index 46ef492f..6d5ec139 100644
    --- a/src/main/java/org/codehaus/plexus/util/xml/pull/XmlSerializer.java
    +++ b/src/main/java/org/codehaus/plexus/util/xml/pull/XmlSerializer.java
    @@ -28,9 +28,7 @@
      * be thrown and it is recommended to use an optional feature to signal that implementation is not supporting this kind
      * of output.
      */
    -
    -public interface XmlSerializer
    -{
    +public interface XmlSerializer {
     
         /**
          * Set feature identified by name (recommended to be URI for uniqueness). Some well known optional features are
    @@ -41,8 +39,7 @@ public interface XmlSerializer
          * @param state feature state
          * @exception IllegalStateException If the feature is not supported or can not be set
          */
    -    void setFeature( String name, boolean state )
    -        throws IllegalArgumentException, IllegalStateException;
    +    void setFeature(String name, boolean state) throws IllegalArgumentException, IllegalStateException;
     
         /**
          * Return the current value of the feature with given name.
    @@ -53,7 +50,7 @@ void setFeature( String name, boolean state )
          * @return The value of named feature.
          * @exception IllegalArgumentException if feature string is null
          */
    -    boolean getFeature( String name );
    +    boolean getFeature(String name);
     
         /**
          * Set the value of a property. (the property name is recommended to be URI for uniqueness). Some well known
    @@ -64,8 +61,7 @@ void setFeature( String name, boolean state )
          * @param value property value
          * @exception IllegalStateException if the property is not supported or can not be set
          */
    -    void setProperty( String name, Object value )
    -        throws IllegalArgumentException, IllegalStateException;
    +    void setProperty(String name, Object value) throws IllegalArgumentException, IllegalStateException;
     
         /**
          * Look up the value of a property. The property name is any fully-qualified URI. I
    @@ -75,7 +71,7 @@ void setProperty( String name, Object value )
          * @param name The name of property to be retrieved.
          * @return The value of named property.
          */
    -    Object getProperty( String name );
    +    Object getProperty(String name);
     
         /**
          * Set to use binary output stream with given encoding.
    @@ -85,8 +81,8 @@ void setProperty( String name, Object value )
          * @throws IllegalArgumentException if null
          * @throws IllegalStateException illegal use
          */
    -    void setOutput( OutputStream os, String encoding )
    -        throws IOException, IllegalArgumentException, IllegalStateException;
    +    void setOutput(OutputStream os, String encoding)
    +            throws IOException, IllegalArgumentException, IllegalStateException;
     
         /**
          * @param writer Set the output to the given writer.
    @@ -96,8 +92,7 @@ void setOutput( OutputStream os, String encoding )
          * @throws IllegalArgumentException if null
          * @throws IllegalStateException illegal use
          */
    -    void setOutput( Writer writer )
    -        throws IOException, IllegalArgumentException, IllegalStateException;
    +    void setOutput(Writer writer) throws IOException, IllegalArgumentException, IllegalStateException;
     
         /**
          * Write <?xml declaration with encoding (if encoding not null) and standalone flag (if standalone not null)
    @@ -108,8 +103,8 @@ void setOutput( Writer writer )
          * @throws IllegalArgumentException if null
          * @throws IllegalStateException illegal use
          */
    -    void startDocument( String encoding, Boolean standalone )
    -        throws IOException, IllegalArgumentException, IllegalStateException;
    +    void startDocument(String encoding, Boolean standalone)
    +            throws IOException, IllegalArgumentException, IllegalStateException;
     
         /**
          * Finish writing. All unclosed start tags will be closed and output will be flushed. After calling this method no
    @@ -118,8 +113,7 @@ void startDocument( String encoding, Boolean standalone )
          * @throws IllegalArgumentException if null
          * @throws IllegalStateException illegal use
          */
    -    void endDocument()
    -        throws IOException, IllegalArgumentException, IllegalStateException;
    +    void endDocument() throws IOException, IllegalArgumentException, IllegalStateException;
     
         /**
          * Binds the given prefix to the given namespace. This call is valid for the next element including child elements.
    @@ -141,8 +135,7 @@ void endDocument()
          * @throws IllegalArgumentException if null
          * @throws IllegalStateException illegal use
          */
    -    void setPrefix( String prefix, String namespace )
    -        throws IOException, IllegalArgumentException, IllegalStateException;
    +    void setPrefix(String prefix, String namespace) throws IOException, IllegalArgumentException, IllegalStateException;
     
         /**
          * @return namespace that corresponds to given prefix If there is no prefix bound to this namespace return null but
    @@ -157,8 +150,7 @@ void setPrefix( String prefix, String namespace )
          * @param generatePrefix to generate the missing prefix
          * @throws IllegalArgumentException if null
          */
    -    String getPrefix( String namespace, boolean generatePrefix )
    -        throws IllegalArgumentException;
    +    String getPrefix(String namespace, boolean generatePrefix) throws IllegalArgumentException;
     
         /**
          * @return the current depth of the element. Outside the root element, the depth is 0. The depth is incremented by 1
    @@ -210,8 +202,8 @@ String getPrefix( String namespace, boolean generatePrefix )
          * @throws IllegalArgumentException if null
          * @throws IllegalStateException illegal use
          */
    -    XmlSerializer startTag( String namespace, String name )
    -        throws IOException, IllegalArgumentException, IllegalStateException;
    +    XmlSerializer startTag(String namespace, String name)
    +            throws IOException, IllegalArgumentException, IllegalStateException;
     
         /**
          * Write an attribute. Calls to attribute() MUST follow a call to startTag() immediately. If there is no prefix
    @@ -225,8 +217,8 @@ XmlSerializer startTag( String namespace, String name )
          * @throws IllegalArgumentException if null
          * @throws IllegalStateException illegal use
          */
    -    XmlSerializer attribute( String namespace, String name, String value )
    -        throws IOException, IllegalArgumentException, IllegalStateException;
    +    XmlSerializer attribute(String namespace, String name, String value)
    +            throws IOException, IllegalArgumentException, IllegalStateException;
     
         /**
          * Write end tag. Repetition of namespace and name is just for avoiding errors.
    @@ -240,8 +232,8 @@ XmlSerializer attribute( String namespace, String name, String value )
          * @throws IllegalArgumentException if null
          * @throws IllegalStateException illegal use
          */
    -    XmlSerializer endTag( String namespace, String name )
    -        throws IOException, IllegalArgumentException, IllegalStateException;
    +    XmlSerializer endTag(String namespace, String name)
    +            throws IOException, IllegalArgumentException, IllegalStateException;
     
         // /**
         // * Writes a start tag with the given namespace and name.
    @@ -303,8 +295,7 @@ XmlSerializer endTag( String namespace, String name )
          * @throws IllegalArgumentException if null
          * @throws IllegalStateException illegal use
          */
    -    XmlSerializer text( String text )
    -        throws IOException, IllegalArgumentException, IllegalStateException;
    +    XmlSerializer text(String text) throws IOException, IllegalArgumentException, IllegalStateException;
     
         /**
          * Writes text, where special XML chars are escaped automatically
    @@ -316,26 +307,20 @@ XmlSerializer text( String text )
          * @throws IllegalArgumentException if null
          * @throws IllegalStateException illegal use
          */
    -    XmlSerializer text( char[] buf, int start, int len )
    -        throws IOException, IllegalArgumentException, IllegalStateException;
    +    XmlSerializer text(char[] buf, int start, int len)
    +            throws IOException, IllegalArgumentException, IllegalStateException;
     
    -    void cdsect( String text )
    -        throws IOException, IllegalArgumentException, IllegalStateException;
    +    void cdsect(String text) throws IOException, IllegalArgumentException, IllegalStateException;
     
    -    void entityRef( String text )
    -        throws IOException, IllegalArgumentException, IllegalStateException;
    +    void entityRef(String text) throws IOException, IllegalArgumentException, IllegalStateException;
     
    -    void processingInstruction( String text )
    -        throws IOException, IllegalArgumentException, IllegalStateException;
    +    void processingInstruction(String text) throws IOException, IllegalArgumentException, IllegalStateException;
     
    -    void comment( String text )
    -        throws IOException, IllegalArgumentException, IllegalStateException;
    +    void comment(String text) throws IOException, IllegalArgumentException, IllegalStateException;
     
    -    void docdecl( String text )
    -        throws IOException, IllegalArgumentException, IllegalStateException;
    +    void docdecl(String text) throws IOException, IllegalArgumentException, IllegalStateException;
     
    -    void ignorableWhitespace( String text )
    -        throws IOException, IllegalArgumentException, IllegalStateException;
    +    void ignorableWhitespace(String text) throws IOException, IllegalArgumentException, IllegalStateException;
     
         /**
          * Write all pending output to the stream. If method startTag() or attribute() was called then start tag is closed
    @@ -345,7 +330,5 @@ void ignorableWhitespace( String text )
          * output call method text() with empty string (text("")).
          * @throws IOException io
          */
    -    void flush()
    -        throws IOException;
    -
    +    void flush() throws IOException;
     }
    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 76125f95..b03e8313 100644
    --- a/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java
    +++ b/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java
    @@ -16,9 +16,7 @@
      * limitations under the License.
      */
     
    -import static org.junit.Assert.assertEquals;
    -import static org.junit.Assert.assertTrue;
    -import static org.junit.Assert.fail;
    +import javax.swing.text.html.HTML.Tag;
     
     import java.io.File;
     import java.io.IOException;
    @@ -27,13 +25,15 @@
     import java.nio.file.Files;
     import java.util.NoSuchElementException;
     
    -import javax.swing.text.html.HTML.Tag;
    -
     import org.codehaus.plexus.util.StringUtils;
     import org.junit.After;
     import org.junit.Before;
     import org.junit.Test;
     
    +import static org.junit.Assert.assertEquals;
    +import static org.junit.Assert.assertTrue;
    +import static org.junit.Assert.fail;
    +
     /**
      * Test of {@link org.codehaus.plexus.util.xml.PrettyPrintXMLWriter}
      *
    @@ -42,8 +42,7 @@
      * @version $Id: $Id
      * @since 3.4.0
      */
    -public class PrettyPrintXMLWriterTest
    -{
    +public class PrettyPrintXMLWriterTest {
         StringWriter w;
     
         PrettyPrintXMLWriter writer;
    @@ -52,8 +51,7 @@ public class PrettyPrintXMLWriterTest
          * 

    setUp.

    */ @Before - public void setUp() - { + public void setUp() { initWriter(); } @@ -61,117 +59,107 @@ public void setUp() *

    tearDown.

    */ @After - public void tearDown() - { + public void tearDown() { writer = null; w = null; } - private void initWriter() - { + private void initWriter() { w = new StringWriter(); - writer = new PrettyPrintXMLWriter( w ); + writer = new PrettyPrintXMLWriter(w); } /** *

    testDefaultPrettyPrintXMLWriter.

    */ @Test - public void testDefaultPrettyPrintXMLWriter() - { - writer.startElement( Tag.HTML.toString() ); + public void testDefaultPrettyPrintXMLWriter() { + writer.startElement(Tag.HTML.toString()); - writeXhtmlHead( writer ); + writeXhtmlHead(writer); - writeXhtmlBody( writer ); + writeXhtmlBody(writer); writer.endElement(); // Tag.HTML - assertEquals( expectedResult( PrettyPrintXMLWriter.LS ), w.toString() ); + assertEquals(expectedResult(PrettyPrintXMLWriter.LS), w.toString()); } /** *

    testPrettyPrintXMLWriterWithGivenLineSeparator.

    */ @Test - public void testPrettyPrintXMLWriterWithGivenLineSeparator() - { - writer.setLineSeparator( "\n" ); + public void testPrettyPrintXMLWriterWithGivenLineSeparator() { + writer.setLineSeparator("\n"); - writer.startElement( Tag.HTML.toString() ); + writer.startElement(Tag.HTML.toString()); - writeXhtmlHead( writer ); + writeXhtmlHead(writer); - writeXhtmlBody( writer ); + writeXhtmlBody(writer); writer.endElement(); // Tag.HTML - assertEquals( expectedResult( "\n" ), w.toString() ); + assertEquals(expectedResult("\n"), w.toString()); } /** *

    testPrettyPrintXMLWriterWithGivenLineIndenter.

    */ @Test - public void testPrettyPrintXMLWriterWithGivenLineIndenter() - { - writer.setLineIndenter( " " ); + public void testPrettyPrintXMLWriterWithGivenLineIndenter() { + writer.setLineIndenter(" "); - writer.startElement( Tag.HTML.toString() ); + writer.startElement(Tag.HTML.toString()); - writeXhtmlHead( writer ); + writeXhtmlHead(writer); - writeXhtmlBody( writer ); + writeXhtmlBody(writer); writer.endElement(); // Tag.HTML - assertEquals( expectedResult( " ", PrettyPrintXMLWriter.LS ), w.toString() ); + assertEquals(expectedResult(" ", PrettyPrintXMLWriter.LS), w.toString()); } /** *

    testEscapeXmlAttribute.

    */ @Test - public void testEscapeXmlAttribute() - { + public void testEscapeXmlAttribute() { // Windows - writer.startElement( Tag.DIV.toString() ); - writer.addAttribute( "class", "sect\r\nion" ); + writer.startElement(Tag.DIV.toString()); + writer.addAttribute("class", "sect\r\nion"); writer.endElement(); // Tag.DIV - assertEquals( "
    ", w.toString() ); + assertEquals("
    ", w.toString()); // Mac initWriter(); - writer.startElement( Tag.DIV.toString() ); - writer.addAttribute( "class", "sect\rion" ); + writer.startElement(Tag.DIV.toString()); + writer.addAttribute("class", "sect\rion"); writer.endElement(); // Tag.DIV - assertEquals( "
    ", w.toString() ); + assertEquals("
    ", w.toString()); // Unix initWriter(); - writer.startElement( Tag.DIV.toString() ); - writer.addAttribute( "class", "sect\nion" ); + writer.startElement(Tag.DIV.toString()); + writer.addAttribute("class", "sect\nion"); writer.endElement(); // Tag.DIV - assertEquals( "
    ", w.toString() ); + assertEquals("
    ", w.toString()); } /** *

    testendElementAlreadyClosed.

    */ @Test - public void testendElementAlreadyClosed() - { - try - { - writer.startElement( Tag.DIV.toString() ); - writer.addAttribute( "class", "someattribute" ); + public void testendElementAlreadyClosed() { + try { + 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! - fail( "Should throw a NoSuchElementException" ); - } - catch ( NoSuchElementException e ) - { - assert ( true ); + fail("Should throw a NoSuchElementException"); + } catch (NoSuchElementException e) { + assert (true); } } @@ -184,105 +172,96 @@ public void testendElementAlreadyClosed() * @throws java.io.IOException if an I/O error occurs */ @Test - public void testIssue51DetectJava7ConcatenationBug() - throws IOException - { - File dir = new File( "target/test-xml" ); - if ( !dir.exists() ) - { - assertTrue( "cannot create directory test-xml", dir.mkdir() ); + public void testIssue51DetectJava7ConcatenationBug() throws IOException { + File dir = new File("target/test-xml"); + if (!dir.exists()) { + assertTrue("cannot create directory test-xml", dir.mkdir()); } - File xmlFile = new File( dir, "test-issue-51.xml" ); - OutputStreamWriter osw = new OutputStreamWriter( Files.newOutputStream( xmlFile.toPath() ), "UTF-8" ); - writer = new PrettyPrintXMLWriter( osw ); + File xmlFile = new File(dir, "test-issue-51.xml"); + OutputStreamWriter osw = new OutputStreamWriter(Files.newOutputStream(xmlFile.toPath()), "UTF-8"); + writer = new PrettyPrintXMLWriter(osw); int iterations = 20000; - try - { - for ( int i = 0; i < iterations; ++i ) - { - writer.startElement( Tag.DIV.toString() + i ); - writer.addAttribute( "class", "someattribute" ); + try { + for (int i = 0; i < iterations; ++i) { + writer.startElement(Tag.DIV.toString() + i); + writer.addAttribute("class", "someattribute"); } - for ( int i = 0; i < iterations; ++i ) - { + for (int i = 0; i < iterations; ++i) { writer.endElement(); // closes Tag.DIV + i } - } - catch ( NoSuchElementException e ) - { - fail( "Should not throw a NoSuchElementException" ); - } - finally - { - if ( osw != null ) - { + } catch (NoSuchElementException e) { + fail("Should not throw a NoSuchElementException"); + } finally { + if (osw != null) { osw.close(); } } } - private void writeXhtmlHead( XMLWriter writer ) - { - writer.startElement( Tag.HEAD.toString() ); - writer.startElement( Tag.TITLE.toString() ); - writer.writeText( "title" ); + private void writeXhtmlHead(XMLWriter writer) { + writer.startElement(Tag.HEAD.toString()); + writer.startElement(Tag.TITLE.toString()); + writer.writeText("title"); writer.endElement(); // Tag.TITLE - writer.startElement( Tag.META.toString() ); - writer.addAttribute( "name", "author" ); - writer.addAttribute( "content", "Author" ); + writer.startElement(Tag.META.toString()); + writer.addAttribute("name", "author"); + writer.addAttribute("content", "Author"); writer.endElement(); // Tag.META - writer.startElement( Tag.META.toString() ); - writer.addAttribute( "name", "date" ); - writer.addAttribute( "content", "Date" ); + writer.startElement(Tag.META.toString()); + writer.addAttribute("name", "date"); + writer.addAttribute("content", "Date"); writer.endElement(); // Tag.META writer.endElement(); // Tag.HEAD } - private void writeXhtmlBody( XMLWriter writer ) - { - writer.startElement( Tag.BODY.toString() ); - writer.startElement( Tag.P.toString() ); - writer.writeText( "Paragraph 1, line 1. Paragraph 1, line 2." ); + private void writeXhtmlBody(XMLWriter writer) { + writer.startElement(Tag.BODY.toString()); + writer.startElement(Tag.P.toString()); + writer.writeText("Paragraph 1, line 1. Paragraph 1, line 2."); writer.endElement(); // Tag.P - writer.startElement( Tag.DIV.toString() ); - writer.addAttribute( "class", "section" ); - writer.startElement( Tag.H2.toString() ); - writer.writeText( "Section title" ); + writer.startElement(Tag.DIV.toString()); + writer.addAttribute("class", "section"); + writer.startElement(Tag.H2.toString()); + writer.writeText("Section title"); writer.endElement(); // Tag.H2 writer.endElement(); // Tag.DIV writer.endElement(); // Tag.BODY } - private String expectedResult( String lineSeparator ) - { - return expectedResult( " ", lineSeparator ); + private String expectedResult(String lineSeparator) { + return expectedResult(" ", lineSeparator); } - private String expectedResult( String lineIndenter, String lineSeparator ) - { + private String expectedResult(String lineIndenter, String lineSeparator) { StringBuilder expected = new StringBuilder(); - expected.append( "" ).append( lineSeparator ); - expected.append( StringUtils.repeat( lineIndenter, 1 ) ).append( "" ).append( lineSeparator ); - expected.append( StringUtils.repeat( lineIndenter, - 2 ) ).append( "title" ).append( lineSeparator ); - expected.append( StringUtils.repeat( lineIndenter, - 2 ) ).append( "" ).append( lineSeparator ); - expected.append( StringUtils.repeat( lineIndenter, - 2 ) ).append( "" ).append( lineSeparator ); - expected.append( StringUtils.repeat( lineIndenter, 1 ) ).append( "" ).append( lineSeparator ); - expected.append( StringUtils.repeat( lineIndenter, 1 ) ).append( "" ).append( lineSeparator ); - expected.append( StringUtils.repeat( lineIndenter, - 2 ) ).append( "

    Paragraph 1, line 1. Paragraph 1, line 2.

    " ).append( lineSeparator ); - expected.append( StringUtils.repeat( lineIndenter, - 2 ) ).append( "
    " ).append( lineSeparator ); - expected.append( StringUtils.repeat( lineIndenter, - 3 ) ).append( "

    Section title

    " ).append( lineSeparator ); - expected.append( StringUtils.repeat( lineIndenter, 2 ) ).append( "
    " ).append( lineSeparator ); - expected.append( StringUtils.repeat( lineIndenter, 1 ) ).append( "" ).append( lineSeparator ); - expected.append( "" ); + expected.append("").append(lineSeparator); + expected.append(StringUtils.repeat(lineIndenter, 1)).append("").append(lineSeparator); + expected.append(StringUtils.repeat(lineIndenter, 2)) + .append("title") + .append(lineSeparator); + expected.append(StringUtils.repeat(lineIndenter, 2)) + .append("") + .append(lineSeparator); + expected.append(StringUtils.repeat(lineIndenter, 2)) + .append("") + .append(lineSeparator); + expected.append(StringUtils.repeat(lineIndenter, 1)).append("").append(lineSeparator); + expected.append(StringUtils.repeat(lineIndenter, 1)).append("").append(lineSeparator); + expected.append(StringUtils.repeat(lineIndenter, 2)) + .append("

    Paragraph 1, line 1. Paragraph 1, line 2.

    ") + .append(lineSeparator); + expected.append(StringUtils.repeat(lineIndenter, 2)) + .append("
    ") + .append(lineSeparator); + expected.append(StringUtils.repeat(lineIndenter, 3)) + .append("

    Section title

    ") + .append(lineSeparator); + expected.append(StringUtils.repeat(lineIndenter, 2)).append("
    ").append(lineSeparator); + expected.append(StringUtils.repeat(lineIndenter, 1)).append("").append(lineSeparator); + expected.append(""); return expected.toString(); } 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 7ca8cc48..93f4eacf 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,9 @@ import java.io.InputStream; import java.io.SequenceInputStream; -import org.codehaus.plexus.util.IOUtil; - import junit.framework.ComparisonFailure; import junit.framework.TestCase; +import org.codehaus.plexus.util.IOUtil; /** *

    XmlStreamReaderTest class.

    @@ -33,9 +32,7 @@ * @version $Id: $Id * @since 3.4.0 */ -public class XmlStreamReaderTest - extends TestCase -{ +public class XmlStreamReaderTest extends TestCase { /** french */ private static final String TEXT_LATIN1 = "eacute: \u00E9"; @@ -50,76 +47,63 @@ public class XmlStreamReaderTest /** Unicode: support everything */ private static final String TEXT_UNICODE = - TEXT_LATIN1 + ", " + TEXT_LATIN7 + ", " + TEXT_LATIN15 + ", " + TEXT_EUC_JP; + TEXT_LATIN1 + ", " + TEXT_LATIN7 + ", " + TEXT_LATIN15 + ", " + TEXT_EUC_JP; /** see http://unicode.org/faq/utf_bom.html#BOM */ - private static final byte[] BOM_UTF8 = { (byte) 0xEF, (byte) 0xBB, (byte) 0xBF }; + private static final byte[] BOM_UTF8 = {(byte) 0xEF, (byte) 0xBB, (byte) 0xBF}; - private static final byte[] BOM_UTF16BE = { (byte) 0xFE, (byte) 0xFF }; + private static final byte[] BOM_UTF16BE = {(byte) 0xFE, (byte) 0xFF}; - private static final byte[] BOM_UTF16LE = { (byte) 0xFF, (byte) 0xFE }; + private static final byte[] BOM_UTF16LE = {(byte) 0xFF, (byte) 0xFE}; - private static final byte[] BOM_UTF32BE = { (byte) 0x00, (byte) 0x00, (byte) 0xFF, (byte) 0xFE }; + private static final byte[] BOM_UTF32BE = {(byte) 0x00, (byte) 0x00, (byte) 0xFF, (byte) 0xFE}; - private static final byte[] BOM_UTF32LE = { (byte) 0xFF, (byte) 0xFE, (byte) 0x00, (byte) 0x00 }; + private static final byte[] BOM_UTF32LE = {(byte) 0xFF, (byte) 0xFE, (byte) 0x00, (byte) 0x00}; - private static String createXmlContent( String text, String encoding ) - { + private static String createXmlContent(String text, String encoding) { String xmlDecl = ""; - if ( encoding != null ) - { + if (encoding != null) { xmlDecl = ""; } String xml = xmlDecl + "\n" + text + ""; return xml; } - private static void checkXmlContent( String xml, String encoding ) - throws IOException - { - checkXmlContent( xml, encoding, null ); + private static void checkXmlContent(String xml, String encoding) throws IOException { + checkXmlContent(xml, encoding, null); } - private static void checkXmlContent( String xml, String encoding, byte... bom ) - throws IOException - { - byte[] xmlContent = xml.getBytes( encoding ); - InputStream in = new ByteArrayInputStream( xmlContent ); + private static void checkXmlContent(String xml, String encoding, byte... bom) throws IOException { + byte[] xmlContent = xml.getBytes(encoding); + InputStream in = new ByteArrayInputStream(xmlContent); - if ( bom != null ) - { - in = new SequenceInputStream( new ByteArrayInputStream( bom ), in ); + if (bom != null) { + in = new SequenceInputStream(new ByteArrayInputStream(bom), in); } - XmlStreamReader reader = new XmlStreamReader( in ); - assertEquals( encoding, reader.getEncoding() ); - String result = IOUtil.toString( reader ); - assertEquals( xml, result ); + XmlStreamReader reader = new XmlStreamReader(in); + assertEquals(encoding, reader.getEncoding()); + String result = IOUtil.toString(reader); + assertEquals(xml, result); } - private static void checkXmlStreamReader( String text, String encoding, String effectiveEncoding ) - throws IOException - { - checkXmlStreamReader( text, encoding, effectiveEncoding, null ); + private static void checkXmlStreamReader(String text, String encoding, String effectiveEncoding) + throws IOException { + checkXmlStreamReader(text, encoding, effectiveEncoding, null); } - private static void checkXmlStreamReader( String text, String encoding ) - throws IOException - { - checkXmlStreamReader( text, encoding, encoding, null ); + private static void checkXmlStreamReader(String text, String encoding) throws IOException { + checkXmlStreamReader(text, encoding, encoding, null); } - private static void checkXmlStreamReader( String text, String encoding, byte... bom ) - throws IOException - { - checkXmlStreamReader( text, encoding, encoding, bom ); + private static void checkXmlStreamReader(String text, String encoding, byte... bom) throws IOException { + checkXmlStreamReader(text, encoding, encoding, bom); } - private static void checkXmlStreamReader( String text, String encoding, String effectiveEncoding, byte... bom ) - throws IOException - { - String xml = createXmlContent( text, encoding ); - checkXmlContent( xml, effectiveEncoding, bom ); + private static void checkXmlStreamReader(String text, String encoding, String effectiveEncoding, byte... bom) + throws IOException { + String xml = createXmlContent(text, encoding); + checkXmlContent(xml, effectiveEncoding, bom); } /** @@ -127,12 +111,10 @@ private static void checkXmlStreamReader( String text, String encoding, String e * * @throws java.io.IOException if any. */ - public void testNoXmlHeader() - throws IOException - { + public void testNoXmlHeader() throws IOException { String xml = "text with no XML header"; - checkXmlContent( xml, "UTF-8" ); - checkXmlContent( xml, "UTF-8", BOM_UTF8 ); + checkXmlContent(xml, "UTF-8"); + checkXmlContent(xml, "UTF-8", BOM_UTF8); } /** @@ -140,11 +122,9 @@ public void testNoXmlHeader() * * @throws java.io.IOException if any. */ - public void testDefaultEncoding() - throws IOException - { - checkXmlStreamReader( TEXT_UNICODE, null, "UTF-8" ); - checkXmlStreamReader( TEXT_UNICODE, null, "UTF-8", BOM_UTF8 ); + public void testDefaultEncoding() throws IOException { + checkXmlStreamReader(TEXT_UNICODE, null, "UTF-8"); + checkXmlStreamReader(TEXT_UNICODE, null, "UTF-8", BOM_UTF8); } /** @@ -152,11 +132,9 @@ public void testDefaultEncoding() * * @throws java.io.IOException if any. */ - public void testUTF8Encoding() - throws IOException - { - checkXmlStreamReader( TEXT_UNICODE, "UTF-8" ); - checkXmlStreamReader( TEXT_UNICODE, "UTF-8", BOM_UTF8 ); + public void testUTF8Encoding() throws IOException { + checkXmlStreamReader(TEXT_UNICODE, "UTF-8"); + checkXmlStreamReader(TEXT_UNICODE, "UTF-8", BOM_UTF8); } /** @@ -164,12 +142,10 @@ public void testUTF8Encoding() * * @throws java.io.IOException if any. */ - public void testUTF16Encoding() - throws IOException - { - checkXmlStreamReader( TEXT_UNICODE, "UTF-16", "UTF-16BE", null ); - checkXmlStreamReader( TEXT_UNICODE, "UTF-16", "UTF-16LE", BOM_UTF16LE ); - checkXmlStreamReader( TEXT_UNICODE, "UTF-16", "UTF-16BE", BOM_UTF16BE ); + public void testUTF16Encoding() throws IOException { + checkXmlStreamReader(TEXT_UNICODE, "UTF-16", "UTF-16BE", null); + checkXmlStreamReader(TEXT_UNICODE, "UTF-16", "UTF-16LE", BOM_UTF16LE); + checkXmlStreamReader(TEXT_UNICODE, "UTF-16", "UTF-16BE", BOM_UTF16BE); } /** @@ -177,10 +153,8 @@ public void testUTF16Encoding() * * @throws java.io.IOException if any. */ - public void testUTF16BEEncoding() - throws IOException - { - checkXmlStreamReader( TEXT_UNICODE, "UTF-16BE" ); + public void testUTF16BEEncoding() throws IOException { + checkXmlStreamReader(TEXT_UNICODE, "UTF-16BE"); } /** @@ -188,10 +162,8 @@ public void testUTF16BEEncoding() * * @throws java.io.IOException if any. */ - public void testUTF16LEEncoding() - throws IOException - { - checkXmlStreamReader( TEXT_UNICODE, "UTF-16LE" ); + public void testUTF16LEEncoding() throws IOException { + checkXmlStreamReader(TEXT_UNICODE, "UTF-16LE"); } /** @@ -199,10 +171,8 @@ public void testUTF16LEEncoding() * * @throws java.io.IOException if any. */ - public void testLatin1Encoding() - throws IOException - { - checkXmlStreamReader( TEXT_LATIN1, "ISO-8859-1" ); + public void testLatin1Encoding() throws IOException { + checkXmlStreamReader(TEXT_LATIN1, "ISO-8859-1"); } /** @@ -210,10 +180,8 @@ public void testLatin1Encoding() * * @throws java.io.IOException if any. */ - public void testLatin7Encoding() - throws IOException - { - checkXmlStreamReader( TEXT_LATIN7, "ISO-8859-7" ); + public void testLatin7Encoding() throws IOException { + checkXmlStreamReader(TEXT_LATIN7, "ISO-8859-7"); } /** @@ -221,10 +189,8 @@ public void testLatin7Encoding() * * @throws java.io.IOException if any. */ - public void testLatin15Encoding() - throws IOException - { - checkXmlStreamReader( TEXT_LATIN15, "ISO-8859-15" ); + public void testLatin15Encoding() throws IOException { + checkXmlStreamReader(TEXT_LATIN15, "ISO-8859-15"); } /** @@ -232,10 +198,8 @@ public void testLatin15Encoding() * * @throws java.io.IOException if any. */ - public void testEUC_JPEncoding() - throws IOException - { - checkXmlStreamReader( TEXT_EUC_JP, "EUC-JP" ); + public void testEUC_JPEncoding() throws IOException { + checkXmlStreamReader(TEXT_EUC_JP, "EUC-JP"); } /** @@ -243,10 +207,8 @@ public void testEUC_JPEncoding() * * @throws java.io.IOException if any. */ - public void testEBCDICEncoding() - throws IOException - { - checkXmlStreamReader( "simple text in EBCDIC", "CP1047" ); + public void testEBCDICEncoding() throws IOException { + checkXmlStreamReader("simple text in EBCDIC", "CP1047"); } /** @@ -254,16 +216,11 @@ public void testEBCDICEncoding() * * @throws java.io.IOException if any. */ - 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 ) - { + 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 } } @@ -273,25 +230,23 @@ public void testInappropriateEncoding() * * @throws java.io.IOException if any. */ - public void testEncodingAttribute() - throws IOException - { + public void testEncodingAttribute() throws IOException { String xml = ""; - checkXmlContent( xml, "US-ASCII" ); + checkXmlContent(xml, "US-ASCII"); xml = ""; - checkXmlContent( xml, "US-ASCII" ); + checkXmlContent(xml, "US-ASCII"); xml = ""; - checkXmlContent( xml, "UTF-8" ); + checkXmlContent(xml, "UTF-8"); xml = "\n"; - checkXmlContent( xml, "US-ASCII" ); + checkXmlContent(xml, "US-ASCII"); xml = "\n"; - checkXmlContent( xml, "UTF-8" ); + checkXmlContent(xml, "UTF-8"); xml = ""; - checkXmlContent( xml, "UTF-8" ); + checkXmlContent(xml, "UTF-8"); } } 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 fa13aaa0..26e131cd 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/XmlStreamWriterTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/XmlStreamWriterTest.java @@ -1,7 +1,5 @@ package org.codehaus.plexus.util.xml; -import static org.junit.Assert.assertEquals; - /* * Copyright The Codehaus Foundation. * @@ -23,6 +21,8 @@ import org.junit.Test; +import static org.junit.Assert.assertEquals; + /** *

    XmlStreamWriterTest class.

    * @@ -30,8 +30,7 @@ * @version $Id: $Id * @since 3.4.0 */ -public class XmlStreamWriterTest -{ +public class XmlStreamWriterTest { /** french */ private static final String TEXT_LATIN1 = "eacute: \u00E9"; @@ -46,37 +45,31 @@ public class XmlStreamWriterTest /** Unicode: support everything */ private static final String TEXT_UNICODE = - TEXT_LATIN1 + ", " + TEXT_LATIN7 + ", " + TEXT_LATIN15 + ", " + TEXT_EUC_JP; + TEXT_LATIN1 + ", " + TEXT_LATIN7 + ", " + TEXT_LATIN15 + ", " + TEXT_EUC_JP; - private static String createXmlContent( String text, String encoding ) - { + private static String createXmlContent(String text, String encoding) { String xmlDecl = ""; - if ( encoding != null ) - { + if (encoding != null) { xmlDecl = ""; } String xml = xmlDecl + "\n" + text + ""; return xml; } - private static void checkXmlContent( String xml, String encoding ) - throws IOException - { + private static void checkXmlContent(String xml, String encoding) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); - XmlStreamWriter writer = new XmlStreamWriter( out ); - writer.write( xml ); + XmlStreamWriter writer = new XmlStreamWriter(out); + writer.write(xml); writer.close(); byte[] xmlContent = out.toByteArray(); - String result = new String( xmlContent, encoding ); - assertEquals( xml, result ); + String result = new String(xmlContent, encoding); + assertEquals(xml, result); } - private static void checkXmlWriter( String text, String encoding ) - throws IOException - { - String xml = createXmlContent( text, encoding ); - String effectiveEncoding = ( encoding == null ) ? "UTF-8" : encoding; - checkXmlContent( xml, effectiveEncoding ); + private static void checkXmlWriter(String text, String encoding) throws IOException { + String xml = createXmlContent(text, encoding); + String effectiveEncoding = (encoding == null) ? "UTF-8" : encoding; + checkXmlContent(xml, effectiveEncoding); } /** @@ -85,11 +78,9 @@ private static void checkXmlWriter( String text, String encoding ) * @throws java.io.IOException if any. */ @Test - public void testNoXmlHeader() - throws IOException - { + public void testNoXmlHeader() throws IOException { String xml = "text with no XML header"; - checkXmlContent( xml, "UTF-8" ); + checkXmlContent(xml, "UTF-8"); } /** @@ -98,15 +89,13 @@ public void testNoXmlHeader() * @throws java.io.IOException if any. */ @Test - public void testEmpty() - throws IOException - { + public void testEmpty() throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); - XmlStreamWriter writer = new XmlStreamWriter( out ); + XmlStreamWriter writer = new XmlStreamWriter(out); writer.flush(); - writer.write( "" ); + writer.write(""); writer.flush(); - writer.write( "." ); + writer.write("."); writer.flush(); writer.close(); } @@ -117,10 +106,8 @@ public void testEmpty() * @throws java.io.IOException if any. */ @Test - public void testDefaultEncoding() - throws IOException - { - checkXmlWriter( TEXT_UNICODE, null ); + public void testDefaultEncoding() throws IOException { + checkXmlWriter(TEXT_UNICODE, null); } /** @@ -129,10 +116,8 @@ public void testDefaultEncoding() * @throws java.io.IOException if any. */ @Test - public void testUTF8Encoding() - throws IOException - { - checkXmlWriter( TEXT_UNICODE, "UTF-8" ); + public void testUTF8Encoding() throws IOException { + checkXmlWriter(TEXT_UNICODE, "UTF-8"); } /** @@ -141,10 +126,8 @@ public void testUTF8Encoding() * @throws java.io.IOException if any. */ @Test - public void testUTF16Encoding() - throws IOException - { - checkXmlWriter( TEXT_UNICODE, "UTF-16" ); + public void testUTF16Encoding() throws IOException { + checkXmlWriter(TEXT_UNICODE, "UTF-16"); } /** @@ -153,10 +136,8 @@ public void testUTF16Encoding() * @throws java.io.IOException if any. */ @Test - public void testUTF16BEEncoding() - throws IOException - { - checkXmlWriter( TEXT_UNICODE, "UTF-16BE" ); + public void testUTF16BEEncoding() throws IOException { + checkXmlWriter(TEXT_UNICODE, "UTF-16BE"); } /** @@ -165,10 +146,8 @@ public void testUTF16BEEncoding() * @throws java.io.IOException if any. */ @Test - public void testUTF16LEEncoding() - throws IOException - { - checkXmlWriter( TEXT_UNICODE, "UTF-16LE" ); + public void testUTF16LEEncoding() throws IOException { + checkXmlWriter(TEXT_UNICODE, "UTF-16LE"); } /** @@ -177,10 +156,8 @@ public void testUTF16LEEncoding() * @throws java.io.IOException if any. */ @Test - public void testLatin1Encoding() - throws IOException - { - checkXmlWriter( TEXT_LATIN1, "ISO-8859-1" ); + public void testLatin1Encoding() throws IOException { + checkXmlWriter(TEXT_LATIN1, "ISO-8859-1"); } /** @@ -189,10 +166,8 @@ public void testLatin1Encoding() * @throws java.io.IOException if any. */ @Test - public void testLatin7Encoding() - throws IOException - { - checkXmlWriter( TEXT_LATIN7, "ISO-8859-7" ); + public void testLatin7Encoding() throws IOException { + checkXmlWriter(TEXT_LATIN7, "ISO-8859-7"); } /** @@ -201,10 +176,8 @@ public void testLatin7Encoding() * @throws java.io.IOException if any. */ @Test - public void testLatin15Encoding() - throws IOException - { - checkXmlWriter( TEXT_LATIN15, "ISO-8859-15" ); + public void testLatin15Encoding() throws IOException { + checkXmlWriter(TEXT_LATIN15, "ISO-8859-15"); } /** @@ -213,10 +186,8 @@ public void testLatin15Encoding() * @throws java.io.IOException if any. */ @Test - public void testEUC_JPEncoding() - throws IOException - { - checkXmlWriter( TEXT_EUC_JP, "EUC-JP" ); + public void testEUC_JPEncoding() throws IOException { + checkXmlWriter(TEXT_EUC_JP, "EUC-JP"); } /** @@ -225,9 +196,7 @@ public void testEUC_JPEncoding() * @throws java.io.IOException if any. */ @Test - public void testEBCDICEncoding() - throws IOException - { - checkXmlWriter( "simple text in EBCDIC", "CP1047" ); + public void testEBCDICEncoding() throws IOException { + checkXmlWriter("simple text in EBCDIC", "CP1047"); } } diff --git a/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java b/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java index 98f90ecc..bdfd76ca 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java @@ -16,9 +16,6 @@ * limitations under the License. */ -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -32,6 +29,9 @@ import org.codehaus.plexus.util.StringUtils; import org.junit.Test; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + /** * Test the {@link org.codehaus.plexus.util.xml.XmlUtil} class. * @@ -39,8 +39,7 @@ * @version $Id: $Id * @since 3.4.0 */ -public class XmlUtilTest -{ +public class XmlUtilTest { private String basedir; /** @@ -48,23 +47,18 @@ public class XmlUtilTest * * @return a {@link java.lang.String} object. */ - public final String getBasedir() - { - if ( null == basedir ) - { - basedir = System.getProperty( "basedir", new File( "" ).getAbsolutePath() ); + public final String getBasedir() { + if (null == basedir) { + basedir = System.getProperty("basedir", new File("").getAbsolutePath()); } return basedir; } - private File getTestOutputFile( String relPath ) - throws IOException - { - final File file = new File( getBasedir(), relPath ); + private File getTestOutputFile(String relPath) throws IOException { + final File file = new File(getBasedir(), relPath); final File parentFile = file.getParentFile(); - if ( !parentFile.isDirectory() && !parentFile.mkdirs() ) - { - throw new IOException( "Could not create test directory " + parentFile ); + if (!parentFile.isDirectory() && !parentFile.mkdirs()) { + throw new IOException("Could not create test directory " + parentFile); } return file; } @@ -75,28 +69,24 @@ private File getTestOutputFile( String relPath ) * @throws java.lang.Exception if any. */ @Test - public void testPrettyFormatInputStreamOutputStream() - throws Exception - { - File testDocument = new File( getBasedir(), "src/test/resources/testDocument.xhtml" ); - assertTrue( testDocument.exists() ); + public void testPrettyFormatInputStreamOutputStream() throws Exception { + File testDocument = new File(getBasedir(), "src/test/resources/testDocument.xhtml"); + assertTrue(testDocument.exists()); InputStream is = null; OutputStream os = null; - try - { - is = Files.newInputStream( testDocument.toPath() ); - os = Files.newOutputStream( getTestOutputFile( "target/test/prettyFormatTestDocumentOutputStream.xml" ).toPath() ); - - assertNotNull( is ); - assertNotNull( os ); - - XmlUtil.prettyFormat( is, os ); - } - finally - { - IOUtil.close( is ); - IOUtil.close( os ); + try { + is = Files.newInputStream(testDocument.toPath()); + os = Files.newOutputStream(getTestOutputFile("target/test/prettyFormatTestDocumentOutputStream.xml") + .toPath()); + + assertNotNull(is); + assertNotNull(os); + + XmlUtil.prettyFormat(is, os); + } finally { + IOUtil.close(is); + IOUtil.close(os); } } @@ -106,29 +96,23 @@ public void testPrettyFormatInputStreamOutputStream() * @throws java.lang.Exception if any. */ @Test - public void testPrettyFormatReaderWriter() - throws Exception - { - File testDocument = new File( getBasedir(), "src/test/resources/testDocument.xhtml" ); - assertTrue( testDocument.exists() ); + public void testPrettyFormatReaderWriter() throws Exception { + File testDocument = new File(getBasedir(), "src/test/resources/testDocument.xhtml"); + assertTrue(testDocument.exists()); Reader reader = null; Writer writer = null; - try - { - reader = ReaderFactory.newXmlReader( testDocument ); - writer = - WriterFactory.newXmlWriter( getTestOutputFile( "target/test/prettyFormatTestDocumentWriter.xml" ) ); + try { + reader = ReaderFactory.newXmlReader(testDocument); + writer = WriterFactory.newXmlWriter(getTestOutputFile("target/test/prettyFormatTestDocumentWriter.xml")); - assertNotNull( reader ); - assertNotNull( writer ); + assertNotNull(reader); + assertNotNull(writer); - XmlUtil.prettyFormat( reader, writer ); - } - finally - { - IOUtil.close( reader ); - IOUtil.close( writer ); + XmlUtil.prettyFormat(reader, writer); + } finally { + IOUtil.close(reader); + IOUtil.close(writer); } } @@ -138,34 +122,29 @@ public void testPrettyFormatReaderWriter() * @throws java.lang.Exception if any. */ @Test - public void testPrettyFormatString() - throws Exception - { - File testDocument = new File( getBasedir(), "src/test/resources/testDocument.xhtml" ); - assertTrue( testDocument.exists() ); + public void testPrettyFormatString() throws Exception { + File testDocument = new File(getBasedir(), "src/test/resources/testDocument.xhtml"); + assertTrue(testDocument.exists()); Reader reader = null; Writer writer = null; String content; - try - { - reader = ReaderFactory.newXmlReader( testDocument ); - content = IOUtil.toString( reader ); + try { + reader = ReaderFactory.newXmlReader(testDocument); + content = IOUtil.toString(reader); - reader = ReaderFactory.newXmlReader( testDocument ); + reader = ReaderFactory.newXmlReader(testDocument); writer = new StringWriter(); - XmlUtil.prettyFormat( reader, writer ); - } - finally - { - IOUtil.close( reader ); - IOUtil.close( writer ); + XmlUtil.prettyFormat(reader, writer); + } finally { + IOUtil.close(reader); + IOUtil.close(writer); } - assertNotNull( content ); + assertNotNull(content); - int countEOL = StringUtils.countMatches( content, XmlUtil.DEFAULT_LINE_SEPARATOR ); - assertTrue( countEOL < StringUtils.countMatches( writer.toString(), XmlUtil.DEFAULT_LINE_SEPARATOR ) ); + int countEOL = StringUtils.countMatches(content, XmlUtil.DEFAULT_LINE_SEPARATOR); + assertTrue(countEOL < StringUtils.countMatches(writer.toString(), XmlUtil.DEFAULT_LINE_SEPARATOR)); } /** @@ -174,28 +153,23 @@ public void testPrettyFormatString() * @throws java.lang.Exception if any. */ @Test - public void testPrettyFormatReaderWriter2() - throws Exception - { - File testDocument = new File( getBasedir(), "src/test/resources/test.xdoc.xhtml" ); - assertTrue( testDocument.exists() ); + public void testPrettyFormatReaderWriter2() throws Exception { + File testDocument = new File(getBasedir(), "src/test/resources/test.xdoc.xhtml"); + assertTrue(testDocument.exists()); Reader reader = null; Writer writer = null; - try - { - reader = ReaderFactory.newXmlReader( testDocument ); - writer = WriterFactory.newXmlWriter( getTestOutputFile( "target/test/prettyFormatTestXdocWriter.xml" ) ); + try { + reader = ReaderFactory.newXmlReader(testDocument); + writer = WriterFactory.newXmlWriter(getTestOutputFile("target/test/prettyFormatTestXdocWriter.xml")); - assertNotNull( reader ); - assertNotNull( writer ); + assertNotNull(reader); + assertNotNull(writer); - XmlUtil.prettyFormat( reader, writer ); - } - finally - { - IOUtil.close( reader ); - IOUtil.close( writer ); + XmlUtil.prettyFormat(reader, writer); + } finally { + IOUtil.close(reader); + IOUtil.close(writer); } } } diff --git a/src/test/java/org/codehaus/plexus/util/xml/XmlWriterUtilTest.java b/src/test/java/org/codehaus/plexus/util/xml/XmlWriterUtilTest.java index 702aa1d3..8b0e3972 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/XmlWriterUtilTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/XmlWriterUtilTest.java @@ -16,9 +16,6 @@ * limitations under the License. */ -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import java.io.ByteArrayOutputStream; import java.io.OutputStream; import java.io.Writer; @@ -28,6 +25,9 @@ import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + /** *

    XmlWriterUtilTest class.

    * @@ -35,8 +35,7 @@ * @version $Id: $Id * @since 3.4.0 */ -public class XmlWriterUtilTest -{ +public class XmlWriterUtilTest { private OutputStream output; private Writer writer; @@ -49,12 +48,10 @@ public class XmlWriterUtilTest * @throws java.lang.Exception if any. */ @Before - public void setUp() - throws Exception - { + public void setUp() throws Exception { output = new ByteArrayOutputStream(); - writer = WriterFactory.newXmlWriter( output ); - xmlWriter = new PrettyPrintXMLWriter( writer ); + writer = WriterFactory.newXmlWriter(output); + xmlWriter = new PrettyPrintXMLWriter(writer); } /** @@ -63,9 +60,7 @@ public void setUp() * @throws java.lang.Exception if any. */ @After - public void tearDown() - throws Exception - { + public void tearDown() throws Exception { xmlWriter = null; writer = null; output = null; @@ -78,12 +73,10 @@ public void tearDown() * @throws java.lang.Exception if any */ @Test - public void testWriteLineBreakXMLWriter() - throws Exception - { - XmlWriterUtil.writeLineBreak( xmlWriter ); + public void testWriteLineBreakXMLWriter() throws Exception { + XmlWriterUtil.writeLineBreak(xmlWriter); writer.close(); - assertTrue( StringUtils.countMatches( output.toString(), XmlWriterUtil.LS ) == 1 ); + assertTrue(StringUtils.countMatches(output.toString(), XmlWriterUtil.LS) == 1); } /** @@ -93,12 +86,10 @@ public void testWriteLineBreakXMLWriter() * @throws java.lang.Exception if any */ @Test - public void testWriteLineBreakXMLWriterInt() - throws Exception - { - XmlWriterUtil.writeLineBreak( xmlWriter, 10 ); + public void testWriteLineBreakXMLWriterInt() throws Exception { + XmlWriterUtil.writeLineBreak(xmlWriter, 10); writer.close(); - assertTrue( StringUtils.countMatches( output.toString(), XmlWriterUtil.LS ) == 10 ); + assertTrue(StringUtils.countMatches(output.toString(), XmlWriterUtil.LS) == 10); } /** @@ -108,15 +99,13 @@ public void testWriteLineBreakXMLWriterInt() * @throws java.lang.Exception if any */ @Test - public void testWriteLineBreakXMLWriterIntInt() - throws Exception - { - XmlWriterUtil.writeLineBreak( xmlWriter, 10, 2 ); + public void testWriteLineBreakXMLWriterIntInt() 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 ); + assertTrue(StringUtils.countMatches(output.toString(), XmlWriterUtil.LS) == 10); + assertTrue(StringUtils.countMatches( + output.toString(), StringUtils.repeat(" ", 2 * XmlWriterUtil.DEFAULT_INDENTATION_SIZE)) + == 1); } /** @@ -126,13 +115,11 @@ public void testWriteLineBreakXMLWriterIntInt() * @throws java.lang.Exception if any */ @Test - public void testWriteLineBreakXMLWriterIntIntInt() - throws Exception - { - XmlWriterUtil.writeLineBreak( xmlWriter, 10, 2, 4 ); + public void testWriteLineBreakXMLWriterIntIntInt() 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 ); + assertTrue(StringUtils.countMatches(output.toString(), XmlWriterUtil.LS) == 10); + assertTrue(StringUtils.countMatches(output.toString(), StringUtils.repeat(" ", 2 * 4)) == 1); } /** @@ -142,15 +129,14 @@ public void testWriteLineBreakXMLWriterIntIntInt() * @throws java.lang.Exception if any */ @Test - public void testWriteCommentLineBreakXMLWriter() - throws Exception - { - XmlWriterUtil.writeCommentLineBreak( xmlWriter ); + public void testWriteCommentLineBreakXMLWriter() 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() ); + sb.append("") + .append(XmlWriterUtil.LS); + assertEquals(output.toString(), sb.toString()); + assertTrue(output.toString().length() == XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length()); } /** @@ -160,19 +146,17 @@ public void testWriteCommentLineBreakXMLWriter() * @throws java.lang.Exception if any */ @Test - public void testWriteCommentLineBreakXMLWriterInt() - throws Exception - { - XmlWriterUtil.writeCommentLineBreak( xmlWriter, 20 ); + public void testWriteCommentLineBreakXMLWriterInt() throws Exception { + XmlWriterUtil.writeCommentLineBreak(xmlWriter, 20); writer.close(); - assertEquals( output.toString(), "" + XmlWriterUtil.LS ); + assertEquals(output.toString(), "" + XmlWriterUtil.LS); tearDown(); setUp(); - XmlWriterUtil.writeCommentLineBreak( xmlWriter, 10 ); + XmlWriterUtil.writeCommentLineBreak(xmlWriter, 10); writer.close(); - assertEquals( output.toString(), output.toString(), "" + XmlWriterUtil.LS ); + assertEquals(output.toString(), output.toString(), "" + XmlWriterUtil.LS); } /** @@ -182,38 +166,40 @@ public void testWriteCommentLineBreakXMLWriterInt() * @throws java.lang.Exception if any */ @Test - public void testWriteCommentXMLWriterString() - throws Exception - { - XmlWriterUtil.writeComment( xmlWriter, "hello" ); + public void testWriteCommentXMLWriterString() 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() ); + sb.append("") + .append(XmlWriterUtil.LS); + assertEquals(output.toString(), sb.toString()); + assertTrue(output.toString().length() == XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length()); tearDown(); setUp(); - XmlWriterUtil.writeComment( xmlWriter, - "hellooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo" ); + XmlWriterUtil.writeComment( + xmlWriter, "hellooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo"); writer.close(); sb = new StringBuffer(); - sb.append( "" ).append( XmlWriterUtil.LS ); - assertEquals( output.toString(), sb.toString() ); - assertTrue( output.toString().length() >= XmlWriterUtil.DEFAULT_COLUMN_LINE ); + sb.append("") + .append(XmlWriterUtil.LS); + assertEquals(output.toString(), sb.toString()); + assertTrue(output.toString().length() >= XmlWriterUtil.DEFAULT_COLUMN_LINE); tearDown(); setUp(); - XmlWriterUtil.writeComment( xmlWriter, "hello\nworld" ); + XmlWriterUtil.writeComment(xmlWriter, "hello\nworld"); writer.close(); sb = new StringBuffer(); - sb.append( "" ).append( XmlWriterUtil.LS ); - sb.append( "" ).append( XmlWriterUtil.LS ); - assertEquals( output.toString(), sb.toString() ); - assertTrue( output.toString().length() == 2 - * ( XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length() ) ); + sb.append("") + .append(XmlWriterUtil.LS); + sb.append("") + .append(XmlWriterUtil.LS); + assertEquals(output.toString(), sb.toString()); + assertTrue( + output.toString().length() == 2 * (XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length())); } /** @@ -223,33 +209,37 @@ public void testWriteCommentXMLWriterString() * @throws java.lang.Exception if any */ @Test - public void testWriteCommentXMLWriterStringInt() - throws Exception - { - String indent = StringUtils.repeat( " ", 2 * XmlWriterUtil.DEFAULT_INDENTATION_SIZE ); + public void testWriteCommentXMLWriterStringInt() throws Exception { + String indent = StringUtils.repeat(" ", 2 * XmlWriterUtil.DEFAULT_INDENTATION_SIZE); - XmlWriterUtil.writeComment( xmlWriter, "hello", 2 ); + XmlWriterUtil.writeComment(xmlWriter, "hello", 2); writer.close(); StringBuffer sb = new StringBuffer(); - sb.append( indent ); - sb.append( "" ).append( XmlWriterUtil.LS ); - assertEquals( output.toString(), sb.toString() ); - assertTrue( output.toString().length() == XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length() - + 2 * XmlWriterUtil.DEFAULT_INDENTATION_SIZE ); + sb.append(indent); + sb.append("") + .append(XmlWriterUtil.LS); + assertEquals(output.toString(), sb.toString()); + assertTrue(output.toString().length() + == XmlWriterUtil.DEFAULT_COLUMN_LINE + - 1 + + XmlWriterUtil.LS.length() + + 2 * XmlWriterUtil.DEFAULT_INDENTATION_SIZE); tearDown(); setUp(); - XmlWriterUtil.writeComment( xmlWriter, "hello\nworld", 2 ); + XmlWriterUtil.writeComment(xmlWriter, "hello\nworld", 2); writer.close(); sb = new StringBuffer(); - sb.append( indent ); - sb.append( "" ).append( XmlWriterUtil.LS ); - sb.append( indent ); - 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() ); + sb.append(indent); + sb.append("") + .append(XmlWriterUtil.LS); + sb.append(indent); + 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()); } /** @@ -259,33 +249,34 @@ public void testWriteCommentXMLWriterStringInt() * @throws java.lang.Exception if any */ @Test - public void testWriteCommentXMLWriterStringIntInt() - throws Exception - { - String repeat = StringUtils.repeat( " ", 2 * 4 ); + public void testWriteCommentXMLWriterStringIntInt() throws Exception { + String repeat = StringUtils.repeat(" ", 2 * 4); - XmlWriterUtil.writeComment( xmlWriter, "hello", 2, 4 ); + XmlWriterUtil.writeComment(xmlWriter, "hello", 2, 4); writer.close(); StringBuffer sb = new StringBuffer(); - sb.append( repeat ); - sb.append( "" ).append( XmlWriterUtil.LS ); - assertEquals( output.toString(), sb.toString() ); - assertTrue( output.toString().length() == XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length() - + 2 * 4 ); + sb.append(repeat); + sb.append("") + .append(XmlWriterUtil.LS); + assertEquals(output.toString(), sb.toString()); + assertTrue(output.toString().length() + == XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length() + 2 * 4); tearDown(); setUp(); - XmlWriterUtil.writeComment( xmlWriter, "hello\nworld", 2, 4 ); + XmlWriterUtil.writeComment(xmlWriter, "hello\nworld", 2, 4); writer.close(); sb = new StringBuffer(); - sb.append( repeat ); - sb.append( "" ).append( XmlWriterUtil.LS ); - sb.append( repeat ); - 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() ); + sb.append(repeat); + sb.append("") + .append(XmlWriterUtil.LS); + sb.append(repeat); + 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()); } /** @@ -295,29 +286,27 @@ public void testWriteCommentXMLWriterStringIntInt() * @throws java.lang.Exception if any */ @Test - public void testWriteCommentXMLWriterStringIntIntInt() - throws Exception - { - String indent = StringUtils.repeat( " ", 2 * 4 ); + public void testWriteCommentXMLWriterStringIntIntInt() throws Exception { + String indent = StringUtils.repeat(" ", 2 * 4); - XmlWriterUtil.writeComment( xmlWriter, "hello", 2, 4, 50 ); + XmlWriterUtil.writeComment(xmlWriter, "hello", 2, 4, 50); writer.close(); StringBuffer sb = new StringBuffer(); - sb.append( indent ); - sb.append( "" ).append( XmlWriterUtil.LS ); - assertEquals( output.toString(), sb.toString() ); - assertTrue( output.toString().length() == 50 - 1 + XmlWriterUtil.LS.length() + 2 * 4 ); + sb.append(indent); + sb.append("").append(XmlWriterUtil.LS); + assertEquals(output.toString(), sb.toString()); + assertTrue(output.toString().length() == 50 - 1 + XmlWriterUtil.LS.length() + 2 * 4); tearDown(); setUp(); - XmlWriterUtil.writeComment( xmlWriter, "hello", 2, 4, 10 ); + XmlWriterUtil.writeComment(xmlWriter, "hello", 2, 4, 10); writer.close(); sb = new StringBuffer(); - sb.append( indent ); - sb.append( "" ).append( XmlWriterUtil.LS ); - assertEquals( output.toString(), sb.toString() ); - assertTrue( output.toString().length() >= 10 + 2 * 4 ); + sb.append(indent); + sb.append("").append(XmlWriterUtil.LS); + assertEquals(output.toString(), sb.toString()); + assertTrue(output.toString().length() >= 10 + 2 * 4); } /** @@ -327,40 +316,56 @@ public void testWriteCommentXMLWriterStringIntIntInt() * @throws java.lang.Exception if any */ @Test - public void testWriteCommentTextXMLWriterStringInt() - throws Exception - { - XmlWriterUtil.writeCommentText( xmlWriter, "hello", 0 ); + public void testWriteCommentTextXMLWriterStringInt() throws Exception { + XmlWriterUtil.writeCommentText(xmlWriter, "hello", 0); writer.close(); StringBuffer sb = new StringBuffer(); - sb.append( XmlWriterUtil.LS ); - sb.append( "" ).append( XmlWriterUtil.LS ); - sb.append( "" ).append( XmlWriterUtil.LS ); - sb.append( "" ).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() ); + sb.append(XmlWriterUtil.LS); + sb.append("") + .append(XmlWriterUtil.LS); + sb.append("") + .append(XmlWriterUtil.LS); + sb.append("") + .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()); tearDown(); setUp(); - String indent = StringUtils.repeat( " ", 2 * 2 ); + String indent = StringUtils.repeat(" ", 2 * 2); - XmlWriterUtil.writeCommentText( xmlWriter, "hello world with end of line\n and " - + "loooooooooooooooooooooooooooooooooooooooooooooooooooooonnnnnnnnnnong line", 2 ); + XmlWriterUtil.writeCommentText( + xmlWriter, + "hello world with end of line\n and " + + "loooooooooooooooooooooooooooooooooooooooooooooooooooooonnnnnnnnnnong line", + 2); writer.close(); sb = new StringBuffer(); - sb.append( XmlWriterUtil.LS ); - sb.append( indent ).append( "" ).append( XmlWriterUtil.LS ); - sb.append( indent ).append( "" ).append( XmlWriterUtil.LS ); - sb.append( indent ).append( "" ).append( XmlWriterUtil.LS ); - sb.append( indent ).append( "" ).append( XmlWriterUtil.LS ); - sb.append( indent ).append( "" ).append( XmlWriterUtil.LS ); - sb.append( indent ).append( "" ).append( XmlWriterUtil.LS ); - sb.append( XmlWriterUtil.LS ); - sb.append( indent ); - assertEquals( output.toString(), sb.toString() ); + sb.append(XmlWriterUtil.LS); + sb.append(indent) + .append("") + .append(XmlWriterUtil.LS); + sb.append(indent) + .append("") + .append(XmlWriterUtil.LS); + sb.append(indent) + .append("") + .append(XmlWriterUtil.LS); + sb.append(indent) + .append("") + .append(XmlWriterUtil.LS); + sb.append(indent) + .append("") + .append(XmlWriterUtil.LS); + sb.append(indent) + .append("") + .append(XmlWriterUtil.LS); + sb.append(XmlWriterUtil.LS); + sb.append(indent); + assertEquals(output.toString(), sb.toString()); } /** @@ -370,23 +375,27 @@ public void testWriteCommentTextXMLWriterStringInt() * @throws java.lang.Exception if any */ @Test - public void testWriteCommentTextXMLWriterStringIntInt() - throws Exception - { - String indent = StringUtils.repeat( " ", 2 * 4 ); + public void testWriteCommentTextXMLWriterStringIntInt() throws Exception { + String indent = StringUtils.repeat(" ", 2 * 4); - XmlWriterUtil.writeCommentText( xmlWriter, "hello", 2, 4 ); + XmlWriterUtil.writeCommentText(xmlWriter, "hello", 2, 4); writer.close(); StringBuilder sb = new StringBuilder(); - sb.append( XmlWriterUtil.LS ); - sb.append( indent ).append( "" ).append( XmlWriterUtil.LS ); - sb.append( indent ).append( "" ).append( XmlWriterUtil.LS ); - sb.append( indent ).append( "" ).append( XmlWriterUtil.LS ); - sb.append( XmlWriterUtil.LS ); - sb.append( indent ); - assertEquals( output.toString(), sb.toString() ); - assertTrue( output.toString().length() == 3 * ( 80 - 1 + XmlWriterUtil.LS.length() ) + 4 * 2 * 4 - + 2 * XmlWriterUtil.LS.length() ); + sb.append(XmlWriterUtil.LS); + sb.append(indent) + .append("") + .append(XmlWriterUtil.LS); + sb.append(indent) + .append("") + .append(XmlWriterUtil.LS); + sb.append(indent) + .append("") + .append(XmlWriterUtil.LS); + sb.append(XmlWriterUtil.LS); + sb.append(indent); + assertEquals(output.toString(), sb.toString()); + assertTrue(output.toString().length() + == 3 * (80 - 1 + XmlWriterUtil.LS.length()) + 4 * 2 * 4 + 2 * XmlWriterUtil.LS.length()); } /** @@ -396,23 +405,27 @@ public void testWriteCommentTextXMLWriterStringIntInt() * @throws java.lang.Exception if any */ @Test - public void testWriteCommentTextXMLWriterStringIntIntInt() - throws Exception - { - String indent = StringUtils.repeat( " ", 2 * 4 ); + public void testWriteCommentTextXMLWriterStringIntIntInt() throws Exception { + String indent = StringUtils.repeat(" ", 2 * 4); - XmlWriterUtil.writeCommentText( xmlWriter, "hello", 2, 4, 50 ); + XmlWriterUtil.writeCommentText(xmlWriter, "hello", 2, 4, 50); writer.close(); StringBuilder sb = new StringBuilder(); - sb.append( XmlWriterUtil.LS ); - sb.append( indent ).append( "" ).append( XmlWriterUtil.LS ); - sb.append( indent ).append( "" ).append( XmlWriterUtil.LS ); - sb.append( indent ).append( "" ).append( XmlWriterUtil.LS ); - sb.append( XmlWriterUtil.LS ); - sb.append( indent ); - assertEquals( output.toString(), sb.toString() ); - assertTrue( output.toString().length() == 3 * ( 50 - 1 + XmlWriterUtil.LS.length() ) + 4 * 2 * 4 - + 2 * XmlWriterUtil.LS.length() ); + sb.append(XmlWriterUtil.LS); + sb.append(indent) + .append("") + .append(XmlWriterUtil.LS); + sb.append(indent) + .append("") + .append(XmlWriterUtil.LS); + sb.append(indent) + .append("") + .append(XmlWriterUtil.LS); + sb.append(XmlWriterUtil.LS); + sb.append(indent); + assertEquals(output.toString(), sb.toString()); + assertTrue(output.toString().length() + == 3 * (50 - 1 + XmlWriterUtil.LS.length()) + 4 * 2 * 4 + 2 * XmlWriterUtil.LS.length()); } /** @@ -422,14 +435,13 @@ public void testWriteCommentTextXMLWriterStringIntIntInt() * @throws java.lang.Exception if any */ @Test - public void testWriteCommentNull() - throws Exception - { - XmlWriterUtil.writeComment( xmlWriter, null ); + public void testWriteCommentNull() throws Exception { + XmlWriterUtil.writeComment(xmlWriter, null); writer.close(); StringBuilder sb = new StringBuilder(); - sb.append( "" ).append( XmlWriterUtil.LS ); - assertEquals( output.toString(), sb.toString() ); + sb.append("") + .append(XmlWriterUtil.LS); + assertEquals(output.toString(), sb.toString()); } /** @@ -439,14 +451,13 @@ public void testWriteCommentNull() * @throws java.lang.Exception if any */ @Test - public void testWriteCommentShort() - throws Exception - { - XmlWriterUtil.writeComment( xmlWriter, "This is a short text" ); + public void testWriteCommentShort() throws Exception { + XmlWriterUtil.writeComment(xmlWriter, "This is a short text"); writer.close(); StringBuilder sb = new StringBuilder(); - sb.append( "" ).append( XmlWriterUtil.LS ); - assertEquals( output.toString(), sb.toString() ); + sb.append("") + .append(XmlWriterUtil.LS); + assertEquals(output.toString(), sb.toString()); } /** @@ -456,18 +467,22 @@ public void testWriteCommentShort() * @throws java.lang.Exception if any */ @Test - public void testWriteCommentLong() - throws Exception - { - XmlWriterUtil.writeComment( xmlWriter, "Maven is a software project management and comprehension tool. " - + "Based on the concept of a project object model (POM), Maven can manage a project's build, reporting " - + "and documentation from a central piece of information." ); + public void testWriteCommentLong() throws Exception { + XmlWriterUtil.writeComment( + xmlWriter, + "Maven is a software project management and comprehension tool. " + + "Based on the concept of a project object model (POM), Maven can manage a project's build, reporting " + + "and documentation from a central piece of information."); writer.close(); StringBuilder sb = new StringBuilder(); - sb.append( "" ).append( XmlWriterUtil.LS ); - sb.append( "" ).append( XmlWriterUtil.LS ); - sb.append( "" ).append( XmlWriterUtil.LS ); - sb.append( "" ).append( XmlWriterUtil.LS ); - assertEquals( output.toString(), sb.toString() ); + sb.append("") + .append(XmlWriterUtil.LS); + sb.append("") + .append(XmlWriterUtil.LS); + sb.append("") + .append(XmlWriterUtil.LS); + sb.append("") + .append(XmlWriterUtil.LS); + assertEquals(output.toString(), sb.toString()); } } 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 3d3cb5ec..f9faac45 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomBuilderTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomBuilderTest.java @@ -16,10 +16,6 @@ * limitations under the License. */ -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.io.StringReader; import java.io.StringWriter; @@ -29,6 +25,10 @@ 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.assertTrue; + /** * Test the Xpp3DomBuilder. * @@ -36,8 +36,7 @@ * @version $Id: $Id * @since 3.4.0 */ -public class Xpp3DomBuilderTest -{ +public class Xpp3DomBuilderTest { private static final String LS = System.lineSeparator(); /** @@ -46,16 +45,14 @@ public class Xpp3DomBuilderTest * @throws java.lang.Exception if any. */ @Test - public void testBuildFromReader() - throws Exception - { + public void testBuildFromReader() throws Exception { String domString = createDomString(); - Xpp3Dom dom = Xpp3DomBuilder.build( new StringReader( domString ) ); + Xpp3Dom dom = Xpp3DomBuilder.build(new StringReader(domString)); Xpp3Dom expectedDom = createExpectedDom(); - assertEquals( "check DOMs match", expectedDom, dom ); + assertEquals("check DOMs match", expectedDom, dom); } /** @@ -64,18 +61,17 @@ public void testBuildFromReader() * @throws java.lang.Exception if any. */ @Test - public void testBuildTrimming() - throws Exception - { + public void testBuildTrimming() throws Exception { String domString = createDomString(); - Xpp3Dom dom = Xpp3DomBuilder.build( new StringReader( domString ), true ); + Xpp3Dom dom = Xpp3DomBuilder.build(new StringReader(domString), true); - assertEquals( "test with trimming on", "element1", dom.getChild( "el1" ).getValue() ); + assertEquals("test with trimming on", "element1", dom.getChild("el1").getValue()); - dom = Xpp3DomBuilder.build( new StringReader( domString ), false ); + dom = Xpp3DomBuilder.build(new StringReader(domString), false); - assertEquals( "test with trimming off", " element1\n ", dom.getChild( "el1" ).getValue() ); + assertEquals( + "test with trimming off", " element1\n ", dom.getChild("el1").getValue()); } /** @@ -84,16 +80,14 @@ public void testBuildTrimming() * @throws java.lang.Exception if any. */ @Test - public void testBuildFromXpp3Dom() - throws Exception - { + public void testBuildFromXpp3Dom() throws Exception { Xpp3Dom expectedDom = createExpectedDom(); Xpp3Dom dom = null; XmlPullParser parser = new MXParser(); String domString = "" + createDomString() + ""; - parser.setInput( new StringReader( domString ) ); + parser.setInput(new StringReader(domString)); int eventType = parser.getEventType(); @@ -101,63 +95,47 @@ public void testBuildFromXpp3Dom() boolean newRootClosed = false; boolean rootClosed = false; - while ( eventType != XmlPullParser.END_DOCUMENT ) - { - if ( eventType == XmlPullParser.START_TAG ) - { + while (eventType != XmlPullParser.END_DOCUMENT) { + if (eventType == XmlPullParser.START_TAG) { String rawName = parser.getName(); - if ( "root".equals( rawName ) ) - { - dom = Xpp3DomBuilder.build( parser ); + if ("root".equals(rawName)) { + dom = Xpp3DomBuilder.build(parser); } - } - else if ( eventType == XmlPullParser.END_TAG ) - { + } else if (eventType == XmlPullParser.END_TAG) { String rawName = parser.getName(); - if ( "configuration".equals( rawName ) ) - { + if ("configuration".equals(rawName)) { configurationClosed = true; - } - else if ( "newRoot".equals( rawName ) ) - { + } else if ("newRoot".equals(rawName)) { newRootClosed = true; - } - else if ( "root".equals( rawName ) ) - { + } else if ("root".equals(rawName)) { rootClosed = true; } } 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("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); } /** * Test we get an error from the parser, and don't hit the IllegalStateException. */ @Test - public void testUnclosedXml() - { + public void testUnclosedXml() { String domString = "" + createDomString(); - try - { - Xpp3DomBuilder.build( new StringReader( domString ) ); - } - catch ( XmlPullParserException expected ) - { + try { + Xpp3DomBuilder.build(new StringReader(domString)); + } catch (XmlPullParserException expected) { // correct - assertTrue( true ); - } - catch ( IOException expected ) - { + assertTrue(true); + } catch (IOException expected) { // this will do too - assertTrue( true ); + assertTrue(true); } } @@ -168,18 +146,18 @@ public void testUnclosedXml() * @throws org.codehaus.plexus.util.xml.pull.XmlPullParserException if any. */ @Test - public void testEscapingInContent() - throws IOException, XmlPullParserException - { - Xpp3Dom dom = Xpp3DomBuilder.build( new StringReader( getEncodedString() ) ); + 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("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()); StringWriter w = new StringWriter(); - Xpp3DomWriter.write( w, dom ); - assertEquals( "Compare stringified DOMs", getExpectedString(), w.toString() ); + Xpp3DomWriter.write(w, dom); + assertEquals("Compare stringified DOMs", getExpectedString(), w.toString()); } /** @@ -189,18 +167,16 @@ public void testEscapingInContent() * @throws org.codehaus.plexus.util.xml.pull.XmlPullParserException if any. */ @Test - public void testEscapingInAttributes() - throws IOException, XmlPullParserException - { + public void testEscapingInAttributes() throws IOException, XmlPullParserException { String s = getAttributeEncodedString(); - Xpp3Dom dom = Xpp3DomBuilder.build( new StringReader( s ) ); + Xpp3Dom dom = Xpp3DomBuilder.build(new StringReader(s)); - assertEquals( "Check attribute value", "", dom.getChild( "el" ).getAttribute( "att" ) ); + assertEquals("Check attribute value", "", dom.getChild("el").getAttribute("att")); StringWriter w = new StringWriter(); - Xpp3DomWriter.write( w, dom ); + Xpp3DomWriter.write(w, dom); String newString = w.toString(); - assertEquals( "Compare stringified DOMs", newString, s ); + assertEquals("Compare stringified DOMs", newString, s); } /** @@ -210,70 +186,61 @@ public void testEscapingInAttributes() * @throws org.codehaus.plexus.util.xml.pull.XmlPullParserException if any. */ @Test - public void testInputLocationTracking() - throws IOException, XmlPullParserException - { + public void testInputLocationTracking() throws IOException, XmlPullParserException { Xpp3DomBuilder.InputLocationBuilder ilb = new Xpp3DomBuilder.InputLocationBuilder() { - public Object toInputLocation( XmlPullParser parser ) - { + public Object toInputLocation(XmlPullParser parser) { return parser.getLineNumber(); // store only line number as a simple Integer } - }; - Xpp3Dom dom = Xpp3DomBuilder.build( new StringReader( createDomString() ), true, ilb ); + Xpp3Dom dom = Xpp3DomBuilder.build(new StringReader(createDomString()), true, ilb); Xpp3Dom expectedDom = createExpectedDom(); - assertEquals( "root input location", expectedDom.getInputLocation(), dom.getInputLocation() ); - 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() ); - - 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("root input location", expectedDom.getInputLocation(), dom.getInputLocation()); + 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()); + + if ("el2".equals(elt.getName())) { + Xpp3Dom el3 = elt.getChild(0); + Xpp3Dom expectedEl3 = expectedElt.getChild(0); + assertEquals(el3.getName() + " input location", expectedEl3.getInputLocation(), el3.getInputLocation()); } } } - private static String getAttributeEncodedString() - { + private static String getAttributeEncodedString() { StringBuilder domString = new StringBuilder(); - domString.append( "" ); - domString.append( LS ); - domString.append( " bar" ); - domString.append( LS ); - domString.append( "" ); + domString.append(""); + domString.append(LS); + domString.append(" bar"); + domString.append(LS); + domString.append(""); return domString.toString(); } - private static String getEncodedString() - { + private static String getEncodedString() { StringBuilder domString = new StringBuilder(); - domString.append( "\n" ); - domString.append( " \"text\"\n" ); - domString.append( " \"text\"]]>\n" ); - domString.append( " <b>"text"</b>\n" ); - domString.append( "" ); + domString.append("\n"); + domString.append(" \"text\"\n"); + domString.append(" \"text\"]]>\n"); + domString.append(" <b>"text"</b>\n"); + domString.append(""); return domString.toString(); } - private static String getExpectedString() - { + private static String getExpectedString() { StringBuilder domString = new StringBuilder(); - domString.append( "" ); - domString.append( LS ); - domString.append( " "text"" ); - domString.append( LS ); - domString.append( " <b>"text"</b>" ); - domString.append( LS ); - domString.append( " <b>"text"</b>" ); - domString.append( LS ); - domString.append( "" ); + domString.append(""); + domString.append(LS); + domString.append(" "text""); + domString.append(LS); + domString.append(" <b>"text"</b>"); + domString.append(LS); + domString.append(" <b>"text"</b>"); + domString.append(LS); + domString.append(""); return domString.toString(); } @@ -282,54 +249,52 @@ private static String getExpectedString() // HELPER METHODS // - private static String createDomString() - { + private static String createDomString() { StringBuilder buf = new StringBuilder(); - buf.append( "\n" ); - buf.append( " element1\n \n" ); - buf.append( " \n" ); - buf.append( " element3\n" ); - buf.append( " \n" ); - buf.append( " \n" ); - buf.append( " \n" ); - buf.append( " do not trim \n" ); - buf.append( "\n" ); + buf.append("\n"); + buf.append(" element1\n \n"); + buf.append(" \n"); + buf.append(" element3\n"); + buf.append(" \n"); + buf.append(" \n"); + buf.append(" \n"); + buf.append(" do not trim \n"); + buf.append("\n"); return buf.toString(); } - private static Xpp3Dom createExpectedDom() - { + private static Xpp3Dom createExpectedDom() { int line = 1; - Xpp3Dom expectedDom = new Xpp3Dom( "root" ); - expectedDom.setInputLocation( line ); - Xpp3Dom el1 = new Xpp3Dom( "el1" ); - el1.setInputLocation( ++line ); - el1.setValue( "element1" ); - expectedDom.addChild( el1 ); + Xpp3Dom expectedDom = new Xpp3Dom("root"); + expectedDom.setInputLocation(line); + Xpp3Dom el1 = new Xpp3Dom("el1"); + el1.setInputLocation(++line); + el1.setValue("element1"); + expectedDom.addChild(el1); ++line; // newline trimmed in Xpp3Dom but not in source - Xpp3Dom el2 = new Xpp3Dom( "el2" ); - el2.setInputLocation( ++line ); - el2.setAttribute( "att2", "attribute2\nnextline" ); - expectedDom.addChild( el2 ); - Xpp3Dom el3 = new Xpp3Dom( "el3" ); - el3.setInputLocation( ++line ); - el3.setAttribute( "att3", "attribute3" ); - el3.setValue( "element3" ); - el2.addChild( el3 ); + Xpp3Dom el2 = new Xpp3Dom("el2"); + el2.setInputLocation(++line); + el2.setAttribute("att2", "attribute2\nnextline"); + expectedDom.addChild(el2); + Xpp3Dom el3 = new Xpp3Dom("el3"); + el3.setInputLocation(++line); + el3.setAttribute("att3", "attribute3"); + el3.setValue("element3"); + el2.addChild(el3); ++line; - Xpp3Dom el4 = new Xpp3Dom( "el4" ); - el4.setInputLocation( ++line ); - el4.setValue( "" ); - expectedDom.addChild( el4 ); - Xpp3Dom el5 = new Xpp3Dom( "el5" ); - el5.setInputLocation( ++line ); - expectedDom.addChild( el5 ); - Xpp3Dom el6 = new Xpp3Dom( "el6" ); - el6.setInputLocation( ++line ); - el6.setAttribute( "xml:space", "preserve" ); - el6.setValue( " do not trim " ); - expectedDom.addChild( el6 ); + Xpp3Dom el4 = new Xpp3Dom("el4"); + el4.setInputLocation(++line); + el4.setValue(""); + expectedDom.addChild(el4); + Xpp3Dom el5 = new Xpp3Dom("el5"); + el5.setInputLocation(++line); + expectedDom.addChild(el5); + Xpp3Dom el6 = new Xpp3Dom("el6"); + el6.setInputLocation(++line); + el6.setAttribute("xml:space", "preserve"); + el6.setValue(" do not trim "); + expectedDom.addChild(el6); return expectedDom; } } diff --git a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomPerfTest.java b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomPerfTest.java index 22bba428..31636955 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomPerfTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomPerfTest.java @@ -46,22 +46,21 @@ @BenchmarkMode(Mode.Throughput) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Warmup(iterations = 3, time = 3, timeUnit = TimeUnit.SECONDS) -public class Xpp3DomPerfTest -{ +public class Xpp3DomPerfTest { @State(Scope.Benchmark) - static public class AdditionState { + public static class AdditionState { Xpp3Dom dom1; Xpp3Dom dom2; @Setup(Level.Iteration) public void setUp() throws IOException, XmlPullParserException { - String testDom = "onetwo"; - dom1 = Xpp3DomBuilder.build( new StringReader( testDom ) ); - dom2 = new Xpp3Dom( dom1 ); + String testDom = + "onetwo"; + dom1 = Xpp3DomBuilder.build(new StringReader(testDom)); + dom2 = new Xpp3Dom(dom1); } } - /** *

    benchmarkClone.

    * @@ -69,9 +68,8 @@ public void setUp() throws IOException, XmlPullParserException { * @return a {@link org.codehaus.plexus.util.xml.Xpp3Dom} object. */ @Benchmark - public Xpp3Dom benchmarkClone(AdditionState state) - { - return new Xpp3Dom( state.dom1 ); + public Xpp3Dom benchmarkClone(AdditionState state) { + return new Xpp3Dom(state.dom1); } /** @@ -80,9 +78,8 @@ public Xpp3Dom benchmarkClone(AdditionState state) * @param state a {@link org.codehaus.plexus.util.xml.Xpp3DomPerfTest.AdditionState} object. */ @Benchmark - public void benchmarkMerge(AdditionState state) - { - Xpp3Dom.mergeXpp3Dom( state.dom1, state.dom2 ); + public void benchmarkMerge(AdditionState state) { + Xpp3Dom.mergeXpp3Dom(state.dom1, state.dom2); } /** @@ -91,14 +88,12 @@ public void benchmarkMerge(AdditionState state) * @param args a {@link java.lang.String} object. * @throws org.openjdk.jmh.runner.RunnerException if any. */ - public static void main( String... args ) - throws RunnerException - { + public static void main(String... args) throws RunnerException { Options opts = new OptionsBuilder() - .measurementIterations( 3 ) - .measurementTime( TimeValue.milliseconds( 3000 ) ) - .forks( 1 ) + .measurementIterations(3) + .measurementTime(TimeValue.milliseconds(3000)) + .forks(1) .build(); - new Runner( opts ).run(); + new Runner(opts).run(); } } 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 6a1b7078..c4f21029 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomTest.java @@ -16,13 +16,6 @@ * limitations under the License. */ -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 java.io.IOException; import java.io.StringReader; import java.util.HashMap; @@ -31,6 +24,13 @@ 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; + /** *

    Xpp3DomTest class.

    * @@ -38,185 +38,172 @@ * @version $Id: $Id * @since 3.4.0 */ -public class Xpp3DomTest -{ +public class Xpp3DomTest { /** *

    testShouldPerformAppendAtFirstSubElementLevel.

    */ @Test - public void testShouldPerformAppendAtFirstSubElementLevel() - { + public void testShouldPerformAppendAtFirstSubElementLevel() { // create the dominant DOM - Xpp3Dom t1 = new Xpp3Dom( "top" ); - t1.setAttribute( Xpp3Dom.CHILDREN_COMBINATION_MODE_ATTRIBUTE, Xpp3Dom.CHILDREN_COMBINATION_APPEND ); - t1.setInputLocation( "t1top" ); + Xpp3Dom t1 = new Xpp3Dom("top"); + t1.setAttribute(Xpp3Dom.CHILDREN_COMBINATION_MODE_ATTRIBUTE, Xpp3Dom.CHILDREN_COMBINATION_APPEND); + t1.setInputLocation("t1top"); - Xpp3Dom t1s1 = new Xpp3Dom( "topsub1" ); - t1s1.setValue( "t1s1Value" ); - t1s1.setInputLocation( "t1s1" ); + Xpp3Dom t1s1 = new Xpp3Dom("topsub1"); + t1s1.setValue("t1s1Value"); + t1s1.setInputLocation("t1s1"); - t1.addChild( t1s1 ); + t1.addChild(t1s1); // create the recessive DOM - Xpp3Dom t2 = new Xpp3Dom( "top" ); - t2.setInputLocation( "t2top" ); + Xpp3Dom t2 = new Xpp3Dom("top"); + t2.setInputLocation("t2top"); - Xpp3Dom t2s1 = new Xpp3Dom( "topsub1" ); - t2s1.setValue( "t2s1Value" ); - t2s1.setInputLocation( "t2s1" ); + Xpp3Dom t2s1 = new Xpp3Dom("topsub1"); + t2s1.setValue("t2s1Value"); + t2s1.setInputLocation("t2s1"); - t2.addChild( t2s1 ); + t2.addChild(t2s1); // merge and check results. - Xpp3Dom result = Xpp3Dom.mergeXpp3Dom( t1, t2 ); + Xpp3Dom result = Xpp3Dom.mergeXpp3Dom(t1, t2); - assertEquals( 2, result.getChildren( "topsub1" ).length ); - assertEquals( "t2s1Value", result.getChildren( "topsub1" )[0].getValue() ); - assertEquals( "t1s1Value", result.getChildren( "topsub1" )[1].getValue() ); + assertEquals(2, result.getChildren("topsub1").length); + assertEquals("t2s1Value", result.getChildren("topsub1")[0].getValue()); + assertEquals("t1s1Value", result.getChildren("topsub1")[1].getValue()); - assertEquals( "t1top", result.getInputLocation() ); - assertEquals( "t2s1", result.getChildren( "topsub1" )[0].getInputLocation() ); - assertEquals( "t1s1", result.getChildren( "topsub1" )[1].getInputLocation() ); + assertEquals("t1top", result.getInputLocation()); + assertEquals("t2s1", result.getChildren("topsub1")[0].getInputLocation()); + assertEquals("t1s1", result.getChildren("topsub1")[1].getInputLocation()); } /** *

    testShouldOverrideAppendAndDeepMerge.

    */ @Test - public void testShouldOverrideAppendAndDeepMerge() - { + public void testShouldOverrideAppendAndDeepMerge() { // create the dominant DOM - Xpp3Dom t1 = new Xpp3Dom( "top" ); - t1.setAttribute( Xpp3Dom.CHILDREN_COMBINATION_MODE_ATTRIBUTE, Xpp3Dom.CHILDREN_COMBINATION_APPEND ); - t1.setInputLocation( "t1top" ); + Xpp3Dom t1 = new Xpp3Dom("top"); + t1.setAttribute(Xpp3Dom.CHILDREN_COMBINATION_MODE_ATTRIBUTE, Xpp3Dom.CHILDREN_COMBINATION_APPEND); + t1.setInputLocation("t1top"); - Xpp3Dom t1s1 = new Xpp3Dom( "topsub1" ); - t1s1.setValue( "t1s1Value" ); - t1s1.setInputLocation( "t1s1" ); + Xpp3Dom t1s1 = new Xpp3Dom("topsub1"); + t1s1.setValue("t1s1Value"); + t1s1.setInputLocation("t1s1"); - t1.addChild( t1s1 ); + t1.addChild(t1s1); // create the recessive DOM - Xpp3Dom t2 = new Xpp3Dom( "top" ); - t2.setInputLocation( "t2top" ); + Xpp3Dom t2 = new Xpp3Dom("top"); + t2.setInputLocation("t2top"); - Xpp3Dom t2s1 = new Xpp3Dom( "topsub1" ); - t2s1.setValue( "t2s1Value" ); - t2s1.setInputLocation( "t2s1" ); + Xpp3Dom t2s1 = new Xpp3Dom("topsub1"); + t2s1.setValue("t2s1Value"); + t2s1.setInputLocation("t2s1"); - t2.addChild( t2s1 ); + t2.addChild(t2s1); // merge and check results. - Xpp3Dom result = Xpp3Dom.mergeXpp3Dom( t1, t2, Boolean.TRUE ); + Xpp3Dom result = Xpp3Dom.mergeXpp3Dom(t1, t2, Boolean.TRUE); - assertEquals( 1, result.getChildren( "topsub1" ).length ); - assertEquals( "t1s1Value", result.getChildren( "topsub1" )[0].getValue() ); + assertEquals(1, result.getChildren("topsub1").length); + assertEquals("t1s1Value", result.getChildren("topsub1")[0].getValue()); - assertEquals( "t1top", result.getInputLocation() ); - assertEquals( "t1s1", result.getChildren( "topsub1" )[0].getInputLocation() ); + assertEquals("t1top", result.getInputLocation()); + assertEquals("t1s1", result.getChildren("topsub1")[0].getInputLocation()); } /** *

    testShouldPerformSelfOverrideAtTopLevel.

    */ @Test - public void testShouldPerformSelfOverrideAtTopLevel() - { + public void testShouldPerformSelfOverrideAtTopLevel() { // create the dominant DOM - Xpp3Dom t1 = new Xpp3Dom( "top" ); - t1.setAttribute( "attr", "value" ); - t1.setInputLocation( "t1top" ); + Xpp3Dom t1 = new Xpp3Dom("top"); + t1.setAttribute("attr", "value"); + t1.setInputLocation("t1top"); - t1.setAttribute( Xpp3Dom.SELF_COMBINATION_MODE_ATTRIBUTE, Xpp3Dom.SELF_COMBINATION_OVERRIDE ); + t1.setAttribute(Xpp3Dom.SELF_COMBINATION_MODE_ATTRIBUTE, Xpp3Dom.SELF_COMBINATION_OVERRIDE); // create the recessive DOM - Xpp3Dom t2 = new Xpp3Dom( "top" ); - t2.setAttribute( "attr2", "value2" ); - t2.setValue( "t2Value" ); - t2.setInputLocation( "t2top" ); + Xpp3Dom t2 = new Xpp3Dom("top"); + t2.setAttribute("attr2", "value2"); + t2.setValue("t2Value"); + t2.setInputLocation("t2top"); // merge and check results. - Xpp3Dom result = Xpp3Dom.mergeXpp3Dom( t1, t2 ); + Xpp3Dom result = Xpp3Dom.mergeXpp3Dom(t1, t2); - assertEquals( 2, result.getAttributeNames().length ); - assertNull( result.getValue() ); - assertEquals( "t1top", result.getInputLocation() ); + assertEquals(2, result.getAttributeNames().length); + assertNull(result.getValue()); + assertEquals("t1top", result.getInputLocation()); } /** *

    testShouldMergeValuesAtTopLevelByDefault.

    */ @Test - public void testShouldMergeValuesAtTopLevelByDefault() - { + public void testShouldMergeValuesAtTopLevelByDefault() { // create the dominant DOM - Xpp3Dom t1 = new Xpp3Dom( "top" ); - t1.setAttribute( "attr", "value" ); - t1.setInputLocation( "t1top" ); + Xpp3Dom t1 = new Xpp3Dom("top"); + t1.setAttribute("attr", "value"); + t1.setInputLocation("t1top"); // create the recessive DOM - Xpp3Dom t2 = new Xpp3Dom( "top" ); - t2.setAttribute( "attr2", "value2" ); - t2.setValue( "t2Value" ); - t2.setInputLocation( "t2top" ); + Xpp3Dom t2 = new Xpp3Dom("top"); + t2.setAttribute("attr2", "value2"); + t2.setValue("t2Value"); + t2.setInputLocation("t2top"); // merge and check results. - Xpp3Dom result = Xpp3Dom.mergeXpp3Dom( t1, t2 ); + Xpp3Dom result = Xpp3Dom.mergeXpp3Dom(t1, t2); // this is still 2, since we're not using the merge-control attribute. - assertEquals( 2, result.getAttributeNames().length ); + assertEquals(2, result.getAttributeNames().length); - assertEquals( result.getValue(), t2.getValue() ); - assertEquals( "t2top", result.getInputLocation() ); + assertEquals(result.getValue(), t2.getValue()); + assertEquals("t2top", result.getInputLocation()); } /** *

    testShouldMergeValuesAtTopLevel.

    */ @Test - public void testShouldMergeValuesAtTopLevel() - { + public void testShouldMergeValuesAtTopLevel() { // create the dominant DOM - Xpp3Dom t1 = new Xpp3Dom( "top" ); - t1.setAttribute( "attr", "value" ); + Xpp3Dom t1 = new Xpp3Dom("top"); + t1.setAttribute("attr", "value"); - t1.setAttribute( Xpp3Dom.SELF_COMBINATION_MODE_ATTRIBUTE, Xpp3Dom.SELF_COMBINATION_MERGE ); + t1.setAttribute(Xpp3Dom.SELF_COMBINATION_MODE_ATTRIBUTE, Xpp3Dom.SELF_COMBINATION_MERGE); // create the recessive DOM - Xpp3Dom t2 = new Xpp3Dom( "top" ); - t2.setAttribute( "attr2", "value2" ); - t2.setValue( "t2Value" ); + Xpp3Dom t2 = new Xpp3Dom("top"); + t2.setAttribute("attr2", "value2"); + t2.setValue("t2Value"); // merge and check results. - Xpp3Dom result = Xpp3Dom.mergeXpp3Dom( t1, t2 ); + Xpp3Dom result = Xpp3Dom.mergeXpp3Dom(t1, t2); - assertEquals( 3, result.getAttributeNames().length ); - assertEquals( result.getValue(), t2.getValue() ); + assertEquals(3, result.getAttributeNames().length); + assertEquals(result.getValue(), t2.getValue()); } /** *

    testNullAttributeNameOrValue.

    */ @Test - public void testNullAttributeNameOrValue() - { - Xpp3Dom t1 = new Xpp3Dom( "top" ); - try - { - t1.setAttribute( "attr", null ); - fail( "null attribute values shouldn't be allowed" ); - } - catch ( NullPointerException e ) - { + public void testNullAttributeNameOrValue() { + 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 ) - { + try { + t1.setAttribute(null, "value"); + fail("null attribute names shouldn't be allowed"); + } catch (NullPointerException e) { } t1.toString(); } @@ -225,13 +212,12 @@ public void testNullAttributeNameOrValue() *

    testEquals.

    */ @Test - public void testEquals() - { - Xpp3Dom dom = new Xpp3Dom( "top" ); + public void testEquals() { + Xpp3Dom dom = new Xpp3Dom("top"); - assertEquals( dom, dom ); - assertFalse( dom.equals( null ) ); - assertFalse( dom.equals( new Xpp3Dom( (String) null ) ) ); + assertEquals(dom, dom); + assertFalse(dom.equals(null)); + assertFalse(dom.equals(new Xpp3Dom((String) null))); } /** @@ -241,29 +227,24 @@ public void testEquals() * @throws java.io.IOException if any. */ @Test - public void testEqualsIsNullSafe() - throws XmlPullParserException, IOException - { + public void testEqualsIsNullSafe() throws XmlPullParserException, IOException { String testDom = "onetwo"; - Xpp3Dom dom = Xpp3DomBuilder.build( new StringReader( testDom ) ); - Xpp3Dom dom2 = Xpp3DomBuilder.build( new StringReader( testDom ) ); + Xpp3Dom dom = Xpp3DomBuilder.build(new StringReader(testDom)); + Xpp3Dom dom2 = Xpp3DomBuilder.build(new StringReader(testDom)); - try - { + try { dom2.attributes = new HashMap(); - dom2.attributes.put( "nullValue", null ); - dom2.attributes.put( null, "nullKey" ); + dom2.attributes.put("nullValue", null); + dom2.attributes.put(null, "nullKey"); dom2.childList.clear(); - dom2.childList.add( null ); + dom2.childList.add(null); - assertFalse( dom.equals( dom2 ) ); - assertFalse( dom2.equals( dom ) ); + assertFalse(dom.equals(dom2)); + assertFalse(dom2.equals(dom)); - } - catch ( NullPointerException ex ) - { + } catch (NullPointerException ex) { ex.printStackTrace(); - fail( "\nNullPointerExceptions should not be thrown." ); + fail("\nNullPointerExceptions should not be thrown."); } } @@ -274,25 +255,23 @@ public void testEqualsIsNullSafe() * @throws java.io.IOException if any. */ @Test - public void testShouldOverwritePluginConfigurationSubItemsByDefault() - throws XmlPullParserException, IOException - { + public void testShouldOverwritePluginConfigurationSubItemsByDefault() throws XmlPullParserException, IOException { String parentConfigStr = "onetwo"; Xpp3Dom parentConfig = - Xpp3DomBuilder.build( new StringReader( parentConfigStr ), new FixedInputLocationBuilder( "parent" ) ); + Xpp3DomBuilder.build(new StringReader(parentConfigStr), new FixedInputLocationBuilder("parent")); String childConfigStr = "three"; Xpp3Dom childConfig = - Xpp3DomBuilder.build( new StringReader( childConfigStr ), new FixedInputLocationBuilder( "child" ) ); + Xpp3DomBuilder.build(new StringReader(childConfigStr), new FixedInputLocationBuilder("child")); - Xpp3Dom result = Xpp3Dom.mergeXpp3Dom( childConfig, parentConfig ); - Xpp3Dom items = result.getChild( "items" ); + Xpp3Dom result = Xpp3Dom.mergeXpp3Dom(childConfig, parentConfig); + Xpp3Dom items = result.getChild("items"); - assertEquals( 1, items.getChildCount() ); + assertEquals(1, items.getChildCount()); - Xpp3Dom item = items.getChild( 0 ); - assertEquals( "three", item.getValue() ); - assertEquals( "child", item.getInputLocation() ); + Xpp3Dom item = items.getChild(0); + assertEquals("three", item.getValue()); + assertEquals("child", item.getInputLocation()); } /** @@ -303,30 +282,29 @@ public void testShouldOverwritePluginConfigurationSubItemsByDefault() */ @Test public void testShouldMergePluginConfigurationSubItemsWithMergeAttributeSet() - throws XmlPullParserException, IOException - { + throws XmlPullParserException, IOException { String parentConfigStr = "onetwo"; Xpp3Dom parentConfig = - Xpp3DomBuilder.build( new StringReader( parentConfigStr ), new FixedInputLocationBuilder( "parent" ) ); + Xpp3DomBuilder.build(new StringReader(parentConfigStr), new FixedInputLocationBuilder("parent")); String childConfigStr = - "three"; + "three"; Xpp3Dom childConfig = - Xpp3DomBuilder.build( new StringReader( childConfigStr ), new FixedInputLocationBuilder( "child" ) ); + Xpp3DomBuilder.build(new StringReader(childConfigStr), new FixedInputLocationBuilder("child")); - Xpp3Dom result = Xpp3Dom.mergeXpp3Dom( childConfig, parentConfig ); - Xpp3Dom items = result.getChild( "items" ); + Xpp3Dom result = Xpp3Dom.mergeXpp3Dom(childConfig, parentConfig); + Xpp3Dom items = result.getChild("items"); - assertEquals( 3, items.getChildCount() ); + assertEquals(3, items.getChildCount()); Xpp3Dom[] item = items.getChildren(); - assertEquals( "one", item[0].getValue() ); - assertEquals( "parent", item[0].getInputLocation() ); - assertEquals( "two", item[1].getValue() ); - assertEquals( "parent", item[1].getInputLocation() ); - assertEquals( "three", item[2].getValue() ); - assertEquals( "child", item[2].getInputLocation() ); + assertEquals("one", item[0].getValue()); + assertEquals("parent", item[0].getInputLocation()); + assertEquals("two", item[1].getValue()); + assertEquals("parent", item[1].getInputLocation()); + assertEquals("three", item[2].getValue()); + assertEquals("child", item[2].getInputLocation()); } /** @@ -335,21 +313,19 @@ public void testShouldMergePluginConfigurationSubItemsWithMergeAttributeSet() * @throws java.lang.Exception if any. */ @Test - public void testShouldNotChangeUponMergeWithItselfWhenFirstOrLastSubItemIsEmpty() - throws Exception - { + public void testShouldNotChangeUponMergeWithItselfWhenFirstOrLastSubItemIsEmpty() throws Exception { String configStr = "test"; - Xpp3Dom dominantConfig = Xpp3DomBuilder.build( new StringReader( configStr ) ); - Xpp3Dom recessiveConfig = Xpp3DomBuilder.build( new StringReader( configStr ) ); + Xpp3Dom dominantConfig = Xpp3DomBuilder.build(new StringReader(configStr)); + Xpp3Dom recessiveConfig = Xpp3DomBuilder.build(new StringReader(configStr)); - Xpp3Dom result = Xpp3Dom.mergeXpp3Dom( dominantConfig, recessiveConfig ); - Xpp3Dom items = result.getChild( "items" ); + Xpp3Dom result = Xpp3Dom.mergeXpp3Dom(dominantConfig, recessiveConfig); + Xpp3Dom items = result.getChild("items"); - assertEquals( 3, items.getChildCount() ); + assertEquals(3, items.getChildCount()); - assertEquals( null, items.getChild( 0 ).getValue() ); - assertEquals( "test", items.getChild( 1 ).getValue() ); - assertEquals( null, items.getChild( 2 ).getValue() ); + assertEquals(null, items.getChild(0).getValue()); + assertEquals("test", items.getChild(1).getValue()); + assertEquals(null, items.getChild(2).getValue()); } /** @@ -358,21 +334,19 @@ public void testShouldNotChangeUponMergeWithItselfWhenFirstOrLastSubItemIsEmpty( * @throws java.lang.Exception if any. */ @Test - public void testShouldCopyRecessiveChildrenNotPresentInTarget() - throws Exception - { + public void testShouldCopyRecessiveChildrenNotPresentInTarget() throws Exception { String dominantStr = "x"; String recessiveStr = "y"; - Xpp3Dom dominantConfig = Xpp3DomBuilder.build( new StringReader( dominantStr ) ); - Xpp3Dom recessiveConfig = Xpp3DomBuilder.build( new StringReader( recessiveStr ) ); + Xpp3Dom dominantConfig = Xpp3DomBuilder.build(new StringReader(dominantStr)); + Xpp3Dom recessiveConfig = Xpp3DomBuilder.build(new StringReader(recessiveStr)); - Xpp3Dom result = Xpp3Dom.mergeXpp3Dom( dominantConfig, recessiveConfig ); + Xpp3Dom result = Xpp3Dom.mergeXpp3Dom(dominantConfig, recessiveConfig); - assertEquals( 2, result.getChildCount() ); + assertEquals(2, result.getChildCount()); - assertEquals( "x", result.getChild( "foo" ).getValue() ); - assertEquals( "y", result.getChild( "bar" ).getValue() ); - assertNotSame( result.getChild( "bar" ), recessiveConfig.getChild( "bar" ) ); + assertEquals("x", result.getChild("foo").getValue()); + assertEquals("y", result.getChild("bar").getValue()); + assertNotSame(result.getChild("bar"), recessiveConfig.getChild("bar")); } /** @@ -382,13 +356,11 @@ public void testShouldCopyRecessiveChildrenNotPresentInTarget() * @throws org.codehaus.plexus.util.xml.pull.XmlPullParserException if any. */ @Test - public void testDupeChildren() - throws IOException, XmlPullParserException - { + public void testDupeChildren() throws IOException, XmlPullParserException { String dupes = "xy"; - Xpp3Dom dom = Xpp3DomBuilder.build( new StringReader( dupes ) ); - assertNotNull( dom ); - assertEquals( "y", dom.getChild( "foo" ).getValue() ); + Xpp3Dom dom = Xpp3DomBuilder.build(new StringReader(dupes)); + assertNotNull(dom); + assertEquals("y", dom.getChild("foo").getValue()); } /** @@ -397,18 +369,16 @@ public void testDupeChildren() * @throws java.lang.Exception if any. */ @Test - public void testShouldRemoveEntireElementWithAttributesAndChildren() - throws Exception - { + public void testShouldRemoveEntireElementWithAttributesAndChildren() throws Exception { String dominantStr = ""; String recessiveStr = "parameter"; - Xpp3Dom dominantConfig = Xpp3DomBuilder.build( new StringReader( dominantStr ) ); - Xpp3Dom recessiveConfig = Xpp3DomBuilder.build( new StringReader( recessiveStr ) ); + Xpp3Dom dominantConfig = Xpp3DomBuilder.build(new StringReader(dominantStr)); + Xpp3Dom recessiveConfig = Xpp3DomBuilder.build(new StringReader(recessiveStr)); - Xpp3Dom result = Xpp3Dom.mergeXpp3Dom( dominantConfig, recessiveConfig ); + Xpp3Dom result = Xpp3Dom.mergeXpp3Dom(dominantConfig, recessiveConfig); - assertEquals( 0, result.getChildCount() ); - assertEquals( "config", result.getName() ); + assertEquals(0, result.getChildCount()); + assertEquals("config", result.getName()); } /** @@ -417,32 +387,26 @@ public void testShouldRemoveEntireElementWithAttributesAndChildren() * @throws java.lang.Exception if any. */ @Test - public void testShouldRemoveDoNotRemoveTagWhenSwappedInputDOMs() - throws Exception - { + public void testShouldRemoveDoNotRemoveTagWhenSwappedInputDOMs() throws Exception { String dominantStr = ""; String recessiveStr = "parameter"; - Xpp3Dom dominantConfig = Xpp3DomBuilder.build( new StringReader( dominantStr ) ); - Xpp3Dom recessiveConfig = Xpp3DomBuilder.build( new StringReader( recessiveStr ) ); + Xpp3Dom dominantConfig = Xpp3DomBuilder.build(new StringReader(dominantStr)); + Xpp3Dom recessiveConfig = Xpp3DomBuilder.build(new StringReader(recessiveStr)); // same DOMs as testShouldRemoveEntireElementWithAttributesAndChildren(), swapping dominant <--> recessive - Xpp3Dom result = Xpp3Dom.mergeXpp3Dom( recessiveConfig, dominantConfig ); + Xpp3Dom result = Xpp3Dom.mergeXpp3Dom(recessiveConfig, dominantConfig); - assertEquals( recessiveConfig.toString(), result.toString() ); + assertEquals(recessiveConfig.toString(), result.toString()); } - private static class FixedInputLocationBuilder - implements Xpp3DomBuilder.InputLocationBuilder - { + private static class FixedInputLocationBuilder implements Xpp3DomBuilder.InputLocationBuilder { private final Object location; - public FixedInputLocationBuilder( Object location ) - { + public FixedInputLocationBuilder(Object location) { this.location = location; } - public Object toInputLocation( XmlPullParser parser ) - { + public Object toInputLocation(XmlPullParser parser) { return location; } } 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 9e244f19..ea21509a 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomUtilsTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomUtilsTest.java @@ -16,8 +16,6 @@ * limitations under the License. */ -import static org.junit.Assert.assertEquals; - import java.io.IOException; import java.io.StringReader; @@ -25,6 +23,8 @@ import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import org.junit.Test; +import static org.junit.Assert.assertEquals; + /** *

    Xpp3DomUtilsTest class.

    * @@ -32,46 +32,51 @@ * @version $Id: $Id * @since 3.4.0 */ -public class Xpp3DomUtilsTest -{ +public class Xpp3DomUtilsTest { /** *

    testCombineId.

    * * @throws java.lang.Exception if any. */ @Test - public void testCombineId() - throws Exception - { + public void testCombineId() throws Exception { String lhs = "" + "LHS-ONLYLHS" - + "TOOVERWRITELHS" + ""; + + "TOOVERWRITELHS" + + ""; String rhs = "" + "RHS-ONLYRHS" - + "TOOVERWRITERHS" + ""; - - Xpp3Dom leftDom = Xpp3DomBuilder.build( new StringReader( lhs ), new FixedInputLocationBuilder( "left" ) ); - Xpp3Dom rightDom = Xpp3DomBuilder.build( new StringReader( rhs ), new FixedInputLocationBuilder( "right" ) ); - - Xpp3Dom mergeResult = Xpp3DomUtils.mergeXpp3Dom( leftDom, rightDom, true ); - assertEquals( 3, mergeResult.getChildren( "property" ).length ); - - Xpp3Dom p0 = mergeResult.getChildren( "property" )[0]; - assertEquals( "LHS-ONLY", p0.getChild( "name" ).getValue() ); - assertEquals( "left", p0.getChild( "name" ).getInputLocation() ); - assertEquals( "LHS", p0.getChild( "value" ).getValue() ); - assertEquals( "left", p0.getChild( "value" ).getInputLocation() ); - - Xpp3Dom p1 = mergeResult.getChildren( "property" )[1]; - assertEquals( "TOOVERWRITE", mergeResult.getChildren( "property" )[1].getChild( "name" ).getValue() ); - assertEquals( "left", p1.getChild( "name" ).getInputLocation() ); - assertEquals( "LHS", mergeResult.getChildren( "property" )[1].getChild( "value" ).getValue() ); - assertEquals( "left", p1.getChild( "value" ).getInputLocation() ); - - Xpp3Dom p2 = mergeResult.getChildren( "property" )[2]; - assertEquals( "RHS-ONLY", mergeResult.getChildren( "property" )[2].getChild( "name" ).getValue() ); - assertEquals( "right", p2.getChild( "name" ).getInputLocation() ); - assertEquals( "RHS", mergeResult.getChildren( "property" )[2].getChild( "value" ).getValue() ); - assertEquals( "right", p2.getChild( "value" ).getInputLocation() ); + + "TOOVERWRITERHS" + + ""; + + Xpp3Dom leftDom = Xpp3DomBuilder.build(new StringReader(lhs), new FixedInputLocationBuilder("left")); + Xpp3Dom rightDom = Xpp3DomBuilder.build(new StringReader(rhs), new FixedInputLocationBuilder("right")); + + Xpp3Dom mergeResult = Xpp3DomUtils.mergeXpp3Dom(leftDom, rightDom, true); + assertEquals(3, mergeResult.getChildren("property").length); + + Xpp3Dom p0 = mergeResult.getChildren("property")[0]; + assertEquals("LHS-ONLY", p0.getChild("name").getValue()); + assertEquals("left", p0.getChild("name").getInputLocation()); + assertEquals("LHS", p0.getChild("value").getValue()); + assertEquals("left", p0.getChild("value").getInputLocation()); + + Xpp3Dom p1 = mergeResult.getChildren("property")[1]; + assertEquals( + "TOOVERWRITE", + mergeResult.getChildren("property")[1].getChild("name").getValue()); + assertEquals("left", p1.getChild("name").getInputLocation()); + assertEquals( + "LHS", mergeResult.getChildren("property")[1].getChild("value").getValue()); + assertEquals("left", p1.getChild("value").getInputLocation()); + + Xpp3Dom p2 = mergeResult.getChildren("property")[2]; + assertEquals( + "RHS-ONLY", + mergeResult.getChildren("property")[2].getChild("name").getValue()); + assertEquals("right", p2.getChild("name").getInputLocation()); + assertEquals( + "RHS", mergeResult.getChildren("property")[2].getChild("value").getValue()); + assertEquals("right", p2.getChild("value").getInputLocation()); } /** @@ -80,38 +85,44 @@ public void testCombineId() * @throws java.lang.Exception if any. */ @Test - public void testCombineKeys() - throws Exception - { - String lhs = "" + "LHS-ONLYLHS" - + "TOOVERWRITELHS" + ""; - - String rhs = "" + "RHS-ONLYRHS" - + "TOOVERWRITERHS" + ""; - - Xpp3Dom leftDom = Xpp3DomBuilder.build( new StringReader( lhs ), new FixedInputLocationBuilder( "left" ) ); - Xpp3Dom rightDom = Xpp3DomBuilder.build( new StringReader( rhs ), new FixedInputLocationBuilder( "right" ) ); - - Xpp3Dom mergeResult = Xpp3DomUtils.mergeXpp3Dom( leftDom, rightDom, true ); - assertEquals( 3, mergeResult.getChildren( "property" ).length ); - - Xpp3Dom p0 = mergeResult.getChildren( "property" )[0]; - assertEquals( "LHS-ONLY", p0.getChild( "name" ).getValue() ); - assertEquals( "left", p0.getChild( "name" ).getInputLocation() ); - assertEquals( "LHS", p0.getChild( "value" ).getValue() ); - assertEquals( "left", p0.getChild( "value" ).getInputLocation() ); - - Xpp3Dom p1 = mergeResult.getChildren( "property" )[1]; - assertEquals( "TOOVERWRITE", mergeResult.getChildren( "property" )[1].getChild( "name" ).getValue() ); - assertEquals( "left", p1.getChild( "name" ).getInputLocation() ); - assertEquals( "LHS", mergeResult.getChildren( "property" )[1].getChild( "value" ).getValue() ); - assertEquals( "left", p1.getChild( "value" ).getInputLocation() ); - - Xpp3Dom p2 = mergeResult.getChildren( "property" )[2]; - assertEquals( "RHS-ONLY", mergeResult.getChildren( "property" )[2].getChild( "name" ).getValue() ); - assertEquals( "right", p2.getChild( "name" ).getInputLocation() ); - assertEquals( "RHS", mergeResult.getChildren( "property" )[2].getChild( "value" ).getValue() ); - assertEquals( "right", p2.getChild( "value" ).getInputLocation() ); + public void testCombineKeys() throws Exception { + String lhs = "" + + "LHS-ONLYLHS" + + "TOOVERWRITELHS" + ""; + + String rhs = "" + + "RHS-ONLYRHS" + + "TOOVERWRITERHS" + ""; + + Xpp3Dom leftDom = Xpp3DomBuilder.build(new StringReader(lhs), new FixedInputLocationBuilder("left")); + Xpp3Dom rightDom = Xpp3DomBuilder.build(new StringReader(rhs), new FixedInputLocationBuilder("right")); + + Xpp3Dom mergeResult = Xpp3DomUtils.mergeXpp3Dom(leftDom, rightDom, true); + assertEquals(3, mergeResult.getChildren("property").length); + + Xpp3Dom p0 = mergeResult.getChildren("property")[0]; + assertEquals("LHS-ONLY", p0.getChild("name").getValue()); + assertEquals("left", p0.getChild("name").getInputLocation()); + assertEquals("LHS", p0.getChild("value").getValue()); + assertEquals("left", p0.getChild("value").getInputLocation()); + + Xpp3Dom p1 = mergeResult.getChildren("property")[1]; + assertEquals( + "TOOVERWRITE", + mergeResult.getChildren("property")[1].getChild("name").getValue()); + assertEquals("left", p1.getChild("name").getInputLocation()); + assertEquals( + "LHS", mergeResult.getChildren("property")[1].getChild("value").getValue()); + assertEquals("left", p1.getChild("value").getInputLocation()); + + Xpp3Dom p2 = mergeResult.getChildren("property")[2]; + assertEquals( + "RHS-ONLY", + mergeResult.getChildren("property")[2].getChild("name").getValue()); + assertEquals("right", p2.getChild("name").getInputLocation()); + assertEquals( + "RHS", mergeResult.getChildren("property")[2].getChild("value").getValue()); + assertEquals("right", p2.getChild("value").getInputLocation()); } @Test @@ -120,48 +131,42 @@ public void testPreserveDominantBlankValue() throws XmlPullParserException, IOEx String rhs = "recessive"; - Xpp3Dom leftDom = Xpp3DomBuilder.build( new StringReader( lhs ), new FixedInputLocationBuilder( "left" ) ); - Xpp3Dom rightDom = Xpp3DomBuilder.build( new StringReader( rhs ), new FixedInputLocationBuilder( "right" ) ); + Xpp3Dom leftDom = Xpp3DomBuilder.build(new StringReader(lhs), new FixedInputLocationBuilder("left")); + Xpp3Dom rightDom = Xpp3DomBuilder.build(new StringReader(rhs), new FixedInputLocationBuilder("right")); - Xpp3Dom mergeResult = Xpp3DomUtils.mergeXpp3Dom( leftDom, rightDom, true ); - assertEquals( " ", mergeResult.getValue() ); + Xpp3Dom mergeResult = Xpp3DomUtils.mergeXpp3Dom(leftDom, rightDom, true); + assertEquals(" ", mergeResult.getValue()); } @Test - public void testPreserveDominantEmptyNode() throws XmlPullParserException, IOException - { + public void testPreserveDominantEmptyNode() throws XmlPullParserException, IOException { String lhs = ""; String rhs = "recessive"; - Xpp3Dom leftDom = Xpp3DomBuilder.build( new StringReader( lhs ), new FixedInputLocationBuilder( "left" ) ); - Xpp3Dom rightDom = Xpp3DomBuilder.build( new StringReader( rhs ), new FixedInputLocationBuilder( "right" ) ); + Xpp3Dom leftDom = Xpp3DomBuilder.build(new StringReader(lhs), new FixedInputLocationBuilder("left")); + Xpp3Dom rightDom = Xpp3DomBuilder.build(new StringReader(rhs), new FixedInputLocationBuilder("right")); - Xpp3Dom mergeResult = Xpp3DomUtils.mergeXpp3Dom( leftDom, rightDom, true ); - assertEquals( "", mergeResult.getValue() ); + Xpp3Dom mergeResult = Xpp3DomUtils.mergeXpp3Dom(leftDom, rightDom, true); + assertEquals("", mergeResult.getValue()); } @Test - public void testIsNotEmptyNegatesIsEmpty() - { - assertEquals( !Xpp3DomUtils.isEmpty( null ), Xpp3DomUtils.isNotEmpty( null ) ); - assertEquals( !Xpp3DomUtils.isEmpty( "" ), Xpp3DomUtils.isNotEmpty( "" ) ); - assertEquals( !Xpp3DomUtils.isEmpty( " " ), Xpp3DomUtils.isNotEmpty( " " ) ); - assertEquals( !Xpp3DomUtils.isEmpty( "someValue" ), Xpp3DomUtils.isNotEmpty( "someValue" ) ); + public void testIsNotEmptyNegatesIsEmpty() { + assertEquals(!Xpp3DomUtils.isEmpty(null), Xpp3DomUtils.isNotEmpty(null)); + assertEquals(!Xpp3DomUtils.isEmpty(""), Xpp3DomUtils.isNotEmpty("")); + assertEquals(!Xpp3DomUtils.isEmpty(" "), Xpp3DomUtils.isNotEmpty(" ")); + assertEquals(!Xpp3DomUtils.isEmpty("someValue"), Xpp3DomUtils.isNotEmpty("someValue")); } - private static class FixedInputLocationBuilder - implements Xpp3DomBuilder.InputLocationBuilder - { + private static class FixedInputLocationBuilder implements Xpp3DomBuilder.InputLocationBuilder { private final Object location; - public FixedInputLocationBuilder( Object location ) - { + public FixedInputLocationBuilder(Object location) { this.location = location; } - public Object toInputLocation( XmlPullParser parser ) - { + public Object toInputLocation(XmlPullParser parser) { return location; } } 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 93c00a7d..55853d0b 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomWriterTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomWriterTest.java @@ -16,12 +16,12 @@ * limitations under the License. */ -import static org.junit.Assert.assertEquals; - import java.io.StringWriter; import org.junit.Test; +import static org.junit.Assert.assertEquals; + /** *

    Xpp3DomWriterTest class.

    * @@ -29,103 +29,95 @@ * @version $Id: $Id * @since 3.4.0 */ -public class Xpp3DomWriterTest -{ - private static final String LS = System.getProperty( "line.separator" ); +public class Xpp3DomWriterTest { + private static final String LS = System.getProperty("line.separator"); /** *

    testWriter.

    */ @Test - public void testWriter() - { + public void testWriter() { StringWriter writer = new StringWriter(); - Xpp3DomWriter.write( writer, createXpp3Dom() ); + Xpp3DomWriter.write(writer, createXpp3Dom()); - assertEquals( "Check if output matches", createExpectedXML( true ), writer.toString() ); + assertEquals("Check if output matches", createExpectedXML(true), writer.toString()); } /** *

    testWriterNoEscape.

    */ @Test - public void testWriterNoEscape() - { + public void testWriterNoEscape() { StringWriter writer = new StringWriter(); - Xpp3DomWriter.write( new PrettyPrintXMLWriter( writer ), createXpp3Dom(), false ); + Xpp3DomWriter.write(new PrettyPrintXMLWriter(writer), createXpp3Dom(), false); - assertEquals( "Check if output matches", createExpectedXML( false ), writer.toString() ); + assertEquals("Check if output matches", createExpectedXML(false), writer.toString()); } - private String createExpectedXML( boolean escape ) - { + private String createExpectedXML(boolean escape) { StringBuilder buf = new StringBuilder(); - buf.append( "" ); - buf.append( LS ); - buf.append( " element1" ); - buf.append( LS ); - buf.append( " " ); - buf.append( LS ); - buf.append( " element3" ); - buf.append( LS ); - buf.append( " " ); - buf.append( LS ); - buf.append( " " ); - buf.append( LS ); - buf.append( " " ); - buf.append( LS ); - buf.append( " " ); - buf.append( LS ); - if ( escape ) - { - buf.append( " element7" ).append( LS ).append( "&"'<>" ); - } - else - { - buf.append( " element7" ).append( LS ).append( "&\"\'<>" ); + buf.append(""); + buf.append(LS); + buf.append(" element1"); + buf.append(LS); + buf.append(" "); + buf.append(LS); + buf.append(" element3"); + buf.append(LS); + buf.append(" "); + buf.append(LS); + buf.append(" "); + buf.append(LS); + buf.append(" "); + buf.append(LS); + buf.append(" "); + buf.append(LS); + if (escape) { + buf.append(" element7").append(LS).append("&"'<>"); + } else { + buf.append(" element7").append(LS).append("&\"\'<>"); } - buf.append( LS ); - buf.append( " " ); - buf.append( LS ); - buf.append( "" ); + buf.append(LS); + buf.append(" "); + buf.append(LS); + buf.append(""); return buf.toString(); } - private Xpp3Dom createXpp3Dom() - { - Xpp3Dom dom = new Xpp3Dom( "root" ); + private Xpp3Dom createXpp3Dom() { + Xpp3Dom dom = new Xpp3Dom("root"); - Xpp3Dom el1 = new Xpp3Dom( "el1" ); - el1.setValue( "element1" ); - dom.addChild( el1 ); + Xpp3Dom el1 = new Xpp3Dom("el1"); + el1.setValue("element1"); + dom.addChild(el1); - Xpp3Dom el2 = new Xpp3Dom( "el2" ); - el2.setAttribute( "att2", "attribute2\nnextline" ); - dom.addChild( el2 ); + Xpp3Dom el2 = new Xpp3Dom("el2"); + el2.setAttribute("att2", "attribute2\nnextline"); + dom.addChild(el2); - Xpp3Dom el3 = new Xpp3Dom( "el3" ); - el3.setAttribute( "att3", "attribute3" ); - el3.setValue( "element3" ); - el2.addChild( el3 ); + Xpp3Dom el3 = new Xpp3Dom("el3"); + el3.setAttribute("att3", "attribute3"); + el3.setValue("element3"); + el2.addChild(el3); - Xpp3Dom el4 = new Xpp3Dom( "el4" ); - el4.setValue( "" ); - dom.addChild( el4 ); + Xpp3Dom el4 = new Xpp3Dom("el4"); + el4.setValue(""); + dom.addChild(el4); - Xpp3Dom el5 = new Xpp3Dom( "el5" ); - dom.addChild( el5 ); + Xpp3Dom el5 = new Xpp3Dom("el5"); + dom.addChild(el5); // test escaping - Xpp3Dom el6 = new Xpp3Dom( "el6" ); - el6.setAttribute( "att6", "attribute6\n&\"'<>" ); - dom.addChild( el6 ); + Xpp3Dom el6 = new Xpp3Dom("el6"); + el6.setAttribute("att6", "attribute6\n&\"'<>"); + dom.addChild(el6); - Xpp3Dom el7 = new Xpp3Dom( "el7" ); - el7.setValue( "element7\n&\"\'<>" ); - el6.addChild( el7 ); + Xpp3Dom el7 = new Xpp3Dom("el7"); + el7.setValue("element7\n&\"\'<>"); + el6.addChild(el7); return dom; } 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 458d800f..becde36c 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 @@ -1,8 +1,5 @@ package org.codehaus.plexus.util.xml.pull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - import java.io.File; import java.io.FileReader; import java.io.IOException; @@ -11,6 +8,9 @@ import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + /** * Test class that execute a particular set of tests associated to a TESCASES tag from the XML W3C Conformance Tests. * TESCASES PROFILE:
    IBM XML Conformance Test Suite - Production 24
    @@ -20,10 +20,10 @@ * @version $Id: $Id * @since 3.4.0 */ -public class IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production24_Test -{ +public +class IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production24_Test { - final static File testResourcesDir = new File( "src/test/resources/", "xmlconf/ibm/" ); + static final File testResourcesDir = new File("src/test/resources/", "xmlconf/ibm/"); MXParser parser; @@ -31,8 +31,7 @@ public class IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMX *

    setUp.

    */ @Before - public void setUp() - { + public void setUp() { parser = new MXParser(); } @@ -46,228 +45,190 @@ public void setUp() * @throws java.io.IOException if there is an I/O error */ @Test - public 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 ) + public 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) ; - fail( "Tests VersionInfo with a required field missing. The VersionNum is missing in the VersionInfo in the XMLDecl." ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "expected apostrophe (') or quotation mark (\") after version and not ?" ) ); + fail( + "Tests VersionInfo with a required field missing. The VersionNum is missing in the VersionInfo in the XMLDecl."); + } catch (XmlPullParserException e) { + assertTrue( + e.getMessage().contains("expected apostrophe (') or quotation mark (\") after version and not ?")); } } - /** - * Test ID:
    ibm-not-wf-P24-ibm24n02.xml
    - * Test URI:
    not-wf/P24/ibm24n02.xml
    - * Comment:
    Tests VersionInfo with a required field missing. The white space is     missing between the key word "xml" and the VersionInfo in the XMLDecl.
    - * Sections:
    2.8
    - * Version: - * - * @throws java.io.IOException if there is an I/O error - */ - @Test - public 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 ) - ; - fail( "Tests VersionInfo with a required field missing. The white space is missing between the key word \"xml\" and the VersionInfo in the XMLDecl." ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "expected v in version and not ?" ) ); - } - } - - /** - * Test ID:
    ibm-not-wf-P24-ibm24n03.xml
    - * Test URI:
    not-wf/P24/ibm24n03.xml
    - * Comment:
    Tests VersionInfo with a required field missing. The "="      (equal sign) is missing between the key word "version" and the VersionNum.
    - * Sections:
    2.8
    - * Version: - * - * @throws java.io.IOException if there is an I/O error - */ - @Test - public 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 ) - ; - fail( "Tests VersionInfo with a required field missing. The \"=\" (equal sign) is missing between the key word \"version\" and the VersionNum." ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "expected equals sign (=) after version and not \\'" ) ); - } - } + /** + * Test ID:
    ibm-not-wf-P24-ibm24n02.xml
    + * Test URI:
    not-wf/P24/ibm24n02.xml
    + * Comment:
    Tests VersionInfo with a required field missing. The white space is     missing between the key word "xml" and the VersionInfo in the XMLDecl.
    + * Sections:
    2.8
    + * Version: + * + * @throws java.io.IOException if there is an I/O error + */ + @Test + public 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) + ; + fail( + "Tests VersionInfo with a required field missing. The white space is missing between the key word \"xml\" and the VersionInfo in the XMLDecl."); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("expected v in version and not ?")); + } + } - /** - * Test ID:
    ibm-not-wf-P24-ibm24n04.xml
    - * Test URI:
    not-wf/P24/ibm24n04.xml
    - * Comment:
    Tests VersionInfo with wrong field ordering. The VersionNum     occurs before "=" and "version".
    - * Sections:
    2.8
    - * Version: - * - * @throws java.io.IOException if there is an I/O error - */ - @Test - public 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 ) - ; - fail( "Tests VersionInfo with wrong field ordering. The VersionNum occurs before \"=\" and \"version\"." ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "expected v in version and not \\'" ) ); - } - } + /** + * Test ID:
    ibm-not-wf-P24-ibm24n03.xml
    + * Test URI:
    not-wf/P24/ibm24n03.xml
    + * Comment:
    Tests VersionInfo with a required field missing. The "="      (equal sign) is missing between the key word "version" and the VersionNum.
    + * Sections:
    2.8
    + * Version: + * + * @throws java.io.IOException if there is an I/O error + */ + @Test + public 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) + ; + fail( + "Tests VersionInfo with a required field missing. The \"=\" (equal sign) is missing between the key word \"version\" and the VersionNum."); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("expected equals sign (=) after version and not \\'")); + } + } - /** - * Test ID:
    ibm-not-wf-P24-ibm24n05.xml
    - * Test URI:
    not-wf/P24/ibm24n05.xml
    - * Comment:
    Tests VersionInfo with wrong field ordering. The "=" occurs     after "version" and the VersionNum.
    - * Sections:
    2.8
    - * Version: - * - * @throws java.io.IOException if there is an I/O error - */ - @Test - public 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 ) - ; - fail( "Tests VersionInfo with wrong field ordering. The \"=\" occurs after \"version\" and the VersionNum." ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "expected equals sign (=) after version and not \\'" ) ); - } - } + /** + * Test ID:
    ibm-not-wf-P24-ibm24n04.xml
    + * Test URI:
    not-wf/P24/ibm24n04.xml
    + * Comment:
    Tests VersionInfo with wrong field ordering. The VersionNum     occurs before "=" and "version".
    + * Sections:
    2.8
    + * Version: + * + * @throws java.io.IOException if there is an I/O error + */ + @Test + public 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) + ; + fail( + "Tests VersionInfo with wrong field ordering. The VersionNum occurs before \"=\" and \"version\"."); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("expected v in version and not \\'")); + } + } - /** - * Test ID:
    ibm-not-wf-P24-ibm24n06.xml
    - * Test URI:
    not-wf/P24/ibm24n06.xml
    - * Comment:
    Tests VersionInfo with the wrong key word "Version".
    - * Sections:
    2.8
    - * Version: - * - * @throws java.io.IOException if there is an I/O error - */ - @Test - public 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 ) - ; - fail( "Tests VersionInfo with the wrong key word \"Version\"." ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "expected v in version and not V" ) ); - } - } + /** + * Test ID:
    ibm-not-wf-P24-ibm24n05.xml
    + * Test URI:
    not-wf/P24/ibm24n05.xml
    + * Comment:
    Tests VersionInfo with wrong field ordering. The "=" occurs     after "version" and the VersionNum.
    + * Sections:
    2.8
    + * Version: + * + * @throws java.io.IOException if there is an I/O error + */ + @Test + public 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) + ; + fail( + "Tests VersionInfo with wrong field ordering. The \"=\" occurs after \"version\" and the VersionNum."); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("expected equals sign (=) after version and not \\'")); + } + } - /** - * Test ID:
    ibm-not-wf-P24-ibm24n07.xml
    - * Test URI:
    not-wf/P24/ibm24n07.xml
    - * Comment:
    Tests VersionInfo with the wrong key word "versioN".
    - * Sections:
    2.8
    - * Version: - * - * @throws java.io.IOException if there is an I/O error - */ - @Test - public 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 ) - ; - fail( "Tests VersionInfo with the wrong key word \"versioN\"." ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "expected n in version and not N" ) ); - } - } + /** + * Test ID:
    ibm-not-wf-P24-ibm24n06.xml
    + * Test URI:
    not-wf/P24/ibm24n06.xml
    + * Comment:
    Tests VersionInfo with the wrong key word "Version".
    + * Sections:
    2.8
    + * Version: + * + * @throws java.io.IOException if there is an I/O error + */ + @Test + public 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) + ; + fail("Tests VersionInfo with the wrong key word \"Version\"."); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("expected v in version and not V")); + } + } - /** - * Test ID:
    ibm-not-wf-P24-ibm24n08.xml
    - * Test URI:
    not-wf/P24/ibm24n08.xml
    - * Comment:
    Tests VersionInfo with mismatched quotes around the VersionNum.      version = '1.0" is used as the VersionInfo.
    - * Sections:
    2.8
    - * Version: - * - * @throws java.io.IOException if there is an I/O error - */ - @Test - public 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 ) - ; - fail( "Tests VersionInfo with mismatched quotes around the VersionNum. version = '1.0\" is used as the VersionInfo." ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "ibm-not-wf-P24-ibm24n07.xml
    + * Test URI:
    not-wf/P24/ibm24n07.xml
    + * Comment:
    Tests VersionInfo with the wrong key word "versioN".
    + * Sections:
    2.8
    + * Version: + * + * @throws java.io.IOException if there is an I/O error + */ + @Test + public 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) + ; + fail("Tests VersionInfo with the wrong key word \"versioN\"."); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("expected n in version and not N")); + } + } - /** - * Test ID:
    ibm-not-wf-P24-ibm24n09.xml
    - * Test URI:
    not-wf/P24/ibm24n09.xml
    - * Comment:
    Tests VersionInfo with mismatched quotes around the VersionNum.      The closing bracket for the VersionNum is missing.
    - * Sections:
    2.8
    - * Version: - * - * @throws java.io.IOException if there is an I/O error - */ - @Test - public 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 ) - ; - fail( "Tests VersionInfo with mismatched quotes around the VersionNum. The closing bracket for the VersionNum is missing." ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "ibm-not-wf-P24-ibm24n08.xml
    + * Test URI:
    not-wf/P24/ibm24n08.xml
    + * Comment:
    Tests VersionInfo with mismatched quotes around the VersionNum.      version = '1.0" is used as the VersionInfo.
    + * Sections:
    2.8
    + * Version: + * + * @throws java.io.IOException if there is an I/O error + */ + @Test + public 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) + ; + fail( + "Tests VersionInfo with mismatched quotes around the VersionNum. version = '1.0\" is used as the VersionInfo."); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("ibm-not-wf-P24-ibm24n09.xml
    + * Test URI:
    not-wf/P24/ibm24n09.xml
    + * Comment:
    Tests VersionInfo with mismatched quotes around the VersionNum.      The closing bracket for the VersionNum is missing.
    + * Sections:
    2.8
    + * Version: + * + * @throws java.io.IOException if there is an I/O error + */ + @Test + public 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) + ; + fail( + "Tests VersionInfo with mismatched quotes around the VersionNum. The closing bracket for the VersionNum is missing."); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("IBM XML Conformance Test Suite - Production 2
    @@ -27,9 +27,10 @@ * @version $Id: $Id * @since 3.4.0 */ -public class IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production2_Test { +public +class IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production2_Test { - final static File testResourcesDir = new File("src/test/resources/", "xmlconf/ibm/"); + static final File testResourcesDir = new File("src/test/resources/", "xmlconf/ibm/"); MXParser parser; @@ -51,23 +52,17 @@ public void setUp() { * @throws java.io.IOException if there is an I/O error */ @Test - public 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 ) + public 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) ; - fail( "Tests a comment which contains an illegal Char: #x00" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "Illegal character 0x0 found in comment" ) ); + fail("Tests a comment which contains an illegal Char: #x00"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("Illegal character 0x0 found in comment")); } } - /** * Test ID:
    ibm-not-wf-P02-ibm02n02.xml
    * Test URI:
    not-wf/P02/ibm02n02.xml
    @@ -78,19 +73,14 @@ public void testibm_not_wf_P02_ibm02n01xml() * @throws java.io.IOException if there is an I/O error */ @Test - public 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 ) + public 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) ; - fail( "Tests a comment which contains an illegal Char: #x01" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "Illegal character 0x1 found in comment" ) ); + fail("Tests a comment which contains an illegal Char: #x01"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("Illegal character 0x1 found in comment")); } } @@ -104,19 +94,14 @@ public void testibm_not_wf_P02_ibm02n02xml() * @throws java.io.IOException if there is an I/O error */ @Test - public 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 ) + public 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) ; - fail( "Tests a comment which contains an illegal Char: #x02" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "Illegal character 0x2 found in comment" ) ); + fail("Tests a comment which contains an illegal Char: #x02"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("Illegal character 0x2 found in comment")); } } @@ -130,19 +115,14 @@ public void testibm_not_wf_P02_ibm02n03xml() * @throws java.io.IOException if there is an I/O error */ @Test - public 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 ) + public 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) ; - fail( "Tests a comment which contains an illegal Char: #x03" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "Illegal character 0x3 found in comment" ) ); + fail("Tests a comment which contains an illegal Char: #x03"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("Illegal character 0x3 found in comment")); } } @@ -156,19 +136,14 @@ public void testibm_not_wf_P02_ibm02n04xml() * @throws java.io.IOException if there is an I/O error */ @Test - public 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 ) + public 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) ; - fail( "Tests a comment which contains an illegal Char: #x04" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "Illegal character 0x4 found in comment" ) ); + fail("Tests a comment which contains an illegal Char: #x04"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("Illegal character 0x4 found in comment")); } } @@ -182,19 +157,14 @@ public void testibm_not_wf_P02_ibm02n05xml() * @throws java.io.IOException if there is an I/O error */ @Test - public 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 ) + public 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) ; - fail( "Tests a comment which contains an illegal Char: #x05" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "Illegal character 0x5 found in comment" ) ); + fail("Tests a comment which contains an illegal Char: #x05"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("Illegal character 0x5 found in comment")); } } @@ -209,18 +179,16 @@ public void testibm_not_wf_P02_ibm02n06xml() */ @Test public void testibm_not_wf_P02_ibm02n07xml() throws IOException { - try(Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n07.xml"))) { + try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n07.xml"))) { parser.setInput(reader); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT); + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) + ; fail("Tests a comment which contains an illegal Char: #x06"); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "Illegal character 0x6 found in comment" ) ); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("Illegal character 0x6 found in comment")); } } - /** * Test ID:
    ibm-not-wf-P02-ibm02n08.xml
    * Test URI:
    not-wf/P02/ibm02n08.xml
    @@ -231,19 +199,14 @@ 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 - { - try ( Reader reader = new FileReader( new File( testResourcesDir, "not-wf/P02/ibm02n08.xml" ) ) ) - { - parser.setInput( reader ); - while ( parser.nextToken() != XmlPullParser.END_DOCUMENT ) + public 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) ; - fail( "Tests a comment which contains an illegal Char: #x07" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "Illegal character 0x7 found in comment" ) ); + fail("Tests a comment which contains an illegal Char: #x07"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("Illegal character 0x7 found in comment")); } } @@ -257,19 +220,14 @@ public void testibm_not_wf_P02_ibm02n08xml() * @throws java.io.IOException if there is an I/O error */ @Test - public 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 ) + public 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) ; - fail( "Tests a comment which contains an illegal Char: #x08" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "Illegal character 0x8 found in comment" ) ); + fail("Tests a comment which contains an illegal Char: #x08"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("Illegal character 0x8 found in comment")); } } @@ -283,19 +241,14 @@ public void testibm_not_wf_P02_ibm02n09xml() * @throws java.io.IOException if there is an I/O error */ @Test - public 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 ) + public 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) ; - fail( "Tests a comment which contains an illegal Char: #x0B" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "Illegal character 0xb found in comment" ) ); + fail("Tests a comment which contains an illegal Char: #x0B"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("Illegal character 0xb found in comment")); } } @@ -309,19 +262,14 @@ public void testibm_not_wf_P02_ibm02n10xml() * @throws java.io.IOException if there is an I/O error */ @Test - public 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 ) + public 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) ; - fail( "Tests a comment which contains an illegal Char: #x0C" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "Illegal character 0xc found in comment" ) ); + fail("Tests a comment which contains an illegal Char: #x0C"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("Illegal character 0xc found in comment")); } } @@ -335,19 +283,14 @@ public void testibm_not_wf_P02_ibm02n11xml() * @throws java.io.IOException if there is an I/O error */ @Test - public 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 ) + public 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) ; - fail( "Tests a comment which contains an illegal Char: #x0E" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "Illegal character 0xe found in comment" ) ); + fail("Tests a comment which contains an illegal Char: #x0E"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("Illegal character 0xe found in comment")); } } @@ -361,19 +304,14 @@ public void testibm_not_wf_P02_ibm02n12xml() * @throws java.io.IOException if there is an I/O error */ @Test - public 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 ) + public 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) ; - fail( "Tests a comment which contains an illegal Char: #x0F" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "Illegal character 0xf found in comment" ) ); + fail("Tests a comment which contains an illegal Char: #x0F"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("Illegal character 0xf found in comment")); } } @@ -387,19 +325,14 @@ public void testibm_not_wf_P02_ibm02n13xml() * @throws java.io.IOException if there is an I/O error */ @Test - public 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 ) + public 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) ; - fail( "Tests a comment which contains an illegal Char: #x10" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "Illegal character 0x10 found in comment" ) ); + fail("Tests a comment which contains an illegal Char: #x10"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("Illegal character 0x10 found in comment")); } } @@ -413,19 +346,14 @@ public void testibm_not_wf_P02_ibm02n14xml() * @throws java.io.IOException if there is an I/O error */ @Test - public 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 ) + public 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) ; - fail( "Tests a comment which contains an illegal Char: #x11" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "Illegal character 0x11 found in comment" ) ); + fail("Tests a comment which contains an illegal Char: #x11"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("Illegal character 0x11 found in comment")); } } @@ -439,19 +367,14 @@ public void testibm_not_wf_P02_ibm02n15xml() * @throws java.io.IOException if there is an I/O error */ @Test - public 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 ) + public 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) ; - fail( "Tests a comment which contains an illegal Char: #x12" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "Illegal character 0x12 found in comment" ) ); + fail("Tests a comment which contains an illegal Char: #x12"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("Illegal character 0x12 found in comment")); } } @@ -465,19 +388,14 @@ public void testibm_not_wf_P02_ibm02n16xml() * @throws java.io.IOException if there is an I/O error */ @Test - public 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 ) + public 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) ; - fail( "Tests a comment which contains an illegal Char: #x13" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "Illegal character 0x13 found in comment" ) ); + fail("Tests a comment which contains an illegal Char: #x13"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("Illegal character 0x13 found in comment")); } } @@ -491,19 +409,14 @@ public void testibm_not_wf_P02_ibm02n17xml() * @throws java.io.IOException if there is an I/O error */ @Test - public 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 ) + public 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) ; - fail( "Tests a comment which contains an illegal Char: #x14" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "Illegal character 0x14 found in comment" ) ); + fail("Tests a comment which contains an illegal Char: #x14"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("Illegal character 0x14 found in comment")); } } @@ -517,19 +430,14 @@ public void testibm_not_wf_P02_ibm02n18xml() * @throws java.io.IOException if there is an I/O error */ @Test - public 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 ) + public 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) ; - fail( "Tests a comment which contains an illegal Char: #x15" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "Illegal character 0x15 found in comment" ) ); + fail("Tests a comment which contains an illegal Char: #x15"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("Illegal character 0x15 found in comment")); } } @@ -543,19 +451,14 @@ public void testibm_not_wf_P02_ibm02n19xml() * @throws java.io.IOException if there is an I/O error */ @Test - public 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 ) + public 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) ; - fail( "Tests a comment which contains an illegal Char: #x16" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "Illegal character 0x16 found in comment" ) ); + fail("Tests a comment which contains an illegal Char: #x16"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("Illegal character 0x16 found in comment")); } } @@ -569,19 +472,14 @@ public void testibm_not_wf_P02_ibm02n20xml() * @throws java.io.IOException if there is an I/O error */ @Test - public 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 ) + public 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) ; - fail( "Tests a comment which contains an illegal Char: #x17" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "Illegal character 0x17 found in comment" ) ); + fail("Tests a comment which contains an illegal Char: #x17"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("Illegal character 0x17 found in comment")); } } @@ -595,19 +493,14 @@ public void testibm_not_wf_P02_ibm02n21xml() * @throws java.io.IOException if there is an I/O error */ @Test - public 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 ) + public 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) ; - fail( "Tests a comment which contains an illegal Char: #x18" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "Illegal character 0x18 found in comment" ) ); + fail("Tests a comment which contains an illegal Char: #x18"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("Illegal character 0x18 found in comment")); } } @@ -621,19 +514,14 @@ public void testibm_not_wf_P02_ibm02n22xml() * @throws java.io.IOException if there is an I/O error */ @Test - public 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 ) + public 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) ; - fail( "Tests a comment which contains an illegal Char: #x19" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "Illegal character 0x19 found in comment" ) ); + fail("Tests a comment which contains an illegal Char: #x19"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("Illegal character 0x19 found in comment")); } } @@ -647,19 +535,14 @@ public void testibm_not_wf_P02_ibm02n23xml() * @throws java.io.IOException if there is an I/O error */ @Test - public 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 ) + public 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) ; - fail( "Tests a comment which contains an illegal Char: #x1A" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "Illegal character 0x1a found in comment" ) ); + fail("Tests a comment which contains an illegal Char: #x1A"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("Illegal character 0x1a found in comment")); } } @@ -673,19 +556,14 @@ public void testibm_not_wf_P02_ibm02n24xml() * @throws java.io.IOException if there is an I/O error */ @Test - public 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 ) + public 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) ; - fail( "Tests a comment which contains an illegal Char: #x1B" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "Illegal character 0x1b found in comment" ) ); + fail("Tests a comment which contains an illegal Char: #x1B"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("Illegal character 0x1b found in comment")); } } @@ -699,19 +577,14 @@ public void testibm_not_wf_P02_ibm02n25xml() * @throws java.io.IOException if there is an I/O error */ @Test - public 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 ) + public 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) ; - fail( "Tests a comment which contains an illegal Char: #x1C" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "Illegal character 0x1c found in comment" ) ); + fail("Tests a comment which contains an illegal Char: #x1C"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("Illegal character 0x1c found in comment")); } } @@ -725,19 +598,14 @@ public void testibm_not_wf_P02_ibm02n26xml() * @throws java.io.IOException if there is an I/O error */ @Test - public 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 ) + public 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) ; - fail( "Tests a comment which contains an illegal Char: #x1D" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "Illegal character 0x1d found in comment" ) ); + fail("Tests a comment which contains an illegal Char: #x1D"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("Illegal character 0x1d found in comment")); } } @@ -751,19 +619,14 @@ public void testibm_not_wf_P02_ibm02n27xml() * @throws java.io.IOException if there is an I/O error */ @Test - public 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 ) + public 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) ; - fail( "Tests a comment which contains an illegal Char: #x1E" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "Illegal character 0x1e found in comment" ) ); + fail("Tests a comment which contains an illegal Char: #x1E"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("Illegal character 0x1e found in comment")); } } @@ -777,19 +640,14 @@ public void testibm_not_wf_P02_ibm02n28xml() * @throws java.io.IOException if there is an I/O error */ @Test - public 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 ) + public 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) ; - fail( "Tests a comment which contains an illegal Char: #x1F" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "Illegal character 0x1f found in comment" ) ); + fail("Tests a comment which contains an illegal Char: #x1F"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("Illegal character 0x1f found in comment")); } } @@ -804,22 +662,17 @@ public void testibm_not_wf_P02_ibm02n29xml() * * NOTE: This test file is malformed into the original test suite, so I skip it. */ - //@Test - public void testibm_not_wf_P02_ibm02n30xml() - throws IOException - { - try ( BufferedReader reader = - Files.newBufferedReader( Paths.get( testResourcesDir.getCanonicalPath(), "not-wf/P02/ibm02n30.xml" ), - Charset.forName( "ISO-8859-15" ) ) ) - { - parser.setInput( reader ); - while ( parser.nextToken() != XmlPullParser.END_DOCUMENT ) + // @Test + public void testibm_not_wf_P02_ibm02n30xml() throws IOException { + try (BufferedReader reader = Files.newBufferedReader( + Paths.get(testResourcesDir.getCanonicalPath(), "not-wf/P02/ibm02n30.xml"), + Charset.forName("ISO-8859-15"))) { + parser.setInput(reader); + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) ; - fail( "Tests a comment which contains an illegal Char: #xD800" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "Illegal character 0xd800 found in comment" ) ); + fail("Tests a comment which contains an illegal Char: #xD800"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("Illegal character 0xd800 found in comment")); } } @@ -834,21 +687,16 @@ public void testibm_not_wf_P02_ibm02n30xml() * * NOTE: This test file is malformed into the original test suite, so I skip it. */ - //@Test - public void testibm_not_wf_P02_ibm02n31xml() - throws IOException - { - try ( FileInputStream is = new FileInputStream( new File( testResourcesDir, "not-wf/P02/ibm02n31.xml" ) ); - InputStreamReader reader = new InputStreamReader( is, "ISO-8859-15" ) ) - { - parser.setInput( reader ); - while ( parser.nextToken() != XmlPullParser.END_DOCUMENT ) + // @Test + public void testibm_not_wf_P02_ibm02n31xml() throws IOException { + try (FileInputStream is = new FileInputStream(new File(testResourcesDir, "not-wf/P02/ibm02n31.xml")); + InputStreamReader reader = new InputStreamReader(is, "ISO-8859-15")) { + parser.setInput(reader); + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) ; - fail( "Tests a comment which contains an illegal Char: #xDFFF" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "Illegal character 0xdfff found in comment" ) ); + fail("Tests a comment which contains an illegal Char: #xDFFF"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("Illegal character 0xdfff found in comment")); } } @@ -862,20 +710,15 @@ public void testibm_not_wf_P02_ibm02n31xml() * @throws java.io.IOException if there is an I/O error */ @Test - public 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 ); - while ( parser.nextToken() != XmlPullParser.END_DOCUMENT ) + public 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); + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) ; - fail( "Tests a comment which contains an illegal Char: #xFFFE" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "Illegal character 0xfffe found in comment" ) ); + fail("Tests a comment which contains an illegal Char: #xFFFE"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("Illegal character 0xfffe found in comment")); } } @@ -889,21 +732,15 @@ public void testibm_not_wf_P02_ibm02n32xml() * @throws java.io.IOException if there is an I/O error */ @Test - public 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 ); - while ( parser.nextToken() != XmlPullParser.END_DOCUMENT ) + public 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); + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) ; - fail( "Tests a comment which contains an illegal Char: #xFFFF" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "Illegal character 0xffff found in comment" ) ); + fail("Tests a comment which contains an illegal Char: #xFFFF"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("Illegal character 0xffff found in comment")); } } - } 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 a6a80030..91effa9d 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 @@ -1,8 +1,5 @@ package org.codehaus.plexus.util.xml.pull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - import java.io.File; import java.io.FileReader; import java.io.IOException; @@ -11,6 +8,9 @@ import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + /** * Test class that execute a particular set of tests associated to a TESCASES tag from the XML W3C Conformance Tests. * TESCASES PROFILE:
    IBM XML Conformance Test Suite - Production 32
    @@ -20,10 +20,10 @@ * @version $Id: $Id * @since 3.4.0 */ -public class IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production32_Test -{ +public +class IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production32_Test { - final static File testResourcesDir = new File( "src/test/resources/", "xmlconf/ibm/" ); + static final File testResourcesDir = new File("src/test/resources/", "xmlconf/ibm/"); MXParser parser; @@ -31,246 +31,203 @@ public class IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMX *

    setUp.

    */ @Before - public void setUp() - { + public void setUp() { parser = new MXParser(); } - /** - * Test ID:
    ibm-not-wf-P32-ibm32n01.xml
    - * Test URI:
    not-wf/P32/ibm32n01.xml
    - * Comment:
    Tests SDDecl with a required field missing. The leading white space     is missing with the SDDecl in the XMLDecl.
    - * Sections:
    2.9
    - * Version: - * - * @throws java.io.IOException if there is an I/O error - */ - @Test - public 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 ) - ; - fail( "Tests SDDecl with a required field missing. The leading white space is missing with the SDDecl in the XMLDecl." ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "expected a space after version and not s" ) ); - } - } - - /** - * Test ID:
    ibm-not-wf-P32-ibm32n02.xml
    - * Test URI:
    not-wf/P32/ibm32n02.xml
    - * Comment:
    Tests SDDecl with a required field missing. The "=" sign is missing     in the SDDecl in the XMLDecl.
    - * Sections:
    2.9
    - * Version: - * - * @throws java.io.IOException if there is an I/O error - */ - @Test - public 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 ) - ; - fail( "Tests SDDecl with a required field missing. The \"=\" sign is missing in the SDDecl in the XMLDecl." ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "expected equals sign (=) after standalone and not \"" ) ); - } - } - - /** - * Test ID:
    ibm-not-wf-P32-ibm32n03.xml
    - * Test URI:
    not-wf/P32/ibm32n03.xml
    - * Comment:
    Tests SDDecl with wrong key word. The word "Standalone" occurs in      the SDDecl in the XMLDecl.
    - * Sections:
    2.9
    - * Version: - * - * @throws java.io.IOException if there is an I/O error - */ - @Test - public 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 ) - ; - fail( "Tests SDDecl with wrong key word. The word \"Standalone\" occurs in the SDDecl in the XMLDecl." ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "unexpected character S" ) ); - } - } + /** + * Test ID:
    ibm-not-wf-P32-ibm32n01.xml
    + * Test URI:
    not-wf/P32/ibm32n01.xml
    + * Comment:
    Tests SDDecl with a required field missing. The leading white space     is missing with the SDDecl in the XMLDecl.
    + * Sections:
    2.9
    + * Version: + * + * @throws java.io.IOException if there is an I/O error + */ + @Test + public 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) + ; + fail( + "Tests SDDecl with a required field missing. The leading white space is missing with the SDDecl in the XMLDecl."); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("expected a space after version and not s")); + } + } - /** - * Test ID:
    ibm-not-wf-P32-ibm32n04.xml
    - * Test URI:
    not-wf/P32/ibm32n04.xml
    - * Comment:
    Tests SDDecl with wrong key word. The word "Yes" occurs in the     SDDecl in the XMLDecl.
    - * Sections:
    2.9
    - * Version: - * - * @throws java.io.IOException if there is an I/O error - */ - @Test - public 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 ) - ; - fail( "Tests SDDecl with wrong key word. The word \"Yes\" occurs in the SDDecl in the XMLDecl." ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "expected 'yes' or 'no' after standalone and not Y" ) ); - } - } + /** + * Test ID:
    ibm-not-wf-P32-ibm32n02.xml
    + * Test URI:
    not-wf/P32/ibm32n02.xml
    + * Comment:
    Tests SDDecl with a required field missing. The "=" sign is missing     in the SDDecl in the XMLDecl.
    + * Sections:
    2.9
    + * Version: + * + * @throws java.io.IOException if there is an I/O error + */ + @Test + public 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) + ; + fail( + "Tests SDDecl with a required field missing. The \"=\" sign is missing in the SDDecl in the XMLDecl."); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("expected equals sign (=) after standalone and not \"")); + } + } - /** - * Test ID:
    ibm-not-wf-P32-ibm32n05.xml
    - * Test URI:
    not-wf/P32/ibm32n05.xml
    - * Comment:
    Tests SDDecl with wrong key word. The word "YES" occurs in the     SDDecl in the XMLDecl.
    - * Sections:
    2.9
    - * Version: - * - * @throws java.io.IOException if there is an I/O error - */ - @Test - public void testibm_not_wf_P32_ibm32n05xml() - throws IOException - { + /** + * Test ID:
    ibm-not-wf-P32-ibm32n03.xml
    + * Test URI:
    not-wf/P32/ibm32n03.xml
    + * Comment:
    Tests SDDecl with wrong key word. The word "Standalone" occurs in      the SDDecl in the XMLDecl.
    + * Sections:
    2.9
    + * Version: + * + * @throws java.io.IOException if there is an I/O error + */ + @Test + public 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) + ; + fail("Tests SDDecl with wrong key word. The word \"Standalone\" occurs in the SDDecl in the XMLDecl."); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("unexpected character S")); + } + } - try ( Reader reader = new FileReader( new File( testResourcesDir, "not-wf/P32/ibm32n05.xml" ) ) ) - { - parser.setInput( reader ); - while ( parser.nextToken() != XmlPullParser.END_DOCUMENT ) - ; - fail( "Tests SDDecl with wrong key word. The word \"YES\" occurs in the SDDecl in the XMLDecl." ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "expected 'yes' or 'no' after standalone and not Y" ) ); - } - } + /** + * Test ID:
    ibm-not-wf-P32-ibm32n04.xml
    + * Test URI:
    not-wf/P32/ibm32n04.xml
    + * Comment:
    Tests SDDecl with wrong key word. The word "Yes" occurs in the     SDDecl in the XMLDecl.
    + * Sections:
    2.9
    + * Version: + * + * @throws java.io.IOException if there is an I/O error + */ + @Test + public 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) + ; + fail("Tests SDDecl with wrong key word. The word \"Yes\" occurs in the SDDecl in the XMLDecl."); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("expected 'yes' or 'no' after standalone and not Y")); + } + } - /** - * Test ID:
    ibm-not-wf-P32-ibm32n06.xml
    - * Test URI:
    not-wf/P32/ibm32n06.xml
    - * Comment:
    Tests SDDecl with wrong key word. The word "No" occurs in the     SDDecl in the XMLDecl.
    - * Sections:
    2.9
    - * Version: - * - * @throws java.io.IOException if there is an I/O error - */ - @Test - public 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 ) - ; - fail( "Tests SDDecl with wrong key word. The word \"No\" occurs in the SDDecl in the XMLDecl." ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "expected 'yes' or 'no' after standalone and not N" ) ); - } - } + /** + * Test ID:
    ibm-not-wf-P32-ibm32n05.xml
    + * Test URI:
    not-wf/P32/ibm32n05.xml
    + * Comment:
    Tests SDDecl with wrong key word. The word "YES" occurs in the     SDDecl in the XMLDecl.
    + * Sections:
    2.9
    + * Version: + * + * @throws java.io.IOException if there is an I/O error + */ + @Test + public void testibm_not_wf_P32_ibm32n05xml() throws IOException { + + try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P32/ibm32n05.xml"))) { + parser.setInput(reader); + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) + ; + fail("Tests SDDecl with wrong key word. The word \"YES\" occurs in the SDDecl in the XMLDecl."); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("expected 'yes' or 'no' after standalone and not Y")); + } + } - /** - * Test ID:
    ibm-not-wf-P32-ibm32n07.xml
    - * Test URI:
    not-wf/P32/ibm32n07.xml
    - * Comment:
    Tests SDDecl with wrong key word. The word "NO" occurs in the     SDDecl in the XMLDecl.
    - * Sections:
    2.9
    - * Version: - * - * @throws java.io.IOException if there is an I/O error - */ - @Test - public 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 ) - ; - fail( "Tests SDDecl with wrong key word. The word \"NO\" occurs in the SDDecl in the XMLDecl." ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "expected 'yes' or 'no' after standalone and not N" ) ); - } - } + /** + * Test ID:
    ibm-not-wf-P32-ibm32n06.xml
    + * Test URI:
    not-wf/P32/ibm32n06.xml
    + * Comment:
    Tests SDDecl with wrong key word. The word "No" occurs in the     SDDecl in the XMLDecl.
    + * Sections:
    2.9
    + * Version: + * + * @throws java.io.IOException if there is an I/O error + */ + @Test + public 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) + ; + fail("Tests SDDecl with wrong key word. The word \"No\" occurs in the SDDecl in the XMLDecl."); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("expected 'yes' or 'no' after standalone and not N")); + } + } - /** - * Test ID:
    ibm-not-wf-P32-ibm32n08.xml
    - * Test URI:
    not-wf/P32/ibm32n08.xml
    - * Comment:
    Tests SDDecl with wrong field ordering. The "=" sign occurs      after the key word "yes" in the SDDecl in the XMLDecl.
    - * Sections:
    2.9
    - * Version: - * - * @throws java.io.IOException if there is an I/O error - */ - @Test - public 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 ) - ; - fail( "Tests SDDecl with wrong field ordering. The \"=\" sign occurs after the key word \"yes\" in the SDDecl in the XMLDecl." ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "expected equals sign (=) after standalone and not \"" ) ); - } - } + /** + * Test ID:
    ibm-not-wf-P32-ibm32n07.xml
    + * Test URI:
    not-wf/P32/ibm32n07.xml
    + * Comment:
    Tests SDDecl with wrong key word. The word "NO" occurs in the     SDDecl in the XMLDecl.
    + * Sections:
    2.9
    + * Version: + * + * @throws java.io.IOException if there is an I/O error + */ + @Test + public 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) + ; + fail("Tests SDDecl with wrong key word. The word \"NO\" occurs in the SDDecl in the XMLDecl."); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("expected 'yes' or 'no' after standalone and not N")); + } + } - /** - * Test ID:
    ibm-not-wf-P32-ibm32n09.xml
    - * Test URI:
    not-wf/P32/ibm32n09.xml
    - * Comment:
    This is test violates WFC: Entity Declared in P68.     The standalone document declaration has the value yes, BUT there is an      external markup declaration of an entity (other than amp, lt, gt, apos,     quot), and references to this entity appear in the document.
    - * Sections:
    2.9
    - * Version: - * - * @throws java.io.IOException if there is an I/O error - * - * NOTE: This test is SKIPPED as MXParser does not support parsing inside DOCTYPEDECL. - */ - // @Test - public void testibm_not_wf_P32_ibm32n09xml() - throws IOException - { - try ( Reader reader = new FileReader( new File( testResourcesDir, "not-wf/P32/ibm32n09.xml" ) ) ) - { - parser.setInput( reader ); - while ( parser.nextToken() != XmlPullParser.END_DOCUMENT ) - ; - fail( "This is test violates WFC: Entity Declared in P68. The standalone document declaration has the value yes, BUT there is an external markup declaration of an entity (other than amp, lt, gt, apos, quot), and references to this entity appear in the document." ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "expected ?> as last part of ibm-not-wf-P32-ibm32n08.xml
  • + * Test URI:
    not-wf/P32/ibm32n08.xml
    + * Comment:
    Tests SDDecl with wrong field ordering. The "=" sign occurs      after the key word "yes" in the SDDecl in the XMLDecl.
    + * Sections:
    2.9
    + * Version: + * + * @throws java.io.IOException if there is an I/O error + */ + @Test + public 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) + ; + fail( + "Tests SDDecl with wrong field ordering. The \"=\" sign occurs after the key word \"yes\" in the SDDecl in the XMLDecl."); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("expected equals sign (=) after standalone and not \"")); + } + } + /** + * Test ID:
    ibm-not-wf-P32-ibm32n09.xml
    + * Test URI:
    not-wf/P32/ibm32n09.xml
    + * Comment:
    This is test violates WFC: Entity Declared in P68.     The standalone document declaration has the value yes, BUT there is an      external markup declaration of an entity (other than amp, lt, gt, apos,     quot), and references to this entity appear in the document.
    + * Sections:
    2.9
    + * Version: + * + * @throws java.io.IOException if there is an I/O error + * + * NOTE: This test is SKIPPED as MXParser does not support parsing inside DOCTYPEDECL. + */ + // @Test + public void testibm_not_wf_P32_ibm32n09xml() throws IOException { + try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P32/ibm32n09.xml"))) { + parser.setInput(reader); + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) + ; + fail( + "This is test violates WFC: Entity Declared in P68. The standalone document declaration has the value yes, BUT there is an external markup declaration of an entity (other than amp, lt, gt, apos, quot), and references to this entity appear in the document."); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("expected ?> as last part of IBM XML Conformance Test Suite - Production 66
    @@ -22,10 +21,10 @@ * @version $Id: $Id * @since 3.4.0 */ -public class IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production66_Test -{ +public +class IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production66_Test { - final static File testResourcesDir = new File( "src/test/resources/", "xmlconf/ibm/" ); + static final File testResourcesDir = new File("src/test/resources/", "xmlconf/ibm/"); MXParser parser; @@ -33,401 +32,339 @@ public class IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMX *

    setUp.

    */ @Before - public void setUp() - { + public void setUp() { parser = new MXParser(); } - /** - * Test ID:
    ibm-not-wf-P66-ibm66n01.xml
    - * Test URI:
    not-wf/P66/ibm66n01.xml
    - * Comment:
    Tests CharRef with an illegal character referred to. The "#002f" is      used as the referred character in the CharRef in the EntityDecl in the DTD.
    - * Sections:
    4.1
    - * Version: - * - * @throws java.io.IOException if there is an I/O error - */ - @Test - public 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 ) - ; - fail( "Tests CharRef with an illegal character referred to. The \"#002f\" is used as the referred character in the CharRef in the EntityDecl in the DTD." ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "character reference (with decimal value) may not contain f" ) ); - } - } - - /** - * Test ID:
    ibm-not-wf-P66-ibm66n02.xml
    - * Test URI:
    not-wf/P66/ibm66n02.xml
    - * Comment:
    Tests CharRef with the semicolon character missing. The semicolon      character is missing at the end of the CharRef in the attribute value in     the STag of element "root".
    - * Sections:
    4.1
    - * Version: - * - * @throws java.io.IOException if there is an I/O error - */ - @Test - public 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 ) - ; - fail( "Tests CharRef with the semicolon character missing. The semicolon character is missing at the end of the CharRef in the attribute value in the STag of element \"root\"." ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "character reference (with hex value) may not contain \"" ) ); - } - } + /** + * Test ID:
    ibm-not-wf-P66-ibm66n01.xml
    + * Test URI:
    not-wf/P66/ibm66n01.xml
    + * Comment:
    Tests CharRef with an illegal character referred to. The "#002f" is      used as the referred character in the CharRef in the EntityDecl in the DTD.
    + * Sections:
    4.1
    + * Version: + * + * @throws java.io.IOException if there is an I/O error + */ + @Test + public 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) + ; + fail( + "Tests CharRef with an illegal character referred to. The \"#002f\" is used as the referred character in the CharRef in the EntityDecl in the DTD."); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("character reference (with decimal value) may not contain f")); + } + } - /** - * Test ID:
    ibm-not-wf-P66-ibm66n03.xml
    - * Test URI:
    not-wf/P66/ibm66n03.xml
    - * Comment:
    Tests CharRef with an illegal character referred to. The "49" is      used as the referred character in the CharRef in the EntityDecl in the DTD.
    - * Sections:
    4.1
    - * Version: - * - * @throws java.io.IOException if there is an I/O error - */ - @Test - public 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 ) - ; - fail( "Tests CharRef with an illegal character referred to. The \"49\" is used as the referred character in the CharRef in the EntityDecl in the DTD." ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "entity reference names can not start with character '4'" ) ); - } - } + /** + * Test ID:
    ibm-not-wf-P66-ibm66n02.xml
    + * Test URI:
    not-wf/P66/ibm66n02.xml
    + * Comment:
    Tests CharRef with the semicolon character missing. The semicolon      character is missing at the end of the CharRef in the attribute value in     the STag of element "root".
    + * Sections:
    4.1
    + * Version: + * + * @throws java.io.IOException if there is an I/O error + */ + @Test + public 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) + ; + fail( + "Tests CharRef with the semicolon character missing. The semicolon character is missing at the end of the CharRef in the attribute value in the STag of element \"root\"."); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("character reference (with hex value) may not contain \"")); + } + } - /** - * Test ID:
    ibm-not-wf-P66-ibm66n04.xml
    - * Test URI:
    not-wf/P66/ibm66n04.xml
    - * Comment:
    Tests CharRef with an illegal character referred to. The "#5~0" is      used as the referred character in the attribute value in the EmptyElemTag     of the element "root".
    - * Sections:
    4.1
    - * Version: - * - * @throws java.io.IOException if there is an I/O error - */ - @Test - public 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 ) - ; - fail( "Tests CharRef with an illegal character referred to. The \"#5~0\" is used as the referred character in the attribute value in the EmptyElemTag of the element \"root\"." ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "character reference (with decimal value) may not contain ~" ) ); - } - } + /** + * Test ID:
    ibm-not-wf-P66-ibm66n03.xml
    + * Test URI:
    not-wf/P66/ibm66n03.xml
    + * Comment:
    Tests CharRef with an illegal character referred to. The "49" is      used as the referred character in the CharRef in the EntityDecl in the DTD.
    + * Sections:
    4.1
    + * Version: + * + * @throws java.io.IOException if there is an I/O error + */ + @Test + public 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) + ; + fail( + "Tests CharRef with an illegal character referred to. The \"49\" is used as the referred character in the CharRef in the EntityDecl in the DTD."); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("entity reference names can not start with character '4'")); + } + } - /** - * Test ID:
    ibm-not-wf-P66-ibm66n05.xml
    - * Test URI:
    not-wf/P66/ibm66n05.xml
    - * Comment:
    Tests CharRef with an illegal character referred to. The "#x002g" is     used as the referred character in the CharRef in the EntityDecl in the DTD.
    - * Sections:
    4.1
    - * Version: - * - * @throws java.io.IOException if there is an I/O error - * @throws java.io.FileNotFoundException if any. - * @throws org.codehaus.plexus.util.xml.pull.XmlPullParserException if any. - */ - @Test - public 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 ) - ; - fail( "Tests CharRef with an illegal character referred to. The \"#x002g\" is used as the referred character in the CharRef in the EntityDecl in the DTD." ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "character reference (with hex value) may not contain g" ) ); - } - } + /** + * Test ID:
    ibm-not-wf-P66-ibm66n04.xml
    + * Test URI:
    not-wf/P66/ibm66n04.xml
    + * Comment:
    Tests CharRef with an illegal character referred to. The "#5~0" is      used as the referred character in the attribute value in the EmptyElemTag     of the element "root".
    + * Sections:
    4.1
    + * Version: + * + * @throws java.io.IOException if there is an I/O error + */ + @Test + public 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) + ; + fail( + "Tests CharRef with an illegal character referred to. The \"#5~0\" is used as the referred character in the attribute value in the EmptyElemTag of the element \"root\"."); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("character reference (with decimal value) may not contain ~")); + } + } - /** - * Test ID:
    ibm-not-wf-P66-ibm66n06.xml
    - * Test URI:
    not-wf/P66/ibm66n06.xml
    - * Comment:
    Tests CharRef with an illegal character referred to. The "#x006G" is     used as the referred character in the attribute value in the EmptyElemTag      of the element "root".
    - * Sections:
    4.1
    - * Version: - * - * @throws java.io.IOException if there is an I/O error - */ - @Test - public 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 ) - ; - fail( "Tests CharRef with an illegal character referred to. The \"#x006G\" is used as the referred character in the attribute value in the EmptyElemTag of the element \"root\"." ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "character reference (with hex value) may not contain G" ) ); - } - } + /** + * Test ID:
    ibm-not-wf-P66-ibm66n05.xml
    + * Test URI:
    not-wf/P66/ibm66n05.xml
    + * Comment:
    Tests CharRef with an illegal character referred to. The "#x002g" is     used as the referred character in the CharRef in the EntityDecl in the DTD.
    + * Sections:
    4.1
    + * Version: + * + * @throws java.io.IOException if there is an I/O error + * @throws java.io.FileNotFoundException if any. + * @throws org.codehaus.plexus.util.xml.pull.XmlPullParserException if any. + */ + @Test + public 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) + ; + fail( + "Tests CharRef with an illegal character referred to. The \"#x002g\" is used as the referred character in the CharRef in the EntityDecl in the DTD."); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("character reference (with hex value) may not contain g")); + } + } - /** - * Test ID:
    ibm-not-wf-P66-ibm66n07.xml
    - * Test URI:
    not-wf/P66/ibm66n07.xml
    - * Comment:
    Tests CharRef with an illegal character referred to. The "#0=2f" is      used as the referred character in the CharRef in the EntityDecl in the DTD.
    - * Sections:
    4.1
    - * Version: - * - * @throws java.io.IOException if there is an I/O error - */ - @Test - public 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 ) - ; - fail( "Tests CharRef with an illegal character referred to. The \"#0=2f\" is used as the referred character in the CharRef in the EntityDecl in the DTD." ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "character reference (with hex value) may not contain =" ) ); - } - } + /** + * Test ID:
    ibm-not-wf-P66-ibm66n06.xml
    + * Test URI:
    not-wf/P66/ibm66n06.xml
    + * Comment:
    Tests CharRef with an illegal character referred to. The "#x006G" is     used as the referred character in the attribute value in the EmptyElemTag      of the element "root".
    + * Sections:
    4.1
    + * Version: + * + * @throws java.io.IOException if there is an I/O error + */ + @Test + public 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) + ; + fail( + "Tests CharRef with an illegal character referred to. The \"#x006G\" is used as the referred character in the attribute value in the EmptyElemTag of the element \"root\"."); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("character reference (with hex value) may not contain G")); + } + } - /** - * Test ID:
    ibm-not-wf-P66-ibm66n08.xml
    - * Test URI:
    not-wf/P66/ibm66n08.xml
    - * Comment:
    Tests CharRef with an illegal character referred to. The "#56.0" is      used as the referred character in the attribute value in the EmptyElemTag      of the element "root".
    - * Sections:
    4.1
    - * Version: - * - * @throws java.io.IOException if there is an I/O error - */ - @Test - public 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 ) - ; - fail( "Tests CharRef with an illegal character referred to. The \"#56.0\" is used as the referred character in the attribute value in the EmptyElemTag of the element \"root\"." ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "character reference (with decimal value) may not contain ." ) ); - } - } + /** + * Test ID:
    ibm-not-wf-P66-ibm66n07.xml
    + * Test URI:
    not-wf/P66/ibm66n07.xml
    + * Comment:
    Tests CharRef with an illegal character referred to. The "#0=2f" is      used as the referred character in the CharRef in the EntityDecl in the DTD.
    + * Sections:
    4.1
    + * Version: + * + * @throws java.io.IOException if there is an I/O error + */ + @Test + public 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) + ; + fail( + "Tests CharRef with an illegal character referred to. The \"#0=2f\" is used as the referred character in the CharRef in the EntityDecl in the DTD."); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("character reference (with hex value) may not contain =")); + } + } - /** - * Test ID:
    ibm-not-wf-P66-ibm66n09.xml
    - * Test URI:
    not-wf/P66/ibm66n09.xml
    - * Comment:
    Tests CharRef with an illegal character referred to. The "#x00/2f"      is used as the referred character in the CharRef in the EntityDecl in the      DTD.
    - * Sections:
    4.1
    - * Version: - * - * @throws java.io.IOException if there is an I/O error - */ - @Test - public 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 ) - ; - fail( "Tests CharRef with an illegal character referred to. The \"#x00/2f\" is used as the referred character in the CharRef in the EntityDecl in the DTD." ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "character reference (with hex value) may not contain /" ) ); - } - } + /** + * Test ID:
    ibm-not-wf-P66-ibm66n08.xml
    + * Test URI:
    not-wf/P66/ibm66n08.xml
    + * Comment:
    Tests CharRef with an illegal character referred to. The "#56.0" is      used as the referred character in the attribute value in the EmptyElemTag      of the element "root".
    + * Sections:
    4.1
    + * Version: + * + * @throws java.io.IOException if there is an I/O error + */ + @Test + public 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) + ; + fail( + "Tests CharRef with an illegal character referred to. The \"#56.0\" is used as the referred character in the attribute value in the EmptyElemTag of the element \"root\"."); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("character reference (with decimal value) may not contain .")); + } + } - /** - * Test ID:
    ibm-not-wf-P66-ibm66n10.xml
    - * Test URI:
    not-wf/P66/ibm66n10.xml
    - * Comment:
    Tests CharRef with an illegal character referred to. The "#51)" is      used as the referred character in the attribute value in the EmptyElemTag      of the element "root".
    - * Sections:
    4.1
    - * Version: - * - * @throws java.io.IOException if there is an I/O error - */ - @Test - public 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 ) - ; - fail( "Tests CharRef with an illegal character referred to. The \"#51)\" is used as the referred character in the attribute value in the EmptyElemTag of the element \"root\"." ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "character reference (with decimal value) may not contain )" ) ); - } - } + /** + * Test ID:
    ibm-not-wf-P66-ibm66n09.xml
    + * Test URI:
    not-wf/P66/ibm66n09.xml
    + * Comment:
    Tests CharRef with an illegal character referred to. The "#x00/2f"      is used as the referred character in the CharRef in the EntityDecl in the      DTD.
    + * Sections:
    4.1
    + * Version: + * + * @throws java.io.IOException if there is an I/O error + */ + @Test + public 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) + ; + fail( + "Tests CharRef with an illegal character referred to. The \"#x00/2f\" is used as the referred character in the CharRef in the EntityDecl in the DTD."); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("character reference (with hex value) may not contain /")); + } + } - /** - * Test ID:
    ibm-not-wf-P66-ibm66n11.xml
    - * Test URI:
    not-wf/P66/ibm66n11.xml
    - * Comment:
    Tests CharRef with an illegal character referred to. The "#00 2f"     is used as the referred character in the CharRef in the EntityDecl in the      DTD.
    - * Sections:
    4.1
    - * Version: - * - * @throws java.io.IOException if there is an I/O error - */ - @Test - public 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 ) - ; - fail( "Tests CharRef with an illegal character referred to. The \"#00 2f\" is used as the referred character in the CharRef in the EntityDecl in the DTD." ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "character reference (with hex value) may not contain " ) ); - } - } + /** + * Test ID:
    ibm-not-wf-P66-ibm66n10.xml
    + * Test URI:
    not-wf/P66/ibm66n10.xml
    + * Comment:
    Tests CharRef with an illegal character referred to. The "#51)" is      used as the referred character in the attribute value in the EmptyElemTag      of the element "root".
    + * Sections:
    4.1
    + * Version: + * + * @throws java.io.IOException if there is an I/O error + */ + @Test + public 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) + ; + fail( + "Tests CharRef with an illegal character referred to. The \"#51)\" is used as the referred character in the attribute value in the EmptyElemTag of the element \"root\"."); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("character reference (with decimal value) may not contain )")); + } + } - /** - * Test ID:
    ibm-not-wf-P66-ibm66n12.xml
    - * Test URI:
    not-wf/P66/ibm66n12.xml
    - * Comment:
    Tests CharRef with an illegal character referred to. The "#x0000"      is used as the referred character in the attribute value in the EmptyElemTag     of the element "root".
    - * Sections:
    4.1
    - * Version: - * - * @throws java.io.IOException if there is an I/O error - */ - @Test - public 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 ) - ; - fail( "Tests CharRef with an illegal character referred to. The \"#x0000\" is used as the referred character in the attribute value in the EmptyElemTag of the element \"root\"." ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "character reference (with hex value 0000) is invalid" ) ); - } - } + /** + * Test ID:
    ibm-not-wf-P66-ibm66n11.xml
    + * Test URI:
    not-wf/P66/ibm66n11.xml
    + * Comment:
    Tests CharRef with an illegal character referred to. The "#00 2f"     is used as the referred character in the CharRef in the EntityDecl in the      DTD.
    + * Sections:
    4.1
    + * Version: + * + * @throws java.io.IOException if there is an I/O error + */ + @Test + public 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) + ; + fail( + "Tests CharRef with an illegal character referred to. The \"#00 2f\" is used as the referred character in the CharRef in the EntityDecl in the DTD."); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("character reference (with hex value) may not contain ")); + } + } - /** - * Test ID:
    ibm-not-wf-P66-ibm66n13.xml
    - * Test URI:
    not-wf/P66/ibm66n13.xml
    - * Comment:
    Tests CharRef with an illegal character referred to. The "#x001f"      is used as the referred character in the attribute value in the EmptyElemTag     of the element "root".
    - * Sections:
    4.1
    - * Version: - * - * @throws java.io.IOException if there is an I/O error - */ - @Test - public 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 ) - ; - fail( "Tests CharRef with an illegal character referred to. The \"#x001f\" is used as the referred character in the attribute value in the EmptyElemTag of the element \"root\"." ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "character reference (with hex value 001f) is invalid" ) ); - } - } + /** + * Test ID:
    ibm-not-wf-P66-ibm66n12.xml
    + * Test URI:
    not-wf/P66/ibm66n12.xml
    + * Comment:
    Tests CharRef with an illegal character referred to. The "#x0000"      is used as the referred character in the attribute value in the EmptyElemTag     of the element "root".
    + * Sections:
    4.1
    + * Version: + * + * @throws java.io.IOException if there is an I/O error + */ + @Test + public 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) + ; + fail( + "Tests CharRef with an illegal character referred to. The \"#x0000\" is used as the referred character in the attribute value in the EmptyElemTag of the element \"root\"."); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("character reference (with hex value 0000) is invalid")); + } + } - /** - * Test ID:
    ibm-not-wf-P66-ibm66n14.xml
    - * Test URI:
    not-wf/P66/ibm66n14.xml
    - * Comment:
    Tests CharRef with an illegal character referred to. The "#xfffe"      is used as the referred character in the attribute value in the EmptyElemTag     of the element "root".
    - * Sections:
    4.1
    - * Version: - * - * @throws java.io.IOException if there is an I/O error - */ - @Test - public 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 ) - ; - fail( "Tests CharRef with an illegal character referred to. The \"#xfffe\" is used as the referred character in the attribute value in the EmptyElemTag of the element \"root\"." ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "character reference (with hex value fffe) is invalid" ) ); - } - } + /** + * Test ID:
    ibm-not-wf-P66-ibm66n13.xml
    + * Test URI:
    not-wf/P66/ibm66n13.xml
    + * Comment:
    Tests CharRef with an illegal character referred to. The "#x001f"      is used as the referred character in the attribute value in the EmptyElemTag     of the element "root".
    + * Sections:
    4.1
    + * Version: + * + * @throws java.io.IOException if there is an I/O error + */ + @Test + public 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) + ; + fail( + "Tests CharRef with an illegal character referred to. The \"#x001f\" is used as the referred character in the attribute value in the EmptyElemTag of the element \"root\"."); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("character reference (with hex value 001f) is invalid")); + } + } - /** - * Test ID:
    ibm-not-wf-P66-ibm66n15.xml
    - * Test URI:
    not-wf/P66/ibm66n15.xml
    - * Comment:
    Tests CharRef with an illegal character referred to. The "#xffff"      is used as the referred character in the attribute value in the EmptyElemTag     of the element "root".
    - * Sections:
    4.1
    - * Version: - * - * @throws java.io.IOException if there is an I/O error - */ - @Test - public 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 ) - ; - fail( "Tests CharRef with an illegal character referred to. The \"#xffff\" is used as the referred character in the attribute value in the EmptyElemTag of the element \"root\"." ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "character reference (with hex value ffff) is invalid" ) ); - } - } + /** + * Test ID:
    ibm-not-wf-P66-ibm66n14.xml
    + * Test URI:
    not-wf/P66/ibm66n14.xml
    + * Comment:
    Tests CharRef with an illegal character referred to. The "#xfffe"      is used as the referred character in the attribute value in the EmptyElemTag     of the element "root".
    + * Sections:
    4.1
    + * Version: + * + * @throws java.io.IOException if there is an I/O error + */ + @Test + public 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) + ; + fail( + "Tests CharRef with an illegal character referred to. The \"#xfffe\" is used as the referred character in the attribute value in the EmptyElemTag of the element \"root\"."); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("character reference (with hex value fffe) is invalid")); + } + } + /** + * Test ID:
    ibm-not-wf-P66-ibm66n15.xml
    + * Test URI:
    not-wf/P66/ibm66n15.xml
    + * Comment:
    Tests CharRef with an illegal character referred to. The "#xffff"      is used as the referred character in the attribute value in the EmptyElemTag     of the element "root".
    + * Sections:
    4.1
    + * Version: + * + * @throws java.io.IOException if there is an I/O error + */ + @Test + public 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) + ; + fail( + "Tests CharRef with an illegal character referred to. The \"#xffff\" is used as the referred character in the attribute value in the EmptyElemTag of the element \"root\"."); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("character reference (with hex value ffff) is invalid")); + } + } } 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 e5510bb5..9b109a67 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 @@ -1,8 +1,5 @@ package org.codehaus.plexus.util.xml.pull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - import java.io.File; import java.io.FileReader; import java.io.IOException; @@ -11,6 +8,9 @@ import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + /** * Test class that execute a particular set of tests associated to a TESCASES tag from the XML W3C Conformance Tests. * TESCASES PROFILE:
    IBM XML Conformance Test Suite - Production 80
    @@ -20,10 +20,10 @@ * @version $Id: $Id * @since 3.4.0 */ -public class IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production80_Test -{ +public +class IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production80_Test { - final static File testResourcesDir = new File( "src/test/resources/", "xmlconf/ibm/" ); + static final File testResourcesDir = new File("src/test/resources/", "xmlconf/ibm/"); MXParser parser; @@ -31,165 +31,140 @@ public class IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMX *

    setUp.

    */ @Before - public void setUp() - { + public void setUp() { parser = new MXParser(); } - /** - * Test ID:
    ibm-not-wf-P80-ibm80n01.xml
    - * Test URI:
    not-wf/P80/ibm80n01.xml
    - * Comment:
    Tests EncodingDecl with a required field missing. The leading white      space is missing in the EncodingDecl in the XMLDecl.
    - * Sections:
    4.3.3
    - * Version: - * - * @throws java.io.IOException if there is an I/O error - */ - @Test - public 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 ) - ; - fail( "Tests EncodingDecl with a required field missing. The leading white space is missing in the EncodingDecl in the XMLDecl." ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "expected a space after version and not e" ) ); - } - } - - /** - * Test ID:
    ibm-not-wf-P80-ibm80n02.xml
    - * Test URI:
    not-wf/P80/ibm80n02.xml
    - * Comment:
    Tests EncodingDecl with a required field missing. The "=" sign is      missing in the EncodingDecl in the XMLDecl.
    - * Sections:
    4.3.3
    - * Version: - * - * @throws java.io.IOException if there is an I/O error - */ - @Test - public 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 ) - ; - fail( "Tests EncodingDecl with a required field missing. The \"=\" sign is missing in the EncodingDecl in the XMLDecl." ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "expected equals sign (=) after encoding and not \"" ) ); - } - } + /** + * Test ID:
    ibm-not-wf-P80-ibm80n01.xml
    + * Test URI:
    not-wf/P80/ibm80n01.xml
    + * Comment:
    Tests EncodingDecl with a required field missing. The leading white      space is missing in the EncodingDecl in the XMLDecl.
    + * Sections:
    4.3.3
    + * Version: + * + * @throws java.io.IOException if there is an I/O error + */ + @Test + public 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) + ; + fail( + "Tests EncodingDecl with a required field missing. The leading white space is missing in the EncodingDecl in the XMLDecl."); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("expected a space after version and not e")); + } + } - /** - * Test ID:
    ibm-not-wf-P80-ibm80n03.xml
    - * Test URI:
    not-wf/P80/ibm80n03.xml
    - * Comment:
    Tests EncodingDecl with a required field missing. The double quoted      EncName are missing in the EncodingDecl in the XMLDecl.
    - * Sections:
    4.3.3
    - * Version: - * - * @throws java.io.IOException if there is an I/O error - */ - @Test - public 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 ) - ; - fail( "Tests EncodingDecl with a required field missing. The double quoted EncName are missing in the EncodingDecl in the XMLDecl." ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "expected apostrophe (') or quotation mark (\") after encoding and not ?" ) ); - } - } + /** + * Test ID:
    ibm-not-wf-P80-ibm80n02.xml
    + * Test URI:
    not-wf/P80/ibm80n02.xml
    + * Comment:
    Tests EncodingDecl with a required field missing. The "=" sign is      missing in the EncodingDecl in the XMLDecl.
    + * Sections:
    4.3.3
    + * Version: + * + * @throws java.io.IOException if there is an I/O error + */ + @Test + public 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) + ; + fail( + "Tests EncodingDecl with a required field missing. The \"=\" sign is missing in the EncodingDecl in the XMLDecl."); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("expected equals sign (=) after encoding and not \"")); + } + } - /** - * Test ID:
    ibm-not-wf-P80-ibm80n04.xml
    - * Test URI:
    not-wf/P80/ibm80n04.xml
    - * Comment:
    Tests EncodingDecl with wrong field ordering. The string "encoding="    occurs after the double quoted EncName in the EncodingDecl in the XMLDecl.
    - * Sections:
    4.3.3
    - * Version: - * - * @throws java.io.IOException if there is an I/O error - */ - @Test - public 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 ) - ; - fail( "Tests EncodingDecl with wrong field ordering. The string \"encoding=\" occurs after the double quoted EncName in the EncodingDecl in the XMLDecl." ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "unexpected character \"" ) ); - } - } + /** + * Test ID:
    ibm-not-wf-P80-ibm80n03.xml
    + * Test URI:
    not-wf/P80/ibm80n03.xml
    + * Comment:
    Tests EncodingDecl with a required field missing. The double quoted      EncName are missing in the EncodingDecl in the XMLDecl.
    + * Sections:
    4.3.3
    + * Version: + * + * @throws java.io.IOException if there is an I/O error + */ + @Test + public 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) + ; + fail( + "Tests EncodingDecl with a required field missing. The double quoted EncName are missing in the EncodingDecl in the XMLDecl."); + } catch (XmlPullParserException e) { + assertTrue( + e.getMessage().contains("expected apostrophe (') or quotation mark (\") after encoding and not ?")); + } + } - /** - * Test ID:
    ibm-not-wf-P80-ibm80n05.xml
    - * Test URI:
    not-wf/P80/ibm80n05.xml
    - * Comment:
    Tests EncodingDecl with wrong field ordering. The "encoding" occurs     after the double quoted EncName in the EncodingDecl in the XMLDecl.
    - * Sections:
    4.3.3
    - * Version: - * - * @throws java.io.IOException if there is an I/O error - */ - @Test - public 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 ) - ; - fail( "Tests EncodingDecl with wrong field ordering. The \"encoding\" occurs after the double quoted EncName in the EncodingDecl in the XMLDecl." ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "unexpected character \"" ) ); - } - } + /** + * Test ID:
    ibm-not-wf-P80-ibm80n04.xml
    + * Test URI:
    not-wf/P80/ibm80n04.xml
    + * Comment:
    Tests EncodingDecl with wrong field ordering. The string "encoding="    occurs after the double quoted EncName in the EncodingDecl in the XMLDecl.
    + * Sections:
    4.3.3
    + * Version: + * + * @throws java.io.IOException if there is an I/O error + */ + @Test + public 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) + ; + fail( + "Tests EncodingDecl with wrong field ordering. The string \"encoding=\" occurs after the double quoted EncName in the EncodingDecl in the XMLDecl."); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("unexpected character \"")); + } + } - /** - * Test ID:
    ibm-not-wf-P80-ibm80n06.xml
    - * Test URI:
    not-wf/P80/ibm80n06.xml
    - * Comment:
    Tests EncodingDecl with wrong key word. The string "Encoding" is      used as the key word in the EncodingDecl in the XMLDecl.
    - * Sections:
    4.3.3
    - * Version: - * - * @throws java.io.IOException if there is an I/O error - */ - @Test - public 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 ) - ; - fail( "Tests EncodingDecl with wrong key word. The string \"Encoding\" is used as the key word in the EncodingDecl in the XMLDecl." ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "unexpected character E" ) ); - } - } + /** + * Test ID:
    ibm-not-wf-P80-ibm80n05.xml
    + * Test URI:
    not-wf/P80/ibm80n05.xml
    + * Comment:
    Tests EncodingDecl with wrong field ordering. The "encoding" occurs     after the double quoted EncName in the EncodingDecl in the XMLDecl.
    + * Sections:
    4.3.3
    + * Version: + * + * @throws java.io.IOException if there is an I/O error + */ + @Test + public 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) + ; + fail( + "Tests EncodingDecl with wrong field ordering. The \"encoding\" occurs after the double quoted EncName in the EncodingDecl in the XMLDecl."); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("unexpected character \"")); + } + } + /** + * Test ID:
    ibm-not-wf-P80-ibm80n06.xml
    + * Test URI:
    not-wf/P80/ibm80n06.xml
    + * Comment:
    Tests EncodingDecl with wrong key word. The string "Encoding" is      used as the key word in the EncodingDecl in the XMLDecl.
    + * Sections:
    4.3.3
    + * Version: + * + * @throws java.io.IOException if there is an I/O error + */ + @Test + public 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) + ; + fail( + "Tests EncodingDecl with wrong key word. The string \"Encoding\" is used as the key word in the EncodingDecl in the XMLDecl."); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("unexpected character E")); + } + } } diff --git a/src/test/java/org/codehaus/plexus/util/xml/pull/MXParserPerfTest.java b/src/test/java/org/codehaus/plexus/util/xml/pull/MXParserPerfTest.java index c4d1a74f..ef6e30a2 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/pull/MXParserPerfTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/pull/MXParserPerfTest.java @@ -51,21 +51,19 @@ public class MXParserPerfTest { @State(Scope.Benchmark) - static public class AdditionState { + public static class AdditionState { byte[] data; @Setup(Level.Iteration) public void setUp() throws IOException, XmlPullParserException { - try (InputStream buf = getClass().getResourceAsStream( "/xml/pom.xml" ) ) - { - data = new byte[ buf.available() ]; - buf.read( data, 0, data.length ); + try (InputStream buf = getClass().getResourceAsStream("/xml/pom.xml")) { + data = new byte[buf.available()]; + buf.read(data, 0, data.length); } } } - /** *

    benchmarkBuild.

    * @@ -75,9 +73,8 @@ public void setUp() throws IOException, XmlPullParserException { * @throws org.codehaus.plexus.util.xml.pull.XmlPullParserException if any. */ @Benchmark - public Xpp3Dom benchmarkBuild( AdditionState state ) throws IOException, XmlPullParserException - { - return Xpp3DomBuilder.build( new ByteArrayInputStream( state.data ), null ); + public Xpp3Dom benchmarkBuild(AdditionState state) throws IOException, XmlPullParserException { + return Xpp3DomBuilder.build(new ByteArrayInputStream(state.data), null); } /** @@ -86,15 +83,13 @@ public Xpp3Dom benchmarkBuild( AdditionState state ) throws IOException, XmlPull * @param args a {@link java.lang.String} object. * @throws org.openjdk.jmh.runner.RunnerException if any. */ - public static void main( String... args ) - throws RunnerException - { + public static void main(String... args) throws RunnerException { Options opts = new OptionsBuilder() - .measurementIterations( 3 ) - .measurementTime( TimeValue.milliseconds( 3000 ) ) - .forks( 1 ) - .include( "org.codehaus.plexus.util.xml.pull.MXParserPerfTest" ) + .measurementIterations(3) + .measurementTime(TimeValue.milliseconds(3000)) + .forks(1) + .include("org.codehaus.plexus.util.xml.pull.MXParserPerfTest") .build(); - new Runner( opts ).run(); + new Runner(opts).run(); } } 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 d793c341..1833f73f 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 @@ -16,11 +16,6 @@ * limitations under the License. */ -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 java.io.EOFException; import java.io.File; import java.io.IOException; @@ -34,6 +29,11 @@ import org.codehaus.plexus.util.xml.ReaderFactory; import org.junit.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; + /** *

    MXParserTest class.

    * @@ -41,32 +41,29 @@ * @version $Id: $Id * @since 3.4.0 */ -public class MXParserTest -{ +public class MXParserTest { /** *

    testHexadecimalEntities.

    * * @throws java.lang.Exception if any. */ @Test - public void testHexadecimalEntities() - throws Exception - { + public void testHexadecimalEntities() throws Exception { MXParser parser = new MXParser(); - parser.defineEntityReplacementText( "test", "replacement" ); + parser.defineEntityReplacementText("test", "replacement"); String input = "A"; - parser.setInput( new StringReader( input ) ); + parser.setInput(new StringReader(input)); - assertEquals( XmlPullParser.START_TAG, parser.next() ); + assertEquals(XmlPullParser.START_TAG, parser.next()); - assertEquals( XmlPullParser.TEXT, parser.next() ); + assertEquals(XmlPullParser.TEXT, parser.next()); - assertEquals( "A", parser.getText() ); + assertEquals("A", parser.getText()); - assertEquals( XmlPullParser.END_TAG, parser.next() ); + assertEquals(XmlPullParser.END_TAG, parser.next()); } /** @@ -75,24 +72,22 @@ public void testHexadecimalEntities() * @throws java.lang.Exception if any. */ @Test - public void testDecimalEntities() - throws Exception - { + public void testDecimalEntities() throws Exception { MXParser parser = new MXParser(); - parser.defineEntityReplacementText( "test", "replacement" ); + parser.defineEntityReplacementText("test", "replacement"); String input = "A"; - parser.setInput( new StringReader( input ) ); + parser.setInput(new StringReader(input)); - assertEquals( XmlPullParser.START_TAG, parser.next() ); + assertEquals(XmlPullParser.START_TAG, parser.next()); - assertEquals( XmlPullParser.TEXT, parser.next() ); + assertEquals(XmlPullParser.TEXT, parser.next()); - assertEquals( "A", parser.getText() ); + assertEquals("A", parser.getText()); - assertEquals( XmlPullParser.END_TAG, parser.next() ); + assertEquals(XmlPullParser.END_TAG, parser.next()); } /** @@ -101,24 +96,22 @@ public void testDecimalEntities() * @throws java.lang.Exception if any. */ @Test - public void testPredefinedEntities() - throws Exception - { + public void testPredefinedEntities() throws Exception { MXParser parser = new MXParser(); - parser.defineEntityReplacementText( "test", "replacement" ); + parser.defineEntityReplacementText("test", "replacement"); String input = "<>&'""; - parser.setInput( new StringReader( input ) ); + parser.setInput(new StringReader(input)); - assertEquals( XmlPullParser.START_TAG, parser.next() ); + assertEquals(XmlPullParser.START_TAG, parser.next()); - assertEquals( XmlPullParser.TEXT, parser.next() ); + assertEquals(XmlPullParser.TEXT, parser.next()); - assertEquals( "<>&'\"", parser.getText() ); + assertEquals("<>&'\"", parser.getText()); - assertEquals( XmlPullParser.END_TAG, parser.next() ); + assertEquals(XmlPullParser.END_TAG, parser.next()); } /** @@ -128,19 +121,17 @@ public void testPredefinedEntities() * @throws java.io.IOException if any. */ @Test - public void testEntityReplacementMap() - throws XmlPullParserException, IOException - { - EntityReplacementMap erm = new EntityReplacementMap( new String[][] { { "abc", "CDE" }, { "EFG", "HIJ" } } ); - MXParser parser = new MXParser( erm ); + public void testEntityReplacementMap() throws XmlPullParserException, IOException { + EntityReplacementMap erm = new EntityReplacementMap(new String[][] {{"abc", "CDE"}, {"EFG", "HIJ"}}); + MXParser parser = new MXParser(erm); String input = "&EFG;"; - parser.setInput( new StringReader( input ) ); + parser.setInput(new StringReader(input)); - assertEquals( XmlPullParser.START_TAG, parser.next() ); - assertEquals( XmlPullParser.TEXT, parser.next() ); - assertEquals( "HIJ", parser.getText() ); - assertEquals( XmlPullParser.END_TAG, parser.next() ); + assertEquals(XmlPullParser.START_TAG, parser.next()); + assertEquals(XmlPullParser.TEXT, parser.next()); + assertEquals("HIJ", parser.getText()); + assertEquals(XmlPullParser.END_TAG, parser.next()); } /** @@ -149,28 +140,26 @@ public void testEntityReplacementMap() * @throws java.lang.Exception if any. */ @Test - public void testCustomEntities() - throws Exception - { + public void testCustomEntities() throws Exception { MXParser parser = new MXParser(); String input = "&myentity;"; - parser.setInput( new StringReader( input ) ); - parser.defineEntityReplacementText( "myentity", "replacement" ); - assertEquals( XmlPullParser.START_TAG, parser.next() ); - assertEquals( XmlPullParser.TEXT, parser.next() ); - assertEquals( "replacement", parser.getText() ); - assertEquals( XmlPullParser.END_TAG, parser.next() ); + parser.setInput(new StringReader(input)); + parser.defineEntityReplacementText("myentity", "replacement"); + assertEquals(XmlPullParser.START_TAG, parser.next()); + assertEquals(XmlPullParser.TEXT, parser.next()); + assertEquals("replacement", parser.getText()); + assertEquals(XmlPullParser.END_TAG, parser.next()); parser = new MXParser(); input = "&myCustom;"; - parser.setInput( new StringReader( input ) ); - parser.defineEntityReplacementText( "fo", "A" ); - parser.defineEntityReplacementText( "myCustom", "&fo;" ); - assertEquals( XmlPullParser.START_TAG, parser.next() ); - assertEquals( XmlPullParser.TEXT, parser.next() ); - assertEquals( "A", parser.getText() ); - assertEquals( XmlPullParser.END_TAG, parser.next() ); + parser.setInput(new StringReader(input)); + parser.defineEntityReplacementText("fo", "A"); + parser.defineEntityReplacementText("myCustom", "&fo;"); + assertEquals(XmlPullParser.START_TAG, parser.next()); + assertEquals(XmlPullParser.TEXT, parser.next()); + assertEquals("A", parser.getText()); + assertEquals(XmlPullParser.END_TAG, parser.next()); } /** @@ -179,26 +168,24 @@ public void testCustomEntities() * @throws java.lang.Exception if any. */ @Test - public void testUnicodeEntities() - throws Exception - { + public void testUnicodeEntities() throws Exception { MXParser parser = new MXParser(); String input = "𝟭"; - parser.setInput( new StringReader( input ) ); + parser.setInput(new StringReader(input)); - assertEquals( XmlPullParser.START_TAG, parser.nextToken() ); - assertEquals( XmlPullParser.ENTITY_REF, parser.nextToken() ); - assertEquals( "\uD835\uDFED", parser.getText() ); - assertEquals( XmlPullParser.END_TAG, parser.nextToken() ); + assertEquals(XmlPullParser.START_TAG, parser.nextToken()); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals("\uD835\uDFED", parser.getText()); + assertEquals(XmlPullParser.END_TAG, parser.nextToken()); parser = new MXParser(); input = "ř"; - parser.setInput( new StringReader( input ) ); + parser.setInput(new StringReader(input)); - assertEquals( XmlPullParser.START_TAG, parser.nextToken() ); - assertEquals( XmlPullParser.ENTITY_REF, parser.nextToken() ); - assertEquals( "\u0159", parser.getText() ); - assertEquals( XmlPullParser.END_TAG, parser.nextToken() ); + assertEquals(XmlPullParser.START_TAG, parser.nextToken()); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals("\u0159", parser.getText()); + assertEquals(XmlPullParser.END_TAG, parser.nextToken()); } /** @@ -207,22 +194,17 @@ public void testUnicodeEntities() * @throws java.lang.Exception if any. */ @Test - public void testInvalidCharacterReferenceHexa() - throws Exception - { + public void testInvalidCharacterReferenceHexa() throws Exception { MXParser parser = new MXParser(); String input = ""; - parser.setInput( new StringReader( input ) ); + parser.setInput(new StringReader(input)); - try - { - assertEquals( XmlPullParser.START_TAG, parser.nextToken() ); - assertEquals( XmlPullParser.ENTITY_REF, parser.nextToken() ); - fail( "Should fail since � is an illegal character reference" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "character reference (with hex value 110000) is invalid" ) ); + try { + assertEquals(XmlPullParser.START_TAG, parser.nextToken()); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + fail("Should fail since � is an illegal character reference"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("character reference (with hex value 110000) is invalid")); } } @@ -232,45 +214,41 @@ public void testInvalidCharacterReferenceHexa() * @throws java.lang.Exception if any. */ @Test - public void testValidCharacterReferenceHexa() - throws Exception - { + public void testValidCharacterReferenceHexa() throws Exception { MXParser parser = new MXParser(); - String input = " Ȁ퟿ᄁ�𐀀􏿽􏿿"; - parser.setInput( new StringReader( input ) ); - - try - { - assertEquals( XmlPullParser.START_TAG, parser.nextToken() ); - assertEquals( XmlPullParser.ENTITY_REF, parser.nextToken() ); - assertEquals( 0x9, parser.getText().codePointAt( 0 ) ); - assertEquals( XmlPullParser.ENTITY_REF, parser.nextToken() ); - assertEquals( 0xA, parser.getText().codePointAt( 0 ) ); - assertEquals( XmlPullParser.ENTITY_REF, parser.nextToken() ); - assertEquals( 0xD, parser.getText().codePointAt( 0 ) ); - assertEquals( XmlPullParser.ENTITY_REF, parser.nextToken() ); - assertEquals( 0x20, parser.getText().codePointAt( 0 ) ); - assertEquals( XmlPullParser.ENTITY_REF, parser.nextToken() ); - assertEquals( 0x200, parser.getText().codePointAt( 0 ) ); - assertEquals( XmlPullParser.ENTITY_REF, parser.nextToken() ); - assertEquals( 0xD7FF, parser.getText().codePointAt( 0 ) ); - assertEquals( XmlPullParser.ENTITY_REF, parser.nextToken() ); - assertEquals( 0xE000, parser.getText().codePointAt( 0 ) ); - assertEquals( XmlPullParser.ENTITY_REF, parser.nextToken() ); - assertEquals( 0xFFA2, parser.getText().codePointAt( 0 ) ); - assertEquals( XmlPullParser.ENTITY_REF, parser.nextToken() ); - assertEquals( 0xFFFD, parser.getText().codePointAt( 0 ) ); - assertEquals( XmlPullParser.ENTITY_REF, parser.nextToken() ); - assertEquals( 0x10000, parser.getText().codePointAt( 0 ) ); - assertEquals( XmlPullParser.ENTITY_REF, parser.nextToken() ); - assertEquals( 0x10FFFD, parser.getText().codePointAt( 0 ) ); - assertEquals( XmlPullParser.ENTITY_REF, parser.nextToken() ); - assertEquals( 0x10FFFF, parser.getText().codePointAt( 0 ) ); - assertEquals( XmlPullParser.END_TAG, parser.nextToken() ); - } - catch ( XmlPullParserException e ) - { - fail( "Should success since the input represents all legal character references" ); + String input = + " Ȁ퟿ᄁ�𐀀􏿽􏿿"; + parser.setInput(new StringReader(input)); + + try { + assertEquals(XmlPullParser.START_TAG, parser.nextToken()); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(0x9, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(0xA, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(0xD, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(0x20, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(0x200, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(0xD7FF, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(0xE000, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(0xFFA2, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(0xFFFD, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(0x10000, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(0x10FFFD, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(0x10FFFF, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.END_TAG, parser.nextToken()); + } catch (XmlPullParserException e) { + fail("Should success since the input represents all legal character references"); } } @@ -280,22 +258,17 @@ public void testValidCharacterReferenceHexa() * @throws java.lang.Exception if any. */ @Test - public void testInvalidCharacterReferenceDecimal() - throws Exception - { + public void testInvalidCharacterReferenceDecimal() throws Exception { MXParser parser = new MXParser(); String input = ""; - parser.setInput( new StringReader( input ) ); + parser.setInput(new StringReader(input)); - try - { - assertEquals( XmlPullParser.START_TAG, parser.nextToken() ); - assertEquals( XmlPullParser.ENTITY_REF, parser.nextToken() ); - fail( "Should fail since � is an illegal character reference" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "character reference (with decimal value 1114112) is invalid" ) ); + try { + assertEquals(XmlPullParser.START_TAG, parser.nextToken()); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + fail("Should fail since � is an illegal character reference"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("character reference (with decimal value 1114112) is invalid")); } } @@ -305,46 +278,41 @@ public void testInvalidCharacterReferenceDecimal() * @throws java.lang.Exception if any. */ @Test - public void testValidCharacterReferenceDecimal() - throws Exception - { + public void testValidCharacterReferenceDecimal() throws Exception { MXParser parser = new MXParser(); String input = - " Ȁ퟿ᄁ�𐀀􏿽􏿿"; - parser.setInput( new StringReader( input ) ); - - try - { - assertEquals( XmlPullParser.START_TAG, parser.nextToken() ); - assertEquals( XmlPullParser.ENTITY_REF, parser.nextToken() ); - assertEquals( 9, parser.getText().codePointAt( 0 ) ); - assertEquals( XmlPullParser.ENTITY_REF, parser.nextToken() ); - assertEquals( 10, parser.getText().codePointAt( 0 ) ); - assertEquals( XmlPullParser.ENTITY_REF, parser.nextToken() ); - assertEquals( 13, parser.getText().codePointAt( 0 ) ); - assertEquals( XmlPullParser.ENTITY_REF, parser.nextToken() ); - assertEquals( 32, parser.getText().codePointAt( 0 ) ); - assertEquals( XmlPullParser.ENTITY_REF, parser.nextToken() ); - assertEquals( 512, parser.getText().codePointAt( 0 ) ); - assertEquals( XmlPullParser.ENTITY_REF, parser.nextToken() ); - assertEquals( 55295, parser.getText().codePointAt( 0 ) ); - assertEquals( XmlPullParser.ENTITY_REF, parser.nextToken() ); - assertEquals( 57344, parser.getText().codePointAt( 0 ) ); - assertEquals( XmlPullParser.ENTITY_REF, parser.nextToken() ); - assertEquals( 65442, parser.getText().codePointAt( 0 ) ); - assertEquals( XmlPullParser.ENTITY_REF, parser.nextToken() ); - assertEquals( 65533, parser.getText().codePointAt( 0 ) ); - assertEquals( XmlPullParser.ENTITY_REF, parser.nextToken() ); - assertEquals( 65536, parser.getText().codePointAt( 0 ) ); - assertEquals( XmlPullParser.ENTITY_REF, parser.nextToken() ); - assertEquals( 1114109, parser.getText().codePointAt( 0 ) ); - assertEquals( XmlPullParser.ENTITY_REF, parser.nextToken() ); - assertEquals( 1114111, parser.getText().codePointAt( 0 ) ); - assertEquals( XmlPullParser.END_TAG, parser.nextToken() ); - } - catch ( XmlPullParserException e ) - { - fail( "Should success since the input represents all legal character references" ); + " Ȁ퟿ᄁ�𐀀􏿽􏿿"; + parser.setInput(new StringReader(input)); + + try { + assertEquals(XmlPullParser.START_TAG, parser.nextToken()); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(9, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(10, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(13, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(32, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(512, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(55295, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(57344, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(65442, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(65533, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(65536, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(1114109, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(1114111, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.END_TAG, parser.nextToken()); + } catch (XmlPullParserException e) { + fail("Should success since the input represents all legal character references"); } } @@ -354,47 +322,44 @@ public void testValidCharacterReferenceDecimal() * @throws java.lang.Exception if any. */ @Test - public void testParserPosition() - throws Exception - { - String input = " \n \tnnn\n"; + public void testParserPosition() throws Exception { + String input = + " \n \tnnn\n"; MXParser parser = new MXParser(); - parser.setInput( new StringReader( input ) ); - - assertEquals( XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken() ); - assertPosition( 1, 39, parser ); - assertEquals( XmlPullParser.COMMENT, parser.nextToken() ); - assertPosition( 1, 49, parser ); - assertEquals( XmlPullParser.IGNORABLE_WHITESPACE, parser.nextToken() ); - assertPosition( 2, 3, parser ); // end when next token starts - assertEquals( XmlPullParser.COMMENT, parser.nextToken() ); - assertPosition( 2, 12, parser ); - assertEquals( XmlPullParser.START_TAG, parser.nextToken() ); - assertPosition( 2, 18, parser ); - assertEquals( XmlPullParser.TEXT, parser.nextToken() ); - assertPosition( 2, 23, parser ); // end when next token starts - assertEquals( XmlPullParser.END_TAG, parser.nextToken() ); - assertPosition( 2, 29, parser ); - assertEquals( XmlPullParser.IGNORABLE_WHITESPACE, parser.nextToken() ); - assertPosition( 3, 2, parser ); // end when next token starts - assertEquals( XmlPullParser.COMMENT, parser.nextToken() ); - assertPosition( 4, 6, parser ); + parser.setInput(new StringReader(input)); + + assertEquals(XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken()); + assertPosition(1, 39, parser); + assertEquals(XmlPullParser.COMMENT, parser.nextToken()); + assertPosition(1, 49, parser); + assertEquals(XmlPullParser.IGNORABLE_WHITESPACE, parser.nextToken()); + assertPosition(2, 3, parser); // end when next token starts + assertEquals(XmlPullParser.COMMENT, parser.nextToken()); + assertPosition(2, 12, parser); + assertEquals(XmlPullParser.START_TAG, parser.nextToken()); + assertPosition(2, 18, parser); + assertEquals(XmlPullParser.TEXT, parser.nextToken()); + assertPosition(2, 23, parser); // end when next token starts + assertEquals(XmlPullParser.END_TAG, parser.nextToken()); + assertPosition(2, 29, parser); + assertEquals(XmlPullParser.IGNORABLE_WHITESPACE, parser.nextToken()); + assertPosition(3, 2, parser); // end when next token starts + assertEquals(XmlPullParser.COMMENT, parser.nextToken()); + assertPosition(4, 6, parser); } @Test - public void testProcessingInstruction() - throws Exception - { + public void testProcessingInstruction() throws Exception { String input = "nnn"; MXParser parser = new MXParser(); - parser.setInput( new StringReader( input ) ); + parser.setInput(new StringReader(input)); - assertEquals( XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken() ); - assertEquals( XmlPullParser.START_TAG, parser.nextToken() ); - assertEquals( XmlPullParser.TEXT, parser.nextToken() ); - assertEquals( XmlPullParser.END_TAG, parser.nextToken() ); + assertEquals(XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken()); + assertEquals(XmlPullParser.START_TAG, parser.nextToken()); + assertEquals(XmlPullParser.TEXT, parser.nextToken()); + assertEquals(XmlPullParser.END_TAG, parser.nextToken()); } /** @@ -403,28 +368,26 @@ public void testProcessingInstruction() * @throws java.lang.Exception if any. */ @Test - public void testProcessingInstructionsContainingXml() - throws Exception - { + public void testProcessingInstructionsContainingXml() throws Exception { StringBuffer sb = new StringBuffer(); - sb.append( "" ); - sb.append( "\n" ); - sb.append( " \n" ); - sb.append( " \n" ); - sb.append( " ?>\n" ); - sb.append( "" ); + sb.append(""); + sb.append("\n"); + sb.append(" \n"); + sb.append(" \n"); + sb.append(" ?>\n"); + sb.append(""); MXParser parser = new MXParser(); - parser.setInput( new StringReader( sb.toString() ) ); - - assertEquals( XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken() ); - assertEquals( XmlPullParser.START_TAG, parser.nextToken() ); - assertEquals( XmlPullParser.TEXT, parser.nextToken() ); // whitespace - assertEquals( XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken() ); - assertEquals( XmlPullParser.TEXT, parser.nextToken() ); // whitespace - assertEquals( XmlPullParser.END_TAG, parser.nextToken() ); + parser.setInput(new StringReader(sb.toString())); + + assertEquals(XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken()); + assertEquals(XmlPullParser.START_TAG, parser.nextToken()); + assertEquals(XmlPullParser.TEXT, parser.nextToken()); // whitespace + assertEquals(XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken()); + assertEquals(XmlPullParser.TEXT, parser.nextToken()); // whitespace + assertEquals(XmlPullParser.END_TAG, parser.nextToken()); } /** @@ -433,56 +396,50 @@ public void testProcessingInstructionsContainingXml() * @throws java.lang.Exception if any. */ @Test - public void testMalformedProcessingInstructionsContainingXmlNoClosingQuestionMark() - throws Exception - { + public void testMalformedProcessingInstructionsContainingXmlNoClosingQuestionMark() throws Exception { StringBuffer sb = new StringBuffer(); - sb.append( "\n" ); - sb.append( "\n" ); - sb.append( "\n" ); - sb.append( " >\n" ); + sb.append("\n"); + sb.append("\n"); + sb.append("\n"); + sb.append(" >\n"); MXParser parser = new MXParser(); - parser.setInput( new StringReader( sb.toString() ) ); - - try - { - assertEquals( XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken() ); - assertEquals( XmlPullParser.IGNORABLE_WHITESPACE, parser.nextToken() ); - assertEquals( XmlPullParser.START_TAG, parser.nextToken() ); - assertEquals( XmlPullParser.END_TAG, parser.nextToken() ); - assertEquals( XmlPullParser.IGNORABLE_WHITESPACE, parser.nextToken() ); - assertEquals( XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken() ); - - fail( "Should fail since it has invalid PI" ); - } - catch ( XmlPullParserException ex ) - { - assertTrue( ex.getMessage().contains( "processing instruction started on line 3 and column 1 was not closed" ) ); + parser.setInput(new StringReader(sb.toString())); + + try { + assertEquals(XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken()); + assertEquals(XmlPullParser.IGNORABLE_WHITESPACE, parser.nextToken()); + assertEquals(XmlPullParser.START_TAG, parser.nextToken()); + assertEquals(XmlPullParser.END_TAG, parser.nextToken()); + assertEquals(XmlPullParser.IGNORABLE_WHITESPACE, parser.nextToken()); + assertEquals(XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken()); + + fail("Should fail since it has invalid PI"); + } catch (XmlPullParserException ex) { + assertTrue( + ex.getMessage().contains("processing instruction started on line 3 and column 1 was not closed")); } } @Test - public void testSubsequentProcessingInstructionShort() - throws Exception - { + public void testSubsequentProcessingInstructionShort() throws Exception { StringBuffer sb = new StringBuffer(); - sb.append( "" ); - sb.append( "" ); - sb.append( "" ); - sb.append( "" ); - sb.append( "" ); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); MXParser parser = new MXParser(); - parser.setInput( new StringReader( sb.toString() ) ); + parser.setInput(new StringReader(sb.toString())); - assertEquals( XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken() ); - assertEquals( XmlPullParser.START_TAG, parser.nextToken() ); - assertEquals( XmlPullParser.COMMENT, parser.nextToken() ); - assertEquals( XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken() ); - assertEquals( XmlPullParser.END_TAG, parser.nextToken() ); + assertEquals(XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken()); + assertEquals(XmlPullParser.START_TAG, parser.nextToken()); + assertEquals(XmlPullParser.COMMENT, parser.nextToken()); + assertEquals(XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken()); + assertEquals(XmlPullParser.END_TAG, parser.nextToken()); } /** @@ -491,46 +448,42 @@ public void testSubsequentProcessingInstructionShort() * @throws java.lang.Exception if any. */ @Test - public void testSubsequentProcessingInstructionMoreThan8k() - throws Exception - { + public void testSubsequentProcessingInstructionMoreThan8k() throws Exception { StringBuffer sb = new StringBuffer(); - sb.append( "" ); - sb.append( "" ); + sb.append(""); + sb.append(""); // add ten times 1000 chars as comment - for ( int j = 0; j < 10; j++ ) - { + for (int j = 0; j < 10; j++) { - sb.append( "" ); + sb.append(" -->"); } - sb.append( "" ); - sb.append( "" ); + sb.append(""); + sb.append(""); MXParser parser = new MXParser(); - parser.setInput( new StringReader( sb.toString() ) ); - - assertEquals( XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken() ); - assertEquals( XmlPullParser.START_TAG, parser.nextToken() ); - assertEquals( XmlPullParser.COMMENT, parser.nextToken() ); - assertEquals( XmlPullParser.COMMENT, parser.nextToken() ); - assertEquals( XmlPullParser.COMMENT, parser.nextToken() ); - assertEquals( XmlPullParser.COMMENT, parser.nextToken() ); - assertEquals( XmlPullParser.COMMENT, parser.nextToken() ); - assertEquals( XmlPullParser.COMMENT, parser.nextToken() ); - assertEquals( XmlPullParser.COMMENT, parser.nextToken() ); - assertEquals( XmlPullParser.COMMENT, parser.nextToken() ); - assertEquals( XmlPullParser.COMMENT, parser.nextToken() ); - assertEquals( XmlPullParser.COMMENT, parser.nextToken() ); - assertEquals( XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken() ); - assertEquals( XmlPullParser.END_TAG, parser.nextToken() ); + parser.setInput(new StringReader(sb.toString())); + + assertEquals(XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken()); + assertEquals(XmlPullParser.START_TAG, parser.nextToken()); + assertEquals(XmlPullParser.COMMENT, parser.nextToken()); + assertEquals(XmlPullParser.COMMENT, parser.nextToken()); + assertEquals(XmlPullParser.COMMENT, parser.nextToken()); + assertEquals(XmlPullParser.COMMENT, parser.nextToken()); + assertEquals(XmlPullParser.COMMENT, parser.nextToken()); + assertEquals(XmlPullParser.COMMENT, parser.nextToken()); + assertEquals(XmlPullParser.COMMENT, parser.nextToken()); + assertEquals(XmlPullParser.COMMENT, parser.nextToken()); + assertEquals(XmlPullParser.COMMENT, parser.nextToken()); + assertEquals(XmlPullParser.COMMENT, parser.nextToken()); + assertEquals(XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken()); + assertEquals(XmlPullParser.END_TAG, parser.nextToken()); } /** @@ -539,25 +492,23 @@ public void testSubsequentProcessingInstructionMoreThan8k() * @throws java.lang.Exception if any. */ @Test - public void testLargeText_NoOverflow() - throws Exception - { + public void testLargeText_NoOverflow() throws Exception { StringBuffer sb = new StringBuffer(); - sb.append( "" ); - sb.append( "" ); + sb.append(""); + sb.append(""); // Anything above 33,554,431 would fail without a fix for // https://web.archive.org/web/20070831191548/http://www.extreme.indiana.edu/bugzilla/show_bug.cgi?id=228 // with java.io.IOException: error reading input, returned 0 - sb.append( new String( new char[33554432] ) ); - sb.append( "" ); + sb.append(new String(new char[33554432])); + sb.append(""); MXParser parser = new MXParser(); - parser.setInput( new StringReader( sb.toString() ) ); + parser.setInput(new StringReader(sb.toString())); - assertEquals( XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken() ); - assertEquals( XmlPullParser.START_TAG, parser.nextToken() ); - assertEquals( XmlPullParser.TEXT, parser.nextToken() ); - assertEquals( XmlPullParser.END_TAG, parser.nextToken() ); + assertEquals(XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken()); + assertEquals(XmlPullParser.START_TAG, parser.nextToken()); + assertEquals(XmlPullParser.TEXT, parser.nextToken()); + assertEquals(XmlPullParser.END_TAG, parser.nextToken()); } /** @@ -566,28 +517,23 @@ public void testLargeText_NoOverflow() * @throws java.lang.Exception if any. */ @Test - public void testMalformedProcessingInstructionAfterTag() - throws Exception - { + public void testMalformedProcessingInstructionAfterTag() throws Exception { MXParser parser = new MXParser(); String input = ""; - parser.setInput( new StringReader( input ) ); + parser.setInput(new StringReader(input)); - try - { - assertEquals( XmlPullParser.START_TAG, parser.next() ); + try { + assertEquals(XmlPullParser.START_TAG, parser.next()); - assertEquals( XmlPullParser.END_TAG, parser.next() ); + assertEquals(XmlPullParser.END_TAG, parser.next()); - assertEquals( XmlPullParser.PROCESSING_INSTRUCTION, parser.next() ); + assertEquals(XmlPullParser.PROCESSING_INSTRUCTION, parser.next()); - fail( "Should fail since it has an invalid Processing Instruction" ); - } - catch ( XmlPullParserException ex ) - { - assertTrue( ex.getMessage().contains( "processing instruction PITarget name not found" ) ); + fail("Should fail since it has an invalid Processing Instruction"); + } catch (XmlPullParserException ex) { + assertTrue(ex.getMessage().contains("processing instruction PITarget name not found")); } } @@ -597,28 +543,23 @@ public void testMalformedProcessingInstructionAfterTag() * @throws java.lang.Exception if any. */ @Test - public void testMalformedProcessingInstructionBeforeTag() - throws Exception - { + public void testMalformedProcessingInstructionBeforeTag() throws Exception { MXParser parser = new MXParser(); String input = ""; - parser.setInput( new StringReader( input ) ); + parser.setInput(new StringReader(input)); - try - { - assertEquals( XmlPullParser.PROCESSING_INSTRUCTION, parser.next() ); + try { + assertEquals(XmlPullParser.PROCESSING_INSTRUCTION, parser.next()); - assertEquals( XmlPullParser.START_TAG, parser.next() ); + assertEquals(XmlPullParser.START_TAG, parser.next()); - assertEquals( XmlPullParser.END_TAG, parser.next() ); + assertEquals(XmlPullParser.END_TAG, parser.next()); - fail( "Should fail since it has invalid PI" ); - } - catch ( XmlPullParserException ex ) - { - assertTrue( ex.getMessage().contains( "processing instruction PITarget name not found" ) ); + fail("Should fail since it has invalid PI"); + } catch (XmlPullParserException ex) { + assertTrue(ex.getMessage().contains("processing instruction PITarget name not found")); } } @@ -628,30 +569,27 @@ public void testMalformedProcessingInstructionBeforeTag() * @throws java.lang.Exception if any. */ @Test - public void testMalformedProcessingInstructionSpaceBeforeName() - throws Exception - { + public void testMalformedProcessingInstructionSpaceBeforeName() throws Exception { MXParser parser = new MXParser(); StringBuilder sb = new StringBuilder(); - sb.append( "" ); - sb.append( "" ); + sb.append(""); + sb.append(""); - parser.setInput( new StringReader( sb.toString() ) ); + parser.setInput(new StringReader(sb.toString())); - try - { - assertEquals( XmlPullParser.PROCESSING_INSTRUCTION, parser.next() ); + try { + assertEquals(XmlPullParser.PROCESSING_INSTRUCTION, parser.next()); - assertEquals( XmlPullParser.START_TAG, parser.next() ); + assertEquals(XmlPullParser.START_TAG, parser.next()); - assertEquals( XmlPullParser.END_TAG, parser.next() ); + assertEquals(XmlPullParser.END_TAG, parser.next()); - fail( "Should fail since it has invalid PI" ); - } - catch ( XmlPullParserException ex ) - { - assertTrue( ex.getMessage().contains( "processing instruction PITarget must be exactly after " ); - sb.append( "" ); + sb.append(""); + sb.append(""); - parser.setInput( new StringReader( sb.toString() ) ); + parser.setInput(new StringReader(sb.toString())); - try - { - assertEquals( XmlPullParser.PROCESSING_INSTRUCTION, parser.next() ); + try { + assertEquals(XmlPullParser.PROCESSING_INSTRUCTION, parser.next()); - assertEquals( XmlPullParser.START_TAG, parser.next() ); + assertEquals(XmlPullParser.START_TAG, parser.next()); - assertEquals( XmlPullParser.END_TAG, parser.next() ); + assertEquals(XmlPullParser.END_TAG, parser.next()); - fail( "Should fail since it has invalid PI" ); - } - catch ( XmlPullParserException ex ) - { - assertTrue( ex.getMessage().contains( "processing instruction started on line 1 and column 1 was not closed" ) ); + fail("Should fail since it has invalid PI"); + } catch (XmlPullParserException ex) { + assertTrue( + ex.getMessage().contains("processing instruction started on line 1 and column 1 was not closed")); } } @@ -694,30 +628,26 @@ public void testMalformedProcessingInstructionNoClosingQuestionMark() * @throws java.lang.Exception if any. */ @Test - public void testSubsequentMalformedProcessingInstructionNoClosingQuestionMark() - throws Exception - { + public void testSubsequentMalformedProcessingInstructionNoClosingQuestionMark() throws Exception { MXParser parser = new MXParser(); StringBuilder sb = new StringBuilder(); - sb.append( "" ); - sb.append( "" ); + sb.append(""); + sb.append(""); - parser.setInput( new StringReader( sb.toString() ) ); + parser.setInput(new StringReader(sb.toString())); - try - { - assertEquals( XmlPullParser.START_TAG, parser.next() ); + try { + assertEquals(XmlPullParser.START_TAG, parser.next()); - assertEquals( XmlPullParser.END_TAG, parser.next() ); + assertEquals(XmlPullParser.END_TAG, parser.next()); - assertEquals( XmlPullParser.PROCESSING_INSTRUCTION, parser.next() ); + assertEquals(XmlPullParser.PROCESSING_INSTRUCTION, parser.next()); - fail( "Should fail since it has invalid PI" ); - } - catch ( XmlPullParserException ex ) - { - assertTrue( ex.getMessage().contains( "processing instruction started on line 1 and column 12 was not closed" ) ); + fail("Should fail since it has invalid PI"); + } catch (XmlPullParserException ex) { + assertTrue( + ex.getMessage().contains("processing instruction started on line 1 and column 12 was not closed")); } } @@ -727,75 +657,61 @@ public void testSubsequentMalformedProcessingInstructionNoClosingQuestionMark() * @throws java.lang.Exception if any. */ @Test - public void testSubsequentAbortedProcessingInstruction() - throws Exception - { + public void testSubsequentAbortedProcessingInstruction() throws Exception { MXParser parser = new MXParser(); StringBuilder sb = new StringBuilder(); - sb.append( "" ); - sb.append( ""); + sb.append("" ); - sb.append( "\n" - + " \n" - + " \n" - + "\n" - + "\n" - + "]", parser.getText() ); - assertEquals( XmlPullParser.IGNORABLE_WHITESPACE, parser.nextToken() ); - assertEquals( XmlPullParser.START_TAG, parser.nextToken() ); - assertEquals( "document", parser.getName() ); - assertEquals( 1, parser.getAttributeCount() ); - assertEquals( "name", parser.getAttributeName( 0 ) ); - assertEquals( "section name with entities: '&' 'Α' '<' ' ' '>' '𝟭' ''' 'ř' '\"'", - parser.getAttributeValue( 0 ) ); - - assertEquals( XmlPullParser.ENTITY_REF, parser.nextToken() ); - assertEquals( "myCustomEntity", parser.getName() ); - assertEquals( "ř", parser.getText() ); - - assertEquals( XmlPullParser.END_TAG, parser.nextToken() ); - assertEquals( XmlPullParser.END_DOCUMENT, parser.nextToken() ); - } - catch ( XmlPullParserException e ) - { - fail( "should not raise exception: " + e ); + parser.setInput(reader); + parser.defineEntityReplacementText("nbsp", " "); + parser.defineEntityReplacementText("Alpha", "Α"); + parser.defineEntityReplacementText("tritPos", "𝟭"); + parser.defineEntityReplacementText("flo", "ř"); + parser.defineEntityReplacementText("myCustomEntity", "&flo;"); + assertEquals(XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken()); + assertEquals(XmlPullParser.IGNORABLE_WHITESPACE, parser.nextToken()); + assertEquals(XmlPullParser.DOCDECL, parser.nextToken()); + assertEquals( + " document [\n" + + " \n" + + " \n" + + " \n" + + "\n" + + "\n" + + "]", + parser.getText()); + assertEquals(XmlPullParser.IGNORABLE_WHITESPACE, parser.nextToken()); + assertEquals(XmlPullParser.START_TAG, parser.nextToken()); + assertEquals("document", parser.getName()); + assertEquals(1, parser.getAttributeCount()); + assertEquals("name", parser.getAttributeName(0)); + assertEquals( + "section name with entities: '&' 'Α' '<' ' ' '>' '𝟭' ''' 'ř' '\"'", + parser.getAttributeValue(0)); + + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals("myCustomEntity", parser.getName()); + assertEquals("ř", parser.getText()); + + assertEquals(XmlPullParser.END_TAG, parser.nextToken()); + assertEquals(XmlPullParser.END_DOCUMENT, parser.nextToken()); + } catch (XmlPullParserException e) { + fail("should not raise exception: " + e); } } @@ -1336,10 +1181,8 @@ private void testDocdeclTextWithEntitiesInAttributes( String filename ) * @since 3.4.2 */ @Test - public void testEntityRefTextUnix() - throws IOException - { - testEntityRefText( "\n" ); + public void testEntityRefTextUnix() throws IOException { + testEntityRefText("\n"); } /** @@ -1352,63 +1195,58 @@ public void testEntityRefTextUnix() * @since 3.4.2 */ @Test - public void testEntityRefTextDOS() - throws IOException - { - testEntityRefText( "\r\n" ); + public void testEntityRefTextDOS() throws IOException { + testEntityRefText("\r\n"); } - private void testEntityRefText( String newLine ) - throws IOException - { + private void testEntityRefText(String newLine) throws IOException { StringBuilder sb = new StringBuilder(); - sb.append( "" ).append( newLine ); - sb.append( "" ).append( newLine ); - sb.append( "" ).append( newLine ); - sb.append( "" ).append( newLine ); - sb.append( "]>" ).append( newLine ); - sb.append( "&foo;&foo1;&foo2;&tritPos;" ); - - try - { + sb.append("").append(newLine); + sb.append("").append(newLine); + sb.append("").append(newLine); + sb.append("").append(newLine); + sb.append("]>").append(newLine); + sb.append("&foo;&foo1;&foo2;&tritPos;"); + + try { MXParser parser = new MXParser(); - parser.setInput( new StringReader( sb.toString() ) ); - parser.defineEntityReplacementText( "foo", "ř" ); - parser.defineEntityReplacementText( "nbsp", " " ); - parser.defineEntityReplacementText( "foo1", " " ); - parser.defineEntityReplacementText( "foo2", "š" ); - parser.defineEntityReplacementText( "tritPos", "𝟭" ); - - assertEquals( XmlPullParser.DOCDECL, parser.nextToken() ); - assertEquals( " test [\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "]", parser.getText() ); - assertEquals( XmlPullParser.IGNORABLE_WHITESPACE, parser.nextToken() ); - assertEquals( XmlPullParser.START_TAG, parser.nextToken() ); - assertEquals( "b", 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( "foo1", parser.getName() ); - assertEquals( XmlPullParser.ENTITY_REF, parser.nextToken() ); - assertEquals( "š", parser.getText() ); - assertEquals( "foo2", parser.getName() ); - assertEquals( XmlPullParser.ENTITY_REF, parser.nextToken() ); - assertEquals( "𝟭", parser.getText() ); - assertEquals( "tritPos", parser.getName() ); - assertEquals( XmlPullParser.END_TAG, parser.nextToken() ); - assertEquals( "b", parser.getName() ); - assertEquals( XmlPullParser.END_DOCUMENT, parser.nextToken() ); - } - catch ( XmlPullParserException e ) - { - fail( "should not raise exception: " + e ); + parser.setInput(new StringReader(sb.toString())); + parser.defineEntityReplacementText("foo", "ř"); + parser.defineEntityReplacementText("nbsp", " "); + parser.defineEntityReplacementText("foo1", " "); + parser.defineEntityReplacementText("foo2", "š"); + parser.defineEntityReplacementText("tritPos", "𝟭"); + + assertEquals(XmlPullParser.DOCDECL, parser.nextToken()); + assertEquals( + " test [\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "]", + parser.getText()); + assertEquals(XmlPullParser.IGNORABLE_WHITESPACE, parser.nextToken()); + assertEquals(XmlPullParser.START_TAG, parser.nextToken()); + assertEquals("b", 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("foo1", parser.getName()); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals("š", parser.getText()); + assertEquals("foo2", parser.getName()); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals("𝟭", parser.getText()); + assertEquals("tritPos", parser.getName()); + assertEquals(XmlPullParser.END_TAG, parser.nextToken()); + assertEquals("b", parser.getName()); + assertEquals(XmlPullParser.END_DOCUMENT, parser.nextToken()); + } catch (XmlPullParserException e) { + fail("should not raise exception: " + e); } } @@ -1425,35 +1263,32 @@ private void testEntityRefText( String newLine ) public void testEntityReplacement() throws IOException { String input = "

      

    "; - try - { + try { MXParser parser = new MXParser(); - parser.setInput( new StringReader( input ) ); - parser.defineEntityReplacementText( "nbsp", " " ); - - assertEquals( XmlPullParser.START_TAG, parser.nextToken() ); - assertEquals( "p", parser.getName() ); - assertEquals( XmlPullParser.COMMENT, parser.nextToken() ); - assertEquals( " a pagebreak: ", parser.getText() ); - assertEquals( XmlPullParser.COMMENT, parser.nextToken() ); - assertEquals( " PB ", parser.getText() ); - assertEquals( XmlPullParser.ENTITY_REF, parser.nextToken() ); - assertEquals( "\u00A0", parser.getText() ); - assertEquals( "#160", parser.getName() ); - assertEquals( XmlPullParser.ENTITY_REF, parser.nextToken() ); - assertEquals( " ", parser.getText() ); - assertEquals( "nbsp", parser.getName() ); - assertEquals( XmlPullParser.START_TAG, parser.nextToken() ); - assertEquals( "unknown", parser.getName() ); - assertEquals( XmlPullParser.END_TAG, parser.nextToken() ); - assertEquals( "unknown", parser.getName() ); - assertEquals( XmlPullParser.END_TAG, parser.nextToken() ); - assertEquals( "p", parser.getName() ); - assertEquals( XmlPullParser.END_DOCUMENT, parser.nextToken() ); - } - catch ( XmlPullParserException e ) - { - fail( "should not raise exception: " + e ); + parser.setInput(new StringReader(input)); + parser.defineEntityReplacementText("nbsp", " "); + + assertEquals(XmlPullParser.START_TAG, parser.nextToken()); + assertEquals("p", parser.getName()); + assertEquals(XmlPullParser.COMMENT, parser.nextToken()); + assertEquals(" a pagebreak: ", parser.getText()); + assertEquals(XmlPullParser.COMMENT, parser.nextToken()); + assertEquals(" PB ", parser.getText()); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals("\u00A0", parser.getText()); + assertEquals("#160", parser.getName()); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(" ", parser.getText()); + assertEquals("nbsp", parser.getName()); + assertEquals(XmlPullParser.START_TAG, parser.nextToken()); + assertEquals("unknown", parser.getName()); + assertEquals(XmlPullParser.END_TAG, parser.nextToken()); + assertEquals("unknown", parser.getName()); + assertEquals(XmlPullParser.END_TAG, parser.nextToken()); + assertEquals("p", parser.getName()); + assertEquals(XmlPullParser.END_DOCUMENT, parser.nextToken()); + } catch (XmlPullParserException e) { + fail("should not raise exception: " + e); } } @@ -1468,47 +1303,42 @@ public void testEntityReplacement() throws IOException { * @since 3.4.2 */ @Test - public void testReplacementInPCArrayWithShorterCharArray() - throws IOException - { + public void testReplacementInPCArrayWithShorterCharArray() throws IOException { String input = "]>" - + "

    &&foo;&tritPos;

    "; + + "

    &&foo;&tritPos;

    "; - try - { + try { MXParser parser = new MXParser(); - parser.setInput( new StringReader( new String(input.getBytes(), "ISO-8859-1" ) ) ); - parser.defineEntityReplacementText( "foo", "ř" ); - parser.defineEntityReplacementText( "tritPos", "𝟭" ); - - assertEquals( XmlPullParser.DOCDECL, parser.nextToken() ); - assertEquals( " test []", parser.getText() ); - assertEquals( XmlPullParser.START_TAG, parser.nextToken() ); - assertEquals( "section", parser.getName() ); - assertEquals( 1, parser.getAttributeCount() ); - assertEquals( "name" , parser.getAttributeName( 0 ) ); - assertEquals( "&ř𝟭" , parser.getAttributeValue( 0 ) ); - assertEquals( XmlPullParser.START_TAG, parser.nextToken() ); - assertEquals( "

    ", parser.getText() ); - assertEquals( "p", parser.getName() ); - assertEquals( XmlPullParser.ENTITY_REF, parser.nextToken() ); - assertEquals( "&", parser.getText() ); - assertEquals( "amp", parser.getName() ); - assertEquals( XmlPullParser.ENTITY_REF, parser.nextToken() ); - assertEquals( "ř", parser.getText() ); - assertEquals( "foo", parser.getName() ); - assertEquals( XmlPullParser.ENTITY_REF, parser.nextToken() ); - assertEquals( "𝟭", parser.getText() ); - assertEquals( "tritPos", parser.getName() ); - assertEquals( XmlPullParser.END_TAG, parser.nextToken() ); - assertEquals( "p", parser.getName() ); - assertEquals( XmlPullParser.END_TAG, parser.nextToken() ); - assertEquals( "section", parser.getName() ); - assertEquals( XmlPullParser.END_DOCUMENT, parser.nextToken() ); - } - catch ( XmlPullParserException e ) - { - fail( "should not raise exception: " + e ); + parser.setInput(new StringReader(new String(input.getBytes(), "ISO-8859-1"))); + parser.defineEntityReplacementText("foo", "ř"); + parser.defineEntityReplacementText("tritPos", "𝟭"); + + assertEquals(XmlPullParser.DOCDECL, parser.nextToken()); + assertEquals(" test []", parser.getText()); + assertEquals(XmlPullParser.START_TAG, parser.nextToken()); + assertEquals("section", parser.getName()); + assertEquals(1, parser.getAttributeCount()); + assertEquals("name", parser.getAttributeName(0)); + assertEquals("&ř𝟭", parser.getAttributeValue(0)); + assertEquals(XmlPullParser.START_TAG, parser.nextToken()); + assertEquals("

    ", parser.getText()); + assertEquals("p", parser.getName()); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals("&", parser.getText()); + assertEquals("amp", parser.getName()); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals("ř", parser.getText()); + assertEquals("foo", parser.getName()); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals("𝟭", parser.getText()); + assertEquals("tritPos", parser.getName()); + assertEquals(XmlPullParser.END_TAG, parser.nextToken()); + assertEquals("p", parser.getName()); + assertEquals(XmlPullParser.END_TAG, parser.nextToken()); + assertEquals("section", parser.getName()); + assertEquals(XmlPullParser.END_DOCUMENT, parser.nextToken()); + } catch (XmlPullParserException e) { + fail("should not raise exception: " + e); } } @@ -1519,22 +1349,19 @@ public void testReplacementInPCArrayWithShorterCharArray() public void testUnicode() throws IOException { String input = ""; - try - { + try { MXParser parser = new MXParser(); - parser.setInput( new StringReader( input ) ); - - assertEquals( XmlPullParser.START_TAG, parser.nextToken() ); - assertEquals( "project", parser.getName() ); - assertEquals( XmlPullParser.COMMENT, parser.nextToken() ); - assertEquals( "ALL TEH BOMS! \uD83D\uDCA3 ", parser.getText() ); - assertEquals( XmlPullParser.END_TAG, parser.nextToken() ); - assertEquals( "project", parser.getName() ); - } - catch ( XmlPullParserException e ) - { + parser.setInput(new StringReader(input)); + + assertEquals(XmlPullParser.START_TAG, parser.nextToken()); + assertEquals("project", parser.getName()); + assertEquals(XmlPullParser.COMMENT, parser.nextToken()); + assertEquals("ALL TEH BOMS! \uD83D\uDCA3 ", parser.getText()); + assertEquals(XmlPullParser.END_TAG, parser.nextToken()); + assertEquals("project", parser.getName()); + } catch (XmlPullParserException e) { e.printStackTrace(); - fail( "should not raise exception: " + e ); + fail("should not raise exception: " + e); } } } 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 854fb494..2ae6de39 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 @@ -1,8 +1,5 @@ package org.codehaus.plexus.util.xml.pull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - import java.io.File; import java.io.FileInputStream; import java.io.FileReader; @@ -14,6 +11,9 @@ import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + /** * Test class that execute a particular set of tests associated to a TESCASES tag from the XML W3C Conformance Tests. * TESCASES PROFILE:

    Bjoern Hoehrmann via HST 2013-09-18
    @@ -23,10 +23,9 @@ * @version $Id: $Id * @since 3.4.0 */ -public class eduni_misc_Test_BjoernHoehrmannviaHST2013_09_18_Test -{ +public class eduni_misc_Test_BjoernHoehrmannviaHST2013_09_18_Test { - final static File testResourcesDir = new File("src/test/resources/", "xmlconf/eduni/misc/"); + static final File testResourcesDir = new File("src/test/resources/", "xmlconf/eduni/misc/"); MXParser parser; @@ -34,8 +33,7 @@ public class eduni_misc_Test_BjoernHoehrmannviaHST2013_09_18_Test *

    setUp.

    */ @Before - public void setUp() - { + public void setUp() { parser = new MXParser(); } @@ -49,19 +47,14 @@ public void setUp() * @throws java.io.IOException if there is an I/O error */ @Test - public 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 ) + public 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) ; - fail( "decimal charref > 10FFFF, indeed > max 32 bit integer, checking for recovery from possible overflow" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "character reference (with hex value FF000000F6) is invalid" ) ); + fail("decimal charref > 10FFFF, indeed > max 32 bit integer, checking for recovery from possible overflow"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("character reference (with hex value FF000000F6) is invalid")); } } @@ -75,19 +68,14 @@ public void testhst_bh_001() * @throws java.io.IOException if there is an I/O error */ @Test - public 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 ) + public 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) ; - fail( "hex charref > 10FFFF, indeed > max 32 bit integer, checking for recovery from possible overflow" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "character reference (with decimal value 4294967542) is invalid" ) ); + fail("hex charref > 10FFFF, indeed > max 32 bit integer, checking for recovery from possible overflow"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("character reference (with decimal value 4294967542) is invalid")); } } @@ -101,19 +89,14 @@ public void testhst_bh_002() * @throws java.io.IOException if there is an I/O error */ @Test - public 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 ) + public 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) ; - fail( "decimal charref > 10FFFF, indeed > max 64 bit integer, checking for recovery from possible overflow" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "character reference (with hex value FFFFFFFF000000F6) is invalid" ) ); + fail("decimal charref > 10FFFF, indeed > max 64 bit integer, checking for recovery from possible overflow"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("character reference (with hex value FFFFFFFF000000F6) is invalid")); } } @@ -127,19 +110,15 @@ public void testhst_bh_003() * @throws java.io.IOException if there is an I/O error */ @Test - public 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 ) + public 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) ; - fail( "hex charref > 10FFFF, indeed > max 64 bit integer, checking for recovery from possible overflow" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "character reference (with decimal value 18446744073709551862) is invalid" ) ); + fail("hex charref > 10FFFF, indeed > max 64 bit integer, checking for recovery from possible overflow"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage() + .contains("character reference (with decimal value 18446744073709551862) is invalid")); } } @@ -155,19 +134,14 @@ public void testhst_bh_004() * NOTE: This test is SKIPPED as MXParser do not supports DOCDECL parsing. */ // @Test - public void testhst_bh_005() - throws IOException - { - try ( Reader reader = new FileReader( new File( testResourcesDir, "005.xml" ) ) ) - { - parser.setInput( reader ); - while ( parser.nextToken() != XmlPullParser.END_DOCUMENT ) + public void testhst_bh_005() throws IOException { + try (Reader reader = new FileReader(new File(testResourcesDir, "005.xml"))) { + parser.setInput(reader); + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) ; - fail( "xmlns:xml is an attribute as far as validation is concerned and must be declared" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( true ); + fail("xmlns:xml is an attribute as far as validation is concerned and must be declared"); + } catch (XmlPullParserException e) { + assertTrue(true); } } @@ -183,19 +157,14 @@ public void testhst_bh_005() * NOTE: This test is SKIPPED as MXParser do not supports DOCDECL parsing. */ // @Test - public void testhst_bh_006() - throws IOException - { - try ( Reader reader = new FileReader( new File( testResourcesDir, "006.xml" ) ) ) - { - parser.setInput( reader ); - while ( parser.nextToken() != XmlPullParser.END_DOCUMENT ) + public void testhst_bh_006() throws IOException { + try (Reader reader = new FileReader(new File(testResourcesDir, "006.xml"))) { + parser.setInput(reader); + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) ; - fail( "xmlns:foo is an attribute as far as validation is concerned and must be declared" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( true ); + fail("xmlns:foo is an attribute as far as validation is concerned and must be declared"); + } catch (XmlPullParserException e) { + assertTrue(true); } } @@ -209,20 +178,15 @@ public void testhst_bh_006() * @throws java.io.IOException if there is an I/O error */ @Test - public void testhst_lhs_007() - throws IOException - { - try ( FileInputStream is = new FileInputStream( new File( testResourcesDir, "007.xml" ) ); - InputStreamReader reader = new InputStreamReader( is, StandardCharsets.UTF_8 ) ) - { - parser.setInput( reader ); - while ( parser.nextToken() != XmlPullParser.END_DOCUMENT ) + public void testhst_lhs_007() throws IOException { + try (FileInputStream is = new FileInputStream(new File(testResourcesDir, "007.xml")); + InputStreamReader reader = new InputStreamReader(is, StandardCharsets.UTF_8)) { + parser.setInput(reader); + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) ; - fail( "UTF-8 BOM plus xml decl of iso-8859-1 incompatible" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "UTF-8 BOM plus xml decl of iso-8859-1 is incompatible" ) ); + fail("UTF-8 BOM plus xml decl of iso-8859-1 incompatible"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("UTF-8 BOM plus xml decl of iso-8859-1 is incompatible")); } } @@ -236,20 +200,15 @@ public void testhst_lhs_007() * @throws java.io.IOException if there is an I/O error */ @Test - public void testhst_lhs_008() - throws IOException - { - try ( FileInputStream is = new FileInputStream( new File( testResourcesDir, "008.xml" ) ); - InputStreamReader reader = new InputStreamReader( is, StandardCharsets.UTF_16 ) ) - { - parser.setInput( reader ); - while ( parser.nextToken() != XmlPullParser.END_DOCUMENT ) + public void testhst_lhs_008() throws IOException { + try (FileInputStream is = new FileInputStream(new File(testResourcesDir, "008.xml")); + InputStreamReader reader = new InputStreamReader(is, StandardCharsets.UTF_16)) { + parser.setInput(reader); + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) ; - fail( "UTF-16 BOM plus xml decl of utf-8 (using UTF-16 coding) incompatible" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "UTF-16 BOM plus xml decl of utf-8 is incompatible" ) ); + fail("UTF-16 BOM plus xml decl of utf-8 (using UTF-16 coding) incompatible"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("UTF-16 BOM plus xml decl of utf-8 is incompatible")); } } @@ -263,21 +222,15 @@ public void testhst_lhs_008() * @throws java.io.IOException if there is an I/O error */ @Test - public void testhst_lhs_009() - throws IOException - { - try ( FileInputStream is = new FileInputStream( new File( testResourcesDir, "009.xml" ) ); - InputStreamReader reader = new InputStreamReader( is, StandardCharsets.UTF_8 ) ) - { - parser.setInput( reader ); - while ( parser.nextToken() != XmlPullParser.END_DOCUMENT ) + public void testhst_lhs_009() throws IOException { + try (FileInputStream is = new FileInputStream(new File(testResourcesDir, "009.xml")); + InputStreamReader reader = new InputStreamReader(is, StandardCharsets.UTF_8)) { + parser.setInput(reader); + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) ; - fail( "UTF-16 BOM plus xml decl of utf-8 (using UTF-8 coding) incompatible" ); - } - catch ( XmlPullParserException e ) - { - assertTrue( e.getMessage().contains( "UTF-16 BOM in a UTF-8 encoded file is incompatible" ) ); + fail("UTF-16 BOM plus xml decl of utf-8 (using UTF-8 coding) incompatible"); + } catch (XmlPullParserException e) { + assertTrue(e.getMessage().contains("UTF-16 BOM in a UTF-8 encoded file is incompatible")); } } - } From cbe17c95eca27bdbafcdacb0ad5f13be9dedeca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Sun, 28 May 2023 11:04:40 +0200 Subject: [PATCH 08/36] pom.mxl and site.xml cleanup --- pom.xml | 91 ++++------------------------------------------- src/site/site.xml | 5 +++ 2 files changed, 12 insertions(+), 84 deletions(-) diff --git a/pom.xml b/pom.xml index 48106965..ed19c4ca 100644 --- a/pom.xml +++ b/pom.xml @@ -28,16 +28,17 @@ limitations under the License. Plexus XML Utilities A collection of various utility classes to ease working with XML in Maven 3. + https://codehaus-plexus.github.io/plexus-xml/ - scm:git:git@github.com:codehaus-plexus/plexus-xml.git - scm:git:git@github.com:codehaus-plexus/plexus-xml.git + scm:git:https://github.com/codehaus-plexus/plexus-xml.git + scm:git:https://github.com/codehaus-plexus/plexus-xml.git 3.x - http://github.com/codehaus-plexus/plexus-xml + https://github.com/codehaus-plexus/plexus-xml/tree/${project.scm.tag}/ github - http://github.com/codehaus-plexus/plexus-xml/issues + https://github.com/codehaus-plexus/plexus-xml/issues @@ -47,7 +48,8 @@ limitations under the License. - 2023-03-02T01:23:19Z + 2023-05-22T15:08:30Z + 8 @@ -80,64 +82,14 @@ limitations under the License. - - org.apache.maven.plugins - maven-enforcer-plugin - 3.3.0 - - - org.apache.maven.plugins - maven-resources-plugin - 3.3.1 - org.apache.maven.plugins maven-surefire-plugin 3.0.0 - - org.apache.maven.plugins - maven-compiler-plugin - 3.11.0 - - - org.apache.maven.plugins - maven-enforcer-plugin - - - enforce-maven - - enforce - - - - - 3.2.5 - This project requires at least Maven 3.2.5 - - - - - - - - maven-compiler-plugin - - - default-compile - - compile - - - 1.8 - 1.8 - - - - org.apache.maven.plugins maven-scm-publish-plugin @@ -176,33 +128,4 @@ limitations under the License. - - - - jdk9+ - - [9,) - - - - - - maven-compiler-plugin - - - compile-java-9 - - compile - - - 8 - - - - - - - - -
    diff --git a/src/site/site.xml b/src/site/site.xml index 38cbad8a..3cb8f1a8 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -4,6 +4,11 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 http://maven.apache.org/xsd/decoration-1.0.0.xsd"> + + + + + From 24d18251fa90ba6c9646238ea9bf1f8753a6f1de Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Fri, 30 Jun 2023 23:57:00 +0200 Subject: [PATCH 09/36] Cleanup after parent pom upgrade --- pom.xml | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/pom.xml b/pom.xml index ed19c4ca..873c6b74 100644 --- a/pom.xml +++ b/pom.xml @@ -49,7 +49,6 @@ limitations under the License. 2023-05-22T15:08:30Z - 8 @@ -80,15 +79,6 @@ limitations under the License. - - - - org.apache.maven.plugins - maven-surefire-plugin - 3.0.0 - - - org.apache.maven.plugins @@ -114,16 +104,6 @@ limitations under the License. true - - - JAVA_HOME - ${JAVA_HOME} - - - M2_HOME - ${M2_HOME} - - From 800f113d985cbd8ef1a34671d519fa3b72657caf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Mon, 11 Sep 2023 19:39:49 +0200 Subject: [PATCH 10/36] fix maven-xml 3 description --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 379ac1e9..040ea01b 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,10 @@ Plexus-Xml ============ [![Build Status](https://github.com/codehaus-plexus/plexus-xml/actions/workflows/maven.yml/badge.svg)](https://github.com/codehaus-plexus/plexus-xml/actions) -[![Maven Central](https://img.shields.io/maven-central/v/org.codehaus.plexus/plexus-xml.svg?label=Maven%20Central)](https://search.maven.org/artifact/org.codehaus.plexus/plexus-xml) +[![Maven Central](https://img.shields.io/maven-central/v/org.codehaus.plexus/plexus-xml.svg?label=Maven%20Central&versionPrefix=3.)](https://search.maven.org/artifact/org.codehaus.plexus/plexus-xml) -This library consists of XML classes (`org.codehaus.plexus.util.xml`, and `ReaderFactory`/`WriterFactory` moved from `org.codehaus.plexus.util`) that have been extracted from [`plexus-utils`](https://github.com/codehaus-plexus/plexus-utils/) 4. +This library consists of XML classes (`org.codehaus.plexus.util.xml`) that have been extracted from [`plexus-utils`](https://github.com/codehaus-plexus/plexus-utils/) 3: +> `plexus-utils` 3 = `plexus-utils` 4 + `plexus-xml` 3. For publishing [the site](https://codehaus-plexus.github.io/plexus-xml/) do the following: From f4bf6161aa96b7652f8cc067091d1e175e72928e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Mon, 11 Sep 2023 19:52:17 +0200 Subject: [PATCH 11/36] fix javadoc --- .../java/org/codehaus/plexus/util/xml/Xpp3DomUtils.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/codehaus/plexus/util/xml/Xpp3DomUtils.java b/src/main/java/org/codehaus/plexus/util/xml/Xpp3DomUtils.java index 768f622a..f337bcd1 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/Xpp3DomUtils.java +++ b/src/main/java/org/codehaus/plexus/util/xml/Xpp3DomUtils.java @@ -235,7 +235,9 @@ public static Xpp3Dom mergeXpp3Dom(Xpp3Dom dominant, Xpp3Dom recessive) { } /** - * @deprecated Use {@link org.codehaus.plexus.util.StringUtils#isNotEmpty(String)} instead + * @param str a String + * @return true if not empty + * @deprecated Use org.codehaus.plexus.util.StringUtils#isNotEmpty(String) instead */ @Deprecated public static boolean isNotEmpty(String str) { @@ -243,7 +245,9 @@ public static boolean isNotEmpty(String str) { } /** - * @deprecated Use {@link org.codehaus.plexus.util.StringUtils#isEmpty(String)} instead + * @param str a String + * @return true if empty + * @deprecated Use org.codehaus.plexus.util.StringUtils#isEmpty(String) instead */ @Deprecated public static boolean isEmpty(String str) { From 636b0c33524edb97a1a9bf6a24a23c23e6ed3fc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Mon, 11 Sep 2023 19:52:41 +0200 Subject: [PATCH 12/36] [maven-release-plugin] prepare release plexus-xml-3.0.0 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 873c6b74..e9bbffc0 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ limitations under the License. plexus-xml - 3.0.0-SNAPSHOT + 3.0.0 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 - 3.x + plexus-xml-3.0.0 https://github.com/codehaus-plexus/plexus-xml/tree/${project.scm.tag}/ @@ -48,7 +48,7 @@ limitations under the License. - 2023-05-22T15:08:30Z + 2023-09-11T17:52:31Z 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 13/36] [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 e9bbffc0..a4920a16 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 14/36] 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 81f67f61..d9ab1e1f 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 15/36] 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 a4920a16..3bd6bd44 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 16/36] 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 c7f59480..16615808 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 4000f8c4..5170a1bc 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 17/36] 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 16615808..00000000 --- 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 5170a1bc..7e523c19 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 18/36] 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 3bd6bd44..074063c5 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 b03e8313..e219e5c1 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 93f4eacf..4ffe7a9c 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 26e131cd..c2803b59 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 bdfd76ca..302bc28a 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 8b0e3972..fb515787 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 f9faac45..c8db71b5 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 c4f21029..dd9aea87 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 ea21509a..66323675 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 55853d0b..7f7f3219 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 becde36c..bb1a7e8f 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 71a342a2..49227a44 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 91effa9d..f99e1ead 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 3266b725..debe5971 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 9b109a67..9581bedc 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 1833f73f..2d3ecefa 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 2ae6de39..65286c5c 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 19/36] 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 332bdaf0..f602668b 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 e69d28f8..ffd0edee 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 7f7f3219..233bdd5b 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 00000000..8b66c23a --- /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 20/36] 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 d9ab1e1f..dc57b748 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 21/36] 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 7e523c19..21edf4cd 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 22/36] 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 074063c5..882eb979 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 23/36] 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 ffd0edee..54e48dc0 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 8b66c23a..0b1d3d7f 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 24/36] [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 882eb979..730973a9 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 From ca4fe6275cdad27f1c217481215441d32c52c9b2 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Tue, 21 May 2024 23:12:10 +0200 Subject: [PATCH 25/36] [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 730973a9..c20289f6 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ limitations under the License. plexus-xml - 3.0.1 + 3.0.2-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 ${project.scm.connection} - plexus-xml-3.0.1 + 3.x https://github.com/codehaus-plexus/plexus-xml/tree/${project.scm.tag}/ @@ -48,7 +48,7 @@ limitations under the License. - 2024-05-21T21:11:54Z + 2024-05-21T21:12:10Z From d2af259231f3c071a66211ab185d8566eac4e046 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 24 Sep 2024 15:58:56 +0000 Subject: [PATCH 26/36] Bump org.codehaus.plexus:plexus-utils from 4.0.1 to 4.0.2 Bumps [org.codehaus.plexus:plexus-utils](https://github.com/codehaus-plexus/plexus-utils) from 4.0.1 to 4.0.2. - [Release notes](https://github.com/codehaus-plexus/plexus-utils/releases) - [Commits](https://github.com/codehaus-plexus/plexus-utils/compare/plexus-utils-4.0.1...plexus-utils-4.0.2) --- updated-dependencies: - dependency-name: org.codehaus.plexus:plexus-utils dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c20289f6..3d2c3810 100644 --- a/pom.xml +++ b/pom.xml @@ -72,7 +72,7 @@ limitations under the License. org.codehaus.plexus plexus-utils - 4.0.1 + 4.0.2 test From a971bc75c10e034bb96e435331361858c1bbb176 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 26 Sep 2024 15:32:24 +0000 Subject: [PATCH 27/36] Bump org.codehaus.plexus:plexus from 18 to 19 Bumps [org.codehaus.plexus:plexus](https://github.com/codehaus-plexus/plexus-pom) from 18 to 19. - [Release notes](https://github.com/codehaus-plexus/plexus-pom/releases) - [Commits](https://github.com/codehaus-plexus/plexus-pom/commits) --- updated-dependencies: - dependency-name: org.codehaus.plexus:plexus dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3d2c3810..a2cd9f9a 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ limitations under the License. org.codehaus.plexus plexus - 18 + 19 plexus-xml From 0c36a51192028afbb1e8bb855a421ff4a2486d00 Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Sun, 6 Oct 2024 23:30:03 +0200 Subject: [PATCH 28/36] Adjust to new model (cherry picked from commit f411cdd227444f92647b15a130e8aa88d79c7631) --- src/site/site.xml | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/site/site.xml b/src/site/site.xml index 3cb8f1a8..a0470195 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -1,8 +1,22 @@ + + - @@ -19,4 +33,4 @@ - \ No newline at end of file + From 3dd1f84267f6271f23ddf1ea28915c8da757cb8b Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Sun, 15 Dec 2024 23:27:22 +0100 Subject: [PATCH 29/36] Tests cleanup --- pom.xml | 7 +- .../util/xml/PrettyPrintXMLWriterTest.java | 79 ++- .../plexus/util/xml/XmlStreamReaderTest.java | 30 +- .../plexus/util/xml/XmlStreamWriterTest.java | 29 +- .../codehaus/plexus/util/xml/XmlUtilTest.java | 11 +- .../plexus/util/xml/XmlWriterUtilTest.java | 216 ++++--- .../plexus/util/xml/Xpp3DomBuilderTest.java | 84 +-- .../codehaus/plexus/util/xml/Xpp3DomTest.java | 47 +- .../plexus/util/xml/Xpp3DomUtilsTest.java | 12 +- .../plexus/util/xml/Xpp3DomWriterTest.java | 8 +- ...onformanceTestSuite_Production24_Test.java | 21 +- ...ConformanceTestSuite_Production2_Test.java | 71 +-- ...onformanceTestSuite_Production32_Test.java | 22 +- ...onformanceTestSuite_Production66_Test.java | 33 +- ...onformanceTestSuite_Production80_Test.java | 15 +- .../plexus/util/xml/pull/MXParserTest.java | 549 +++++++++--------- .../util/xml/pull/MXSerializerTest.java | 25 +- ..._BjoernHoehrmannviaHST2013_09_18_Test.java | 23 +- 18 files changed, 619 insertions(+), 663 deletions(-) diff --git a/pom.xml b/pom.xml index a2cd9f9a..1b9dbcc2 100644 --- a/pom.xml +++ b/pom.xml @@ -48,6 +48,7 @@ limitations under the License. + 1.37 2024-05-21T21:12:10Z @@ -55,18 +56,18 @@ limitations under the License. org.openjdk.jmh jmh-core - 1.37 + ${jmhVersion} test org.openjdk.jmh jmh-generator-annprocess - 1.37 + ${jmhVersion} test org.junit.jupiter - junit-jupiter + junit-jupiter-api test diff --git a/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java b/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java index e219e5c1..6c7736fb 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java @@ -22,6 +22,7 @@ import java.io.IOException; import java.io.OutputStreamWriter; import java.io.StringWriter; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.NoSuchElementException; @@ -42,7 +43,7 @@ * @version $Id: $Id * @since 3.4.0 */ -public class PrettyPrintXMLWriterTest { +class PrettyPrintXMLWriterTest { StringWriter w; PrettyPrintXMLWriter writer; @@ -51,7 +52,7 @@ public class PrettyPrintXMLWriterTest { *

    setUp.

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

    tearDown.

    */ @AfterEach - public void tearDown() { + void tearDown() { writer = null; w = null; } @@ -73,7 +74,7 @@ private void initWriter() { *

    testDefaultPrettyPrintXMLWriter.

    */ @Test - public void testDefaultPrettyPrintXMLWriter() { + void defaultPrettyPrintXMLWriter() { writer.startElement(Tag.HTML.toString()); writeXhtmlHead(writer); @@ -89,7 +90,7 @@ public void testDefaultPrettyPrintXMLWriter() { *

    testPrettyPrintXMLWriterWithGivenLineSeparator.

    */ @Test - public void testPrettyPrintXMLWriterWithGivenLineSeparator() { + void prettyPrintXMLWriterWithGivenLineSeparator() { writer.setLineSeparator("\n"); writer.startElement(Tag.HTML.toString()); @@ -107,7 +108,7 @@ public void testPrettyPrintXMLWriterWithGivenLineSeparator() { *

    testPrettyPrintXMLWriterWithGivenLineIndenter.

    */ @Test - public void testPrettyPrintXMLWriterWithGivenLineIndenter() { + void prettyPrintXMLWriterWithGivenLineIndenter() { writer.setLineIndenter(" "); writer.startElement(Tag.HTML.toString()); @@ -125,7 +126,7 @@ public void testPrettyPrintXMLWriterWithGivenLineIndenter() { *

    testEscapeXmlAttribute.

    */ @Test - public void testEscapeXmlAttribute() { + void escapeXmlAttribute() { // Windows writer.startElement(Tag.DIV.toString()); writer.addAttribute("class", "sect\r\nion"); @@ -151,7 +152,7 @@ public void testEscapeXmlAttribute() { *

    testendElementAlreadyClosed.

    */ @Test - public void testendElementAlreadyClosed() { + void testendElementAlreadyClosed() { try { writer.startElement(Tag.DIV.toString()); writer.addAttribute("class", "someattribute"); @@ -164,21 +165,22 @@ public void testendElementAlreadyClosed() { } /** - * Issue #51: https://github.com/codehaus-plexus/plexus-utils/issues/51 Purpose: test if concatenation string + * Issue #51: ... Purpose: test if concatenation string * optimization bug is present. Target environment: Java 7 (u79 and u80 verified) running on Windows. Detection * strategy: Tries to build a big XML file (~750MB size) and with many nested tags to force the JVM to trigger the * concatenation string optimization bug that throws a NoSuchElementException when calling endElement() method. * - * @throws java.io.IOException if an I/O error occurs + * @throws IOException if an I/O error occurs */ @Test - public void testIssue51DetectJava7ConcatenationBug() throws IOException { + void issue51DetectJava7ConcatenationBug() throws IOException { File dir = new File("target/test-xml"); if (!dir.exists()) { assertTrue(dir.mkdir(), "cannot create directory test-xml"); } File xmlFile = new File(dir, "test-issue-51.xml"); - OutputStreamWriter osw = new OutputStreamWriter(Files.newOutputStream(xmlFile.toPath()), "UTF-8"); + OutputStreamWriter osw = + new OutputStreamWriter(Files.newOutputStream(xmlFile.toPath()), StandardCharsets.UTF_8); writer = new PrettyPrintXMLWriter(osw); int iterations = 20000; @@ -235,34 +237,29 @@ private String expectedResult(String lineSeparator) { } private String expectedResult(String lineIndenter, String lineSeparator) { - StringBuilder expected = new StringBuilder(); - - expected.append("").append(lineSeparator); - expected.append(StringUtils.repeat(lineIndenter, 1)).append("").append(lineSeparator); - expected.append(StringUtils.repeat(lineIndenter, 2)) - .append("title") - .append(lineSeparator); - expected.append(StringUtils.repeat(lineIndenter, 2)) - .append("") - .append(lineSeparator); - expected.append(StringUtils.repeat(lineIndenter, 2)) - .append("") - .append(lineSeparator); - expected.append(StringUtils.repeat(lineIndenter, 1)).append("").append(lineSeparator); - expected.append(StringUtils.repeat(lineIndenter, 1)).append("").append(lineSeparator); - expected.append(StringUtils.repeat(lineIndenter, 2)) - .append("

    Paragraph 1, line 1. Paragraph 1, line 2.

    ") - .append(lineSeparator); - expected.append(StringUtils.repeat(lineIndenter, 2)) - .append("
    ") - .append(lineSeparator); - expected.append(StringUtils.repeat(lineIndenter, 3)) - .append("

    Section title

    ") - .append(lineSeparator); - expected.append(StringUtils.repeat(lineIndenter, 2)).append("
    ").append(lineSeparator); - expected.append(StringUtils.repeat(lineIndenter, 1)).append("").append(lineSeparator); - expected.append(""); - - return expected.toString(); + return "" + lineSeparator + StringUtils.repeat(lineIndenter, 1) + + "" + lineSeparator + StringUtils.repeat(lineIndenter, 2) + + "title" + + lineSeparator + + StringUtils.repeat(lineIndenter, 2) + + "" + + lineSeparator + + StringUtils.repeat(lineIndenter, 2) + + "" + + lineSeparator + + StringUtils.repeat(lineIndenter, 1) + + "" + lineSeparator + StringUtils.repeat(lineIndenter, 1) + + "" + lineSeparator + StringUtils.repeat(lineIndenter, 2) + + "

    Paragraph 1, line 1. Paragraph 1, line 2.

    " + + lineSeparator + + StringUtils.repeat(lineIndenter, 2) + + "
    " + + lineSeparator + + StringUtils.repeat(lineIndenter, 3) + + "

    Section title

    " + + lineSeparator + + StringUtils.repeat(lineIndenter, 2) + + "
    " + lineSeparator + StringUtils.repeat(lineIndenter, 1) + + "" + lineSeparator + ""; } } diff --git a/src/test/java/org/codehaus/plexus/util/xml/XmlStreamReaderTest.java b/src/test/java/org/codehaus/plexus/util/xml/XmlStreamReaderTest.java index 4ffe7a9c..0ce093e8 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/XmlStreamReaderTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/XmlStreamReaderTest.java @@ -35,7 +35,7 @@ * @version $Id: $Id * @since 3.4.0 */ -public class XmlStreamReaderTest { +class XmlStreamReaderTest { /** french */ private static final String TEXT_LATIN1 = "eacute: \u00E9"; @@ -52,7 +52,7 @@ public class XmlStreamReaderTest { private static final String TEXT_UNICODE = TEXT_LATIN1 + ", " + TEXT_LATIN7 + ", " + TEXT_LATIN15 + ", " + TEXT_EUC_JP; - /** see http://unicode.org/faq/utf_bom.html#BOM */ + /** see BOM */ private static final byte[] BOM_UTF8 = {(byte) 0xEF, (byte) 0xBB, (byte) 0xBF}; private static final byte[] BOM_UTF16BE = {(byte) 0xFE, (byte) 0xFF}; @@ -115,7 +115,7 @@ private static void checkXmlStreamReader(String text, String encoding, String ef * @throws java.io.IOException if any. */ @Test - public void testNoXmlHeader() throws IOException { + void noXmlHeader() throws IOException { String xml = "text with no XML header"; checkXmlContent(xml, "UTF-8"); checkXmlContent(xml, "UTF-8", BOM_UTF8); @@ -127,7 +127,7 @@ public void testNoXmlHeader() throws IOException { * @throws java.io.IOException if any. */ @Test - public void testDefaultEncoding() throws IOException { + void defaultEncoding() throws IOException { checkXmlStreamReader(TEXT_UNICODE, null, "UTF-8"); checkXmlStreamReader(TEXT_UNICODE, null, "UTF-8", BOM_UTF8); } @@ -138,7 +138,7 @@ public void testDefaultEncoding() throws IOException { * @throws java.io.IOException if any. */ @Test - public void testUTF8Encoding() throws IOException { + void utf8Encoding() throws IOException { checkXmlStreamReader(TEXT_UNICODE, "UTF-8"); checkXmlStreamReader(TEXT_UNICODE, "UTF-8", BOM_UTF8); } @@ -149,7 +149,7 @@ public void testUTF8Encoding() throws IOException { * @throws java.io.IOException if any. */ @Test - public void testUTF16Encoding() throws IOException { + void utf16Encoding() throws IOException { checkXmlStreamReader(TEXT_UNICODE, "UTF-16", "UTF-16BE", null); checkXmlStreamReader(TEXT_UNICODE, "UTF-16", "UTF-16LE", BOM_UTF16LE); checkXmlStreamReader(TEXT_UNICODE, "UTF-16", "UTF-16BE", BOM_UTF16BE); @@ -161,7 +161,7 @@ public void testUTF16Encoding() throws IOException { * @throws java.io.IOException if any. */ @Test - public void testUTF16BEEncoding() throws IOException { + void utf16beEncoding() throws IOException { checkXmlStreamReader(TEXT_UNICODE, "UTF-16BE"); } @@ -171,7 +171,7 @@ public void testUTF16BEEncoding() throws IOException { * @throws java.io.IOException if any. */ @Test - public void testUTF16LEEncoding() throws IOException { + void utf16leEncoding() throws IOException { checkXmlStreamReader(TEXT_UNICODE, "UTF-16LE"); } @@ -181,7 +181,7 @@ public void testUTF16LEEncoding() throws IOException { * @throws java.io.IOException if any. */ @Test - public void testLatin1Encoding() throws IOException { + void latin1Encoding() throws IOException { checkXmlStreamReader(TEXT_LATIN1, "ISO-8859-1"); } @@ -191,7 +191,7 @@ public void testLatin1Encoding() throws IOException { * @throws java.io.IOException if any. */ @Test - public void testLatin7Encoding() throws IOException { + void latin7Encoding() throws IOException { checkXmlStreamReader(TEXT_LATIN7, "ISO-8859-7"); } @@ -201,7 +201,7 @@ public void testLatin7Encoding() throws IOException { * @throws java.io.IOException if any. */ @Test - public void testLatin15Encoding() throws IOException { + void latin15Encoding() throws IOException { checkXmlStreamReader(TEXT_LATIN15, "ISO-8859-15"); } @@ -211,7 +211,7 @@ public void testLatin15Encoding() throws IOException { * @throws java.io.IOException if any. */ @Test - public void testEUC_JPEncoding() throws IOException { + void euc_jpEncoding() throws IOException { checkXmlStreamReader(TEXT_EUC_JP, "EUC-JP"); } @@ -221,7 +221,7 @@ public void testEUC_JPEncoding() throws IOException { * @throws java.io.IOException if any. */ @Test - public void testEBCDICEncoding() throws IOException { + void ebcdicEncoding() throws IOException { checkXmlStreamReader("simple text in EBCDIC", "CP1047"); } @@ -231,7 +231,7 @@ public void testEBCDICEncoding() throws IOException { * @throws java.io.IOException if any. */ @Test - public void testInappropriateEncoding() throws IOException { + void inappropriateEncoding() throws IOException { // expected failure, since the encoding does not contain some characters assertThrows( AssertionFailedError.class, @@ -245,7 +245,7 @@ public void testInappropriateEncoding() throws IOException { * @throws java.io.IOException if any. */ @Test - public void testEncodingAttribute() throws IOException { + void encodingAttribute() throws IOException { String xml = ""; checkXmlContent(xml, "US-ASCII"); diff --git a/src/test/java/org/codehaus/plexus/util/xml/XmlStreamWriterTest.java b/src/test/java/org/codehaus/plexus/util/xml/XmlStreamWriterTest.java index c2803b59..6fa531b6 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/XmlStreamWriterTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/XmlStreamWriterTest.java @@ -30,7 +30,7 @@ * @version $Id: $Id * @since 3.4.0 */ -public class XmlStreamWriterTest { +class XmlStreamWriterTest { /** french */ private static final String TEXT_LATIN1 = "eacute: \u00E9"; @@ -61,8 +61,7 @@ private static void checkXmlContent(String xml, String encoding) throws IOExcept XmlStreamWriter writer = new XmlStreamWriter(out); writer.write(xml); writer.close(); - byte[] xmlContent = out.toByteArray(); - String result = new String(xmlContent, encoding); + String result = out.toString(encoding); assertEquals(xml, result); } @@ -78,7 +77,7 @@ private static void checkXmlWriter(String text, String encoding) throws IOExcept * @throws java.io.IOException if any. */ @Test - public void testNoXmlHeader() throws IOException { + void noXmlHeader() throws IOException { String xml = "text with no XML header"; checkXmlContent(xml, "UTF-8"); } @@ -89,7 +88,7 @@ public void testNoXmlHeader() throws IOException { * @throws java.io.IOException if any. */ @Test - public void testEmpty() throws IOException { + void empty() throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); XmlStreamWriter writer = new XmlStreamWriter(out); writer.flush(); @@ -106,7 +105,7 @@ public void testEmpty() throws IOException { * @throws java.io.IOException if any. */ @Test - public void testDefaultEncoding() throws IOException { + void defaultEncoding() throws IOException { checkXmlWriter(TEXT_UNICODE, null); } @@ -116,7 +115,7 @@ public void testDefaultEncoding() throws IOException { * @throws java.io.IOException if any. */ @Test - public void testUTF8Encoding() throws IOException { + void utf8Encoding() throws IOException { checkXmlWriter(TEXT_UNICODE, "UTF-8"); } @@ -126,7 +125,7 @@ public void testUTF8Encoding() throws IOException { * @throws java.io.IOException if any. */ @Test - public void testUTF16Encoding() throws IOException { + void utf16Encoding() throws IOException { checkXmlWriter(TEXT_UNICODE, "UTF-16"); } @@ -136,7 +135,7 @@ public void testUTF16Encoding() throws IOException { * @throws java.io.IOException if any. */ @Test - public void testUTF16BEEncoding() throws IOException { + void utf16beEncoding() throws IOException { checkXmlWriter(TEXT_UNICODE, "UTF-16BE"); } @@ -146,7 +145,7 @@ public void testUTF16BEEncoding() throws IOException { * @throws java.io.IOException if any. */ @Test - public void testUTF16LEEncoding() throws IOException { + void utf16leEncoding() throws IOException { checkXmlWriter(TEXT_UNICODE, "UTF-16LE"); } @@ -156,7 +155,7 @@ public void testUTF16LEEncoding() throws IOException { * @throws java.io.IOException if any. */ @Test - public void testLatin1Encoding() throws IOException { + void latin1Encoding() throws IOException { checkXmlWriter(TEXT_LATIN1, "ISO-8859-1"); } @@ -166,7 +165,7 @@ public void testLatin1Encoding() throws IOException { * @throws java.io.IOException if any. */ @Test - public void testLatin7Encoding() throws IOException { + void latin7Encoding() throws IOException { checkXmlWriter(TEXT_LATIN7, "ISO-8859-7"); } @@ -176,7 +175,7 @@ public void testLatin7Encoding() throws IOException { * @throws java.io.IOException if any. */ @Test - public void testLatin15Encoding() throws IOException { + void latin15Encoding() throws IOException { checkXmlWriter(TEXT_LATIN15, "ISO-8859-15"); } @@ -186,7 +185,7 @@ public void testLatin15Encoding() throws IOException { * @throws java.io.IOException if any. */ @Test - public void testEUC_JPEncoding() throws IOException { + void euc_jpEncoding() throws IOException { checkXmlWriter(TEXT_EUC_JP, "EUC-JP"); } @@ -196,7 +195,7 @@ public void testEUC_JPEncoding() throws IOException { * @throws java.io.IOException if any. */ @Test - public void testEBCDICEncoding() throws IOException { + void ebcdicEncoding() throws IOException { checkXmlWriter("simple text in EBCDIC", "CP1047"); } } diff --git a/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java b/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java index 302bc28a..e6f9f596 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java @@ -29,7 +29,8 @@ import org.codehaus.plexus.util.StringUtils; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test the {@link org.codehaus.plexus.util.xml.XmlUtil} class. @@ -68,7 +69,7 @@ private File getTestOutputFile(String relPath) throws IOException { * @throws java.lang.Exception if any. */ @Test - public void testPrettyFormatInputStreamOutputStream() throws Exception { + void prettyFormatInputStreamOutputStream() throws Exception { File testDocument = new File(getBasedir(), "src/test/resources/testDocument.xhtml"); assertTrue(testDocument.exists()); @@ -95,7 +96,7 @@ public void testPrettyFormatInputStreamOutputStream() throws Exception { * @throws java.lang.Exception if any. */ @Test - public void testPrettyFormatReaderWriter() throws Exception { + void prettyFormatReaderWriter() throws Exception { File testDocument = new File(getBasedir(), "src/test/resources/testDocument.xhtml"); assertTrue(testDocument.exists()); @@ -121,7 +122,7 @@ public void testPrettyFormatReaderWriter() throws Exception { * @throws java.lang.Exception if any. */ @Test - public void testPrettyFormatString() throws Exception { + void prettyFormatString() throws Exception { File testDocument = new File(getBasedir(), "src/test/resources/testDocument.xhtml"); assertTrue(testDocument.exists()); @@ -152,7 +153,7 @@ public void testPrettyFormatString() throws Exception { * @throws java.lang.Exception if any. */ @Test - public void testPrettyFormatReaderWriter2() throws Exception { + void prettyFormatReaderWriter2() throws Exception { File testDocument = new File(getBasedir(), "src/test/resources/test.xdoc.xhtml"); assertTrue(testDocument.exists()); diff --git a/src/test/java/org/codehaus/plexus/util/xml/XmlWriterUtilTest.java b/src/test/java/org/codehaus/plexus/util/xml/XmlWriterUtilTest.java index fb515787..ff078f5a 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/XmlWriterUtilTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/XmlWriterUtilTest.java @@ -25,7 +25,8 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** *

    XmlWriterUtilTest class.

    @@ -34,7 +35,7 @@ * @version $Id: $Id * @since 3.4.0 */ -public class XmlWriterUtilTest { +class XmlWriterUtilTest { private OutputStream output; private Writer writer; @@ -47,7 +48,7 @@ public class XmlWriterUtilTest { * @throws java.lang.Exception if any. */ @BeforeEach - public void setUp() throws Exception { + void setUp() throws Exception { output = new ByteArrayOutputStream(); writer = WriterFactory.newXmlWriter(output); xmlWriter = new PrettyPrintXMLWriter(writer); @@ -59,7 +60,7 @@ public void setUp() throws Exception { * @throws java.lang.Exception if any. */ @AfterEach - public void tearDown() throws Exception { + void tearDown() throws Exception { xmlWriter = null; writer = null; output = null; @@ -72,10 +73,10 @@ public void tearDown() throws Exception { * @throws java.lang.Exception if any */ @Test - public void testWriteLineBreakXMLWriter() throws Exception { + void writeLineBreakXMLWriter() throws Exception { XmlWriterUtil.writeLineBreak(xmlWriter); writer.close(); - assertTrue(StringUtils.countMatches(output.toString(), XmlWriterUtil.LS) == 1); + assertEquals(1, StringUtils.countMatches(output.toString(), XmlWriterUtil.LS)); } /** @@ -85,10 +86,10 @@ public void testWriteLineBreakXMLWriter() throws Exception { * @throws java.lang.Exception if any */ @Test - public void testWriteLineBreakXMLWriterInt() throws Exception { + void writeLineBreakXMLWriterInt() throws Exception { XmlWriterUtil.writeLineBreak(xmlWriter, 10); writer.close(); - assertTrue(StringUtils.countMatches(output.toString(), XmlWriterUtil.LS) == 10); + assertEquals(10, StringUtils.countMatches(output.toString(), XmlWriterUtil.LS)); } /** @@ -98,13 +99,14 @@ public void testWriteLineBreakXMLWriterInt() throws Exception { * @throws java.lang.Exception if any */ @Test - public void testWriteLineBreakXMLWriterIntInt() throws Exception { + void writeLineBreakXMLWriterIntInt() throws Exception { XmlWriterUtil.writeLineBreak(xmlWriter, 10, 2); writer.close(); - assertTrue(StringUtils.countMatches(output.toString(), XmlWriterUtil.LS) == 10); - assertTrue(StringUtils.countMatches( - output.toString(), StringUtils.repeat(" ", 2 * XmlWriterUtil.DEFAULT_INDENTATION_SIZE)) - == 1); + assertEquals(10, StringUtils.countMatches(output.toString(), XmlWriterUtil.LS)); + assertEquals( + 1, + StringUtils.countMatches( + output.toString(), StringUtils.repeat(" ", 2 * XmlWriterUtil.DEFAULT_INDENTATION_SIZE))); } /** @@ -114,11 +116,11 @@ public void testWriteLineBreakXMLWriterIntInt() throws Exception { * @throws java.lang.Exception if any */ @Test - public void testWriteLineBreakXMLWriterIntIntInt() throws Exception { + void writeLineBreakXMLWriterIntIntInt() throws Exception { XmlWriterUtil.writeLineBreak(xmlWriter, 10, 2, 4); writer.close(); - assertTrue(StringUtils.countMatches(output.toString(), XmlWriterUtil.LS) == 10); - assertTrue(StringUtils.countMatches(output.toString(), StringUtils.repeat(" ", 2 * 4)) == 1); + assertEquals(10, StringUtils.countMatches(output.toString(), XmlWriterUtil.LS)); + assertEquals(1, StringUtils.countMatches(output.toString(), StringUtils.repeat(" ", 2 * 4))); } /** @@ -128,14 +130,13 @@ public void testWriteLineBreakXMLWriterIntIntInt() throws Exception { * @throws java.lang.Exception if any */ @Test - public void testWriteCommentLineBreakXMLWriter() throws Exception { + void writeCommentLineBreakXMLWriter() throws Exception { XmlWriterUtil.writeCommentLineBreak(xmlWriter); writer.close(); - StringBuilder sb = new StringBuilder(); - sb.append("") - .append(XmlWriterUtil.LS); - assertEquals(output.toString(), sb.toString()); - assertTrue(output.toString().length() == XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length()); + String sb = + "" + XmlWriterUtil.LS; + assertEquals(output.toString(), sb); + assertEquals(output.toString().length(), XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length()); } /** @@ -145,10 +146,10 @@ public void testWriteCommentLineBreakXMLWriter() throws Exception { * @throws java.lang.Exception if any */ @Test - public void testWriteCommentLineBreakXMLWriterInt() throws Exception { + void writeCommentLineBreakXMLWriterInt() throws Exception { XmlWriterUtil.writeCommentLineBreak(xmlWriter, 20); writer.close(); - assertEquals(output.toString(), "" + XmlWriterUtil.LS); + assertEquals("" + XmlWriterUtil.LS, output.toString()); tearDown(); setUp(); @@ -165,14 +166,14 @@ public void testWriteCommentLineBreakXMLWriterInt() throws Exception { * @throws java.lang.Exception if any */ @Test - public void testWriteCommentXMLWriterString() throws Exception { + void writeCommentXMLWriterString() throws Exception { XmlWriterUtil.writeComment(xmlWriter, "hello"); writer.close(); - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append("") .append(XmlWriterUtil.LS); assertEquals(output.toString(), sb.toString()); - assertTrue(output.toString().length() == XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length()); + assertEquals(output.toString().length(), XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length()); tearDown(); setUp(); @@ -180,7 +181,7 @@ public void testWriteCommentXMLWriterString() throws Exception { XmlWriterUtil.writeComment( xmlWriter, "hellooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo"); writer.close(); - sb = new StringBuffer(); + sb = new StringBuilder(); sb.append("") .append(XmlWriterUtil.LS); assertEquals(output.toString(), sb.toString()); @@ -191,14 +192,14 @@ public void testWriteCommentXMLWriterString() throws Exception { XmlWriterUtil.writeComment(xmlWriter, "hello\nworld"); writer.close(); - sb = new StringBuffer(); + sb = new StringBuilder(); sb.append("") .append(XmlWriterUtil.LS); sb.append("") .append(XmlWriterUtil.LS); assertEquals(output.toString(), sb.toString()); - assertTrue( - output.toString().length() == 2 * (XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length())); + assertEquals( + output.toString().length(), 2 * (XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length())); } /** @@ -208,18 +209,19 @@ public void testWriteCommentXMLWriterString() throws Exception { * @throws java.lang.Exception if any */ @Test - public void testWriteCommentXMLWriterStringInt() throws Exception { + void writeCommentXMLWriterStringInt() throws Exception { String indent = StringUtils.repeat(" ", 2 * XmlWriterUtil.DEFAULT_INDENTATION_SIZE); XmlWriterUtil.writeComment(xmlWriter, "hello", 2); writer.close(); - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append(indent); sb.append("") .append(XmlWriterUtil.LS); assertEquals(output.toString(), sb.toString()); - assertTrue(output.toString().length() - == XmlWriterUtil.DEFAULT_COLUMN_LINE + assertEquals( + output.toString().length(), + XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length() + 2 * XmlWriterUtil.DEFAULT_INDENTATION_SIZE); @@ -229,7 +231,7 @@ public void testWriteCommentXMLWriterStringInt() throws Exception { XmlWriterUtil.writeComment(xmlWriter, "hello\nworld", 2); writer.close(); - sb = new StringBuffer(); + sb = new StringBuilder(); sb.append(indent); sb.append("") .append(XmlWriterUtil.LS); @@ -237,8 +239,9 @@ public void testWriteCommentXMLWriterStringInt() throws Exception { sb.append("") .append(XmlWriterUtil.LS); assertEquals(output.toString(), sb.toString()); - assertTrue(output.toString().length() - == 2 * (XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length()) + 2 * indent.length()); + assertEquals( + output.toString().length(), + 2 * (XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length()) + 2 * indent.length()); } /** @@ -248,25 +251,25 @@ public void testWriteCommentXMLWriterStringInt() throws Exception { * @throws java.lang.Exception if any */ @Test - public void testWriteCommentXMLWriterStringIntInt() throws Exception { + void writeCommentXMLWriterStringIntInt() throws Exception { String repeat = StringUtils.repeat(" ", 2 * 4); XmlWriterUtil.writeComment(xmlWriter, "hello", 2, 4); writer.close(); - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append(repeat); sb.append("") .append(XmlWriterUtil.LS); assertEquals(output.toString(), sb.toString()); - assertTrue(output.toString().length() - == XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length() + 2 * 4); + assertEquals( + output.toString().length(), XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length() + 2 * 4); tearDown(); setUp(); XmlWriterUtil.writeComment(xmlWriter, "hello\nworld", 2, 4); writer.close(); - sb = new StringBuffer(); + sb = new StringBuilder(); sb.append(repeat); sb.append("") .append(XmlWriterUtil.LS); @@ -274,8 +277,9 @@ public void testWriteCommentXMLWriterStringIntInt() throws Exception { sb.append("") .append(XmlWriterUtil.LS); assertEquals(output.toString(), sb.toString()); - assertTrue(output.toString().length() - == 2 * (XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length()) + 2 * repeat.length()); + assertEquals( + output.toString().length(), + 2 * (XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length()) + 2 * repeat.length()); } /** @@ -285,23 +289,23 @@ public void testWriteCommentXMLWriterStringIntInt() throws Exception { * @throws java.lang.Exception if any */ @Test - public void testWriteCommentXMLWriterStringIntIntInt() throws Exception { + void writeCommentXMLWriterStringIntIntInt() throws Exception { String indent = StringUtils.repeat(" ", 2 * 4); XmlWriterUtil.writeComment(xmlWriter, "hello", 2, 4, 50); writer.close(); - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append(indent); sb.append("").append(XmlWriterUtil.LS); assertEquals(output.toString(), sb.toString()); - assertTrue(output.toString().length() == 50 - 1 + XmlWriterUtil.LS.length() + 2 * 4); + assertEquals(output.toString().length(), 50 - 1 + XmlWriterUtil.LS.length() + 2 * 4); tearDown(); setUp(); XmlWriterUtil.writeComment(xmlWriter, "hello", 2, 4, 10); writer.close(); - sb = new StringBuffer(); + sb = new StringBuilder(); sb.append(indent); sb.append("").append(XmlWriterUtil.LS); assertEquals(output.toString(), sb.toString()); @@ -315,10 +319,10 @@ public void testWriteCommentXMLWriterStringIntIntInt() throws Exception { * @throws java.lang.Exception if any */ @Test - public void testWriteCommentTextXMLWriterStringInt() throws Exception { + void writeCommentTextXMLWriterStringInt() throws Exception { XmlWriterUtil.writeCommentText(xmlWriter, "hello", 0); writer.close(); - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append(XmlWriterUtil.LS); sb.append("") .append(XmlWriterUtil.LS); @@ -328,8 +332,8 @@ public void testWriteCommentTextXMLWriterStringInt() throws Exception { .append(XmlWriterUtil.LS); sb.append(XmlWriterUtil.LS); assertEquals(output.toString(), sb.toString()); - assertTrue( - output.toString().length() == 3 * (80 - 1 + XmlWriterUtil.LS.length()) + 2 * XmlWriterUtil.LS.length()); + assertEquals( + output.toString().length(), 3 * (80 - 1 + XmlWriterUtil.LS.length()) + 2 * XmlWriterUtil.LS.length()); tearDown(); setUp(); @@ -342,7 +346,7 @@ public void testWriteCommentTextXMLWriterStringInt() throws Exception { + "loooooooooooooooooooooooooooooooooooooooooooooooooooooonnnnnnnnnnong line", 2); writer.close(); - sb = new StringBuffer(); + sb = new StringBuilder(); sb.append(XmlWriterUtil.LS); sb.append(indent) .append("") @@ -374,27 +378,26 @@ public void testWriteCommentTextXMLWriterStringInt() throws Exception { * @throws java.lang.Exception if any */ @Test - public void testWriteCommentTextXMLWriterStringIntInt() throws Exception { + void writeCommentTextXMLWriterStringIntInt() throws Exception { String indent = StringUtils.repeat(" ", 2 * 4); XmlWriterUtil.writeCommentText(xmlWriter, "hello", 2, 4); writer.close(); - StringBuilder sb = new StringBuilder(); - sb.append(XmlWriterUtil.LS); - sb.append(indent) - .append("") - .append(XmlWriterUtil.LS); - sb.append(indent) - .append("") - .append(XmlWriterUtil.LS); - sb.append(indent) - .append("") - .append(XmlWriterUtil.LS); - sb.append(XmlWriterUtil.LS); - sb.append(indent); - assertEquals(output.toString(), sb.toString()); - assertTrue(output.toString().length() - == 3 * (80 - 1 + XmlWriterUtil.LS.length()) + 4 * 2 * 4 + 2 * XmlWriterUtil.LS.length()); + String sb = XmlWriterUtil.LS + indent + + "" + + XmlWriterUtil.LS + + indent + + "" + + XmlWriterUtil.LS + + indent + + "" + + XmlWriterUtil.LS + + XmlWriterUtil.LS + + indent; + assertEquals(output.toString(), sb); + assertEquals( + output.toString().length(), + 3 * (80 - 1 + XmlWriterUtil.LS.length()) + 4 * 2 * 4 + 2 * XmlWriterUtil.LS.length()); } /** @@ -404,27 +407,26 @@ public void testWriteCommentTextXMLWriterStringIntInt() throws Exception { * @throws java.lang.Exception if any */ @Test - public void testWriteCommentTextXMLWriterStringIntIntInt() throws Exception { + void writeCommentTextXMLWriterStringIntIntInt() throws Exception { String indent = StringUtils.repeat(" ", 2 * 4); XmlWriterUtil.writeCommentText(xmlWriter, "hello", 2, 4, 50); writer.close(); - StringBuilder sb = new StringBuilder(); - sb.append(XmlWriterUtil.LS); - sb.append(indent) - .append("") - .append(XmlWriterUtil.LS); - sb.append(indent) - .append("") - .append(XmlWriterUtil.LS); - sb.append(indent) - .append("") - .append(XmlWriterUtil.LS); - sb.append(XmlWriterUtil.LS); - sb.append(indent); - assertEquals(output.toString(), sb.toString()); - assertTrue(output.toString().length() - == 3 * (50 - 1 + XmlWriterUtil.LS.length()) + 4 * 2 * 4 + 2 * XmlWriterUtil.LS.length()); + String sb = XmlWriterUtil.LS + indent + + "" + + XmlWriterUtil.LS + + indent + + "" + + XmlWriterUtil.LS + + indent + + "" + + XmlWriterUtil.LS + + XmlWriterUtil.LS + + indent; + assertEquals(output.toString(), sb); + assertEquals( + output.toString().length(), + 3 * (50 - 1 + XmlWriterUtil.LS.length()) + 4 * 2 * 4 + 2 * XmlWriterUtil.LS.length()); } /** @@ -434,13 +436,12 @@ public void testWriteCommentTextXMLWriterStringIntIntInt() throws Exception { * @throws java.lang.Exception if any */ @Test - public void testWriteCommentNull() throws Exception { + void writeCommentNull() throws Exception { XmlWriterUtil.writeComment(xmlWriter, null); writer.close(); - StringBuilder sb = new StringBuilder(); - sb.append("") - .append(XmlWriterUtil.LS); - assertEquals(output.toString(), sb.toString()); + String sb = + "" + XmlWriterUtil.LS; + assertEquals(output.toString(), sb); } /** @@ -450,13 +451,12 @@ public void testWriteCommentNull() throws Exception { * @throws java.lang.Exception if any */ @Test - public void testWriteCommentShort() throws Exception { + void writeCommentShort() throws Exception { XmlWriterUtil.writeComment(xmlWriter, "This is a short text"); writer.close(); - StringBuilder sb = new StringBuilder(); - sb.append("") - .append(XmlWriterUtil.LS); - assertEquals(output.toString(), sb.toString()); + String sb = + "" + XmlWriterUtil.LS; + assertEquals(output.toString(), sb); } /** @@ -466,22 +466,20 @@ public void testWriteCommentShort() throws Exception { * @throws java.lang.Exception if any */ @Test - public void testWriteCommentLong() throws Exception { + void writeCommentLong() throws Exception { XmlWriterUtil.writeComment( xmlWriter, "Maven is a software project management and comprehension tool. " + "Based on the concept of a project object model (POM), Maven can manage a project's build, reporting " + "and documentation from a central piece of information."); writer.close(); - StringBuilder sb = new StringBuilder(); - sb.append("") - .append(XmlWriterUtil.LS); - sb.append("") - .append(XmlWriterUtil.LS); - sb.append("") - .append(XmlWriterUtil.LS); - sb.append("") - .append(XmlWriterUtil.LS); - assertEquals(output.toString(), sb.toString()); + String sb = "" + XmlWriterUtil.LS + + "" + + XmlWriterUtil.LS + + "" + + XmlWriterUtil.LS + + "" + + XmlWriterUtil.LS; + assertEquals(output.toString(), sb); } } diff --git a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomBuilderTest.java b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomBuilderTest.java index c8db71b5..a23eec14 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomBuilderTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomBuilderTest.java @@ -34,7 +34,7 @@ * @version $Id: $Id * @since 3.4.0 */ -public class Xpp3DomBuilderTest { +class Xpp3DomBuilderTest { private static final String LS = System.lineSeparator(); /** @@ -43,7 +43,7 @@ public class Xpp3DomBuilderTest { * @throws java.lang.Exception if any. */ @Test - public void testBuildFromReader() throws Exception { + void buildFromReader() throws Exception { String domString = createDomString(); Xpp3Dom dom = Xpp3DomBuilder.build(new StringReader(domString)); @@ -59,7 +59,7 @@ public void testBuildFromReader() throws Exception { * @throws java.lang.Exception if any. */ @Test - public void testBuildTrimming() throws Exception { + void buildTrimming() throws Exception { String domString = createDomString(); Xpp3Dom dom = Xpp3DomBuilder.build(new StringReader(domString), true); @@ -77,7 +77,7 @@ public void testBuildTrimming() throws Exception { * @throws java.lang.Exception if any. */ @Test - public void testBuildFromXpp3Dom() throws Exception { + void buildFromXpp3Dom() throws Exception { Xpp3Dom expectedDom = createExpectedDom(); Xpp3Dom dom = null; @@ -123,7 +123,7 @@ public void testBuildFromXpp3Dom() throws Exception { * Test we get an error from the parser, and don't hit the IllegalStateException. */ @Test - public void testUnclosedXml() { + void unclosedXml() { String domString = "" + createDomString(); try { Xpp3DomBuilder.build(new StringReader(domString)); @@ -143,7 +143,7 @@ public void testUnclosedXml() { * @throws org.codehaus.plexus.util.xml.pull.XmlPullParserException if any. */ @Test - public void testEscapingInContent() throws IOException, XmlPullParserException { + void escapingInContent() throws IOException, XmlPullParserException { Xpp3Dom dom = Xpp3DomBuilder.build(new StringReader(getEncodedString())); assertEquals("\"text\"", dom.getChild("el").getValue(), "Check content value"); @@ -162,7 +162,7 @@ public void testEscapingInContent() throws IOException, XmlPullParserException { * @throws org.codehaus.plexus.util.xml.pull.XmlPullParserException if any. */ @Test - public void testEscapingInAttributes() throws IOException, XmlPullParserException { + void escapingInAttributes() throws IOException, XmlPullParserException { String s = getAttributeEncodedString(); Xpp3Dom dom = Xpp3DomBuilder.build(new StringReader(s)); @@ -181,12 +181,9 @@ public void testEscapingInAttributes() throws IOException, XmlPullParserExceptio * @throws org.codehaus.plexus.util.xml.pull.XmlPullParserException if any. */ @Test - public void testInputLocationTracking() throws IOException, XmlPullParserException { - Xpp3DomBuilder.InputLocationBuilder ilb = new Xpp3DomBuilder.InputLocationBuilder() { - public Object toInputLocation(XmlPullParser parser) { - return parser.getLineNumber(); // store only line number as a simple Integer - } - }; + void inputLocationTracking() throws IOException, XmlPullParserException { + // store only line number as a simple Integer + Xpp3DomBuilder.InputLocationBuilder ilb = XmlPullParser::getLineNumber; Xpp3Dom dom = Xpp3DomBuilder.build(new StringReader(createDomString()), true, ilb); Xpp3Dom expectedDom = createExpectedDom(); assertEquals(expectedDom.getInputLocation(), dom.getInputLocation(), "root input location"); @@ -204,40 +201,25 @@ public Object toInputLocation(XmlPullParser parser) { } private static String getAttributeEncodedString() { - StringBuilder domString = new StringBuilder(); - domString.append(""); - domString.append(LS); - domString.append(" bar"); - domString.append(LS); - domString.append(""); - - return domString.toString(); + return "" + LS + " bar" + LS + ""; } private static String getEncodedString() { - StringBuilder domString = new StringBuilder(); - domString.append("\n"); - domString.append(" \"text\"\n"); - domString.append(" \"text\"]]>\n"); - domString.append(" <b>"text"</b>\n"); - domString.append(""); - - return domString.toString(); + return "\n" + " \"text\"\n" + + " \"text\"]]>\n" + + " <b>"text"</b>\n" + + ""; } private static String getExpectedString() { - StringBuilder domString = new StringBuilder(); - domString.append(""); - domString.append(LS); - domString.append(" "text""); - domString.append(LS); - domString.append(" <b>"text"</b>"); - domString.append(LS); - domString.append(" <b>"text"</b>"); - domString.append(LS); - domString.append(""); - - return domString.toString(); + return "" + LS + + " "text"" + + LS + + " <b>"text"</b>" + + LS + + " <b>"text"</b>" + + LS + + ""; } // @@ -245,18 +227,14 @@ private static String getExpectedString() { // private static String createDomString() { - StringBuilder buf = new StringBuilder(); - buf.append("\n"); - buf.append(" element1\n \n"); - buf.append(" \n"); - buf.append(" element3\n"); - buf.append(" \n"); - buf.append(" \n"); - buf.append(" \n"); - buf.append(" do not trim \n"); - buf.append("\n"); - - return buf.toString(); + return "\n" + " element1\n \n" + + " \n" + + " element3\n" + + " \n" + + " \n" + + " \n" + + " do not trim \n" + + "\n"; } private static Xpp3Dom createExpectedDom() { diff --git a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomTest.java b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomTest.java index dd9aea87..fdf19dd0 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomTest.java @@ -33,12 +33,12 @@ * @version $Id: $Id * @since 3.4.0 */ -public class Xpp3DomTest { +class Xpp3DomTest { /** *

    testShouldPerformAppendAtFirstSubElementLevel.

    */ @Test - public void testShouldPerformAppendAtFirstSubElementLevel() { + void shouldPerformAppendAtFirstSubElementLevel() { // create the dominant DOM Xpp3Dom t1 = new Xpp3Dom("top"); t1.setAttribute(Xpp3Dom.CHILDREN_COMBINATION_MODE_ATTRIBUTE, Xpp3Dom.CHILDREN_COMBINATION_APPEND); @@ -76,7 +76,7 @@ public void testShouldPerformAppendAtFirstSubElementLevel() { *

    testShouldOverrideAppendAndDeepMerge.

    */ @Test - public void testShouldOverrideAppendAndDeepMerge() { + void shouldOverrideAppendAndDeepMerge() { // create the dominant DOM Xpp3Dom t1 = new Xpp3Dom("top"); t1.setAttribute(Xpp3Dom.CHILDREN_COMBINATION_MODE_ATTRIBUTE, Xpp3Dom.CHILDREN_COMBINATION_APPEND); @@ -112,7 +112,7 @@ public void testShouldOverrideAppendAndDeepMerge() { *

    testShouldPerformSelfOverrideAtTopLevel.

    */ @Test - public void testShouldPerformSelfOverrideAtTopLevel() { + void shouldPerformSelfOverrideAtTopLevel() { // create the dominant DOM Xpp3Dom t1 = new Xpp3Dom("top"); t1.setAttribute("attr", "value"); @@ -138,7 +138,7 @@ public void testShouldPerformSelfOverrideAtTopLevel() { *

    testShouldMergeValuesAtTopLevelByDefault.

    */ @Test - public void testShouldMergeValuesAtTopLevelByDefault() { + void shouldMergeValuesAtTopLevelByDefault() { // create the dominant DOM Xpp3Dom t1 = new Xpp3Dom("top"); t1.setAttribute("attr", "value"); @@ -164,7 +164,7 @@ public void testShouldMergeValuesAtTopLevelByDefault() { *

    testShouldMergeValuesAtTopLevel.

    */ @Test - public void testShouldMergeValuesAtTopLevel() { + void shouldMergeValuesAtTopLevel() { // create the dominant DOM Xpp3Dom t1 = new Xpp3Dom("top"); t1.setAttribute("attr", "value"); @@ -187,7 +187,7 @@ public void testShouldMergeValuesAtTopLevel() { *

    testNullAttributeNameOrValue.

    */ @Test - public void testNullAttributeNameOrValue() { + void nullAttributeNameOrValue() { Xpp3Dom t1 = new Xpp3Dom("top"); try { t1.setAttribute("attr", null); @@ -207,12 +207,12 @@ public void testNullAttributeNameOrValue() { *

    testEquals.

    */ @Test - public void testEquals() { + void equals() { Xpp3Dom dom = new Xpp3Dom("top"); assertEquals(dom, dom); - assertFalse(dom.equals(null)); - assertFalse(dom.equals(new Xpp3Dom((String) null))); + assertNotEquals(null, dom); + assertNotEquals(new Xpp3Dom((String) null), dom); } /** @@ -222,20 +222,20 @@ public void testEquals() { * @throws java.io.IOException if any. */ @Test - public void testEqualsIsNullSafe() throws XmlPullParserException, IOException { + void equalsIsNullSafe() throws XmlPullParserException, IOException { String testDom = "onetwo"; Xpp3Dom dom = Xpp3DomBuilder.build(new StringReader(testDom)); Xpp3Dom dom2 = Xpp3DomBuilder.build(new StringReader(testDom)); try { - dom2.attributes = new HashMap(); + dom2.attributes = new HashMap<>(); dom2.attributes.put("nullValue", null); dom2.attributes.put(null, "nullKey"); dom2.childList.clear(); dom2.childList.add(null); - assertFalse(dom.equals(dom2)); - assertFalse(dom2.equals(dom)); + assertNotEquals(dom, dom2); + assertNotEquals(dom2, dom); } catch (NullPointerException ex) { ex.printStackTrace(); @@ -250,7 +250,7 @@ public void testEqualsIsNullSafe() throws XmlPullParserException, IOException { * @throws java.io.IOException if any. */ @Test - public void testShouldOverwritePluginConfigurationSubItemsByDefault() throws XmlPullParserException, IOException { + void shouldOverwritePluginConfigurationSubItemsByDefault() throws XmlPullParserException, IOException { String parentConfigStr = "onetwo"; Xpp3Dom parentConfig = Xpp3DomBuilder.build(new StringReader(parentConfigStr), new FixedInputLocationBuilder("parent")); @@ -276,8 +276,7 @@ public void testShouldOverwritePluginConfigurationSubItemsByDefault() throws Xml * @throws java.io.IOException if any. */ @Test - public void testShouldMergePluginConfigurationSubItemsWithMergeAttributeSet() - throws XmlPullParserException, IOException { + void shouldMergePluginConfigurationSubItemsWithMergeAttributeSet() throws XmlPullParserException, IOException { String parentConfigStr = "onetwo"; Xpp3Dom parentConfig = Xpp3DomBuilder.build(new StringReader(parentConfigStr), new FixedInputLocationBuilder("parent")); @@ -308,7 +307,7 @@ public void testShouldMergePluginConfigurationSubItemsWithMergeAttributeSet() * @throws java.lang.Exception if any. */ @Test - public void testShouldNotChangeUponMergeWithItselfWhenFirstOrLastSubItemIsEmpty() throws Exception { + void shouldNotChangeUponMergeWithItselfWhenFirstOrLastSubItemIsEmpty() throws Exception { String configStr = "test"; Xpp3Dom dominantConfig = Xpp3DomBuilder.build(new StringReader(configStr)); Xpp3Dom recessiveConfig = Xpp3DomBuilder.build(new StringReader(configStr)); @@ -318,9 +317,9 @@ public void testShouldNotChangeUponMergeWithItselfWhenFirstOrLastSubItemIsEmpty( assertEquals(3, items.getChildCount()); - assertEquals(null, items.getChild(0).getValue()); + assertNull(items.getChild(0).getValue()); assertEquals("test", items.getChild(1).getValue()); - assertEquals(null, items.getChild(2).getValue()); + assertNull(items.getChild(2).getValue()); } /** @@ -329,7 +328,7 @@ public void testShouldNotChangeUponMergeWithItselfWhenFirstOrLastSubItemIsEmpty( * @throws java.lang.Exception if any. */ @Test - public void testShouldCopyRecessiveChildrenNotPresentInTarget() throws Exception { + void shouldCopyRecessiveChildrenNotPresentInTarget() throws Exception { String dominantStr = "x"; String recessiveStr = "y"; Xpp3Dom dominantConfig = Xpp3DomBuilder.build(new StringReader(dominantStr)); @@ -351,7 +350,7 @@ public void testShouldCopyRecessiveChildrenNotPresentInTarget() throws Exception * @throws org.codehaus.plexus.util.xml.pull.XmlPullParserException if any. */ @Test - public void testDupeChildren() throws IOException, XmlPullParserException { + void dupeChildren() throws IOException, XmlPullParserException { String dupes = "xy"; Xpp3Dom dom = Xpp3DomBuilder.build(new StringReader(dupes)); assertNotNull(dom); @@ -364,7 +363,7 @@ public void testDupeChildren() throws IOException, XmlPullParserException { * @throws java.lang.Exception if any. */ @Test - public void testShouldRemoveEntireElementWithAttributesAndChildren() throws Exception { + void shouldRemoveEntireElementWithAttributesAndChildren() throws Exception { String dominantStr = ""; String recessiveStr = "parameter"; Xpp3Dom dominantConfig = Xpp3DomBuilder.build(new StringReader(dominantStr)); @@ -382,7 +381,7 @@ public void testShouldRemoveEntireElementWithAttributesAndChildren() throws Exce * @throws java.lang.Exception if any. */ @Test - public void testShouldRemoveDoNotRemoveTagWhenSwappedInputDOMs() throws Exception { + void shouldRemoveDoNotRemoveTagWhenSwappedInputDOMs() throws Exception { String dominantStr = ""; String recessiveStr = "parameter"; Xpp3Dom dominantConfig = Xpp3DomBuilder.build(new StringReader(dominantStr)); diff --git a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomUtilsTest.java b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomUtilsTest.java index 66323675..64c31430 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomUtilsTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomUtilsTest.java @@ -32,14 +32,14 @@ * @version $Id: $Id * @since 3.4.0 */ -public class Xpp3DomUtilsTest { +class Xpp3DomUtilsTest { /** *

    testCombineId.

    * * @throws java.lang.Exception if any. */ @Test - public void testCombineId() throws Exception { + void combineId() throws Exception { String lhs = "" + "LHS-ONLYLHS" + "TOOVERWRITELHS" + ""; @@ -85,7 +85,7 @@ public void testCombineId() throws Exception { * @throws java.lang.Exception if any. */ @Test - public void testCombineKeys() throws Exception { + void combineKeys() throws Exception { String lhs = "" + "LHS-ONLYLHS" + "TOOVERWRITELHS" + ""; @@ -126,7 +126,7 @@ public void testCombineKeys() throws Exception { } @Test - public void testPreserveDominantBlankValue() throws XmlPullParserException, IOException { + void preserveDominantBlankValue() throws XmlPullParserException, IOException { String lhs = " "; String rhs = "recessive"; @@ -139,7 +139,7 @@ public void testPreserveDominantBlankValue() throws XmlPullParserException, IOEx } @Test - public void testPreserveDominantEmptyNode() throws XmlPullParserException, IOException { + void preserveDominantEmptyNode() throws XmlPullParserException, IOException { String lhs = ""; String rhs = "recessive"; @@ -152,7 +152,7 @@ public void testPreserveDominantEmptyNode() throws XmlPullParserException, IOExc } @Test - public void testIsNotEmptyNegatesIsEmpty() { + void isNotEmptyNegatesIsEmpty() { assertEquals(!Xpp3DomUtils.isEmpty(null), Xpp3DomUtils.isNotEmpty(null)); assertEquals(!Xpp3DomUtils.isEmpty(""), Xpp3DomUtils.isNotEmpty("")); assertEquals(!Xpp3DomUtils.isEmpty(" "), Xpp3DomUtils.isNotEmpty(" ")); diff --git a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomWriterTest.java b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomWriterTest.java index 233bdd5b..cfea0d37 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomWriterTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomWriterTest.java @@ -29,14 +29,14 @@ * @version $Id: $Id * @since 3.4.0 */ -public class Xpp3DomWriterTest { - private static final String LS = System.getProperty("line.separator"); +class Xpp3DomWriterTest { + private static final String LS = System.lineSeparator(); /** *

    testWriter.

    */ @Test - public void testWriter() { + void writer() { StringWriter writer = new StringWriter(); Xpp3DomWriter.write(writer, createXpp3Dom()); @@ -48,7 +48,7 @@ public void testWriter() { *

    testWriterNoEscape.

    */ @Test - public void testWriterNoEscape() { + void writerNoEscape() { StringWriter writer = new StringWriter(); Xpp3DomWriter.write(new PrettyPrintXMLWriter(writer), createXpp3Dom(), false); diff --git a/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production24_Test.java b/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production24_Test.java index bb1a7e8f..2e1fd7fe 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 49227a44..c4150edc 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production2_Test.java +++ b/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production2_Test.java @@ -13,6 +13,7 @@ import java.nio.file.Paths; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -38,7 +39,7 @@ class IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConfo *

    setUp.

    */ @BeforeEach - public void setUp() { + void setUp() { parser = new MXParser(); } @@ -52,7 +53,7 @@ public void setUp() { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n01xml() throws IOException { + void testibm_not_wf_P02_ibm02n01xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n01.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -73,7 +74,7 @@ public void testibm_not_wf_P02_ibm02n01xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n02xml() throws IOException { + void testibm_not_wf_P02_ibm02n02xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n02.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -94,7 +95,7 @@ public void testibm_not_wf_P02_ibm02n02xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n03xml() throws IOException { + void testibm_not_wf_P02_ibm02n03xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n03.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -115,7 +116,7 @@ public void testibm_not_wf_P02_ibm02n03xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n04xml() throws IOException { + void testibm_not_wf_P02_ibm02n04xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n04.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -136,7 +137,7 @@ public void testibm_not_wf_P02_ibm02n04xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n05xml() throws IOException { + void testibm_not_wf_P02_ibm02n05xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n05.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -157,7 +158,7 @@ public void testibm_not_wf_P02_ibm02n05xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n06xml() throws IOException { + void testibm_not_wf_P02_ibm02n06xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n06.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -178,7 +179,7 @@ public void testibm_not_wf_P02_ibm02n06xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n07xml() throws IOException { + void testibm_not_wf_P02_ibm02n07xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n07.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -199,7 +200,7 @@ public void testibm_not_wf_P02_ibm02n07xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n08xml() throws IOException { + void testibm_not_wf_P02_ibm02n08xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n08.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -220,7 +221,7 @@ public void testibm_not_wf_P02_ibm02n08xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n09xml() throws IOException { + void testibm_not_wf_P02_ibm02n09xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n09.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -241,7 +242,7 @@ public void testibm_not_wf_P02_ibm02n09xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n10xml() throws IOException { + void testibm_not_wf_P02_ibm02n10xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n10.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -262,7 +263,7 @@ public void testibm_not_wf_P02_ibm02n10xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n11xml() throws IOException { + void testibm_not_wf_P02_ibm02n11xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n11.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -283,7 +284,7 @@ public void testibm_not_wf_P02_ibm02n11xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n12xml() throws IOException { + void testibm_not_wf_P02_ibm02n12xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n12.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -304,7 +305,7 @@ public void testibm_not_wf_P02_ibm02n12xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n13xml() throws IOException { + void testibm_not_wf_P02_ibm02n13xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n13.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -325,7 +326,7 @@ public void testibm_not_wf_P02_ibm02n13xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n14xml() throws IOException { + void testibm_not_wf_P02_ibm02n14xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n14.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -346,7 +347,7 @@ public void testibm_not_wf_P02_ibm02n14xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n15xml() throws IOException { + void testibm_not_wf_P02_ibm02n15xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n15.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -367,7 +368,7 @@ public void testibm_not_wf_P02_ibm02n15xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n16xml() throws IOException { + void testibm_not_wf_P02_ibm02n16xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n16.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -388,7 +389,7 @@ public void testibm_not_wf_P02_ibm02n16xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n17xml() throws IOException { + void testibm_not_wf_P02_ibm02n17xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n17.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -409,7 +410,7 @@ public void testibm_not_wf_P02_ibm02n17xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n18xml() throws IOException { + void testibm_not_wf_P02_ibm02n18xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n18.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -430,7 +431,7 @@ public void testibm_not_wf_P02_ibm02n18xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n19xml() throws IOException { + void testibm_not_wf_P02_ibm02n19xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n19.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -451,7 +452,7 @@ public void testibm_not_wf_P02_ibm02n19xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n20xml() throws IOException { + void testibm_not_wf_P02_ibm02n20xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n20.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -472,7 +473,7 @@ public void testibm_not_wf_P02_ibm02n20xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n21xml() throws IOException { + void testibm_not_wf_P02_ibm02n21xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n21.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -493,7 +494,7 @@ public void testibm_not_wf_P02_ibm02n21xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n22xml() throws IOException { + void testibm_not_wf_P02_ibm02n22xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n22.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -514,7 +515,7 @@ public void testibm_not_wf_P02_ibm02n22xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n23xml() throws IOException { + void testibm_not_wf_P02_ibm02n23xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n23.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -535,7 +536,7 @@ public void testibm_not_wf_P02_ibm02n23xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n24xml() throws IOException { + void testibm_not_wf_P02_ibm02n24xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n24.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -556,7 +557,7 @@ public void testibm_not_wf_P02_ibm02n24xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n25xml() throws IOException { + void testibm_not_wf_P02_ibm02n25xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n25.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -577,7 +578,7 @@ public void testibm_not_wf_P02_ibm02n25xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n26xml() throws IOException { + void testibm_not_wf_P02_ibm02n26xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n26.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -598,7 +599,7 @@ public void testibm_not_wf_P02_ibm02n26xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n27xml() throws IOException { + void testibm_not_wf_P02_ibm02n27xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n27.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -619,7 +620,7 @@ public void testibm_not_wf_P02_ibm02n27xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n28xml() throws IOException { + void testibm_not_wf_P02_ibm02n28xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n28.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -640,7 +641,7 @@ public void testibm_not_wf_P02_ibm02n28xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n29xml() throws IOException { + void testibm_not_wf_P02_ibm02n29xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n29.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -662,7 +663,8 @@ public void testibm_not_wf_P02_ibm02n29xml() throws IOException { * * NOTE: This test file is malformed into the original test suite, so I skip it. */ - // @Test + @Test + @Disabled public void testibm_not_wf_P02_ibm02n30xml() throws IOException { try (BufferedReader reader = Files.newBufferedReader( Paths.get(testResourcesDir.getCanonicalPath(), "not-wf/P02/ibm02n30.xml"), @@ -687,7 +689,8 @@ public void testibm_not_wf_P02_ibm02n30xml() throws IOException { * * NOTE: This test file is malformed into the original test suite, so I skip it. */ - // @Test + @Test + @Disabled public void testibm_not_wf_P02_ibm02n31xml() throws IOException { try (FileInputStream is = new FileInputStream(new File(testResourcesDir, "not-wf/P02/ibm02n31.xml")); InputStreamReader reader = new InputStreamReader(is, "ISO-8859-15")) { @@ -710,7 +713,7 @@ public void testibm_not_wf_P02_ibm02n31xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n32xml() throws IOException { + void testibm_not_wf_P02_ibm02n32xml() throws IOException { try (FileInputStream is = new FileInputStream(new File(testResourcesDir, "not-wf/P02/ibm02n32.xml")); InputStreamReader reader = new InputStreamReader(is, StandardCharsets.UTF_8)) { parser.setInput(reader); @@ -732,7 +735,7 @@ public void testibm_not_wf_P02_ibm02n32xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n33xml() throws IOException { + void testibm_not_wf_P02_ibm02n33xml() throws IOException { try (FileInputStream is = new FileInputStream(new File(testResourcesDir, "not-wf/P02/ibm02n33.xml")); InputStreamReader reader = new InputStreamReader(is, StandardCharsets.UTF_8)) { parser.setInput(reader); diff --git a/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production32_Test.java b/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production32_Test.java index f99e1ead..cfc2c532 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production32_Test.java +++ b/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production32_Test.java @@ -6,6 +6,7 @@ import java.io.Reader; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -31,7 +32,7 @@ class IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConfo *

    setUp.

    */ @BeforeEach - public void setUp() { + void setUp() { parser = new MXParser(); } @@ -45,7 +46,7 @@ public void setUp() { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P32_ibm32n01xml() throws IOException { + void testibm_not_wf_P32_ibm32n01xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P32/ibm32n01.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -67,7 +68,7 @@ public void testibm_not_wf_P32_ibm32n01xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P32_ibm32n02xml() throws IOException { + void testibm_not_wf_P32_ibm32n02xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P32/ibm32n02.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -89,7 +90,7 @@ public void testibm_not_wf_P32_ibm32n02xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P32_ibm32n03xml() throws IOException { + void testibm_not_wf_P32_ibm32n03xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P32/ibm32n03.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -110,7 +111,7 @@ public void testibm_not_wf_P32_ibm32n03xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P32_ibm32n04xml() throws IOException { + void testibm_not_wf_P32_ibm32n04xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P32/ibm32n04.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -131,7 +132,7 @@ public void testibm_not_wf_P32_ibm32n04xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P32_ibm32n05xml() throws IOException { + void testibm_not_wf_P32_ibm32n05xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P32/ibm32n05.xml"))) { parser.setInput(reader); @@ -153,7 +154,7 @@ public void testibm_not_wf_P32_ibm32n05xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P32_ibm32n06xml() throws IOException { + void testibm_not_wf_P32_ibm32n06xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P32/ibm32n06.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -174,7 +175,7 @@ public void testibm_not_wf_P32_ibm32n06xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P32_ibm32n07xml() throws IOException { + void testibm_not_wf_P32_ibm32n07xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P32/ibm32n07.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -195,7 +196,7 @@ public void testibm_not_wf_P32_ibm32n07xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P32_ibm32n08xml() throws IOException { + void testibm_not_wf_P32_ibm32n08xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P32/ibm32n08.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -218,7 +219,8 @@ public void testibm_not_wf_P32_ibm32n08xml() throws IOException { * * NOTE: This test is SKIPPED as MXParser does not support parsing inside DOCTYPEDECL. */ - // @Test + @Test + @Disabled public void testibm_not_wf_P32_ibm32n09xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P32/ibm32n09.xml"))) { parser.setInput(reader); diff --git a/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production66_Test.java b/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production66_Test.java index debe5971..c08b1142 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 9581bedc..a2b2c165 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 2d3ecefa..9c3e5804 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/pull/MXParserTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/pull/MXParserTest.java @@ -22,11 +22,13 @@ import java.io.InputStream; import java.io.Reader; import java.io.StringReader; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.xml.ReaderFactory; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -41,14 +43,14 @@ * @version $Id: $Id * @since 3.4.0 */ -public class MXParserTest { +class MXParserTest { /** *

    testHexadecimalEntities.

    * * @throws java.lang.Exception if any. */ @Test - public void testHexadecimalEntities() throws Exception { + void hexadecimalEntities() throws Exception { MXParser parser = new MXParser(); parser.defineEntityReplacementText("test", "replacement"); @@ -72,7 +74,7 @@ public void testHexadecimalEntities() throws Exception { * @throws java.lang.Exception if any. */ @Test - public void testDecimalEntities() throws Exception { + void decimalEntities() throws Exception { MXParser parser = new MXParser(); parser.defineEntityReplacementText("test", "replacement"); @@ -96,7 +98,7 @@ public void testDecimalEntities() throws Exception { * @throws java.lang.Exception if any. */ @Test - public void testPredefinedEntities() throws Exception { + void predefinedEntities() throws Exception { MXParser parser = new MXParser(); parser.defineEntityReplacementText("test", "replacement"); @@ -121,7 +123,7 @@ public void testPredefinedEntities() throws Exception { * @throws java.io.IOException if any. */ @Test - public void testEntityReplacementMap() throws XmlPullParserException, IOException { + void entityReplacementMap() throws XmlPullParserException, IOException { EntityReplacementMap erm = new EntityReplacementMap(new String[][] {{"abc", "CDE"}, {"EFG", "HIJ"}}); MXParser parser = new MXParser(erm); @@ -140,7 +142,7 @@ public void testEntityReplacementMap() throws XmlPullParserException, IOExceptio * @throws java.lang.Exception if any. */ @Test - public void testCustomEntities() throws Exception { + void customEntities() throws Exception { MXParser parser = new MXParser(); String input = "&myentity;"; @@ -168,7 +170,7 @@ public void testCustomEntities() throws Exception { * @throws java.lang.Exception if any. */ @Test - public void testUnicodeEntities() throws Exception { + void unicodeEntities() throws Exception { MXParser parser = new MXParser(); String input = "𝟭"; parser.setInput(new StringReader(input)); @@ -194,7 +196,7 @@ public void testUnicodeEntities() throws Exception { * @throws java.lang.Exception if any. */ @Test - public void testInvalidCharacterReferenceHexa() throws Exception { + void invalidCharacterReferenceHexa() throws Exception { MXParser parser = new MXParser(); String input = ""; parser.setInput(new StringReader(input)); @@ -214,42 +216,42 @@ public void testInvalidCharacterReferenceHexa() throws Exception { * @throws java.lang.Exception if any. */ @Test - public void testValidCharacterReferenceHexa() throws Exception { + void validCharacterReferenceHexa() throws Exception { MXParser parser = new MXParser(); String input = " Ȁ퟿ᄁ�𐀀􏿽􏿿"; parser.setInput(new StringReader(input)); - try { - assertEquals(XmlPullParser.START_TAG, parser.nextToken()); - assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); - assertEquals(0x9, parser.getText().codePointAt(0)); - assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); - assertEquals(0xA, parser.getText().codePointAt(0)); - assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); - assertEquals(0xD, parser.getText().codePointAt(0)); - assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); - assertEquals(0x20, parser.getText().codePointAt(0)); - assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); - assertEquals(0x200, parser.getText().codePointAt(0)); - assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); - assertEquals(0xD7FF, parser.getText().codePointAt(0)); - assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); - assertEquals(0xE000, parser.getText().codePointAt(0)); - assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); - assertEquals(0xFFA2, parser.getText().codePointAt(0)); - assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); - assertEquals(0xFFFD, parser.getText().codePointAt(0)); - assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); - assertEquals(0x10000, parser.getText().codePointAt(0)); - assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); - assertEquals(0x10FFFD, parser.getText().codePointAt(0)); - assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); - assertEquals(0x10FFFF, parser.getText().codePointAt(0)); - assertEquals(XmlPullParser.END_TAG, parser.nextToken()); - } catch (XmlPullParserException e) { - fail("Should success since the input represents all legal character references"); - } + Assertions.assertDoesNotThrow( + () -> { + assertEquals(XmlPullParser.START_TAG, parser.nextToken()); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(0x9, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(0xA, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(0xD, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(0x20, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(0x200, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(0xD7FF, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(0xE000, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(0xFFA2, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(0xFFFD, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(0x10000, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(0x10FFFD, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(0x10FFFF, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.END_TAG, parser.nextToken()); + }, + "Should success since the input represents all legal character references"); } /** @@ -258,7 +260,7 @@ public void testValidCharacterReferenceHexa() throws Exception { * @throws java.lang.Exception if any. */ @Test - public void testInvalidCharacterReferenceDecimal() throws Exception { + void invalidCharacterReferenceDecimal() throws Exception { MXParser parser = new MXParser(); String input = ""; parser.setInput(new StringReader(input)); @@ -278,42 +280,42 @@ public void testInvalidCharacterReferenceDecimal() throws Exception { * @throws java.lang.Exception if any. */ @Test - public void testValidCharacterReferenceDecimal() throws Exception { + void validCharacterReferenceDecimal() throws Exception { MXParser parser = new MXParser(); String input = " Ȁ퟿ᄁ�𐀀􏿽􏿿"; parser.setInput(new StringReader(input)); - try { - assertEquals(XmlPullParser.START_TAG, parser.nextToken()); - assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); - assertEquals(9, parser.getText().codePointAt(0)); - assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); - assertEquals(10, parser.getText().codePointAt(0)); - assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); - assertEquals(13, parser.getText().codePointAt(0)); - assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); - assertEquals(32, parser.getText().codePointAt(0)); - assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); - assertEquals(512, parser.getText().codePointAt(0)); - assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); - assertEquals(55295, parser.getText().codePointAt(0)); - assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); - assertEquals(57344, parser.getText().codePointAt(0)); - assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); - assertEquals(65442, parser.getText().codePointAt(0)); - assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); - assertEquals(65533, parser.getText().codePointAt(0)); - assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); - assertEquals(65536, parser.getText().codePointAt(0)); - assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); - assertEquals(1114109, parser.getText().codePointAt(0)); - assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); - assertEquals(1114111, parser.getText().codePointAt(0)); - assertEquals(XmlPullParser.END_TAG, parser.nextToken()); - } catch (XmlPullParserException e) { - fail("Should success since the input represents all legal character references"); - } + Assertions.assertDoesNotThrow( + () -> { + assertEquals(XmlPullParser.START_TAG, parser.nextToken()); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(9, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(10, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(13, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(32, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(512, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(55295, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(57344, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(65442, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(65533, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(65536, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(1114109, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(1114111, parser.getText().codePointAt(0)); + assertEquals(XmlPullParser.END_TAG, parser.nextToken()); + }, + "Should success since the input represents all legal character references"); } /** @@ -322,7 +324,7 @@ public void testValidCharacterReferenceDecimal() throws Exception { * @throws java.lang.Exception if any. */ @Test - public void testParserPosition() throws Exception { + void parserPosition() throws Exception { String input = " \n \tnnn\n"; @@ -350,7 +352,7 @@ public void testParserPosition() throws Exception { } @Test - public void testProcessingInstruction() throws Exception { + void processingInstruction() throws Exception { String input = "nnn"; MXParser parser = new MXParser(); @@ -368,19 +370,17 @@ public void testProcessingInstruction() throws Exception { * @throws java.lang.Exception if any. */ @Test - public void testProcessingInstructionsContainingXml() throws Exception { - StringBuffer sb = new StringBuffer(); + void processingInstructionsContainingXml() throws Exception { - sb.append(""); - sb.append("\n"); - sb.append(" \n"); - sb.append(" \n"); - sb.append(" ?>\n"); - sb.append(""); + String sb = "" + "\n" + + " \n" + + " \n" + + " ?>\n" + + ""; MXParser parser = new MXParser(); - parser.setInput(new StringReader(sb.toString())); + parser.setInput(new StringReader(sb)); assertEquals(XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken()); assertEquals(XmlPullParser.START_TAG, parser.nextToken()); @@ -396,16 +396,14 @@ public void testProcessingInstructionsContainingXml() throws Exception { * @throws java.lang.Exception if any. */ @Test - public void testMalformedProcessingInstructionsContainingXmlNoClosingQuestionMark() throws Exception { - StringBuffer sb = new StringBuffer(); - sb.append("\n"); - sb.append("\n"); - sb.append("\n"); - sb.append(" >\n"); + void malformedProcessingInstructionsContainingXmlNoClosingQuestionMark() throws Exception { + String sb = "\n" + "\n" + + "\n" + + " >\n"; MXParser parser = new MXParser(); - parser.setInput(new StringReader(sb.toString())); + parser.setInput(new StringReader(sb)); try { assertEquals(XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken()); @@ -423,17 +421,15 @@ public void testMalformedProcessingInstructionsContainingXmlNoClosingQuestionMar } @Test - public void testSubsequentProcessingInstructionShort() throws Exception { - StringBuffer sb = new StringBuffer(); + void subsequentProcessingInstructionShort() throws Exception { - sb.append(""); - sb.append(""); - sb.append(""); - sb.append(""); - sb.append(""); + String sb = "" + "" + + "" + + "" + + ""; MXParser parser = new MXParser(); - parser.setInput(new StringReader(sb.toString())); + parser.setInput(new StringReader(sb)); assertEquals(XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken()); assertEquals(XmlPullParser.START_TAG, parser.nextToken()); @@ -448,8 +444,8 @@ public void testSubsequentProcessingInstructionShort() throws Exception { * @throws java.lang.Exception if any. */ @Test - public void testSubsequentProcessingInstructionMoreThan8k() throws Exception { - StringBuffer sb = new StringBuffer(); + void subsequentProcessingInstructionMoreThan8k() throws Exception { + StringBuilder sb = new StringBuilder(); sb.append(""); sb.append(""); @@ -492,18 +488,17 @@ public void testSubsequentProcessingInstructionMoreThan8k() throws Exception { * @throws java.lang.Exception if any. */ @Test - public void testLargeText_NoOverflow() throws Exception { - StringBuffer sb = new StringBuffer(); - sb.append(""); - sb.append(""); - // Anything above 33,554,431 would fail without a fix for - // https://web.archive.org/web/20070831191548/http://www.extreme.indiana.edu/bugzilla/show_bug.cgi?id=228 - // with java.io.IOException: error reading input, returned 0 - sb.append(new String(new char[33554432])); - sb.append(""); + void largeTextNoOverflow() throws Exception { + String sb = "" + "" + + + // Anything above 33,554,431 would fail without a fix for + // https://web.archive.org/web/20070831191548/http://www.extreme.indiana.edu/bugzilla/show_bug.cgi?id=228 + // with java.io.IOException: error reading input, returned 0 + new String(new char[33554432]) + + ""; MXParser parser = new MXParser(); - parser.setInput(new StringReader(sb.toString())); + parser.setInput(new StringReader(sb)); assertEquals(XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken()); assertEquals(XmlPullParser.START_TAG, parser.nextToken()); @@ -517,7 +512,7 @@ public void testLargeText_NoOverflow() throws Exception { * @throws java.lang.Exception if any. */ @Test - public void testMalformedProcessingInstructionAfterTag() throws Exception { + void malformedProcessingInstructionAfterTag() throws Exception { MXParser parser = new MXParser(); String input = ""; @@ -543,7 +538,7 @@ public void testMalformedProcessingInstructionAfterTag() throws Exception { * @throws java.lang.Exception if any. */ @Test - public void testMalformedProcessingInstructionBeforeTag() throws Exception { + void malformedProcessingInstructionBeforeTag() throws Exception { MXParser parser = new MXParser(); String input = ""; @@ -569,14 +564,12 @@ public void testMalformedProcessingInstructionBeforeTag() throws Exception { * @throws java.lang.Exception if any. */ @Test - public void testMalformedProcessingInstructionSpaceBeforeName() throws Exception { + void malformedProcessingInstructionSpaceBeforeName() throws Exception { MXParser parser = new MXParser(); - StringBuilder sb = new StringBuilder(); - sb.append(""); - sb.append(""); + String sb = "" + ""; - parser.setInput(new StringReader(sb.toString())); + parser.setInput(new StringReader(sb)); try { assertEquals(XmlPullParser.PROCESSING_INSTRUCTION, parser.next()); @@ -599,14 +592,12 @@ public void testMalformedProcessingInstructionSpaceBeforeName() throws Exception * @throws java.lang.Exception if any. */ @Test - public void testMalformedProcessingInstructionNoClosingQuestionMark() throws Exception { + void malformedProcessingInstructionNoClosingQuestionMark() throws Exception { MXParser parser = new MXParser(); - StringBuilder sb = new StringBuilder(); - sb.append(""); - sb.append(""); + String sb = "" + ""; - parser.setInput(new StringReader(sb.toString())); + parser.setInput(new StringReader(sb)); try { assertEquals(XmlPullParser.PROCESSING_INSTRUCTION, parser.next()); @@ -628,14 +619,12 @@ public void testMalformedProcessingInstructionNoClosingQuestionMark() throws Exc * @throws java.lang.Exception if any. */ @Test - public void testSubsequentMalformedProcessingInstructionNoClosingQuestionMark() throws Exception { + void subsequentMalformedProcessingInstructionNoClosingQuestionMark() throws Exception { MXParser parser = new MXParser(); - StringBuilder sb = new StringBuilder(); - sb.append(""); - sb.append(""); + String sb = "" + ""; - parser.setInput(new StringReader(sb.toString())); + parser.setInput(new StringReader(sb)); try { assertEquals(XmlPullParser.START_TAG, parser.next()); @@ -657,13 +646,11 @@ public void testSubsequentMalformedProcessingInstructionNoClosingQuestionMark() * @throws java.lang.Exception if any. */ @Test - public void testSubsequentAbortedProcessingInstruction() throws Exception { + void subsequentAbortedProcessingInstruction() throws Exception { MXParser parser = new MXParser(); - StringBuilder sb = new StringBuilder(); - sb.append(""); - sb.append("" + ""); - sb.append("  

    "; - try { - MXParser parser = new MXParser(); - parser.setInput(new StringReader(input)); - parser.defineEntityReplacementText("nbsp", " "); - - assertEquals(XmlPullParser.START_TAG, parser.nextToken()); - assertEquals("p", parser.getName()); - assertEquals(XmlPullParser.COMMENT, parser.nextToken()); - assertEquals(" a pagebreak: ", parser.getText()); - assertEquals(XmlPullParser.COMMENT, parser.nextToken()); - assertEquals(" PB ", parser.getText()); - assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); - assertEquals("\u00A0", parser.getText()); - assertEquals("#160", parser.getName()); - assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); - assertEquals(" ", parser.getText()); - assertEquals("nbsp", parser.getName()); - assertEquals(XmlPullParser.START_TAG, parser.nextToken()); - assertEquals("unknown", parser.getName()); - assertEquals(XmlPullParser.END_TAG, parser.nextToken()); - assertEquals("unknown", parser.getName()); - assertEquals(XmlPullParser.END_TAG, parser.nextToken()); - assertEquals("p", parser.getName()); - assertEquals(XmlPullParser.END_DOCUMENT, parser.nextToken()); - } catch (XmlPullParserException e) { - fail("should not raise exception: " + e); - } + Assertions.assertDoesNotThrow( + () -> { + MXParser parser = new MXParser(); + parser.setInput(new StringReader(input)); + parser.defineEntityReplacementText("nbsp", " "); + + assertEquals(XmlPullParser.START_TAG, parser.nextToken()); + assertEquals("p", parser.getName()); + assertEquals(XmlPullParser.COMMENT, parser.nextToken()); + assertEquals(" a pagebreak: ", parser.getText()); + assertEquals(XmlPullParser.COMMENT, parser.nextToken()); + assertEquals(" PB ", parser.getText()); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals("\u00A0", parser.getText()); + assertEquals("#160", parser.getName()); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals(" ", parser.getText()); + assertEquals("nbsp", parser.getName()); + assertEquals(XmlPullParser.START_TAG, parser.nextToken()); + assertEquals("unknown", parser.getName()); + assertEquals(XmlPullParser.END_TAG, parser.nextToken()); + assertEquals("unknown", parser.getName()); + assertEquals(XmlPullParser.END_TAG, parser.nextToken()); + assertEquals("p", parser.getName()); + assertEquals(XmlPullParser.END_DOCUMENT, parser.nextToken()); + }, + "should not raise exception: "); } /** * Ensures correct replacements inside the internal PC array when the new copied array size is shorter than * previous ones. - * + *

    * Regression test: assure same behavior of MXParser from plexus-utils 3.3.0. * * @throws IOException if any. @@ -1303,50 +1284,50 @@ public void testEntityReplacement() throws IOException { * @since 3.4.2 */ @Test - public void testReplacementInPCArrayWithShorterCharArray() throws IOException { + void replacementInPCArrayWithShorterCharArray() throws IOException { String input = "]>" + "

    &&foo;&tritPos;

    "; - try { - MXParser parser = new MXParser(); - parser.setInput(new StringReader(new String(input.getBytes(), "ISO-8859-1"))); - parser.defineEntityReplacementText("foo", "ř"); - parser.defineEntityReplacementText("tritPos", "𝟭"); - - assertEquals(XmlPullParser.DOCDECL, parser.nextToken()); - assertEquals(" test []", parser.getText()); - assertEquals(XmlPullParser.START_TAG, parser.nextToken()); - assertEquals("section", parser.getName()); - assertEquals(1, parser.getAttributeCount()); - assertEquals("name", parser.getAttributeName(0)); - assertEquals("&ř𝟭", parser.getAttributeValue(0)); - assertEquals(XmlPullParser.START_TAG, parser.nextToken()); - assertEquals("

    ", parser.getText()); - assertEquals("p", parser.getName()); - assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); - assertEquals("&", parser.getText()); - assertEquals("amp", parser.getName()); - assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); - assertEquals("ř", parser.getText()); - assertEquals("foo", parser.getName()); - assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); - assertEquals("𝟭", parser.getText()); - assertEquals("tritPos", parser.getName()); - assertEquals(XmlPullParser.END_TAG, parser.nextToken()); - assertEquals("p", parser.getName()); - assertEquals(XmlPullParser.END_TAG, parser.nextToken()); - assertEquals("section", parser.getName()); - assertEquals(XmlPullParser.END_DOCUMENT, parser.nextToken()); - } catch (XmlPullParserException e) { - fail("should not raise exception: " + e); - } + Assertions.assertDoesNotThrow( + () -> { + MXParser parser = new MXParser(); + parser.setInput(new StringReader(new String(input.getBytes(), StandardCharsets.ISO_8859_1))); + parser.defineEntityReplacementText("foo", "ř"); + parser.defineEntityReplacementText("tritPos", "𝟭"); + + assertEquals(XmlPullParser.DOCDECL, parser.nextToken()); + assertEquals(" test []", parser.getText()); + assertEquals(XmlPullParser.START_TAG, parser.nextToken()); + assertEquals("section", parser.getName()); + assertEquals(1, parser.getAttributeCount()); + assertEquals("name", parser.getAttributeName(0)); + assertEquals("&ř𝟭", parser.getAttributeValue(0)); + assertEquals(XmlPullParser.START_TAG, parser.nextToken()); + assertEquals("

    ", parser.getText()); + assertEquals("p", parser.getName()); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals("&", parser.getText()); + assertEquals("amp", parser.getName()); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals("ř", parser.getText()); + assertEquals("foo", parser.getName()); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertEquals("𝟭", parser.getText()); + assertEquals("tritPos", parser.getName()); + assertEquals(XmlPullParser.END_TAG, parser.nextToken()); + assertEquals("p", parser.getName()); + assertEquals(XmlPullParser.END_TAG, parser.nextToken()); + assertEquals("section", parser.getName()); + assertEquals(XmlPullParser.END_DOCUMENT, parser.nextToken()); + }, + "should not raise exception: "); } /** * Ensures emoji can be parsed correctly */ @Test - public void testUnicode() throws IOException { + void unicode() throws IOException { String input = ""; try { diff --git a/src/test/java/org/codehaus/plexus/util/xml/pull/MXSerializerTest.java b/src/test/java/org/codehaus/plexus/util/xml/pull/MXSerializerTest.java index 0b1d3d7f..abfcb62a 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/pull/MXSerializerTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/pull/MXSerializerTest.java @@ -12,7 +12,7 @@ class MXSerializerTest { @Test - void testSerialize() throws Exception { + void serialize() throws Exception { StringWriter writer = new StringWriter(); @@ -33,7 +33,7 @@ void testSerialize() throws Exception { } @Test - void testDeserialize() throws Exception { + void deserialize() throws Exception { MXParser parser = new MXParser(); parser.setInput(new StringReader(expectedOutput())); int eventType = parser.getEventType(); @@ -44,24 +44,21 @@ void testDeserialize() throws Exception { } private String expectedOutput() { - StringBuilder out = new StringBuilder(); - out.append(""); - out.append(""); - out.append("BACKSPACE: "); - out.append("CHARACTER TABULATION: \t"); - out.append("LINE FEED (LF): \n"); - out.append("LINE TABULATION: "); - out.append("CARRIAGE RETURN (CR): \r"); - out.append("SHIFT IN: "); - out.append(""); - return out.toString(); + return "" + "" + + "BACKSPACE: " + + "CHARACTER TABULATION: \t" + + "LINE FEED (LF): \n" + + "LINE TABULATION: " + + "CARRIAGE RETURN (CR): \r" + + "SHIFT IN: " + + ""; } /** * Tests MJAVADOC-793. */ @Test - public void testWriteNullValues() throws IOException { + void writeNullValues() throws IOException { // should be no-ops new MXSerializer().writeElementContent(null, null); new MXSerializer().writeAttributeValue(null, null); diff --git a/src/test/java/org/codehaus/plexus/util/xml/pull/eduni_misc_Test_BjoernHoehrmannviaHST2013_09_18_Test.java b/src/test/java/org/codehaus/plexus/util/xml/pull/eduni_misc_Test_BjoernHoehrmannviaHST2013_09_18_Test.java index 65286c5c..a419ac0f 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/pull/eduni_misc_Test_BjoernHoehrmannviaHST2013_09_18_Test.java +++ b/src/test/java/org/codehaus/plexus/util/xml/pull/eduni_misc_Test_BjoernHoehrmannviaHST2013_09_18_Test.java @@ -9,6 +9,7 @@ import java.nio.charset.StandardCharsets; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -33,7 +34,7 @@ public class eduni_misc_Test_BjoernHoehrmannviaHST2013_09_18_Test { *

    setUp.

    */ @BeforeEach - public void setUp() { + void setUp() { parser = new MXParser(); } @@ -47,7 +48,7 @@ public void setUp() { * @throws java.io.IOException if there is an I/O error */ @Test - public void testhst_bh_001() throws IOException { + void testhst_bh_001() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "001.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -68,7 +69,7 @@ public void testhst_bh_001() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testhst_bh_002() throws IOException { + void testhst_bh_002() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "002.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -89,7 +90,7 @@ public void testhst_bh_002() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testhst_bh_003() throws IOException { + void testhst_bh_003() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "003.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -110,7 +111,7 @@ public void testhst_bh_003() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testhst_bh_004() throws IOException { + void testhst_bh_004() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "004.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -133,7 +134,8 @@ public void testhst_bh_004() throws IOException { * * NOTE: This test is SKIPPED as MXParser do not supports DOCDECL parsing. */ - // @Test + @Test + @Disabled public void testhst_bh_005() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "005.xml"))) { parser.setInput(reader); @@ -156,7 +158,8 @@ public void testhst_bh_005() throws IOException { * * NOTE: This test is SKIPPED as MXParser do not supports DOCDECL parsing. */ - // @Test + @Test + @Disabled public void testhst_bh_006() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "006.xml"))) { parser.setInput(reader); @@ -178,7 +181,7 @@ public void testhst_bh_006() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testhst_lhs_007() throws IOException { + void testhst_lhs_007() throws IOException { try (FileInputStream is = new FileInputStream(new File(testResourcesDir, "007.xml")); InputStreamReader reader = new InputStreamReader(is, StandardCharsets.UTF_8)) { parser.setInput(reader); @@ -200,7 +203,7 @@ public void testhst_lhs_007() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testhst_lhs_008() throws IOException { + void testhst_lhs_008() throws IOException { try (FileInputStream is = new FileInputStream(new File(testResourcesDir, "008.xml")); InputStreamReader reader = new InputStreamReader(is, StandardCharsets.UTF_16)) { parser.setInput(reader); @@ -222,7 +225,7 @@ public void testhst_lhs_008() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testhst_lhs_009() throws IOException { + void testhst_lhs_009() throws IOException { try (FileInputStream is = new FileInputStream(new File(testResourcesDir, "009.xml")); InputStreamReader reader = new InputStreamReader(is, StandardCharsets.UTF_8)) { parser.setInput(reader); From 0ce8ed3ae22bfe16555bd4e31609a843f54f23a4 Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Mon, 16 Dec 2024 00:25:31 +0100 Subject: [PATCH 30/36] Cleanup tests and drop dependency to plexus-utils --- pom.xml | 6 -- .../util/xml/PrettyPrintXMLWriterTest.java | 37 +++++----- .../codehaus/plexus/util/xml/TestUtils.java | 47 +++++++++++++ .../plexus/util/xml/XmlStreamReaderTest.java | 11 ++- .../plexus/util/xml/XmlStreamWriterTest.java | 3 +- .../codehaus/plexus/util/xml/XmlUtilTest.java | 68 ++++++------------- .../plexus/util/xml/XmlWriterUtilTest.java | 28 ++++---- .../codehaus/plexus/util/xml/Xpp3DomTest.java | 37 ++++------ .../plexus/util/xml/pull/MXParserTest.java | 10 +-- 9 files changed, 118 insertions(+), 129 deletions(-) create mode 100644 src/test/java/org/codehaus/plexus/util/xml/TestUtils.java diff --git a/pom.xml b/pom.xml index 1b9dbcc2..38745b02 100644 --- a/pom.xml +++ b/pom.xml @@ -70,12 +70,6 @@ limitations under the License. junit-jupiter-api test
    - - org.codehaus.plexus - plexus-utils - 4.0.2 - test - diff --git a/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java b/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java index 6c7736fb..c5d8bd9f 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java @@ -26,9 +26,9 @@ import java.nio.file.Files; import java.util.NoSuchElementException; -import org.codehaus.plexus.util.StringUtils; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -172,6 +172,7 @@ void testendElementAlreadyClosed() { * * @throws IOException if an I/O error occurs */ + @Disabled("This test is only relevant on JDK 1.7, which is not supported anymore") @Test void issue51DetectJava7ConcatenationBug() throws IOException { File dir = new File("target/test-xml"); @@ -179,13 +180,11 @@ void issue51DetectJava7ConcatenationBug() throws IOException { assertTrue(dir.mkdir(), "cannot create directory test-xml"); } File xmlFile = new File(dir, "test-issue-51.xml"); - OutputStreamWriter osw = - new OutputStreamWriter(Files.newOutputStream(xmlFile.toPath()), StandardCharsets.UTF_8); - writer = new PrettyPrintXMLWriter(osw); int iterations = 20000; - - try { + try (OutputStreamWriter osw = + new OutputStreamWriter(Files.newOutputStream(xmlFile.toPath()), StandardCharsets.UTF_8)) { + writer = new PrettyPrintXMLWriter(osw); for (int i = 0; i < iterations; ++i) { writer.startElement(Tag.DIV.toString() + i); writer.addAttribute("class", "someattribute"); @@ -195,10 +194,6 @@ void issue51DetectJava7ConcatenationBug() throws IOException { } } catch (NoSuchElementException e) { fail("Should not throw a NoSuchElementException"); - } finally { - if (osw != null) { - osw.close(); - } } } @@ -237,29 +232,29 @@ private String expectedResult(String lineSeparator) { } private String expectedResult(String lineIndenter, String lineSeparator) { - return "" + lineSeparator + StringUtils.repeat(lineIndenter, 1) - + "" + lineSeparator + StringUtils.repeat(lineIndenter, 2) + return "" + lineSeparator + lineIndenter + + "" + lineSeparator + lineIndenter + lineIndenter + "title" + lineSeparator - + StringUtils.repeat(lineIndenter, 2) + + lineIndenter + lineIndenter + "" + lineSeparator - + StringUtils.repeat(lineIndenter, 2) + + lineIndenter + lineIndenter + "" + lineSeparator - + StringUtils.repeat(lineIndenter, 1) - + "" + lineSeparator + StringUtils.repeat(lineIndenter, 1) - + "" + lineSeparator + StringUtils.repeat(lineIndenter, 2) + + lineIndenter + + "" + lineSeparator + lineIndenter + + "" + lineSeparator + lineIndenter + lineIndenter + "

    Paragraph 1, line 1. Paragraph 1, line 2.

    " + lineSeparator - + StringUtils.repeat(lineIndenter, 2) + + lineIndenter + lineIndenter + "
    " + lineSeparator - + StringUtils.repeat(lineIndenter, 3) + + lineIndenter + lineIndenter + lineIndenter + "

    Section title

    " + lineSeparator - + StringUtils.repeat(lineIndenter, 2) - + "
    " + lineSeparator + StringUtils.repeat(lineIndenter, 1) + + lineIndenter + lineIndenter + + "" + lineSeparator + lineIndenter + "" + lineSeparator + ""; } } diff --git a/src/test/java/org/codehaus/plexus/util/xml/TestUtils.java b/src/test/java/org/codehaus/plexus/util/xml/TestUtils.java new file mode 100644 index 00000000..b824d1e1 --- /dev/null +++ b/src/test/java/org/codehaus/plexus/util/xml/TestUtils.java @@ -0,0 +1,47 @@ +package org.codehaus.plexus.util.xml; + +import java.io.IOException; +import java.io.Reader; +import java.io.StringWriter; + +public class TestUtils { + + public static String readAllFrom(Reader input) throws IOException { + StringWriter output = new StringWriter(); + char[] buffer = new char[16384]; + int n = 0; + while (0 <= (n = input.read(buffer))) { + output.write(buffer, 0, n); + } + output.flush(); + return output.toString(); + } + /** + *

    + * How many times is the substring in the larger String. + *

    + *

    + * null returns 0. + *

    + * + * @param str the String to check + * @param sub the substring to count + * @return the number of occurrences, 0 if the String is null + * @throws NullPointerException if sub is null + */ + public static int countMatches(String str, String sub) { + if (sub.isEmpty()) { + return 0; + } + if (str == null) { + return 0; + } + int count = 0; + int idx = 0; + while ((idx = str.indexOf(sub, idx)) != -1) { + count++; + idx += sub.length(); + } + return count; + } +} diff --git a/src/test/java/org/codehaus/plexus/util/xml/XmlStreamReaderTest.java b/src/test/java/org/codehaus/plexus/util/xml/XmlStreamReaderTest.java index 0ce093e8..438a1394 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/XmlStreamReaderTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/XmlStreamReaderTest.java @@ -21,10 +21,10 @@ import java.io.InputStream; import java.io.SequenceInputStream; -import org.codehaus.plexus.util.IOUtil; import org.junit.jupiter.api.Test; import org.opentest4j.AssertionFailedError; +import static org.codehaus.plexus.util.xml.TestUtils.readAllFrom; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -68,8 +68,7 @@ private static String createXmlContent(String text, String encoding) { if (encoding != null) { xmlDecl = ""; } - String xml = xmlDecl + "\n" + text + ""; - return xml; + return xmlDecl + "\n" + text + ""; } private static void checkXmlContent(String xml, String encoding) throws IOException { @@ -86,8 +85,7 @@ private static void checkXmlContent(String xml, String encoding, byte... bom) th XmlStreamReader reader = new XmlStreamReader(in); assertEquals(encoding, reader.getEncoding()); - String result = IOUtil.toString(reader); - assertEquals(xml, result); + assertEquals(xml, readAllFrom(reader)); } private static void checkXmlStreamReader(String text, String encoding, String effectiveEncoding) @@ -228,10 +226,9 @@ void ebcdicEncoding() throws IOException { /** *

    testInappropriateEncoding.

    * - * @throws java.io.IOException if any. */ @Test - void inappropriateEncoding() throws IOException { + void inappropriateEncoding() { // expected failure, since the encoding does not contain some characters assertThrows( AssertionFailedError.class, diff --git a/src/test/java/org/codehaus/plexus/util/xml/XmlStreamWriterTest.java b/src/test/java/org/codehaus/plexus/util/xml/XmlStreamWriterTest.java index 6fa531b6..2e59ab99 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/XmlStreamWriterTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/XmlStreamWriterTest.java @@ -52,8 +52,7 @@ private static String createXmlContent(String text, String encoding) { if (encoding != null) { xmlDecl = ""; } - String xml = xmlDecl + "\n" + text + ""; - return xml; + return xmlDecl + "\n" + text + ""; } private static void checkXmlContent(String xml, String encoding) throws IOException { diff --git a/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java b/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java index e6f9f596..d0361dd4 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java @@ -16,19 +16,12 @@ * limitations under the License. */ -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.Reader; -import java.io.StringWriter; -import java.io.Writer; +import java.io.*; import java.nio.file.Files; -import org.codehaus.plexus.util.IOUtil; -import org.codehaus.plexus.util.StringUtils; import org.junit.jupiter.api.Test; +import static org.codehaus.plexus.util.xml.TestUtils.readAllFrom; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -73,20 +66,14 @@ void prettyFormatInputStreamOutputStream() throws Exception { File testDocument = new File(getBasedir(), "src/test/resources/testDocument.xhtml"); assertTrue(testDocument.exists()); - InputStream is = null; - OutputStream os = null; - try { - is = Files.newInputStream(testDocument.toPath()); - os = Files.newOutputStream(getTestOutputFile("target/test/prettyFormatTestDocumentOutputStream.xml") - .toPath()); - + try (InputStream is = Files.newInputStream(testDocument.toPath()); + OutputStream os = + Files.newOutputStream(getTestOutputFile("target/test/prettyFormatTestDocumentOutputStream.xml") + .toPath())) { assertNotNull(is); assertNotNull(os); XmlUtil.prettyFormat(is, os); - } finally { - IOUtil.close(is); - IOUtil.close(os); } } @@ -100,19 +87,14 @@ void prettyFormatReaderWriter() throws Exception { File testDocument = new File(getBasedir(), "src/test/resources/testDocument.xhtml"); assertTrue(testDocument.exists()); - Reader reader = null; - Writer writer = null; - try { - reader = ReaderFactory.newXmlReader(testDocument); - writer = WriterFactory.newXmlWriter(getTestOutputFile("target/test/prettyFormatTestDocumentWriter.xml")); + try (Reader reader = ReaderFactory.newXmlReader(testDocument); + Writer writer = WriterFactory.newXmlWriter( + getTestOutputFile("target/test/prettyFormatTestDocumentWriter.xml"))) { assertNotNull(reader); assertNotNull(writer); XmlUtil.prettyFormat(reader, writer); - } finally { - IOUtil.close(reader); - IOUtil.close(writer); } } @@ -126,25 +108,22 @@ void prettyFormatString() throws Exception { File testDocument = new File(getBasedir(), "src/test/resources/testDocument.xhtml"); assertTrue(testDocument.exists()); - Reader reader = null; - Writer writer = null; String content; - try { - reader = ReaderFactory.newXmlReader(testDocument); - content = IOUtil.toString(reader); + try (Reader reader = ReaderFactory.newXmlReader(testDocument)) { + content = readAllFrom(reader); + } - reader = ReaderFactory.newXmlReader(testDocument); - writer = new StringWriter(); + String contentPretty; + try (Reader reader = ReaderFactory.newXmlReader(testDocument)) { + Writer writer = new StringWriter(); XmlUtil.prettyFormat(reader, writer); - } finally { - IOUtil.close(reader); - IOUtil.close(writer); + contentPretty = writer.toString(); } assertNotNull(content); - int countEOL = StringUtils.countMatches(content, XmlUtil.DEFAULT_LINE_SEPARATOR); - assertTrue(countEOL < StringUtils.countMatches(writer.toString(), XmlUtil.DEFAULT_LINE_SEPARATOR)); + int countEOL = TestUtils.countMatches(content, XmlUtil.DEFAULT_LINE_SEPARATOR); + assertTrue(countEOL < TestUtils.countMatches(contentPretty, XmlUtil.DEFAULT_LINE_SEPARATOR)); } /** @@ -157,19 +136,14 @@ void prettyFormatReaderWriter2() throws Exception { File testDocument = new File(getBasedir(), "src/test/resources/test.xdoc.xhtml"); assertTrue(testDocument.exists()); - Reader reader = null; - Writer writer = null; - try { - reader = ReaderFactory.newXmlReader(testDocument); - writer = WriterFactory.newXmlWriter(getTestOutputFile("target/test/prettyFormatTestXdocWriter.xml")); + try (Reader reader = ReaderFactory.newXmlReader(testDocument); + Writer writer = + WriterFactory.newXmlWriter(getTestOutputFile("target/test/prettyFormatTestXdocWriter.xml"))) { assertNotNull(reader); assertNotNull(writer); XmlUtil.prettyFormat(reader, writer); - } finally { - IOUtil.close(reader); - IOUtil.close(writer); } } } diff --git a/src/test/java/org/codehaus/plexus/util/xml/XmlWriterUtilTest.java b/src/test/java/org/codehaus/plexus/util/xml/XmlWriterUtilTest.java index ff078f5a..7a4cea49 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/XmlWriterUtilTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/XmlWriterUtilTest.java @@ -20,7 +20,6 @@ import java.io.OutputStream; import java.io.Writer; -import org.codehaus.plexus.util.StringUtils; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -76,7 +75,7 @@ void tearDown() throws Exception { void writeLineBreakXMLWriter() throws Exception { XmlWriterUtil.writeLineBreak(xmlWriter); writer.close(); - assertEquals(1, StringUtils.countMatches(output.toString(), XmlWriterUtil.LS)); + assertEquals(1, TestUtils.countMatches(output.toString(), XmlWriterUtil.LS)); } /** @@ -89,7 +88,7 @@ void writeLineBreakXMLWriter() throws Exception { void writeLineBreakXMLWriterInt() throws Exception { XmlWriterUtil.writeLineBreak(xmlWriter, 10); writer.close(); - assertEquals(10, StringUtils.countMatches(output.toString(), XmlWriterUtil.LS)); + assertEquals(10, TestUtils.countMatches(output.toString(), XmlWriterUtil.LS)); } /** @@ -102,11 +101,8 @@ void writeLineBreakXMLWriterInt() throws Exception { void writeLineBreakXMLWriterIntInt() throws Exception { XmlWriterUtil.writeLineBreak(xmlWriter, 10, 2); writer.close(); - assertEquals(10, StringUtils.countMatches(output.toString(), XmlWriterUtil.LS)); - assertEquals( - 1, - StringUtils.countMatches( - output.toString(), StringUtils.repeat(" ", 2 * XmlWriterUtil.DEFAULT_INDENTATION_SIZE))); + assertEquals(10, TestUtils.countMatches(output.toString(), XmlWriterUtil.LS)); + assertEquals(1, TestUtils.countMatches(output.toString(), " ")); // } /** @@ -119,8 +115,8 @@ void writeLineBreakXMLWriterIntInt() throws Exception { void writeLineBreakXMLWriterIntIntInt() throws Exception { XmlWriterUtil.writeLineBreak(xmlWriter, 10, 2, 4); writer.close(); - assertEquals(10, StringUtils.countMatches(output.toString(), XmlWriterUtil.LS)); - assertEquals(1, StringUtils.countMatches(output.toString(), StringUtils.repeat(" ", 2 * 4))); + assertEquals(10, TestUtils.countMatches(output.toString(), XmlWriterUtil.LS)); + assertEquals(1, TestUtils.countMatches(output.toString(), " ")); } /** @@ -210,7 +206,7 @@ void writeCommentXMLWriterString() throws Exception { */ @Test void writeCommentXMLWriterStringInt() throws Exception { - String indent = StringUtils.repeat(" ", 2 * XmlWriterUtil.DEFAULT_INDENTATION_SIZE); + String indent = " "; XmlWriterUtil.writeComment(xmlWriter, "hello", 2); writer.close(); @@ -252,7 +248,7 @@ void writeCommentXMLWriterStringInt() throws Exception { */ @Test void writeCommentXMLWriterStringIntInt() throws Exception { - String repeat = StringUtils.repeat(" ", 2 * 4); + String repeat = " "; XmlWriterUtil.writeComment(xmlWriter, "hello", 2, 4); writer.close(); @@ -290,7 +286,7 @@ void writeCommentXMLWriterStringIntInt() throws Exception { */ @Test void writeCommentXMLWriterStringIntIntInt() throws Exception { - String indent = StringUtils.repeat(" ", 2 * 4); + String indent = " "; XmlWriterUtil.writeComment(xmlWriter, "hello", 2, 4, 50); writer.close(); @@ -338,7 +334,7 @@ void writeCommentTextXMLWriterStringInt() throws Exception { tearDown(); setUp(); - String indent = StringUtils.repeat(" ", 2 * 2); + String indent = " "; XmlWriterUtil.writeCommentText( xmlWriter, @@ -379,7 +375,7 @@ void writeCommentTextXMLWriterStringInt() throws Exception { */ @Test void writeCommentTextXMLWriterStringIntInt() throws Exception { - String indent = StringUtils.repeat(" ", 2 * 4); + String indent = " "; XmlWriterUtil.writeCommentText(xmlWriter, "hello", 2, 4); writer.close(); @@ -408,7 +404,7 @@ void writeCommentTextXMLWriterStringIntInt() throws Exception { */ @Test void writeCommentTextXMLWriterStringIntIntInt() throws Exception { - String indent = StringUtils.repeat(" ", 2 * 4); + String indent = " "; XmlWriterUtil.writeCommentText(xmlWriter, "hello", 2, 4, 50); writer.close(); diff --git a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomTest.java b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomTest.java index fdf19dd0..5b213851 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomTest.java @@ -189,18 +189,11 @@ void shouldMergeValuesAtTopLevel() { @Test void nullAttributeNameOrValue() { Xpp3Dom t1 = new Xpp3Dom("top"); - try { - t1.setAttribute("attr", null); - fail("null attribute values shouldn't be allowed"); - } catch (NullPointerException e) { - } - t1.toString(); - try { - t1.setAttribute(null, "value"); - fail("null attribute names shouldn't be allowed"); - } catch (NullPointerException e) { - } - t1.toString(); + assertThrows(NullPointerException.class, () -> t1.setAttribute("attr", null)); + assertNotNull(t1.toString()); + + assertThrows(NullPointerException.class, () -> t1.setAttribute(null, "value")); + assertNotNull(t1.toString()); } /** @@ -227,20 +220,14 @@ void equalsIsNullSafe() throws XmlPullParserException, IOException { Xpp3Dom dom = Xpp3DomBuilder.build(new StringReader(testDom)); Xpp3Dom dom2 = Xpp3DomBuilder.build(new StringReader(testDom)); - try { - dom2.attributes = new HashMap<>(); - dom2.attributes.put("nullValue", null); - dom2.attributes.put(null, "nullKey"); - dom2.childList.clear(); - dom2.childList.add(null); + dom2.attributes = new HashMap<>(); + dom2.attributes.put("nullValue", null); + dom2.attributes.put(null, "nullKey"); + dom2.childList.clear(); + dom2.childList.add(null); - assertNotEquals(dom, dom2); - assertNotEquals(dom2, dom); - - } catch (NullPointerException ex) { - ex.printStackTrace(); - fail("\nNullPointerExceptions should not be thrown."); - } + assertNotEquals(dom, dom2); + assertNotEquals(dom2, dom); } /** diff --git a/src/test/java/org/codehaus/plexus/util/xml/pull/MXParserTest.java b/src/test/java/org/codehaus/plexus/util/xml/pull/MXParserTest.java index 9c3e5804..68a986ca 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/pull/MXParserTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/pull/MXParserTest.java @@ -26,11 +26,11 @@ import java.nio.file.Files; import java.nio.file.Paths; -import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.xml.ReaderFactory; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import static org.codehaus.plexus.util.xml.TestUtils.readAllFrom; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -833,7 +833,7 @@ void xmlDeclVersionEncodingStandaloneNoSpace() throws Exception { } /** - * Issue 163: ... + * Issue 163: Issue 163 * * @throws IOException if IO error. * @@ -854,7 +854,7 @@ void encodingISO88591setInputReader() throws IOException { } /** - * Issue 163: ... + * Issue 163: Issue 163 * * @throws IOException if IO error. * @@ -880,7 +880,7 @@ private static void assertPosition(int row, int col, MXParser parser) { } /** - * Issue 163: ... + * Issue 163: Issue 163 *

    * Another case of bug #163: File encoding information is lost after the input file is copied to a String. * @@ -893,7 +893,7 @@ void encodingISO88591setStringReader() throws IOException { try (Reader reader = ReaderFactory.newXmlReader(new File("src/test/resources/xml", "test-encoding-ISO-8859-1.xml"))) { MXParser parser = new MXParser(); - String xmlFileContents = IOUtil.toString(reader); + String xmlFileContents = readAllFrom(reader); parser.setInput(new StringReader(xmlFileContents)); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) ; From 4ffd4bdd2fe7935f0167781d6d40514da5fcef5b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Feb 2025 15:31:12 +0000 Subject: [PATCH 31/36] Bump org.codehaus.plexus:plexus from 19 to 20 Bumps [org.codehaus.plexus:plexus](https://github.com/codehaus-plexus/plexus-pom) from 19 to 20. - [Release notes](https://github.com/codehaus-plexus/plexus-pom/releases) - [Commits](https://github.com/codehaus-plexus/plexus-pom/commits) --- updated-dependencies: - dependency-name: org.codehaus.plexus:plexus dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 38745b02..6cc71ed5 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ limitations under the License. org.codehaus.plexus plexus - 19 + 20 plexus-xml From 61942bebf67e8695550bd1ae59d3c1fffc356a54 Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Sat, 5 Apr 2025 17:44:00 +0200 Subject: [PATCH 32/36] (doc) Reduce reported warnings --- src/test/java/org/codehaus/plexus/util/xml/Xpp3DomUtilsTest.java | 1 + 1 file changed, 1 insertion(+) 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 64c31430..778af3b6 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomUtilsTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomUtilsTest.java @@ -152,6 +152,7 @@ void preserveDominantEmptyNode() throws XmlPullParserException, IOException { } @Test + @SuppressWarnings("deprecation") void isNotEmptyNegatesIsEmpty() { assertEquals(!Xpp3DomUtils.isEmpty(null), Xpp3DomUtils.isNotEmpty(null)); assertEquals(!Xpp3DomUtils.isEmpty(""), Xpp3DomUtils.isNotEmpty("")); From 474a0e3daca9caeb1f8f72ebf33db44f5ffb3c0c Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Sat, 5 Apr 2025 17:45:16 +0200 Subject: [PATCH 33/36] [maven-release-plugin] prepare release plexus-xml-3.0.2 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 6cc71ed5..10957b7b 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ limitations under the License. plexus-xml - 3.0.2-SNAPSHOT + 3.0.2 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.2 https://github.com/codehaus-plexus/plexus-xml/tree/${project.scm.tag}/ @@ -49,7 +49,7 @@ limitations under the License. 1.37 - 2024-05-21T21:12:10Z + 2025-04-05T15:45:11Z From 03e0ef37f2afcf2942e25851f651dbc698b187cc Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Sat, 5 Apr 2025 17:45:19 +0200 Subject: [PATCH 34/36] [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 10957b7b..1c8fab96 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ limitations under the License. plexus-xml - 3.0.2 + 3.0.3-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 ${project.scm.connection} - plexus-xml-3.0.2 + 3.x https://github.com/codehaus-plexus/plexus-xml/tree/${project.scm.tag}/ @@ -49,7 +49,7 @@ limitations under the License. 1.37 - 2025-04-05T15:45:11Z + 2025-04-05T15:45:19Z From c0418be69f4034c64267efb45260f1b97015f295 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Jun 2025 15:32:34 +0000 Subject: [PATCH 35/36] Bump org.codehaus.plexus:plexus from 20 to 22 Bumps [org.codehaus.plexus:plexus](https://github.com/codehaus-plexus/plexus-pom) from 20 to 22. - [Release notes](https://github.com/codehaus-plexus/plexus-pom/releases) - [Commits](https://github.com/codehaus-plexus/plexus-pom/commits) --- updated-dependencies: - dependency-name: org.codehaus.plexus:plexus dependency-version: '22' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- README.md | 4 +++- pom.xml | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 040ea01b..0e33110f 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,11 @@ Plexus-Xml -============ +========== [![Build Status](https://github.com/codehaus-plexus/plexus-xml/actions/workflows/maven.yml/badge.svg)](https://github.com/codehaus-plexus/plexus-xml/actions) [![Maven Central](https://img.shields.io/maven-central/v/org.codehaus.plexus/plexus-xml.svg?label=Maven%20Central&versionPrefix=3.)](https://search.maven.org/artifact/org.codehaus.plexus/plexus-xml) This library consists of XML classes (`org.codehaus.plexus.util.xml`) that have been extracted from [`plexus-utils`](https://github.com/codehaus-plexus/plexus-utils/) 3: + > `plexus-utils` 3 = `plexus-utils` 4 + `plexus-xml` 3. For publishing [the site](https://codehaus-plexus.github.io/plexus-xml/) do the following: @@ -12,3 +13,4 @@ For publishing [the site](https://codehaus-plexus.github.io/plexus-xml/) do the ``` mvn -Preporting verify site site:stage scm-publish:publish-scm ``` + diff --git a/pom.xml b/pom.xml index 1c8fab96..01d15081 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ limitations under the License. org.codehaus.plexus plexus - 20 + 22 plexus-xml From 25905cb7fe9891ebf1240fb9b0cce26a86d20c85 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Aug 2025 21:34:08 +0000 Subject: [PATCH 36/36] Bump org.codehaus.plexus:plexus from 22 to 23 Bumps [org.codehaus.plexus:plexus](https://github.com/codehaus-plexus/plexus-pom) from 22 to 23. - [Release notes](https://github.com/codehaus-plexus/plexus-pom/releases) - [Commits](https://github.com/codehaus-plexus/plexus-pom/commits) --- updated-dependencies: - dependency-name: org.codehaus.plexus:plexus dependency-version: '23' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 01d15081..70846c7f 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ limitations under the License. org.codehaus.plexus plexus - 22 + 23 plexus-xml