|
| 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 80</pre> |
| 17 | + * XML test files base folder: <pre>xmlconf/ibm/</pre> |
| 18 | + * |
| 19 | + * @author <a href="mailto:belingueres@gmail.com">Gabriel Belingueres</a> |
| 20 | + */ |
| 21 | +public class IBMXML10Tests_Test_IBMXMLConformanceTestSuite_not_wftests_Test_IBMXMLConformanceTestSuite_Production80_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-P80-ibm80n01.xml</pre> |
| 36 | + * Test URI: <pre>not-wf/P80/ibm80n01.xml</pre> |
| 37 | + * Comment: <pre>Tests EncodingDecl with a required field missing. The leading white space is missing in the EncodingDecl in the XMLDecl.</pre> |
| 38 | + * Sections: <pre>4.3.3</pre> |
| 39 | + * Version: |
| 40 | + * |
| 41 | + * @throws IOException if there is an I/O error |
| 42 | + */ |
| 43 | + @Test |
| 44 | + public void testibm_not_wf_P80_ibm80n01xml() |
| 45 | + throws IOException |
| 46 | + { |
| 47 | + try ( Reader reader = new FileReader( new File( testResourcesDir, "not-wf/P80/ibm80n01.xml" ) ) ) |
| 48 | + { |
| 49 | + parser.setInput( reader ); |
| 50 | + while ( parser.nextToken() != XmlPullParser.END_DOCUMENT ) |
| 51 | + ; |
| 52 | + fail( "Tests EncodingDecl with a required field missing. The leading white space is missing in the EncodingDecl in the XMLDecl." ); |
| 53 | + } |
| 54 | + catch ( XmlPullParserException e ) |
| 55 | + { |
| 56 | + assertTrue( e.getMessage().contains( "expected a space after version and not e" ) ); |
| 57 | + } |
| 58 | + } |
| 59 | + |
| 60 | + /** |
| 61 | + * Test ID: <pre>ibm-not-wf-P80-ibm80n02.xml</pre> |
| 62 | + * Test URI: <pre>not-wf/P80/ibm80n02.xml</pre> |
| 63 | + * Comment: <pre>Tests EncodingDecl with a required field missing. The "=" sign is missing in the EncodingDecl in the XMLDecl.</pre> |
| 64 | + * Sections: <pre>4.3.3</pre> |
| 65 | + * Version: |
| 66 | + * |
| 67 | + * @throws IOException if there is an I/O error |
| 68 | + */ |
| 69 | + @Test |
| 70 | + public void testibm_not_wf_P80_ibm80n02xml() |
| 71 | + throws IOException |
| 72 | + { |
| 73 | + try ( Reader reader = new FileReader( new File( testResourcesDir, "not-wf/P80/ibm80n02.xml" ) ) ) |
| 74 | + { |
| 75 | + parser.setInput( reader ); |
| 76 | + while ( parser.nextToken() != XmlPullParser.END_DOCUMENT ) |
| 77 | + ; |
| 78 | + fail( "Tests EncodingDecl with a required field missing. The \"=\" sign is missing in the EncodingDecl in the XMLDecl." ); |
| 79 | + } |
| 80 | + catch ( XmlPullParserException e ) |
| 81 | + { |
| 82 | + assertTrue( e.getMessage().contains( "expected equals sign (=) after encoding and not \"" ) ); |
| 83 | + } |
| 84 | + } |
| 85 | + |
| 86 | + /** |
| 87 | + * Test ID: <pre>ibm-not-wf-P80-ibm80n03.xml</pre> |
| 88 | + * Test URI: <pre>not-wf/P80/ibm80n03.xml</pre> |
| 89 | + * Comment: <pre>Tests EncodingDecl with a required field missing. The double quoted EncName are missing in the EncodingDecl in the XMLDecl.</pre> |
| 90 | + * Sections: <pre>4.3.3</pre> |
| 91 | + * Version: |
| 92 | + * |
| 93 | + * @throws IOException if there is an I/O error |
| 94 | + */ |
| 95 | + @Test |
| 96 | + public void testibm_not_wf_P80_ibm80n03xml() |
| 97 | + throws IOException |
| 98 | + { |
| 99 | + try ( Reader reader = new FileReader( new File( testResourcesDir, "not-wf/P80/ibm80n03.xml" ) ) ) |
| 100 | + { |
| 101 | + parser.setInput( reader ); |
| 102 | + while ( parser.nextToken() != XmlPullParser.END_DOCUMENT ) |
| 103 | + ; |
| 104 | + fail( "Tests EncodingDecl with a required field missing. The double quoted EncName are missing in the EncodingDecl in the XMLDecl." ); |
| 105 | + } |
| 106 | + catch ( XmlPullParserException e ) |
| 107 | + { |
| 108 | + assertTrue( e.getMessage().contains( "expected apostrophe (') or quotation mark (\") after encoding and not ?" ) ); |
| 109 | + } |
| 110 | + } |
| 111 | + |
| 112 | + /** |
| 113 | + * Test ID: <pre>ibm-not-wf-P80-ibm80n04.xml</pre> |
| 114 | + * Test URI: <pre>not-wf/P80/ibm80n04.xml</pre> |
| 115 | + * Comment: <pre>Tests EncodingDecl with wrong field ordering. The string "encoding=" occurs after the double quoted EncName in the EncodingDecl in the XMLDecl.</pre> |
| 116 | + * Sections: <pre>4.3.3</pre> |
| 117 | + * Version: |
| 118 | + * |
| 119 | + * @throws IOException if there is an I/O error |
| 120 | + */ |
| 121 | + @Test |
| 122 | + public void testibm_not_wf_P80_ibm80n04xml() |
| 123 | + throws IOException |
| 124 | + { |
| 125 | + try ( Reader reader = new FileReader( new File( testResourcesDir, "not-wf/P80/ibm80n04.xml" ) ) ) |
| 126 | + { |
| 127 | + parser.setInput( reader ); |
| 128 | + while ( parser.nextToken() != XmlPullParser.END_DOCUMENT ) |
| 129 | + ; |
| 130 | + fail( "Tests EncodingDecl with wrong field ordering. The string \"encoding=\" occurs after the double quoted EncName in the EncodingDecl in the XMLDecl." ); |
| 131 | + } |
| 132 | + catch ( XmlPullParserException e ) |
| 133 | + { |
| 134 | + assertTrue( e.getMessage().contains( "unexpected character \"" ) ); |
| 135 | + } |
| 136 | + } |
| 137 | + |
| 138 | + /** |
| 139 | + * Test ID: <pre>ibm-not-wf-P80-ibm80n05.xml</pre> |
| 140 | + * Test URI: <pre>not-wf/P80/ibm80n05.xml</pre> |
| 141 | + * Comment: <pre>Tests EncodingDecl with wrong field ordering. The "encoding" occurs after the double quoted EncName in the EncodingDecl in the XMLDecl.</pre> |
| 142 | + * Sections: <pre>4.3.3</pre> |
| 143 | + * Version: |
| 144 | + * |
| 145 | + * @throws IOException if there is an I/O error |
| 146 | + */ |
| 147 | + @Test |
| 148 | + public void testibm_not_wf_P80_ibm80n05xml() |
| 149 | + throws IOException |
| 150 | + { |
| 151 | + try ( Reader reader = new FileReader( new File( testResourcesDir, "not-wf/P80/ibm80n05.xml" ) ) ) |
| 152 | + { |
| 153 | + parser.setInput( reader ); |
| 154 | + while ( parser.nextToken() != XmlPullParser.END_DOCUMENT ) |
| 155 | + ; |
| 156 | + fail( "Tests EncodingDecl with wrong field ordering. The \"encoding\" occurs after the double quoted EncName in the EncodingDecl in the XMLDecl." ); |
| 157 | + } |
| 158 | + catch ( XmlPullParserException e ) |
| 159 | + { |
| 160 | + assertTrue( e.getMessage().contains( "unexpected character \"" ) ); |
| 161 | + } |
| 162 | + } |
| 163 | + |
| 164 | + /** |
| 165 | + * Test ID: <pre>ibm-not-wf-P80-ibm80n06.xml</pre> |
| 166 | + * Test URI: <pre>not-wf/P80/ibm80n06.xml</pre> |
| 167 | + * Comment: <pre>Tests EncodingDecl with wrong key word. The string "Encoding" is used as the key word in the EncodingDecl in the XMLDecl.</pre> |
| 168 | + * Sections: <pre>4.3.3</pre> |
| 169 | + * Version: |
| 170 | + * |
| 171 | + * @throws IOException if there is an I/O error |
| 172 | + */ |
| 173 | + @Test |
| 174 | + public void testibm_not_wf_P80_ibm80n06xml() |
| 175 | + throws IOException |
| 176 | + { |
| 177 | + try ( Reader reader = new FileReader( new File( testResourcesDir, "not-wf/P80/ibm80n06.xml" ) ) ) |
| 178 | + { |
| 179 | + parser.setInput( reader ); |
| 180 | + while ( parser.nextToken() != XmlPullParser.END_DOCUMENT ) |
| 181 | + ; |
| 182 | + fail( "Tests EncodingDecl with wrong key word. The string \"Encoding\" is used as the key word in the EncodingDecl in the XMLDecl." ); |
| 183 | + } |
| 184 | + catch ( XmlPullParserException e ) |
| 185 | + { |
| 186 | + assertTrue( e.getMessage().contains( "unexpected character E" ) ); |
| 187 | + } |
| 188 | + } |
| 189 | + |
| 190 | +} |
0 commit comments