You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by js...@apache.org on 2002/08/20 19:26:10 UTC
cvs commit: jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/impl TestTagLibraryResolver.java
jstrachan 2002/08/20 10:26:10
Added: jelly/src/test/org/apache/commons/jelly/test/impl
DummyTagLibrary.java DummyTag.java
jelly/src/test/org/apache/commons/jelly/impl
TestTagLibraryResolver.java
Log:
Added new TagLibraryResolver interface and an implementation using commons-discovery
Revision Changes Path
1.1 jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/test/impl/DummyTagLibrary.java
Index: DummyTagLibrary.java
===================================================================
package org.apache.commons.jelly.test.impl;
import org.apache.commons.jelly.TagLibrary;
import org.apache.commons.jelly.TagSupport;
import org.apache.commons.jelly.XMLOutput;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Test taglibrary
*
* @author <a href="mailto:vinayc@apache.org">Vinay Chandran</a>
*/
public class DummyTagLibrary extends TagLibrary {
/** The Log to which logging calls will be made. */
private static final Log log = LogFactory.getLog(DummyTagLibrary.class);
public DummyTagLibrary() {
registerTag("dummy", DummyTag.class);
}
}
1.1 jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/test/impl/DummyTag.java
Index: DummyTag.java
===================================================================
/*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-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/>.
*
*/
package org.apache.commons.jelly.test.impl;
import org.apache.commons.jelly.TagSupport;
import org.apache.commons.jelly.XMLOutput;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Simple Test Tag
*
* @author <a href="mailto:vinayc@apache.org">Vinay Chandran</a>
*/
public class DummyTag extends TagSupport {
/** The Log to which logging calls will be made. */
private static final Log log = LogFactory.getLog(DummyTag.class);
/** A test class to be loaded by the Tag*/
private String m_classToBeLoaded = null;
/**
*
* @see org.apache.commons.jelly.Tag#doTag(XMLOutput)
* @see org.apache.commons.jelly.tags.core.JellyTag
*/
public void doTag(XMLOutput output) throws Exception {
if (log.isDebugEnabled())
log.debug("********Executing DummyTag Body*********");
if (m_classToBeLoaded != null) {
try {
Class clazz =
getClass().getClassLoader().loadClass(m_classToBeLoaded);
if (log.isDebugEnabled())
log.debug("Class[" + m_classToBeLoaded + "] FOUND");
}
catch (ClassNotFoundException cnfe) {
if (log.isWarnEnabled())
log.warn("Class[" + m_classToBeLoaded + "] NOT FOUND");
}
}
invokeBody(output);
}
/**
* A Test Variable(Used for testing the TagLibraryClassloader)
*/
public void setLoadClass(String extraClass) {
m_classToBeLoaded = extraClass;
}
}
1.1 jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/impl/TestTagLibraryResolver.java
Index: TestTagLibraryResolver.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/TestTagLibraryResolver.java,v 1.9 2002/06/07 09:36:11 jstrachan Exp $
* $Revision: 1.9 $
* $Date: 2002/06/07 09:36:11 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-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: TestTagLibraryResolver.java,v 1.9 2002/06/07 09:36:11 jstrachan Exp $
*/
package org.apache.commons.jelly.impl;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
import org.apache.commons.jelly.TagLibrary;
import org.apache.commons.jelly.impl.DefaultTagLibraryResolver;
import org.apache.commons.jelly.impl.TagLibraryResolver;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/** Tests the core tags
*
* @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
* @version $Revision: 1.9 $
*/
public class TestTagLibraryResolver extends TestCase {
/** The Log to which logging calls will be made. */
private static final Log log = LogFactory.getLog(TestTagLibraryResolver.class);
private TagLibraryResolver resolver = new DefaultTagLibraryResolver();
public static void main(String[] args) {
TestRunner.run(suite());
}
public static Test suite() {
return new TestSuite(TestTagLibraryResolver.class);
}
public TestTagLibraryResolver(String testName) {
super(testName);
}
public void testResolver() throws Exception {
TagLibrary library = resolver.resolveTagLibrary("jelly:test-library" );
assertTrue( "Found a tag library", library != null );
assertEquals( "Tag library is of the correct type", "org.apache.commons.jelly.test.impl.DummyTagLibrary", library.getClass().getName() );
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>