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