Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 96703 invoked from network); 1 Feb 2003 17:35:34 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 1 Feb 2003 17:35:34 -0000 Received: (qmail 1899 invoked by uid 97); 1 Feb 2003 17:37:04 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@nagoya.betaversion.org Received: (qmail 1892 invoked from network); 1 Feb 2003 17:37:03 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 1 Feb 2003 17:37:03 -0000 Received: (qmail 94247 invoked by uid 500); 1 Feb 2003 17:35:06 -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 94207 invoked by uid 500); 1 Feb 2003 17:35:05 -0000 Received: (qmail 94188 invoked from network); 1 Feb 2003 17:35:05 -0000 Received: from icarus.apache.org (208.185.179.13) by daedalus.apache.org with SMTP; 1 Feb 2003 17:35:05 -0000 Received: (qmail 13556 invoked by uid 1235); 1 Feb 2003 17:35:05 -0000 Date: 1 Feb 2003 17:35:05 -0000 Message-ID: <20030201173505.13555.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/core TestIncludeTag.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 2003/02/01 09:35:05 Added: jelly/src/test/org/apache/commons/jelly/core TestIncludeTag.java Log: renamed TestIncludedNested to TestIncludeTag, added test to insure that includes work correctly as files as well as classpath elements Revision Changes Path 1.1 jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/core/TestIncludeTag.java Index: TestIncludeTag.java =================================================================== /* * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/core/TestIncludeNesting.java,v 1.3 2002/12/11 12:41:00 jstrachan Exp $ * $Revision: 1.3 $ * $Date: 2002/12/11 12:41:00 $ * * ==================================================================== * * 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 * . * * $Id: TestIncludeNesting.java,v 1.3 2002/12/11 12:41:00 jstrachan Exp $ */ package org.apache.commons.jelly.core; 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.TagLibrary; import org.apache.commons.jelly.XMLOutput; /** * Makes sure that nested includes work correctly * * @author Morgan Delagrange * @version $Revision: 1.3 $ */ public class TestIncludeTag extends TestCase { Jelly jelly = null; JellyContext context = null; XMLOutput xmlOutput = null; public TestIncludeTag(String name) { super(name); } public static TestSuite suite() throws Exception { return new TestSuite(TestIncludeTag.class); } public void setUp(String scriptName) throws Exception { URL url = this.getClass().getResource(scriptName); if ( url == null ) { throw new Exception( "Could not find Jelly script: " + scriptName + " in package of class: " + this.getClass().getName() ); } setUpFromURL(url); } public void setUpFromURL(URL url) throws Exception { context = new CoreTaglibOnlyContext(); xmlOutput = XMLOutput.createDummyXMLOutput(); jelly = new Jelly(); jelly.setUrl(url); String exturl = url.toExternalForm(); int lastSlash = exturl.lastIndexOf("/"); String extBase = exturl.substring(0,lastSlash+1); URL baseurl = new URL(extBase); context.setCurrentURL(baseurl); } public void testInnermost() throws Exception { // performs no includes setUp("c.jelly"); Script script = jelly.compileScript(); script.run(context,xmlOutput); assertTrue("should have set 'c' variable to 'true'", context.getVariable("c").equals("true")); } public void testMiddle() throws Exception { // performs one include setUp("b.jelly"); Script script = jelly.compileScript(); script.run(context,xmlOutput); assertTrue("should have set 'c' variable to 'true'", context.getVariable("c").equals("true")); assertTrue("should have set 'b' variable to 'true'", context.getVariable("b").equals("true")); } public void testOutermost() throws Exception { // performs one nested include setUp("a.jelly"); Script script = jelly.compileScript(); script.run(context,xmlOutput); assertTrue("should have set 'c' variable to 'true'", context.getVariable("c").equals("true")); assertTrue("should have set 'b' variable to 'true'", context.getVariable("b").equals("true")); assertTrue("should have set 'a' variable to 'true'", context.getVariable("a").equals("true")); } /** * Insure that includes happen correctly when Jelly scripts * are referenced as a file (rather than as a classpath * element). Specifically checks to make sure includes succeed * when the initial script is not in the user.dir directory. */ public void testFileInclude() throws Exception { // testing outermost setUpFromURL(new URL("file:src/test/org/apache/commons/jelly/core/a.jelly")); Script script = jelly.compileScript(); script.run(context,xmlOutput); assertTrue("should have set 'c' variable to 'true'", context.getVariable("c").equals("true")); assertTrue("should have set 'b' variable to 'true'", context.getVariable("b").equals("true")); assertTrue("should have set 'a' variable to 'true'", context.getVariable("a").equals("true")); } private class CoreTaglibOnlyContext extends JellyContext { /** * This implementations makes sure that only "jelly:core" * taglib is instantiated, insuring that "optional" dependencies * are not inadvertantly called. Specifically addresses a bug * in older Jelly dev versions where a nested include * would trigger instantiation of all tag libraries. * * @param namespaceURI * @return */ public TagLibrary getTagLibrary(String namespaceURI) { if (namespaceURI.equals("jelly:core")) { return super.getTagLibrary(namespaceURI); } else { throw new NoClassDefFoundError("Unexpected tag library uri: " + namespaceURI); } } } } --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org