jdk/test/javax/xml/jaxp/testng/validation/8037819/FixedAttrTest.java
author lana
Thu, 16 Oct 2014 14:15:58 -0700
changeset 27113 28c10766cfac
parent 26335 67078b90e47b
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26335
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
     1
/*
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
     2
 * Licensed to the Apache Software Foundation (ASF) under one or more
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
     3
 * contributor license agreements.  See the NOTICE file distributed with
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
     4
 * this work for additional information regarding copyright ownership.
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
     5
 * The ASF licenses this file to You under the Apache License, Version 2.0
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
     6
 * (the "License"); you may not use this file except in compliance with
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
     7
 * the License.  You may obtain a copy of the License at
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
     8
 *
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
     9
 *      http://www.apache.org/licenses/LICENSE-2.0
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    10
 *
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    11
 * Unless required by applicable law or agreed to in writing, software
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    12
 * distributed under the License is distributed on an "AS IS" BASIS,
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    14
 * See the License for the specific language governing permissions and
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    15
 * limitations under the License.
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    16
 */
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    17
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    18
import com.sun.org.apache.xerces.internal.dom.PSVIElementNSImpl;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    19
import com.sun.org.apache.xerces.internal.xs.ItemPSVI;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    20
import org.testng.annotations.AfterClass;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    21
import org.testng.annotations.BeforeClass;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    22
import org.testng.annotations.Test;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    23
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    24
/**
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    25
 * The purpose of this test is to execute all of the isComparable calls in
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    26
 * XMLSchemaValidator. There are two calls in processElementContent and two
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    27
 * calls in processOneAttribute.
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    28
 *
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    29
 * @author peterjm
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    30
 */
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    31
public class FixedAttrTest extends BaseTest {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    32
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    33
    protected String getXMLDocument() {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    34
        return "fixedAttr.xml";
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    35
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    36
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    37
    protected String getSchemaFile() {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    38
        return "base.xsd";
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    39
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    40
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    41
    public FixedAttrTest(String name) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    42
        super(name);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    43
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    44
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    45
    @BeforeClass
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    46
    protected void setUp() throws Exception {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    47
        super.setUp();
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    48
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    49
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    50
    @AfterClass
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    51
    protected void tearDown() throws Exception {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    52
        super.tearDown();
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    53
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    54
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    55
    @Test
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    56
    public void testDefault() {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    57
        try {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    58
            reset();
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    59
            validateDocument();
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    60
        } catch (Exception e) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    61
            fail("Validation failed: " + e.getMessage());
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    62
        }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    63
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    64
        assertValidity(ItemPSVI.VALIDITY_VALID, fRootNode.getValidity());
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    65
        assertValidationAttempted(ItemPSVI.VALIDATION_FULL, fRootNode
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    66
                .getValidationAttempted());
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    67
        assertElementName("A", fRootNode.getElementDeclaration().getName());
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    68
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    69
        PSVIElementNSImpl child = super.getChild(1);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    70
        assertValidity(ItemPSVI.VALIDITY_VALID, child.getValidity());
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    71
        assertValidationAttempted(ItemPSVI.VALIDATION_FULL, child
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    72
                .getValidationAttempted());
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    73
        assertElementName("B", child.getElementDeclaration().getName());
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    74
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    75
        child = super.getChild(2);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    76
        assertValidity(ItemPSVI.VALIDITY_VALID, child.getValidity());
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    77
        assertValidationAttempted(ItemPSVI.VALIDATION_FULL, child
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    78
                .getValidationAttempted());
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    79
        assertElementName("D", child.getElementDeclaration().getName());
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    80
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    81
}