Path: blob/master/test/jdk/javax/xml/jaxp/testng/validation/jdk8037819/BasicTest.java
41159 views
/*1* Licensed to the Apache Software Foundation (ASF) under one or more2* contributor license agreements. See the NOTICE file distributed with3* this work for additional information regarding copyright ownership.4* The ASF licenses this file to You under the Apache License, Version 2.05* (the "License"); you may not use this file except in compliance with6* the License. You may obtain a copy of the License at7*8* http://www.apache.org/licenses/LICENSE-2.09*10* Unless required by applicable law or agreed to in writing, software11* distributed under the License is distributed on an "AS IS" BASIS,12* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13* See the License for the specific language governing permissions and14* limitations under the License.15*/1617package validation.jdk8037819;1819import com.sun.org.apache.xerces.internal.dom.PSVIElementNSImpl;20import com.sun.org.apache.xerces.internal.xs.ItemPSVI;21import org.testng.annotations.AfterClass;22import org.testng.annotations.BeforeClass;23import org.testng.annotations.Test;24import validation.BaseTest;2526public class BasicTest extends BaseTest {2728protected String getXMLDocument() {29return "base.xml";30}3132protected String getSchemaFile() {33return "base.xsd";34}3536public BasicTest(String name) {37super(name);38}3940@BeforeClass41protected void setUp() throws Exception {42super.setUp();43}4445@AfterClass46protected void tearDown() throws Exception {47super.tearDown();48}4950@Test51public void testSimpleValidation() {52try {53reset();54validateDocument();55} catch (Exception e) {56fail("Validation failed: " + e.getMessage());57}58doValidityAsserts();59}6061@Test62public void testSimpleValidationWithTrivialXSIType() {63try {64reset();65((PSVIElementNSImpl) fRootNode).setAttributeNS(66"http://www.w3.org/2001/XMLSchema-instance", "type", "X");67validateDocument();68} catch (Exception e) {69fail("Validation failed: " + e.getMessage());70}71doValidityAsserts();72}7374private void doValidityAsserts() {75assertValidity(ItemPSVI.VALIDITY_VALID, fRootNode.getValidity());76assertValidationAttempted(ItemPSVI.VALIDATION_FULL, fRootNode77.getValidationAttempted());78assertElementName("A", fRootNode.getElementDeclaration().getName());79assertElementNamespaceNull(fRootNode.getElementDeclaration()80.getNamespace());81assertTypeName("X", fRootNode.getTypeDefinition().getName());82assertTypeNamespaceNull(fRootNode.getTypeDefinition().getNamespace());83}84}858687