You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by mo...@apache.org on 2003/01/23 23:25:01 UTC
cvs commit: jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/test/xml TestNonexistentTags.java nonexistentTags1.jelly
morgand 2003/01/23 14:25:01
Modified: jelly/src/java/org/apache/commons/jelly/parser
XMLParser.java
Added: jelly/src/test/org/apache/commons/jelly/test/xml
TestNonexistentTags.java nonexistentTags1.jelly
Log:
scripts will now fail to parse if they declare Jelly tags that do not exist,
per Jelly bug #21: http://jira.werken.com/ViewIssue.jspa?key=JELLY-21
Revision Changes Path
1.44 +9 -9 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.43
retrieving revision 1.44
diff -u -r1.43 -r1.44
--- XMLParser.java 14 Jan 2003 18:40:19 -0000 1.43
+++ XMLParser.java 23 Jan 2003 22:25:01 -0000 1.44
@@ -1044,16 +1044,16 @@
context.registerTagLibrary(namespaceURI, taglib);
}
catch (ClassNotFoundException e) {
- log.warn("Could not load class: " + uri + " so disabling the taglib", e);
+ throw createSAXException("Could not load class: " + uri + " so taglib instantiation failed", e);
}
catch (IllegalAccessException e) {
- log.warn("Constructor for class is not accessible: " + uri + " so disabling the taglib", e);
+ throw createSAXException("Constructor for class is not accessible: " + uri + " so taglib instantiation failed",e);
}
catch (InstantiationException e) {
- log.warn("Class could not be instantiated: " + uri + " so disabling the taglib", e);
+ throw createSAXException("Class could not be instantiated: " + uri + " so taglib instantiation failed",e);
}
catch (ClassCastException e) {
- log.warn("Class is not a TagLibrary: " + uri + " so disabling the taglib", e);
+ throw createSAXException("Class is not a TagLibrary: " + uri + " so taglib instantiation failed",e);
}
}
}
1.1 jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/test/xml/TestNonexistentTags.java
Index: TestNonexistentTags.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/test/xml/TestNonexistentTags.java,v 1.1 2003/01/23 22:25:01 morgand Exp $
* $Revision: 1.1 $
* $Date: 2003/01/23 22:25:01 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* $Id: TestNonexistentTags.java,v 1.1 2003/01/23 22:25:01 morgand Exp $
*/
package org.apache.commons.jelly.test.xml;
import java.io.StringWriter;
import java.net.URL;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.apache.commons.jelly.Jelly;
import org.apache.commons.jelly.JellyContext;
import org.apache.commons.jelly.Script;
import org.apache.commons.jelly.XMLOutput;
import org.xml.sax.SAXParseException;
/**
* A test to confirm that Jelly scripts fail to parse if they declare tags
* that do not exist
*
* @author Morgan Delagrange
* @version $Revision: 1.1 $
*/
public class TestNonexistentTags extends TestCase {
Jelly jelly = null;
JellyContext context = null;
XMLOutput xmlOutput = null;
public TestNonexistentTags(String name) {
super(name);
}
public static TestSuite suite() throws Exception {
return new TestSuite(TestNonexistentTags.class);
}
public void setUp(String scriptName) throws Exception {
context = new JellyContext();
xmlOutput = XMLOutput.createDummyXMLOutput();
jelly = new Jelly();
String script = scriptName;
URL url = this.getClass().getResource(script);
if ( url == null ) {
throw new Exception(
"Could not find Jelly script: " + script
+ " in package of class: " + this.getClass().getName()
);
}
jelly.setUrl(url);
}
/**
* A script should fail to parse if it declares tags that don't exist.
*/
public void testNonexistentTags() throws Exception {
setUp("nonexistentTags1.jelly");
try {
Script script = jelly.compileScript();
fail("Scripts should throw SAXParseException when it declares a nonexistent tag.");
} catch (SAXParseException e) {
}
}
}
1.1 jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/test/xml/nonexistentTags1.jelly
Index: nonexistentTags1.jelly
===================================================================
<?xml version="1.0"?>
<j:jelly
xmlns:j="jelly:core" xmlns:x="jelly:xml">
<j:set var="foo" value="bar"/>
<!-- should fail, because xml tags are not in the classpath -->
<x:parse var="foo" xml="nonexistentTags1.jelly"/>
</j:jelly>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>