jdk/test/javax/xml/jaxp/testng/validation/8037819/IgnoreXSITypeTest_A_C.java
author joehw
Fri, 29 Aug 2014 11:59:34 -0700
changeset 26335 67078b90e47b
permissions -rw-r--r--
8037819: Xerces Update: jaxp/validation/XMLSchemaFactory Reviewed-by: lancea
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
public class IgnoreXSITypeTest_A_C extends BaseTest {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    25
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    26
    protected String getXMLDocument() {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    27
        return "xsitype_A_C.xml";
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    28
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    29
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    30
    protected String getSchemaFile() {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    31
        return "base.xsd";
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    32
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    33
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    34
    public IgnoreXSITypeTest_A_C(String name) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    35
        super(name);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    36
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    37
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    38
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    39
    @BeforeClass
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    40
    protected void setUp() throws Exception {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    41
        super.setUp();
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    42
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    43
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    44
    @AfterClass
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    45
    protected void tearDown() throws Exception {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    46
        super.tearDown();
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    47
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    48
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    49
    @Test
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    50
    public void testDefaultDocument() {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    51
        try {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    52
            reset();
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    53
            validateDocument();
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    54
        } catch (Exception e) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    55
            fail("Validation failed: " + e.getMessage());
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    56
        }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    57
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    58
        // default value of the feature is false
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    59
        checkFalseResult();
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    60
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    61
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    62
    @Test
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    63
    public void testDefaultFragment() {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    64
        try {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    65
            reset();
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    66
            validateFragment();
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    67
        } catch (Exception e) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    68
            fail("Validation failed: " + e.getMessage());
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    69
        }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    70
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    71
        // default value of the feature is false
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    72
        checkFalseResult();
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    73
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    74
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    75
    @Test
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    76
    public void testSetFalseDocument() {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    77
        try {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    78
            reset();
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    79
            fValidator.setFeature(IGNORE_XSI_TYPE, false);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    80
            validateDocument();
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    81
        } catch (Exception e) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    82
            fail("Validation failed: " + e.getMessage());
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    83
        }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    84
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    85
        checkFalseResult();
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    86
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    87
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    88
    @Test
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    89
    public void testSetFalseFragment() {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    90
        try {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    91
            reset();
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    92
            fValidator.setFeature(IGNORE_XSI_TYPE, false);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    93
            validateFragment();
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    94
        } catch (Exception e) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    95
            fail("Validation failed: " + e.getMessage());
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    96
        }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    97
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    98
        checkFalseResult();
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    99
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   100
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   101
    @Test
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   102
    public void testSetTrueDocument() {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   103
        try {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   104
            reset();
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   105
            fValidator.setFeature(IGNORE_XSI_TYPE, true);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   106
            validateDocument();
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   107
        } catch (Exception e) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   108
            fail("Validation failed: " + e.getMessage());
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   109
        }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   110
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   111
        checkTrueResult();
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   112
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   113
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   114
    @Test
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   115
    public void testSetTrueFragment() {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   116
        try {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   117
            reset();
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   118
            fValidator.setFeature(IGNORE_XSI_TYPE, true);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   119
            validateFragment();
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   120
        } catch (Exception e) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   121
            fail("Validation failed: " + e.getMessage());
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   122
        }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   123
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   124
        checkTrueResult();
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   125
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   126
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   127
    private void checkTrueResult() {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   128
        checkResult();
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   129
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   130
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   131
    private void checkFalseResult() {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   132
        checkResult();
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   133
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   134
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   135
    private void checkResult() {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   136
        assertValidity(ItemPSVI.VALIDITY_VALID, fRootNode.getValidity());
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   137
        assertValidationAttempted(ItemPSVI.VALIDATION_FULL, fRootNode
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   138
                .getValidationAttempted());
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   139
        assertElementName("A", fRootNode.getElementDeclaration().getName());
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   140
        assertTypeName("Y", fRootNode.getTypeDefinition().getName());
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   141
        assertTypeNamespaceNull(fRootNode.getTypeDefinition().getNamespace());
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   142
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   143
        PSVIElementNSImpl child = super.getChild(1);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   144
        assertValidity(ItemPSVI.VALIDITY_VALID, child.getValidity());
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   145
        assertValidationAttempted(ItemPSVI.VALIDATION_FULL, child
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   146
                .getValidationAttempted());
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   147
        assertElementNull(child.getElementDeclaration());
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   148
        assertTypeName("Y", child.getTypeDefinition().getName());
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   149
        assertTypeNamespaceNull(child.getTypeDefinition().getNamespace());
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   150
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   151
}