author | joehw |
Mon, 13 Oct 2014 14:11:20 -0700 | |
changeset 27037 | 5a6ef51923c4 |
permissions | -rw-r--r-- |
27037
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
1 |
package validation; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
2 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
3 |
import java.io.File; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
4 |
import java.io.FileNotFoundException; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
5 |
import java.net.URL; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
6 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
7 |
import javax.xml.XMLConstants; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
8 |
import javax.xml.parsers.DocumentBuilder; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
9 |
import javax.xml.parsers.DocumentBuilderFactory; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
10 |
import javax.xml.transform.Result; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
11 |
import javax.xml.transform.Source; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
12 |
import javax.xml.transform.dom.DOMResult; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
13 |
import javax.xml.transform.dom.DOMSource; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
14 |
import javax.xml.validation.Schema; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
15 |
import javax.xml.validation.SchemaFactory; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
16 |
import javax.xml.validation.Validator; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
17 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
18 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
19 |
import com.sun.org.apache.xerces.internal.dom.PSVIElementNSImpl; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
20 |
import com.sun.org.apache.xerces.internal.impl.Constants; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
21 |
import com.sun.org.apache.xerces.internal.impl.xs.SchemaGrammar; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
22 |
import com.sun.org.apache.xerces.internal.xs.ElementPSVI; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
23 |
import com.sun.org.apache.xerces.internal.xs.ItemPSVI; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
24 |
import com.sun.org.apache.xerces.internal.xs.XSElementDeclaration; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
25 |
import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
26 |
import java.security.Policy; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
27 |
import javax.xml.transform.stream.StreamSource; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
28 |
import org.w3c.dom.Document; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
29 |
import org.w3c.dom.Node; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
30 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
31 |
public abstract class BaseTest { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
32 |
protected final static String ROOT_TYPE = Constants.XERCES_PROPERTY_PREFIX |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
33 |
+ Constants.ROOT_TYPE_DEFINITION_PROPERTY; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
34 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
35 |
protected final static String IGNORE_XSI_TYPE = Constants.XERCES_FEATURE_PREFIX |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
36 |
+ Constants.IGNORE_XSI_TYPE_FEATURE; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
37 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
38 |
protected final static String ID_IDREF_CHECKING = Constants.XERCES_FEATURE_PREFIX |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
39 |
+ Constants.ID_IDREF_CHECKING_FEATURE; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
40 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
41 |
protected final static String IDC_CHECKING = Constants.XERCES_FEATURE_PREFIX |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
42 |
+ Constants.IDC_CHECKING_FEATURE; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
43 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
44 |
protected final static String UNPARSED_ENTITY_CHECKING = Constants.XERCES_FEATURE_PREFIX |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
45 |
+ Constants.UNPARSED_ENTITY_CHECKING_FEATURE; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
46 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
47 |
protected final static String USE_GRAMMAR_POOL_ONLY = Constants.XERCES_FEATURE_PREFIX |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
48 |
+ Constants.USE_GRAMMAR_POOL_ONLY_FEATURE; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
49 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
50 |
protected final static String DYNAMIC_VALIDATION = Constants.XERCES_FEATURE_PREFIX |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
51 |
+ Constants.DYNAMIC_VALIDATION_FEATURE; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
52 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
53 |
protected final static String DOCUMENT_CLASS_NAME = Constants.XERCES_PROPERTY_PREFIX |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
54 |
+ Constants.DOCUMENT_CLASS_NAME_PROPERTY; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
55 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
56 |
public static boolean isWindows = false; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
57 |
static { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
58 |
if (System.getProperty("os.name").indexOf("Windows")>-1) { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
59 |
isWindows = true; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
60 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
61 |
}; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
62 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
63 |
protected Schema schema; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
64 |
protected Validator fValidator; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
65 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
66 |
protected SpecialCaseErrorHandler fErrorHandler; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
67 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
68 |
protected DocumentBuilder builder; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
69 |
protected Document fDocument; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
70 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
71 |
protected ElementPSVI fRootNode; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
72 |
protected URL fDocumentURL; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
73 |
protected URL fSchemaURL; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
74 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
75 |
static String errMessage; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
76 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
77 |
int passed = 0, failed = 0; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
78 |
private boolean hasSM; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
79 |
private Policy orig; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
80 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
81 |
protected abstract String getSchemaFile(); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
82 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
83 |
protected abstract String getXMLDocument(); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
84 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
85 |
public BaseTest(String name) { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
86 |
fErrorHandler = new SpecialCaseErrorHandler(getRelevantErrorIDs()); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
87 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
88 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
89 |
protected void setUp() throws Exception { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
90 |
if (System.getSecurityManager() != null) { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
91 |
hasSM = true; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
92 |
System.setSecurityManager(null); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
93 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
94 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
95 |
orig = Policy.getPolicy(); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
96 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
97 |
DocumentBuilderFactory docFactory = DocumentBuilderFactory |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
98 |
.newInstance(); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
99 |
docFactory.setAttribute(DOCUMENT_CLASS_NAME, |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
100 |
"com.sun.org.apache.xerces.internal.dom.PSVIDocumentImpl"); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
101 |
docFactory.setNamespaceAware(true); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
102 |
builder = docFactory.newDocumentBuilder(); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
103 |
// build the location URL of the document |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
104 |
String filepath = System.getProperty("test.src", "."); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
105 |
String packageDir = this.getClass().getPackage().getName().replace('.', |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
106 |
'/'); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
107 |
String documentPath = filepath + "/" + packageDir + "/" + getXMLDocument(); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
108 |
String schemaPath = filepath + "/" + packageDir + "/" + getSchemaFile(); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
109 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
110 |
if (isWindows) { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
111 |
fDocumentURL = new URL("file:/" + documentPath); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
112 |
fSchemaURL = new URL("file:/" + schemaPath); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
113 |
} else { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
114 |
fDocumentURL = new URL("file:" + documentPath); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
115 |
fSchemaURL = new URL("file:" + schemaPath); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
116 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
117 |
if (fDocumentURL == null) { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
118 |
throw new FileNotFoundException("Couldn't find xml file for test: " + documentPath); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
119 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
120 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
121 |
SchemaFactory sf = SchemaFactory |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
122 |
.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
123 |
sf.setFeature(USE_GRAMMAR_POOL_ONLY, getUseGrammarPoolOnly()); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
124 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
125 |
if (fSchemaURL == null) { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
126 |
throw new FileNotFoundException("Couldn't find schema file for test: " + schemaPath); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
127 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
128 |
schema = sf.newSchema(fSchemaURL); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
129 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
130 |
// String schemaPath = "./jaxp-ri/src/unit-test/apache/xerces/jdk8037819/" + getSchemaFile(); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
131 |
// Schema schema = sf.newSchema(new StreamSource(new File(schemaPath))); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
132 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
133 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
134 |
protected void tearDown() throws Exception { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
135 |
System.setSecurityManager(null); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
136 |
Policy.setPolicy(orig); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
137 |
if (hasSM) { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
138 |
System.setSecurityManager(new SecurityManager()); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
139 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
140 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
141 |
builder = null; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
142 |
schema = null; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
143 |
fRootNode = null; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
144 |
fErrorHandler.reset(); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
145 |
System.out.println("\nNumber of tests passed: " + passed); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
146 |
System.out.println("Number of tests failed: " + failed + "\n"); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
147 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
148 |
if (errMessage != null) { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
149 |
throw new RuntimeException(errMessage); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
150 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
151 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
152 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
153 |
protected void validateDocument() throws Exception { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
154 |
Source source = new DOMSource(fDocument); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
155 |
source.setSystemId(fDocumentURL.toExternalForm()); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
156 |
Result result = new DOMResult(fDocument); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
157 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
158 |
fValidator.validate(source, result); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
159 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
160 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
161 |
protected void validateFragment() throws Exception { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
162 |
Source source = new DOMSource((Node) fRootNode); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
163 |
source.setSystemId(fDocumentURL.toExternalForm()); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
164 |
Result result = new DOMResult((Node) fRootNode); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
165 |
fValidator.validate(source, result); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
166 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
167 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
168 |
protected void reset() throws Exception { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
169 |
// fDocument = builder.parse(new File("./jaxp-ri/src/unit-test/apache/xerces/jdk8037819/" + getXMLDocument())); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
170 |
fDocument = builder.parse(fDocumentURL.toExternalForm()); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
171 |
fRootNode = (ElementPSVI) fDocument.getDocumentElement(); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
172 |
fValidator = schema.newValidator(); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
173 |
fErrorHandler.reset(); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
174 |
fValidator.setErrorHandler(fErrorHandler); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
175 |
fValidator.setFeature(DYNAMIC_VALIDATION, false); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
176 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
177 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
178 |
protected PSVIElementNSImpl getChild(int n) { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
179 |
int numFound = 0; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
180 |
Node child = ((Node) fRootNode).getFirstChild(); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
181 |
while (child != null) { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
182 |
if (child.getNodeType() == Node.ELEMENT_NODE) { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
183 |
numFound++; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
184 |
if (numFound == n) { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
185 |
return (PSVIElementNSImpl) child; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
186 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
187 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
188 |
child = child.getNextSibling(); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
189 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
190 |
return null; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
191 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
192 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
193 |
protected String[] getRelevantErrorIDs() { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
194 |
return new String[] {}; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
195 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
196 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
197 |
protected boolean getUseGrammarPoolOnly() { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
198 |
return false; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
199 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
200 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
201 |
// specialized asserts |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
202 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
203 |
protected void assertValidity(short expectedValidity, short actualValidity) { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
204 |
String expectedString = expectedValidity == ItemPSVI.VALIDITY_VALID ? "valid" |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
205 |
: (expectedValidity == ItemPSVI.VALIDITY_INVALID ? "invalid" |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
206 |
: "notKnown"); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
207 |
String actualString = actualValidity == ItemPSVI.VALIDITY_VALID ? "valid" |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
208 |
: (actualValidity == ItemPSVI.VALIDITY_INVALID ? "invalid" |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
209 |
: "notKnown"); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
210 |
String message = "{validity} was <" + actualString |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
211 |
+ "> but it should have been <" + expectedString + ">"; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
212 |
assertEquals(message, expectedValidity, actualValidity); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
213 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
214 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
215 |
protected void assertValidationAttempted(short expectedAttempted, |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
216 |
short actualAttempted) { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
217 |
String expectedString = expectedAttempted == ItemPSVI.VALIDATION_FULL ? "full" |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
218 |
: (expectedAttempted == ItemPSVI.VALIDATION_PARTIAL ? "partial" |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
219 |
: "none"); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
220 |
String actualString = actualAttempted == ItemPSVI.VALIDATION_FULL ? "full" |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
221 |
: (actualAttempted == ItemPSVI.VALIDATION_PARTIAL ? "partial" |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
222 |
: "none"); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
223 |
String message = "{validity} was <" + actualString |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
224 |
+ "> but it should have been <" + expectedString + ">"; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
225 |
assertEquals(message, expectedAttempted, actualAttempted); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
226 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
227 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
228 |
protected void assertElementName(String expectedName, String actualName) { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
229 |
assertEquals("Local name of element declaration is wrong.", |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
230 |
expectedName, actualName); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
231 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
232 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
233 |
protected void assertElementNull(XSElementDeclaration elem) { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
234 |
assertNull("Element declaration should be null.", elem); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
235 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
236 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
237 |
protected void assertElementNamespace(String expectedName, String actualName) { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
238 |
assertEquals("Namespace of element declaration is wrong.", |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
239 |
expectedName, actualName); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
240 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
241 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
242 |
protected void assertElementNamespaceNull(String actualName) { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
243 |
assertNull("Local name of element declaration should be null.", |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
244 |
actualName); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
245 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
246 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
247 |
protected void assertTypeName(String expectedName, String actualName) { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
248 |
assertEquals("Local name of type definition is wrong.", expectedName, |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
249 |
actualName); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
250 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
251 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
252 |
protected void assertTypeNull(XSTypeDefinition type) { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
253 |
assertNull("Type definition should be null.", type); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
254 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
255 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
256 |
protected void assertTypeNamespace(String expectedName, String actualName) { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
257 |
assertEquals("Namespace of type definition is wrong.", expectedName, |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
258 |
actualName); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
259 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
260 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
261 |
protected void assertTypeNamespaceNull(String actualName) { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
262 |
assertNull("Namespace of type definition should be null.", actualName); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
263 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
264 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
265 |
protected void assertError(String error) { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
266 |
assertTrue("Error <" + error + "> should have occured, but did not.", |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
267 |
fErrorHandler.specialCaseFound(error)); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
268 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
269 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
270 |
protected void assertNoError(String error) { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
271 |
assertFalse("Error <" + error |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
272 |
+ "> should not have occured (but it did)", fErrorHandler |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
273 |
.specialCaseFound(error)); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
274 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
275 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
276 |
protected void assertAnyType(XSTypeDefinition type) { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
277 |
assertEquals("Type is supposed to be anyType", SchemaGrammar.fAnyType, |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
278 |
type); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
279 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
280 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
281 |
void assertEquals(String msg, Object expected, Object actual) { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
282 |
if (!expected.equals(actual)) { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
283 |
fail(msg + " Expected: " + expected + " Actual: " + actual); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
284 |
} else { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
285 |
success(null); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
286 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
287 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
288 |
void assertNull(String msg, Object value) { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
289 |
if (value != null) { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
290 |
fail(msg); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
291 |
} else { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
292 |
success(null); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
293 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
294 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
295 |
public void assertTrue(String msg, boolean value) { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
296 |
if (!value) { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
297 |
fail(msg); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
298 |
} else { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
299 |
success(null); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
300 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
301 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
302 |
public void assertFalse(String msg, boolean value) { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
303 |
if (value) { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
304 |
fail(msg); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
305 |
} else { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
306 |
success(null); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
307 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
308 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
309 |
public void fail(String errMsg) { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
310 |
if (errMessage == null) { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
311 |
errMessage = errMsg; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
312 |
} else { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
313 |
errMessage = errMessage + "\n" + errMsg; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
314 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
315 |
failed++; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
316 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
317 |
|
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
318 |
public void success(String msg) { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
319 |
passed++; |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
320 |
if (msg != null) { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
321 |
if (msg.length() != 0) { |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
322 |
System.out.println(msg); |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
323 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
324 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
325 |
} |
5a6ef51923c4
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff
changeset
|
326 |
} |