Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/javax/xml/jaxp/testng/validation/jdk8037819/UnparsedEntityCheckingTest.java
41159 views
1
/*
2
* Licensed to the Apache Software Foundation (ASF) under one or more
3
* contributor license agreements. See the NOTICE file distributed with
4
* this work for additional information regarding copyright ownership.
5
* The ASF licenses this file to You under the Apache License, Version 2.0
6
* (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
16
*/
17
package validation.jdk8037819;
18
19
import com.sun.org.apache.xerces.internal.dom.PSVIElementNSImpl;
20
import com.sun.org.apache.xerces.internal.xs.ItemPSVI;
21
import org.testng.annotations.AfterClass;
22
import org.testng.annotations.BeforeClass;
23
import org.testng.annotations.Test;
24
import validation.BaseTest;
25
26
public class UnparsedEntityCheckingTest extends BaseTest {
27
public static final String UNDECLARED_ENTITY = "UndeclaredEntity";
28
29
protected String getXMLDocument() {
30
return "unparsedEntity.xml";
31
}
32
33
protected String getSchemaFile() {
34
return "base.xsd";
35
}
36
37
protected String[] getRelevantErrorIDs() {
38
return new String[] { UNDECLARED_ENTITY };
39
}
40
41
public UnparsedEntityCheckingTest(String name) {
42
super(name);
43
}
44
45
@BeforeClass
46
protected void setUp() throws Exception {
47
super.setUp();
48
}
49
50
@AfterClass
51
protected void tearDown() throws Exception {
52
super.tearDown();
53
}
54
55
@Test
56
public void testDefaultValid() {
57
try {
58
reset();
59
validateDocument();
60
} catch (Exception e) {
61
fail("Validation failed: " + e.getMessage());
62
}
63
64
checkDefault();
65
}
66
67
@Test
68
public void testSetFalseValid() {
69
try {
70
reset();
71
fValidator.setFeature(UNPARSED_ENTITY_CHECKING, false);
72
validateDocument();
73
} catch (Exception e) {
74
fail("Validation failed: " + e.getMessage());
75
}
76
77
checkDefault();
78
}
79
80
@Test
81
public void testSetTrueValid() {
82
try {
83
reset();
84
fValidator.setFeature(UNPARSED_ENTITY_CHECKING, true);
85
validateDocument();
86
} catch (Exception e) {
87
fail("Validation failed: " + e.getMessage());
88
}
89
90
checkDefault();
91
}
92
93
@Test
94
public void testDefaultInvalid() {
95
try {
96
reset();
97
((PSVIElementNSImpl) fRootNode).setAttributeNS(null,
98
"unparsedEntityAttr", "invalid");
99
validateDocument();
100
} catch (Exception e) {
101
fail("Validation failed: " + e.getMessage());
102
}
103
104
checkInvalid();
105
}
106
107
@Test
108
public void testSetFalseInvalid() {
109
try {
110
reset();
111
((PSVIElementNSImpl) fRootNode).setAttributeNS(null,
112
"unparsedEntityAttr", "invalid");
113
fValidator.setFeature(UNPARSED_ENTITY_CHECKING, false);
114
validateDocument();
115
} catch (Exception e) {
116
fail("Validation failed: " + e.getMessage());
117
}
118
119
checkDefault();
120
}
121
122
@Test
123
public void testSetTrueInvalid() {
124
try {
125
reset();
126
((PSVIElementNSImpl) fRootNode).setAttributeNS(null,
127
"unparsedEntityAttr", "invalid");
128
fValidator.setFeature(UNPARSED_ENTITY_CHECKING, true);
129
validateDocument();
130
} catch (Exception e) {
131
fail("Validation failed: " + e.getMessage());
132
}
133
134
checkInvalid();
135
}
136
137
private void checkDefault() {
138
assertNoError(UNDECLARED_ENTITY);
139
assertValidity(ItemPSVI.VALIDITY_VALID, fRootNode.getValidity());
140
assertValidationAttempted(ItemPSVI.VALIDATION_FULL, fRootNode
141
.getValidationAttempted());
142
assertElementName("A", fRootNode.getElementDeclaration().getName());
143
assertTypeName("X", fRootNode.getTypeDefinition().getName());
144
}
145
146
private void checkInvalid() {
147
assertError(UNDECLARED_ENTITY);
148
assertValidity(ItemPSVI.VALIDITY_INVALID, fRootNode.getValidity());
149
assertValidationAttempted(ItemPSVI.VALIDATION_FULL, fRootNode
150
.getValidationAttempted());
151
assertElementName("A", fRootNode.getElementDeclaration().getName());
152
assertTypeName("X", fRootNode.getTypeDefinition().getName());
153
}
154
}
155
156