|
| 1 | +package org.codehaus.plexus.util.xml.pull; |
| 2 | + |
| 3 | +import static org.junit.Assert.assertTrue; |
| 4 | +import static org.junit.Assert.fail; |
| 5 | + |
| 6 | +import java.io.File; |
| 7 | +import java.io.FileReader; |
| 8 | +import java.io.IOException; |
| 9 | +import java.io.Reader; |
| 10 | + |
| 11 | +import org.junit.Before; |
| 12 | +import org.junit.Test; |
| 13 | + |
| 14 | +/** |
| 15 | + * Test class that execute a particular set of tests associated to a TESCASES tag from the XML W3C Conformance Tests. |
| 16 | + * TESCASES PROFILE: <pre>IBM XML Conformance Test Suite - Production 32</pre> |
| 17 | + * XML test files base folder: <pre>xmlconf/ibm/</pre> |
| 18 | + * |
| 19 | + * @author <a href="mailto:[email protected]">Gabriel Belingueres</a> |
| 20 | + */ |
| 21 | +public class IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production32_Test |
| 22 | +{ |
| 23 | + |
| 24 | + final static File testResourcesDir = new File( "src/test/resources/", "xmlconf/ibm/" ); |
| 25 | + |
| 26 | + MXParser parser; |
| 27 | + |
| 28 | + @Before |
| 29 | + public void setUp() |
| 30 | + { |
| 31 | + parser = new MXParser(); |
| 32 | + } |
| 33 | + |
| 34 | + /** |
| 35 | + * Test ID: <pre>ibm-not-wf-P32-ibm32n01.xml</pre> |
| 36 | + * Test URI: <pre>not-wf/P32/ibm32n01.xml</pre> |
| 37 | + * Comment: <pre>Tests SDDecl with a required field missing. The leading white space is missing with the SDDecl in the XMLDecl.</pre> |
| 38 | + * Sections: <pre>2.9</pre> |
| 39 | + * Version: |
| 40 | + * |
| 41 | + * @throws IOException if there is an I/O error |
| 42 | + */ |
| 43 | + @Test |
| 44 | + public void testibm_not_wf_P32_ibm32n01xml() |
| 45 | + throws IOException |
| 46 | + { |
| 47 | + try ( Reader reader = new FileReader( new File( testResourcesDir, "not-wf/P32/ibm32n01.xml" ) ) ) |
| 48 | + { |
| 49 | + parser.setInput( reader ); |
| 50 | + while ( parser.nextToken() != XmlPullParser.END_DOCUMENT ) |
| 51 | + ; |
| 52 | + fail( "Tests SDDecl with a required field missing. The leading white space is missing with the SDDecl in the XMLDecl." ); |
| 53 | + } |
| 54 | + catch ( XmlPullParserException e ) |
| 55 | + { |
| 56 | + assertTrue( e.getMessage().contains( "expected ?> as last part of <?xml not t" ) ); |
| 57 | + } |
| 58 | + } |
| 59 | + |
| 60 | + /** |
| 61 | + * Test ID: <pre>ibm-not-wf-P32-ibm32n02.xml</pre> |
| 62 | + * Test URI: <pre>not-wf/P32/ibm32n02.xml</pre> |
| 63 | + * Comment: <pre>Tests SDDecl with a required field missing. The "=" sign is missing in the SDDecl in the XMLDecl.</pre> |
| 64 | + * Sections: <pre>2.9</pre> |
| 65 | + * Version: |
| 66 | + * |
| 67 | + * @throws IOException if there is an I/O error |
| 68 | + */ |
| 69 | + @Test |
| 70 | + public void testibm_not_wf_P32_ibm32n02xml() |
| 71 | + throws IOException |
| 72 | + { |
| 73 | + try ( Reader reader = new FileReader( new File( testResourcesDir, "not-wf/P32/ibm32n02.xml" ) ) ) |
| 74 | + { |
| 75 | + parser.setInput( reader ); |
| 76 | + while ( parser.nextToken() != XmlPullParser.END_DOCUMENT ) |
| 77 | + ; |
| 78 | + fail( "Tests SDDecl with a required field missing. The \"=\" sign is missing in the SDDecl in the XMLDecl." ); |
| 79 | + } |
| 80 | + catch ( XmlPullParserException e ) |
| 81 | + { |
| 82 | + assertTrue( e.getMessage().contains( "expected ?> as last part of <?xml not t" ) ); |
| 83 | + } |
| 84 | + } |
| 85 | + |
| 86 | + /** |
| 87 | + * Test ID: <pre>ibm-not-wf-P32-ibm32n03.xml</pre> |
| 88 | + * Test URI: <pre>not-wf/P32/ibm32n03.xml</pre> |
| 89 | + * Comment: <pre>Tests SDDecl with wrong key word. The word "Standalone" occurs in the SDDecl in the XMLDecl.</pre> |
| 90 | + * Sections: <pre>2.9</pre> |
| 91 | + * Version: |
| 92 | + * |
| 93 | + * @throws IOException if there is an I/O error |
| 94 | + */ |
| 95 | + @Test |
| 96 | + public void testibm_not_wf_P32_ibm32n03xml() |
| 97 | + throws IOException |
| 98 | + { |
| 99 | + try ( Reader reader = new FileReader( new File( testResourcesDir, "not-wf/P32/ibm32n03.xml" ) ) ) |
| 100 | + { |
| 101 | + parser.setInput( reader ); |
| 102 | + while ( parser.nextToken() != XmlPullParser.END_DOCUMENT ) |
| 103 | + ; |
| 104 | + fail( "Tests SDDecl with wrong key word. The word \"Standalone\" occurs in the SDDecl in the XMLDecl." ); |
| 105 | + } |
| 106 | + catch ( XmlPullParserException e ) |
| 107 | + { |
| 108 | + assertTrue( e.getMessage().contains( "expected ?> as last part of <?xml not t" ) ); |
| 109 | + } |
| 110 | + } |
| 111 | + |
| 112 | + /** |
| 113 | + * Test ID: <pre>ibm-not-wf-P32-ibm32n04.xml</pre> |
| 114 | + * Test URI: <pre>not-wf/P32/ibm32n04.xml</pre> |
| 115 | + * Comment: <pre>Tests SDDecl with wrong key word. The word "Yes" occurs in the SDDecl in the XMLDecl.</pre> |
| 116 | + * Sections: <pre>2.9</pre> |
| 117 | + * Version: |
| 118 | + * |
| 119 | + * @throws IOException if there is an I/O error |
| 120 | + */ |
| 121 | + @Test |
| 122 | + public void testibm_not_wf_P32_ibm32n04xml() |
| 123 | + throws IOException |
| 124 | + { |
| 125 | + try ( Reader reader = new FileReader( new File( testResourcesDir, "not-wf/P32/ibm32n04.xml" ) ) ) |
| 126 | + { |
| 127 | + parser.setInput( reader ); |
| 128 | + while ( parser.nextToken() != XmlPullParser.END_DOCUMENT ) |
| 129 | + ; |
| 130 | + fail( "Tests SDDecl with wrong key word. The word \"Yes\" occurs in the SDDecl in the XMLDecl." ); |
| 131 | + } |
| 132 | + catch ( XmlPullParserException e ) |
| 133 | + { |
| 134 | + assertTrue( e.getMessage().contains( "expected ?> as last part of <?xml not t" ) ); |
| 135 | + } |
| 136 | + } |
| 137 | + |
| 138 | + /** |
| 139 | + * Test ID: <pre>ibm-not-wf-P32-ibm32n05.xml</pre> |
| 140 | + * Test URI: <pre>not-wf/P32/ibm32n05.xml</pre> |
| 141 | + * Comment: <pre>Tests SDDecl with wrong key word. The word "YES" occurs in the SDDecl in the XMLDecl.</pre> |
| 142 | + * Sections: <pre>2.9</pre> |
| 143 | + * Version: |
| 144 | + * |
| 145 | + * @throws IOException if there is an I/O error |
| 146 | + */ |
| 147 | + @Test |
| 148 | + public void testibm_not_wf_P32_ibm32n05xml() |
| 149 | + throws IOException |
| 150 | + { |
| 151 | + |
| 152 | + try ( Reader reader = new FileReader( new File( testResourcesDir, "not-wf/P32/ibm32n05.xml" ) ) ) |
| 153 | + { |
| 154 | + parser.setInput( reader ); |
| 155 | + while ( parser.nextToken() != XmlPullParser.END_DOCUMENT ) |
| 156 | + ; |
| 157 | + fail( "Tests SDDecl with wrong key word. The word \"YES\" occurs in the SDDecl in the XMLDecl." ); |
| 158 | + } |
| 159 | + catch ( XmlPullParserException e ) |
| 160 | + { |
| 161 | + assertTrue( e.getMessage().contains( "expected ?> as last part of <?xml not t" ) ); |
| 162 | + } |
| 163 | + } |
| 164 | + |
| 165 | + /** |
| 166 | + * Test ID: <pre>ibm-not-wf-P32-ibm32n06.xml</pre> |
| 167 | + * Test URI: <pre>not-wf/P32/ibm32n06.xml</pre> |
| 168 | + * Comment: <pre>Tests SDDecl with wrong key word. The word "No" occurs in the SDDecl in the XMLDecl.</pre> |
| 169 | + * Sections: <pre>2.9</pre> |
| 170 | + * Version: |
| 171 | + * |
| 172 | + * @throws IOException if there is an I/O error |
| 173 | + */ |
| 174 | + @Test |
| 175 | + public void testibm_not_wf_P32_ibm32n06xml() |
| 176 | + throws IOException |
| 177 | + { |
| 178 | + try ( Reader reader = new FileReader( new File( testResourcesDir, "not-wf/P32/ibm32n06.xml" ) ) ) |
| 179 | + { |
| 180 | + parser.setInput( reader ); |
| 181 | + while ( parser.nextToken() != XmlPullParser.END_DOCUMENT ) |
| 182 | + ; |
| 183 | + fail( "Tests SDDecl with wrong key word. The word \"No\" occurs in the SDDecl in the XMLDecl." ); |
| 184 | + } |
| 185 | + catch ( XmlPullParserException e ) |
| 186 | + { |
| 187 | + assertTrue( e.getMessage().contains( "expected ?> as last part of <?xml not t" ) ); |
| 188 | + } |
| 189 | + } |
| 190 | + |
| 191 | + /** |
| 192 | + * Test ID: <pre>ibm-not-wf-P32-ibm32n07.xml</pre> |
| 193 | + * Test URI: <pre>not-wf/P32/ibm32n07.xml</pre> |
| 194 | + * Comment: <pre>Tests SDDecl with wrong key word. The word "NO" occurs in the SDDecl in the XMLDecl.</pre> |
| 195 | + * Sections: <pre>2.9</pre> |
| 196 | + * Version: |
| 197 | + * |
| 198 | + * @throws IOException if there is an I/O error |
| 199 | + */ |
| 200 | + @Test |
| 201 | + public void testibm_not_wf_P32_ibm32n07xml() |
| 202 | + throws IOException |
| 203 | + { |
| 204 | + try ( Reader reader = new FileReader( new File( testResourcesDir, "not-wf/P32/ibm32n07.xml" ) ) ) |
| 205 | + { |
| 206 | + parser.setInput( reader ); |
| 207 | + while ( parser.nextToken() != XmlPullParser.END_DOCUMENT ) |
| 208 | + ; |
| 209 | + fail( "Tests SDDecl with wrong key word. The word \"NO\" occurs in the SDDecl in the XMLDecl." ); |
| 210 | + } |
| 211 | + catch ( XmlPullParserException e ) |
| 212 | + { |
| 213 | + assertTrue( e.getMessage().contains( "expected ?> as last part of <?xml not t" ) ); |
| 214 | + } |
| 215 | + } |
| 216 | + |
| 217 | + /** |
| 218 | + * Test ID: <pre>ibm-not-wf-P32-ibm32n08.xml</pre> |
| 219 | + * Test URI: <pre>not-wf/P32/ibm32n08.xml</pre> |
| 220 | + * Comment: <pre>Tests SDDecl with wrong field ordering. The "=" sign occurs after the key word "yes" in the SDDecl in the XMLDecl.</pre> |
| 221 | + * Sections: <pre>2.9</pre> |
| 222 | + * Version: |
| 223 | + * |
| 224 | + * @throws IOException if there is an I/O error |
| 225 | + */ |
| 226 | + @Test |
| 227 | + public void testibm_not_wf_P32_ibm32n08xml() |
| 228 | + throws IOException |
| 229 | + { |
| 230 | + try ( Reader reader = new FileReader( new File( testResourcesDir, "not-wf/P32/ibm32n08.xml" ) ) ) |
| 231 | + { |
| 232 | + parser.setInput( reader ); |
| 233 | + while ( parser.nextToken() != XmlPullParser.END_DOCUMENT ) |
| 234 | + ; |
| 235 | + fail( "Tests SDDecl with wrong field ordering. The \"=\" sign occurs after the key word \"yes\" in the SDDecl in the XMLDecl." ); |
| 236 | + } |
| 237 | + catch ( XmlPullParserException e ) |
| 238 | + { |
| 239 | + assertTrue( e.getMessage().contains( "expected ?> as last part of <?xml not t" ) ); |
| 240 | + } |
| 241 | + } |
| 242 | + |
| 243 | + /** |
| 244 | + * Test ID: <pre>ibm-not-wf-P32-ibm32n09.xml</pre> |
| 245 | + * Test URI: <pre>not-wf/P32/ibm32n09.xml</pre> |
| 246 | + * Comment: <pre>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.</pre> |
| 247 | + * Sections: <pre>2.9</pre> |
| 248 | + * Version: |
| 249 | + * |
| 250 | + * @throws IOException if there is an I/O error |
| 251 | + */ |
| 252 | + @Test |
| 253 | + public void testibm_not_wf_P32_ibm32n09xml() |
| 254 | + throws IOException |
| 255 | + { |
| 256 | + try ( Reader reader = new FileReader( new File( testResourcesDir, "not-wf/P32/ibm32n09.xml" ) ) ) |
| 257 | + { |
| 258 | + parser.setInput( reader ); |
| 259 | + while ( parser.nextToken() != XmlPullParser.END_DOCUMENT ) |
| 260 | + ; |
| 261 | + 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." ); |
| 262 | + } |
| 263 | + catch ( XmlPullParserException e ) |
| 264 | + { |
| 265 | + assertTrue( e.getMessage().contains( "expected ?> as last part of <?xml not t" ) ); |
| 266 | + } |
| 267 | + } |
| 268 | + |
| 269 | +} |
0 commit comments