jdk/test/javax/xml/jaxp/testng/validation/jdk8036951/Xerces1128doc2Test.java
author joehw
Mon, 13 Oct 2014 14:11:20 -0700
changeset 27037 5a6ef51923c4
permissions -rw-r--r--
8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java Reviewed-by: lancea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27037
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
     1
/*
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
     2
 * Licensed to the Apache Software Foundation (ASF) under one or more
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
     3
 * contributor license agreements.  See the NOTICE file distributed with
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
     4
 * this work for additional information regarding copyright ownership.
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
     5
 * The ASF licenses this file to You under the Apache License, Version 2.0
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
     6
 * (the "License"); you may not use this file except in compliance with
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
     7
 * the License.  You may obtain a copy of the License at
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
     8
 *
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
     9
 *      http://www.apache.org/licenses/LICENSE-2.0
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    10
 *
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    11
 * Unless required by applicable law or agreed to in writing, software
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    12
 * distributed under the License is distributed on an "AS IS" BASIS,
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    14
 * See the License for the specific language governing permissions and
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    15
 * limitations under the License.
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    16
 */
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
package validation.jdk8036951;
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    19
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    20
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    21
import com.sun.org.apache.xerces.internal.dom.PSVIElementNSImpl;
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    22
import com.sun.org.apache.xerces.internal.xs.ItemPSVI;
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    23
import org.testng.annotations.AfterClass;
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    24
import org.testng.annotations.BeforeClass;
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    25
import org.testng.annotations.Test;
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    26
import validation.BaseTest;
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    27
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    28
public class Xerces1128doc2Test extends BaseTest {
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    29
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    30
    private final static String UNKNOWN_TYPE_ERROR = "cvc-type.1";
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    31
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    32
    private final static String INVALID_DERIVATION_ERROR = "cvc-elt.4.3";
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    33
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    34
    @BeforeClass
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    35
    protected void setUp() throws Exception {
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    36
        super.setUp();
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
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    39
    @AfterClass
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    40
    protected void tearDown() throws Exception {
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    41
        super.tearDown();
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    42
    }
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 String getXMLDocument() {
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    45
        return "xerces1128_2.xml";
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
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    48
    protected String getSchemaFile() {
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    49
        return "xerces1128.xsd";
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    50
    }
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    51
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    52
    protected String[] getRelevantErrorIDs() {
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    53
        return new String[] { UNKNOWN_TYPE_ERROR, INVALID_DERIVATION_ERROR };
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    54
    }
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 Xerces1128doc2Test(String name) {
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    57
        super(name);
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    58
    }
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    59
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
     * XERCESJ-1128 values for {validation attempted} property in PSVI
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    63
     */
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    64
    @Test
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    65
    public void testDocument1() {
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    66
        try {
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    67
            reset();
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    68
            validateDocument();
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    69
        } catch (Exception e) {
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    70
            fail("Validation failed: " + e.getMessage());
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    71
        }
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    72
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    73
        // default value of the feature is false
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    74
        checkResult();
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    75
    }
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
    private void checkResult() {
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    78
        PSVIElementNSImpl child = super.getChild(1);
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    79
        assertValidity(ItemPSVI.VALIDITY_VALID, child.getValidity());
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    80
        assertValidationAttempted(ItemPSVI.VALIDATION_FULL, child
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    81
                .getValidationAttempted());
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    82
        assertElementNull(child.getElementDeclaration());
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    83
        assertTypeName("X", child.getTypeDefinition().getName());
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    84
        assertTypeNamespaceNull(child.getTypeDefinition().getNamespace());
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    85
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    86
        child = super.getChild(2);
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    87
        assertValidity(ItemPSVI.VALIDITY_NOTKNOWN, child.getValidity());
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    88
        assertValidationAttempted(ItemPSVI.VALIDATION_NONE, child
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    89
                .getValidationAttempted());
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    90
        assertElementNull(child.getElementDeclaration());
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    91
        assertTypeName("anyType", child.getTypeDefinition().getName());
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    92
        assertTypeNamespace("http://www.w3.org/2001/XMLSchema",
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    93
                child.getTypeDefinition().getNamespace());
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
    }
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    96
}