jdk/test/javax/xml/jaxp/testng/validation/8037819/BasicTest.java
changeset 27129 98b357b2e8a6
parent 27128 d1480cb49283
parent 27116 64a78dd93766
child 27130 41df50e7303d
equal deleted inserted replaced
27128:d1480cb49283 27129:98b357b2e8a6
     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 
       
    18 import com.sun.org.apache.xerces.internal.dom.PSVIElementNSImpl;
       
    19 import com.sun.org.apache.xerces.internal.xs.ItemPSVI;
       
    20 import org.testng.annotations.AfterClass;
       
    21 import org.testng.annotations.BeforeClass;
       
    22 import org.testng.annotations.Test;
       
    23 
       
    24 public class BasicTest extends BaseTest {
       
    25 
       
    26     protected String getXMLDocument() {
       
    27         return "base.xml";
       
    28     }
       
    29 
       
    30     protected String getSchemaFile() {
       
    31         return "base.xsd";
       
    32     }
       
    33 
       
    34     public BasicTest(String name) {
       
    35         super(name);
       
    36     }
       
    37 
       
    38     @BeforeClass
       
    39     protected void setUp() throws Exception {
       
    40         super.setUp();
       
    41     }
       
    42 
       
    43     @AfterClass
       
    44     protected void tearDown() throws Exception {
       
    45         super.tearDown();
       
    46     }
       
    47 
       
    48     @Test
       
    49     public void testSimpleValidation() {
       
    50         try {
       
    51             reset();
       
    52             validateDocument();
       
    53         } catch (Exception e) {
       
    54             fail("Validation failed: " + e.getMessage());
       
    55         }
       
    56         doValidityAsserts();
       
    57     }
       
    58 
       
    59     @Test
       
    60     public void testSimpleValidationWithTrivialXSIType() {
       
    61         try {
       
    62             reset();
       
    63             ((PSVIElementNSImpl) fRootNode).setAttributeNS(
       
    64                 "http://www.w3.org/2001/XMLSchema-instance", "type", "X");
       
    65             validateDocument();
       
    66         } catch (Exception e) {
       
    67             fail("Validation failed: " + e.getMessage());
       
    68         }
       
    69         doValidityAsserts();
       
    70     }
       
    71 
       
    72     private void doValidityAsserts() {
       
    73         assertValidity(ItemPSVI.VALIDITY_VALID, fRootNode.getValidity());
       
    74         assertValidationAttempted(ItemPSVI.VALIDATION_FULL, fRootNode
       
    75                 .getValidationAttempted());
       
    76         assertElementName("A", fRootNode.getElementDeclaration().getName());
       
    77         assertElementNamespaceNull(fRootNode.getElementDeclaration()
       
    78                 .getNamespace());
       
    79         assertTypeName("X", fRootNode.getTypeDefinition().getName());
       
    80         assertTypeNamespaceNull(fRootNode.getTypeDefinition().getNamespace());
       
    81     }
       
    82 }