IgnoreXSITypeTest_A_A.java revision 10791:745a5e1d4508
1142425Snectar/*
2160814Ssimon * Licensed to the Apache Software Foundation (ASF) under one or more
3142425Snectar * contributor license agreements.  See the NOTICE file distributed with
4142425Snectar * this work for additional information regarding copyright ownership.
5142425Snectar * The ASF licenses this file to You under the Apache License, Version 2.0
6142425Snectar * (the "License"); you may not use this file except in compliance with
7142425Snectar * the License.  You may obtain a copy of the License at
8142425Snectar *
9142425Snectar *      http://www.apache.org/licenses/LICENSE-2.0
10142425Snectar *
11142425Snectar * Unless required by applicable law or agreed to in writing, software
12142425Snectar * distributed under the License is distributed on an "AS IS" BASIS,
13194206Ssimon * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14142425Snectar * See the License for the specific language governing permissions and
15142425Snectar * limitations under the License.
16142425Snectar */
17160814Ssimon
18142425Snectarpackage validation.jdk8037819;
19142425Snectar
20142425Snectarimport com.sun.org.apache.xerces.internal.dom.PSVIElementNSImpl;
21142425Snectarimport com.sun.org.apache.xerces.internal.xs.ItemPSVI;
22142425Snectarimport org.testng.annotations.AfterClass;
23142425Snectarimport org.testng.annotations.BeforeClass;
24238405Sjkimimport org.testng.annotations.Test;
25238405Sjkimimport validation.BaseTest;
26142425Snectar
27142425Snectarpublic class IgnoreXSITypeTest_A_A extends BaseTest {
28142425Snectar
29142425Snectar    protected String getXMLDocument() {
30142425Snectar        return "xsitype_A_A.xml";
31142425Snectar    }
32142425Snectar
33142425Snectar    protected String getSchemaFile() {
34142425Snectar        return "base.xsd";
35142425Snectar    }
36142425Snectar
37142425Snectar    public IgnoreXSITypeTest_A_A(String name) {
38142425Snectar        super(name);
39142425Snectar    }
40238405Sjkim
41142425Snectar    @BeforeClass
42142425Snectar    protected void setUp() throws Exception {
43142425Snectar        super.setUp();
44238405Sjkim    }
45238405Sjkim
46142425Snectar    @AfterClass
47238405Sjkim    protected void tearDown() throws Exception {
48238405Sjkim        super.tearDown();
49238405Sjkim    }
50238405Sjkim
51142425Snectar    @Test
52238405Sjkim    public void testDefaultDocument() {
53238405Sjkim        try {
54238405Sjkim            reset();
55238405Sjkim            validateDocument();
56238405Sjkim        } catch (Exception e) {
57238405Sjkim            fail("Validation failed: " + e.getMessage());
58238405Sjkim        }
59160814Ssimon
60238405Sjkim        // default value of the feature is false
61238405Sjkim        checkFalseResult();
62160814Ssimon    }
63160814Ssimon
64142425Snectar    @Test
65238405Sjkim    public void testDefaultFragment() {
66238405Sjkim        try {
67238405Sjkim            reset();
68142425Snectar            validateFragment();
69142425Snectar        } catch (Exception e) {
70142425Snectar            fail("Validation failed: " + e.getMessage());
71142425Snectar        }
72142425Snectar
73142425Snectar        // default value of the feature is false
74142425Snectar        checkFalseResult();
75142425Snectar    }
76142425Snectar
77160814Ssimon    @Test
78160814Ssimon    public void testSetFalseDocument() {
79142425Snectar        try {
80142425Snectar            reset();
81142425Snectar            fValidator.setFeature(IGNORE_XSI_TYPE, false);
82142425Snectar            validateDocument();
83142425Snectar        } catch (Exception e) {
84142425Snectar            fail("Validation failed: " + e.getMessage());
85142425Snectar        }
86142425Snectar
87142425Snectar        checkFalseResult();
88142425Snectar    }
89142425Snectar
90142425Snectar    @Test
91142425Snectar    public void testSetFalseFragment() {
92284285Sjkim        try {
93284285Sjkim            reset();
94142425Snectar            fValidator.setFeature(IGNORE_XSI_TYPE, false);
95160814Ssimon            validateFragment();
96142425Snectar        } catch (Exception e) {
97142425Snectar            fail("Validation failed: " + e.getMessage());
98142425Snectar        }
99142425Snectar
100142425Snectar        checkFalseResult();
101142425Snectar    }
102142425Snectar
103160814Ssimon    @Test
104142425Snectar    public void testSetTrueDocument() {
105142425Snectar        try {
106142425Snectar            reset();
107160814Ssimon            fValidator.setFeature(IGNORE_XSI_TYPE, true);
108160814Ssimon            validateDocument();
109160814Ssimon        } catch (Exception e) {
110160814Ssimon            fail("Validation failed: " + e.getMessage());
111160814Ssimon        }
112160814Ssimon
113160814Ssimon        checkTrueResult();
114160814Ssimon    }
115160814Ssimon
116160814Ssimon    @Test
117160814Ssimon    public void testSetTrueFragment() {
118238405Sjkim        try {
119160814Ssimon            reset();
120160814Ssimon            fValidator.setFeature(IGNORE_XSI_TYPE, true);
121160814Ssimon            validateFragment();
122160814Ssimon        } catch (Exception e) {
123238405Sjkim            fail("Validation failed: " + e.getMessage());
124238405Sjkim        }
125238405Sjkim
126238405Sjkim        checkTrueResult();
127238405Sjkim    }
128
129    private void checkTrueResult() {
130        checkResult();
131    }
132
133    private void checkFalseResult() {
134        checkResult();
135    }
136
137    private void checkResult() {
138        assertValidity(ItemPSVI.VALIDITY_VALID, fRootNode.getValidity());
139        assertValidationAttempted(ItemPSVI.VALIDATION_FULL, fRootNode
140                .getValidationAttempted());
141        assertElementName("A", fRootNode.getElementDeclaration().getName());
142        assertTypeName("Y", fRootNode.getTypeDefinition().getName());
143        assertTypeNamespaceNull(fRootNode.getTypeDefinition().getNamespace());
144
145        PSVIElementNSImpl child = super.getChild(1);
146        assertValidity(ItemPSVI.VALIDITY_VALID, child.getValidity());
147        assertValidationAttempted(ItemPSVI.VALIDATION_FULL, child
148                .getValidationAttempted());
149        assertElementName("A", child.getElementDeclaration().getName());
150        assertTypeName("Y", child.getTypeDefinition().getName());
151        assertTypeNamespaceNull(child.getTypeDefinition().getNamespace());
152    }
153}
154