< prev index next >

test/javax/xml/jaxp/unittest/common/ValidationWarningsTest.java

Print this page




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 package common;
  25 
  26 import java.io.ByteArrayInputStream;
  27 import java.io.StringReader;

  28 import javax.xml.XMLConstants;
  29 import javax.xml.transform.Source;
  30 import javax.xml.transform.sax.SAXSource;
  31 import javax.xml.transform.stream.StreamSource;
  32 import javax.xml.validation.Schema;
  33 import javax.xml.validation.SchemaFactory;
  34 import javax.xml.validation.Validator;
  35 import org.testng.annotations.Test;
  36 import org.testng.annotations.BeforeClass;


  37 import org.xml.sax.InputSource;
  38 
  39 /*
  40  * @test
  41  * @modules javax.xml/com.sun.org.apache.xerces.internal.jaxp
  42  * @bug 8144593
  43  * @summary Check that warnings about unsupported properties from SAX
  44  *  parsers are suppressed during the xml validation process.
  45  */

  46 public class ValidationWarningsTest extends WarningsTestBase {
  47 
  48     @BeforeClass
  49     public void setup() {
  50         //Set test SAX driver implementation.
  51         System.setProperty("org.xml.sax.driver", "common.TestSAXDriver");
  52     }
  53 
  54     @Test
  55     public void testValidation() throws Exception {
  56         startTest();
  57     }
  58 
  59     //One iteration of xml validation test case. It will be called from each
  60     //TestWorker task defined in WarningsTestBase class.
  61     void doOneTestIteration() throws Exception {
  62         Source src = new StreamSource(new StringReader(xml));
  63         SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
  64         SAXSource xsdSource = new SAXSource(new InputSource(new ByteArrayInputStream(xsd.getBytes())));
  65         Schema schema = schemaFactory.newSchema(xsdSource);


   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 package common;
  25 
  26 import java.io.ByteArrayInputStream;
  27 import java.io.StringReader;
  28 
  29 import javax.xml.XMLConstants;
  30 import javax.xml.transform.Source;
  31 import javax.xml.transform.sax.SAXSource;
  32 import javax.xml.transform.stream.StreamSource;
  33 import javax.xml.validation.Schema;
  34 import javax.xml.validation.SchemaFactory;
  35 import javax.xml.validation.Validator;
  36 
  37 import org.testng.annotations.BeforeClass;
  38 import org.testng.annotations.Listeners;
  39 import org.testng.annotations.Test;
  40 import org.xml.sax.InputSource;
  41 
  42 /*
  43  * @test

  44  * @bug 8144593
  45  * @summary Check that warnings about unsupported properties from SAX
  46  *  parsers are suppressed during the xml validation process.
  47  */
  48 @Listeners({jaxp.library.InternalAPIPolicy.class})
  49 public class ValidationWarningsTest extends WarningsTestBase {
  50 
  51     @BeforeClass
  52     public void setup() {
  53         //Set test SAX driver implementation.
  54         System.setProperty("org.xml.sax.driver", "common.TestSAXDriver");
  55     }
  56 
  57     @Test
  58     public void testValidation() throws Exception {
  59         startTest();
  60     }
  61 
  62     //One iteration of xml validation test case. It will be called from each
  63     //TestWorker task defined in WarningsTestBase class.
  64     void doOneTestIteration() throws Exception {
  65         Source src = new StreamSource(new StringReader(xml));
  66         SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
  67         SAXSource xsdSource = new SAXSource(new InputSource(new ByteArrayInputStream(xsd.getBytes())));
  68         Schema schema = schemaFactory.newSchema(xsdSource);
< prev index next >