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.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;
25
26/**
27 * The purpose of this test is to execute all of the isComparable calls in
28 * XMLSchemaValidator. There are two calls in processElementContent and two
29 * calls in processOneAttribute.
30 *
31 * @author peterjm
32 */
33public class FixedAttrTest extends BaseTest {
34
35    protected String getXMLDocument() {
36        return "fixedAttr.xml";
37    }
38
39    protected String getSchemaFile() {
40        return "base.xsd";
41    }
42
43    public FixedAttrTest(String name) {
44        super(name);
45    }
46
47    @BeforeClass
48    protected void setUp() throws Exception {
49        super.setUp();
50    }
51
52    @AfterClass
53    protected void tearDown() throws Exception {
54        super.tearDown();
55    }
56
57    @Test
58    public void testDefault() {
59        try {
60            reset();
61            validateDocument();
62        } catch (Exception e) {
63            fail("Validation failed: " + e.getMessage());
64        }
65
66        assertValidity(ItemPSVI.VALIDITY_VALID, fRootNode.getValidity());
67        assertValidationAttempted(ItemPSVI.VALIDATION_FULL, fRootNode
68                .getValidationAttempted());
69        assertElementName("A", fRootNode.getElementDeclaration().getName());
70
71        PSVIElementNSImpl child = super.getChild(1);
72        assertValidity(ItemPSVI.VALIDITY_VALID, child.getValidity());
73        assertValidationAttempted(ItemPSVI.VALIDATION_FULL, child
74                .getValidationAttempted());
75        assertElementName("B", child.getElementDeclaration().getName());
76
77        child = super.getChild(2);
78        assertValidity(ItemPSVI.VALIDITY_VALID, child.getValidity());
79        assertValidationAttempted(ItemPSVI.VALIDATION_FULL, child
80                .getValidationAttempted());
81        assertElementName("D", child.getElementDeclaration().getName());
82    }
83}
84