Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 7959 invoked from network); 16 Oct 2002 16:19:06 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 16 Oct 2002 16:19:06 -0000 Received: (qmail 21675 invoked by uid 97); 16 Oct 2002 16:19:41 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@jakarta.apache.org Received: (qmail 21503 invoked by uid 97); 16 Oct 2002 16:19:39 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 21361 invoked by uid 97); 16 Oct 2002 16:19:38 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) Date: 16 Oct 2002 16:18:43 -0000 Message-ID: <20021016161843.93986.qmail@icarus.apache.org> From: morgand@apache.org To: jakarta-commons-sandbox-cvs@apache.org Subject: cvs commit: jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/test/xml TestXMLValidation.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N morgand 2002/10/16 09:18:43 Modified: jelly/src/java/org/apache/commons/jelly/parser XMLParser.java jelly/src/test/org/apache/commons/jelly/test/xml TestXMLValidation.java Log: XMLParser.error(SAXParseException) and XMLParser.fatalError(SAXParseException) [but not XMLParser.warning(SAXParseException)] will now throw a SAXException by default when no error handler is supplied. As a result, invalid Jelly scripts will now fail when validation is enabled by Jelly.setValidateXML(boolean). Revision Changes Path 1.34 +14 -8 jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/parser/XMLParser.java Index: XMLParser.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/parser/XMLParser.java,v retrieving revision 1.33 retrieving revision 1.34 diff -u -r1.33 -r1.34 --- XMLParser.java 16 Oct 2002 12:45:52 -0000 1.33 +++ XMLParser.java 16 Oct 2002 16:18:42 -0000 1.34 @@ -858,7 +858,7 @@ /** * Forward notification of a parsing error to the application supplied - * error handler (if any). + * error handler, if any, otherwise throw a SAXException with the error. * * @param exception The error information * @@ -875,12 +875,14 @@ exception); if (errorHandler != null) { errorHandler.error(exception); + } else { + throw exception; } } /** * Forward notification of a fatal parsing error to the application - * supplied error handler (if any). + * supplied error handler, if any, otherwise throw a SAXException with the error. * * @param exception The fatal error information * @@ -897,12 +899,16 @@ exception); if (errorHandler != null) { errorHandler.fatalError(exception); + } else { + throw exception; } } /** * Forward notification of a parse warning to the application supplied - * error handler (if any). + * error handler (if any). Unlike XMLParser.error(SAXParseException) and + * XMLParser.fatalError(SAXParseException), this implementation will + * NOT throw a SAXException by default if no error handler is supplied. * * @param exception The warning information * 1.2 +10 -7 jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/test/xml/TestXMLValidation.java Index: TestXMLValidation.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/test/xml/TestXMLValidation.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- TestXMLValidation.java 14 Oct 2002 19:17:01 -0000 1.1 +++ TestXMLValidation.java 16 Oct 2002 16:18:42 -0000 1.2 @@ -73,6 +73,8 @@ import org.apache.commons.jelly.Script; import org.apache.commons.jelly.XMLOutput; +import org.xml.sax.SAXParseException; + /** * A test to confirm that invalid documents are * reject iff jelly.setValidateXML(true) @@ -132,10 +134,11 @@ // with validation setUp("invalidScript1.jelly"); jelly.setValidateXML(true); - Script script = jelly.compileScript(); - script.run(context,xmlOutput); - assertTrue("should have set 'foo' variable to 'bar'", - context.getVariable("foo").equals("bar")); + try { + Script script = jelly.compileScript(); + fail("Invalid scripts should throw SAXParseException on parse"); + } catch (SAXParseException e) { + } } public void testValidXML1Validation()throws Exception { -- To unsubscribe, e-mail: For additional commands, e-mail: