1package validation.jdk8037819;
2
3import com.sun.org.apache.xerces.internal.dom.PSVIElementNSImpl;
4import com.sun.org.apache.xerces.internal.xs.ItemPSVI;
5import validation.BaseTest;
6
7public class BasicTest1 extends BaseTest {
8    public static void main(String[] args) throws Exception {
9        BasicTest1 test = new BasicTest1();
10        test.setUp();
11        test.testSimpleValidation();
12        test.testSimpleValidationWithTrivialXSIType();
13        test.tearDown();
14    }
15
16    protected String getXMLDocument() {
17        return "base.xml";
18    }
19
20    protected String getSchemaFile() {
21        return "base.xsd";
22    }
23
24    public BasicTest1() {
25        super("BasicTest1");
26    }
27
28    protected void setUp() throws Exception {
29        super.setUp();
30    }
31
32    protected void tearDown() throws Exception {
33        super.tearDown();
34    }
35
36    public void testSimpleValidation() {
37        try {
38            reset();
39            validateDocument();
40        } catch (Exception e) {
41            fail("Validation failed: " + e.getMessage());
42        }
43        doValidityAsserts();
44    }
45
46    public void testSimpleValidationWithTrivialXSIType() {
47        try {
48            reset();
49            ((PSVIElementNSImpl) fRootNode).setAttributeNS(
50                "http://www.w3.org/2001/XMLSchema-instance", "type", "X");
51            validateDocument();
52        } catch (Exception e) {
53            fail("Validation failed: " + e.getMessage());
54        }
55        doValidityAsserts();
56    }
57
58    private void doValidityAsserts() {
59        assertValidity(ItemPSVI.VALIDITY_VALID, fRootNode.getValidity());
60        assertValidationAttempted(ItemPSVI.VALIDATION_FULL, fRootNode
61                .getValidationAttempted());
62        assertElementName("A", fRootNode.getElementDeclaration().getName());
63        assertElementNamespaceNull(fRootNode.getElementDeclaration()
64                .getNamespace());
65        assertTypeName("X", fRootNode.getTypeDefinition().getName());
66        assertTypeNamespaceNull(fRootNode.getTypeDefinition().getNamespace());
67    }
68}
69