|
33 | 33 | import java.io.InputStream;
|
34 | 34 | import java.io.StringReader;
|
35 | 35 | import java.io.StringWriter;
|
36 |
| -import java.nio.file.Files; |
37 |
| -import java.nio.file.Paths; |
38 | 36 |
|
39 | 37 | import javax.xml.parsers.DocumentBuilder;
|
40 | 38 | import javax.xml.parsers.DocumentBuilderFactory;
|
|
66 | 64 |
|
67 | 65 | /*
|
68 | 66 | * @test
|
69 |
| - * @bug 6439439 8087303 8174025 8223291 8249867 8261209 8260858 |
| 67 | + * @bug 6439439 8087303 8174025 8223291 8249867 8261209 8260858 8265073 |
70 | 68 | * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
|
71 | 69 | * @run testng/othervm -DrunSecMngr=true -Djava.security.manager=allow common.prettyprint.PrettyPrintTest
|
72 | 70 | * @run testng/othervm common.prettyprint.PrettyPrintTest
|
@@ -180,6 +178,54 @@ Object[][] getSystemProperty() throws Exception {
|
180 | 178 | };
|
181 | 179 | }
|
182 | 180 |
|
| 181 | + private final String xml1 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" |
| 182 | + + "<a><b>element b</b><c>element c</c><d xml:space=\"preserve\">TRUE</d><e>test</e></a>"; |
| 183 | + private final String expected1 = "<a>\n" |
| 184 | + + " <b>element b</b>\n" |
| 185 | + + " <c>element c</c>\n" |
| 186 | + + " <d xml:space=\"preserve\">TRUE</d>\n" |
| 187 | + + " <e>test</e>\n" |
| 188 | + + "</a>\n"; |
| 189 | + |
| 190 | + private final String xml2 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" |
| 191 | + + "<l0><l1><l2 xml:space=\"preserve\">level 2</l2> level 1 <l2>level 2</l2></l1>" |
| 192 | + + "<l1 xml:space=\"preserve\"><l2>level 2</l2> level 1 <l2>level 2</l2></l1></l0>"; |
| 193 | + private final String expected2 = "<l0>\n" |
| 194 | + + " <l1>\n" |
| 195 | + + " <l2 xml:space=\"preserve\">level 2</l2>\n" |
| 196 | + + " level 1 \n" |
| 197 | + + " <l2>level 2</l2>\n" |
| 198 | + + " </l1>\n" |
| 199 | + + " <l1 xml:space=\"preserve\"><l2>level 2</l2> level 1 <l2>level 2</l2></l1>\n" |
| 200 | + + "</l0>\n"; |
| 201 | + |
| 202 | + /* |
| 203 | + * Bug: 8265073 |
| 204 | + * source and expected output |
| 205 | + */ |
| 206 | + @DataProvider |
| 207 | + public Object[][] preserveSpace() { |
| 208 | + return new Object[][]{ |
| 209 | + {xml1, expected1}, |
| 210 | + {xml2, expected2}, |
| 211 | + }; |
| 212 | + } |
| 213 | + |
| 214 | + /** |
| 215 | + * Bug: 8265073 |
| 216 | + * Verifies that the scope of the preserve attribute is applied properly |
| 217 | + * within the relevant elements. |
| 218 | + * @param xml the source |
| 219 | + * @param expected the expected result |
| 220 | + * @throws Exception if the assertion fails or an error occurs in the |
| 221 | + * transform process |
| 222 | + */ |
| 223 | + @Test(dataProvider = "preserveSpace") |
| 224 | + public void test(String xml, String expected) throws Exception { |
| 225 | + String result = transform(null, xml, true, true, false, false, false); |
| 226 | + Assert.assertEquals(result.replaceAll("\r\n", "\n"), expected); |
| 227 | + } |
| 228 | + |
183 | 229 | /*
|
184 | 230 | * Bug: 8260858
|
185 | 231 | * Verifies the use of the new property "xsltcIsStandalone" and the
|
|
0 commit comments