From 06cb0ca8975fd38019fa0f596f0ed9d493416fc7 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Thu, 23 Jul 2015 16:11:16 -0700 Subject: [PATCH] Adding JSTL test cases --- .gitignore | 4 ++ .../org/eclipse/jetty/jstl/JspConfig.java | 12 ------ .../java/org/eclipse/jetty/jstl/JstlTest.java | 41 ++++++++++++++++--- .../src/test/taglibjar/META-INF/etag.tld | 21 ++++++++++ .../taglibjar/META-INF/tags/errorhandler.tag | 13 ++++++ .../taglibjar/META-INF/tags/errortest.tag | 3 ++ apache-jstl/src/test/webapp/catch-basic.jsp | 16 ++++++++ apache-jstl/src/test/webapp/catch-taglib.jsp | 11 +++++ 8 files changed, 103 insertions(+), 18 deletions(-) create mode 100644 apache-jstl/src/test/taglibjar/META-INF/etag.tld create mode 100644 apache-jstl/src/test/taglibjar/META-INF/tags/errorhandler.tag create mode 100644 apache-jstl/src/test/taglibjar/META-INF/tags/errortest.tag create mode 100644 apache-jstl/src/test/webapp/catch-basic.jsp create mode 100644 apache-jstl/src/test/webapp/catch-taglib.jsp diff --git a/.gitignore b/.gitignore index 52260df3621..699c68b16d7 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,7 @@ bin/ # merge tooling *.orig + +# test generated content +*/src/test/*/WEB-INF/lib/test*.jar + diff --git a/apache-jstl/src/test/java/org/eclipse/jetty/jstl/JspConfig.java b/apache-jstl/src/test/java/org/eclipse/jetty/jstl/JspConfig.java index 3ca87d679cc..df145af94a8 100644 --- a/apache-jstl/src/test/java/org/eclipse/jetty/jstl/JspConfig.java +++ b/apache-jstl/src/test/java/org/eclipse/jetty/jstl/JspConfig.java @@ -20,19 +20,7 @@ package org.eclipse.jetty.jstl; import java.io.File; import java.net.URI; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.ArrayList; -import java.util.List; -import org.apache.tomcat.InstanceManager; -import org.apache.tomcat.SimpleInstanceManager; -import org.eclipse.jetty.annotations.ServletContainerInitializersStarter; -import org.eclipse.jetty.apache.jsp.JettyJasperInitializer; -import org.eclipse.jetty.jsp.JettyJspServlet; -import org.eclipse.jetty.plus.annotation.ContainerInitializer; -import org.eclipse.jetty.servlet.DefaultServlet; -import org.eclipse.jetty.servlet.ServletHolder; import org.eclipse.jetty.webapp.WebAppContext; /** diff --git a/apache-jstl/src/test/java/org/eclipse/jetty/jstl/JstlTest.java b/apache-jstl/src/test/java/org/eclipse/jetty/jstl/JstlTest.java index 858701f67e7..6221c1d6943 100644 --- a/apache-jstl/src/test/java/org/eclipse/jetty/jstl/JstlTest.java +++ b/apache-jstl/src/test/java/org/eclipse/jetty/jstl/JstlTest.java @@ -25,19 +25,21 @@ import java.io.File; import java.io.IOException; import java.net.URI; +import javax.servlet.jsp.JspException; + import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.toolchain.test.FS; +import org.eclipse.jetty.toolchain.test.JAR; import org.eclipse.jetty.toolchain.test.MavenTestingUtils; import org.eclipse.jetty.toolchain.test.SimpleRequest; -import org.eclipse.jetty.webapp.WebAppContext; import org.eclipse.jetty.webapp.Configuration; +import org.eclipse.jetty.webapp.WebAppContext; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Test; -@Ignore public class JstlTest { private static Server server; @@ -54,6 +56,14 @@ public class JstlTest // Setup WebAppContext File testWebAppDir = MavenTestingUtils.getProjectDir("src/test/webapp"); + + // Prepare WebApp libs + File libDir = new File(testWebAppDir, "WEB-INF/lib"); + FS.ensureDirExists(libDir); + File testTagLibDir = MavenTestingUtils.getProjectDir("src/test/taglibjar"); + JAR.create(testTagLibDir,new File(libDir, "testtaglib.jar")); + + // Configure WebAppContext Configuration.ClassList classlist = Configuration.ClassList .setServerDefault(server); @@ -61,7 +71,6 @@ public class JstlTest classlist.addBefore( "org.eclipse.jetty.webapp.JettyWebXmlConfiguration", "org.eclipse.jetty.annotations.AnnotationConfiguration"); - WebAppContext context = new WebAppContext(); context.setContextPath("/"); @@ -99,8 +108,28 @@ public class JstlTest assertThat("Response should be JSP processed", resp, not(containsString(" + + + eclipse jetty test taglib + 1.0 + + jtest + org.eclipse.jetty.jstl.jtest + + + errortest + /META-INF/tags/errortest.tag + + + + errorhandler + /META-INF/tags/errorhandler.tag + + \ No newline at end of file diff --git a/apache-jstl/src/test/taglibjar/META-INF/tags/errorhandler.tag b/apache-jstl/src/test/taglibjar/META-INF/tags/errorhandler.tag new file mode 100644 index 00000000000..854952bc2f5 --- /dev/null +++ b/apache-jstl/src/test/taglibjar/META-INF/tags/errorhandler.tag @@ -0,0 +1,13 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> + + + + + + +[jtest:errorhandler] exception : ${error} +[jtest:errorhandler] exception.message : ${error.message} + + +[jtest:errorhandler] exception is null + diff --git a/apache-jstl/src/test/taglibjar/META-INF/tags/errortest.tag b/apache-jstl/src/test/taglibjar/META-INF/tags/errortest.tag new file mode 100644 index 00000000000..c41a875c0ce --- /dev/null +++ b/apache-jstl/src/test/taglibjar/META-INF/tags/errortest.tag @@ -0,0 +1,3 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> + + \ No newline at end of file diff --git a/apache-jstl/src/test/webapp/catch-basic.jsp b/apache-jstl/src/test/webapp/catch-basic.jsp new file mode 100644 index 00000000000..06e2bcfd2bc --- /dev/null +++ b/apache-jstl/src/test/webapp/catch-basic.jsp @@ -0,0 +1,16 @@ +<%@ page contentType="text/plain; charset=UTF-8" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> +Title: JSTL c:catch test + + + + + + +[c:catch] exception : ${catchException} +[c:catch] exception.message : ${catchException.message} + + +[c:catch] exception is null + diff --git a/apache-jstl/src/test/webapp/catch-taglib.jsp b/apache-jstl/src/test/webapp/catch-taglib.jsp new file mode 100644 index 00000000000..68c7b8f50e6 --- /dev/null +++ b/apache-jstl/src/test/webapp/catch-taglib.jsp @@ -0,0 +1,11 @@ +<%@ page contentType="text/plain; charset=UTF-8" %> +<%@ taglib uri="org.eclipse.jetty.jstl.jtest" prefix="jtest" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> +Title: JSTL c:catch test + + + + + +parsedNum = \ No newline at end of file