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
18package validation.jdk8036951;
19
20
21import com.sun.org.apache.xerces.internal.dom.PSVIElementNSImpl;
22import com.sun.org.apache.xerces.internal.xs.ItemPSVI;
23import org.testng.annotations.AfterClass;
24import org.testng.annotations.BeforeClass;
25import org.testng.annotations.Test;
26import validation.BaseTest;
27
28public class Xerces1128doc2Test extends BaseTest {
29
30    private final static String UNKNOWN_TYPE_ERROR = "cvc-type.1";
31
32    private final static String INVALID_DERIVATION_ERROR = "cvc-elt.4.3";
33
34    @BeforeClass
35    protected void setUp() throws Exception {
36        super.setUp();
37    }
38
39    @AfterClass
40    protected void tearDown() throws Exception {
41        super.tearDown();
42    }
43
44    protected String getXMLDocument() {
45        return "xerces1128_2.xml";
46    }
47
48    protected String getSchemaFile() {
49        return "xerces1128.xsd";
50    }
51
52    protected String[] getRelevantErrorIDs() {
53        return new String[] { UNKNOWN_TYPE_ERROR, INVALID_DERIVATION_ERROR };
54    }
55
56    public Xerces1128doc2Test(String name) {
57        super(name);
58    }
59
60
61    /**
62     * XERCESJ-1128 values for {validation attempted} property in PSVI
63     */
64    @Test
65    public void testDocument1() {
66        try {
67            reset();
68            validateDocument();
69        } catch (Exception e) {
70            fail("Validation failed: " + e.getMessage());
71        }
72
73        // default value of the feature is false
74        checkResult();
75    }
76
77    private void checkResult() {
78        PSVIElementNSImpl child = super.getChild(1);
79        assertValidity(ItemPSVI.VALIDITY_VALID, child.getValidity());
80        assertValidationAttempted(ItemPSVI.VALIDATION_FULL, child
81                .getValidationAttempted());
82        assertElementNull(child.getElementDeclaration());
83        assertTypeName("X", child.getTypeDefinition().getName());
84        assertTypeNamespaceNull(child.getTypeDefinition().getNamespace());
85
86        child = super.getChild(2);
87        assertValidity(ItemPSVI.VALIDITY_NOTKNOWN, child.getValidity());
88        assertValidationAttempted(ItemPSVI.VALIDATION_NONE, child
89                .getValidationAttempted());
90        assertElementNull(child.getElementDeclaration());
91        assertTypeName("anyType", child.getTypeDefinition().getName());
92        assertTypeNamespace("http://www.w3.org/2001/XMLSchema",
93                child.getTypeDefinition().getNamespace());
94
95    }
96}
97