Author: polx Date: Fri Nov 21 16:25:35 2008 New Revision: 719761 URL: http://svn.apache.org/viewvc?rev=719761&view=rev Log: Further patch from JELLY-286. paul
Modified: commons/proper/jelly/trunk/.classpath commons/proper/jelly/trunk/build.xml commons/proper/jelly/trunk/project.xml commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/TagSupport.java commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/ExpressionSupport.java commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/jexl/JexlExpression.java commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/TJEcho.java commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/TJTagLibrary.java commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/TJTest.java commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/TestNamespacePrefixes.java commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/TestNestedExceptions.java commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/TestUnknownTags.java commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/expression/TestCustomExpressionFactory.java commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/expression/TestExpressions.java commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/expression/jelly1.xml Modified: commons/proper/jelly/trunk/.classpath URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/.classpath?rev=719761&r1=719760&r2=719761&view=diff ============================================================================== --- commons/proper/jelly/trunk/.classpath (original) +++ commons/proper/jelly/trunk/.classpath Fri Nov 21 16:25:35 2008 @@ -1,7 +1,15 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src/java"/> - <classpathentry output="target/test-classes" kind="src" path="src/test"/> + <classpathentry kind="src" output="target/test-classes" path="src/test"/> + <classpathentry kind="src" path="jelly-tags/define/src/java"/> + <classpathentry kind="src" path="jelly-tags/define/src/test"/> + <classpathentry kind="src" path="jelly-tags/log/src/java"/> + <classpathentry kind="src" path="jelly-tags/log/src/test"/> + <classpathentry kind="src" path="jelly-tags/util/src/java"/> + <classpathentry kind="src" path="jelly-tags/util/src/test"/> + <classpathentry kind="src" path="jelly-tags/xml/src/java"/> + <classpathentry kind="src" path="jelly-tags/xml/src/test"/> <classpathentry kind="var" path="MAVEN_REPO/junit/jars/junit-3.8.1.jar"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="var" path="MAVEN_REPO/commons-jexl/jars/commons-jexl-1.0.jar"/> @@ -9,8 +17,6 @@ <classpathentry kind="var" path="MAVEN_REPO/commons-beanutils/jars/commons-beanutils-1.6.jar"/> <classpathentry kind="var" path="MAVEN_REPO/commons-collections/jars/commons-collections-2.1.jar"/> <classpathentry kind="var" path="MAVEN_REPO/commons-logging/jars/commons-logging-1.0.3.jar"/> - <classpathentry kind="var" path="MAVEN_REPO/dom4j/jars/dom4j-1.5.jar"/> - <classpathentry kind="var" path="MAVEN_REPO/jaxen/jars/jaxen-1.1-beta-2.jar"/> <classpathentry kind="var" path="MAVEN_REPO/xerces/jars/xerces-2.2.1.jar"/> <classpathentry kind="var" path="MAVEN_REPO/servletapi/jars/servletapi-2.3.jar"/> <classpathentry kind="var" path="MAVEN_REPO/commons-cli/jars/commons-cli-1.0.jar"/> @@ -18,5 +24,7 @@ <classpathentry kind="var" path="MAVEN_REPO/commons-discovery/jars/commons-discovery-20030211.213356.jar"/> <classpathentry kind="var" path="MAVEN_REPO/forehead/jars/forehead-1.0-beta-5.jar"/> <classpathentry kind="var" path="MAVEN_REPO/jstl/jars/jstl-1.0.6.jar"/> + <classpathentry kind="var" path="MAVEN_REPO/dom4j/jars/dom4j-1.5.2.jar"/> + <classpathentry kind="var" path="MAVEN_REPO/jaxen/jars/jaxen-1.1-beta-9.jar"/> <classpathentry kind="output" path="target/classes"/> </classpath> Modified: commons/proper/jelly/trunk/build.xml URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/build.xml?rev=719761&r1=719760&r2=719761&view=diff ============================================================================== --- commons/proper/jelly/trunk/build.xml (original) +++ commons/proper/jelly/trunk/build.xml Fri Nov 21 16:25:35 2008 @@ -168,6 +168,8 @@ </include> <exclude name="**/TestCoreMemoryLeak.java"> </exclude> + <exclude name="**/TestNestedExceptions.java"> + </exclude> </fileset> </batchtest> </junit> @@ -411,7 +413,10 @@ <get dest="${libdir}/xerces/jars/xerces-2.2.1.jar" usetimestamp="true" ignoreerrors="true" src="${xerces.jar}"> </get> </target> + <!-- <target name="get-deps" unless="noget" depends="get-dep-servletapi.jar,get-dep-commons-cli.jar,get-dep-commons-lang.jar,get-dep-commons-discovery.jar,get-dep-forehead.jar,get-dep-jstl.jar,get-dep-junit.jar,get-dep-commons-jexl.jar,get-dep-xml-apis.jar,get-dep-commons-beanutils.jar,get-dep-commons-collections.jar,get-dep-commons-logging.jar,get-dep-dom4j.jar,get-dep-jaxen.jar,get-dep-xerces.jar"> + --> + <target name="get-deps" unless="noget"> </target> <target name="setProxy" if="useProxy" depends="init"> <!--Proxy settings works only with a JDK 1.2 and higher.--> Modified: commons/proper/jelly/trunk/project.xml URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/project.xml?rev=719761&r1=719760&r2=719761&view=diff ============================================================================== --- commons/proper/jelly/trunk/project.xml (original) +++ commons/proper/jelly/trunk/project.xml Fri Nov 21 16:25:35 2008 @@ -306,6 +306,30 @@ <role>Developer</role> </roles> </contributor> + <contributor> + <name>John Spackman</name> + <email>[EMAIL PROTECTED]</email> + <organization>Zenesis Limited</organization> + <roles> + <role>Developer</role> + </roles> + </contributor> + <contributor> + <name>John Spackman</name> + <email>[EMAIL PROTECTED]</email> + <organization>Zenesis Limited</organization> + <roles> + <role>Developer</role> + </roles> + </contributor> + <contributor> + <name>John Spackman</name> + <email>[EMAIL PROTECTED]</email> + <organization>Zenesis Limited</organization> + <roles> + <role>Developer</role> + </roles> + </contributor> </contributors> <dependencies> <!-- for servlet support --> @@ -395,9 +419,11 @@ <excludes> <exclude>**/TestCoreMemoryLeak.java</exclude> <exclude>**/TestNamespacePrefixes.java</exclude> - <exclude>**/TestNestedExceptions.java</exclude> <exclude>**/TestUnknownTags.java</exclude> <exclude>**/TestCustomExpressionFactory.java</exclude> + <!-- + --> + <exclude>**/TestNestedExceptions.java</exclude> </excludes> Modified: commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/TagSupport.java URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/TagSupport.java?rev=719761&r1=719760&r2=719761&view=diff ============================================================================== --- commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/TagSupport.java (original) +++ commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/TagSupport.java Fri Nov 21 16:25:35 2008 @@ -159,7 +159,6 @@ /* (non-Javadoc) * @see org.apache.commons.jelly.Tag#getTagLibrary() */ - @Override public TagLibrary getTagLibrary() { return tagLibrary; } @@ -167,7 +166,6 @@ /* (non-Javadoc) * @see org.apache.commons.jelly.Tag#setTagLibrary(org.apache.commons.jelly.TagLibrary) */ - @Override public void setTagLibrary(TagLibrary tagLibrary) { if (this.tagLibrary != null && tagLibrary != this.tagLibrary) throw new IllegalArgumentException("Cannot setTagLibrary once set"); Modified: commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/ExpressionSupport.java URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/ExpressionSupport.java?rev=719761&r1=719760&r2=719761&view=diff ============================================================================== --- commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/ExpressionSupport.java (original) +++ commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/ExpressionSupport.java Fri Nov 21 16:25:35 2008 @@ -28,7 +28,6 @@ import org.apache.commons.collections.iterators.SingletonIterator; import org.apache.commons.jelly.JellyContext; -import org.apache.commons.jelly.JellyException; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.lang.StringUtils; Modified: commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/jexl/JexlExpression.java URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/jexl/JexlExpression.java?rev=719761&r1=719760&r2=719761&view=diff ============================================================================== --- commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/jexl/JexlExpression.java (original) +++ commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/jexl/JexlExpression.java Fri Nov 21 16:25:35 2008 @@ -22,7 +22,6 @@ import java.util.Collection; import org.apache.commons.jelly.JellyContext; -import org.apache.commons.jelly.JellyException; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.expression.ExpressionSupport; Modified: commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/TJEcho.java URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/TJEcho.java?rev=719761&r1=719760&r2=719761&view=diff ============================================================================== --- commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/TJEcho.java (original) +++ commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/TJEcho.java Fri Nov 21 16:25:35 2008 @@ -14,7 +14,6 @@ private String attr; private String text; - @Override public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException { text = getBodyText(); String str = "id=" + id + "; attr=" + attr + "; text=" + text + "\n"; Modified: commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/TJTagLibrary.java URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/TJTagLibrary.java?rev=719761&r1=719760&r2=719761&view=diff ============================================================================== --- commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/TJTagLibrary.java (original) +++ commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/TJTagLibrary.java Fri Nov 21 16:25:35 2008 @@ -15,7 +15,6 @@ /* (non-Javadoc) * @see org.apache.commons.jelly.expression.ExpressionFactory#createExpression(java.lang.String) */ - @Override public Expression createExpression(String text) throws JellyException { return new ConstantExpression("${TEST FACTORY: " + text + "}"); } @@ -30,7 +29,6 @@ /* (non-Javadoc) * @see org.apache.commons.jelly.TagLibrary#getExpressionFactory() */ - @Override public ExpressionFactory getExpressionFactory() { return TEST_FACTORY; } Modified: commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/TJTest.java URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/TJTest.java?rev=719761&r1=719760&r2=719761&view=diff ============================================================================== --- commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/TJTest.java (original) +++ commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/TJTest.java Fri Nov 21 16:25:35 2008 @@ -9,7 +9,6 @@ public static final String TAG_NAME = "test"; - @Override public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException { invokeBody(output); } Modified: commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/TestNamespacePrefixes.java URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/TestNamespacePrefixes.java?rev=719761&r1=719760&r2=719761&view=diff ============================================================================== --- commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/TestNamespacePrefixes.java (original) +++ commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/TestNamespacePrefixes.java Fri Nov 21 16:25:35 2008 @@ -25,10 +25,8 @@ 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.apache.commons.jelly.parser.XMLParser; import org.apache.commons.jelly.test.BaseJellyTest; import org.xml.sax.InputSource; Modified: commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/TestNestedExceptions.java URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/TestNestedExceptions.java?rev=719761&r1=719760&r2=719761&view=diff ============================================================================== --- commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/TestNestedExceptions.java (original) +++ commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/TestNestedExceptions.java Fri Nov 21 16:25:35 2008 @@ -3,10 +3,7 @@ import junit.framework.TestSuite; import junit.textui.TestRunner; -import org.apache.commons.jelly.Script; import org.apache.commons.jelly.tags.junit.JellyTestSuite; -import org.apache.commons.jelly.TestJelly; -import org.apache.commons.jelly.test.BaseJellyTest; public class TestNestedExceptions extends JellyTestSuite { Modified: commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/TestUnknownTags.java URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/TestUnknownTags.java?rev=719761&r1=719760&r2=719761&view=diff ============================================================================== --- commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/TestUnknownTags.java (original) +++ commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/TestUnknownTags.java Fri Nov 21 16:25:35 2008 @@ -16,17 +16,12 @@ */ package org.apache.commons.jelly.core; -import java.io.StringWriter; - import junit.framework.TestSuite; +import org.apache.commons.jelly.JellyException; import org.apache.commons.jelly.Script; -import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.test.BaseJellyTest; -import org.dom4j.io.HTMLWriter; -import org.dom4j.io.OutputFormat; -import org.dom4j.io.XMLWriter; -import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; /** * Tests for exceptions being raised when an unknown tag is encountered - new @@ -46,8 +41,17 @@ public void testUnknownTags() throws Exception { setUpScript("testUnknownTags.xml"); - Script script = getJelly().compileScript(); - script.run(getJellyContext(), getXMLOutput()); - System.out.println(getStringOutput()); + try { + Script script = getJelly().compileScript(); + script.run(getJellyContext(), getXMLOutput()); + System.out.println(getStringOutput()); + }catch(JellyException e) { + if (e.getCause() instanceof SAXParseException) { + Throwable cause = e.getCause(); + if (cause.getMessage().indexOf("Unrecognised tag called tag-that-does-not-exist in TagLibrary jelly:test") > -1) + return; + } + throw e; + } } } Modified: commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/expression/TestCustomExpressionFactory.java URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/expression/TestCustomExpressionFactory.java?rev=719761&r1=719760&r2=719761&view=diff ============================================================================== --- commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/expression/TestCustomExpressionFactory.java (original) +++ commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/expression/TestCustomExpressionFactory.java Fri Nov 21 16:25:35 2008 @@ -10,19 +10,26 @@ import junit.textui.TestRunner; import org.apache.commons.jelly.JellyContext; +import org.apache.commons.jelly.Script; import org.apache.commons.jelly.TJTagLibrary; import org.apache.commons.jelly.XMLOutput; +import org.apache.commons.jelly.test.BaseJellyTest; -public class TestCustomExpressionFactory extends TestCase { +public class TestCustomExpressionFactory extends BaseJellyTest { private static final String EXPECTED = "id=1; attr=${TEST FACTORY: 1 + 2 }; text=${TEST FACTORY: 'hello' + \" world\" }\n" + - "id=2; attr=${TEST FACTORY: 2 + 3 }; text=<sometag xmlns=\"jelly:test\">${TEST FACTORY: 'goodbye cruel' + \" world\" }</sometag>\n"; + "id=2; attr=${TEST FACTORY: 2 + 3 }; text=<sometag>${TEST FACTORY: 'goodbye cruel' + \" world\" }</sometag>\n"; public TestCustomExpressionFactory() { super("TestCustomExpressionFactory"); } public void testCustomFactory() throws Exception { + setUpScript("jelly1.xml"); + Script script = getJelly().compileScript(); + script.run(getJellyContext(), getXMLOutput()); + + /* JellyContext ctx = new JellyContext(); ctx.registerTagLibrary(TJTagLibrary.NS, TJTagLibrary.class.getName()); @@ -34,7 +41,8 @@ XMLOutput output = XMLOutput.createXMLOutput(strWriter); ctx.runScript(file, output); - String str = strWriter.toString(); + */ + String str = getStringOutput().toString(); System.out.println(str); assertEquals(str, EXPECTED); } Modified: commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/expression/TestExpressions.java URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/expression/TestExpressions.java?rev=719761&r1=719760&r2=719761&view=diff ============================================================================== --- commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/expression/TestExpressions.java (original) +++ commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/expression/TestExpressions.java Fri Nov 21 16:25:35 2008 @@ -79,14 +79,14 @@ assertExpressionNotExpressionText("$$type$${topping}$$", "$$type${topping}$$"); try { - assertExpression("${ some junk !< 4}", true); + assertExpression("${ some junk !< 4}", Boolean.TRUE); assertTrue("An illegal expression was allowed", false); }catch(JellyException e) { // Nothing, the test passed } context.setVariable("test", new TestHelper()); try { - assertExpression("${test.throwAnException()}", true); + assertExpression("${test.throwAnException()}", Boolean.TRUE); assertTrue("An exception was suppressed while processing the JEXL script", false); }catch(JellyTagException e) { if (!(e.getCause() instanceof TestException)) Modified: commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/expression/jelly1.xml URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/expression/jelly1.xml?rev=719761&r1=719760&r2=719761&view=diff ============================================================================== --- commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/expression/jelly1.xml (original) +++ commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/expression/jelly1.xml Fri Nov 21 16:25:35 2008 @@ -1,6 +1,6 @@ -<test xmlns="jelly:test"> +<t:test xmlns:t="jelly:test"> - <echo id="1" attr="${ 1 + 2 }">${ 'hello' + " world" }</echo> - <echo id="2" attr="${ 2 + 3 }"><sometag>${ 'goodbye cruel' + " world" }</sometag></echo> + <t:echo id="1" attr="${ 1 + 2 }">${ 'hello' + " world" }</t:echo> + <t:echo id="2" attr="${ 2 + 3 }"><sometag>${ 'goodbye cruel' + " world" }</sometag></t:echo> -</test> +</t:test>