< prev index next >

test/javax/xml/jaxp/functional/test/astro/SchemaValidationTest.java

Print this page




  59     }
  60 
  61     /*
  62      * Test SAXException shall be thrown if schemaSource is set but
  63      * schemaLanguage is not set.
  64      */
  65     @Test(expectedExceptions = SAXException.class)
  66     public void testSchemaValidationNeg() throws Exception {
  67         SAXParser sp = getValidatingParser();
  68         sp.setProperty(JAXP_SCHEMA_SOURCE, "catalog.xsd");
  69         sp.parse(new File(ASTROCAT), new DefaultHandler());
  70     }
  71 
  72     private SAXParser getValidatingParser() throws ParserConfigurationException, SAXException {
  73         SAXParserFactory spf = SAXParserFactory.newInstance();
  74         spf.setNamespaceAware(true);
  75         spf.setValidating(true);
  76         return spf.newSAXParser();
  77     }
  78 }
  79 


  59     }
  60 
  61     /*
  62      * Test SAXException shall be thrown if schemaSource is set but
  63      * schemaLanguage is not set.
  64      */
  65     @Test(expectedExceptions = SAXException.class)
  66     public void testSchemaValidationNeg() throws Exception {
  67         SAXParser sp = getValidatingParser();
  68         sp.setProperty(JAXP_SCHEMA_SOURCE, "catalog.xsd");
  69         sp.parse(new File(ASTROCAT), new DefaultHandler());
  70     }
  71 
  72     private SAXParser getValidatingParser() throws ParserConfigurationException, SAXException {
  73         SAXParserFactory spf = SAXParserFactory.newInstance();
  74         spf.setNamespaceAware(true);
  75         spf.setValidating(true);
  76         return spf.newSAXParser();
  77     }
  78 }

< prev index next >