|
21 | 21 | import static org.junit.Assert.fail;
|
22 | 22 |
|
23 | 23 | import java.io.EOFException;
|
| 24 | +import java.io.File; |
24 | 25 | import java.io.IOException;
|
| 26 | +import java.io.InputStream; |
| 27 | +import java.io.Reader; |
25 | 28 | import java.io.StringReader;
|
| 29 | +import java.nio.file.Files; |
| 30 | +import java.nio.file.Paths; |
26 | 31 |
|
| 32 | +import org.codehaus.plexus.util.ReaderFactory; |
27 | 33 | import org.junit.Test;
|
28 | 34 |
|
29 | 35 | /**
|
@@ -840,4 +846,56 @@ public void testXMLDeclVersionEncodingStandaloneNoSpace()
|
840 | 846 | }
|
841 | 847 | }
|
842 | 848 |
|
| 849 | + /** |
| 850 | + * Issue 163: https://github.com/codehaus-plexus/plexus-utils/issues/163 |
| 851 | + * |
| 852 | + * @throws IOException if IO error. |
| 853 | + * |
| 854 | + * @since 3.4.1 |
| 855 | + */ |
| 856 | + @Test |
| 857 | + public void testEncodingISO_8859_1setInputReader() |
| 858 | + throws IOException |
| 859 | + { |
| 860 | + try ( Reader reader = |
| 861 | + ReaderFactory.newXmlReader( new File( "src/test/resources/xml", "test-encoding-ISO-8859-1.xml" ) ) ) |
| 862 | + { |
| 863 | + MXParser parser = new MXParser(); |
| 864 | + parser.setInput( reader ); |
| 865 | + while ( parser.nextToken() != XmlPullParser.END_DOCUMENT ) |
| 866 | + ; |
| 867 | + assertTrue( true ); |
| 868 | + } |
| 869 | + catch ( XmlPullParserException e ) |
| 870 | + { |
| 871 | + fail( "should not raise exception: " + e ); |
| 872 | + } |
| 873 | + } |
| 874 | + |
| 875 | + /** |
| 876 | + * Issue 163: https://github.com/codehaus-plexus/plexus-utils/issues/163 |
| 877 | + * |
| 878 | + * @throws IOException if IO error. |
| 879 | + * |
| 880 | + * @since 3.4.1 |
| 881 | + */ |
| 882 | + @Test |
| 883 | + public void testEncodingISO_8859_1_setInputStream() |
| 884 | + throws IOException |
| 885 | + { |
| 886 | + try ( InputStream input = |
| 887 | + Files.newInputStream( Paths.get( "src/test/resources/xml", "test-encoding-ISO-8859-1.xml" ) ) ) |
| 888 | + { |
| 889 | + MXParser parser = new MXParser(); |
| 890 | + parser.setInput( input, null ); |
| 891 | + while ( parser.nextToken() != XmlPullParser.END_DOCUMENT ) |
| 892 | + ; |
| 893 | + assertTrue( true ); |
| 894 | + } |
| 895 | + catch ( XmlPullParserException e ) |
| 896 | + { |
| 897 | + fail( "should not raise exception: " + e ); |
| 898 | + } |
| 899 | + } |
| 900 | + |
843 | 901 | }
|
0 commit comments