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 */ 17package validation.jdk8037819; 18 19import com.sun.org.apache.xerces.internal.xs.ItemPSVI; 20import org.testng.annotations.AfterClass; 21import org.testng.annotations.BeforeClass; 22import org.testng.annotations.Test; 23import validation.BaseTest; 24 25public class UseGrammarPoolOnlyTest_False extends BaseTest { 26 private final static String UNKNOWN_TYPE_ERROR = "cvc-type.1"; 27 28 private final static String INVALID_DERIVATION_ERROR = "cvc-elt.4.3"; 29 30 protected String getXMLDocument() { 31 return "otherNamespace.xml"; 32 } 33 34 protected String getSchemaFile() { 35 return "base.xsd"; 36 } 37 38 protected String[] getRelevantErrorIDs() { 39 return new String[] { UNKNOWN_TYPE_ERROR, INVALID_DERIVATION_ERROR }; 40 } 41 42 protected boolean getUseGrammarPoolOnly() { 43 return false; 44 } 45 46 public UseGrammarPoolOnlyTest_False(String name) { 47 super(name); 48 } 49 50 @BeforeClass 51 protected void setUp() throws Exception { 52 super.setUp(); 53 } 54 55 @AfterClass 56 protected void tearDown() throws Exception { 57 super.tearDown(); 58 } 59 60 /** 61 * The purpose of this test is to check if setting the USE_GRAMMAR_POOL_ONLY 62 * feature to true causes external schemas to not be read. This 63 * functionality already existed prior to adding the XSLT 2.0 validation 64 * features; however, because the class that controlled it changed, this 65 * test simply ensures that the existing functionality did not disappear. 66 * -PM 67 */ 68 @Test 69 public void testUsingOnlyGrammarPool() { 70 try { 71 reset(); 72 validateDocument(); 73 } catch (Exception e) { 74 fail("Validation failed: " + e.getMessage()); 75 } 76 77 assertValidity(ItemPSVI.VALIDITY_VALID, fRootNode.getValidity()); 78 assertValidationAttempted(ItemPSVI.VALIDATION_FULL, fRootNode 79 .getValidationAttempted()); 80 assertElementName("A", fRootNode.getElementDeclaration().getName()); 81 assertElementNamespace("xslt.unittests", fRootNode 82 .getElementDeclaration().getNamespace()); 83 assertTypeName("W", fRootNode.getTypeDefinition().getName()); 84 assertTypeNamespace("xslt.unittests", fRootNode.getTypeDefinition() 85 .getNamespace()); 86 } 87} 88