Code example for SAXException

Methods: getLocalizedMessage

        try { 
            fail("MUST NOT be able to validate bad restlet.xml"); 
        } catch (SAXException x) {
            // the error must be a "cvc-complex-type.2.4.a" 
            assertTrue("MUST detect schema violation", x.getLocalizedMessage()
            // ...and it has to refer to 'bad-element' 
            assertTrue("MUST detect schema violation related to 'bad-element'", 
                    x.getLocalizedMessage().indexOf("bad-element") > 0);
        } catch (IOException x) {
            fail("MUST throw a SAXException only"); 
    public void testValidatorWithoutXMLNS() { 
        System.out.println("-- testValidatorWithoutXMLNS");
        try { 
Experience pair programming with AI  Get Codota for Java