author | joehw |
Wed, 28 Jan 2015 22:49:58 -0800 | |
changeset 28697 | fae50549d70d |
child 28793 | 9c016ad3173c |
permissions | -rw-r--r-- |
28697
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
1 |
/* |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
2 |
* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
4 |
* |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
8 |
* |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
13 |
* accompanied this code). |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
14 |
* |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
18 |
* |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
21 |
* questions. |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
22 |
*/ |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
23 |
package javax.xml.validation.ptests; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
24 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
25 |
import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
26 |
import static javax.xml.validation.ptests.ValidationTestConst.XML_DIR; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
27 |
import static org.testng.Assert.assertNotNull; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
28 |
import static org.testng.Assert.assertNull; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
29 |
import static org.testng.Assert.assertSame; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
30 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
31 |
import java.io.ByteArrayInputStream; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
32 |
import java.io.File; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
33 |
import java.io.IOException; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
34 |
import java.io.InputStream; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
35 |
import java.net.URL; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
36 |
import java.nio.file.Files; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
37 |
import java.nio.file.Paths; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
38 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
39 |
import javax.xml.parsers.DocumentBuilder; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
40 |
import javax.xml.parsers.DocumentBuilderFactory; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
41 |
import javax.xml.parsers.ParserConfigurationException; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
42 |
import javax.xml.transform.Source; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
43 |
import javax.xml.transform.dom.DOMSource; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
44 |
import javax.xml.transform.sax.SAXSource; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
45 |
import javax.xml.transform.stream.StreamSource; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
46 |
import javax.xml.validation.Schema; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
47 |
import javax.xml.validation.SchemaFactory; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
48 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
49 |
import org.testng.annotations.BeforeClass; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
50 |
import org.testng.annotations.DataProvider; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
51 |
import org.testng.annotations.Test; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
52 |
import org.w3c.dom.Document; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
53 |
import org.xml.sax.ErrorHandler; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
54 |
import org.xml.sax.InputSource; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
55 |
import org.xml.sax.SAXException; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
56 |
import org.xml.sax.SAXNotRecognizedException; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
57 |
import org.xml.sax.SAXNotSupportedException; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
58 |
import org.xml.sax.SAXParseException; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
59 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
60 |
/* |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
61 |
* @summary Class containing the test cases for SchemaFactory |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
62 |
*/ |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
63 |
@Test(singleThreaded = true) |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
64 |
public class SchemaFactoryTest { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
65 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
66 |
@BeforeClass |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
67 |
public void setup() throws SAXException, IOException, ParserConfigurationException { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
68 |
sf = newSchemaFactory(); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
69 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
70 |
assertNotNull(sf); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
71 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
72 |
xsd1 = Files.readAllBytes(Paths.get(XML_DIR + "test.xsd")); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
73 |
xsd2 = Files.readAllBytes(Paths.get(XML_DIR + "test1.xsd")); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
74 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
75 |
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
76 |
dbf.setNamespaceAware(true); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
77 |
DocumentBuilder db = dbf.newDocumentBuilder(); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
78 |
xsdDoc1 = db.parse(newInputStream(xsd1)); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
79 |
xsdDoc2 = db.parse(newInputStream(xsd2)); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
80 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
81 |
xml = Files.readAllBytes(Paths.get(XML_DIR + "test.xml")); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
82 |
} |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
83 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
84 |
@Test(expectedExceptions = SAXParseException.class) |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
85 |
public void testNewSchemaDefault() throws SAXException, IOException { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
86 |
validate(sf.newSchema()); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
87 |
} |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
88 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
89 |
@Test |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
90 |
public void testNewSchemaWithFile() throws SAXException, IOException { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
91 |
validate(sf.newSchema(new File(XML_DIR + "test.xsd"))); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
92 |
} |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
93 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
94 |
@Test(expectedExceptions = NullPointerException.class) |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
95 |
public void testNewSchemaWithNullFile() throws SAXException { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
96 |
sf.newSchema((File) null); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
97 |
} |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
98 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
99 |
@DataProvider(name = "valid-source") |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
100 |
public Object[][] getValidSource() { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
101 |
return new Object[][] { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
102 |
{ streamSource(xsd1) }, |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
103 |
{ saxSource(xsd1) }, |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
104 |
{ domSource(xsdDoc1) } }; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
105 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
106 |
} |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
107 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
108 |
@Test(dataProvider = "valid-source") |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
109 |
public void testNewSchemaWithValidSource(Source schema) throws SAXException, IOException { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
110 |
validate(sf.newSchema(schema)); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
111 |
} |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
112 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
113 |
@DataProvider(name = "invalid-source") |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
114 |
public Object[][] getInvalidSource() { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
115 |
return new Object[][] { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
116 |
{ nullStreamSource() }, |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
117 |
{ nullSaxSource() } }; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
118 |
} |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
119 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
120 |
@Test(dataProvider = "invalid-source", expectedExceptions = SAXParseException.class) |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
121 |
public void testNewSchemaWithInvalidSource(Source schema) throws SAXException { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
122 |
sf.newSchema(schema); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
123 |
} |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
124 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
125 |
@Test(expectedExceptions = NullPointerException.class) |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
126 |
public void testNewSchemaWithNullSource() throws SAXException { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
127 |
sf.newSchema((Source)null); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
128 |
} |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
129 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
130 |
@DataProvider(name = "valid-sources") |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
131 |
public Object[][] getValidSources() { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
132 |
return new Object[][] { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
133 |
{ streamSource(xsd1), streamSource(xsd2) }, |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
134 |
{ saxSource(xsd1), saxSource(xsd2) }, |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
135 |
{ domSource(xsdDoc1), domSource(xsdDoc2) } }; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
136 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
137 |
} |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
138 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
139 |
@Test(dataProvider = "valid-sources") |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
140 |
public void testNewSchemaWithValidSourceArray(Source schema1, Source schema2) throws SAXException, IOException { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
141 |
validate(sf.newSchema(new Source[] { schema1, schema2 })); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
142 |
} |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
143 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
144 |
@DataProvider(name = "invalid-sources") |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
145 |
public Object[][] getInvalidSources() { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
146 |
return new Object[][] { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
147 |
{ streamSource(xsd1), nullStreamSource() }, |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
148 |
{ nullStreamSource(), nullStreamSource() }, |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
149 |
{ saxSource(xsd1), nullSaxSource() }, |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
150 |
{ nullSaxSource(), nullSaxSource() } }; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
151 |
} |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
152 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
153 |
@Test(dataProvider = "invalid-sources", expectedExceptions = SAXParseException.class) |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
154 |
public void testNewSchemaWithInvalidSourceArray(Source schema1, Source schema2) throws SAXException { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
155 |
sf.newSchema(new Source[] { schema1, schema2 }); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
156 |
} |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
157 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
158 |
@DataProvider(name = "null-sources") |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
159 |
public Object[][] getNullSources() { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
160 |
return new Object[][] { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
161 |
{ new Source[] { domSource(xsdDoc1), null } }, |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
162 |
{ new Source[] { null, null } }, |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
163 |
{ null } }; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
164 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
165 |
} |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
166 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
167 |
@Test(dataProvider = "null-sources", expectedExceptions = NullPointerException.class) |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
168 |
public void testNewSchemaWithNullSourceArray(Source[] schemas) throws SAXException { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
169 |
sf.newSchema(schemas); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
170 |
} |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
171 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
172 |
@Test(expectedExceptions = NullPointerException.class) |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
173 |
public void testNewSchemaWithNullUrl() throws SAXException { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
174 |
sf.newSchema((URL) null); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
175 |
} |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
176 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
177 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
178 |
@Test |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
179 |
public void testErrorHandler() { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
180 |
SchemaFactory sf = newSchemaFactory(); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
181 |
assertNull(sf.getErrorHandler(), "When SchemaFactory is created, initially ErrorHandler should not be set."); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
182 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
183 |
ErrorHandler handler = new MyErrorHandler(); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
184 |
sf.setErrorHandler(handler); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
185 |
assertSame(sf.getErrorHandler(), handler); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
186 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
187 |
sf.setErrorHandler(null); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
188 |
assertNull(sf.getErrorHandler()); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
189 |
} |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
190 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
191 |
@Test(expectedExceptions = SAXNotRecognizedException.class) |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
192 |
public void testGetUnrecognizedProperty() throws SAXNotRecognizedException, SAXNotSupportedException { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
193 |
SchemaFactory sf = newSchemaFactory(); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
194 |
sf.getProperty(UNRECOGNIZED_NAME); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
195 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
196 |
} |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
197 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
198 |
@Test(expectedExceptions = SAXNotRecognizedException.class) |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
199 |
public void testSetUnrecognizedProperty() throws SAXNotRecognizedException, SAXNotSupportedException { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
200 |
SchemaFactory sf = newSchemaFactory(); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
201 |
sf.setProperty(UNRECOGNIZED_NAME, "test"); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
202 |
} |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
203 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
204 |
@Test(expectedExceptions = NullPointerException.class) |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
205 |
public void testGetNullProperty() throws SAXNotRecognizedException, SAXNotSupportedException { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
206 |
SchemaFactory sf = newSchemaFactory(); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
207 |
assertNotNull(sf); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
208 |
sf.getProperty(null); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
209 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
210 |
} |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
211 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
212 |
@Test(expectedExceptions = NullPointerException.class) |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
213 |
public void testSetNullProperty() throws SAXNotRecognizedException, SAXNotSupportedException { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
214 |
SchemaFactory sf = newSchemaFactory(); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
215 |
assertNotNull(sf); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
216 |
sf.setProperty(null, "test"); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
217 |
} |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
218 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
219 |
@Test(expectedExceptions = SAXNotRecognizedException.class) |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
220 |
public void testGetUnrecognizedFeature() throws SAXNotRecognizedException, SAXNotSupportedException { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
221 |
SchemaFactory sf = newSchemaFactory(); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
222 |
sf.getFeature(UNRECOGNIZED_NAME); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
223 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
224 |
} |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
225 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
226 |
@Test(expectedExceptions = SAXNotRecognizedException.class) |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
227 |
public void testSetUnrecognizedFeature() throws SAXNotRecognizedException, SAXNotSupportedException { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
228 |
SchemaFactory sf = newSchemaFactory(); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
229 |
sf.setFeature(UNRECOGNIZED_NAME, true); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
230 |
} |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
231 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
232 |
@Test(expectedExceptions = NullPointerException.class) |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
233 |
public void testGetNullFeature() throws SAXNotRecognizedException, SAXNotSupportedException { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
234 |
SchemaFactory sf = newSchemaFactory(); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
235 |
assertNotNull(sf); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
236 |
sf.getFeature(null); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
237 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
238 |
} |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
239 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
240 |
@Test(expectedExceptions = NullPointerException.class) |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
241 |
public void testSetNullFeature() throws SAXNotRecognizedException, SAXNotSupportedException { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
242 |
SchemaFactory sf = newSchemaFactory(); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
243 |
assertNotNull(sf); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
244 |
sf.setFeature(null, true); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
245 |
} |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
246 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
247 |
@Test(expectedExceptions = IllegalArgumentException.class) |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
248 |
public void testInvalidSchemaLanguage() { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
249 |
final String INVALID_SCHEMA_LANGUAGE = "http://relaxng.org/ns/structure/1.0"; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
250 |
SchemaFactory.newInstance(INVALID_SCHEMA_LANGUAGE); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
251 |
} |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
252 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
253 |
@Test(expectedExceptions = NullPointerException.class) |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
254 |
public void testNullSchemaLanguage() { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
255 |
SchemaFactory.newInstance(null); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
256 |
} |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
257 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
258 |
private void validate(Schema schema) throws SAXException, IOException { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
259 |
schema.newValidator().validate(new StreamSource(new ByteArrayInputStream(xml))); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
260 |
} |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
261 |
private InputStream newInputStream(byte[] xsd) { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
262 |
return new ByteArrayInputStream(xsd); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
263 |
} |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
264 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
265 |
private Source streamSource(byte[] xsd) { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
266 |
return new StreamSource(newInputStream(xsd)); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
267 |
} |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
268 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
269 |
private Source nullStreamSource() { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
270 |
return new StreamSource((InputStream) null); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
271 |
} |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
272 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
273 |
private Source saxSource(byte[] xsd) { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
274 |
return new SAXSource(new InputSource(newInputStream(xsd))); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
275 |
} |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
276 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
277 |
private Source nullSaxSource() { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
278 |
return new SAXSource(new InputSource((InputStream) null)); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
279 |
} |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
280 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
281 |
private Source domSource(Document xsdDoc) { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
282 |
return new DOMSource(xsdDoc); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
283 |
} |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
284 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
285 |
private SchemaFactory newSchemaFactory() { |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
286 |
return SchemaFactory.newInstance(W3C_XML_SCHEMA_NS_URI); |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
287 |
} |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
288 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
289 |
private static final String UNRECOGNIZED_NAME = "http://xml.org/sax/features/namespace-prefixes"; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
290 |
|
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
291 |
private SchemaFactory sf; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
292 |
private byte[] xsd1; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
293 |
private byte[] xsd2; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
294 |
private Document xsdDoc1; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
295 |
private Document xsdDoc2; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
296 |
private byte[] xml; |
fae50549d70d
8051547: Convert JAXP function tests: javax.xml.validation.* to jtreg (testng) tests
joehw
parents:
diff
changeset
|
297 |
} |