jaxp/test/javax/xml/jaxp/unittest/validation/tck/ParticleTest.java
author fyuan
Mon, 08 Aug 2016 12:50:00 +0800
changeset 40223 64662417aa2d
parent 34461 f346a0b2b7f9
child 40829 ad509d5baa06
permissions -rw-r--r--
8067170: Enable security manager on JAXP unit tests and make some improvement 8130494: [TESTBUG] 2 jaxp test cases are failing 8160216: jaxp/test/javax/xml/jaxp/unittest/validation/Bug6457662.java should clean up better Reviewed-by: joehw, dfuchs, amlu Contributed-by: Frank Yuan <frank.yuan@oracle.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34461
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
     1
/*
40223
64662417aa2d 8067170: Enable security manager on JAXP unit tests and make some improvement
fyuan
parents: 34461
diff changeset
     2
 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
34461
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
     4
 *
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
     7
 * published by the Free Software Foundation.
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
     8
 *
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    13
 * accompanied this code).
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    14
 *
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    18
 *
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    21
 * questions.
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    22
 */
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    23
package validation.tck;
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    24
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    25
import java.io.IOException;
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    26
import javax.xml.XMLConstants;
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    27
import javax.xml.transform.stream.StreamSource;
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    28
import javax.xml.validation.Schema;
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    29
import javax.xml.validation.SchemaFactory;
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    30
import javax.xml.validation.Validator;
40223
64662417aa2d 8067170: Enable security manager on JAXP unit tests and make some improvement
fyuan
parents: 34461
diff changeset
    31
import org.testng.annotations.Listeners;
34461
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    32
import org.testng.annotations.Test;
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    33
import org.xml.sax.SAXException;
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    34
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    35
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    36
/*
40223
64662417aa2d 8067170: Enable security manager on JAXP unit tests and make some improvement
fyuan
parents: 34461
diff changeset
    37
 * @test
34461
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    38
 * @bug 8142463
40223
64662417aa2d 8067170: Enable security manager on JAXP unit tests and make some improvement
fyuan
parents: 34461
diff changeset
    39
 * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
64662417aa2d 8067170: Enable security manager on JAXP unit tests and make some improvement
fyuan
parents: 34461
diff changeset
    40
 * @run testng/othervm -DrunSecMngr=true validation.tck.ParticleTest
64662417aa2d 8067170: Enable security manager on JAXP unit tests and make some improvement
fyuan
parents: 34461
diff changeset
    41
 * @run testng/othervm validation.tck.ParticleTest
34461
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    42
 * @summary Tests that verify bug fixes for Particles (http://www.w3.org/TR/xmlschema11-1/#cParticles)
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    43
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    44
 * @author Joe Wang (huizhe.wang@oracle.com)
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    45
 */
40223
64662417aa2d 8067170: Enable security manager on JAXP unit tests and make some improvement
fyuan
parents: 34461
diff changeset
    46
@Listeners({jaxp.library.FilePolicy.class})
34461
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    47
public class ParticleTest {
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    48
    static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    49
    static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    50
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    51
    /*
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    52
       @bug 8142463
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    53
       This test verifies the fix for a missing flag that indicates the DFA
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    54
       is compacted for UPA. Without the fix, the 2nd foo:foo element was
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    55
       rejected.
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    56
    */
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    57
    @Test
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    58
    public void test() throws SAXException, IOException {
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    59
        SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    60
        Schema schema = schemaFactory.newSchema(new StreamSource(ParticleTest.class.getResourceAsStream("upa01.xsd")));
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    61
        Validator validator = schema.newValidator();
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    62
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    63
        validator.validate(new StreamSource(ParticleTest.class.getResourceAsStream("upa01.xml")));
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    64
    }
f346a0b2b7f9 8142463: Xml schema validation failing after Xerces update; maxOccurs ignored
joehw
parents:
diff changeset
    65
}
40223
64662417aa2d 8067170: Enable security manager on JAXP unit tests and make some improvement
fyuan
parents: 34461
diff changeset
    66