jdk/test/javax/xml/jaxp/testng/validation/jdk8037819/UseGrammarPoolOnlyTest_False.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
package validation.jdk8037819;
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.xs.ItemPSVI;
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    20
import org.testng.annotations.AfterClass;
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    21
import org.testng.annotations.BeforeClass;
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    22
import org.testng.annotations.Test;
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    23
import validation.BaseTest;
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    24
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    25
public class UseGrammarPoolOnlyTest_False extends BaseTest {
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    26
    private final static String UNKNOWN_TYPE_ERROR = "cvc-type.1";
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
    private final static String INVALID_DERIVATION_ERROR = "cvc-elt.4.3";
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
    protected String getXMLDocument() {
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    31
        return "otherNamespace.xml";
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    32
    }
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
    protected String getSchemaFile() {
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    35
        return "base.xsd";
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    36
    }
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 String[] getRelevantErrorIDs() {
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    39
        return new String[] { UNKNOWN_TYPE_ERROR, INVALID_DERIVATION_ERROR };
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
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    42
    protected boolean getUseGrammarPoolOnly() {
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    43
        return false;
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    44
    }
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    45
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    46
    public UseGrammarPoolOnlyTest_False(String name) {
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    47
        super(name);
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    48
    }
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
    @BeforeClass
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    51
    protected void setUp() throws Exception {
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    52
        super.setUp();
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    53
    }
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
    @AfterClass
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    56
    protected void tearDown() throws Exception {
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    57
        super.tearDown();
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
     * The purpose of this test is to check if setting the USE_GRAMMAR_POOL_ONLY
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    62
     * feature to true causes external schemas to not be read. This
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    63
     * functionality already existed prior to adding the XSLT 2.0 validation
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    64
     * features; however, because the class that controlled it changed, this
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    65
     * test simply ensures that the existing functionality did not disappear.
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    66
     * -PM
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
    @Test
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    69
    public void testUsingOnlyGrammarPool() {
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    70
        try {
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    71
            reset();
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    72
            validateDocument();
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    73
        } catch (Exception e) {
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    74
            fail("Validation failed: " + e.getMessage());
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
        assertValidity(ItemPSVI.VALIDITY_VALID, fRootNode.getValidity());
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    78
        assertValidationAttempted(ItemPSVI.VALIDATION_FULL, fRootNode
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    79
                .getValidationAttempted());
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    80
        assertElementName("A", fRootNode.getElementDeclaration().getName());
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    81
        assertElementNamespace("xslt.unittests", fRootNode
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    82
                .getElementDeclaration().getNamespace());
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    83
        assertTypeName("W", fRootNode.getTypeDefinition().getName());
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    84
        assertTypeNamespace("xslt.unittests", fRootNode.getTypeDefinition()
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    85
                .getNamespace());
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    86
    }
5a6ef51923c4 8036951: Xerces Update: XMLSchemaValidator.java and XMLSchemaLoader.java
joehw
parents:
diff changeset
    87
}