From 0bcfeb7a783eee7931094ee2d70f8ca086aa11dc Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Tue, 4 Apr 2023 14:04:10 +0200 Subject: [PATCH 01/74] Use maven-api-xml and maven-xml-impl as the Xpp3Dom implementation --- pom.xml | 7 +- .../plexus/util/xml/ReaderFactory.java | 221 ---------- .../plexus/util/xml/WriterFactory.java | 176 -------- .../codehaus/plexus/util/xml/XmlReader.java | 21 +- .../plexus/util/xml/XmlStreamReader.java | 21 +- .../org/codehaus/plexus/util/xml/XmlUtil.java | 10 +- .../org/codehaus/plexus/util/xml/Xpp3Dom.java | 393 +++++------------- .../plexus/util/xml/Xpp3DomBuilder.java | 179 +------- .../plexus/util/xml/pull/MXParser.java | 6 +- .../codehaus/plexus/util/xml/XmlUtilTest.java | 56 +-- .../plexus/util/xml/XmlWriterUtilTest.java | 2 +- .../codehaus/plexus/util/xml/Xpp3DomTest.java | 33 +- .../plexus/util/xml/pull/MXParserTest.java | 19 +- 13 files changed, 199 insertions(+), 945 deletions(-) delete mode 100644 src/main/java/org/codehaus/plexus/util/xml/ReaderFactory.java delete mode 100644 src/main/java/org/codehaus/plexus/util/xml/WriterFactory.java diff --git a/pom.xml b/pom.xml index 61e81547..de4e34bf 100644 --- a/pom.xml +++ b/pom.xml @@ -54,10 +54,9 @@ limitations under the License. - org.codehaus.plexus - plexus-utils - 4.0.0-SNAPSHOT - test + org.apache.maven + maven-xml-impl + 4.0.0-alpha-5 org.openjdk.jmh diff --git a/src/main/java/org/codehaus/plexus/util/xml/ReaderFactory.java b/src/main/java/org/codehaus/plexus/util/xml/ReaderFactory.java deleted file mode 100644 index c8c35e18..00000000 --- a/src/main/java/org/codehaus/plexus/util/xml/ReaderFactory.java +++ /dev/null @@ -1,221 +0,0 @@ -package org.codehaus.plexus.util.xml; - -/* - * Copyright The Codehaus Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.io.UnsupportedEncodingException; -import java.net.URL; -import java.nio.charset.Charset; -import java.nio.file.Files; - -/** - * Utility to create Readers from streams, with explicit encoding choice: platform default, XML, or specified. - * - * @author Herve Boutemy - * @see Charset - * @see Supported encodings - * - * @since 1.4.3 - */ -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"; - - /** - * 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"; - - /** - * 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"; - - /** - * 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"; - - /** - * 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"; - - /** - * 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"; - - /** - * The file.encoding System Property. - */ - public static final String FILE_ENCODING = System.getProperty( "file.encoding" ); - - /** - * Create a new Reader with XML encoding detection rules. - * - * @param in not null input stream. - * @return an XML reader instance for the input stream. - * @throws IOException if any. - * @see XmlStreamReader - */ - public static XmlStreamReader newXmlReader( InputStream in ) - throws IOException - { - return new XmlStreamReader( in ); - } - - /** - * Create a new Reader with XML encoding detection rules. - * - * @param file not null file. - * @return an XML reader instance for the input file. - * @throws IOException if any. - * @see XmlStreamReader - */ - public static XmlStreamReader newXmlReader( File file ) - throws IOException - { - return new XmlStreamReader( file ); - } - - /** - * Create a new Reader with XML encoding detection rules. - * - * @param url not null url. - * @return an XML reader instance for the input url. - * @throws IOException if any. - * @see XmlStreamReader - */ - public static XmlStreamReader newXmlReader( URL url ) - throws IOException - { - return new XmlStreamReader( url ); - } - - /** - * Create a new Reader with default platform encoding. - * - * @param in not null input stream. - * @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 ); - } - - /** - * Create a new Reader with default platform encoding. - * - * @param file not null file. - * @return a reader instance for the input file using the default platform charset. - * @throws IOException if any. - * @see Charset#defaultCharset() - */ - public static Reader newPlatformReader( File file ) - throws IOException - { - return Files.newBufferedReader( file.toPath() ); - } - - /** - * Create a new Reader with default platform encoding. - * - * @param url not null url. - * @return a reader instance for the input url using the default platform charset. - * @throws IOException if any. - * @see Charset#defaultCharset() - */ - public static Reader newPlatformReader( URL url ) - throws IOException - { - return new InputStreamReader( url.openStream() ); - } - - /** - * Create a new Reader with specified encoding. - * - * @param in not null input stream. - * @param encoding not null supported encoding. - * @return a reader instance for the input stream using the given encoding. - * @throws UnsupportedEncodingException if any. - * @see Supported encodings - */ - public static Reader newReader( InputStream in, String encoding ) - throws UnsupportedEncodingException - { - return new InputStreamReader( in, encoding ); - } - - /** - * Create a new Reader with specified encoding. Note that there is no buffering on this reader, which favours - * clients that read into large buffers (8K+). - * - * @param file not null file. - * @param encoding not null supported encoding. - * @return a reader instance for the input file using the given 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 ); - } - - /** - * Create a new Reader with specified encoding. - * - * @param url not null url. - * @param encoding not null supported encoding. - * @return a reader instance for the input url using the given encoding. - * @throws IOException if any. - * @see Supported encodings - */ - 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/WriterFactory.java b/src/main/java/org/codehaus/plexus/util/xml/WriterFactory.java deleted file mode 100644 index 9978bfa4..00000000 --- a/src/main/java/org/codehaus/plexus/util/xml/WriterFactory.java +++ /dev/null @@ -1,176 +0,0 @@ -package org.codehaus.plexus.util.xml; - -/* - * Copyright The Codehaus Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.io.File; -import java.io.IOException; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.UnsupportedEncodingException; -import java.io.Writer; -import java.nio.charset.Charset; -import java.nio.file.Files; - -/** - * Utility to create Writers, with explicit encoding choice: platform default, XML, or specified. - * - * @author Herve Boutemy - * @see Charset - * @see Supported encodings - * - * @since 1.4.4 - */ -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"; - - /** - * 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"; - - /** - * 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"; - - /** - * 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"; - - /** - * 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"; - - /** - * 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"; - - /** - * The file.encoding System Property. - */ - public static final String FILE_ENCODING = System.getProperty( "file.encoding" ); - - /** - * Create a new Writer with XML encoding detection rules. - * - * @param out not null output stream. - * @return an XML writer instance for the output stream. - * @throws IOException if any. - * @see XmlStreamWriter - */ - public static XmlStreamWriter newXmlWriter( OutputStream out ) - throws IOException - { - return new XmlStreamWriter( out ); - } - - /** - * Create a new Writer with XML encoding detection rules. - * - * @param file not null file. - * @return an XML writer instance for the output file. - * @throws IOException if any. - * @see XmlStreamWriter - */ - public static XmlStreamWriter newXmlWriter( File file ) - throws IOException - { - return new XmlStreamWriter( file ); - } - - /** - * Create a new Writer with default platform encoding. - * - * @param out not null output stream. - * @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 ); - } - - /** - * Create a new Writer with default platform encoding. - * - * @param file not null file. - * @return a writer instance for the output file using the default platform charset. - * @throws IOException if any. - * @see Charset#defaultCharset() - */ - public static Writer newPlatformWriter( File file ) - throws IOException - { - return Files.newBufferedWriter( file.toPath() ); - } - - /** - * Create a new Writer with specified encoding. - * - * @param out not null output stream. - * @param encoding not null supported encoding. - * @return a writer instance for the output stream using the given encoding. - * @throws UnsupportedEncodingException if any. - * @see Supported encodings - */ - public static Writer newWriter( OutputStream out, String encoding ) - throws UnsupportedEncodingException - { - return new OutputStreamWriter( out, encoding ); - } - - /** - * Create a new Writer with specified encoding. - * - * @param file not null file. - * @param encoding not null supported encoding. - * @return a writer instance for the output file using the given 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 ); - } -} 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..08099acb 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/XmlReader.java +++ b/src/main/java/org/codehaus/plexus/util/xml/XmlReader.java @@ -28,6 +28,7 @@ import java.net.URLConnection; import java.nio.file.Files; import java.net.HttpURLConnection; +import java.nio.file.Path; import java.util.Locale; import java.util.regex.Pattern; import java.util.regex.Matcher; @@ -111,6 +112,24 @@ public static String getDefaultEncoding() return _staticDefaultEncoding; } + /** + * Creates a Reader for a Path. + *

+ * It looks for the UTF-8 BOM first, if none sniffs the XML prolog charset, if this is also missing defaults to + * UTF-8. + *

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

+ * + * @param path Path to create a Reader from. + * @throws IOException thrown if there is a problem reading the file. + */ + public XmlReader( Path path ) + throws IOException + { + this( Files.newInputStream( path ) ); + } + /** * Creates a Reader for a File. *

@@ -126,7 +145,7 @@ public static String getDefaultEncoding() public XmlReader( File file ) throws IOException { - this( Files.newInputStream( file.toPath() ) ); + this( file.toPath() ); } /** 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..20eb1211 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/XmlStreamReader.java +++ b/src/main/java/org/codehaus/plexus/util/xml/XmlStreamReader.java @@ -21,6 +21,7 @@ import java.io.InputStream; import java.net.URL; import java.net.URLConnection; +import java.nio.file.Path; /** * Character stream that handles (or at least attempts to) all the necessary Voodo to figure out the charset encoding of @@ -49,6 +50,24 @@ public class XmlStreamReader extends XmlReader { + /** + * Creates a Reader for a Path. + *

+ * It looks for the UTF-8 BOM first, if none sniffs the XML prolog charset, if this is also missing defaults to + * UTF-8. + *

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

+ * + * @param path Path to create a Reader from. + * @throws IOException thrown if there is a problem reading the file. + */ + public XmlStreamReader( Path path ) + throws IOException + { + super( path ); + } + /** * Creates a Reader for a File. *

@@ -64,7 +83,7 @@ public class XmlStreamReader public XmlStreamReader( File file ) throws IOException { - super( file ); + this( file.toPath() ); } /** 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..213bd0c0 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/XmlUtil.java +++ b/src/main/java/org/codehaus/plexus/util/xml/XmlUtil.java @@ -61,7 +61,7 @@ public static boolean isXml( File f ) throw new IllegalArgumentException( "The file '" + f.getAbsolutePath() + "' is not a file." ); } - try ( Reader reader = ReaderFactory.newXmlReader( f ) ) + try ( Reader reader = new XmlStreamReader( f ) ) { XmlPullParser parser = new MXParser(); parser.setInput( reader ); @@ -93,8 +93,6 @@ public static boolean isXml( File f ) * @param writer not null * @throws IOException if any or invalid xml content * @see #prettyFormat(Reader, Writer, int, String) - * @see ReaderFactory to read an xml content - * @see WriterFactory to write an xml content */ public static void prettyFormat( Reader reader, Writer writer ) throws IOException @@ -122,8 +120,6 @@ public static void prettyFormat( Reader reader, Writer writer ) * @param indentSize positive number for the indentation * @param lineSeparator the wanted line separator * @throws IOException if any or invalid xml content - * @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 @@ -221,7 +217,7 @@ public static void prettyFormat( InputStream is, OutputStream os, int indentSize indentSize = 0; } - try ( Reader reader = ReaderFactory.newXmlReader( is ); + try ( InputStream input = is; Writer writer = new OutputStreamWriter( os ) ) { final PrettyPrintXMLWriter xmlWriter = new PrettyPrintXMLWriter( writer ); @@ -229,7 +225,7 @@ public static void prettyFormat( InputStream is, OutputStream os, int indentSize xmlWriter.setLineSeparator( lineSeparator ); final XmlPullParser parser = new MXParser(); - parser.setInput( reader ); + parser.setInput( input, null ); prettyFormatInternal( parser, xmlWriter ); } 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..7512c507 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/Xpp3Dom.java +++ b/src/main/java/org/codehaus/plexus/util/xml/Xpp3Dom.java @@ -16,17 +16,15 @@ * limitations under the License. */ +import org.apache.maven.api.xml.XmlNode; +import org.apache.maven.internal.xml.XmlNodeImpl; import org.codehaus.plexus.util.xml.pull.XmlSerializer; import java.io.IOException; import java.io.Serializable; -import java.io.StringWriter; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; -import java.util.Iterator; import java.util.List; -import java.util.ListIterator; import java.util.Map; /** @@ -35,27 +33,8 @@ public class Xpp3Dom implements Serializable { - private static final long serialVersionUID = 2567894443061173996L; - - protected String name; - - protected String value; - - protected Map attributes; - - protected final List childList; - - protected Xpp3Dom parent; - - /** - * @since 3.2.0 - */ - protected Object inputLocation; - private static final String[] EMPTY_STRING_ARRAY = new String[0]; - private static final Xpp3Dom[] EMPTY_DOM_ARRAY = new Xpp3Dom[0]; - public static final String CHILDREN_COMBINATION_MODE_ATTRIBUTE = "combine.children"; public static final String CHILDREN_COMBINATION_MERGE = "merge"; @@ -85,10 +64,12 @@ public class Xpp3Dom */ public static final String DEFAULT_SELF_COMBINATION_MODE = SELF_COMBINATION_MERGE; + private ChildrenTracking childrenTracking; + private XmlNode dom; + public Xpp3Dom( String name ) { - this.name = name; - childList = new ArrayList<>(); + this.dom = new XmlNodeImpl( name ); } /** @@ -98,8 +79,7 @@ public Xpp3Dom( String name ) */ public Xpp3Dom( String name, Object inputLocation ) { - this( name ); - this.inputLocation = inputLocation; + this.dom = new XmlNodeImpl( name, null, null, null, inputLocation ); } /** @@ -118,25 +98,29 @@ public Xpp3Dom( Xpp3Dom src ) */ public Xpp3Dom( Xpp3Dom src, String name ) { - this.name = name; - this.inputLocation = src.inputLocation; - - int childCount = src.getChildCount(); + this.dom = new XmlNodeImpl( src.dom, name ); + } - childList = new ArrayList( childCount ); + public Xpp3Dom( XmlNode dom ) + { + this.dom = dom; + } - setValue( src.getValue() ); + public Xpp3Dom( XmlNode dom, Xpp3Dom parent ) + { + this.dom = dom; + this.childrenTracking = parent::replace; + } - String[] attributeNames = src.getAttributeNames(); - for ( String attributeName : attributeNames ) - { - setAttribute( attributeName, src.getAttribute( attributeName ) ); - } + public Xpp3Dom( XmlNode dom, ChildrenTracking childrenTracking ) + { + this.dom = dom; + this.childrenTracking = childrenTracking; + } - for ( int i = 0; i < childCount; i++ ) - { - addChild( new Xpp3Dom( src.getChild( i ) ) ); - } + public XmlNode getDom() + { + return dom; } // ---------------------------------------------------------------------- @@ -145,7 +129,7 @@ public Xpp3Dom( Xpp3Dom src, String name ) public String getName() { - return name; + return dom.getName(); } // ---------------------------------------------------------------------- @@ -154,12 +138,12 @@ public String getName() public String getValue() { - return value; + return dom.getValue(); } public void setValue( String value ) { - this.value = value; + update( new XmlNodeImpl( dom.getName(), value, dom.getAttributes(), dom.getChildren(), dom.getInputLocation() ) ); } // ---------------------------------------------------------------------- @@ -168,19 +152,12 @@ public void setValue( String value ) public String[] getAttributeNames() { - if ( null == attributes || attributes.isEmpty() ) - { - return EMPTY_STRING_ARRAY; - } - else - { - return attributes.keySet().toArray( EMPTY_STRING_ARRAY ); - } + return dom.getAttributes().keySet().toArray( EMPTY_STRING_ARRAY ); } public String getAttribute( String name ) { - return ( null != attributes ) ? attributes.get( name ) : null; + return dom.getAttribute( name ); } /** @@ -191,7 +168,17 @@ public String getAttribute( String name ) */ public boolean removeAttribute( String name ) { - return StringUtils.isEmpty( name ) ? false: attributes.remove( name ) == null; + if ( name != null && !name.isEmpty() ) + { + Map attrs = new HashMap<>(dom.getAttributes()); + boolean ret = attrs.remove(name) != null; + if (ret) { + update(new XmlNodeImpl( + dom.getName(), dom.getValue(), attrs, dom.getChildren(), dom.getInputLocation())); + } + return ret; + } + return false; } /** @@ -208,14 +195,11 @@ public void setAttribute( String name, String value ) } if ( null == name ) { - throw new NullPointerException( "Attribute name can not be null" ); + throw new NullPointerException("Attribute name can not be null"); } - if ( null == attributes ) - { - attributes = new HashMap(); - } - - attributes.put( name, value ); + Map attrs = new HashMap<>(dom.getAttributes()); + attrs.put(name, value); + update(new XmlNodeImpl(dom.getName(), dom.getValue(), attrs, dom.getChildren(), dom.getInputLocation())); } // ---------------------------------------------------------------------- @@ -224,105 +208,53 @@ public void setAttribute( String name, String value ) public Xpp3Dom getChild( int i ) { - return childList.get( i ); + return new Xpp3Dom( dom.getChildren().get(i), this ); } 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() ) ) - { - return child; - } - } - } - return null; + XmlNode child = dom.getChild( name ); + return child != null ? new Xpp3Dom( child, this ) : null; } public void addChild( Xpp3Dom xpp3Dom ) { - xpp3Dom.setParent( this ); - childList.add( xpp3Dom ); + List children = new ArrayList<>( dom.getChildren() ); + children.add( xpp3Dom.dom ); + xpp3Dom.childrenTracking = this::replace; + update( new XmlNodeImpl( dom.getName(), dom.getValue(), dom.getAttributes(), children, dom.getInputLocation() ) ); } public Xpp3Dom[] getChildren() { - if ( null == childList || childList.isEmpty() ) - { - return EMPTY_DOM_ARRAY; - } - else - { - return childList.toArray( EMPTY_DOM_ARRAY ); - } + return dom.getChildren().stream().map(d -> new Xpp3Dom(d, this)).toArray(Xpp3Dom[]::new); } public Xpp3Dom[] getChildren( String name ) { - return getChildrenAsList( name ).toArray( EMPTY_DOM_ARRAY ); - } - - private List getChildrenAsList( String name ) - { - if ( null == childList ) - { - return Collections.emptyList(); - } - else - { - ArrayList children = null; - - for ( Xpp3Dom configuration : childList ) - { - if ( name.equals( configuration.getName() ) ) - { - if ( children == null ) - { - children = new ArrayList(); - } - children.add( configuration ); - } - } - - if ( children != null ) - { - return children; - } - else - { - return Collections.emptyList(); - } - } + return dom.getChildren().stream() + .filter( c -> c.getName().equals( name ) ) + .map( d -> new Xpp3Dom( d, this ) ) + .toArray( Xpp3Dom[]::new ); } public int getChildCount() { - if ( null == childList ) - { - return 0; - } - - return childList.size(); + return dom.getChildren().size(); } public void removeChild( int i ) { - Xpp3Dom child = getChild( i ); - childList.remove( i ); - // In case of any dangling references - child.setParent( null ); + List children = new ArrayList<>( dom.getChildren() ); + children.remove( i ); + update( new XmlNodeImpl( dom.getName(), dom.getValue(), dom.getAttributes(), children, dom.getInputLocation() ) ); } public void removeChild( Xpp3Dom child ) { - childList.remove( child ); - // In case of any dangling references - child.setParent( null ); + List children = new ArrayList<>( dom.getChildren() ); + children.remove( child.dom ); + update( new XmlNodeImpl( dom.getName(), dom.getValue(), dom.getAttributes(), children, dom.getInputLocation() ) ); } // ---------------------------------------------------------------------- @@ -331,12 +263,11 @@ public void removeChild( Xpp3Dom child ) public Xpp3Dom getParent() { - return parent; + throw new UnsupportedOperationException(); } public void setParent( Xpp3Dom parent ) { - this.parent = parent; } // ---------------------------------------------------------------------- @@ -349,7 +280,7 @@ public void setParent( Xpp3Dom parent ) */ public Object getInputLocation() { - return inputLocation; + return dom.getInputLocation(); } /** @@ -358,15 +289,14 @@ public Object getInputLocation() */ public void setInputLocation( Object inputLocation ) { - this.inputLocation = inputLocation; + update( new XmlNodeImpl( dom.getName(), dom.getValue(), dom.getAttributes(), dom.getChildren(), 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! @@ -422,115 +352,7 @@ private static void mergeIntoXpp3Dom( Xpp3Dom dominant, Xpp3Dom recessive, Boole { return; } - - boolean mergeSelf = true; - - String selfMergeMode = dominant.getAttribute( SELF_COMBINATION_MODE_ATTRIBUTE ); - - 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 ( recessive.attributes != null ) - { - for ( String attr : recessive.attributes.keySet() ) - { - if ( isEmpty( dominant.getAttribute( attr ) ) ) - { - dominant.setAttribute( attr, recessive.getAttribute( attr ) ); - } - } - } - - if ( recessive.getChildCount() > 0 ) - { - boolean mergeChildren = true; - - if ( childMergeOverride != null ) - { - mergeChildren = childMergeOverride; - } - else - { - String childMergeMode = dominant.getAttribute( CHILDREN_COMBINATION_MODE_ATTRIBUTE ); - - if ( CHILDREN_COMBINATION_APPEND.equals( childMergeMode ) ) - { - mergeChildren = false; - } - } - - 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 ) ); - } - - // now, re-add these children so they'll be appended to the recessive list. - for ( Xpp3Dom aDominantChildren : dominantChildren ) - { - dominant.addChild( aDominantChildren ); - } - } - else - { - Map> commonChildren = new HashMap>(); - - 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() ); - } - } - - 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 ); - } - } - } - } - } - } + dominant.dom = dominant.dom.merge( recessive.dom, childMergeOverride ); } /** @@ -581,8 +403,7 @@ public static Xpp3Dom mergeXpp3Dom( Xpp3Dom dominant, Xpp3Dom recessive ) @Override public boolean equals( Object obj ) { - if ( obj == this ) - { + if (obj == this) { return true; } @@ -591,60 +412,25 @@ public boolean equals( Object obj ) return false; } - Xpp3Dom dom = (Xpp3Dom) obj; - - if ( name == null ? dom.name != null : !name.equals( dom.name ) ) - { - return false; - } - else if ( value == null ? dom.value != null : !value.equals( dom.value ) ) - { - return false; - } - else if ( attributes == null ? dom.attributes != null : !attributes.equals( dom.attributes ) ) - { - return false; - } - else if ( childList == null ? dom.childList != null : !childList.equals( dom.childList ) ) - { - return false; - } - else - { - return true; - } + Xpp3Dom dom = ( Xpp3Dom ) obj; + return this.dom.equals( dom.dom ); } @Override 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 ); - return result; + return dom.hashCode(); } @Override 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 ); - return writer.toString(); + return dom.toString(); } 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 ); - return writer.toString(); + return ( ( Xpp3Dom ) dom ).toUnescapedString(); } public static boolean isNotEmpty( String str ) @@ -657,4 +443,31 @@ public static boolean isEmpty( String str ) return ( ( str == null ) || ( str.trim().length() == 0 ) ); } + private void update(XmlNode dom) + { + if ( childrenTracking != null ) + { + childrenTracking.replace( this.dom, dom ); + } + this.dom = dom; + } + + private boolean replace(Object prevChild, Object newChild) + { + List children = new ArrayList<>( dom.getChildren() ); + children.replaceAll( d -> d == prevChild ? (XmlNode) newChild : d ); + update( new XmlNodeImpl( dom.getName(), dom.getValue(), dom.getAttributes(), children, dom.getInputLocation() ) ); + return true; + } + + public void setChildrenTracking( ChildrenTracking childrenTracking ) + { + this.childrenTracking = childrenTracking; + } + + @FunctionalInterface + public interface ChildrenTracking + { + boolean replace( Object oldDelegate, Object newDelegate ); + } } 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..cc10df39 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/Xpp3DomBuilder.java +++ b/src/main/java/org/codehaus/plexus/util/xml/Xpp3DomBuilder.java @@ -16,15 +16,13 @@ * limitations under the License. */ -import org.codehaus.plexus.util.xml.pull.MXParser; +import org.apache.maven.internal.xml.XmlNodeBuilder; 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; /** * @@ -40,12 +38,7 @@ public static Xpp3Dom build( Reader reader ) } /** - * @param reader the reader - * @param locationBuilder the builder * @since 3.2.0 - * @return DOM - * @throws XmlPullParserException xml exception - * @throws IOException io */ public static Xpp3Dom build( Reader reader, InputLocationBuilder locationBuilder ) throws XmlPullParserException, IOException @@ -62,30 +55,9 @@ public static Xpp3Dom build( InputStream is, String encoding ) public static Xpp3Dom build( InputStream is, String encoding, boolean trim ) throws XmlPullParserException, IOException { - try + try ( InputStream closeMe = is ) { - final XmlPullParser parser = new MXParser(); - parser.setInput( is, encoding ); - - final Xpp3Dom xpp3Dom = build( parser, trim ); - is.close(); - is = null; - - return xpp3Dom; - } - finally - { - if ( is != null ) - { - try - { - is.close(); - } - catch ( IOException ioe ) - { - // ignore - } - } + return new Xpp3Dom( XmlNodeBuilder.build( is, encoding, trim ) ); } } @@ -96,41 +68,15 @@ public static Xpp3Dom build( Reader reader, boolean trim ) } /** - * @param reader the reader - * @param trim to trim - * @param locationBuilder the builder * @since 3.2.0 - * @return DOM - * @throws XmlPullParserException xml exception - * @throws IOException io */ public static Xpp3Dom build( Reader reader, boolean trim, InputLocationBuilder locationBuilder ) throws XmlPullParserException, IOException { - try - { - final XmlPullParser parser = new MXParser(); - parser.setInput( reader ); - - final Xpp3Dom xpp3Dom = build( parser, trim, locationBuilder ); - reader.close(); - reader = null; - - return xpp3Dom; - } - finally + try ( Reader closeMe = reader ) { - if ( reader != null ) - { - try - { - reader.close(); - } - catch ( IOException ioe ) - { - // ignore - } - } + return new Xpp3Dom( XmlNodeBuilder.build( + reader, trim, locationBuilder != null ? locationBuilder::toInputLocation : null ) ); } } @@ -148,119 +94,12 @@ public static Xpp3Dom build( XmlPullParser parser, boolean trim ) /** * @since 3.2.0 - * @param locationBuilder builder - * @param parser the parser - * @param trim do trim - * @return DOM - * @throws XmlPullParserException xml exception - * @throws IOException io */ public static Xpp3Dom build( XmlPullParser parser, boolean trim, InputLocationBuilder locationBuilder ) throws XmlPullParserException, IOException { - List elements = new ArrayList<>(); - - List values = new ArrayList<>(); - - int eventType = parser.getEventType(); - - boolean spacePreserve = false; - - while ( eventType != XmlPullParser.END_DOCUMENT ) - { - if ( eventType == XmlPullParser.START_TAG ) - { - spacePreserve = false; - - String rawName = parser.getName(); - - Xpp3Dom childConfiguration = new Xpp3Dom( rawName ); - - if ( locationBuilder != null ) - { - childConfiguration.setInputLocation( locationBuilder.toInputLocation( parser ) ); - } - - int depth = elements.size(); - - if ( depth > 0 ) - { - Xpp3Dom parent = elements.get( depth - 1 ); - - parent.addChild( childConfiguration ); - } - - elements.add( childConfiguration ); - - 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 ); - - String value = parser.getAttributeValue( i ); - - childConfiguration.setAttribute( name, value ); - - spacePreserve = spacePreserve || ( "xml:space".equals( name ) && "preserve".equals( value ) ); - } - } - else if ( eventType == XmlPullParser.TEXT ) - { - int depth = values.size() - 1; - - @SuppressWarnings( "MismatchedQueryAndUpdateOfStringBuilder" ) - StringBuilder valueBuffer = values.get( depth ); - - String text = parser.getText(); - - if ( trim && !spacePreserve ) - { - text = text.trim(); - } - - valueBuffer.append( text ); - } - else if ( eventType == XmlPullParser.END_TAG ) - { - int depth = elements.size() - 1; - - Xpp3Dom finishedConfiguration = elements.remove( depth ); - - /* this Object could be null if it is a singleton tag */ - Object accumulatedValue = values.remove( depth ); - - if ( finishedConfiguration.getChildCount() == 0 ) - { - if ( accumulatedValue == null ) - { - finishedConfiguration.setValue( null ); - } - else - { - finishedConfiguration.setValue( accumulatedValue.toString() ); - } - } - - if ( depth == 0 ) - { - return finishedConfiguration; - } - } - - eventType = parser.next(); - } - - throw new IllegalStateException( "End of document found before returning to 0 depth" ); + return new Xpp3Dom( + XmlNodeBuilder.build( parser, trim, locationBuilder != null ? locationBuilder::toInputLocation : null ) ); } /** @@ -268,7 +107,7 @@ else if ( eventType == XmlPullParser.END_TAG ) * * @since 3.2.0 */ - public static interface InputLocationBuilder + public interface InputLocationBuilder { Object toInputLocation( XmlPullParser parser ); } 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..0a1bc9c6 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 @@ -15,8 +15,8 @@ import java.io.Reader; import java.io.UnsupportedEncodingException; -import org.codehaus.plexus.util.xml.ReaderFactory; import org.codehaus.plexus.util.xml.XmlReader; +import org.codehaus.plexus.util.xml.XmlStreamReader; //import java.util.Hashtable; @@ -692,11 +692,11 @@ public void setInput( java.io.InputStream inputStream, String inputEncoding ) { if ( inputEncoding != null ) { - reader = ReaderFactory.newReader( inputStream, inputEncoding ); + reader = new InputStreamReader( inputStream, inputEncoding ); } else { - reader = ReaderFactory.newXmlReader( inputStream ); + reader = new XmlStreamReader( inputStream ); } } catch ( UnsupportedEncodingException une ) 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..bb564ad5 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java @@ -81,23 +81,14 @@ public void testPrettyFormatInputStreamOutputStream() File testDocument = new File( getBasedir(), "src/test/resources/testDocument.xhtml" ); assertTrue( testDocument.exists() ); - InputStream is = null; - OutputStream os = null; - try + try ( InputStream is = Files.newInputStream( testDocument.toPath() ); + OutputStream os = Files.newOutputStream( getTestOutputFile( "target/test/prettyFormatTestDocumentOutputStream.xml" ).toPath() ) ) { - 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 ); - } } /** @@ -112,24 +103,14 @@ public void testPrettyFormatReaderWriter() File testDocument = new File( getBasedir(), "src/test/resources/testDocument.xhtml" ); assertTrue( testDocument.exists() ); - Reader reader = null; - Writer writer = null; - try + try ( Reader reader = new XmlStreamReader( testDocument ); + Writer writer = new XmlStreamWriter( getTestOutputFile( "target/test/prettyFormatTestDocumentWriter.xml" ) ) ) { - reader = ReaderFactory.newXmlReader( testDocument ); - writer = - WriterFactory.newXmlWriter( getTestOutputFile( "target/test/prettyFormatTestDocumentWriter.xml" ) ); - assertNotNull( reader ); assertNotNull( writer ); XmlUtil.prettyFormat( reader, writer ); } - finally - { - IOUtil.close( reader ); - IOUtil.close( writer ); - } } /** @@ -144,22 +125,16 @@ public void testPrettyFormatString() File testDocument = new File( getBasedir(), "src/test/resources/testDocument.xhtml" ); assertTrue( testDocument.exists() ); - Reader reader = null; - Writer writer = null; String content; - try + try ( Reader reader = new XmlStreamReader( testDocument ) ) { - reader = ReaderFactory.newXmlReader( testDocument ); content = IOUtil.toString( reader ); - - reader = ReaderFactory.newXmlReader( testDocument ); - writer = new StringWriter(); - XmlUtil.prettyFormat( reader, writer ); } - finally + + Writer writer = new StringWriter(); + try ( Reader reader = new XmlStreamReader( testDocument ) ) { - IOUtil.close( reader ); - IOUtil.close( writer ); + XmlUtil.prettyFormat( reader, writer ); } assertNotNull( content ); @@ -180,22 +155,13 @@ public void testPrettyFormatReaderWriter2() File testDocument = new File( getBasedir(), "src/test/resources/test.xdoc.xhtml" ); assertTrue( testDocument.exists() ); - Reader reader = null; - Writer writer = null; - try + try ( Reader reader = new XmlStreamReader( testDocument ); + Writer writer = new XmlStreamWriter( getTestOutputFile( "target/test/prettyFormatTestXdocWriter.xml" ) ) ) { - reader = ReaderFactory.newXmlReader( testDocument ); - 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 702aa1d3..145f0f10 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/XmlWriterUtilTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/XmlWriterUtilTest.java @@ -53,7 +53,7 @@ public void setUp() throws Exception { output = new ByteArrayOutputStream(); - writer = WriterFactory.newXmlWriter( output ); + writer = new XmlStreamWriter( output ); xmlWriter = new PrettyPrintXMLWriter( writer ); } 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..db390ef3 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomTest.java @@ -18,6 +18,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertNull; @@ -25,8 +26,13 @@ import java.io.IOException; import java.io.StringReader; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.apache.maven.api.xml.XmlNode; +import org.apache.maven.internal.xml.XmlNodeImpl; import org.codehaus.plexus.util.xml.pull.XmlPullParser; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import org.junit.Test; @@ -231,7 +237,7 @@ public void testEquals() assertEquals( dom, dom ); assertFalse( dom.equals( null ) ); - assertFalse( dom.equals( new Xpp3Dom( (String) null ) ) ); + assertFalse( dom.equals( new Xpp3Dom( "" ) ) ); } /** @@ -246,25 +252,16 @@ public void testEqualsIsNullSafe() { String testDom = "onetwo"; 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 ); - - assertFalse( dom.equals( dom2 ) ); - assertFalse( dom2.equals( dom ) ); + Map attributes = new HashMap<>(); + attributes.put( "nullValue", null ); + attributes.put( null, "nullKey" ); + List childList = new ArrayList<>(); + childList.add( null ); + Xpp3Dom dom2 = new Xpp3Dom( new XmlNodeImpl( dom.getName(), null, attributes, childList, null ) ); - } - 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 0c393c6b..3b6d5214 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 @@ -31,7 +31,7 @@ import java.nio.file.Paths; import org.codehaus.plexus.util.IOUtil; -import org.codehaus.plexus.util.xml.ReaderFactory; +import org.codehaus.plexus.util.xml.XmlStreamReader; import org.junit.Test; /** @@ -972,7 +972,7 @@ public void testEncodingISO_8859_1setInputReader() throws IOException { try ( Reader reader = - ReaderFactory.newXmlReader( new File( "src/test/resources/xml", "test-encoding-ISO-8859-1.xml" ) ) ) + new XmlStreamReader( Paths.get( "src/test/resources/xml", "test-encoding-ISO-8859-1.xml" ) ) ) { MXParser parser = new MXParser(); parser.setInput( reader ); @@ -1031,11 +1031,14 @@ private static void assertPosition( int row, int col, MXParser parser ) public void testEncodingISO_8859_1setStringReader() throws IOException { + String xmlFileContents; try ( Reader reader = - ReaderFactory.newXmlReader( new File( "src/test/resources/xml", "test-encoding-ISO-8859-1.xml" ) ) ) - { + new XmlStreamReader( Paths.get( "src/test/resources/xml", "test-encoding-ISO-8859-1.xml" ) ) ) { + xmlFileContents = IOUtil.toString(reader); + } + + try { MXParser parser = new MXParser(); - String xmlFileContents = IOUtil.toString( reader ); parser.setInput( new StringReader( xmlFileContents ) ); while ( parser.nextToken() != XmlPullParser.END_DOCUMENT ) ; @@ -1223,7 +1226,7 @@ public void testDocdeclTextWithEntitiesDOS() private void testDocdeclTextWithEntities( String filename ) throws IOException { - try ( Reader reader = ReaderFactory.newXmlReader( new File( "src/test/resources/xml", filename ) ) ) + try ( Reader reader = new XmlStreamReader( new File( "src/test/resources/xml", filename ) ) ) { MXParser parser = new MXParser(); parser.setInput( reader ); @@ -1286,10 +1289,10 @@ public void testDocdeclTextWithEntitiesInAttributesDOS() private void testDocdeclTextWithEntitiesInAttributes( String filename ) throws IOException { - try ( Reader reader = ReaderFactory.newXmlReader( new File( "src/test/resources/xml", filename ) ) ) + try ( InputStream input = Files.newInputStream( Paths.get( "src/test/resources/xml", filename ) ) ) { MXParser parser = new MXParser(); - parser.setInput( reader ); + parser.setInput( input, null ); parser.defineEntityReplacementText( "nbsp", " " ); parser.defineEntityReplacementText( "Alpha", "Α" ); parser.defineEntityReplacementText( "tritPos", "𝟭" ); From 1332277827f6c6edaca9a6a92c476e44389cd42e Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Wed, 5 Apr 2023 22:13:06 +0200 Subject: [PATCH 02/74] Fix tests The behavior has changed with https://github.com/codehaus-plexus/plexus-utils/issues/216 but plexus-utils contains duplicate merge code in Xpp3Dom and Xpp3DomUtils and the two pieces have divered. This duplication is removed by the PR by switching to the XmlNode implementation in both cases, but we now need to fix the expectations. --- .../codehaus/plexus/util/xml/Xpp3DomTest.java | 10 ++-- .../plexus/util/xml/Xpp3DomUtilsTest.java | 52 +++++++++++++++++++ 2 files changed, 57 insertions(+), 5 deletions(-) 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 db390ef3..ec4f4ee3 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomTest.java @@ -153,7 +153,7 @@ public void testShouldPerformSelfOverrideAtTopLevel() *

testShouldMergeValuesAtTopLevelByDefault.

*/ @Test - public void testShouldMergeValuesAtTopLevelByDefault() + public void testShouldNotMergeValuesAtTopLevelByDefault() { // create the dominant DOM Xpp3Dom t1 = new Xpp3Dom( "top" ); @@ -172,15 +172,15 @@ public void testShouldMergeValuesAtTopLevelByDefault() // this is still 2, since we're not using the merge-control attribute. assertEquals( 2, result.getAttributeNames().length ); - assertEquals( result.getValue(), t2.getValue() ); - assertEquals( "t2top", result.getInputLocation() ); + assertEquals( result.getValue(), t1.getValue() ); + assertEquals( "t1top", result.getInputLocation() ); } /** *

testShouldMergeValuesAtTopLevel.

*/ @Test - public void testShouldMergeValuesAtTopLevel() + public void testShouldNotMergeValues() { // create the dominant DOM Xpp3Dom t1 = new Xpp3Dom( "top" ); @@ -197,7 +197,7 @@ public void testShouldMergeValuesAtTopLevel() Xpp3Dom result = Xpp3Dom.mergeXpp3Dom( t1, t2 ); assertEquals( 3, result.getAttributeNames().length ); - assertEquals( result.getValue(), t2.getValue() ); + assertNull( result.getValue(), t1.getValue() ); } /** 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..74c08baf 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomUtilsTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomUtilsTest.java @@ -17,6 +17,7 @@ */ import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; import java.io.IOException; import java.io.StringReader; @@ -150,6 +151,57 @@ public void testIsNotEmptyNegatesIsEmpty() assertEquals( !Xpp3DomUtils.isEmpty( "someValue" ), Xpp3DomUtils.isNotEmpty( "someValue" ) ); } + /** + *

testShouldMergeValuesAtTopLevelByDefault.

+ */ + @Test + public void testShouldNotMergeValuesAtTopLevelByDefault() + { + // create the dominant DOM + 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" ); + + // merge and check results. + Xpp3Dom result = Xpp3DomUtils.mergeXpp3Dom( t1, t2 ); + + // this is still 2, since we're not using the merge-control attribute. + assertEquals( 2, result.getAttributeNames().length ); + + assertEquals( result.getValue(), t1.getValue() ); + assertEquals( "t1top", result.getInputLocation() ); + } + + /** + *

testShouldMergeValuesAtTopLevel.

+ */ + @Test + public void testShouldNotMergeValues() + { + // create the dominant DOM + Xpp3Dom t1 = new Xpp3Dom( "top" ); + t1.setAttribute( "attr", "value" ); + + 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" ); + + // merge and check results. + Xpp3Dom result = Xpp3DomUtils.mergeXpp3Dom( t1, t2 ); + + assertEquals( 3, result.getAttributeNames().length ); + assertNull( result.getValue(), t1.getValue() ); + } + private static class FixedInputLocationBuilder implements Xpp3DomBuilder.InputLocationBuilder { From 31016cd70e9fba66efc151f109ff407aa81ce520 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Thu, 6 Apr 2023 22:37:07 +0200 Subject: [PATCH 03/74] 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 300a4e490213979e7b91973f206daa0289a2d656 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Fri, 7 Apr 2023 17:01:57 +0200 Subject: [PATCH 04/74] Fix parsing an UTF-8 file without BOM and ISO-8859-1 encoding (#1) * do not try to discover the encoding used when the input is given a Reader * simplified test-encoding-ISO-8859-1.xml test file * fixed tests exercising encoding checks. Unsupported tests were skipped --------- Co-authored-by: Gabriel Belingueres --- .../codehaus/plexus/util/xml/XmlReader.java | 7 +- .../plexus/util/xml/pull/MXParser.java | 42 +- .../plexus/util/xml/pull/MXParserTest.java | 104 +- ..._BjoernHoehrmannviaHST2013_09_18_Test.java | 33 +- .../xml/test-encoding-ISO-8859-1.xml | 1504 +---------------- 5 files changed, 127 insertions(+), 1563 deletions(-) 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 08099acb..8ac13cab 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/XmlReader.java +++ b/src/main/java/org/codehaus/plexus/util/xml/XmlReader.java @@ -523,11 +523,8 @@ else if ( bomEnc.equals( 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 } ) ); - } - if ( xmlEnc != null && !xmlEnc.equals( UTF_16 ) && !xmlEnc.equals( bomEnc ) ) + if ( xmlGuessEnc != null && !xmlGuessEnc.equals( bomEnc ) + || 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 ); 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 0a1bc9c6..2dfc4c50 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 @@ -15,10 +15,9 @@ import java.io.Reader; import java.io.UnsupportedEncodingException; -import org.codehaus.plexus.util.xml.XmlReader; import org.codehaus.plexus.util.xml.XmlStreamReader; +import org.codehaus.plexus.util.xml.XmlStreamReaderException; -//import java.util.Hashtable; //TODO best handling of interning issues // have isAllNewStringInterned ??? @@ -663,20 +662,6 @@ public void setInput( Reader in ) { reset(); reader = in; - - if ( reader instanceof XmlReader ) { - // encoding already detected - XmlReader xsr = (XmlReader) reader; - fileEncoding = xsr.getEncoding(); - } - else if ( reader instanceof InputStreamReader ) - { - InputStreamReader isr = (InputStreamReader) reader; - if ( isr.getEncoding() != null ) - { - fileEncoding = isr.getEncoding().toUpperCase(); - } - } } @Override @@ -696,7 +681,7 @@ public void setInput( java.io.InputStream inputStream, String inputEncoding ) } else { - reader = new XmlStreamReader( inputStream ); + reader = new XmlStreamReader( inputStream, false ); } } catch ( UnsupportedEncodingException une ) @@ -704,6 +689,18 @@ public void setInput( java.io.InputStream inputStream, String inputEncoding ) throw new XmlPullParserException( "could not create reader for encoding " + inputEncoding + " : " + une, this, une ); } + catch ( XmlStreamReaderException e ) + { + if ( "UTF-8".equals( e.getBomEncoding() ) ) + { + throw new XmlPullParserException( "UTF-8 BOM plus xml decl of " + e.getXmlEncoding() + " is incompatible", this, e ); + } + if ( e.getBomEncoding() != null && e.getBomEncoding().startsWith( "UTF-16" ) ) + { + throw new XmlPullParserException( "UTF-16 BOM in a " + e.getXmlEncoding() + " encoded file is incompatible", this, e ); + } + throw new XmlPullParserException( "could not create reader : " + e, this, e ); + } catch ( IOException e ) { throw new XmlPullParserException( "could not create reader : " + e, this, e ); @@ -3434,17 +3431,6 @@ private void parseXmlDeclWithVersion( int versionStart, int versionEnd ) // TODO reconcile with setInput encodingName inputEncoding = newString( buf, encodingStart, encodingEnd - encodingStart ); - if ( "UTF8".equals( fileEncoding ) && inputEncoding.toUpperCase().startsWith( "ISO-" ) ) - { - throw new XmlPullParserException( "UTF-8 BOM plus xml decl of " + inputEncoding + " is incompatible", - this, null ); - } - else if ("UTF-16".equals( fileEncoding ) && inputEncoding.equalsIgnoreCase( "UTF-8" )) - { - throw new XmlPullParserException( "UTF-16 BOM plus xml decl of " + inputEncoding + " is incompatible", - this, null ); - } - lastParsedAttr = "encoding"; ch = more(); 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 3b6d5214..e0d77330 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 @@ -23,10 +23,13 @@ import java.io.EOFException; import java.io.File; +import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import java.io.InputStreamReader; import java.io.Reader; import java.io.StringReader; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; @@ -968,7 +971,7 @@ public void testXMLDeclVersionEncodingStandaloneNoSpace() * @since 3.4.1 */ @Test - public void testEncodingISO_8859_1setInputReader() + public void testEncodingISO_8859_1_newXmlReader() throws IOException { try ( Reader reader = @@ -994,7 +997,7 @@ public void testEncodingISO_8859_1setInputReader() * @since 3.4.1 */ @Test - public void testEncodingISO_8859_1_setInputStream() + public void testEncodingISO_8859_1_InputStream() throws IOException { try ( InputStream input = @@ -1012,12 +1015,6 @@ public void testEncodingISO_8859_1_setInputStream() } } - private static void assertPosition( int row, int col, MXParser parser ) - { - assertEquals( "Current line", row, parser.getLineNumber() ); - assertEquals( "Current column", col, parser.getColumnNumber() ); - } - /** * Issue 163: https://github.com/codehaus-plexus/plexus-utils/issues/163 * @@ -1028,7 +1025,7 @@ private static void assertPosition( int row, int col, MXParser parser ) * @since 3.4.2 */ @Test - public void testEncodingISO_8859_1setStringReader() + public void testEncodingISO_8859_1_StringReader() throws IOException { String xmlFileContents; @@ -1050,6 +1047,95 @@ public void testEncodingISO_8859_1setStringReader() } } + /** + * Issue 163: https://github.com/codehaus-plexus/plexus-utils/issues/163 + * + * Another case of bug #163: Reader generated with ReaderFactory.newReader and the right file encoding. + * + * @throws IOException if IO error. + * + * @since 3.5.2 + */ + @Test + public void testEncodingISO_8859_1_newReader() + throws IOException + { + // NOTE: if using Files.newBufferedReader(path, StandardCharsets.UTF-8), the reader will throw an exception + // because the decoder created by new InputStreamReader() is lenient while the one created by + // Files.newBufferedReader() is not. + try ( Reader reader = new InputStreamReader( Files.newInputStream( + Paths.get( "src/test/resources/xml", "test-encoding-ISO-8859-1.xml" ) ), + StandardCharsets.UTF_8 ) ) + { + MXParser parser = new MXParser(); + parser.setInput( reader ); + while ( parser.nextToken() != XmlPullParser.END_DOCUMENT ) + ; + assertTrue( true ); + } + catch ( XmlPullParserException e ) + { + fail( "should not raise exception: " + e ); + } + } + + /** + * Issue 163: https://github.com/codehaus-plexus/plexus-utils/issues/163 + * + * Another case of bug #163: InputStream supplied with the right file encoding. + * + * @throws IOException if IO error. + * + * @since 3.5.2 + */ + @Test + public void testEncodingISO_8859_1_InputStream_encoded() throws IOException { + try ( InputStream input = + Files.newInputStream( Paths.get( "src/test/resources/xml", "test-encoding-ISO-8859-1.xml" ) ) ) + { + MXParser parser = new MXParser(); + parser.setInput( input, StandardCharsets.UTF_8.name() ); + while ( parser.nextToken() != XmlPullParser.END_DOCUMENT ) + ; + assertTrue( true ); + } + catch ( XmlPullParserException e ) + { + fail( "should not raise exception: " + e ); + } + } + + /** + * Issue 163: https://github.com/codehaus-plexus/plexus-utils/issues/163 + * + * @throws IOException if IO error. + * + * @since 3.4.1 + */ + @Test + public void testEncodingUTF8_newXmlReader() + throws IOException + { + try ( Reader reader = new XmlStreamReader( Paths.get( "src/test/resources/xml", "test-encoding-ISO-8859-1.xml" ) ) ) + { + MXParser parser = new MXParser(); + parser.setInput( reader ); + while ( parser.nextToken() != XmlPullParser.END_DOCUMENT ) + ; + assertTrue( true ); + } + catch ( XmlPullParserException e ) + { + fail( "should not raise exception: " + e ); + } + } + + private static void assertPosition( int row, int col, MXParser parser ) + { + assertEquals( "Current line", row, parser.getLineNumber() ); + assertEquals( "Current column", col, parser.getColumnNumber() ); + } + /** *

* Test custom Entity not found. 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..7d2f6299 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 @@ -7,10 +7,8 @@ import java.io.FileInputStream; import java.io.FileReader; import java.io.IOException; -import java.io.InputStreamReader; +import java.io.InputStream; import java.io.Reader; -import java.nio.charset.StandardCharsets; - import org.junit.Before; import org.junit.Test; @@ -212,17 +210,16 @@ public void testhst_bh_006() 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 ) ) + try ( InputStream is = new FileInputStream( new File( testResourcesDir, "007.xml" ) ) ) { - parser.setInput( reader ); + parser.setInput( is, null ); while ( parser.nextToken() != XmlPullParser.END_DOCUMENT ) ; - fail( "UTF-8 BOM plus xml decl of iso-8859-1 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" ) ); + assertTrue( e.getMessage().contains( "UTF-8 BOM plus xml decl of ISO-8859-1 is incompatible" ) ); } } @@ -239,17 +236,16 @@ public void testhst_lhs_007() 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 ) ) + try ( InputStream is = new FileInputStream( new File( testResourcesDir, "008.xml" ) ) ) { - parser.setInput( reader ); + parser.setInput( is, null ); while ( parser.nextToken() != XmlPullParser.END_DOCUMENT ) ; - fail( "UTF-16 BOM plus xml decl of utf-8 (using UTF-16 coding) 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" ) ); + assertTrue( e.getMessage().contains( "UTF-16 BOM in a UTF-8 encoded file is incompatible" ) ); } } @@ -266,17 +262,16 @@ public void testhst_lhs_008() 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 ); + try ( InputStream is = new FileInputStream( new File( testResourcesDir, "009.xml" ) ) ) + { + parser.setInput( is, null ); while ( parser.nextToken() != XmlPullParser.END_DOCUMENT ) ; - fail( "UTF-16 BOM plus xml decl of utf-8 (using UTF-8 coding) 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" ) ); + assertTrue( e.getMessage(), e.getMessage().contains( "UTF-16 BOM in a UTF-8 encoded file is incompatible" ) ); } } diff --git a/src/test/resources/xml/test-encoding-ISO-8859-1.xml b/src/test/resources/xml/test-encoding-ISO-8859-1.xml index ae0aefe7..e37a912c 100644 --- a/src/test/resources/xml/test-encoding-ISO-8859-1.xml +++ b/src/test/resources/xml/test-encoding-ISO-8859-1.xml @@ -1,1503 +1,3 @@ - - - 4.0.0 - - org.apache - apache - 16 - - org.apache.commons - commons-parent - pom - 39 - Apache Commons Parent - http://commons.apache.org/ - The Apache Commons Parent POM provides common settings for all Apache Commons components. - - - - - - 3.0.1 - - - - continuum - https://continuum-ci.apache.org/ - - - - - - - scm:svn:http://svn.apache.org/repos/asf/commons/proper/commons-parent/tags/commons-parent-39 - scm:svn:https://svn.apache.org/repos/asf/commons/proper/commons-parent/tags/commons-parent-39 - http://svn.apache.org/viewvc/commons/proper/commons-parent/tags/commons-parent-39 - - - - - - - - Commons User List - user-subscribe@commons.apache.org - user-unsubscribe@commons.apache.org - user@commons.apache.org - http://mail-archives.apache.org/mod_mbox/commons-user/ - - http://markmail.org/list/org.apache.commons.users/ - http://old.nabble.com/Commons---User-f319.html - http://www.mail-archive.com/user@commons.apache.org/ - http://news.gmane.org/gmane.comp.jakarta.commons.user - - - - Commons Dev List - dev-subscribe@commons.apache.org - dev-unsubscribe@commons.apache.org - dev@commons.apache.org - http://mail-archives.apache.org/mod_mbox/commons-dev/ - - http://markmail.org/list/org.apache.commons.dev/ - http://old.nabble.com/Commons---Dev-f317.html - http://www.mail-archive.com/dev@commons.apache.org/ - http://news.gmane.org/gmane.comp.jakarta.commons.devel - - - - Commons Issues List - issues-subscribe@commons.apache.org - issues-unsubscribe@commons.apache.org - http://mail-archives.apache.org/mod_mbox/commons-issues/ - - http://markmail.org/list/org.apache.commons.issues/ - http://old.nabble.com/Commons---Issues-f25499.html - http://www.mail-archive.com/issues@commons.apache.org/ - - - - Commons Commits List - commits-subscribe@commons.apache.org - commits-unsubscribe@commons.apache.org - http://mail-archives.apache.org/mod_mbox/commons-commits/ - - http://markmail.org/list/org.apache.commons.commits/ - http://www.mail-archive.com/commits@commons.apache.org/ - - - - Apache Announce List - announce-subscribe@apache.org - announce-unsubscribe@apache.org - http://mail-archives.apache.org/mod_mbox/www-announce/ - - http://markmail.org/list/org.apache.announce/ - http://old.nabble.com/Apache-News-and-Announce-f109.html - http://www.mail-archive.com/announce@apache.org/ - http://news.gmane.org/gmane.comp.apache.announce - - - - - - - - - src/main/resources - - - - ${basedir} - META-INF - - NOTICE.txt - LICENSE.txt - - - - - - - - src/test/resources - - - - ${basedir} - META-INF - - NOTICE.txt - LICENSE.txt - - - - - - - - org.apache.maven.plugins - maven-antrun-plugin - 1.8 - - - org.apache.maven.plugins - maven-assembly-plugin - 2.5.5 - - - org.apache.maven.plugins - maven-clean-plugin - 2.6.1 - - - org.apache.maven.plugins - maven-compiler-plugin - ${commons.compiler.version} - - ${maven.compiler.source} - ${maven.compiler.target} - ${commons.encoding} - - ${commons.compiler.fork} - - ${commons.compiler.compilerVersion} - ${commons.compiler.javac} - - - - org.apache.maven.plugins - maven-deploy-plugin - 2.8.2 - - - - org.apache.maven.plugins - maven-gpg-plugin - 1.6 - - - org.apache.maven.plugins - maven-install-plugin - 2.5.2 - - - - org.apache.maven.plugins - maven-jar-plugin - 2.6 - - - org.apache.maven.plugins - maven-javadoc-plugin - ${commons.javadoc.version} - - - true - ${commons.encoding} - ${commons.docEncoding} - true - - ${commons.javadoc.java.link} - ${commons.javadoc.javaee.link} - - - - true - true - - - - - - org.apache.maven.plugins - maven-release-plugin - 2.5.2 - - - - org.apache.maven.plugins - maven-remote-resources-plugin - - 1.5 - - - true - - - - org.apache.maven.plugins - maven-resources-plugin - 2.7 - - - - org.apache.maven.plugins - maven-site-plugin - ${commons.site-plugin.version} - - - true - - - - - org.apache.maven.wagon - wagon-ssh - ${commons.wagon-ssh.version} - - - - - attach-descriptor - - attach-descriptor - - - - - - org.apache.maven.plugins - maven-source-plugin - 2.4 - - - - true - true - - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${commons.surefire.version} - - - - org.apache.commons - commons-build-plugin - 1.4 - - ${commons.release.name} - - - - org.apache.felix - maven-bundle-plugin - 2.5.3 - true - - - org.apache.rat - apache-rat-plugin - ${commons.rat.version} - - - org.codehaus.mojo - build-helper-maven-plugin - 1.9.1 - - - org.codehaus.mojo - buildnumber-maven-plugin - 1.3 - - - org.codehaus.mojo - clirr-maven-plugin - ${commons.clirr.version} - - ${minSeverity} - - - - - - - - - - maven-assembly-plugin - - - src/assembly/src.xml - - gnu - - - - - org.apache.maven.plugins - maven-antrun-plugin - - - javadoc.resources - generate-sources - - run - - - - - - - - - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - - true - org.apache.maven.plugins - maven-enforcer-plugin - 1.3.1 - - - enforce-maven-3 - - enforce - - - - - 3.0.0 - - - true - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - ${commons.manifestfile} - - ${project.name} - ${project.version} - ${project.organization.name} - ${project.name} - ${project.version} - ${project.organization.name} - org.apache - ${implementation.build} - ${maven.compiler.source} - ${maven.compiler.target} - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - ${commons.surefire.java} - - - - - org.apache.commons - commons-build-plugin - - - org.apache.felix - maven-bundle-plugin - - - - true - - ${commons.osgi.excludeDependencies} - ${project.build.directory}/osgi - - - <_nouses>true - - <_removeheaders>JAVA_1_3_HOME,JAVA_1_4_HOME,JAVA_1_5_HOME,JAVA_1_6_HOME,JAVA_1_7_HOME,JAVA_1_8_HOME,JAVA_1_9_HOME - ${commons.osgi.symbolicName} - ${commons.osgi.export} - ${commons.osgi.private} - ${commons.osgi.import} - ${commons.osgi.dynamicImport} - ${project.url} - - - - - bundle-manifest - process-classes - - manifest - - - - - - - org.apache.rat - apache-rat-plugin - ${commons.rat.version} - - - - - site-content/** - .checkstyle - .fbprefs - .pmd - src/site/resources/download_*.cgi - src/site/resources/profile.* - - - - - - org.apache.maven.plugins - maven-scm-publish-plugin - ${commons.scm-publish.version} - - ${project.reporting.outputDirectory} - scm:svn:${commons.scmPubUrl} - ${commons.scmPubCheckoutDirectory} - ${commons.scmPubServer} - true - - - - scm-publish - site-deploy - - publish-scm - - - - - - - - - - - - - - org.apache.maven.plugins - maven-changes-plugin - ${commons.changes.version} - - ${basedir}/src/changes/changes.xml - Fix Version,Key,Component,Summary,Type,Resolution,Status - - Fix Version DESC,Type,Key DESC - Fixed - Resolved,Closed - - Bug,New Feature,Task,Improvement,Wish,Test - - true - ${commons.changes.onlyCurrentVersion} - ${commons.changes.maxEntries} - ${commons.changes.runOnlyAtExecutionRoot} - - - - - changes-report - jira-report - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - ${commons.javadoc.version} - - - true - ${maven.compiler.source} - ${commons.encoding} - ${commons.docEncoding} - true - true - - true - - ${commons.javadoc.java.link} - ${commons.javadoc.javaee.link} - - - - - - default - - javadoc - - - - - - org.apache.maven.plugins - maven-jxr-plugin - ${commons.jxr.version} - - - org.apache.maven.plugins - maven-project-info-reports-plugin - ${commons.project-info.version} - - - - - index - summary - modules - - project-team - scm - issue-tracking - mailing-list - dependency-info - dependency-management - dependencies - dependency-convergence - cim - - - distribution-management - - - - - - org.apache.maven.plugins - maven-site-plugin - ${commons.site-plugin.version} - - - - navigation.xml,changes.xml - - - - - org.apache.maven.plugins - maven-surefire-report-plugin - ${commons.surefire-report.version} - - ${commons.surefire-report.aggregate} - - - - - org.apache.rat - apache-rat-plugin - ${commons.rat.version} - - - - - site-content/** - .checkstyle - .fbprefs - .pmd - src/site/resources/download_*.cgi - src/site/resources/profile.* - - - - - org.codehaus.mojo - clirr-maven-plugin - ${commons.clirr.version} - - ${minSeverity} - - - - org.codehaus.mojo - jdepend-maven-plugin - ${commons.jdepend.version} - - - - - - - - - parse-target-version - - - - user.home - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - parse-version - - - parse-version - - - javaTarget - ${maven.compiler.target} - - - - - - - - - - - - animal-sniffer - - - - src/site/resources/profile.noanimal - - - - - - java${javaTarget.majorVersion}${javaTarget.minorVersion} - - - - - - - - org.codehaus.mojo - animal-sniffer-maven-plugin - ${commons.animal-sniffer.version} - - - checkAPIcompatibility - - - - check - - - - - - org.codehaus.mojo.signature - ${animal-sniffer.signature} - ${commons.animal-sniffer.signature.version} - - - - - - - - - - jacoco - - - - src/site/resources/profile.jacoco - - - - - - org.jacoco - jacoco-maven-plugin - ${commons.jacoco.version} - - - - prepare-agent - process-test-classes - - prepare-agent - - - - report - site - - report - - - - check - - check - - - - - BUNDLE - - - CLASS - COVEREDRATIO - ${commons.jacoco.classRatio} - - - INSTRUCTION - COVEREDRATIO - ${commons.jacoco.instructionRatio} - - - METHOD - COVEREDRATIO - ${commons.jacoco.methodRatio} - - - BRANCH - COVEREDRATIO - ${commons.jacoco.branchRatio} - - - LINE - COVEREDRATIO - ${commons.jacoco.lineRatio} - - - COMPLEXITY - COVEREDRATIO - ${commons.jacoco.complexityRatio} - - - - - ${commons.jacoco.haltOnFailure} - - - - - - - - - - org.jacoco - jacoco-maven-plugin - ${commons.jacoco.version} - - - - - - - cobertura - - - src/site/resources/profile.cobertura - - - - - - org.codehaus.mojo - cobertura-maven-plugin - ${commons.cobertura.version} - - - - - - - - release - - - - - maven-gpg-plugin - - ${gpg.passphrase} - - - - sign-artifacts - verify - - sign - - - - - - maven-install-plugin - - true - - - - maven-source-plugin - - - create-source-jar - - jar - test-jar - - - - - - maven-jar-plugin - - - - test-jar - - - - true - - - - - - maven-release-plugin - - - -Prelease - - - - maven-javadoc-plugin - - - create-javadoc-jar - - javadoc - jar - - package - - - - ${maven.compiler.source} - - - - maven-assembly-plugin - true - - - - single - - package - - - - - - - - - - apache-release - - - - maven-release-plugin - - apache-release - - - - org.apache.maven.plugins - maven-source-plugin - - - attach-test-sources - - test-jar - - - - - - maven-install-plugin - - true - - - - org.apache.maven.plugins - maven-jar-plugin - - - - test-jar - - - - - - - - - - - java-1.3 - - true - 1.3 - ${JAVA_1_3_HOME}/bin/javac - ${JAVA_1_3_HOME}/bin/java - - - - - - java-1.4 - - true - 1.4 - ${JAVA_1_4_HOME}/bin/javac - ${JAVA_1_4_HOME}/bin/java - - 2.11 - - - - - - java-1.5 - - true - 1.5 - ${JAVA_1_5_HOME}/bin/javac - ${JAVA_1_5_HOME}/bin/java - - - - - - java-1.6 - - true - 1.6 - ${JAVA_1_6_HOME}/bin/javac - ${JAVA_1_6_HOME}/bin/java - - - - - - java-1.7 - - true - 1.7 - ${JAVA_1_7_HOME}/bin/javac - ${JAVA_1_7_HOME}/bin/java - - - - - - java-1.8 - - true - 1.8 - ${JAVA_1_8_HOME}/bin/javac - ${JAVA_1_8_HOME}/bin/java - - - - - - java-1.9 - - true - 1.9 - ${JAVA_1_9_HOME}/bin/javac - ${JAVA_1_9_HOME}/bin/java - - - - - - - - test-deploy - - id::default::file:target/deploy - - - - - - release-notes - - - - org.apache.maven.plugins - maven-changes-plugin - ${commons.changes.version} - - - src/changes - true - . - RELEASE-NOTES.txt - - ${commons.release.version} - - - - - create-release-notes - generate-resources - - announcement-generate - - - - - - - - - - - svn-buildnumber - - - !buildNumber.skip - !true - - - - - - org.codehaus.mojo - buildnumber-maven-plugin - - - generate-resources - - create - - - - - - true - - ?????? - false - false - - - - - - - - javasvn - - - - org.codehaus.mojo - buildnumber-maven-plugin - - - javasvn - - - - - - - - - jdk7-plugin-fix-version - - [1.7,) - - - - 3.0.0 - - 1.14 - - - - - - site-basic - - true - true - true - true - true - true - true - true - true - true - - - - - - - - ${project.version} - RC1 - COMMONSSITE - - - - 1.3 - 1.3 - - - false - - - - - - 2.18.1 - 2.18.1 - 2.10.3 - 0.11 - 2.11 - 2.6.1 - 2.5 - 2.8 - 2.8 - 3.4 - 0.7.5.201505241946 - 2.7 - 2.0 - 3.3 - 1.1 - 2.5.5 - - 1.11 - - 1.0 - - - ${project.artifactId}-${commons.release.version} - - -bin - ${project.artifactId}-${commons.release.2.version} - - -bin - ${project.artifactId}-${commons.release.3.version} - - -bin - - - 1.00 - 0.90 - 0.95 - 0.85 - 0.85 - 0.90 - false - - - ${project.artifactId} - - - org.apache.commons.${commons.componentid} - org.apache.commons.*;version=${project.version};-noimport:=true - * - - - true - - - ${project.build.directory}/osgi/MANIFEST.MF - - - scp - - - iso-8859-1 - - ${commons.encoding} - - ${commons.encoding} - - ${commons.encoding} - - - http://docs.oracle.com/javase/7/docs/api/ - http://docs.oracle.com/javaee/6/api/ - - - yyyy-MM-dd HH:mm:ssZ - ${scmBranch}@r${buildNumber}; ${maven.build.timestamp} - - - info - - - 100 - - - false - - - false - - 100 - - false - - - ${user.home}/commons-sites - - ${project.artifactId} - - https://svn.apache.org/repos/infra/websites/production/commons/content/proper/${project.artifactId} - ${commons.site.cache}/${commons.site.path} - commons.site - - https://analysis.apache.org/ - - - - + + From cb1f9f42ce395e96bb6cd07bfe320faa49f06838 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Mon, 17 Apr 2023 11:16:52 +0200 Subject: [PATCH 05/74] Switch to junit 5 (#2) --- pom.xml | 6 +-- .../util/xml/PrettyPrintXMLWriterTest.java | 43 +++++++------------ .../plexus/util/xml/XmlStreamReaderTest.java | 36 ++++++++++------ .../plexus/util/xml/XmlStreamWriterTest.java | 6 +-- .../codehaus/plexus/util/xml/XmlUtilTest.java | 7 ++- .../plexus/util/xml/XmlWriterUtilTest.java | 15 +++---- .../plexus/util/xml/Xpp3DomBuilderTest.java | 40 ++++++++--------- .../codehaus/plexus/util/xml/Xpp3DomTest.java | 12 ++---- .../plexus/util/xml/Xpp3DomUtilsTest.java | 7 ++- .../plexus/util/xml/Xpp3DomWriterTest.java | 10 ++--- ...onformanceTestSuite_Production24_Test.java | 12 +++--- ...ConformanceTestSuite_Production2_Test.java | 12 +++--- ...onformanceTestSuite_Production32_Test.java | 12 +++--- ...onformanceTestSuite_Production66_Test.java | 12 +++--- ...onformanceTestSuite_Production80_Test.java | 12 +++--- .../plexus/util/xml/pull/MXParserTest.java | 14 +++--- ..._BjoernHoehrmannviaHST2013_09_18_Test.java | 15 ++++--- 17 files changed, 128 insertions(+), 143 deletions(-) diff --git a/pom.xml b/pom.xml index de4e34bf..b231c210 100644 --- a/pom.xml +++ b/pom.xml @@ -71,9 +71,9 @@ limitations under the License. test - junit - junit - 4.13.2 + org.junit.jupiter + junit-jupiter + 5.9.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 76125f95..af0bf253 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java @@ -16,10 +16,6 @@ * limitations under the License. */ -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - import java.io.File; import java.io.IOException; import java.io.OutputStreamWriter; @@ -30,9 +26,14 @@ 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 org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +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} @@ -51,7 +52,7 @@ public class PrettyPrintXMLWriterTest /** *

setUp.

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

tearDown.

*/ - @After + @AfterEach public void tearDown() { writer = null; @@ -161,18 +162,12 @@ public void testEscapeXmlAttribute() @Test public void testendElementAlreadyClosed() { - try - { + assertThrows(NoSuchElementException.class, () -> { writer.startElement( Tag.DIV.toString() ); writer.addAttribute( "class", "someattribute" ); writer.endElement(); // Tag.DIV closed writer.endElement(); // Tag.DIV already closed, and there is no other outer tag! - fail( "Should throw a NoSuchElementException" ); - } - catch ( NoSuchElementException e ) - { - assert ( true ); - } + }); } /** @@ -190,16 +185,15 @@ public void testIssue51DetectJava7ConcatenationBug() 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" ); - writer = new PrettyPrintXMLWriter( osw ); int iterations = 20000; - try + try ( OutputStreamWriter osw = new OutputStreamWriter( Files.newOutputStream( xmlFile.toPath() ), "UTF-8" ) ) { + writer = new PrettyPrintXMLWriter( osw ); for ( int i = 0; i < iterations; ++i ) { writer.startElement( Tag.DIV.toString() + i ); @@ -214,13 +208,6 @@ public void testIssue51DetectJava7ConcatenationBug() { fail( "Should not throw a NoSuchElementException" ); } - finally - { - if ( osw != null ) - { - osw.close(); - } - } } private void writeXhtmlHead( XMLWriter writer ) 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..3fe0b515 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/XmlStreamReaderTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/XmlStreamReaderTest.java @@ -23,8 +23,12 @@ import org.codehaus.plexus.util.IOUtil; -import junit.framework.ComparisonFailure; -import junit.framework.TestCase; +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; +import static org.junit.jupiter.api.Assertions.fail; /** *

XmlStreamReaderTest class.

@@ -34,7 +38,6 @@ * @since 3.4.0 */ public class XmlStreamReaderTest - extends TestCase { /** french */ private static final String TEXT_LATIN1 = "eacute: \u00E9"; @@ -127,6 +130,7 @@ private static void checkXmlStreamReader( String text, String encoding, String e * * @throws java.io.IOException if any. */ + @Test public void testNoXmlHeader() throws IOException { @@ -140,6 +144,7 @@ public void testNoXmlHeader() * * @throws java.io.IOException if any. */ + @Test public void testDefaultEncoding() throws IOException { @@ -152,6 +157,7 @@ public void testDefaultEncoding() * * @throws java.io.IOException if any. */ + @Test public void testUTF8Encoding() throws IOException { @@ -164,6 +170,7 @@ public void testUTF8Encoding() * * @throws java.io.IOException if any. */ + @Test public void testUTF16Encoding() throws IOException { @@ -177,6 +184,7 @@ public void testUTF16Encoding() * * @throws java.io.IOException if any. */ + @Test public void testUTF16BEEncoding() throws IOException { @@ -188,6 +196,7 @@ public void testUTF16BEEncoding() * * @throws java.io.IOException if any. */ + @Test public void testUTF16LEEncoding() throws IOException { @@ -199,6 +208,7 @@ public void testUTF16LEEncoding() * * @throws java.io.IOException if any. */ + @Test public void testLatin1Encoding() throws IOException { @@ -210,6 +220,7 @@ public void testLatin1Encoding() * * @throws java.io.IOException if any. */ + @Test public void testLatin7Encoding() throws IOException { @@ -221,6 +232,7 @@ public void testLatin7Encoding() * * @throws java.io.IOException if any. */ + @Test public void testLatin15Encoding() throws IOException { @@ -232,6 +244,7 @@ public void testLatin15Encoding() * * @throws java.io.IOException if any. */ + @Test public void testEUC_JPEncoding() throws IOException { @@ -243,6 +256,7 @@ public void testEUC_JPEncoding() * * @throws java.io.IOException if any. */ + @Test public void testEBCDICEncoding() throws IOException { @@ -254,18 +268,15 @@ public void testEBCDICEncoding() * * @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" + ); } /** @@ -273,6 +284,7 @@ public void testInappropriateEncoding() * * @throws java.io.IOException if any. */ + @Test public void testEncodingAttribute() throws IOException { 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..b699f732 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. * @@ -21,7 +19,9 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +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 bb564ad5..3b54f16f 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; @@ -30,7 +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.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 145f0f10..eb8041f7 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/XmlWriterUtilTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/XmlWriterUtilTest.java @@ -16,17 +16,16 @@ * 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; 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.jupiter.api.Assertions.*; /** *

XmlWriterUtilTest class.

@@ -48,7 +47,7 @@ public class XmlWriterUtilTest * * @throws java.lang.Exception if any. */ - @Before + @BeforeEach public void setUp() throws Exception { @@ -62,7 +61,7 @@ public void setUp() * * @throws java.lang.Exception if any. */ - @After + @AfterEach public void tearDown() throws Exception { 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..bd696d62 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; @@ -27,7 +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.jupiter.api.Assertions.*; /** * Test the Xpp3DomBuilder. @@ -55,7 +53,7 @@ public void testBuildFromReader() Xpp3Dom expectedDom = createExpectedDom(); - assertEquals( "check DOMs match", expectedDom, dom ); + assertEquals( expectedDom, dom, "check DOMs match" ); } /** @@ -71,11 +69,11 @@ public void testBuildTrimming() 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" ); } /** @@ -132,10 +130,10 @@ else if ( "root".equals( rawName ) ) 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" ); } /** @@ -173,13 +171,13 @@ public void testEscapingInContent() { 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" ); } /** @@ -195,12 +193,12 @@ public void testEscapingInAttributes() 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" ); } /** @@ -222,18 +220,18 @@ 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 ec4f4ee3..5dbdc2c3 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomTest.java @@ -16,14 +16,6 @@ * limitations under the License. */ -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -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.ArrayList; @@ -35,7 +27,9 @@ import org.apache.maven.internal.xml.XmlNodeImpl; 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.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 74c08baf..0f700dd2 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomUtilsTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomUtilsTest.java @@ -16,15 +16,14 @@ * limitations under the License. */ -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - import java.io.IOException; import java.io.StringReader; 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.jupiter.api.Assertions.*; /** *

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 93c00a7d..8076b37f 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomWriterTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomWriterTest.java @@ -16,11 +16,11 @@ * limitations under the License. */ -import static org.junit.Assert.assertEquals; - import java.io.StringWriter; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; /** *

Xpp3DomWriterTest class.

@@ -43,7 +43,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" ); } /** @@ -56,7 +56,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 458d800f..0d183346 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,15 +1,15 @@ 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; 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.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 @@ public class IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMX /** *

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 92998db9..4cb0a8ce 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 @@ -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.BufferedReader; import java.io.File; import java.io.FileInputStream; @@ -15,8 +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.Test; +import org.junit.jupiter.api.BeforeEach; + +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. @@ -36,7 +36,7 @@ public class IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMX /** *

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 a6a80030..9a877456 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,15 +1,15 @@ 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; 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.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 @@ public class IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMX /** *

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 639f1589..2d697b02 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 @@ -1,17 +1,17 @@ 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.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.Reader; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.BeforeEach; + +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 IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMX /** *

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 e5510bb5..7d7fc20a 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,15 +1,15 @@ 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; 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.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 @@ public class IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMX /** *

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 e0d77330..e5754180 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,14 +16,8 @@ * 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.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -35,7 +29,9 @@ import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.xml.XmlStreamReader; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; /** *

MXParserTest class.

@@ -1132,8 +1128,8 @@ public void testEncodingUTF8_newXmlReader() 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 7d2f6299..8c174f54 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,16 +1,17 @@ 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; import java.io.IOException; import java.io.InputStream; 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.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 +32,7 @@ public class eduni_misc_Test_BjoernHoehrmannviaHST2013_09_18_Test /** *

setUp.

*/ - @Before + @BeforeEach public void setUp() { parser = new MXParser(); @@ -271,7 +272,7 @@ public void testhst_lhs_009() } catch ( XmlPullParserException e ) { - assertTrue( e.getMessage(), e.getMessage().contains( "UTF-16 BOM in a UTF-8 encoded file is incompatible" ) ); + assertTrue( e.getMessage().contains( "UTF-16 BOM in a UTF-8 encoded file is incompatible" ), e.getMessage() ); } } From 3803a07e9f27574ea15c2922df3a9baf7a0a66bd Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Mon, 17 Apr 2023 13:20:18 +0200 Subject: [PATCH 06/74] Add deploy job --- .github/workflows/maven.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 81f67f61..39970153 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -23,3 +23,9 @@ jobs: build: name: Build it uses: codehaus-plexus/.github/.github/workflows/maven.yml@v0.0.5 + + deploy: + name: Deploy + needs: build + uses: mojohaus/.github/.github/workflows/maven-deploy.yml@master + secrets: inherit From b341280bc7880479356822509a08bf139c67ef90 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Wed, 19 Apr 2023 07:49:53 +0200 Subject: [PATCH 07/74] Use codehaus-plexus deploy job --- .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 39970153..fd924e7d 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -27,5 +27,5 @@ jobs: deploy: name: Deploy needs: build - uses: mojohaus/.github/.github/workflows/maven-deploy.yml@master + uses: codehaus-plexus/.github/.github/workflows/maven-deploy.yml@master secrets: inherit From d0c0bc623e1bbd4209be2186f5020e0ba50e8567 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 08/74] 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 e5754180..b5c7b908 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 @@ -1270,7 +1270,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.

* @@ -1288,7 +1288,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.

* @@ -1333,7 +1333,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.

* @@ -1351,7 +1351,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 02e2c78aaceae90d58770fdaf8dbfb62e3c92a0b Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Wed, 10 May 2023 13:40:42 +0200 Subject: [PATCH 09/74] 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 b231c210..0579cd01 100644 --- a/pom.xml +++ b/pom.xml @@ -81,14 +81,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 @@ -126,7 +166,7 @@ limitations under the License. true - + JAVA_HOME ${JAVA_HOME} @@ -135,7 +175,7 @@ limitations under the License. M2_HOME ${M2_HOME} - + From 8351c4ec5eb6bdeeccdb9bc49c03f167d6c64269 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Wed, 10 May 2023 13:43:46 +0200 Subject: [PATCH 10/74] Use a ArrayDeque and enable test only for JDK < 1.8 (#5) --- .../plexus/util/xml/PrettyPrintXMLWriter.java | 11 ++++------- .../plexus/util/xml/PrettyPrintXMLWriterTest.java | 7 +++++-- 2 files changed, 9 insertions(+), 9 deletions(-) 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..c01109c9 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriter.java +++ b/src/main/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriter.java @@ -18,6 +18,8 @@ import java.io.PrintWriter; import java.io.Writer; +import java.util.ArrayDeque; +import java.util.Deque; import java.util.LinkedList; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -35,7 +37,7 @@ public class PrettyPrintXMLWriter private PrintWriter writer; - private LinkedList elementStack = new LinkedList(); + private final Deque elementStack = new ArrayDeque<>(); private boolean tagInProgress; @@ -307,11 +309,6 @@ public void endElement() { finishTag(); - // see issue #51: https://github.com/codehaus-plexus/plexus-utils/issues/51 - // Rationale: replaced 1 write() with string concatenations with 3 write() - // (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( "" ); @@ -518,7 +515,7 @@ protected String getDocType() /** * @return the current elementStack; */ - protected LinkedList getElementStack() + protected Deque getElementStack() { return elementStack; } 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 af0bf253..bb004c73 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java @@ -18,8 +18,9 @@ import java.io.File; import java.io.IOException; -import java.io.OutputStreamWriter; import java.io.StringWriter; +import java.io.Writer; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.NoSuchElementException; @@ -28,6 +29,7 @@ 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; @@ -178,6 +180,7 @@ public void testendElementAlreadyClosed() * * @throws java.io.IOException if an I/O error occurs */ + @Disabled( "This test is only relevant on JDK 1.7, which is not supported anymore" ) @Test public void testIssue51DetectJava7ConcatenationBug() throws IOException @@ -191,7 +194,7 @@ public void testIssue51DetectJava7ConcatenationBug() int iterations = 20000; - try ( OutputStreamWriter osw = new OutputStreamWriter( Files.newOutputStream( xmlFile.toPath() ), "UTF-8" ) ) + try ( Writer osw = Files.newBufferedWriter( xmlFile.toPath(), StandardCharsets.UTF_8 ) ) { writer = new PrettyPrintXMLWriter( osw ); for ( int i = 0; i < iterations; ++i ) From 85fe71e68e91de21000ba2f0d97ff73e020fd143 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Sun, 14 May 2023 22:35:08 +0200 Subject: [PATCH 11/74] Deprecate Xpp3DomUtils (fixes #6) (#9) --- .../org/codehaus/plexus/util/xml/Xpp3Dom.java | 22 +- .../plexus/util/xml/Xpp3DomUtils.java | 246 ++++-------------- .../codehaus/plexus/util/xml/Xpp3DomTest.java | 107 ++++++++ .../plexus/util/xml/Xpp3DomUtilsTest.java | 219 ---------------- 4 files changed, 175 insertions(+), 419 deletions(-) delete mode 100644 src/test/java/org/codehaus/plexus/util/xml/Xpp3DomUtilsTest.java 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 7512c507..2046da3f 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/Xpp3Dom.java +++ b/src/main/java/org/codehaus/plexus/util/xml/Xpp3Dom.java @@ -35,26 +35,26 @@ public class Xpp3Dom { private static final String[] EMPTY_STRING_ARRAY = new String[0]; - public static final String CHILDREN_COMBINATION_MODE_ATTRIBUTE = "combine.children"; + public static final String CHILDREN_COMBINATION_MODE_ATTRIBUTE = XmlNode.CHILDREN_COMBINATION_MODE_ATTRIBUTE; - public static final String CHILDREN_COMBINATION_MERGE = "merge"; + public static final String CHILDREN_COMBINATION_MERGE = XmlNode.CHILDREN_COMBINATION_MERGE; - public static final String CHILDREN_COMBINATION_APPEND = "append"; + public static final String CHILDREN_COMBINATION_APPEND = XmlNode.CHILDREN_COMBINATION_APPEND; /** * This default mode for combining children DOMs during merge means that where element names match, the process will * try to merge the element data, rather than putting the dominant and recessive elements (which share the same * element name) as siblings in the resulting DOM. */ - public static final String DEFAULT_CHILDREN_COMBINATION_MODE = CHILDREN_COMBINATION_MERGE; + public static final String DEFAULT_CHILDREN_COMBINATION_MODE = XmlNode.DEFAULT_CHILDREN_COMBINATION_MODE; - public static final String SELF_COMBINATION_MODE_ATTRIBUTE = "combine.self"; + public static final String SELF_COMBINATION_MODE_ATTRIBUTE = XmlNode.SELF_COMBINATION_MODE_ATTRIBUTE; - public static final String SELF_COMBINATION_OVERRIDE = "override"; + public static final String SELF_COMBINATION_OVERRIDE = XmlNode.SELF_COMBINATION_OVERRIDE; - public static final String SELF_COMBINATION_MERGE = "merge"; + public static final String SELF_COMBINATION_MERGE = XmlNode.SELF_COMBINATION_MERGE; - public static final String SELF_COMBINATION_REMOVE = "remove"; + public static final String SELF_COMBINATION_REMOVE = XmlNode.SELF_COMBINATION_REMOVE; /** * This default mode for combining a DOM node during merge means that where element names match, the process will @@ -62,7 +62,11 @@ public class Xpp3Dom * dominant one. This means that wherever the dominant element doesn't provide the value or a particular attribute, * that value or attribute will be set from the recessive DOM node. */ - public static final String DEFAULT_SELF_COMBINATION_MODE = SELF_COMBINATION_MERGE; + public static final String DEFAULT_SELF_COMBINATION_MODE = XmlNode.DEFAULT_SELF_COMBINATION_MODE; + + public static final String ID_COMBINATION_MODE_ATTRIBUTE = XmlNode.ID_COMBINATION_MODE_ATTRIBUTE; + + public static final String KEYS_COMBINATION_MODE_ATTRIBUTE = XmlNode.KEYS_COMBINATION_MODE_ATTRIBUTE; private ChildrenTracking childrenTracking; private XmlNode dom; 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..6fda3eb4 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/Xpp3DomUtils.java +++ b/src/main/java/org/codehaus/plexus/util/xml/Xpp3DomUtils.java @@ -23,207 +23,77 @@ import org.codehaus.plexus.util.xml.pull.XmlSerializer; /** @author Jason van Zyl */ +@Deprecated public class Xpp3DomUtils { - public static final String CHILDREN_COMBINATION_MODE_ATTRIBUTE = "combine.children"; - - public static final String CHILDREN_COMBINATION_MERGE = "merge"; + /** + * @deprecated use {@link Xpp3Dom#CHILDREN_COMBINATION_MODE_ATTRIBUTE} + */ + @Deprecated + public static final String CHILDREN_COMBINATION_MODE_ATTRIBUTE = Xpp3Dom.CHILDREN_COMBINATION_MODE_ATTRIBUTE; - public static final String CHILDREN_COMBINATION_APPEND = "append"; + /** + * @deprecated use {@link Xpp3Dom#CHILDREN_COMBINATION_MERGE} + */ + @Deprecated + public static final String CHILDREN_COMBINATION_MERGE = Xpp3Dom.CHILDREN_COMBINATION_MERGE; /** - * This default mode for combining children DOMs during merge means that where element names match, the process will - * try to merge the element data, rather than putting the dominant and recessive elements (which share the same - * element name) as siblings in the resulting DOM. + * @deprecated use {@link Xpp3Dom#CHILDREN_COMBINATION_APPEND} */ - public static final String DEFAULT_CHILDREN_COMBINATION_MODE = CHILDREN_COMBINATION_MERGE; + @Deprecated + public static final String CHILDREN_COMBINATION_APPEND = Xpp3Dom.CHILDREN_COMBINATION_APPEND; - public static final String SELF_COMBINATION_MODE_ATTRIBUTE = "combine.self"; + /** + * @deprecated use {@link Xpp3Dom#DEFAULT_CHILDREN_COMBINATION_MODE} + */ + @Deprecated + public static final String DEFAULT_CHILDREN_COMBINATION_MODE = Xpp3Dom.DEFAULT_CHILDREN_COMBINATION_MODE; - public static final String SELF_COMBINATION_OVERRIDE = "override"; + /** + * @deprecated use {@link Xpp3Dom#SELF_COMBINATION_MODE_ATTRIBUTE} + */ + @Deprecated + public static final String SELF_COMBINATION_MODE_ATTRIBUTE = Xpp3Dom.SELF_COMBINATION_MODE_ATTRIBUTE; - public static final String SELF_COMBINATION_MERGE = "merge"; + /** + * @deprecated use {@link Xpp3Dom#SELF_COMBINATION_OVERRIDE} + */ + @Deprecated + public static final String SELF_COMBINATION_OVERRIDE = Xpp3Dom.SELF_COMBINATION_OVERRIDE; /** - * In case of complex XML structures, combining can be done based on id. - * - * @since 3.0.22 + * @deprecated use {@link Xpp3Dom#SELF_COMBINATION_MERGE} */ - public static final String ID_COMBINATION_MODE_ATTRIBUTE = "combine.id"; - + @Deprecated + public static final String SELF_COMBINATION_MERGE = Xpp3Dom.SELF_COMBINATION_MERGE; + /** - * 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 + * @deprecated use {@link Xpp3Dom#ID_COMBINATION_MODE_ATTRIBUTE} */ - public static final String KEYS_COMBINATION_MODE_ATTRIBUTE = "combine.keys"; + @Deprecated + public static final String ID_COMBINATION_MODE_ATTRIBUTE = Xpp3Dom.ID_COMBINATION_MODE_ATTRIBUTE; /** - * This default mode for combining a DOM node during merge means that where element names match, the process will - * try to merge the element attributes and values, rather than overriding the recessive element completely with the - * dominant one. This means that wherever the dominant element doesn't provide the value or a particular attribute, - * that value or attribute will be set from the recessive DOM node. + * @deprecated use {@link Xpp3Dom#KEYS_COMBINATION_MODE_ATTRIBUTE} */ - public static final String DEFAULT_SELF_COMBINATION_MODE = SELF_COMBINATION_MERGE; + @Deprecated + public static final String KEYS_COMBINATION_MODE_ATTRIBUTE = Xpp3Dom.KEYS_COMBINATION_MODE_ATTRIBUTE; - 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 ); - } - } + /** + * @deprecated use {@link Xpp3Dom#DEFAULT_SELF_COMBINATION_MODE} + */ + @Deprecated + public static final String DEFAULT_SELF_COMBINATION_MODE = Xpp3Dom.DEFAULT_SELF_COMBINATION_MODE; /** - * Merges one DOM into another, given a specific algorithm and possible override points for that algorithm.

- * The algorithm is as follows: - *

    - *
  1. if the recessive DOM is null, there is nothing to do... return.
  2. - *
  3. Determine whether the dominant node will suppress the recessive one (flag=mergeSelf). - *
      - *
    1. retrieve the 'combine.self' attribute on the dominant node, and try to match against 'override'... - * if it matches 'override', then set mergeSelf == false...the dominant node suppresses the recessive one - * completely.
    2. - *
    3. otherwise, use the default value for mergeSelf, which is true...this is the same as specifying - * 'combine.self' == 'merge' as an attribute of the dominant root node.
    4. - *
  4. - *
  5. If mergeSelf == true - *
      - *
    1. Determine whether children from the recessive DOM will be merged or appended to the dominant DOM as - * siblings (flag=mergeChildren). - *
        - *
      1. if childMergeOverride is set (non-null), use that value (true/false)
      2. - *
      3. retrieve the 'combine.children' attribute on the dominant node, and try to match against - * 'append'...
      4. - *
      5. if it matches 'append', then set mergeChildren == false...the recessive children will be appended as - * siblings of the dominant children.
      6. - *
      7. otherwise, use the default value for mergeChildren, which is true...this is the same as specifying - * 'combine.children' == 'merge' as an attribute on the dominant root node.
      8. - *
    2. - *
    3. Iterate through the recessive children, and: - *
        - *
      1. if 'combine.id' is set and there is a corresponding dominant child (matched by value of 'combine.id'), - * merge the two.
      2. - *
      3. if 'combine.keys' is set and there is a corresponding dominant child (matched by value of key elements), - * merge the two.
      4. - *
      5. if mergeChildren == true and there is a corresponding dominant child (matched by element name), - * merge the two.
      6. - *
      7. otherwise, add the recessive child as a new child on the dominant root node.
      8. - *
    4. - *
  6. - *
+ * @deprecated use {@link Xpp3Dom#writeToSerializer(String, XmlSerializer)} */ - private static void mergeIntoXpp3Dom( Xpp3Dom dominant, Xpp3Dom recessive, Boolean childMergeOverride ) + @Deprecated + public void writeToSerializer( String namespace, XmlSerializer serializer, Xpp3Dom dom ) + throws IOException { - // TODO: share this as some sort of assembler, implement a walk interface? - if ( recessive == null ) - { - return; - } - - boolean mergeSelf = true; - - String selfMergeMode = dominant.getAttribute( SELF_COMBINATION_MODE_ATTRIBUTE ); - - if ( isNotEmpty( selfMergeMode ) && SELF_COMBINATION_OVERRIDE.equals( selfMergeMode ) ) - { - mergeSelf = false; - } - - if ( mergeSelf ) - { - String[] recessiveAttrs = recessive.getAttributeNames(); - for ( String attr : recessiveAttrs ) - { - if ( isEmpty( dominant.getAttribute( attr ) ) ) - { - dominant.setAttribute( attr, recessive.getAttribute( attr ) ); - } - } - - boolean mergeChildren = true; - - if ( childMergeOverride != null ) - { - mergeChildren = childMergeOverride; - } - else - { - String childMergeMode = dominant.getAttribute( CHILDREN_COMBINATION_MODE_ATTRIBUTE ); - - if ( isNotEmpty( childMergeMode ) && CHILDREN_COMBINATION_APPEND.equals( childMergeMode ) ) - { - mergeChildren = false; - } - } - - 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 ); - - Xpp3Dom childDom = null; - 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 ) ); - } - - 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 ) ) - { - 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 - { - dominant.addChild( new Xpp3Dom( recessiveChild ) ); - } - } - } + dom.writeToSerializer( namespace, serializer ); } /** @@ -236,15 +106,12 @@ else if ( isNotEmpty( keysValue ) ) * @param childMergeOverride Overrides attribute flags to force merging or appending of child elements into the * dominant DOM * @return merged DOM + * @deprecated use {@link Xpp3Dom#mergeXpp3Dom(Xpp3Dom, Xpp3Dom, Boolean)} */ + @Deprecated public static Xpp3Dom mergeXpp3Dom( Xpp3Dom dominant, Xpp3Dom recessive, Boolean childMergeOverride ) { - if ( dominant != null ) - { - mergeIntoXpp3Dom( dominant, recessive, childMergeOverride ); - return dominant; - } - return recessive; + return Xpp3Dom.mergeXpp3Dom( dominant, recessive, childMergeOverride ); } /** @@ -256,15 +123,12 @@ public static Xpp3Dom mergeXpp3Dom( Xpp3Dom dominant, Xpp3Dom recessive, Boolean * @param dominant The dominant DOM into which the recessive value/attributes/children will be merged * @param recessive The recessive DOM, which will be merged into the dominant DOM * @return merged DOM + * @deprecated use {@link Xpp3Dom#mergeXpp3Dom(Xpp3Dom, Xpp3Dom)} */ + @Deprecated public static Xpp3Dom mergeXpp3Dom( Xpp3Dom dominant, Xpp3Dom recessive ) { - if ( dominant != null ) - { - mergeIntoXpp3Dom( dominant, recessive, null ); - return dominant; - } - return recessive; + return Xpp3Dom.mergeXpp3Dom( dominant, recessive ); } /** 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 5dbdc2c3..469bb3f8 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomTest.java @@ -422,6 +422,113 @@ public void testShouldRemoveDoNotRemoveTagWhenSwappedInputDOMs() assertEquals( recessiveConfig.toString(), result.toString() ); } + /** + *

testCombineId.

+ * + * @throws java.lang.Exception if any. + */ + @Test + public void testCombineId() + throws Exception + { + String lhs = "" + "LHS-ONLYLHS" + + "TOOVERWRITELHS" + ""; + + String rhs = "" + "RHS-ONLYRHS" + + "TOOVERWRITERHS" + ""; + + Xpp3Dom leftDom = Xpp3DomBuilder.build( new StringReader( lhs ), new Xpp3DomTest.FixedInputLocationBuilder( "left" ) ); + Xpp3Dom rightDom = Xpp3DomBuilder.build( new StringReader( rhs ), new Xpp3DomTest.FixedInputLocationBuilder( "right" ) ); + + Xpp3Dom mergeResult = Xpp3Dom.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() ); + } + + /** + *

testCombineKeys.

+ * + * @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 Xpp3DomTest.FixedInputLocationBuilder( "left" ) ); + Xpp3Dom rightDom = Xpp3DomBuilder.build( new StringReader( rhs ), new Xpp3DomTest.FixedInputLocationBuilder( "right" ) ); + + Xpp3Dom mergeResult = Xpp3Dom.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 + public void testPreserveDominantBlankValue() throws XmlPullParserException, IOException { + String lhs = " "; + + String rhs = "recessive"; + + Xpp3Dom leftDom = Xpp3DomBuilder.build( new StringReader( lhs ), new Xpp3DomTest.FixedInputLocationBuilder( "left" ) ); + Xpp3Dom rightDom = Xpp3DomBuilder.build( new StringReader( rhs ), new Xpp3DomTest.FixedInputLocationBuilder( "right" ) ); + + Xpp3Dom mergeResult = Xpp3Dom.mergeXpp3Dom( leftDom, rightDom, true ); + assertEquals( " ", mergeResult.getValue() ); + } + + @Test + public void testPreserveDominantEmptyNode() throws XmlPullParserException, IOException + { + String lhs = ""; + + String rhs = "recessive"; + + Xpp3Dom leftDom = Xpp3DomBuilder.build( new StringReader( lhs ), new Xpp3DomTest.FixedInputLocationBuilder( "left" ) ); + Xpp3Dom rightDom = Xpp3DomBuilder.build( new StringReader( rhs ), new Xpp3DomTest.FixedInputLocationBuilder( "right" ) ); + + Xpp3Dom mergeResult = Xpp3Dom.mergeXpp3Dom( leftDom, rightDom, true ); + assertEquals( "", mergeResult.getValue() ); + } + private static class FixedInputLocationBuilder implements Xpp3DomBuilder.InputLocationBuilder { diff --git a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomUtilsTest.java b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomUtilsTest.java deleted file mode 100644 index 0f700dd2..00000000 --- a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomUtilsTest.java +++ /dev/null @@ -1,219 +0,0 @@ -package org.codehaus.plexus.util.xml; - -/* - * Copyright The Codehaus Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.io.IOException; -import java.io.StringReader; - -import org.codehaus.plexus.util.xml.pull.XmlPullParser; -import org.codehaus.plexus.util.xml.pull.XmlPullParserException; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.*; - -/** - *

Xpp3DomUtilsTest class.

- * - * @author herve - * @version $Id: $Id - * @since 3.4.0 - */ -public class Xpp3DomUtilsTest -{ - /** - *

testCombineId.

- * - * @throws java.lang.Exception if any. - */ - @Test - public void testCombineId() - 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() ); - } - - /** - *

testCombineKeys.

- * - * @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() ); - } - - @Test - public void testPreserveDominantBlankValue() 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 mergeResult = Xpp3DomUtils.mergeXpp3Dom( leftDom, rightDom, true ); - assertEquals( " ", mergeResult.getValue() ); - } - - @Test - 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 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" ) ); - } - - /** - *

testShouldMergeValuesAtTopLevelByDefault.

- */ - @Test - public void testShouldNotMergeValuesAtTopLevelByDefault() - { - // create the dominant DOM - 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" ); - - // merge and check results. - Xpp3Dom result = Xpp3DomUtils.mergeXpp3Dom( t1, t2 ); - - // this is still 2, since we're not using the merge-control attribute. - assertEquals( 2, result.getAttributeNames().length ); - - assertEquals( result.getValue(), t1.getValue() ); - assertEquals( "t1top", result.getInputLocation() ); - } - - /** - *

testShouldMergeValuesAtTopLevel.

- */ - @Test - public void testShouldNotMergeValues() - { - // create the dominant DOM - Xpp3Dom t1 = new Xpp3Dom( "top" ); - t1.setAttribute( "attr", "value" ); - - 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" ); - - // merge and check results. - Xpp3Dom result = Xpp3DomUtils.mergeXpp3Dom( t1, t2 ); - - assertEquals( 3, result.getAttributeNames().length ); - assertNull( result.getValue(), t1.getValue() ); - } - - private static class FixedInputLocationBuilder - implements Xpp3DomBuilder.InputLocationBuilder - { - private final Object location; - - public FixedInputLocationBuilder( Object location ) - { - this.location = location; - } - - public Object toInputLocation( XmlPullParser parser ) - { - return location; - } - } -} From 792f94742e997577cf5fea84ba879115bc9c79c2 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Sun, 14 May 2023 22:35:19 +0200 Subject: [PATCH 12/74] MXParser tokenization fails when PI is before first tag (fixes #7) (#12) --- .../plexus/util/xml/pull/MXParser.java | 11 ++--- .../plexus/util/xml/pull/MXParserTest.java | 42 +++++++++++++++++++ 2 files changed, 45 insertions(+), 8 deletions(-) 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 2dfc4c50..ca7c33cc 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 @@ -1822,13 +1822,9 @@ else if ( ch == '\uFFFD' ) { // check if it is 'xml' // deal with XMLDecl - boolean isXMLDecl = parsePI(); + parsePI(); if ( tokenize ) { - if ( isXMLDecl ) - { - return eventType = START_DOCUMENT; - } return eventType = PROCESSING_INSTRUCTION; } } @@ -3111,7 +3107,7 @@ else if ( ch == '\n' ) } } - private boolean parsePI() + private void parsePI() throws XmlPullParserException, IOException { // implements XML 1.0 Section 2.6 Processing Instructions @@ -3213,7 +3209,7 @@ else if ( ch == '<' ) final int off = piTargetStart + 3; final int len = pos - 2 - off; xmlDeclContent = newString( buf, off, len ); - return false; + return; } } } @@ -3291,7 +3287,6 @@ else if ( ch == '\n' ) --pcEnd; } } - return true; } // protected final static char[] VERSION = {'v','e','r','s','i','o','n'}; 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 b5c7b908..51df710b 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 @@ -1622,4 +1622,46 @@ public void testUnicode() throws IOException { fail( "should not raise exception: " + e ); } } + + @Test + public void testProcessingInstructionTokenizeBeforeFirstTag() + throws Exception + { + String input = "nnn"; + + MXParser parser = new MXParser(); + parser.setInput( new StringReader( input ) ); + + assertEquals( XmlPullParser.START_DOCUMENT, parser.getEventType() ); + assertEquals( XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken() ); + assertEquals( "a", parser.getText() ); + assertEquals( XmlPullParser.START_TAG, parser.nextToken() ); + assertEquals( "test", parser.getName() ); + assertEquals( XmlPullParser.TEXT, parser.nextToken() ); + assertEquals( "nnn", parser.getText() ); + assertEquals( XmlPullParser.END_TAG, parser.nextToken() ); + assertEquals( XmlPullParser.END_DOCUMENT, parser.nextToken() ); + } + + @Test + public void testProcessingInstructionTokenizeAfterXMLDeclAndBeforeFirstTag() + throws Exception + { + String input = "nnn"; + + MXParser parser = new MXParser(); + parser.setInput( new StringReader( input ) ); + + assertEquals( XmlPullParser.START_DOCUMENT, parser.getEventType() ); + assertEquals( XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken() ); + assertEquals( "xml version=\"1.0\" encoding=\"UTF-8\"", parser.getText() ); + assertEquals( XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken() ); + assertEquals( "a", parser.getText() ); + assertEquals( XmlPullParser.START_TAG, parser.nextToken() ); + assertEquals( "test", parser.getName() ); + assertEquals( XmlPullParser.TEXT, parser.nextToken() ); + assertEquals( "nnn", parser.getText() ); + assertEquals( XmlPullParser.END_TAG, parser.nextToken() ); + assertEquals( XmlPullParser.END_DOCUMENT, parser.nextToken() ); + } } From 9ba44ebfdb3eba3063385197bf6c032b2b61ccd4 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Mon, 22 May 2023 15:28:23 +0200 Subject: [PATCH 13/74] Fix SCM urls (#13) --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 0579cd01..ac86ec0a 100644 --- a/pom.xml +++ b/pom.xml @@ -32,10 +32,10 @@ limitations under the License. A collection of various utility classes to ease working with XML. - 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 + scm:git:https://github.com/codehaus-plexus/plexus-xml.git + ${project.scm.connection} master + https://github.com/codehaus-plexus/plexus-xml/tree/master/ github From e1f38f157a898aa9284606272b992f5219fd13eb Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Mon, 22 May 2023 15:28:42 +0200 Subject: [PATCH 14/74] Switch build ci workflow to master branch (#14) --- .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 fd924e7d..09feae47 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -22,7 +22,7 @@ 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 deploy: name: Deploy From b1794a39037eb63e0f3ebc8db67f890ce593c1ed Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Mon, 22 May 2023 16:42:59 +0200 Subject: [PATCH 15/74] Fix site generation (#15) --- pom.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pom.xml b/pom.xml index ac86ec0a..1f488407 100644 --- a/pom.xml +++ b/pom.xml @@ -96,11 +96,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 9547a2d9c78c78871ce6d372f5141f1b51cb9669 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Tue, 16 May 2023 18:17:48 +0200 Subject: [PATCH 16/74] Fix Xpp3DomUtils imports --- .../java/org/codehaus/plexus/util/xml/Xpp3DomUtils.java | 6 ++---- 1 file changed, 2 insertions(+), 4 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 6fda3eb4..8195d496 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. * @@ -22,6 +18,8 @@ import org.codehaus.plexus.util.xml.pull.XmlSerializer; +import java.io.IOException; + /** @author Jason van Zyl */ @Deprecated public class Xpp3DomUtils From d58719dc833c66c97d0f2f0d63235931282ffb9c Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Mon, 22 May 2023 15:34:51 +0200 Subject: [PATCH 17/74] Upgrade to plexus 13 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1f488407..65be8e56 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ limitations under the License. org.codehaus.plexus plexus - 10 + 13 plexus-xml From 17787e5ff7dea8acf347fd3f92bd855e110d6dfe Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Mon, 22 May 2023 15:35:24 +0200 Subject: [PATCH 18/74] Reformat using spotless --- pom.xml | 8 +- .../plexus/util/xml/CompactXMLWriter.java | 17 +- .../plexus/util/xml/PrettyPrintXMLWriter.java | 285 +- .../plexus/util/xml/SerializerXMLWriter.java | 95 +- .../codehaus/plexus/util/xml/StringUtils.java | 116 +- .../codehaus/plexus/util/xml/XMLWriter.java | 12 +- .../codehaus/plexus/util/xml/XmlReader.java | 571 ++- .../plexus/util/xml/XmlReaderException.java | 36 +- .../plexus/util/xml/XmlStreamReader.java | 78 +- .../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 | 245 +- .../plexus/util/xml/Xpp3DomBuilder.java | 82 +- .../plexus/util/xml/Xpp3DomUtils.java | 33 +- .../plexus/util/xml/Xpp3DomWriter.java | 48 +- .../util/xml/pull/EntityReplacementMap.java | 358 +- .../plexus/util/xml/pull/MXParser.java | 3356 +++++++---------- .../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 | 209 +- .../plexus/util/xml/XmlStreamReaderTest.java | 182 +- .../plexus/util/xml/XmlStreamWriterTest.java | 109 +- .../codehaus/plexus/util/xml/XmlUtilTest.java | 118 +- .../plexus/util/xml/XmlWriterUtilTest.java | 399 +- .../plexus/util/xml/Xpp3DomBuilderTest.java | 268 +- .../plexus/util/xml/Xpp3DomPerfTest.java | 35 +- .../codehaus/plexus/util/xml/Xpp3DomTest.java | 506 ++- .../plexus/util/xml/Xpp3DomWriterTest.java | 120 +- ...onformanceTestSuite_Production24_Test.java | 397 +- ...ConformanceTestSuite_Production2_Test.java | 643 ++-- ...onformanceTestSuite_Production32_Test.java | 425 +-- ...onformanceTestSuite_Production66_Test.java | 707 ++-- ...onformanceTestSuite_Production80_Test.java | 287 +- .../util/xml/pull/MXParserPerfTest.java | 29 +- .../plexus/util/xml/pull/MXParserTest.java | 1579 ++++---- ..._BjoernHoehrmannviaHST2013_09_18_Test.java | 181 +- 40 files changed, 5616 insertions(+), 7820 deletions(-) diff --git a/pom.xml b/pom.xml index 65be8e56..6e8d2a50 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,4 @@ - - 4.0.0 @@ -143,15 +141,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 c01109c9..e089c5c1 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriter.java +++ b/src/main/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriter.java @@ -20,7 +20,6 @@ import java.io.Writer; import java.util.ArrayDeque; import java.util.Deque; -import java.util.LinkedList; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -29,11 +28,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; @@ -59,34 +56,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)); } /** @@ -95,9 +88,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); } /** @@ -106,9 +98,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); } /** @@ -116,9 +107,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); } /** @@ -126,9 +116,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); } /** @@ -138,42 +127,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; @@ -182,65 +168,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; @@ -248,70 +224,62 @@ 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(); - write( "" ); + write(""); } readyForNewLine = true; @@ -319,25 +287,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; @@ -350,8 +314,7 @@ private void finishTag() * * @return the line indenter */ - protected String getLineIndenter() - { + protected String getLineIndenter() { return lineIndenter; } @@ -360,8 +323,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; } @@ -371,8 +333,7 @@ protected void setLineIndenter( String lineIndenter ) * @return the line separator * @see #LS */ - protected String getLineSeparator() - { + protected String getLineSeparator() { return lineSeparator; } @@ -381,8 +342,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; } @@ -392,36 +352,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(); } @@ -432,11 +387,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; @@ -447,8 +400,7 @@ protected void setWriter( PrintWriter writer ) * * @return the underlying writer */ - protected PrintWriter getWriter() - { + protected PrintWriter getWriter() { return writer; } @@ -457,8 +409,7 @@ protected PrintWriter getWriter() * * @param depth new depth */ - protected void setDepth( int depth ) - { + protected void setDepth(int depth) { this.depth = depth; } @@ -467,8 +418,7 @@ protected void setDepth( int depth ) * * @return the current depth */ - protected int getDepth() - { + protected int getDepth() { return depth; } @@ -477,8 +427,7 @@ protected int getDepth() * * @param encoding new encoding */ - protected void setEncoding( String encoding ) - { + protected void setEncoding(String encoding) { this.encoding = encoding; } @@ -487,8 +436,7 @@ protected void setEncoding( String encoding ) * * @return the current encoding */ - protected String getEncoding() - { + protected String getEncoding() { return encoding; } @@ -497,8 +445,7 @@ protected String getEncoding() * * @param docType new docType */ - protected void setDocType( String docType ) - { + protected void setDocType(String docType) { this.docType = docType; } @@ -507,16 +454,14 @@ protected void setDocType( String docType ) * * @return the current docType */ - protected String getDocType() - { + protected String getDocType() { return docType; } /** * @return the current elementStack; */ - protected Deque getElementStack() - { + protected Deque getElementStack() { return elementStack; } } 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/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 8ac13cab..f2a03161 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/XmlReader.java +++ b/src/main/java/org/codehaus/plexus/util/xml/XmlReader.java @@ -24,29 +24,29 @@ 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.nio.file.Path; +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 @@ -59,9 +59,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"; @@ -87,28 +85,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; } @@ -124,10 +120,8 @@ public static String getDefaultEncoding() * @param path Path to create a Reader from. * @throws IOException thrown if there is a problem reading the file. */ - public XmlReader( Path path ) - throws IOException - { - this( Files.newInputStream( path ) ); + public XmlReader(Path path) throws IOException { + this(Files.newInputStream(path)); } /** @@ -142,10 +136,8 @@ public XmlReader( Path path ) * @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( file.toPath() ); + public XmlReader(File file) throws IOException { + this(file.toPath()); } /** @@ -159,10 +151,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); } /** @@ -189,23 +179,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); } } } @@ -225,10 +207,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()); } /** @@ -246,42 +226,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); } } } @@ -300,10 +264,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); } /** @@ -335,23 +297,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); } } } @@ -384,44 +339,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); } } @@ -431,16 +375,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); } /** @@ -450,180 +391,155 @@ 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 ) - || 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 ); + } else if (bomEnc.equals(UTF_16BE) || bomEnc.equals(UTF_16LE)) { + if (xmlGuessEnc != null && !xmlGuessEnc.equals(bomEnc) + || 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; @@ -631,127 +547,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); } } } @@ -759,33 +645,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 20eb1211..c81c64d3 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/XmlStreamReader.java +++ b/src/main/java/org/codehaus/plexus/util/xml/XmlStreamReader.java @@ -41,15 +41,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 Path. *

@@ -62,10 +60,8 @@ public class XmlStreamReader * @param path Path to create a Reader from. * @throws IOException thrown if there is a problem reading the file. */ - public XmlStreamReader( Path path ) - throws IOException - { - super( path ); + public XmlStreamReader(Path path) throws IOException { + super(path); } /** @@ -76,14 +72,12 @@ public XmlStreamReader( Path path ) *

* 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 - { - this( file.toPath() ); + public XmlStreamReader(File file) throws IOException { + this(file.toPath()); } /** @@ -93,14 +87,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); } /** @@ -121,16 +113,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); } /** @@ -144,14 +134,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); } /** @@ -165,14 +153,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); } /** @@ -184,15 +170,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); } /** @@ -216,7 +200,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. @@ -224,10 +208,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); } /** @@ -251,16 +234,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 213bd0c0..deb41d2e 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 = new XmlStreamReader( f ) ) - { + try (Reader reader = new XmlStreamReader(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>
@@ -94,21 +87,19 @@ public static boolean isXml( File f )
      * @throws IOException if any or invalid xml content
      * @see #prettyFormat(Reader, Writer, int, String)
      */
-    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>
@@ -121,48 +112,41 @@ public static void prettyFormat( Reader reader, Writer writer )
      * @param lineSeparator the wanted line separator
      * @throws IOException if any or invalid 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>
@@ -174,21 +158,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>
@@ -201,37 +183,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 ( InputStream input = is;
-              Writer writer = new OutputStreamWriter( os ) )
-        {
-            final PrettyPrintXMLWriter xmlWriter = new PrettyPrintXMLWriter( writer );
-            xmlWriter.setLineIndenter( StringUtils.repeat( " ", indentSize ) );
-            xmlWriter.setLineSeparator( lineSeparator );
+        try (InputStream input = 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( input, null );
+            parser.setInput(input, null);
 
-            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());
         }
     }
 
@@ -241,82 +216,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 2046da3f..0e8ddfe9 100644
--- a/src/main/java/org/codehaus/plexus/util/xml/Xpp3Dom.java
+++ b/src/main/java/org/codehaus/plexus/util/xml/Xpp3Dom.java
@@ -16,10 +16,6 @@
  * limitations under the License.
  */
 
-import org.apache.maven.api.xml.XmlNode;
-import org.apache.maven.internal.xml.XmlNodeImpl;
-import org.codehaus.plexus.util.xml.pull.XmlSerializer;
-
 import java.io.IOException;
 import java.io.Serializable;
 import java.util.ArrayList;
@@ -27,12 +23,14 @@
 import java.util.List;
 import java.util.Map;
 
+import org.apache.maven.api.xml.XmlNode;
+import org.apache.maven.internal.xml.XmlNodeImpl;
+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 String[] EMPTY_STRING_ARRAY = new String[0];
 
     public static final String CHILDREN_COMBINATION_MODE_ATTRIBUTE = XmlNode.CHILDREN_COMBINATION_MODE_ATTRIBUTE;
@@ -71,9 +69,8 @@ public class Xpp3Dom
     private ChildrenTracking childrenTracking;
     private XmlNode dom;
 
-    public Xpp3Dom( String name )
-    {
-        this.dom = new XmlNodeImpl( name );
+    public Xpp3Dom(String name) {
+        this.dom = new XmlNodeImpl(name);
     }
 
     /**
@@ -81,18 +78,16 @@ public Xpp3Dom( String name )
      * @param inputLocation The input location.
      * @param name The name of the Dom.
      */
-    public Xpp3Dom( String name, Object inputLocation )
-    {
-        this.dom = new XmlNodeImpl( name, null, null, null, inputLocation );
+    public Xpp3Dom(String name, Object inputLocation) {
+        this.dom = new XmlNodeImpl(name, null, null, null, inputLocation);
     }
 
     /**
      * Copy constructor.
      * @param src The source Dom.
      */
-    public Xpp3Dom( Xpp3Dom src )
-    {
-        this( src, src.getName() );
+    public Xpp3Dom(Xpp3Dom src) {
+        this(src, src.getName());
     }
 
     /**
@@ -100,30 +95,25 @@ public Xpp3Dom( Xpp3Dom src )
      * @param src The source Dom.
      * @param name The name of the Dom.
      */
-    public Xpp3Dom( Xpp3Dom src, String name )
-    {
-        this.dom = new XmlNodeImpl( src.dom, name );
+    public Xpp3Dom(Xpp3Dom src, String name) {
+        this.dom = new XmlNodeImpl(src.dom, name);
     }
 
-    public Xpp3Dom( XmlNode dom )
-    {
+    public Xpp3Dom(XmlNode dom) {
         this.dom = dom;
     }
 
-    public Xpp3Dom( XmlNode dom, Xpp3Dom parent )
-    {
+    public Xpp3Dom(XmlNode dom, Xpp3Dom parent) {
         this.dom = dom;
         this.childrenTracking = parent::replace;
     }
 
-    public Xpp3Dom( XmlNode dom, ChildrenTracking childrenTracking )
-    {
+    public Xpp3Dom(XmlNode dom, ChildrenTracking childrenTracking) {
         this.dom = dom;
         this.childrenTracking = childrenTracking;
     }
 
-    public XmlNode getDom()
-    {
+    public XmlNode getDom() {
         return dom;
     }
 
@@ -131,8 +121,7 @@ public XmlNode getDom()
     // Name handling
     // ----------------------------------------------------------------------
 
-    public String getName()
-    {
+    public String getName() {
         return dom.getName();
     }
 
@@ -140,28 +129,24 @@ public String getName()
     // Value handling
     // ----------------------------------------------------------------------
 
-    public String getValue()
-    {
+    public String getValue() {
         return dom.getValue();
     }
 
-    public void setValue( String value )
-    {
-        update( new XmlNodeImpl( dom.getName(), value, dom.getAttributes(), dom.getChildren(), dom.getInputLocation() ) );
+    public void setValue(String value) {
+        update(new XmlNodeImpl(dom.getName(), value, dom.getAttributes(), dom.getChildren(), dom.getInputLocation()));
     }
 
     // ----------------------------------------------------------------------
     // Attribute handling
     // ----------------------------------------------------------------------
 
-    public String[] getAttributeNames()
-    {
-        return dom.getAttributes().keySet().toArray( EMPTY_STRING_ARRAY );
+    public String[] getAttributeNames() {
+        return dom.getAttributes().keySet().toArray(EMPTY_STRING_ARRAY);
     }
 
-    public String getAttribute( String name )
-    {
-        return dom.getAttribute( name );
+    public String getAttribute(String name) {
+        return dom.getAttribute(name);
     }
 
     /**
@@ -170,10 +155,8 @@ public String getAttribute( String name )
      * @return true if the attribute has been removed
      * @since 3.4.0
      */
-    public boolean removeAttribute( String name )
-    {
-        if ( name != null && !name.isEmpty() )
-        {
+    public boolean removeAttribute(String name) {
+        if (name != null && !name.isEmpty()) {
             Map attrs = new HashMap<>(dom.getAttributes());
             boolean ret = attrs.remove(name) != null;
             if (ret) {
@@ -187,18 +170,15 @@ public boolean removeAttribute( String name )
 
     /**
      * 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 )
-        {
+        if (null == name) {
             throw new NullPointerException("Attribute name can not be null");
         }
         Map attrs = new HashMap<>(dom.getAttributes());
@@ -210,69 +190,58 @@ public void setAttribute( String name, String value )
     // Child handling
     // ----------------------------------------------------------------------
 
-    public Xpp3Dom getChild( int i )
-    {
-        return new Xpp3Dom( dom.getChildren().get(i), this );
+    public Xpp3Dom getChild(int i) {
+        return new Xpp3Dom(dom.getChildren().get(i), this);
     }
 
-    public Xpp3Dom getChild( String name )
-    {
-        XmlNode child = dom.getChild( name );
-        return child != null ? new Xpp3Dom( child, this ) : null;
+    public Xpp3Dom getChild(String name) {
+        XmlNode child = dom.getChild(name);
+        return child != null ? new Xpp3Dom(child, this) : null;
     }
 
-    public void addChild( Xpp3Dom xpp3Dom )
-    {
-        List children = new ArrayList<>( dom.getChildren() );
-        children.add( xpp3Dom.dom );
+    public void addChild(Xpp3Dom xpp3Dom) {
+        List children = new ArrayList<>(dom.getChildren());
+        children.add(xpp3Dom.dom);
         xpp3Dom.childrenTracking = this::replace;
-        update( new XmlNodeImpl( dom.getName(), dom.getValue(), dom.getAttributes(), children, dom.getInputLocation() ) );
+        update(new XmlNodeImpl(dom.getName(), dom.getValue(), dom.getAttributes(), children, dom.getInputLocation()));
     }
 
-    public Xpp3Dom[] getChildren()
-    {
+    public Xpp3Dom[] getChildren() {
         return dom.getChildren().stream().map(d -> new Xpp3Dom(d, this)).toArray(Xpp3Dom[]::new);
     }
 
-    public Xpp3Dom[] getChildren( String name )
-    {
+    public Xpp3Dom[] getChildren(String name) {
         return dom.getChildren().stream()
-                .filter( c -> c.getName().equals( name ) )
-                .map( d -> new Xpp3Dom( d, this ) )
-                .toArray( Xpp3Dom[]::new );
+                .filter(c -> c.getName().equals(name))
+                .map(d -> new Xpp3Dom(d, this))
+                .toArray(Xpp3Dom[]::new);
     }
 
-    public int getChildCount()
-    {
+    public int getChildCount() {
         return dom.getChildren().size();
     }
 
-    public void removeChild( int i )
-    {
-        List children = new ArrayList<>( dom.getChildren() );
-        children.remove( i );
-        update( new XmlNodeImpl( dom.getName(), dom.getValue(), dom.getAttributes(), children, dom.getInputLocation() ) );
+    public void removeChild(int i) {
+        List children = new ArrayList<>(dom.getChildren());
+        children.remove(i);
+        update(new XmlNodeImpl(dom.getName(), dom.getValue(), dom.getAttributes(), children, dom.getInputLocation()));
     }
 
-    public void removeChild( Xpp3Dom child )
-    {
-        List children = new ArrayList<>( dom.getChildren() );
-        children.remove( child.dom );
-        update( new XmlNodeImpl( dom.getName(), dom.getValue(), dom.getAttributes(), children, dom.getInputLocation() ) );
+    public void removeChild(Xpp3Dom child) {
+        List children = new ArrayList<>(dom.getChildren());
+        children.remove(child.dom);
+        update(new XmlNodeImpl(dom.getName(), dom.getValue(), dom.getAttributes(), children, dom.getInputLocation()));
     }
 
     // ----------------------------------------------------------------------
     // Parent handling
     // ----------------------------------------------------------------------
 
-    public Xpp3Dom getParent()
-    {
+    public Xpp3Dom getParent() {
         throw new UnsupportedOperationException();
     }
 
-    public void setParent( Xpp3Dom parent )
-    {
-    }
+    public void setParent(Xpp3Dom parent) {}
 
     // ----------------------------------------------------------------------
     // Input location handling
@@ -282,8 +251,7 @@ public void setParent( Xpp3Dom parent )
      * @since 3.2.0
      * @return input location
      */
-    public Object getInputLocation()
-    {
+    public Object getInputLocation() {
         return dom.getInputLocation();
     }
 
@@ -291,24 +259,21 @@ public Object getInputLocation()
      * @since 3.2.0
      * @param inputLocation input location to set
      */
-    public void setInputLocation( Object inputLocation )
-    {
-        update( new XmlNodeImpl( dom.getName(), dom.getValue(), dom.getAttributes(), dom.getChildren(), inputLocation ) );
+    public void setInputLocation(Object inputLocation) {
+        update(new XmlNodeImpl(dom.getName(), dom.getValue(), dom.getAttributes(), dom.getChildren(), 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);
         }
     }
 
@@ -349,14 +314,12 @@ public void writeToSerializer( String namespace, XmlSerializer serializer ) thro
      *   
      * 
      */
-    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;
         }
-        dominant.dom = dominant.dom.merge( recessive.dom, childMergeOverride );
+        dominant.dom = dominant.dom.merge(recessive.dom, childMergeOverride);
     }
 
     /**
@@ -370,11 +333,9 @@ private static void mergeIntoXpp3Dom( Xpp3Dom dominant, Xpp3Dom recessive, Boole
      *            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;
@@ -390,11 +351,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;
@@ -405,73 +364,61 @@ public static Xpp3Dom mergeXpp3Dom( Xpp3Dom dominant, Xpp3Dom recessive )
     // ----------------------------------------------------------------------
 
     @Override
-    public boolean equals( Object obj )
-    {
+    public boolean equals(Object obj) {
         if (obj == this) {
             return true;
         }
 
-        if ( !( obj instanceof Xpp3Dom ) )
-        {
+        if (!(obj instanceof Xpp3Dom)) {
             return false;
         }
 
-        Xpp3Dom dom = ( Xpp3Dom ) obj;
-        return this.dom.equals( dom.dom );
+        Xpp3Dom dom = (Xpp3Dom) obj;
+        return this.dom.equals(dom.dom);
     }
 
     @Override
-    public int hashCode()
-    {
+    public int hashCode() {
         return dom.hashCode();
     }
 
     @Override
-    public String toString()
-    {
+    public String toString() {
         return dom.toString();
     }
 
-    public String toUnescapedString()
-    {
-        return ( ( Xpp3Dom ) dom ).toUnescapedString();
+    public String toUnescapedString() {
+        return ((Xpp3Dom) dom).toUnescapedString();
     }
 
-    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));
     }
 
-    private void update(XmlNode dom)
-    {
-        if ( childrenTracking != null )
-        {
-            childrenTracking.replace( this.dom, dom );
+    private void update(XmlNode dom) {
+        if (childrenTracking != null) {
+            childrenTracking.replace(this.dom, dom);
         }
         this.dom = dom;
     }
 
-    private boolean replace(Object prevChild, Object newChild)
-    {
-        List children = new ArrayList<>( dom.getChildren() );
-        children.replaceAll( d -> d == prevChild ? (XmlNode) newChild : d );
-        update( new XmlNodeImpl( dom.getName(), dom.getValue(), dom.getAttributes(), children, dom.getInputLocation() ) );
+    private boolean replace(Object prevChild, Object newChild) {
+        List children = new ArrayList<>(dom.getChildren());
+        children.replaceAll(d -> d == prevChild ? (XmlNode) newChild : d);
+        update(new XmlNodeImpl(dom.getName(), dom.getValue(), dom.getAttributes(), children, dom.getInputLocation()));
         return true;
     }
 
-    public void setChildrenTracking( ChildrenTracking childrenTracking )
-    {
+    public void setChildrenTracking(ChildrenTracking childrenTracking) {
         this.childrenTracking = childrenTracking;
     }
 
     @FunctionalInterface
-    public interface ChildrenTracking
-    {
-        boolean replace( Object oldDelegate, Object newDelegate );
+    public interface ChildrenTracking {
+        boolean replace(Object oldDelegate, Object newDelegate);
     }
 }
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 cc10df39..b75e681f 100644
--- a/src/main/java/org/codehaus/plexus/util/xml/Xpp3DomBuilder.java
+++ b/src/main/java/org/codehaus/plexus/util/xml/Xpp3DomBuilder.java
@@ -16,90 +16,73 @@
  * limitations under the License.
  */
 
-import org.apache.maven.internal.xml.XmlNodeBuilder;
-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 org.apache.maven.internal.xml.XmlNodeBuilder;
+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);
     }
 
     /**
      * @since 3.2.0
      */
-    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 ( InputStream closeMe = is )
-        {
-            return new Xpp3Dom( XmlNodeBuilder.build( is, encoding, trim ) );
+    public static Xpp3Dom build(InputStream is, String encoding, boolean trim)
+            throws XmlPullParserException, IOException {
+        try (InputStream closeMe = is) {
+            return new Xpp3Dom(XmlNodeBuilder.build(is, encoding, trim));
         }
     }
 
-    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);
     }
 
     /**
      * @since 3.2.0
      */
-    public static Xpp3Dom build( Reader reader, boolean trim, InputLocationBuilder locationBuilder )
-        throws XmlPullParserException, IOException
-    {
-        try ( Reader closeMe = reader )
-        {
-            return new Xpp3Dom( XmlNodeBuilder.build(
-                    reader, trim, locationBuilder != null ? locationBuilder::toInputLocation : null ) );
+    public static Xpp3Dom build(Reader reader, boolean trim, InputLocationBuilder locationBuilder)
+            throws XmlPullParserException, IOException {
+        try (Reader closeMe = reader) {
+            return new Xpp3Dom(XmlNodeBuilder.build(
+                    reader, trim, locationBuilder != null ? locationBuilder::toInputLocation : null));
         }
     }
 
-    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);
     }
 
     /**
      * @since 3.2.0
      */
-    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 {
         return new Xpp3Dom(
-                XmlNodeBuilder.build( parser, trim, locationBuilder != null ? locationBuilder::toInputLocation : null ) );
+                XmlNodeBuilder.build(parser, trim, locationBuilder != null ? locationBuilder::toInputLocation : null));
     }
 
     /**
@@ -107,8 +90,7 @@ public static Xpp3Dom build( XmlPullParser parser, boolean trim, InputLocationBu
      *
      * @since 3.2.0
      */
-    public interface InputLocationBuilder
-    {
-        Object toInputLocation( XmlPullParser parser );
+    public 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 8195d496..b4475f61 100644
--- a/src/main/java/org/codehaus/plexus/util/xml/Xpp3DomUtils.java
+++ b/src/main/java/org/codehaus/plexus/util/xml/Xpp3DomUtils.java
@@ -16,14 +16,13 @@
  * limitations under the License.
  */
 
-import org.codehaus.plexus.util.xml.pull.XmlSerializer;
-
 import java.io.IOException;
 
+import org.codehaus.plexus.util.xml.pull.XmlSerializer;
+
 /** @author Jason van Zyl */
 @Deprecated
-public class Xpp3DomUtils
-{
+public class Xpp3DomUtils {
     /**
      * @deprecated use {@link Xpp3Dom#CHILDREN_COMBINATION_MODE_ATTRIBUTE}
      */
@@ -88,10 +87,8 @@ public class Xpp3DomUtils
      * @deprecated use {@link Xpp3Dom#writeToSerializer(String, XmlSerializer)}
      */
     @Deprecated
-    public void writeToSerializer( String namespace, XmlSerializer serializer, Xpp3Dom dom )
-        throws IOException
-    {
-        dom.writeToSerializer( namespace, serializer );
+    public void writeToSerializer(String namespace, XmlSerializer serializer, Xpp3Dom dom) throws IOException {
+        dom.writeToSerializer(namespace, serializer);
     }
 
     /**
@@ -107,9 +104,8 @@ public void writeToSerializer( String namespace, XmlSerializer serializer, Xpp3D
      * @deprecated use {@link Xpp3Dom#mergeXpp3Dom(Xpp3Dom, Xpp3Dom, Boolean)}
      */
     @Deprecated
-    public static Xpp3Dom mergeXpp3Dom( Xpp3Dom dominant, Xpp3Dom recessive, Boolean childMergeOverride )
-    {
-        return Xpp3Dom.mergeXpp3Dom( dominant, recessive, childMergeOverride );
+    public static Xpp3Dom mergeXpp3Dom(Xpp3Dom dominant, Xpp3Dom recessive, Boolean childMergeOverride) {
+        return Xpp3Dom.mergeXpp3Dom(dominant, recessive, childMergeOverride);
     }
 
     /**
@@ -124,26 +120,23 @@ public static Xpp3Dom mergeXpp3Dom( Xpp3Dom dominant, Xpp3Dom recessive, Boolean
      * @deprecated use {@link Xpp3Dom#mergeXpp3Dom(Xpp3Dom, Xpp3Dom)}
      */
     @Deprecated
-    public static Xpp3Dom mergeXpp3Dom( Xpp3Dom dominant, Xpp3Dom recessive )
-    {
-        return Xpp3Dom.mergeXpp3Dom( dominant, recessive );
+    public static Xpp3Dom mergeXpp3Dom(Xpp3Dom dominant, Xpp3Dom recessive) {
+        return Xpp3Dom.mergeXpp3Dom(dominant, 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 ca7c33cc..9f4396bc 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,13 +18,12 @@
 import org.codehaus.plexus.util.xml.XmlStreamReader;
 import org.codehaus.plexus.util.xml.XmlStreamReaderException;
 
-
-//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
@@ -32,31 +31,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.
@@ -68,19 +62,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;
@@ -129,40 +120,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;
             }
@@ -170,23 +152,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];
@@ -224,44 +203,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;
             }
 
@@ -279,32 +249,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;
             }
@@ -313,26 +277,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;
@@ -354,38 +313,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;
             }
@@ -404,9 +357,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;
 
@@ -458,8 +411,7 @@ private void ensureEntityCapacity()
 
     private String xmlDeclContent;
 
-    private void reset()
-    {
+    private void reset() {
         // System.out.println("reset() called");
         location = null;
         lineNumber = 1;
@@ -504,20 +456,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,
@@ -540,49 +488,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);
         }
     }
 
@@ -590,28 +524,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;
         }
@@ -619,116 +544,81 @@ 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;
     }
 
     @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 = new InputStreamReader( inputStream, inputEncoding );
-            }
-            else
-            {
-                reader = new XmlStreamReader( inputStream, false );
-            }
-        }
-        catch ( UnsupportedEncodingException une )
-        {
-            throw new XmlPullParserException( "could not create reader for encoding " + inputEncoding + " : " + une,
-                                              this, une );
-        }
-        catch ( XmlStreamReaderException e )
-        {
-            if ( "UTF-8".equals( e.getBomEncoding() ) )
-            {
-                throw new XmlPullParserException( "UTF-8 BOM plus xml decl of " + e.getXmlEncoding() + " is incompatible", this, e );
-            }
-            if ( e.getBomEncoding() != null && e.getBomEncoding().startsWith( "UTF-16" ) )
-            {
-                throw new XmlPullParserException( "UTF-16 BOM in a " + e.getXmlEncoding() + " encoded file is incompatible", this, e );
-            }
-            throw new XmlPullParserException( "could not create reader : " + e, this, e );
-        }
-        catch ( IOException e )
-        {
-            throw new XmlPullParserException( "could not create reader : " + e, this, e );
-        }
-        setInput( reader );
+        try {
+            if (inputEncoding != null) {
+                reader = new InputStreamReader(inputStream, inputEncoding);
+            } else {
+                reader = new XmlStreamReader(inputStream, false);
+            }
+        } catch (UnsupportedEncodingException une) {
+            throw new XmlPullParserException(
+                    "could not create reader for encoding " + inputEncoding + " : " + une, this, une);
+        } catch (XmlStreamReaderException e) {
+            if ("UTF-8".equals(e.getBomEncoding())) {
+                throw new XmlPullParserException(
+                        "UTF-8 BOM plus xml decl of " + e.getXmlEncoding() + " is incompatible", this, e);
+            }
+            if (e.getBomEncoding() != null && e.getBomEncoding().startsWith("UTF-16")) {
+                throw new XmlPullParserException(
+                        "UTF-16 BOM in a " + e.getXmlEncoding() + " encoded file is incompatible", this, e);
+            }
+            throw new XmlPullParserException("could not create reader : " + e, this, e);
+        } 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];
                 }
             }
@@ -739,14 +629,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 ]]>???)
@@ -754,121 +643,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;
     }
@@ -877,137 +734,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;
@@ -1021,15 +845,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;
@@ -1052,41 +872,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;
@@ -1096,132 +903,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];
                 }
             }
@@ -1230,37 +1009,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()) + ")");
         }
     }
 
@@ -1270,20 +1050,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;
             }
         }
@@ -1298,9 +1072,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) {
@@ -1321,96 +1093,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();
             }
@@ -1418,18 +1167,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!!!
@@ -1440,67 +1184,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;
                                 }
                             }
@@ -1542,106 +1269,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;
@@ -1659,75 +1356,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;
@@ -1735,66 +1407,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);
                 }
             }
         }
@@ -1803,327 +1459,224 @@ 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
                     parsePI();
-                    if ( tokenize )
-                    {
+                    if (tokenize) {
                         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;
+                        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;
-                            }
-                            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
@@ -2134,36 +1687,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
@@ -2173,9 +1729,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? '/>'
@@ -2189,19 +1743,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;
             }
         }
@@ -2211,12 +1762,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;
 
@@ -2224,79 +1774,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;
 
@@ -2305,22 +1833,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;
                 }
             }
@@ -2329,51 +1851,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);
                     }
                 }
             }
@@ -2384,9 +1896,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]
@@ -2395,144 +1905,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;
@@ -2542,95 +2023,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;
                 }
             }
@@ -2638,29 +2092,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;
         }
@@ -2672,11 +2122,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;
 
@@ -2689,9 +2139,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
 
@@ -2701,125 +2149,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;
@@ -2827,37 +2246,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;
@@ -2875,19 +2288,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;
     }
 
     /**
@@ -2896,24 +2305,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;
     }
 
     /**
@@ -2923,44 +2328,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];
                 }
             }
@@ -2968,120 +2365,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;
                             }
                         }
@@ -3090,33 +2453,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 void parsePI()
-        throws XmlPullParserException, IOException
-    {
+    private void 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;
@@ -3266,24 +2588,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;
             }
         }
@@ -3295,19 +2615,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
@@ -3318,207 +2636,195 @@ 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;
 
@@ -3606,21 +2889,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;
             }
@@ -3629,29 +2906,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
@@ -3661,44 +2932,31 @@ private void parseCDSect( boolean hadCharData )
 
         // ASSUMPTION: seen  posStart )
-                        {
+                        if (posEnd > posStart) {
                             joinPC();
-                        }
-                        else
-                        {
+                        } else {
                             usePC = true;
                             pcStart = pcEnd = 0;
                         }
@@ -3708,99 +2966,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;
             }
         }
@@ -3808,46 +3036,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;
@@ -3855,123 +3073,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);
@@ -3988,53 +3190,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;
@@ -4051,48 +3244,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'
@@ -4116,14 +3301,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');
@@ -4140,9 +3325,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');
     }
 
@@ -4150,52 +3334,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 bb004c73..9e23c420 100644
    --- a/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java
    +++ b/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java
    @@ -16,6 +16,8 @@
      * limitations under the License.
      */
     
    +import javax.swing.text.html.HTML.Tag;
    +
     import java.io.File;
     import java.io.IOException;
     import java.io.StringWriter;
    @@ -24,8 +26,6 @@
     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.jupiter.api.AfterEach;
     import org.junit.jupiter.api.BeforeEach;
    @@ -45,8 +45,7 @@
      * @version $Id: $Id
      * @since 3.4.0
      */
    -public class PrettyPrintXMLWriterTest
    -{
    +public class PrettyPrintXMLWriterTest {
         StringWriter w;
     
         PrettyPrintXMLWriter writer;
    @@ -55,8 +54,7 @@ public class PrettyPrintXMLWriterTest
          * 

    setUp.

    */ @BeforeEach - public void setUp() - { + public void setUp() { initWriter(); } @@ -64,109 +62,102 @@ public void setUp() *

    tearDown.

    */ @AfterEach - 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() - { + public void testendElementAlreadyClosed() { assertThrows(NoSuchElementException.class, () -> { - writer.startElement( Tag.DIV.toString() ); - writer.addAttribute( "class", "someattribute" ); + 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! }); @@ -180,99 +171,93 @@ public void testendElementAlreadyClosed() * * @throws java.io.IOException if an I/O error occurs */ - @Disabled( "This test is only relevant on JDK 1.7, which is not supported anymore" ) + @Disabled("This test is only relevant on JDK 1.7, which is not supported anymore") @Test - public void testIssue51DetectJava7ConcatenationBug() - throws IOException - { - File dir = new File( "target/test-xml" ); - if ( !dir.exists() ) - { - assertTrue( dir.mkdir(), "cannot create directory test-xml" ); + public void testIssue51DetectJava7ConcatenationBug() 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" ); + File xmlFile = new File(dir, "test-issue-51.xml"); int iterations = 20000; - try ( Writer osw = Files.newBufferedWriter( 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" ); + try (Writer osw = Files.newBufferedWriter(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"); } - 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" ); + } catch (NoSuchElementException e) { + fail("Should not throw a NoSuchElementException"); } } - 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 3fe0b515..4ffe7a9c 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/XmlStreamReaderTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/XmlStreamReaderTest.java @@ -22,13 +22,11 @@ import java.io.SequenceInputStream; 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; -import static org.junit.jupiter.api.Assertions.fail; /** *

    XmlStreamReaderTest class.

    @@ -37,8 +35,7 @@ * @version $Id: $Id * @since 3.4.0 */ -public class XmlStreamReaderTest -{ +public class XmlStreamReaderTest { /** french */ private static final String TEXT_LATIN1 = "eacute: \u00E9"; @@ -53,76 +50,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); } /** @@ -131,12 +115,10 @@ private static void checkXmlStreamReader( String text, String encoding, String e * @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", BOM_UTF8 ); + checkXmlContent(xml, "UTF-8"); + checkXmlContent(xml, "UTF-8", BOM_UTF8); } /** @@ -145,11 +127,9 @@ public void testNoXmlHeader() * @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 ); + public void testDefaultEncoding() throws IOException { + checkXmlStreamReader(TEXT_UNICODE, null, "UTF-8"); + checkXmlStreamReader(TEXT_UNICODE, null, "UTF-8", BOM_UTF8); } /** @@ -158,11 +138,9 @@ public void testDefaultEncoding() * @throws java.io.IOException if any. */ @Test - 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); } /** @@ -171,12 +149,10 @@ public void testUTF8Encoding() * @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 ); - 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); } /** @@ -185,10 +161,8 @@ public void testUTF16Encoding() * @throws java.io.IOException if any. */ @Test - public void testUTF16BEEncoding() - throws IOException - { - checkXmlStreamReader( TEXT_UNICODE, "UTF-16BE" ); + public void testUTF16BEEncoding() throws IOException { + checkXmlStreamReader(TEXT_UNICODE, "UTF-16BE"); } /** @@ -197,10 +171,8 @@ public void testUTF16BEEncoding() * @throws java.io.IOException if any. */ @Test - public void testUTF16LEEncoding() - throws IOException - { - checkXmlStreamReader( TEXT_UNICODE, "UTF-16LE" ); + public void testUTF16LEEncoding() throws IOException { + checkXmlStreamReader(TEXT_UNICODE, "UTF-16LE"); } /** @@ -209,10 +181,8 @@ public void testUTF16LEEncoding() * @throws java.io.IOException if any. */ @Test - public void testLatin1Encoding() - throws IOException - { - checkXmlStreamReader( TEXT_LATIN1, "ISO-8859-1" ); + public void testLatin1Encoding() throws IOException { + checkXmlStreamReader(TEXT_LATIN1, "ISO-8859-1"); } /** @@ -221,10 +191,8 @@ public void testLatin1Encoding() * @throws java.io.IOException if any. */ @Test - public void testLatin7Encoding() - throws IOException - { - checkXmlStreamReader( TEXT_LATIN7, "ISO-8859-7" ); + public void testLatin7Encoding() throws IOException { + checkXmlStreamReader(TEXT_LATIN7, "ISO-8859-7"); } /** @@ -233,10 +201,8 @@ public void testLatin7Encoding() * @throws java.io.IOException if any. */ @Test - public void testLatin15Encoding() - throws IOException - { - checkXmlStreamReader( TEXT_LATIN15, "ISO-8859-15" ); + public void testLatin15Encoding() throws IOException { + checkXmlStreamReader(TEXT_LATIN15, "ISO-8859-15"); } /** @@ -245,10 +211,8 @@ public void testLatin15Encoding() * @throws java.io.IOException if any. */ @Test - public void testEUC_JPEncoding() - throws IOException - { - checkXmlStreamReader( TEXT_EUC_JP, "EUC-JP" ); + public void testEUC_JPEncoding() throws IOException { + checkXmlStreamReader(TEXT_EUC_JP, "EUC-JP"); } /** @@ -257,10 +221,8 @@ public void testEUC_JPEncoding() * @throws java.io.IOException if any. */ @Test - public void testEBCDICEncoding() - throws IOException - { - checkXmlStreamReader( "simple text in EBCDIC", "CP1047" ); + public void testEBCDICEncoding() throws IOException { + checkXmlStreamReader("simple text in EBCDIC", "CP1047"); } /** @@ -269,14 +231,12 @@ public void testEBCDICEncoding() * @throws java.io.IOException if any. */ @Test - public void testInappropriateEncoding() - throws IOException - { + public void testInappropriateEncoding() throws IOException { // 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" - ); + assertThrows( + AssertionFailedError.class, + () -> checkXmlStreamReader(TEXT_UNICODE, "ISO-8859-2"), + "Check should have failed, since some characters are not available in the specified encoding"); } /** @@ -285,25 +245,23 @@ public void testInappropriateEncoding() * @throws java.io.IOException if any. */ @Test - 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 b699f732..c2803b59 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/XmlStreamWriterTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/XmlStreamWriterTest.java @@ -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 3b54f16f..eb6db5eb 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java @@ -38,8 +38,7 @@ * @version $Id: $Id * @since 3.4.0 */ -public class XmlUtilTest -{ +public class XmlUtilTest { private String basedir; /** @@ -47,23 +46,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; } @@ -74,19 +68,18 @@ 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() ); - - 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 ); + public void testPrettyFormatInputStreamOutputStream() throws Exception { + File testDocument = new File(getBasedir(), "src/test/resources/testDocument.xhtml"); + assertTrue(testDocument.exists()); + + 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); } } @@ -96,19 +89,17 @@ 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() ); - - try ( Reader reader = new XmlStreamReader( testDocument ); - Writer writer = new XmlStreamWriter( getTestOutputFile( "target/test/prettyFormatTestDocumentWriter.xml" ) ) ) - { - assertNotNull( reader ); - assertNotNull( writer ); - - XmlUtil.prettyFormat( reader, writer ); + public void testPrettyFormatReaderWriter() throws Exception { + File testDocument = new File(getBasedir(), "src/test/resources/testDocument.xhtml"); + assertTrue(testDocument.exists()); + + try (Reader reader = new XmlStreamReader(testDocument); + Writer writer = + new XmlStreamWriter(getTestOutputFile("target/test/prettyFormatTestDocumentWriter.xml"))) { + assertNotNull(reader); + assertNotNull(writer); + + XmlUtil.prettyFormat(reader, writer); } } @@ -118,28 +109,24 @@ 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()); String content; - try ( Reader reader = new XmlStreamReader( testDocument ) ) - { - content = IOUtil.toString( reader ); + try (Reader reader = new XmlStreamReader(testDocument)) { + content = IOUtil.toString(reader); } Writer writer = new StringWriter(); - try ( Reader reader = new XmlStreamReader( testDocument ) ) - { - XmlUtil.prettyFormat( reader, writer ); + try (Reader reader = new XmlStreamReader(testDocument)) { + XmlUtil.prettyFormat(reader, 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)); } /** @@ -148,19 +135,16 @@ 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() ); - - try ( Reader reader = new XmlStreamReader( testDocument ); - Writer writer = new XmlStreamWriter( getTestOutputFile( "target/test/prettyFormatTestXdocWriter.xml" ) ) ) - { - assertNotNull( reader ); - assertNotNull( writer ); - - XmlUtil.prettyFormat( reader, writer ); + public void testPrettyFormatReaderWriter2() throws Exception { + File testDocument = new File(getBasedir(), "src/test/resources/test.xdoc.xhtml"); + assertTrue(testDocument.exists()); + + try (Reader reader = new XmlStreamReader(testDocument); + Writer writer = new XmlStreamWriter(getTestOutputFile("target/test/prettyFormatTestXdocWriter.xml"))) { + assertNotNull(reader); + assertNotNull(writer); + + XmlUtil.prettyFormat(reader, 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 eb8041f7..35ca0a25 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/XmlWriterUtilTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/XmlWriterUtilTest.java @@ -34,8 +34,7 @@ * @version $Id: $Id * @since 3.4.0 */ -public class XmlWriterUtilTest -{ +public class XmlWriterUtilTest { private OutputStream output; private Writer writer; @@ -48,12 +47,10 @@ public class XmlWriterUtilTest * @throws java.lang.Exception if any. */ @BeforeEach - public void setUp() - throws Exception - { + public void setUp() throws Exception { output = new ByteArrayOutputStream(); - writer = new XmlStreamWriter( output ); - xmlWriter = new PrettyPrintXMLWriter( writer ); + writer = new XmlStreamWriter(output); + xmlWriter = new PrettyPrintXMLWriter(writer); } /** @@ -62,9 +59,7 @@ public void setUp() * @throws java.lang.Exception if any. */ @AfterEach - public void tearDown() - throws Exception - { + public void tearDown() throws Exception { xmlWriter = null; writer = null; output = null; @@ -77,12 +72,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); } /** @@ -92,12 +85,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); } /** @@ -107,15 +98,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); } /** @@ -125,13 +114,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); } /** @@ -141,15 +128,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()); } /** @@ -159,19 +145,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); } /** @@ -181,38 +165,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())); } /** @@ -222,33 +208,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()); } /** @@ -258,33 +248,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()); } /** @@ -294,29 +285,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); } /** @@ -326,40 +315,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()); } /** @@ -369,23 +374,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()); } /** @@ -395,23 +404,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()); } /** @@ -421,14 +434,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()); } /** @@ -438,14 +450,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()); } /** @@ -455,18 +466,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 bd696d62..c8db71b5 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomBuilderTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomBuilderTest.java @@ -34,8 +34,7 @@ * @version $Id: $Id * @since 3.4.0 */ -public class Xpp3DomBuilderTest -{ +public class Xpp3DomBuilderTest { private static final String LS = System.lineSeparator(); /** @@ -44,16 +43,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( expectedDom, dom, "check DOMs match" ); + assertEquals(expectedDom, dom, "check DOMs match"); } /** @@ -62,18 +59,16 @@ 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( "element1", dom.getChild( "el1" ).getValue(), "test with trimming on" ); + assertEquals("element1", dom.getChild("el1").getValue(), "test with trimming on"); - dom = Xpp3DomBuilder.build( new StringReader( domString ), false ); + dom = Xpp3DomBuilder.build(new StringReader(domString), false); - assertEquals( " element1\n ", dom.getChild( "el1" ).getValue(), "test with trimming off" ); + assertEquals(" element1\n ", dom.getChild("el1").getValue(), "test with trimming off"); } /** @@ -82,16 +77,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(); @@ -99,63 +92,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( 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" ); + 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"); } /** * 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); } } @@ -166,18 +143,16 @@ 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( "\"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" ); + 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( getExpectedString(), w.toString(), "Compare stringified DOMs" ); + Xpp3DomWriter.write(w, dom); + assertEquals(getExpectedString(), w.toString(), "Compare stringified DOMs"); } /** @@ -187,18 +162,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( "", dom.getChild( "el" ).getAttribute( "att" ), "Check attribute value" ); + assertEquals("", dom.getChild("el").getAttribute("att"), "Check attribute value"); StringWriter w = new StringWriter(); - Xpp3DomWriter.write( w, dom ); + Xpp3DomWriter.write(w, dom); String newString = w.toString(); - assertEquals( newString, s, "Compare stringified DOMs" ); + assertEquals(newString, s, "Compare stringified DOMs"); } /** @@ -208,70 +181,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( 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( expectedElt.getInputLocation(), elt.getInputLocation(), elt.getName() + " input location" ); - - if ( "el2".equals( elt.getName() ) ) - { - Xpp3Dom el3 = elt.getChild( 0 ); - Xpp3Dom expectedEl3 = expectedElt.getChild( 0 ); - assertEquals( expectedEl3.getInputLocation(), el3.getInputLocation(), el3.getName() + " input location" ); + 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(expectedElt.getInputLocation(), elt.getInputLocation(), elt.getName() + " input location"); + + if ("el2".equals(elt.getName())) { + Xpp3Dom el3 = elt.getChild(0); + Xpp3Dom expectedEl3 = expectedElt.getChild(0); + assertEquals(expectedEl3.getInputLocation(), el3.getInputLocation(), el3.getName() + " input location"); } } } - 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(); } @@ -280,54 +244,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 469bb3f8..dccdde34 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomTest.java @@ -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 testShouldNotMergeValuesAtTopLevelByDefault() - { + public void testShouldNotMergeValuesAtTopLevelByDefault() { // 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(), t1.getValue() ); - assertEquals( "t1top", result.getInputLocation() ); + assertEquals(result.getValue(), t1.getValue()); + assertEquals("t1top", result.getInputLocation()); } /** *

    testShouldMergeValuesAtTopLevel.

    */ @Test - public void testShouldNotMergeValues() - { + public void testShouldNotMergeValues() { // 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 ); - assertNull( result.getValue(), t1.getValue() ); + assertEquals(3, result.getAttributeNames().length); + assertNull(result.getValue(), t1.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( "" ) ) ); + assertEquals(dom, dom); + assertFalse(dom.equals(null)); + assertFalse(dom.equals(new Xpp3Dom(""))); } /** @@ -241,21 +227,19 @@ 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 dom = Xpp3DomBuilder.build(new StringReader(testDom)); Map attributes = new HashMap<>(); - attributes.put( "nullValue", null ); - attributes.put( null, "nullKey" ); + attributes.put("nullValue", null); + attributes.put(null, "nullKey"); List childList = new ArrayList<>(); - childList.add( null ); - Xpp3Dom dom2 = new Xpp3Dom( new XmlNodeImpl( dom.getName(), null, attributes, childList, null ) ); + childList.add(null); + Xpp3Dom dom2 = new Xpp3Dom(new XmlNodeImpl(dom.getName(), null, attributes, childList, null)); - assertNotEquals( dom, dom2 ); - assertNotEquals( dom2, dom ); + assertNotEquals(dom, dom2); + assertNotEquals(dom2, dom); } /** @@ -265,25 +249,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()); } /** @@ -294,30 +276,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()); } /** @@ -326,21 +307,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()); } /** @@ -349,21 +328,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")); } /** @@ -373,13 +350,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()); } /** @@ -388,18 +363,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()); } /** @@ -408,18 +381,16 @@ 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()); } /** @@ -428,38 +399,46 @@ public void testShouldRemoveDoNotRemoveTagWhenSwappedInputDOMs() * @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 Xpp3DomTest.FixedInputLocationBuilder( "left" ) ); - Xpp3Dom rightDom = Xpp3DomBuilder.build( new StringReader( rhs ), new Xpp3DomTest.FixedInputLocationBuilder( "right" ) ); - - Xpp3Dom mergeResult = Xpp3Dom.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 Xpp3DomTest.FixedInputLocationBuilder("left")); + Xpp3Dom rightDom = + Xpp3DomBuilder.build(new StringReader(rhs), new Xpp3DomTest.FixedInputLocationBuilder("right")); + + Xpp3Dom mergeResult = Xpp3Dom.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()); } /** @@ -468,38 +447,46 @@ 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 Xpp3DomTest.FixedInputLocationBuilder( "left" ) ); - Xpp3Dom rightDom = Xpp3DomBuilder.build( new StringReader( rhs ), new Xpp3DomTest.FixedInputLocationBuilder( "right" ) ); - - Xpp3Dom mergeResult = Xpp3Dom.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 Xpp3DomTest.FixedInputLocationBuilder("left")); + Xpp3Dom rightDom = + Xpp3DomBuilder.build(new StringReader(rhs), new Xpp3DomTest.FixedInputLocationBuilder("right")); + + Xpp3Dom mergeResult = Xpp3Dom.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 @@ -508,39 +495,38 @@ public void testPreserveDominantBlankValue() throws XmlPullParserException, IOEx String rhs = "recessive"; - Xpp3Dom leftDom = Xpp3DomBuilder.build( new StringReader( lhs ), new Xpp3DomTest.FixedInputLocationBuilder( "left" ) ); - Xpp3Dom rightDom = Xpp3DomBuilder.build( new StringReader( rhs ), new Xpp3DomTest.FixedInputLocationBuilder( "right" ) ); + Xpp3Dom leftDom = + Xpp3DomBuilder.build(new StringReader(lhs), new Xpp3DomTest.FixedInputLocationBuilder("left")); + Xpp3Dom rightDom = + Xpp3DomBuilder.build(new StringReader(rhs), new Xpp3DomTest.FixedInputLocationBuilder("right")); - Xpp3Dom mergeResult = Xpp3Dom.mergeXpp3Dom( leftDom, rightDom, true ); - assertEquals( " ", mergeResult.getValue() ); + Xpp3Dom mergeResult = Xpp3Dom.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 Xpp3DomTest.FixedInputLocationBuilder( "left" ) ); - Xpp3Dom rightDom = Xpp3DomBuilder.build( new StringReader( rhs ), new Xpp3DomTest.FixedInputLocationBuilder( "right" ) ); + Xpp3Dom leftDom = + Xpp3DomBuilder.build(new StringReader(lhs), new Xpp3DomTest.FixedInputLocationBuilder("left")); + Xpp3Dom rightDom = + Xpp3DomBuilder.build(new StringReader(rhs), new Xpp3DomTest.FixedInputLocationBuilder("right")); - Xpp3Dom mergeResult = Xpp3Dom.mergeXpp3Dom( leftDom, rightDom, true ); - assertEquals( "", mergeResult.getValue() ); + Xpp3Dom mergeResult = Xpp3Dom.mergeXpp3Dom(leftDom, rightDom, true); + assertEquals("", mergeResult.getValue()); } - 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 8076b37f..7f7f3219 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomWriterTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomWriterTest.java @@ -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( createExpectedXML( true ), writer.toString(), "Check if output matches" ); + assertEquals(createExpectedXML(true), writer.toString(), "Check if output matches"); } /** *

    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( createExpectedXML( false ), writer.toString(), "Check if output matches" ); + assertEquals(createExpectedXML(false), writer.toString(), "Check if output matches"); } - 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( "&"'<>" ); + 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("&\"\'<>"); } - 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 0d183346..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 @@ -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.

    */ @BeforeEach - 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-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 9a877456..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 @@ -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.

    */ @BeforeEach - 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 setUp.

    */ @BeforeEach - 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 7d7fc20a..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 @@ -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.

    */ @BeforeEach - 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 51df710b..8c3fd284 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 @@ -40,32 +40,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()); } /** @@ -74,24 +71,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()); } /** @@ -100,24 +95,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()); } /** @@ -127,19 +120,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()); } /** @@ -148,28 +139,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()); } /** @@ -178,26 +167,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()); } /** @@ -206,22 +193,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")); } } @@ -231,45 +213,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"); } } @@ -279,22 +257,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")); } } @@ -304,46 +277,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"); } } @@ -353,47 +321,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()); } /** @@ -402,28 +367,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()); } /** @@ -432,56 +395,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()); } /** @@ -490,46 +447,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()); } /** @@ -538,25 +491,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()); } /** @@ -565,28 +516,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")); } } @@ -596,28 +542,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")); } } @@ -627,30 +568,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")); } } @@ -693,30 +627,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")); } } @@ -726,75 +656,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(input, null); + 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); } } @@ -1421,10 +1252,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"); } /** @@ -1437,63 +1266,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); } } @@ -1510,35 +1334,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); } } @@ -1553,47 +1374,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); } } @@ -1604,64 +1420,57 @@ 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); } } @Test - public void testProcessingInstructionTokenizeBeforeFirstTag() - throws Exception - { + public void testProcessingInstructionTokenizeBeforeFirstTag() throws Exception { String input = "nnn"; MXParser parser = new MXParser(); - parser.setInput( new StringReader( input ) ); - - assertEquals( XmlPullParser.START_DOCUMENT, parser.getEventType() ); - assertEquals( XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken() ); - assertEquals( "a", parser.getText() ); - assertEquals( XmlPullParser.START_TAG, parser.nextToken() ); - assertEquals( "test", parser.getName() ); - assertEquals( XmlPullParser.TEXT, parser.nextToken() ); - assertEquals( "nnn", parser.getText() ); - assertEquals( XmlPullParser.END_TAG, parser.nextToken() ); - assertEquals( XmlPullParser.END_DOCUMENT, parser.nextToken() ); + parser.setInput(new StringReader(input)); + + assertEquals(XmlPullParser.START_DOCUMENT, parser.getEventType()); + assertEquals(XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken()); + assertEquals("a", parser.getText()); + assertEquals(XmlPullParser.START_TAG, parser.nextToken()); + assertEquals("test", parser.getName()); + assertEquals(XmlPullParser.TEXT, parser.nextToken()); + assertEquals("nnn", parser.getText()); + assertEquals(XmlPullParser.END_TAG, parser.nextToken()); + assertEquals(XmlPullParser.END_DOCUMENT, parser.nextToken()); } @Test - public void testProcessingInstructionTokenizeAfterXMLDeclAndBeforeFirstTag() - throws Exception - { + public void testProcessingInstructionTokenizeAfterXMLDeclAndBeforeFirstTag() throws Exception { String input = "nnn"; MXParser parser = new MXParser(); - parser.setInput( new StringReader( input ) ); - - assertEquals( XmlPullParser.START_DOCUMENT, parser.getEventType() ); - assertEquals( XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken() ); - assertEquals( "xml version=\"1.0\" encoding=\"UTF-8\"", parser.getText() ); - assertEquals( XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken() ); - assertEquals( "a", parser.getText() ); - assertEquals( XmlPullParser.START_TAG, parser.nextToken() ); - assertEquals( "test", parser.getName() ); - assertEquals( XmlPullParser.TEXT, parser.nextToken() ); - assertEquals( "nnn", parser.getText() ); - assertEquals( XmlPullParser.END_TAG, parser.nextToken() ); - assertEquals( XmlPullParser.END_DOCUMENT, parser.nextToken() ); + parser.setInput(new StringReader(input)); + + assertEquals(XmlPullParser.START_DOCUMENT, parser.getEventType()); + assertEquals(XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken()); + assertEquals("xml version=\"1.0\" encoding=\"UTF-8\"", parser.getText()); + assertEquals(XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken()); + assertEquals("a", parser.getText()); + assertEquals(XmlPullParser.START_TAG, parser.nextToken()); + assertEquals("test", parser.getName()); + assertEquals(XmlPullParser.TEXT, parser.nextToken()); + assertEquals("nnn", parser.getText()); + assertEquals(XmlPullParser.END_TAG, parser.nextToken()); + assertEquals(XmlPullParser.END_DOCUMENT, parser.nextToken()); } } 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 8c174f54..642e729f 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 @@ -22,10 +22,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; @@ -33,8 +32,7 @@ public class eduni_misc_Test_BjoernHoehrmannviaHST2013_09_18_Test *

    setUp.

    */ @BeforeEach - public void setUp() - { + public void setUp() { parser = new MXParser(); } @@ -48,19 +46,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")); } } @@ -74,19 +67,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")); } } @@ -100,19 +88,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")); } } @@ -126,19 +109,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")); } } @@ -154,19 +133,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); } } @@ -182,19 +156,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); } } @@ -208,19 +177,14 @@ 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 ( InputStream is = new FileInputStream( new File( testResourcesDir, "007.xml" ) ) ) - { - parser.setInput( is, null ); - while ( parser.nextToken() != XmlPullParser.END_DOCUMENT ) + public void testhst_lhs_007() throws IOException { + try (InputStream is = new FileInputStream(new File(testResourcesDir, "007.xml"))) { + parser.setInput(is, null); + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) ; - 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")); } } @@ -234,19 +198,14 @@ 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 ( InputStream is = new FileInputStream( new File( testResourcesDir, "008.xml" ) ) ) - { - parser.setInput( is, null ); - while ( parser.nextToken() != XmlPullParser.END_DOCUMENT ) + public void testhst_lhs_008() throws IOException { + try (InputStream is = new FileInputStream(new File(testResourcesDir, "008.xml"))) { + parser.setInput(is, null); + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) ; - 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 in a UTF-8 encoded file 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 in a UTF-8 encoded file is incompatible")); } } @@ -260,20 +219,14 @@ 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 ( InputStream is = new FileInputStream( new File( testResourcesDir, "009.xml" ) ) ) - { - parser.setInput( is, null ); - while ( parser.nextToken() != XmlPullParser.END_DOCUMENT ) + public void testhst_lhs_009() throws IOException { + try (InputStream is = new FileInputStream(new File(testResourcesDir, "009.xml"))) { + parser.setInput(is, null); + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) ; - 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" ), e.getMessage() ); + 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"), e.getMessage()); } } - } From cac55e8c167b168c6c36dd4a057dedfadec03c0e Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Mon, 22 May 2023 17:08:27 +0200 Subject: [PATCH 19/74] [maven-release-plugin] prepare release plexus-xml-4.0.0 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 6e8d2a50..cfc72fd8 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ limitations under the License. plexus-xml - 4.0.0-SNAPSHOT + 4.0.0 Plexus XML Utilities A collection of various utility classes to ease working with XML. @@ -32,7 +32,7 @@ limitations under the License. scm:git:https://github.com/codehaus-plexus/plexus-xml.git ${project.scm.connection} - master + plexus-xml-4.0.0 https://github.com/codehaus-plexus/plexus-xml/tree/master/ @@ -47,7 +47,7 @@ limitations under the License. - 2023-03-02T01:23:19Z + 2023-05-22T15:08:22Z From 62f50bc46c7b51d51a25541dfe0a502063dc1fc3 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Mon, 22 May 2023 17:08:30 +0200 Subject: [PATCH 20/74] [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 cfc72fd8..ae0821f7 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ limitations under the License. plexus-xml - 4.0.0 + 4.0.1-SNAPSHOT Plexus XML Utilities A collection of various utility classes to ease working with XML. @@ -32,7 +32,7 @@ limitations under the License. scm:git:https://github.com/codehaus-plexus/plexus-xml.git ${project.scm.connection} - plexus-xml-4.0.0 + master https://github.com/codehaus-plexus/plexus-xml/tree/master/ @@ -47,7 +47,7 @@ limitations under the License. - 2023-05-22T15:08:22Z + 2023-05-22T15:08:30Z From 27d6127d3196d09263d8fe0f445b9d83f6ccfb75 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 21/74] pom.mxl and site.xml cleanup --- pom.xml | 85 +++-------------------------------------------- src/site/site.xml | 5 +++ 2 files changed, 9 insertions(+), 81 deletions(-) diff --git a/pom.xml b/pom.xml index ae0821f7..e99c9a98 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. + https://codehaus-plexus.github.io/plexus-xml/ scm:git:https://github.com/codehaus-plexus/plexus-xml.git ${project.scm.connection} master - https://github.com/codehaus-plexus/plexus-xml/tree/master/ + 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 @@ -48,6 +49,7 @@ limitations under the License. 2023-05-22T15:08:30Z + 8 @@ -79,64 +81,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 @@ -175,33 +127,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 d227a49f0f9b552a61b2aaac3bbe2c722ce06fea Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Fri, 23 Jun 2023 21:50:05 +0200 Subject: [PATCH 22/74] Fix detection of invalid spaces in prolog (#20) --- pom.xml | 6 +++++ .../plexus/util/xml/pull/MXParser.java | 6 +++-- .../plexus/util/xml/pull/MXParserTest.java | 22 +++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index e99c9a98..76e4a4fe 100644 --- a/pom.xml +++ b/pom.xml @@ -76,6 +76,12 @@ limitations under the License. 5.9.2 test + + org.hamcrest + hamcrest + 2.2 + test + 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 9f4396bc..63fffedd 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 @@ -2528,9 +2528,11 @@ private void parsePI() throws XmlPullParserException, IOException { 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) { // 2) { // nnn"; + + MXParser parser = new MXParser(); + parser.setInput(new StringReader(ws + xml)); + assertThat( + assertThrows(XmlPullParserException.class, parser::next).getMessage(), + containsString("XMLDecl is only allowed as first characters in input")); + + parser.setInput(new StringReader(ws + xml)); + assertEquals(XmlPullParser.IGNORABLE_WHITESPACE, parser.nextToken()); + assertThat( + assertThrows(XmlPullParserException.class, parser::nextToken).getMessage(), + containsString("processing instruction can not have PITarget with reserved xml name")); + } } From bcb6981e2a9c635d024e0422de2a997a00ffdd8e Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Fri, 23 Jun 2023 21:56:23 +0200 Subject: [PATCH 23/74] [maven-release-plugin] prepare release plexus-xml-4.0.1 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 76e4a4fe..607c9142 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ limitations under the License. plexus-xml - 4.0.1-SNAPSHOT + 4.0.1 Plexus XML Utilities A collection of various utility classes to ease working with XML. @@ -33,7 +33,7 @@ limitations under the License. scm:git:https://github.com/codehaus-plexus/plexus-xml.git ${project.scm.connection} - master + plexus-xml-4.0.1 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-06-23T19:56:18Z 8 From 25a00cd9d04ff3ab7acdcebdefdbb19ec5c4560d Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Fri, 23 Jun 2023 21:56:25 +0200 Subject: [PATCH 24/74] [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 607c9142..ba7eed7c 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ limitations under the License. plexus-xml - 4.0.1 + 4.0.2-SNAPSHOT Plexus XML Utilities A collection of various utility classes to ease working with XML. @@ -33,7 +33,7 @@ limitations under the License. scm:git:https://github.com/codehaus-plexus/plexus-xml.git ${project.scm.connection} - plexus-xml-4.0.1 + master https://github.com/codehaus-plexus/plexus-xml/tree/${project.scm.tag}/ @@ -48,7 +48,7 @@ limitations under the License. - 2023-06-23T19:56:18Z + 2023-06-23T19:56:25Z 8 From a83cefa086c9a5bb8b6674a409016f378b19891e Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Fri, 30 Jun 2023 23:57:00 +0200 Subject: [PATCH 25/74] Cleanup after parent pom upgrade --- pom.xml | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/pom.xml b/pom.xml index ba7eed7c..8d97cb40 100644 --- a/pom.xml +++ b/pom.xml @@ -49,7 +49,6 @@ limitations under the License. 2023-06-23T19:56:25Z - 8 @@ -73,7 +72,6 @@ limitations under the License. org.junit.jupiter junit-jupiter - 5.9.2 test @@ -85,15 +83,6 @@ limitations under the License. - - - - org.apache.maven.plugins - maven-surefire-plugin - 3.0.0 - - - org.apache.maven.plugins @@ -119,16 +108,6 @@ limitations under the License. true - - - JAVA_HOME - ${JAVA_HOME} - - - M2_HOME - ${M2_HOME} - - From c3d99b433a272d8eb1cc7c799410799e8c16ace3 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Mon, 3 Jul 2023 10:34:18 +0200 Subject: [PATCH 26/74] Upgrade to 4.0.0-alpha-7 and exclude dependency to sisu (fixes #17) (#23) --- pom.xml | 14 +++++++++++++- .../org/codehaus/plexus/util/xml/Xpp3DomUtils.java | 4 ++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 8d97cb40..14236bb7 100644 --- a/pom.xml +++ b/pom.xml @@ -55,7 +55,13 @@ limitations under the License. org.apache.maven maven-xml-impl - 4.0.0-alpha-5 + 4.0.0-alpha-7 + + + org.eclipse.sisu + org.eclipse.sisu.plexus + + org.openjdk.jmh @@ -80,6 +86,12 @@ limitations under the License. 2.2 test + + org.codehaus.plexus + plexus-utils + 4.0.0 + test + 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 b4475f61..d8a47e53 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/Xpp3DomUtils.java +++ b/src/main/java/org/codehaus/plexus/util/xml/Xpp3DomUtils.java @@ -125,7 +125,7 @@ public static Xpp3Dom mergeXpp3Dom(Xpp3Dom dominant, Xpp3Dom recessive) { } /** - * @deprecated Use {@link org.codehaus.plexus.util.StringUtils#isNotEmpty(String)} instead + * @deprecated Use org.codehaus.plexus.util.StringUtils#isNotEmpty(String) instead */ @Deprecated public static boolean isNotEmpty(String str) { @@ -133,7 +133,7 @@ public static boolean isNotEmpty(String str) { } /** - * @deprecated Use {@link org.codehaus.plexus.util.StringUtils#isEmpty(String)} instead + * @deprecated Use org.codehaus.plexus.util.StringUtils#isEmpty(String) instead */ @Deprecated public static boolean isEmpty(String str) { From 944197c74386b199857a003160d840fb5593ac29 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Tue, 4 Jul 2023 10:14:18 +0200 Subject: [PATCH 27/74] [maven-release-plugin] prepare release plexus-xml-4.0.2 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 14236bb7..35d72bce 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ limitations under the License. plexus-xml - 4.0.2-SNAPSHOT + 4.0.2 Plexus XML Utilities A collection of various utility classes to ease working with XML. @@ -33,7 +33,7 @@ limitations under the License. scm:git:https://github.com/codehaus-plexus/plexus-xml.git ${project.scm.connection} - master + plexus-xml-4.0.2 https://github.com/codehaus-plexus/plexus-xml/tree/${project.scm.tag}/ @@ -48,7 +48,7 @@ limitations under the License. - 2023-06-23T19:56:25Z + 2023-07-04T08:14:13Z From 72c06a0a2d0793a79b1ea6b68eb453cc1ee9c867 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Tue, 4 Jul 2023 10:14:21 +0200 Subject: [PATCH 28/74] [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 35d72bce..32cff2ab 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ limitations under the License. plexus-xml - 4.0.2 + 4.0.3-SNAPSHOT Plexus XML Utilities A collection of various utility classes to ease working with XML. @@ -33,7 +33,7 @@ limitations under the License. scm:git:https://github.com/codehaus-plexus/plexus-xml.git ${project.scm.connection} - plexus-xml-4.0.2 + master https://github.com/codehaus-plexus/plexus-xml/tree/${project.scm.tag}/ @@ -48,7 +48,7 @@ limitations under the License. - 2023-07-04T08:14:13Z + 2023-07-04T08:14:21Z From bcf34dcd790955f6381efe442f2d24dbe2b8170e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Sat, 9 Sep 2023 14:46:23 +0200 Subject: [PATCH 29/74] describe plexus-xml update to maven-xml-impl --- README.md | 4 +++- src/site/markdown/index.md | 8 ++++++++ src/site/site.xml | 3 +++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 src/site/markdown/index.md diff --git a/README.md b/README.md index 379ac1e9..89bb19de 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,9 @@ 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`](https://github.com/codehaus-plexus/plexus-utils/) 4. +This library consists of XML classes (`org.codehaus.plexus.util.xml` and `org.codehaus.plexus.util.xml.pull`) that: +1. have been extracted from [`plexus-utils`](https://github.com/codehaus-plexus/plexus-utils/) 4, +2. then updated to use [`maven-xml-api`](https://github.com/apache/maven/tree/maven-4.0.0-alpha-7/api/maven-api-xml)/[`maven-xml-impl`](https://github.com/apache/maven/tree/maven-4.0.0-alpha-7/maven-xml-impl) For publishing [the site](https://codehaus-plexus.github.io/plexus-xml/) do the following: diff --git a/src/site/markdown/index.md b/src/site/markdown/index.md new file mode 100644 index 00000000..823a3b2e --- /dev/null +++ b/src/site/markdown/index.md @@ -0,0 +1,8 @@ +## Plexus XML Utilities + +A collection of various utility classes to ease working with XML. + +This library consists of XML classes (`org.codehaus.plexus.util.xml` and `org.codehaus.plexus.util.xml.pull`): +1. that have been extracted from [`plexus-utils`](../plexus-utils/) 4, +2. then updated to use [`maven-xml-api`](https://maven.apache.org/ref/4.0.0-alpha-7/api/maven-api-xml/)/[`maven-xml-impl`](https://maven.apache.org/ref/4.0.0-alpha-7/maven-xml-impl/index.html) + diff --git a/src/site/site.xml b/src/site/site.xml index 3cb8f1a8..43170c22 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -4,6 +4,9 @@ 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 07f63919296984b2c5f5d30a433411c0715b2e9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Mon, 11 Sep 2023 22:42:12 +0200 Subject: [PATCH 30/74] explain 3 vs 4 --- README.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 89bb19de..73f800cc 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,18 @@ 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) [![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 `org.codehaus.plexus.util.xml.pull`) that: -1. have been extracted from [`plexus-utils`](https://github.com/codehaus-plexus/plexus-utils/) 4, -2. then updated to use [`maven-xml-api`](https://github.com/apache/maven/tree/maven-4.0.0-alpha-7/api/maven-api-xml)/[`maven-xml-impl`](https://github.com/apache/maven/tree/maven-4.0.0-alpha-7/maven-xml-impl) + +1. have been extracted from [`plexus-utils`](https://github.com/codehaus-plexus/plexus-utils/) 4:\ + this step is released as `plexus-xml` 3, maintained in [3.x branch](tree/3.x)\ + [![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), + +2. then updated to use [`maven-xml-api`](https://github.com/apache/maven/tree/maven-4.0.0-alpha-7/api/maven-api-xml)/[`maven-xml-impl`](https://github.com/apache/maven/tree/maven-4.0.0-alpha-7/maven-xml-impl):\ + this is the `master` branch from which `plexus-xml` 4 is released\ + [![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) For publishing [the site](https://codehaus-plexus.github.io/plexus-xml/) do the following: From 7bfeb09596b87f4a28add4699bbd663fe6dcbd6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Tue, 12 Sep 2023 08:08:47 +0200 Subject: [PATCH 31/74] clarify "Maven 4-specific" --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 73f800cc..ce4cf7ab 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ This library consists of XML classes (`org.codehaus.plexus.util.xml` and `org.co this step is released as `plexus-xml` 3, maintained in [3.x branch](tree/3.x)\ [![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), -2. then updated to use [`maven-xml-api`](https://github.com/apache/maven/tree/maven-4.0.0-alpha-7/api/maven-api-xml)/[`maven-xml-impl`](https://github.com/apache/maven/tree/maven-4.0.0-alpha-7/maven-xml-impl):\ +2. then updated to use Maven 4-specific [`maven-xml-api`](https://github.com/apache/maven/tree/maven-4.0.0-alpha-7/api/maven-api-xml)/[`maven-xml-impl`](https://github.com/apache/maven/tree/maven-4.0.0-alpha-7/maven-xml-impl):\ this is the `master` branch from which `plexus-xml` 4 is released\ [![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) From aa82ed33a2e8c178fcd2a2106f57023d6947d84e Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Wed, 13 Dec 2023 06:57:39 +0100 Subject: [PATCH 32/74] Update dependencies (#26) * Update dependencies Changes: * parent POM to 16 * remove sole use of hamcrest * jmh update * nullcheck --- pom.xml | 14 ++++---------- .../plexus/util/xml/pull/MXParserTest.java | 16 ++++++++-------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/pom.xml b/pom.xml index 32cff2ab..f554aebb 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ limitations under the License. org.codehaus.plexus plexus - 13 + 16 plexus-xml @@ -55,7 +55,7 @@ limitations under the License. org.apache.maven maven-xml-impl - 4.0.0-alpha-7 + 4.0.0-alpha-8 org.eclipse.sisu @@ -66,13 +66,13 @@ limitations under the License. org.openjdk.jmh jmh-core - 1.36 + 1.37 test org.openjdk.jmh jmh-generator-annprocess - 1.36 + 1.37 test @@ -80,12 +80,6 @@ limitations under the License. junit-jupiter test - - org.hamcrest - hamcrest - 2.2 - test - org.codehaus.plexus plexus-utils 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 f7c9d68c..0359b8c7 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 @@ -33,8 +33,6 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; import static org.junit.jupiter.api.Assertions.*; /** @@ -1485,14 +1483,16 @@ void testBlankAtBeginning(String ws) throws XmlPullParserException, IOException MXParser parser = new MXParser(); parser.setInput(new StringReader(ws + xml)); - assertThat( - assertThrows(XmlPullParserException.class, parser::next).getMessage(), - containsString("XMLDecl is only allowed as first characters in input")); + + String message; + message = assertThrows(XmlPullParserException.class, parser::next).getMessage(); + assertNotNull(message); + assertTrue(message.contains("XMLDecl is only allowed as first characters in input"), message); parser.setInput(new StringReader(ws + xml)); assertEquals(XmlPullParser.IGNORABLE_WHITESPACE, parser.nextToken()); - assertThat( - assertThrows(XmlPullParserException.class, parser::nextToken).getMessage(), - containsString("processing instruction can not have PITarget with reserved xml name")); + message = assertThrows(XmlPullParserException.class, parser::nextToken).getMessage(); + assertNotNull(message); + assertTrue(message.contains("processing instruction can not have PITarget with reserved xml name"), message); } } From e6a6427dd4c1e0b40832ea027f5c102cd739ef85 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Wed, 13 Dec 2023 20:59:12 +0100 Subject: [PATCH 33/74] Upgrade to Maven 4.0.0-alpha-9 (#27) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f554aebb..489292bc 100644 --- a/pom.xml +++ b/pom.xml @@ -55,7 +55,7 @@ limitations under the License. org.apache.maven maven-xml-impl - 4.0.0-alpha-8 + 4.0.0-alpha-9 org.eclipse.sisu From 784ff955e0944bea8b3a15254ad7ce06ae72dc20 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Wed, 13 Dec 2023 21:00:16 +0100 Subject: [PATCH 34/74] [maven-release-plugin] prepare release plexus-xml-4.0.3 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 489292bc..f8a0bf3a 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ limitations under the License. plexus-xml - 4.0.3-SNAPSHOT + 4.0.3 Plexus XML Utilities A collection of various utility classes to ease working with XML. @@ -33,7 +33,7 @@ limitations under the License. scm:git:https://github.com/codehaus-plexus/plexus-xml.git ${project.scm.connection} - master + plexus-xml-4.0.3 https://github.com/codehaus-plexus/plexus-xml/tree/${project.scm.tag}/ @@ -48,7 +48,7 @@ limitations under the License. - 2023-07-04T08:14:21Z + 2023-12-13T20:00:11Z From 0407d057cc482589f6e4047c60baa738a4276ffd Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Wed, 13 Dec 2023 21:00:19 +0100 Subject: [PATCH 35/74] [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 f8a0bf3a..d8c91aef 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ limitations under the License. plexus-xml - 4.0.3 + 4.0.4-SNAPSHOT Plexus XML Utilities A collection of various utility classes to ease working with XML. @@ -33,7 +33,7 @@ limitations under the License. scm:git:https://github.com/codehaus-plexus/plexus-xml.git ${project.scm.connection} - plexus-xml-4.0.3 + master https://github.com/codehaus-plexus/plexus-xml/tree/${project.scm.tag}/ @@ -48,7 +48,7 @@ limitations under the License. - 2023-12-13T20:00:11Z + 2023-12-13T20:00:19Z From c9d72affa12e1109be3003911af1b12e6d79026a Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 20 May 2024 16:09:36 +0200 Subject: [PATCH 36/74] Remove special chars from xml output (#28) --------- Co-authored-by: Michael Osipov <1983-01-06@gmx.net> --- .../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 e089c5c1..cd35289d 100644 --- a/src/main/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriter.java +++ b/src/main/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriter.java @@ -24,9 +24,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) */ @@ -186,7 +186,7 @@ private void writeText(String text, boolean escapeXml) { finishTag(); if (escapeXml) { - text = escapeXml(text); + text = escapeXmlText(text); } write(StringUtils.unifyLineSeparators(text, lineSeparator)); @@ -226,10 +226,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); @@ -247,6 +249,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 b459efdba485e89fedc9aaba16da4c29bbd7d18c Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 20 May 2024 16:46:48 +0200 Subject: [PATCH 37/74] Release drafter for master and 3.x branch --- .github/release-drafter.yml | 3 ++- .github/workflows/release-drafter-3x.yml | 14 ++++++++++++++ ...ease-drafter.yml => release-drafter-master.yml} | 2 ++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release-drafter-3x.yml rename .github/workflows/{release-drafter.yml => release-drafter-master.yml} (84%) diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index c7f59480..e85fffbe 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -1,2 +1,3 @@ _extends: .github -tag-template: plexus-utils-$NEXT_MINOR_VERSION +tag-template: plexus-xml-$NEXT_MINOR_VERSION +filter-by-commitish: true \ No newline at end of file diff --git a/.github/workflows/release-drafter-3x.yml b/.github/workflows/release-drafter-3x.yml new file mode 100644 index 00000000..4f0194e6 --- /dev/null +++ b/.github/workflows/release-drafter-3x.yml @@ -0,0 +1,14 @@ +name: Release Drafter +on: + push: + branches: + - 3.x +jobs: + update_release_draft: + runs-on: ubuntu-latest + steps: + - uses: release-drafter/release-drafter@v5 + with: + commitish: '3.x' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter-master.yml similarity index 84% rename from .github/workflows/release-drafter.yml rename to .github/workflows/release-drafter-master.yml index 4000f8c4..19758825 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter-master.yml @@ -8,5 +8,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: release-drafter/release-drafter@v5 + with: + commitish: 'master' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From e9ce97841e3f5ad6d2392f3f31c7521fd01e59e1 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 20 May 2024 17:30:34 +0200 Subject: [PATCH 38/74] Add dependabot for 3.x branch --- .github/dependabot.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index b76b8957..99bc7a7e 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -2,9 +2,24 @@ version: 2 updates: - package-ecosystem: "maven" directory: "/" + target-branch: "master" schedule: interval: "daily" + + - package-ecosystem: "maven" + directory: "/" + target-branch: "3.x" + schedule: + interval: "daily" + + - package-ecosystem: "github-actions" + directory: "/" + target-branch: "master" + schedule: + interval: "daily" + - package-ecosystem: "github-actions" directory: "/" + target-branch: "3.x" schedule: interval: "daily" From ba61f627b9a56e933e3264cb1217bf19b688bbd6 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 20 May 2024 17:46:58 +0200 Subject: [PATCH 39/74] Separate release-drafter config per branch --- .github/release-drafter-3.x.yml | 6 ++++++ .github/release-drafter-master.yml | 6 ++++++ .github/release-drafter.yml | 3 --- .github/workflows/release-drafter-3x.yml | 2 +- .github/workflows/release-drafter-master.yml | 2 +- 5 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 .github/release-drafter-3.x.yml create mode 100644 .github/release-drafter-master.yml delete mode 100644 .github/release-drafter.yml diff --git a/.github/release-drafter-3.x.yml b/.github/release-drafter-3.x.yml new file mode 100644 index 00000000..1eb29b37 --- /dev/null +++ b/.github/release-drafter-3.x.yml @@ -0,0 +1,6 @@ +_extends: .github +name-template: '3.$MINOR.$PATCH' +tag-template: 'plexus-xml-3.$MINOR.$PATCH' +version-template: '3.$MINOR.$PATCH' +commitish: '3.x' +filter-by-commitish: true diff --git a/.github/release-drafter-master.yml b/.github/release-drafter-master.yml new file mode 100644 index 00000000..4634f2c0 --- /dev/null +++ b/.github/release-drafter-master.yml @@ -0,0 +1,6 @@ +_extends: .github +name-template: '4.$MINOR.$PATCH' +tag-template: 'plexus-xml-4.$MINOR.$PATCH' +version-template: '4.$MINOR.$PATCH' +commitish: 'master' +filter-by-commitish: true diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml deleted file mode 100644 index e85fffbe..00000000 --- a/.github/release-drafter.yml +++ /dev/null @@ -1,3 +0,0 @@ -_extends: .github -tag-template: plexus-xml-$NEXT_MINOR_VERSION -filter-by-commitish: true \ No newline at end of file diff --git a/.github/workflows/release-drafter-3x.yml b/.github/workflows/release-drafter-3x.yml index 4f0194e6..2a616846 100644 --- a/.github/workflows/release-drafter-3x.yml +++ b/.github/workflows/release-drafter-3x.yml @@ -9,6 +9,6 @@ jobs: steps: - uses: release-drafter/release-drafter@v5 with: - commitish: '3.x' + config-name: 'release-drafter-3.x.yml' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release-drafter-master.yml b/.github/workflows/release-drafter-master.yml index 19758825..caead2f9 100644 --- a/.github/workflows/release-drafter-master.yml +++ b/.github/workflows/release-drafter-master.yml @@ -9,6 +9,6 @@ jobs: steps: - uses: release-drafter/release-drafter@v5 with: - commitish: 'master' + config-name: 'release-drafter-master.yml' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From d3fe89dcbdb0d033588036ca65e90fbdc63d9c31 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 20 May 2024 17:53:48 +0200 Subject: [PATCH 40/74] Fix release-drafter global file name --- .github/release-drafter-3.x.yml | 2 +- .github/release-drafter-master.yml | 2 +- .github/workflows/release-drafter-3x.yml | 2 +- .github/workflows/release-drafter-master.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/release-drafter-3.x.yml b/.github/release-drafter-3.x.yml index 1eb29b37..8f6cf633 100644 --- a/.github/release-drafter-3.x.yml +++ b/.github/release-drafter-3.x.yml @@ -1,4 +1,4 @@ -_extends: .github +_extends: .github:.github/release-drafter.yml name-template: '3.$MINOR.$PATCH' tag-template: 'plexus-xml-3.$MINOR.$PATCH' version-template: '3.$MINOR.$PATCH' diff --git a/.github/release-drafter-master.yml b/.github/release-drafter-master.yml index 4634f2c0..f509f284 100644 --- a/.github/release-drafter-master.yml +++ b/.github/release-drafter-master.yml @@ -1,4 +1,4 @@ -_extends: .github +_extends: .github:.github/release-drafter.yml name-template: '4.$MINOR.$PATCH' tag-template: 'plexus-xml-4.$MINOR.$PATCH' version-template: '4.$MINOR.$PATCH' diff --git a/.github/workflows/release-drafter-3x.yml b/.github/workflows/release-drafter-3x.yml index 2a616846..4f26406e 100644 --- a/.github/workflows/release-drafter-3x.yml +++ b/.github/workflows/release-drafter-3x.yml @@ -1,4 +1,4 @@ -name: Release Drafter +name: Release Drafter 3.x on: push: branches: diff --git a/.github/workflows/release-drafter-master.yml b/.github/workflows/release-drafter-master.yml index caead2f9..b9401ad8 100644 --- a/.github/workflows/release-drafter-master.yml +++ b/.github/workflows/release-drafter-master.yml @@ -1,4 +1,4 @@ -name: Release Drafter +name: Release Drafter Master on: push: branches: From 1977a0b146e54b54820764e3fdcb3d309cf4e22c Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 20 May 2024 17:58:47 +0200 Subject: [PATCH 41/74] Fix release-drafter config --- .github/release-drafter-3.x.yml | 8 ++++---- .github/release-drafter-master.yml | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/release-drafter-3.x.yml b/.github/release-drafter-3.x.yml index 8f6cf633..fb6e79de 100644 --- a/.github/release-drafter-3.x.yml +++ b/.github/release-drafter-3.x.yml @@ -1,6 +1,6 @@ _extends: .github:.github/release-drafter.yml -name-template: '3.$MINOR.$PATCH' -tag-template: 'plexus-xml-3.$MINOR.$PATCH' -version-template: '3.$MINOR.$PATCH' -commitish: '3.x' +name-template: 3.$MINOR.$PATCH +tag-template: plexus-xml-3.$MINOR.$PATCH +version-template: 3.$MINOR.$PATCH +commitish: 3.x filter-by-commitish: true diff --git a/.github/release-drafter-master.yml b/.github/release-drafter-master.yml index f509f284..fe998d89 100644 --- a/.github/release-drafter-master.yml +++ b/.github/release-drafter-master.yml @@ -1,6 +1,6 @@ _extends: .github:.github/release-drafter.yml -name-template: '4.$MINOR.$PATCH' -tag-template: 'plexus-xml-4.$MINOR.$PATCH' -version-template: '4.$MINOR.$PATCH' -commitish: 'master' +name-template: 4.$MINOR.$PATCH' +tag-template: plexus-xml-4.$MINOR.$PATCH +version-template: 4.$MINOR.$PATCH +commitish: master filter-by-commitish: true From 14d3067a15b4f444db45efe904fcf6d4ec295b50 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 20 May 2024 18:04:40 +0200 Subject: [PATCH 42/74] Fix release-drafter config --- .github/release-drafter-3.x.yml | 2 -- .github/release-drafter-master.yml | 2 -- 2 files changed, 4 deletions(-) diff --git a/.github/release-drafter-3.x.yml b/.github/release-drafter-3.x.yml index fb6e79de..54ffe362 100644 --- a/.github/release-drafter-3.x.yml +++ b/.github/release-drafter-3.x.yml @@ -1,6 +1,4 @@ _extends: .github:.github/release-drafter.yml -name-template: 3.$MINOR.$PATCH -tag-template: plexus-xml-3.$MINOR.$PATCH version-template: 3.$MINOR.$PATCH commitish: 3.x filter-by-commitish: true diff --git a/.github/release-drafter-master.yml b/.github/release-drafter-master.yml index fe998d89..920fd960 100644 --- a/.github/release-drafter-master.yml +++ b/.github/release-drafter-master.yml @@ -1,6 +1,4 @@ _extends: .github:.github/release-drafter.yml -name-template: 4.$MINOR.$PATCH' -tag-template: plexus-xml-4.$MINOR.$PATCH version-template: 4.$MINOR.$PATCH commitish: master filter-by-commitish: true From b97a574847f0769f697cca871983920eae3bd0df Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 20 May 2024 18:06:29 +0200 Subject: [PATCH 43/74] Fix release-drafter config --- .github/release-drafter-3.x.yml | 1 + .github/release-drafter-master.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/release-drafter-3.x.yml b/.github/release-drafter-3.x.yml index 54ffe362..2b81e3e6 100644 --- a/.github/release-drafter-3.x.yml +++ b/.github/release-drafter-3.x.yml @@ -1,4 +1,5 @@ _extends: .github:.github/release-drafter.yml +tag-template: plexus-xml-$NEXT_PATCH_VERSION version-template: 3.$MINOR.$PATCH commitish: 3.x filter-by-commitish: true diff --git a/.github/release-drafter-master.yml b/.github/release-drafter-master.yml index 920fd960..6c322a82 100644 --- a/.github/release-drafter-master.yml +++ b/.github/release-drafter-master.yml @@ -1,4 +1,5 @@ _extends: .github:.github/release-drafter.yml +tag-template: plexus-xml-$NEXT_PATCH_VERSION version-template: 4.$MINOR.$PATCH commitish: master filter-by-commitish: true From d56dbc91dec6ed4f380b89d5a626777b9a1473ec Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 20 May 2024 21:16:27 +0200 Subject: [PATCH 44/74] Config release-drafter on master --- .github/workflows/release-drafter-3x.yml | 14 -------------- ...ease-drafter-master.yml => release-drafter.yml} | 2 +- 2 files changed, 1 insertion(+), 15 deletions(-) delete mode 100644 .github/workflows/release-drafter-3x.yml rename .github/workflows/{release-drafter-master.yml => release-drafter.yml} (74%) diff --git a/.github/workflows/release-drafter-3x.yml b/.github/workflows/release-drafter-3x.yml deleted file mode 100644 index 4f26406e..00000000 --- a/.github/workflows/release-drafter-3x.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: Release Drafter 3.x -on: - push: - branches: - - 3.x -jobs: - update_release_draft: - runs-on: ubuntu-latest - steps: - - uses: release-drafter/release-drafter@v5 - with: - config-name: 'release-drafter-3.x.yml' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release-drafter-master.yml b/.github/workflows/release-drafter.yml similarity index 74% rename from .github/workflows/release-drafter-master.yml rename to .github/workflows/release-drafter.yml index b9401ad8..ab919cbf 100644 --- a/.github/workflows/release-drafter-master.yml +++ b/.github/workflows/release-drafter.yml @@ -9,6 +9,6 @@ jobs: steps: - uses: release-drafter/release-drafter@v5 with: - config-name: 'release-drafter-master.yml' + config-name: 'release-drafter-master.yml' # located in .github/ in default branch env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 4ee6e6319ce10d3fba92015e143f59ba1f749d7d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 21:04:34 +0000 Subject: [PATCH 45/74] --- updated-dependencies: - dependency-name: release-drafter/release-drafter dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .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 ab919cbf..e10bac4a 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-master.yml' # located in .github/ in default branch env: From e0a18411cd1309c82b5e1867c144008c1dccf0c8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 21 May 2024 00:13:00 +0200 Subject: [PATCH 46/74] Bump org.codehaus.plexus:plexus-utils from 4.0.0 to 4.0.1 (#37) updated-dependencies: - dependency-name: org.codehaus.plexus:plexus-utils dependency-type: direct:development update-type: version-update:semver-patch ... 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 d8c91aef..63e6872e 100644 --- a/pom.xml +++ b/pom.xml @@ -83,7 +83,7 @@ limitations under the License. org.codehaus.plexus plexus-utils - 4.0.0 + 4.0.1 test From d84cafe193583cc1e5295c0ab5c98485fc42b48d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 21 May 2024 00:20:59 +0200 Subject: [PATCH 47/74] Bump org.codehaus.plexus:plexus from 16 to 17 (#35) 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 63e6872e..ab13bd19 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ limitations under the License. org.codehaus.plexus plexus - 16 + 17 plexus-xml From 6bccd346ebe060dc427d8cf16097966eb2e7bf3c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 21 May 2024 22:42:32 +0200 Subject: [PATCH 48/74] Bump org.codehaus.plexus:plexus from 17 to 18 (#39) 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 ab13bd19..b5651923 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ limitations under the License. org.codehaus.plexus plexus - 17 + 18 plexus-xml From 43dbdca6780fd60371e63f7e94d938b482e2edc9 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Mon, 20 May 2024 10:33:23 -0400 Subject: [PATCH 49/74] Allow nulls for write elements in MXSerializer https://issues.apache.org/jira/browse/MJAVADOC-793 --- .../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 f25521bc31d321c2ffb57cf26ae17f745c2c35a6 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Tue, 21 May 2024 23:02:13 +0200 Subject: [PATCH 50/74] [maven-release-plugin] prepare release plexus-xml-4.0.4 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index b5651923..cbcddc56 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ limitations under the License. plexus-xml - 4.0.4-SNAPSHOT + 4.0.4 Plexus XML Utilities A collection of various utility classes to ease working with XML. @@ -33,7 +33,7 @@ limitations under the License. scm:git:https://github.com/codehaus-plexus/plexus-xml.git ${project.scm.connection} - master + plexus-xml-4.0.4 https://github.com/codehaus-plexus/plexus-xml/tree/${project.scm.tag}/ @@ -48,7 +48,7 @@ limitations under the License. - 2023-12-13T20:00:19Z + 2024-05-21T21:02:09Z From 0890afc673f58f2efa0091cdfa7a2f65d9fc3e3a Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Tue, 21 May 2024 23:02:17 +0200 Subject: [PATCH 51/74] [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 cbcddc56..d277bf33 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ limitations under the License. plexus-xml - 4.0.4 + 4.0.5-SNAPSHOT Plexus XML Utilities A collection of various utility classes to ease working with XML. @@ -33,7 +33,7 @@ limitations under the License. scm:git:https://github.com/codehaus-plexus/plexus-xml.git ${project.scm.connection} - plexus-xml-4.0.4 + master https://github.com/codehaus-plexus/plexus-xml/tree/${project.scm.tag}/ @@ -48,7 +48,7 @@ limitations under the License. - 2024-05-21T21:02:09Z + 2024-05-21T21:02:17Z From 05f3c9fe8680f8bb79f78f61a3b929a7034cda58 Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Sun, 16 Jun 2024 19:35:40 +0200 Subject: [PATCH 52/74] Require Java 17 and upgrade maven-xml-impl to 4.0.0-beta-3 --- .github/workflows/maven.yml | 7 +++++++ README.md | 1 + pom.xml | 5 +++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 09feae47..e8a60412 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -23,6 +23,13 @@ jobs: build: name: Build it uses: codehaus-plexus/.github/.github/workflows/maven.yml@master + with: + # Works with Java 17+ + matrix-exclude: > + [ + {"jdk": "8"}, + {"jdk": "11"} + ] deploy: name: Deploy diff --git a/README.md b/README.md index ce4cf7ab..d819ce65 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ This library consists of XML classes (`org.codehaus.plexus.util.xml` and `org.co 2. then updated to use Maven 4-specific [`maven-xml-api`](https://github.com/apache/maven/tree/maven-4.0.0-alpha-7/api/maven-api-xml)/[`maven-xml-impl`](https://github.com/apache/maven/tree/maven-4.0.0-alpha-7/maven-xml-impl):\ this is the `master` branch from which `plexus-xml` 4 is released\ + Version 4.x requires Java 17 (like Maven 4) [![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) For publishing [the site](https://codehaus-plexus.github.io/plexus-xml/) do the following: diff --git a/pom.xml b/pom.xml index d277bf33..15600310 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ limitations under the License. plexus-xml - 4.0.5-SNAPSHOT + 4.1.0-SNAPSHOT Plexus XML Utilities A collection of various utility classes to ease working with XML. @@ -48,6 +48,7 @@ limitations under the License. + 17 2024-05-21T21:02:17Z @@ -55,7 +56,7 @@ limitations under the License. org.apache.maven maven-xml-impl - 4.0.0-alpha-9 + 4.0.0-beta-3 org.eclipse.sisu From aec86f0b3b8b354a53289f9671363996ed7d9135 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Mon, 19 Aug 2024 02:00:57 +0200 Subject: [PATCH 53/74] use new Reproducible Central badge endpoint --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index d819ce65..2bd6888b 100644 --- a/README.md +++ b/README.md @@ -4,6 +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&versionPrefix=3.)](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)](https://search.maven.org/artifact/org.codehaus.plexus/plexus-xml) +[![Reproducible Builds](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/jvm-repo-rebuild/reproducible-central/master/content/org/codehaus/plexus/plexus-xml/badge.json)](https://github.com/jvm-repo-rebuild/reproducible-central/blob/master/content/org/codehaus/plexus/plexus-xml/README.md) This library consists of XML classes (`org.codehaus.plexus.util.xml` and `org.codehaus.plexus.util.xml.pull`) that: From d592f2b0c6ebe5c834bd5e970a39686ba346c82b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Sep 2024 15:20:25 +0000 Subject: [PATCH 54/74] Bump org.apache.maven:maven-xml-impl from 4.0.0-beta-3 to 4.0.0-beta-4 Bumps [org.apache.maven:maven-xml-impl](https://github.com/apache/maven) from 4.0.0-beta-3 to 4.0.0-beta-4. - [Release notes](https://github.com/apache/maven/releases) - [Commits](https://github.com/apache/maven/compare/maven-4.0.0-beta-3...maven-4.0.0-beta-4) --- updated-dependencies: - dependency-name: org.apache.maven:maven-xml-impl dependency-type: direct:production 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 15600310..1e4fd084 100644 --- a/pom.xml +++ b/pom.xml @@ -56,7 +56,7 @@ limitations under the License. org.apache.maven maven-xml-impl - 4.0.0-beta-3 + 4.0.0-beta-4 org.eclipse.sisu From 356a7785d621e8b222ae5c276ea3a8913c014c86 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 24 Sep 2024 16:01:41 +0000 Subject: [PATCH 55/74] 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 1e4fd084..727096a8 100644 --- a/pom.xml +++ b/pom.xml @@ -84,7 +84,7 @@ limitations under the License. org.codehaus.plexus plexus-utils - 4.0.1 + 4.0.2 test From 3b0c0a2d06743b11d8b03ba961fb650fb80301af Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Sun, 6 Oct 2024 23:04:02 +0200 Subject: [PATCH 56/74] Update README to beta-4 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2bd6888b..85452437 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ This library consists of XML classes (`org.codehaus.plexus.util.xml` and `org.co this step is released as `plexus-xml` 3, maintained in [3.x branch](tree/3.x)\ [![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), -2. then updated to use Maven 4-specific [`maven-xml-api`](https://github.com/apache/maven/tree/maven-4.0.0-alpha-7/api/maven-api-xml)/[`maven-xml-impl`](https://github.com/apache/maven/tree/maven-4.0.0-alpha-7/maven-xml-impl):\ +2. then updated to use Maven 4-specific [`maven-xml-api`](https://github.com/apache/maven/tree/maven-4.0.0-beta-4/api/maven-api-xml)/[`maven-xml-impl`](https://github.com/apache/maven/tree/maven-4.0.0-beta-4/maven-xml-impl):\ this is the `master` branch from which `plexus-xml` 4 is released\ Version 4.x requires Java 17 (like Maven 4) [![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) From e7265457eef7944672f2fdb8e577764b471995a0 Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Sun, 6 Oct 2024 23:05:25 +0200 Subject: [PATCH 57/74] Update index.md to beta-4 --- src/site/markdown/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/site/markdown/index.md b/src/site/markdown/index.md index 823a3b2e..03b37fea 100644 --- a/src/site/markdown/index.md +++ b/src/site/markdown/index.md @@ -4,5 +4,5 @@ A collection of various utility classes to ease working with XML. This library consists of XML classes (`org.codehaus.plexus.util.xml` and `org.codehaus.plexus.util.xml.pull`): 1. that have been extracted from [`plexus-utils`](../plexus-utils/) 4, -2. then updated to use [`maven-xml-api`](https://maven.apache.org/ref/4.0.0-alpha-7/api/maven-api-xml/)/[`maven-xml-impl`](https://maven.apache.org/ref/4.0.0-alpha-7/maven-xml-impl/index.html) +2. then updated to use [`maven-xml-api`](https://maven.apache.org/ref/4.0.0-beta-4/api/maven-api-xml/)/[`maven-xml-impl`](https://maven.apache.org/ref/4.0.0-beta-4/maven-xml-impl/index.html) From 0eb30c19b93fc74f89d247e7f2ee0134bae2f6cc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 22 Oct 2024 15:23:41 +0000 Subject: [PATCH 58/74] Bump org.apache.maven:maven-xml-impl from 4.0.0-beta-4 to 4.0.0-beta-5 Bumps [org.apache.maven:maven-xml-impl](https://github.com/apache/maven) from 4.0.0-beta-4 to 4.0.0-beta-5. - [Release notes](https://github.com/apache/maven/releases) - [Commits](https://github.com/apache/maven/compare/maven-4.0.0-beta-4...maven-4.0.0-beta-5) --- updated-dependencies: - dependency-name: org.apache.maven:maven-xml-impl dependency-type: direct:production 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 727096a8..eb2fbcb6 100644 --- a/pom.xml +++ b/pom.xml @@ -56,7 +56,7 @@ limitations under the License. org.apache.maven maven-xml-impl - 4.0.0-beta-4 + 4.0.0-beta-5 org.eclipse.sisu From ead39ddf9c76295250a29e53c3361015fe624b4a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 26 Sep 2024 15:17:28 +0000 Subject: [PATCH 59/74] 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 eb2fbcb6..3443aecb 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ limitations under the License. org.codehaus.plexus plexus - 18 + 19 plexus-xml From f411cdd227444f92647b15a130e8aa88d79c7631 Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Sun, 6 Oct 2024 23:30:03 +0200 Subject: [PATCH 60/74] Adjust to new model --- src/site/markdown/index.md | 2 +- src/site/site.xml | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/site/markdown/index.md b/src/site/markdown/index.md index 03b37fea..30bb189b 100644 --- a/src/site/markdown/index.md +++ b/src/site/markdown/index.md @@ -1,4 +1,4 @@ -## Plexus XML Utilities +# Plexus XML Utilities A collection of various utility classes to ease working with XML. diff --git a/src/site/site.xml b/src/site/site.xml index 43170c22..075f5ece 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -1,8 +1,22 @@ + + - @@ -22,4 +36,4 @@ - \ No newline at end of file + From f6fc5ed773395f3c019975c52acab1523f96123e Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Sat, 2 Nov 2024 11:43:58 +0100 Subject: [PATCH 61/74] Bump descriptions to Maven beta-5 --- README.md | 2 +- src/site/markdown/index.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 85452437..c7ea09d9 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ This library consists of XML classes (`org.codehaus.plexus.util.xml` and `org.co this step is released as `plexus-xml` 3, maintained in [3.x branch](tree/3.x)\ [![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), -2. then updated to use Maven 4-specific [`maven-xml-api`](https://github.com/apache/maven/tree/maven-4.0.0-beta-4/api/maven-api-xml)/[`maven-xml-impl`](https://github.com/apache/maven/tree/maven-4.0.0-beta-4/maven-xml-impl):\ +2. then updated to use Maven 4-specific [`maven-xml-api`](https://github.com/apache/maven/tree/maven-4.0.0-beta-5/api/maven-api-xml)/[`maven-xml-impl`](https://github.com/apache/maven/tree/maven-4.0.0-beta-5/maven-xml-impl):\ this is the `master` branch from which `plexus-xml` 4 is released\ Version 4.x requires Java 17 (like Maven 4) [![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) diff --git a/src/site/markdown/index.md b/src/site/markdown/index.md index 30bb189b..4e77c870 100644 --- a/src/site/markdown/index.md +++ b/src/site/markdown/index.md @@ -4,5 +4,5 @@ A collection of various utility classes to ease working with XML. This library consists of XML classes (`org.codehaus.plexus.util.xml` and `org.codehaus.plexus.util.xml.pull`): 1. that have been extracted from [`plexus-utils`](../plexus-utils/) 4, -2. then updated to use [`maven-xml-api`](https://maven.apache.org/ref/4.0.0-beta-4/api/maven-api-xml/)/[`maven-xml-impl`](https://maven.apache.org/ref/4.0.0-beta-4/maven-xml-impl/index.html) +2. then updated to use [`maven-xml-api`](https://maven.apache.org/ref/4.0.0-beta-5/api/maven-api-xml/)/[`maven-xml-impl`](https://maven.apache.org/ref/4.0.0-beta-5/maven-xml-impl/index.html) From 5a1f0a35c3fe17d0a3c96648ff85b9f8f596711f Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Mon, 16 Dec 2024 00:38:10 +0100 Subject: [PATCH 62/74] Cleanup tests --- .../util/xml/PrettyPrintXMLWriterTest.java | 31 +- .../plexus/util/xml/XmlStreamReaderTest.java | 28 +- .../plexus/util/xml/XmlStreamWriterTest.java | 26 +- .../codehaus/plexus/util/xml/XmlUtilTest.java | 11 +- .../plexus/util/xml/XmlWriterUtilTest.java | 101 ++-- .../plexus/util/xml/Xpp3DomBuilderTest.java | 16 +- .../codehaus/plexus/util/xml/Xpp3DomTest.java | 49 +- .../plexus/util/xml/Xpp3DomWriterTest.java | 6 +- ...onformanceTestSuite_Production24_Test.java | 21 +- ...ConformanceTestSuite_Production2_Test.java | 64 +-- ...onformanceTestSuite_Production32_Test.java | 18 +- ...onformanceTestSuite_Production66_Test.java | 33 +- ...onformanceTestSuite_Production80_Test.java | 15 +- .../plexus/util/xml/pull/MXParserTest.java | 473 +++++++++--------- .../util/xml/pull/MXSerializerTest.java | 6 +- ..._BjoernHoehrmannviaHST2013_09_18_Test.java | 16 +- 16 files changed, 460 insertions(+), 454 deletions(-) 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 9e23c420..00f40794 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java @@ -45,7 +45,7 @@ * @version $Id: $Id * @since 3.4.0 */ -public class PrettyPrintXMLWriterTest { +class PrettyPrintXMLWriterTest { StringWriter w; PrettyPrintXMLWriter writer; @@ -54,7 +54,7 @@ public class PrettyPrintXMLWriterTest { *

    setUp.

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

    tearDown.

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

    testDefaultPrettyPrintXMLWriter.

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

    testPrettyPrintXMLWriterWithGivenLineSeparator.

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

    testPrettyPrintXMLWriterWithGivenLineIndenter.

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

    testEscapeXmlAttribute.

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

    testendElementAlreadyClosed.

    */ @Test - public void testendElementAlreadyClosed() { - assertThrows(NoSuchElementException.class, () -> { - writer.startElement(Tag.DIV.toString()); - writer.addAttribute("class", "someattribute"); - writer.endElement(); // Tag.DIV closed - writer.endElement(); // Tag.DIV already closed, and there is no other outer tag! - }); + void testendElementAlreadyClosed() { + writer.startElement(Tag.DIV.toString()); + writer.addAttribute("class", "someattribute"); + writer.endElement(); + assertThrows( + NoSuchElementException.class, + () -> // Tag.DIV closed + writer.endElement()); } /** @@ -173,7 +174,7 @@ public void testendElementAlreadyClosed() { */ @Disabled("This test is only relevant on JDK 1.7, which is not supported anymore") @Test - public void testIssue51DetectJava7ConcatenationBug() throws IOException { + void issue51DetectJava7ConcatenationBug() throws IOException { File dir = new File("target/test-xml"); if (!dir.exists()) { assertTrue(dir.mkdir(), "cannot create directory test-xml"); 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..c87f9f70 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"; @@ -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..19b4027c 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"; @@ -78,7 +78,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 +89,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 +106,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 +116,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 +126,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 +136,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 +146,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 +156,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 +166,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 +176,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 +186,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 +196,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 eb6db5eb..4805cd69 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()); @@ -89,7 +90,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()); @@ -109,7 +110,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()); @@ -135,7 +136,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 35ca0a25..d0b94f8e 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 = new XmlStreamWriter(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,14 @@ public void testWriteLineBreakXMLWriterIntIntInt() throws Exception { * @throws java.lang.Exception if any */ @Test - public void testWriteCommentLineBreakXMLWriter() throws Exception { + void writeCommentLineBreakXMLWriter() throws Exception { XmlWriterUtil.writeCommentLineBreak(xmlWriter); writer.close(); StringBuilder sb = new StringBuilder(); sb.append("") .append(XmlWriterUtil.LS); assertEquals(output.toString(), sb.toString()); - assertTrue(output.toString().length() == XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length()); + assertEquals(output.toString().length(), XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length()); } /** @@ -145,7 +147,7 @@ public void testWriteCommentLineBreakXMLWriter() throws Exception { * @throws java.lang.Exception if any */ @Test - public void testWriteCommentLineBreakXMLWriterInt() throws Exception { + void writeCommentLineBreakXMLWriterInt() throws Exception { XmlWriterUtil.writeCommentLineBreak(xmlWriter, 20); writer.close(); assertEquals(output.toString(), "" + XmlWriterUtil.LS); @@ -165,14 +167,14 @@ public void testWriteCommentLineBreakXMLWriterInt() throws Exception { * @throws java.lang.Exception if any */ @Test - public void testWriteCommentXMLWriterString() throws Exception { + void writeCommentXMLWriterString() throws Exception { XmlWriterUtil.writeComment(xmlWriter, "hello"); writer.close(); StringBuffer sb = new StringBuffer(); sb.append("") .append(XmlWriterUtil.LS); assertEquals(output.toString(), sb.toString()); - assertTrue(output.toString().length() == XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length()); + assertEquals(output.toString().length(), XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length()); tearDown(); setUp(); @@ -197,8 +199,8 @@ public void testWriteCommentXMLWriterString() throws Exception { sb.append("") .append(XmlWriterUtil.LS); assertEquals(output.toString(), sb.toString()); - assertTrue( - output.toString().length() == 2 * (XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length())); + assertEquals( + output.toString().length(), 2 * (XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length())); } /** @@ -208,7 +210,7 @@ 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); @@ -218,8 +220,9 @@ public void testWriteCommentXMLWriterStringInt() throws Exception { sb.append("") .append(XmlWriterUtil.LS); assertEquals(output.toString(), sb.toString()); - assertTrue(output.toString().length() - == XmlWriterUtil.DEFAULT_COLUMN_LINE + assertEquals( + output.toString().length(), + XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length() + 2 * XmlWriterUtil.DEFAULT_INDENTATION_SIZE); @@ -237,8 +240,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,7 +252,7 @@ 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); @@ -258,8 +262,8 @@ public void testWriteCommentXMLWriterStringIntInt() throws Exception { sb.append("") .append(XmlWriterUtil.LS); assertEquals(output.toString(), sb.toString()); - assertTrue(output.toString().length() - == XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length() + 2 * 4); + assertEquals( + output.toString().length(), XmlWriterUtil.DEFAULT_COLUMN_LINE - 1 + XmlWriterUtil.LS.length() + 2 * 4); tearDown(); setUp(); @@ -274,8 +278,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,7 +290,7 @@ 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); @@ -294,7 +299,7 @@ public void testWriteCommentXMLWriterStringIntIntInt() throws Exception { sb.append(indent); sb.append("").append(XmlWriterUtil.LS); assertEquals(output.toString(), sb.toString()); - assertTrue(output.toString().length() == 50 - 1 + XmlWriterUtil.LS.length() + 2 * 4); + assertEquals(output.toString().length(), 50 - 1 + XmlWriterUtil.LS.length() + 2 * 4); tearDown(); setUp(); @@ -315,7 +320,7 @@ public void testWriteCommentXMLWriterStringIntIntInt() throws Exception { * @throws java.lang.Exception if any */ @Test - public void testWriteCommentTextXMLWriterStringInt() throws Exception { + void writeCommentTextXMLWriterStringInt() throws Exception { XmlWriterUtil.writeCommentText(xmlWriter, "hello", 0); writer.close(); StringBuffer sb = new StringBuffer(); @@ -328,8 +333,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(); @@ -374,7 +379,7 @@ 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); @@ -393,8 +398,9 @@ public void testWriteCommentTextXMLWriterStringIntInt() throws Exception { sb.append(XmlWriterUtil.LS); sb.append(indent); assertEquals(output.toString(), sb.toString()); - assertTrue(output.toString().length() - == 3 * (80 - 1 + XmlWriterUtil.LS.length()) + 4 * 2 * 4 + 2 * XmlWriterUtil.LS.length()); + assertEquals( + output.toString().length(), + 3 * (80 - 1 + XmlWriterUtil.LS.length()) + 4 * 2 * 4 + 2 * XmlWriterUtil.LS.length()); } /** @@ -404,7 +410,7 @@ 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); @@ -423,8 +429,9 @@ public void testWriteCommentTextXMLWriterStringIntIntInt() throws Exception { sb.append(XmlWriterUtil.LS); sb.append(indent); assertEquals(output.toString(), sb.toString()); - assertTrue(output.toString().length() - == 3 * (50 - 1 + XmlWriterUtil.LS.length()) + 4 * 2 * 4 + 2 * XmlWriterUtil.LS.length()); + assertEquals( + output.toString().length(), + 3 * (50 - 1 + XmlWriterUtil.LS.length()) + 4 * 2 * 4 + 2 * XmlWriterUtil.LS.length()); } /** @@ -434,7 +441,7 @@ public void testWriteCommentTextXMLWriterStringIntIntInt() throws Exception { * @throws java.lang.Exception if any */ @Test - public void testWriteCommentNull() throws Exception { + void writeCommentNull() throws Exception { XmlWriterUtil.writeComment(xmlWriter, null); writer.close(); StringBuilder sb = new StringBuilder(); @@ -450,7 +457,7 @@ public void testWriteCommentNull() throws Exception { * @throws java.lang.Exception if any */ @Test - public void testWriteCommentShort() throws Exception { + void writeCommentShort() throws Exception { XmlWriterUtil.writeComment(xmlWriter, "This is a short text"); writer.close(); StringBuilder sb = new StringBuilder(); @@ -466,7 +473,7 @@ public void testWriteCommentShort() throws Exception { * @throws java.lang.Exception if any */ @Test - public void testWriteCommentLong() throws Exception { + void writeCommentLong() throws Exception { XmlWriterUtil.writeComment( xmlWriter, "Maven is a software project management and comprehension tool. " diff --git a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomBuilderTest.java b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomBuilderTest.java index c8db71b5..a490540b 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,7 +181,7 @@ public void testEscapingInAttributes() throws IOException, XmlPullParserExceptio * @throws org.codehaus.plexus.util.xml.pull.XmlPullParserException if any. */ @Test - public void testInputLocationTracking() throws IOException, XmlPullParserException { + void inputLocationTracking() 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 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 dccdde34..828c6cda 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomTest.java @@ -38,12 +38,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); @@ -81,7 +81,7 @@ public void testShouldPerformAppendAtFirstSubElementLevel() { *

    testShouldOverrideAppendAndDeepMerge.

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

    testShouldPerformSelfOverrideAtTopLevel.

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

    testShouldMergeValuesAtTopLevelByDefault.

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

    testShouldMergeValuesAtTopLevel.

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

    testNullAttributeNameOrValue.

    */ @Test - public void testNullAttributeNameOrValue() { + void nullAttributeNameOrValue() { Xpp3Dom t1 = new Xpp3Dom("top"); try { t1.setAttribute("attr", null); @@ -212,12 +212,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(""))); + assertNotEquals(null, dom); + assertNotEquals(dom, new Xpp3Dom("")); } /** @@ -227,7 +227,7 @@ 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)); @@ -249,7 +249,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")); @@ -275,8 +275,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")); @@ -307,7 +306,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)); @@ -317,9 +316,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()); } /** @@ -328,7 +327,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)); @@ -350,7 +349,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); @@ -363,7 +362,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)); @@ -381,7 +380,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)); @@ -399,7 +398,7 @@ public void testShouldRemoveDoNotRemoveTagWhenSwappedInputDOMs() throws Exceptio * @throws java.lang.Exception if any. */ @Test - public void testCombineId() throws Exception { + void combineId() throws Exception { String lhs = "" + "LHS-ONLYLHS" + "TOOVERWRITELHS" + ""; @@ -447,7 +446,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" + ""; @@ -490,7 +489,7 @@ public void testCombineKeys() throws Exception { } @Test - public void testPreserveDominantBlankValue() throws XmlPullParserException, IOException { + void preserveDominantBlankValue() throws XmlPullParserException, IOException { String lhs = " "; String rhs = "recessive"; @@ -505,7 +504,7 @@ public void testPreserveDominantBlankValue() throws XmlPullParserException, IOEx } @Test - public void testPreserveDominantEmptyNode() throws XmlPullParserException, IOException { + void preserveDominantEmptyNode() throws XmlPullParserException, IOException { String lhs = ""; String rhs = "recessive"; 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..fc4cc279 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 { +class Xpp3DomWriterTest { private static final String LS = System.getProperty("line.separator"); /** *

    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..43279b83 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production2_Test.java +++ b/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production2_Test.java @@ -38,7 +38,7 @@ class IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConfo *

    setUp.

    */ @BeforeEach - public void setUp() { + void setUp() { parser = new MXParser(); } @@ -52,7 +52,7 @@ public void setUp() { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n01xml() throws IOException { + void testibm_not_wf_P02_ibm02n01xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n01.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -73,7 +73,7 @@ public void testibm_not_wf_P02_ibm02n01xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n02xml() throws IOException { + void testibm_not_wf_P02_ibm02n02xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n02.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -94,7 +94,7 @@ public void testibm_not_wf_P02_ibm02n02xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n03xml() throws IOException { + void testibm_not_wf_P02_ibm02n03xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n03.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -115,7 +115,7 @@ public void testibm_not_wf_P02_ibm02n03xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n04xml() throws IOException { + void testibm_not_wf_P02_ibm02n04xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n04.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -136,7 +136,7 @@ public void testibm_not_wf_P02_ibm02n04xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n05xml() throws IOException { + void testibm_not_wf_P02_ibm02n05xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n05.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -157,7 +157,7 @@ public void testibm_not_wf_P02_ibm02n05xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n06xml() throws IOException { + void testibm_not_wf_P02_ibm02n06xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n06.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -178,7 +178,7 @@ public void testibm_not_wf_P02_ibm02n06xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n07xml() throws IOException { + void testibm_not_wf_P02_ibm02n07xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n07.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -199,7 +199,7 @@ public void testibm_not_wf_P02_ibm02n07xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n08xml() throws IOException { + void testibm_not_wf_P02_ibm02n08xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n08.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -220,7 +220,7 @@ public void testibm_not_wf_P02_ibm02n08xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n09xml() throws IOException { + void testibm_not_wf_P02_ibm02n09xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n09.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -241,7 +241,7 @@ public void testibm_not_wf_P02_ibm02n09xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n10xml() throws IOException { + void testibm_not_wf_P02_ibm02n10xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n10.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -262,7 +262,7 @@ public void testibm_not_wf_P02_ibm02n10xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n11xml() throws IOException { + void testibm_not_wf_P02_ibm02n11xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n11.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -283,7 +283,7 @@ public void testibm_not_wf_P02_ibm02n11xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n12xml() throws IOException { + void testibm_not_wf_P02_ibm02n12xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n12.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -304,7 +304,7 @@ public void testibm_not_wf_P02_ibm02n12xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n13xml() throws IOException { + void testibm_not_wf_P02_ibm02n13xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n13.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -325,7 +325,7 @@ public void testibm_not_wf_P02_ibm02n13xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n14xml() throws IOException { + void testibm_not_wf_P02_ibm02n14xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n14.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -346,7 +346,7 @@ public void testibm_not_wf_P02_ibm02n14xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n15xml() throws IOException { + void testibm_not_wf_P02_ibm02n15xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n15.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -367,7 +367,7 @@ public void testibm_not_wf_P02_ibm02n15xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n16xml() throws IOException { + void testibm_not_wf_P02_ibm02n16xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n16.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -388,7 +388,7 @@ public void testibm_not_wf_P02_ibm02n16xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n17xml() throws IOException { + void testibm_not_wf_P02_ibm02n17xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n17.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -409,7 +409,7 @@ public void testibm_not_wf_P02_ibm02n17xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n18xml() throws IOException { + void testibm_not_wf_P02_ibm02n18xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n18.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -430,7 +430,7 @@ public void testibm_not_wf_P02_ibm02n18xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n19xml() throws IOException { + void testibm_not_wf_P02_ibm02n19xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n19.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -451,7 +451,7 @@ public void testibm_not_wf_P02_ibm02n19xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n20xml() throws IOException { + void testibm_not_wf_P02_ibm02n20xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n20.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -472,7 +472,7 @@ public void testibm_not_wf_P02_ibm02n20xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n21xml() throws IOException { + void testibm_not_wf_P02_ibm02n21xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n21.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -493,7 +493,7 @@ public void testibm_not_wf_P02_ibm02n21xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n22xml() throws IOException { + void testibm_not_wf_P02_ibm02n22xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n22.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -514,7 +514,7 @@ public void testibm_not_wf_P02_ibm02n22xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n23xml() throws IOException { + void testibm_not_wf_P02_ibm02n23xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n23.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -535,7 +535,7 @@ public void testibm_not_wf_P02_ibm02n23xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n24xml() throws IOException { + void testibm_not_wf_P02_ibm02n24xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n24.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -556,7 +556,7 @@ public void testibm_not_wf_P02_ibm02n24xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n25xml() throws IOException { + void testibm_not_wf_P02_ibm02n25xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n25.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -577,7 +577,7 @@ public void testibm_not_wf_P02_ibm02n25xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n26xml() throws IOException { + void testibm_not_wf_P02_ibm02n26xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n26.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -598,7 +598,7 @@ public void testibm_not_wf_P02_ibm02n26xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n27xml() throws IOException { + void testibm_not_wf_P02_ibm02n27xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n27.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -619,7 +619,7 @@ public void testibm_not_wf_P02_ibm02n27xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n28xml() throws IOException { + void testibm_not_wf_P02_ibm02n28xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n28.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -640,7 +640,7 @@ public void testibm_not_wf_P02_ibm02n28xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n29xml() throws IOException { + void testibm_not_wf_P02_ibm02n29xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P02/ibm02n29.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -710,7 +710,7 @@ public void testibm_not_wf_P02_ibm02n31xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n32xml() throws IOException { + void testibm_not_wf_P02_ibm02n32xml() throws IOException { try (FileInputStream is = new FileInputStream(new File(testResourcesDir, "not-wf/P02/ibm02n32.xml")); InputStreamReader reader = new InputStreamReader(is, StandardCharsets.UTF_8)) { parser.setInput(reader); @@ -732,7 +732,7 @@ public void testibm_not_wf_P02_ibm02n32xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P02_ibm02n33xml() throws IOException { + void testibm_not_wf_P02_ibm02n33xml() throws IOException { try (FileInputStream is = new FileInputStream(new File(testResourcesDir, "not-wf/P02/ibm02n33.xml")); InputStreamReader reader = new InputStreamReader(is, StandardCharsets.UTF_8)) { parser.setInput(reader); diff --git a/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production32_Test.java b/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production32_Test.java index f99e1ead..cda5f99e 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production32_Test.java +++ b/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production32_Test.java @@ -31,7 +31,7 @@ class IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConfo *

    setUp.

    */ @BeforeEach - public void setUp() { + void setUp() { parser = new MXParser(); } @@ -45,7 +45,7 @@ public void setUp() { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P32_ibm32n01xml() throws IOException { + void testibm_not_wf_P32_ibm32n01xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P32/ibm32n01.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -67,7 +67,7 @@ public void testibm_not_wf_P32_ibm32n01xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P32_ibm32n02xml() throws IOException { + void testibm_not_wf_P32_ibm32n02xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P32/ibm32n02.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -89,7 +89,7 @@ public void testibm_not_wf_P32_ibm32n02xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P32_ibm32n03xml() throws IOException { + void testibm_not_wf_P32_ibm32n03xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P32/ibm32n03.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -110,7 +110,7 @@ public void testibm_not_wf_P32_ibm32n03xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P32_ibm32n04xml() throws IOException { + void testibm_not_wf_P32_ibm32n04xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P32/ibm32n04.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -131,7 +131,7 @@ public void testibm_not_wf_P32_ibm32n04xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P32_ibm32n05xml() throws IOException { + void testibm_not_wf_P32_ibm32n05xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P32/ibm32n05.xml"))) { parser.setInput(reader); @@ -153,7 +153,7 @@ public void testibm_not_wf_P32_ibm32n05xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P32_ibm32n06xml() throws IOException { + void testibm_not_wf_P32_ibm32n06xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P32/ibm32n06.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -174,7 +174,7 @@ public void testibm_not_wf_P32_ibm32n06xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P32_ibm32n07xml() throws IOException { + void testibm_not_wf_P32_ibm32n07xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P32/ibm32n07.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -195,7 +195,7 @@ public void testibm_not_wf_P32_ibm32n07xml() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testibm_not_wf_P32_ibm32n08xml() throws IOException { + void testibm_not_wf_P32_ibm32n08xml() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P32/ibm32n08.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) diff --git a/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production66_Test.java b/src/test/java/org/codehaus/plexus/util/xml/pull/IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production66_Test.java index 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 0359b8c7..543f84ee 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 @@ -29,6 +29,7 @@ import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.xml.XmlStreamReader; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; @@ -42,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"); @@ -73,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"); @@ -97,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"); @@ -122,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); @@ -141,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;"; @@ -169,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)); @@ -195,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)); @@ -215,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"); } /** @@ -259,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)); @@ -279,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"); } /** @@ -323,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"; @@ -351,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(); @@ -369,7 +370,7 @@ public void testProcessingInstruction() throws Exception { * @throws java.lang.Exception if any. */ @Test - public void testProcessingInstructionsContainingXml() throws Exception { + void processingInstructionsContainingXml() throws Exception { StringBuffer sb = new StringBuffer(); sb.append(""); @@ -397,7 +398,7 @@ public void testProcessingInstructionsContainingXml() throws Exception { * @throws java.lang.Exception if any. */ @Test - public void testMalformedProcessingInstructionsContainingXmlNoClosingQuestionMark() throws Exception { + void malformedProcessingInstructionsContainingXmlNoClosingQuestionMark() throws Exception { StringBuffer sb = new StringBuffer(); sb.append("\n"); sb.append("\n"); @@ -424,7 +425,7 @@ public void testMalformedProcessingInstructionsContainingXmlNoClosingQuestionMar } @Test - public void testSubsequentProcessingInstructionShort() throws Exception { + void subsequentProcessingInstructionShort() throws Exception { StringBuffer sb = new StringBuffer(); sb.append(""); @@ -449,7 +450,7 @@ public void testSubsequentProcessingInstructionShort() throws Exception { * @throws java.lang.Exception if any. */ @Test - public void testSubsequentProcessingInstructionMoreThan8k() throws Exception { + void subsequentProcessingInstructionMoreThan8k() throws Exception { StringBuffer sb = new StringBuffer(); sb.append(""); @@ -493,7 +494,7 @@ public void testSubsequentProcessingInstructionMoreThan8k() throws Exception { * @throws java.lang.Exception if any. */ @Test - public void testLargeText_NoOverflow() throws Exception { + void largeTextNoOverflow() throws Exception { StringBuffer sb = new StringBuffer(); sb.append(""); sb.append(""); @@ -518,7 +519,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 = ""; @@ -544,7 +545,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 = ""; @@ -570,7 +571,7 @@ 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(); @@ -600,7 +601,7 @@ 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(); @@ -629,7 +630,7 @@ 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(); @@ -658,7 +659,7 @@ 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(""); @@ -680,7 +681,7 @@ public void testSubsequentAbortedProcessingInstruction() throws Exception { } @Test - public void testSubsequentAbortedComment() throws Exception { + void subsequentAbortedComment() throws Exception { MXParser parser = new MXParser(); StringBuilder sb = new StringBuilder(); sb.append(""); @@ -701,7 +702,7 @@ public void testSubsequentAbortedComment() throws Exception { } @Test - public void testMalformedXMLRootElement() throws Exception { + void malformedXMLRootElement() throws Exception { String input = " { + assertEquals(XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken()); + assertEquals(XmlPullParser.START_TAG, parser.nextToken()); + assertEquals(XmlPullParser.END_TAG, parser.nextToken()); + }, + "Should not throw Exception"); } /** @@ -835,7 +836,7 @@ public void testXMLDeclVersionOnly() throws Exception { * @throws java.lang.Exception if any. */ @Test - public void testXMLDeclVersionEncodingStandaloneNoSpace() throws Exception { + void xmlDeclVersionEncodingStandaloneNoSpace() throws Exception { String input = ""; MXParser parser = new MXParser(); @@ -856,7 +857,7 @@ public void testXMLDeclVersionEncodingStandaloneNoSpace() throws Exception { * @since 3.4.1 */ @Test - public void testEncodingISO_8859_1_newXmlReader() throws IOException { + void encodingISO88591NewXmlReader() throws IOException { try (Reader reader = new XmlStreamReader(Paths.get("src/test/resources/xml", "test-encoding-ISO-8859-1.xml"))) { MXParser parser = new MXParser(); parser.setInput(reader); @@ -876,7 +877,7 @@ public void testEncodingISO_8859_1_newXmlReader() throws IOException { * @since 3.4.1 */ @Test - public void testEncodingISO_8859_1_InputStream() throws IOException { + void encodingISO88591InputStream() throws IOException { try (InputStream input = Files.newInputStream(Paths.get("src/test/resources/xml", "test-encoding-ISO-8859-1.xml"))) { MXParser parser = new MXParser(); @@ -899,21 +900,21 @@ public void testEncodingISO_8859_1_InputStream() throws IOException { * @since 3.4.2 */ @Test - public void testEncodingISO_8859_1_StringReader() throws IOException { + void encodingISO88591StringReader() throws IOException { String xmlFileContents; try (Reader reader = new XmlStreamReader(Paths.get("src/test/resources/xml", "test-encoding-ISO-8859-1.xml"))) { xmlFileContents = IOUtil.toString(reader); } - try { - MXParser parser = new MXParser(); - parser.setInput(new StringReader(xmlFileContents)); - while (parser.nextToken() != XmlPullParser.END_DOCUMENT) - ; - assertTrue(true); - } catch (XmlPullParserException e) { - fail("should not raise exception: " + e); - } + Assertions.assertDoesNotThrow( + () -> { + MXParser parser = new MXParser(); + parser.setInput(new StringReader(xmlFileContents)); + while (parser.nextToken() != XmlPullParser.END_DOCUMENT) + ; + assertTrue(true); + }, + "should not raise exception: "); } /** @@ -926,7 +927,7 @@ public void testEncodingISO_8859_1_StringReader() throws IOException { * @since 3.5.2 */ @Test - public void testEncodingISO_8859_1_newReader() throws IOException { + void encodingISO88591NewReader() throws IOException { // NOTE: if using Files.newBufferedReader(path, StandardCharsets.UTF-8), the reader will throw an exception // because the decoder created by new InputStreamReader() is lenient while the one created by // Files.newBufferedReader() is not. @@ -953,7 +954,7 @@ public void testEncodingISO_8859_1_newReader() throws IOException { * @since 3.5.2 */ @Test - public void testEncodingISO_8859_1_InputStream_encoded() throws IOException { + void encodingISO88591InputStreamEncoded() throws IOException { try (InputStream input = Files.newInputStream(Paths.get("src/test/resources/xml", "test-encoding-ISO-8859-1.xml"))) { MXParser parser = new MXParser(); @@ -974,7 +975,7 @@ public void testEncodingISO_8859_1_InputStream_encoded() throws IOException { * @since 3.4.1 */ @Test - public void testEncodingUTF8_newXmlReader() throws IOException { + void encodingUTF8NewXmlReader() throws IOException { try (Reader reader = new XmlStreamReader(Paths.get("src/test/resources/xml", "test-encoding-ISO-8859-1.xml"))) { MXParser parser = new MXParser(); parser.setInput(reader); @@ -1003,7 +1004,7 @@ private static void assertPosition(int row, int col, MXParser parser) { * @since 3.4.2 */ @Test - public void testCustomEntityNotFoundInText() throws Exception { + void customEntityNotFoundInText() throws Exception { MXParser parser = new MXParser(); String input = "&otherentity;"; @@ -1036,20 +1037,20 @@ public void testCustomEntityNotFoundInText() throws Exception { * @since 3.4.2 */ @Test - public void testCustomEntityNotFoundInTextTokenize() throws Exception { + void customEntityNotFoundInTextTokenize() throws Exception { MXParser parser = new MXParser(); String input = "&otherentity;"; parser.setInput(new StringReader(input)); parser.defineEntityReplacementText("myentity", "replacement"); - try { - assertEquals(XmlPullParser.START_TAG, parser.nextToken()); - assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); - assertNull(parser.getText()); - } catch (XmlPullParserException e) { - fail("should not throw exception if tokenize"); - } + Assertions.assertDoesNotThrow( + () -> { + assertEquals(XmlPullParser.START_TAG, parser.nextToken()); + assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); + assertNull(parser.getText()); + }, + "should not throw exception if tokenize"); } /** @@ -1064,7 +1065,7 @@ public void testCustomEntityNotFoundInTextTokenize() throws Exception { * @since 3.4.2 */ @Test - public void testCustomEntityNotFoundInAttr() throws Exception { + void customEntityNotFoundInAttr() throws Exception { MXParser parser = new MXParser(); String input = "sometext"; @@ -1097,7 +1098,7 @@ public void testCustomEntityNotFoundInAttr() throws Exception { * @since 3.4.2 */ @Test - public void testCustomEntityNotFoundInAttrTokenize() throws Exception { + void customEntityNotFoundInAttrTokenize() throws Exception { MXParser parser = new MXParser(); String input = "sometext"; @@ -1130,7 +1131,7 @@ public void testCustomEntityNotFoundInAttrTokenize() throws Exception { * @since 3.4.2 */ @Test - public void testDocdeclTextWithEntitiesUnix() throws IOException { + void docdeclTextWithEntitiesUnix() throws IOException { testDocdeclTextWithEntities("test-entities-UNIX.xml"); } @@ -1146,7 +1147,7 @@ public void testDocdeclTextWithEntitiesUnix() throws IOException { * @since 3.4.2 */ @Test - public void testDocdeclTextWithEntitiesDOS() throws IOException { + void docdeclTextWithEntitiesDOS() throws IOException { testDocdeclTextWithEntities("test-entities-DOS.xml"); } @@ -1183,7 +1184,7 @@ private void testDocdeclTextWithEntities(String filename) throws IOException { * @since 3.4.2 */ @Test - public void testDocdeclTextWithEntitiesInAttributesUnix() throws IOException { + void docdeclTextWithEntitiesInAttributesUnix() throws IOException { testDocdeclTextWithEntitiesInAttributes("test-entities-in-attr-UNIX.xml"); } @@ -1199,7 +1200,7 @@ public void testDocdeclTextWithEntitiesInAttributesUnix() throws IOException { * @since 3.4.2 */ @Test - public void testDocdeclTextWithEntitiesInAttributesDOS() throws IOException { + void docdeclTextWithEntitiesInAttributesDOS() throws IOException { testDocdeclTextWithEntitiesInAttributes("test-entities-in-attr-DOS.xml"); } @@ -1254,7 +1255,7 @@ private void testDocdeclTextWithEntitiesInAttributes(String filename) throws IOE * @since 3.4.2 */ @Test - public void testEntityRefTextUnix() throws IOException { + void entityRefTextUnix() throws IOException { testEntityRefText("\n"); } @@ -1268,7 +1269,7 @@ public void testEntityRefTextUnix() throws IOException { * @since 3.4.2 */ @Test - public void testEntityRefTextDOS() throws IOException { + void entityRefTextDOS() throws IOException { testEntityRefText("\r\n"); } @@ -1282,45 +1283,45 @@ private void testEntityRefText(String newLine) throws IOException { 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); - } + Assertions.assertDoesNotThrow( + () -> { + 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()); + }, + "should not raise exception: "); } /** @@ -1333,36 +1334,36 @@ private void testEntityRefText(String newLine) throws IOException { * @since 3.4.2 */ @Test - public void testEntityReplacement() throws IOException { + void entityReplacement() throws IOException { String input = "

      

    "; - 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: "); } /** @@ -1376,50 +1377,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(), "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 { @@ -1439,7 +1440,7 @@ public void testUnicode() throws IOException { } @Test - public void testProcessingInstructionTokenizeBeforeFirstTag() throws Exception { + void processingInstructionTokenizeBeforeFirstTag() throws Exception { String input = "nnn"; MXParser parser = new MXParser(); @@ -1457,7 +1458,7 @@ public void testProcessingInstructionTokenizeBeforeFirstTag() throws Exception { } @Test - public void testProcessingInstructionTokenizeAfterXMLDeclAndBeforeFirstTag() throws Exception { + void processingInstructionTokenizeAfterXMLDeclAndBeforeFirstTag() throws Exception { String input = "nnn"; MXParser parser = new MXParser(); @@ -1478,7 +1479,7 @@ public void testProcessingInstructionTokenizeAfterXMLDeclAndBeforeFirstTag() thr @ParameterizedTest @ValueSource(strings = {" ", "\n", "\r", "\r\n", " ", "\n "}) - void testBlankAtBeginning(String ws) throws XmlPullParserException, IOException { + void blankAtBeginning(String ws) throws XmlPullParserException, IOException { String xml = "nnn"; MXParser parser = new MXParser(); 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..bc5f0267 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(); @@ -61,7 +61,7 @@ private String expectedOutput() { * 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 642e729f..e362c2ff 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 @@ -32,7 +32,7 @@ public class eduni_misc_Test_BjoernHoehrmannviaHST2013_09_18_Test { *

    setUp.

    */ @BeforeEach - public void setUp() { + void setUp() { parser = new MXParser(); } @@ -46,7 +46,7 @@ public void setUp() { * @throws java.io.IOException if there is an I/O error */ @Test - public void testhst_bh_001() throws IOException { + void testhst_bh_001() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "001.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -67,7 +67,7 @@ public void testhst_bh_001() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testhst_bh_002() throws IOException { + void testhst_bh_002() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "002.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -88,7 +88,7 @@ public void testhst_bh_002() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testhst_bh_003() throws IOException { + void testhst_bh_003() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "003.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -109,7 +109,7 @@ public void testhst_bh_003() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testhst_bh_004() throws IOException { + void testhst_bh_004() throws IOException { try (Reader reader = new FileReader(new File(testResourcesDir, "004.xml"))) { parser.setInput(reader); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -177,7 +177,7 @@ public void testhst_bh_006() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testhst_lhs_007() throws IOException { + void testhst_lhs_007() throws IOException { try (InputStream is = new FileInputStream(new File(testResourcesDir, "007.xml"))) { parser.setInput(is, null); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -198,7 +198,7 @@ public void testhst_lhs_007() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testhst_lhs_008() throws IOException { + void testhst_lhs_008() throws IOException { try (InputStream is = new FileInputStream(new File(testResourcesDir, "008.xml"))) { parser.setInput(is, null); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) @@ -219,7 +219,7 @@ public void testhst_lhs_008() throws IOException { * @throws java.io.IOException if there is an I/O error */ @Test - public void testhst_lhs_009() throws IOException { + void testhst_lhs_009() throws IOException { try (InputStream is = new FileInputStream(new File(testResourcesDir, "009.xml"))) { parser.setInput(is, null); while (parser.nextToken() != XmlPullParser.END_DOCUMENT) From bf0366425bfd7b637b29b30ca2ab203b6d619df2 Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Mon, 16 Dec 2024 00:25:31 +0100 Subject: [PATCH 63/74] Cleanup tests and drop dependency to plexus-utils --- pom.xml | 12 ++-- .../util/xml/PrettyPrintXMLWriterTest.java | 56 +++++++++---------- .../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 | 13 +++-- .../plexus/util/xml/XmlWriterUtilTest.java | 28 ++++------ .../codehaus/plexus/util/xml/Xpp3DomTest.java | 19 ++----- .../plexus/util/xml/pull/MXParserTest.java | 35 ++++++------ 9 files changed, 125 insertions(+), 99 deletions(-) create mode 100644 src/test/java/org/codehaus/plexus/util/xml/TestUtils.java diff --git a/pom.xml b/pom.xml index 3443aecb..f0fc7da3 100644 --- a/pom.xml +++ b/pom.xml @@ -49,6 +49,7 @@ limitations under the License. 17 + 1.37 2024-05-21T21:02:17Z @@ -67,24 +68,23 @@ 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 - org.codehaus.plexus - plexus-utils - 4.0.2 + org.junit.jupiter + junit-jupiter-params 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 00f40794..f26631d0 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/PrettyPrintXMLWriterTest.java @@ -26,7 +26,6 @@ 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; @@ -165,7 +164,7 @@ void testendElementAlreadyClosed() { } /** - * Issue #51: https://github.com/codehaus-plexus/plexus-utils/issues/51 Purpose: test if concatenation string + * Issue #51: Issue 51 Purpose: test if concatenation string * optimization bug is present. Target environment: Java 7 (u79 and u80 verified) running on Windows. Detection * strategy: Tries to build a big XML file (~750MB size) and with many nested tags to force the JVM to trigger the * concatenation string optimization bug that throws a NoSuchElementException when calling endElement() method. @@ -232,34 +231,29 @@ private String expectedResult(String lineSeparator) { } private String expectedResult(String lineIndenter, String lineSeparator) { - StringBuilder expected = new StringBuilder(); - - expected.append("").append(lineSeparator); - expected.append(StringUtils.repeat(lineIndenter, 1)).append("").append(lineSeparator); - expected.append(StringUtils.repeat(lineIndenter, 2)) - .append("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 + lineIndenter + + "" + lineSeparator + lineIndenter + + lineIndenter + "title" + + lineSeparator + + lineIndenter + + lineIndenter + "" + + lineSeparator + + lineIndenter + + lineIndenter + "" + + lineSeparator + + lineIndenter + + "" + lineSeparator + lineIndenter + + "" + lineSeparator + lineIndenter + + lineIndenter + "

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

    " + + lineSeparator + + lineIndenter + + lineIndenter + "
    " + + lineSeparator + + lineIndenter + + lineIndenter + lineIndenter + "

    Section title

    " + + lineSeparator + + 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 c87f9f70..0390ac2c 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 19b4027c..a7028d92 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 4805cd69..b5049f8a 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java @@ -25,10 +25,9 @@ import java.io.Writer; 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; @@ -116,18 +115,20 @@ void prettyFormatString() throws Exception { String content; try (Reader reader = new XmlStreamReader(testDocument)) { - content = IOUtil.toString(reader); + content = readAllFrom(reader); } - Writer writer = new StringWriter(); + String contentPretty; try (Reader reader = new XmlStreamReader(testDocument)) { + Writer writer = new StringWriter(); XmlUtil.prettyFormat(reader, 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)); } /** 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 d0b94f8e..2a8c54a2 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(), " ")); } /** @@ -211,7 +207,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(); @@ -253,7 +249,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(); @@ -291,7 +287,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(); @@ -339,7 +335,7 @@ void writeCommentTextXMLWriterStringInt() throws Exception { tearDown(); setUp(); - String indent = StringUtils.repeat(" ", 2 * 2); + String indent = " "; XmlWriterUtil.writeCommentText( xmlWriter, @@ -380,7 +376,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(); @@ -411,7 +407,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 828c6cda..9c3d85ff 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/Xpp3DomTest.java @@ -194,18 +194,11 @@ void shouldNotMergeValues() { @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()); } /** @@ -217,7 +210,7 @@ void equals() { assertEquals(dom, dom); assertNotEquals(null, dom); - assertNotEquals(dom, new Xpp3Dom("")); + assertNotEquals(new Xpp3Dom(""), 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 543f84ee..7a817b9e 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,13 +27,12 @@ import java.nio.file.Files; import java.nio.file.Paths; -import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.xml.XmlStreamReader; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; +import static org.codehaus.plexus.util.xml.TestUtils.readAllFrom; import static org.junit.jupiter.api.Assertions.*; /** @@ -222,7 +221,7 @@ void validCharacterReferenceHexa() throws Exception { " Ȁ퟿ᄁ�𐀀􏿽􏿿"; parser.setInput(new StringReader(input)); - Assertions.assertDoesNotThrow( + assertDoesNotThrow( () -> { assertEquals(XmlPullParser.START_TAG, parser.nextToken()); assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); @@ -286,7 +285,7 @@ void validCharacterReferenceDecimal() throws Exception { " Ȁ퟿ᄁ�𐀀􏿽􏿿"; parser.setInput(new StringReader(input)); - Assertions.assertDoesNotThrow( + assertDoesNotThrow( () -> { assertEquals(XmlPullParser.START_TAG, parser.nextToken()); assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); @@ -821,7 +820,7 @@ void xmlDeclVersionOnly() throws Exception { MXParser parser = new MXParser(); parser.setInput(new StringReader(input)); - Assertions.assertDoesNotThrow( + assertDoesNotThrow( () -> { assertEquals(XmlPullParser.PROCESSING_INSTRUCTION, parser.nextToken()); assertEquals(XmlPullParser.START_TAG, parser.nextToken()); @@ -850,7 +849,7 @@ void xmlDeclVersionEncodingStandaloneNoSpace() throws Exception { } /** - * Issue 163: https://github.com/codehaus-plexus/plexus-utils/issues/163 + * Issue 163: Issue 163 * * @throws IOException if IO error. * @@ -870,7 +869,7 @@ void encodingISO88591NewXmlReader() throws IOException { } /** - * Issue 163: https://github.com/codehaus-plexus/plexus-utils/issues/163 + * Issue 163: Issue 163 * * @throws IOException if IO error. * @@ -891,8 +890,8 @@ void encodingISO88591InputStream() throws IOException { } /** - * Issue 163: https://github.com/codehaus-plexus/plexus-utils/issues/163 - * + * Issue 163: Issue 163 + *

    * Another case of bug #163: File encoding information is lost after the input file is copied to a String. * * @throws IOException if IO error. @@ -903,10 +902,10 @@ void encodingISO88591InputStream() throws IOException { void encodingISO88591StringReader() throws IOException { String xmlFileContents; try (Reader reader = new XmlStreamReader(Paths.get("src/test/resources/xml", "test-encoding-ISO-8859-1.xml"))) { - xmlFileContents = IOUtil.toString(reader); + xmlFileContents = readAllFrom(reader); } - Assertions.assertDoesNotThrow( + assertDoesNotThrow( () -> { MXParser parser = new MXParser(); parser.setInput(new StringReader(xmlFileContents)); @@ -918,7 +917,7 @@ void encodingISO88591StringReader() throws IOException { } /** - * Issue 163: https://github.com/codehaus-plexus/plexus-utils/issues/163 + * Issue 163: Issue 163 * * Another case of bug #163: Reader generated with ReaderFactory.newReader and the right file encoding. * @@ -945,7 +944,7 @@ void encodingISO88591NewReader() throws IOException { } /** - * Issue 163: https://github.com/codehaus-plexus/plexus-utils/issues/163 + * Issue 163: Issue 163 * * Another case of bug #163: InputStream supplied with the right file encoding. * @@ -968,7 +967,7 @@ void encodingISO88591InputStreamEncoded() throws IOException { } /** - * Issue 163: https://github.com/codehaus-plexus/plexus-utils/issues/163 + * Issue 163: Issue 163 * * @throws IOException if IO error. * @@ -1044,7 +1043,7 @@ void customEntityNotFoundInTextTokenize() throws Exception { parser.setInput(new StringReader(input)); parser.defineEntityReplacementText("myentity", "replacement"); - Assertions.assertDoesNotThrow( + assertDoesNotThrow( () -> { assertEquals(XmlPullParser.START_TAG, parser.nextToken()); assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken()); @@ -1283,7 +1282,7 @@ private void testEntityRefText(String newLine) throws IOException { sb.append("]>").append(newLine); sb.append("&foo;&foo1;&foo2;&tritPos;"); - Assertions.assertDoesNotThrow( + assertDoesNotThrow( () -> { MXParser parser = new MXParser(); parser.setInput(new StringReader(sb.toString())); @@ -1337,7 +1336,7 @@ private void testEntityRefText(String newLine) throws IOException { void entityReplacement() throws IOException { String input = "

      

    "; - Assertions.assertDoesNotThrow( + assertDoesNotThrow( () -> { MXParser parser = new MXParser(); parser.setInput(new StringReader(input)); @@ -1381,7 +1380,7 @@ void replacementInPCArrayWithShorterCharArray() throws IOException { String input = "]>" + "

    &&foo;&tritPos;

    "; - Assertions.assertDoesNotThrow( + assertDoesNotThrow( () -> { MXParser parser = new MXParser(); parser.setInput(new StringReader(new String(input.getBytes(), "ISO-8859-1"))); From 1f1ff6f331bd98c326620b8a452657800edfa3a7 Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Wed, 25 Dec 2024 23:42:25 +0100 Subject: [PATCH 64/74] Upgrade to Maven 4.0.0-rc-2 --- README.md | 2 +- pom.xml | 4 ++-- src/site/markdown/index.md | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c7ea09d9..347452c4 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ This library consists of XML classes (`org.codehaus.plexus.util.xml` and `org.co this step is released as `plexus-xml` 3, maintained in [3.x branch](tree/3.x)\ [![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), -2. then updated to use Maven 4-specific [`maven-xml-api`](https://github.com/apache/maven/tree/maven-4.0.0-beta-5/api/maven-api-xml)/[`maven-xml-impl`](https://github.com/apache/maven/tree/maven-4.0.0-beta-5/maven-xml-impl):\ +2. then updated to use Maven 4-specific [`maven-xml-api`](https://github.com/apache/maven/tree/maven-4.0.0-rc-2/api/maven-api-xml)/[`maven-xml`](https://github.com/apache/maven/tree/maven-4.0.0-rc-2/maven-xml):\ this is the `master` branch from which `plexus-xml` 4 is released\ Version 4.x requires Java 17 (like Maven 4) [![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) diff --git a/pom.xml b/pom.xml index f0fc7da3..f690fa0d 100644 --- a/pom.xml +++ b/pom.xml @@ -56,8 +56,8 @@ limitations under the License. org.apache.maven - maven-xml-impl - 4.0.0-beta-5 + maven-xml + 4.0.0-rc-2 org.eclipse.sisu diff --git a/src/site/markdown/index.md b/src/site/markdown/index.md index 4e77c870..7ac1952f 100644 --- a/src/site/markdown/index.md +++ b/src/site/markdown/index.md @@ -4,5 +4,5 @@ A collection of various utility classes to ease working with XML. This library consists of XML classes (`org.codehaus.plexus.util.xml` and `org.codehaus.plexus.util.xml.pull`): 1. that have been extracted from [`plexus-utils`](../plexus-utils/) 4, -2. then updated to use [`maven-xml-api`](https://maven.apache.org/ref/4.0.0-beta-5/api/maven-api-xml/)/[`maven-xml-impl`](https://maven.apache.org/ref/4.0.0-beta-5/maven-xml-impl/index.html) +2. then updated to use [`maven-xml-api`](https://maven.apache.org/ref/4.0.0-rc-2/api/maven-api-xml/)/[`maven-xml`](https://maven.apache.org/ref/4.0.0-rc-2/maven-xml/index.html) From 26b97493136bf30d34b9f14c2a97e933b0f59ae5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Feb 2025 15:40:28 +0000 Subject: [PATCH 65/74] 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 f690fa0d..84dcafba 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ limitations under the License. org.codehaus.plexus plexus - 19 + 20 plexus-xml From 2b85a28dbadeb283cff8a63e21d5555165385f81 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Mar 2025 16:31:22 +0000 Subject: [PATCH 66/74] Bump org.apache.maven:maven-xml from 4.0.0-rc-2 to 4.0.0-rc-3 Bumps [org.apache.maven:maven-xml](https://github.com/apache/maven) from 4.0.0-rc-2 to 4.0.0-rc-3. - [Release notes](https://github.com/apache/maven/releases) - [Commits](https://github.com/apache/maven/compare/maven-4.0.0-rc-2...maven-4.0.0-rc-3) --- updated-dependencies: - dependency-name: org.apache.maven:maven-xml dependency-type: direct:production 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 84dcafba..5f3a0d20 100644 --- a/pom.xml +++ b/pom.xml @@ -57,7 +57,7 @@ limitations under the License. org.apache.maven maven-xml - 4.0.0-rc-2 + 4.0.0-rc-3 org.eclipse.sisu From fd8cf37adbf40c49b5a14870385275ff61dc6059 Mon Sep 17 00:00:00 2001 From: Gerd Aschemann Date: Fri, 14 Mar 2025 14:39:01 +0100 Subject: [PATCH 67/74] Apply spotless re-formatting Detected in the course of support-and-care/maven-support-and-care#77. --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 347452c4..d72d9e96 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ 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) @@ -22,3 +22,4 @@ For publishing [the site](https://codehaus-plexus.github.io/plexus-xml/) do the ``` mvn -Preporting verify site site:stage scm-publish:publish-scm ``` + From 9f89131f53747476234b285cfbd6c351aa57f1f9 Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Sat, 5 Apr 2025 18:07:03 +0200 Subject: [PATCH 68/74] [maven-release-plugin] prepare release plexus-xml-4.1.0 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 5f3a0d20..ca7b61fe 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ limitations under the License. plexus-xml - 4.1.0-SNAPSHOT + 4.1.0 Plexus XML Utilities A collection of various utility classes to ease working with XML. @@ -33,7 +33,7 @@ limitations under the License. scm:git:https://github.com/codehaus-plexus/plexus-xml.git ${project.scm.connection} - master + plexus-xml-4.1.0 https://github.com/codehaus-plexus/plexus-xml/tree/${project.scm.tag}/ @@ -50,7 +50,7 @@ limitations under the License. 17 1.37 - 2024-05-21T21:02:17Z + 2025-04-05T16:06:58Z From 924660bae07dcc8ec0df3e9b60e1ba7b18855cd1 Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Sat, 5 Apr 2025 18:07:06 +0200 Subject: [PATCH 69/74] [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 ca7b61fe..cc110dee 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ limitations under the License. plexus-xml - 4.1.0 + 4.1.1-SNAPSHOT Plexus XML Utilities A collection of various utility classes to ease working with XML. @@ -33,7 +33,7 @@ limitations under the License. scm:git:https://github.com/codehaus-plexus/plexus-xml.git ${project.scm.connection} - plexus-xml-4.1.0 + master https://github.com/codehaus-plexus/plexus-xml/tree/${project.scm.tag}/ @@ -50,7 +50,7 @@ limitations under the License. 17 1.37 - 2025-04-05T16:06:58Z + 2025-04-05T16:07:06Z From 1407ddc87ba515e35fc948535d87884e95ac909b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 May 2025 16:07:03 +0000 Subject: [PATCH 70/74] Bump org.codehaus.plexus:plexus from 20 to 21 Bumps [org.codehaus.plexus:plexus](https://github.com/codehaus-plexus/plexus-pom) from 20 to 21. - [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: '21' 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 cc110dee..19a15967 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ limitations under the License. org.codehaus.plexus plexus - 20 + 21 plexus-xml From 9434226f83ea3a9091e6b5ef6a3fe87c881d2841 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Jun 2025 15:28:39 +0000 Subject: [PATCH 71/74] Bump org.codehaus.plexus:plexus from 21 to 22 Bumps [org.codehaus.plexus:plexus](https://github.com/codehaus-plexus/plexus-pom) from 21 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] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 19a15967..df91a920 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ limitations under the License. org.codehaus.plexus plexus - 21 + 22 plexus-xml From bad0a2b466b0700a88b21be80f9c673af32a3606 Mon Sep 17 00:00:00 2001 From: Goooler Date: Tue, 3 Jun 2025 17:30:50 +0800 Subject: [PATCH 72/74] Declare license info in POM --- pom.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pom.xml b/pom.xml index df91a920..a18a5a55 100644 --- a/pom.xml +++ b/pom.xml @@ -30,6 +30,14 @@ limitations under the License. A collection of various utility classes to ease working with XML. https://codehaus-plexus.github.io/plexus-xml/ + + + Apache-2.0 + https://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + scm:git:https://github.com/codehaus-plexus/plexus-xml.git ${project.scm.connection} From c6b2c7ae97bc97934a935e9bbb504ffb3bc8585f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 25 Jun 2025 15:19:57 +0000 Subject: [PATCH 73/74] Bump org.apache.maven:maven-xml from 4.0.0-rc-3 to 4.0.0-rc-4 Bumps [org.apache.maven:maven-xml](https://github.com/apache/maven) from 4.0.0-rc-3 to 4.0.0-rc-4. - [Release notes](https://github.com/apache/maven/releases) - [Commits](https://github.com/apache/maven/compare/maven-4.0.0-rc-3...maven-4.0.0-rc-4) --- updated-dependencies: - dependency-name: org.apache.maven:maven-xml dependency-version: 4.0.0-rc-4 dependency-type: direct:production 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 a18a5a55..85e802f4 100644 --- a/pom.xml +++ b/pom.xml @@ -65,7 +65,7 @@ limitations under the License. org.apache.maven maven-xml - 4.0.0-rc-3 + 4.0.0-rc-4 org.eclipse.sisu From 2294db68a1035d15a4e9a3ba86f73b28a774a1ad Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Aug 2025 21:19:43 +0000 Subject: [PATCH 74/74] 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 85e802f4..90efae8a 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ limitations under the License. org.codehaus.plexus plexus - 22 + 23 plexus-xml