1616 */
1717package org .apache .commons .io .input ;
1818
19+ import static org .junit .Assert .assertEquals ;
20+ import static org .junit .Assert .assertTrue ;
21+ import static org .junit .Assert .fail ;
22+
1923import java .io .ByteArrayInputStream ;
2024import java .io .ByteArrayOutputStream ;
2125import java .io .IOException ;
2630import java .util .HashMap ;
2731import java .util .Map ;
2832
29- import junit .framework .TestCase ;
30-
3133import org .apache .commons .io .IOUtils ;
34+ import org .junit .Ignore ;
35+ import org .junit .Test ;
3236
3337/**
3438 */
35- public class XmlStreamReaderTest extends TestCase {
39+ public class XmlStreamReaderTest {
3640 private static final String XML5 = "xml-prolog-encoding-spaced-single-quotes" ;
3741 private static final String XML4 = "xml-prolog-encoding-single-quotes" ;
3842 private static final String XML3 = "xml-prolog-encoding-double-quotes" ;
@@ -71,14 +75,45 @@ protected void _testRawNoBomInvalid(String encoding) throws Exception {
7175 }
7276 }
7377
74- public void testRawNoBom () throws Exception {
78+ @ Test
79+ public void testRawNoBomUsAscii () throws Exception {
7580 _testRawNoBomValid ("US-ASCII" );
81+ }
82+
83+ @ Test
84+ public void testRawNoBomUtf8 () throws Exception {
7685 _testRawNoBomValid ("UTF-8" );
86+ }
87+
88+ @ Test
89+ public void testRawNoBomUtf16BE () throws Exception {
7790 _testRawNoBomValid ("UTF-16BE" );
91+ }
92+
93+ @ Test
94+ public void testRawNoBomUtf16LE () throws Exception {
7895 _testRawNoBomValid ("UTF-16LE" );
79- //_testRawNoBomValid("UTF-32BE");
80- //_testRawNoBomValid("UTF-32LE");
96+ }
97+
98+ @ Test
99+ @ Ignore
100+ public void testRawNoBomUtf32BE () throws Exception {
101+ _testRawNoBomValid ("UTF-32BE" );
102+ }
103+
104+ @ Test
105+ @ Ignore
106+ public void testRawNoBomUtf32LE () throws Exception {
107+ _testRawNoBomValid ("UTF-32LE" );
108+ }
109+
110+ @ Test
111+ public void testRawNoBomIso8859_1 () throws Exception {
81112 _testRawNoBomValid ("ISO-8859-1" );
113+ }
114+
115+ @ Test
116+ public void testRawNoBomCp1047 () throws Exception {
82117 _testRawNoBomValid ("CP1047" );
83118 }
84119
@@ -108,14 +143,9 @@ protected void _testRawBomInvalid(String bomEnc, String streamEnc,
108143 }
109144 }
110145
111- public void testRawBom () throws Exception {
146+ @ Test
147+ public void testRawBomUtf8 () throws Exception {
112148 _testRawBomValid ("UTF-8" );
113- _testRawBomValid ("UTF-16BE" );
114- _testRawBomValid ("UTF-16LE" );
115- //_testRawBomValid("UTF-32BE");
116- //_testRawBomValid("UTF-32LE");
117- _testRawBomValid ("UTF-16" );
118-
119149 _testRawBomInvalid ("UTF-8-bom" , "US-ASCII" , "US-ASCII" );
120150 _testRawBomInvalid ("UTF-8-bom" , "ISO-8859-1" , "ISO-8859-1" );
121151 _testRawBomInvalid ("UTF-8-bom" , "UTF-8" , "UTF-16" );
@@ -126,6 +156,27 @@ public void testRawBom() throws Exception {
126156 _testRawBomInvalid ("UTF-16LE-bom" , "UTF-16LE" , "UTF-8" );
127157 }
128158
159+ @ Test
160+ public void testRawBomUtf16 () throws Exception {
161+ _testRawBomValid ("UTF-16BE" );
162+ _testRawBomValid ("UTF-16LE" );
163+ _testRawBomValid ("UTF-16" );
164+
165+ _testRawBomInvalid ("UTF-16BE-bom" , "UTF-16BE" , "UTF-16LE" );
166+ _testRawBomInvalid ("UTF-16LE-bom" , "UTF-16LE" , "UTF-16BE" );
167+ _testRawBomInvalid ("UTF-16LE-bom" , "UTF-16LE" , "UTF-8" );
168+ }
169+
170+ @ Ignore
171+ @ Test
172+ public void testRawBomUtf32 () throws Exception {
173+ _testRawBomValid ("UTF-32BE" );
174+ _testRawBomValid ("UTF-32LE" );
175+ _testRawBomValid ("UTF-32" );
176+ }
177+
178+
179+ @ Test
129180 public void testHttp () throws Exception {
130181 // niallp 2010-10-06 - remove following 2 tests - I reinstated
131182 // checks for non-UTF-16 encodings (18 tests) and these failed
@@ -226,8 +277,8 @@ public void testHttp() throws Exception {
226277 _testHttpLenient ("text/html;charset=UTF-16BE" , "no-bom" , "US-ASCII" ,
227278 "UTF-8" , "UTF-8" );
228279 }
229-
230280
281+ @ Test
231282 public void testRawContent () throws Exception {
232283 String encoding = "UTF-8" ;
233284 String xml = getXML ("no-bom" , XML3 , encoding , encoding );
@@ -237,6 +288,7 @@ public void testRawContent() throws Exception {
237288 assertEquals ("Check content" , xml , IOUtils .toString (xmlReader ));
238289 }
239290
291+ @ Test
240292 public void testHttpContent () throws Exception {
241293 String encoding = "UTF-8" ;
242294 String xml = getXML ("no-bom" , XML3 , encoding , encoding );
@@ -310,6 +362,7 @@ protected void _testHttpLenient(String cT, String bomEnc, String streamEnc,
310362 + " <atom:title encoding='base64'><![CDATA\n "
311363 + "aW5nTGluZSIgLz4" ;
312364
365+ @ Test
313366 public void testEncodingAttributeXML () throws Exception {
314367 InputStream is = new ByteArrayInputStream (ENCODING_ATTRIBUTE_XML
315368 .getBytes ("UTF-8" ));
0 commit comments