1
1
/*
2
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
28
28
import javax .xml .stream .XMLEventReader ;
29
29
30
30
import javax .xml .stream .XMLInputFactory ;
31
+ import javax .xml .stream .XMLStreamException ;
32
+ import javax .xml .stream .events .StartDocument ;
33
+
34
+ import org .testng .annotations .DataProvider ;
31
35
import org .testng .annotations .Listeners ;
32
36
import org .testng .annotations .Test ;
33
37
38
+ import static org .testng .Assert .assertEquals ;
39
+
34
40
/*
35
41
* @test
36
- * @bug 8204329
42
+ * @bug 8204329 8256515
37
43
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
38
44
* @run testng stream.XMLEventReaderTest.EventReaderTest
39
45
* @summary Tests XMLEventReader
@@ -51,4 +57,23 @@ public void testNextEvent() throws Exception {
51
57
// no more event
52
58
eventReader .nextEvent ();
53
59
}
60
+
61
+ @ DataProvider
62
+ Object [][] standaloneSetTestData () {
63
+ return new Object [][]{
64
+ {"<?xml version=\" 1.0\" ?>" , false , false },
65
+ {"<?xml version=\" 1.0\" standalone=\" no\" ?>" , false , true },
66
+ {"<?xml version=\" 1.0\" standalone=\" yes\" ?>" , true , true }
67
+ };
68
+ }
69
+
70
+ @ Test (dataProvider = "standaloneSetTestData" )
71
+ void testStandaloneSet (String xml , boolean standalone , boolean standaloneSet ) throws XMLStreamException {
72
+ XMLInputFactory factory = XMLInputFactory .newInstance ();
73
+ XMLEventReader reader = factory .createXMLEventReader (new StringReader (xml ));
74
+ StartDocument startDocumentEvent = (StartDocument ) reader .nextEvent ();
75
+
76
+ assertEquals (startDocumentEvent .isStandalone (), standalone );
77
+ assertEquals (startDocumentEvent .standaloneSet (), standaloneSet );
78
+ }
54
79
}
0 commit comments