jdk/test/javax/xml/jaxp/testng/validation/8037819/BaseTest.java
author joehw
Fri, 29 Aug 2014 11:59:34 -0700
changeset 26335 67078b90e47b
permissions -rw-r--r--
8037819: Xerces Update: jaxp/validation/XMLSchemaFactory Reviewed-by: lancea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26335
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
     1
/*
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
     2
 * Licensed to the Apache Software Foundation (ASF) under one or more
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
     3
 * contributor license agreements.  See the NOTICE file distributed with
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
     4
 * this work for additional information regarding copyright ownership.
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
     5
 * The ASF licenses this file to You under the Apache License, Version 2.0
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
     6
 * (the "License"); you may not use this file except in compliance with
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
     7
 * the License.  You may obtain a copy of the License at
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
     8
 *
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
     9
 *      http://www.apache.org/licenses/LICENSE-2.0
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    10
 *
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    11
 * Unless required by applicable law or agreed to in writing, software
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    12
 * distributed under the License is distributed on an "AS IS" BASIS,
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    14
 * See the License for the specific language governing permissions and
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    15
 * limitations under the License.
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    16
 */
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    17
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    18
import java.io.File;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    19
import java.net.URL;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    20
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    21
import javax.xml.XMLConstants;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    22
import javax.xml.parsers.DocumentBuilder;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    23
import javax.xml.parsers.DocumentBuilderFactory;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    24
import javax.xml.transform.Result;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    25
import javax.xml.transform.Source;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    26
import javax.xml.transform.dom.DOMResult;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    27
import javax.xml.transform.dom.DOMSource;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    28
import javax.xml.validation.Schema;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    29
import javax.xml.validation.SchemaFactory;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    30
import javax.xml.validation.Validator;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    31
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    32
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    33
import com.sun.org.apache.xerces.internal.dom.PSVIElementNSImpl;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    34
import com.sun.org.apache.xerces.internal.impl.Constants;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    35
import com.sun.org.apache.xerces.internal.impl.xs.SchemaGrammar;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    36
import com.sun.org.apache.xerces.internal.xs.ElementPSVI;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    37
import com.sun.org.apache.xerces.internal.xs.ItemPSVI;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    38
import com.sun.org.apache.xerces.internal.xs.XSElementDeclaration;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    39
import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    40
import javax.xml.transform.stream.StreamSource;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    41
import org.w3c.dom.Document;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    42
import org.w3c.dom.Node;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    43
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    44
public abstract class BaseTest {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    45
    protected final static String ROOT_TYPE = Constants.XERCES_PROPERTY_PREFIX
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    46
            + Constants.ROOT_TYPE_DEFINITION_PROPERTY;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    47
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    48
    protected final static String IGNORE_XSI_TYPE = Constants.XERCES_FEATURE_PREFIX
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    49
            + Constants.IGNORE_XSI_TYPE_FEATURE;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    50
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    51
    protected final static String ID_IDREF_CHECKING = Constants.XERCES_FEATURE_PREFIX
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    52
            + Constants.ID_IDREF_CHECKING_FEATURE;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    53
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    54
    protected final static String IDC_CHECKING = Constants.XERCES_FEATURE_PREFIX
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    55
            + Constants.IDC_CHECKING_FEATURE;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    56
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    57
    protected final static String UNPARSED_ENTITY_CHECKING = Constants.XERCES_FEATURE_PREFIX
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    58
            + Constants.UNPARSED_ENTITY_CHECKING_FEATURE;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    59
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    60
    protected final static String USE_GRAMMAR_POOL_ONLY = Constants.XERCES_FEATURE_PREFIX
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    61
            + Constants.USE_GRAMMAR_POOL_ONLY_FEATURE;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    62
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    63
    protected final static String DYNAMIC_VALIDATION = Constants.XERCES_FEATURE_PREFIX
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    64
            + Constants.DYNAMIC_VALIDATION_FEATURE;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    65
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    66
    protected final static String DOCUMENT_CLASS_NAME = Constants.XERCES_PROPERTY_PREFIX
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    67
            + Constants.DOCUMENT_CLASS_NAME_PROPERTY;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    68
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    69
    protected Schema schema;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    70
    protected Validator fValidator;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    71
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    72
    protected SpecialCaseErrorHandler fErrorHandler;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    73
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    74
    DocumentBuilder builder;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    75
    protected Document fDocument;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    76
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    77
    protected ElementPSVI fRootNode;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    78
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    79
    protected URL fDocumentURL;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    80
    protected String documentPath;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    81
    protected String fDocumentId;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    82
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    83
    static String errMessage;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    84
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    85
    int passed = 0, failed = 0;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    86
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    87
    public static boolean isWindows = false;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    88
    static {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    89
        if (System.getProperty("os.name").indexOf("Windows")>-1) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    90
            isWindows = true;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    91
        }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    92
    };
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    93
    public static final String USER_DIR = System.getProperty("user.dir", ".");
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    94
    public static final String BASE_DIR = System.getProperty("test.src", USER_DIR)
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    95
            .replaceAll("\\" + System.getProperty("file.separator"), "/");
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    96
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    97
    protected abstract String getSchemaFile();
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    98
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
    99
    protected abstract String getXMLDocument();
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   100
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   101
    public BaseTest(String name) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   102
        fErrorHandler = new SpecialCaseErrorHandler(getRelevantErrorIDs());
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   103
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   104
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   105
    protected void setUp() throws Exception {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   106
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   107
        DocumentBuilderFactory docFactory = DocumentBuilderFactory
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   108
                .newInstance();
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   109
        docFactory.setAttribute(DOCUMENT_CLASS_NAME,
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   110
                "com.sun.org.apache.xerces.internal.dom.PSVIDocumentImpl");
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   111
        docFactory.setNamespaceAware(true);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   112
        builder = docFactory.newDocumentBuilder();
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   113
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   114
        documentPath = BASE_DIR + "/" + getXMLDocument();
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   115
System.out.println("documentPath:"+documentPath);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   116
        if (isWindows) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   117
            fDocumentId = "file:/" + documentPath;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   118
        } else {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   119
            fDocumentId = "file:" + documentPath;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   120
        }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   121
        //fDocumentURL = ClassLoader.getSystemResource(documentPath);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   122
        //fDocumentURL = getClass().getResource(documentPath);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   123
System.out.println("fDocumentId:"+fDocumentId);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   124
//System.out.println("fDocumentURL.toExternalForm:"+fDocumentURL.toExternalForm());
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   125
/**
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   126
        if (fDocumentURL == null) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   127
            throw new FileNotFoundException("Couldn't find xml file for test: " + documentPath);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   128
        }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   129
        fDocument = builder.parse(fDocumentURL.toExternalForm());
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   130
        fRootNode = (ElementPSVI) fDocument.getDocumentElement();
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   131
        */
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   132
        SchemaFactory sf = SchemaFactory
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   133
                .newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   134
        sf.setFeature(USE_GRAMMAR_POOL_ONLY, getUseGrammarPoolOnly());
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   135
        String schemaPath = BASE_DIR + "/" + getSchemaFile();
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   136
        /**
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   137
        URL schemaURL = ClassLoader.getSystemResource(schemaPath);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   138
        if (schemaURL == null) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   139
            throw new FileNotFoundException("Couldn't find schema file for test: " + schemaPath);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   140
        }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   141
        */
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   142
        schema = sf.newSchema(new StreamSource(new File(schemaPath)));
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   143
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   144
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   145
    protected void tearDown() throws Exception {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   146
        fValidator = null;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   147
        fDocument = null;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   148
        fRootNode = null;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   149
        fErrorHandler.reset();
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   150
        System.out.println("\nNumber of tests passed: " + passed);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   151
        System.out.println("Number of tests failed: " + failed + "\n");
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   152
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   153
        if (errMessage != null) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   154
            throw new RuntimeException(errMessage);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   155
        }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   156
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   157
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   158
    protected void validateDocument() throws Exception {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   159
        Source source = new DOMSource(fDocument);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   160
        source.setSystemId(fDocumentId);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   161
        Result result = new DOMResult(fDocument);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   162
        fValidator.validate(source, result);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   163
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   164
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   165
    protected void validateFragment() throws Exception {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   166
        Source source = new DOMSource((Node) fRootNode);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   167
        source.setSystemId(fDocumentId);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   168
        Result result = new DOMResult((Node) fRootNode);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   169
        fValidator.validate(source, result);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   170
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   171
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   172
    protected void reset() throws Exception {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   173
        try {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   174
System.out.println("new File(documentPath)" + new File(documentPath));
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   175
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   176
        fDocument = builder.parse(new File(documentPath));
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   177
        fRootNode = (ElementPSVI) fDocument.getDocumentElement();
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   178
System.out.println("fDocument" + fDocument);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   179
System.out.println("fRootNode" + fRootNode);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   180
        fValidator = schema.newValidator();
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   181
        fErrorHandler.reset();
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   182
        fValidator.setErrorHandler(fErrorHandler);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   183
        fValidator.setFeature(DYNAMIC_VALIDATION, false);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   184
        } catch (Exception e) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   185
            e.printStackTrace();
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   186
        }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   187
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   188
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   189
    protected PSVIElementNSImpl getChild(int n) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   190
        int numFound = 0;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   191
        Node child = ((Node) fRootNode).getFirstChild();
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   192
        while (child != null) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   193
            if (child.getNodeType() == Node.ELEMENT_NODE) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   194
                numFound++;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   195
                if (numFound == n) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   196
                    return (PSVIElementNSImpl) child;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   197
                }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   198
            }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   199
            child = child.getNextSibling();
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   200
        }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   201
        return null;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   202
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   203
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   204
    protected String[] getRelevantErrorIDs() {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   205
        return new String[] {};
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   206
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   207
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   208
    protected boolean getUseGrammarPoolOnly() {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   209
        return false;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   210
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   211
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   212
    // specialized asserts
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   213
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   214
    protected void assertValidity(short expectedValidity, short actualValidity) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   215
        String expectedString = expectedValidity == ItemPSVI.VALIDITY_VALID ? "valid"
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   216
                : (expectedValidity == ItemPSVI.VALIDITY_INVALID ? "invalid"
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   217
                        : "notKnown");
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   218
        String actualString = actualValidity == ItemPSVI.VALIDITY_VALID ? "valid"
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   219
                : (actualValidity == ItemPSVI.VALIDITY_INVALID ? "invalid"
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   220
                        : "notKnown");
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   221
        String message = "{validity} was <" + actualString
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   222
                + "> but it should have been <" + expectedString + ">";
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   223
        assertEquals(message, expectedValidity, actualValidity);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   224
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   225
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   226
    protected void assertValidationAttempted(short expectedAttempted,
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   227
            short actualAttempted) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   228
        String expectedString = expectedAttempted == ItemPSVI.VALIDATION_FULL ? "full"
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   229
                : (expectedAttempted == ItemPSVI.VALIDATION_PARTIAL ? "partial"
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   230
                        : "none");
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   231
        String actualString = actualAttempted == ItemPSVI.VALIDATION_FULL ? "full"
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   232
                : (actualAttempted == ItemPSVI.VALIDATION_PARTIAL ? "partial"
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   233
                        : "none");
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   234
        String message = "{validity} was <" + actualString
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   235
                + "> but it should have been <" + expectedString + ">";
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   236
        assertEquals(message, expectedAttempted, actualAttempted);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   237
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   238
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   239
    protected void assertElementName(String expectedName, String actualName) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   240
        assertEquals("Local name of element declaration is wrong.",
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   241
                expectedName, actualName);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   242
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   243
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   244
    protected void assertElementNull(XSElementDeclaration elem) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   245
        assertNull("Element declaration should be null.", elem);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   246
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   247
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   248
    protected void assertElementNamespace(String expectedName, String actualName) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   249
        assertEquals("Namespace of element declaration is wrong.",
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   250
                expectedName, actualName);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   251
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   252
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   253
    protected void assertElementNamespaceNull(String actualName) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   254
        assertNull("Local name of element declaration should be null.",
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   255
                actualName);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   256
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   257
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   258
    protected void assertTypeName(String expectedName, String actualName) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   259
        assertEquals("Local name of type definition is wrong.", expectedName,
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   260
                actualName);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   261
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   262
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   263
    protected void assertTypeNull(XSTypeDefinition type) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   264
        assertNull("Type definition should be null.", type);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   265
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   266
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   267
    protected void assertTypeNamespace(String expectedName, String actualName) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   268
        assertEquals("Namespace of type definition is wrong.", expectedName,
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   269
                actualName);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   270
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   271
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   272
    protected void assertTypeNamespaceNull(String actualName) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   273
        assertNull("Namespace of type definition should be null.", actualName);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   274
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   275
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   276
    protected void assertError(String error) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   277
        assertTrue("Error <" + error + "> should have occured, but did not.",
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   278
                fErrorHandler.specialCaseFound(error));
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   279
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   280
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   281
    protected void assertNoError(String error) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   282
        assertFalse("Error <" + error
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   283
                + "> should not have occured (but it did)", fErrorHandler
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   284
                .specialCaseFound(error));
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   285
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   286
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   287
    protected void assertAnyType(XSTypeDefinition type) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   288
        assertEquals("Type is supposed to be anyType", SchemaGrammar.fAnyType,
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   289
                type);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   290
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   291
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   292
    void assertEquals(String msg, Object expected, Object actual) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   293
        if (!expected.equals(actual)) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   294
            fail(msg + " Expected: " + expected + " Actual: " + actual);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   295
        } else {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   296
            success(null);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   297
        }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   298
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   299
    void assertNull(String msg, Object value) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   300
        if (value != null) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   301
            fail(msg);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   302
        } else {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   303
            success(null);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   304
        }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   305
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   306
    void assertTrue(String msg, boolean value) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   307
        if (!value) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   308
            fail(msg);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   309
        } else {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   310
            success(null);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   311
        }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   312
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   313
    void assertFalse(String msg, boolean value) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   314
        if (value) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   315
            fail(msg);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   316
        } else {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   317
            success(null);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   318
        }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   319
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   320
    void fail(String errMsg) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   321
        if (errMessage == null) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   322
            errMessage = errMsg;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   323
        } else {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   324
            errMessage = errMessage + "\n" + errMsg;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   325
        }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   326
        failed++;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   327
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   328
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   329
    void success(String msg) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   330
        passed++;
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   331
        System.out.println(msg);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   332
        if (msg != null) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   333
            if (msg.length() != 0) {
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   334
                System.out.println(msg);
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   335
            }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   336
        }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   337
    }
67078b90e47b 8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
joehw
parents:
diff changeset
   338
}