Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoakim Erdfelt2015-07-23 19:11:16 -0400
committerJoakim Erdfelt2015-07-23 19:11:16 -0400
commit06cb0ca8975fd38019fa0f596f0ed9d493416fc7 (patch)
treefdeaa3fa2dbd8dc3c4402e1fdd9f0017bdf61e5c /apache-jstl
parent0476d4d28d6350616bb41525d0b6cbe1067d57aa (diff)
downloadorg.eclipse.jetty.project-06cb0ca8975fd38019fa0f596f0ed9d493416fc7.tar.gz
org.eclipse.jetty.project-06cb0ca8975fd38019fa0f596f0ed9d493416fc7.tar.xz
org.eclipse.jetty.project-06cb0ca8975fd38019fa0f596f0ed9d493416fc7.zip
Adding <c:catch> JSTL test cases
Diffstat (limited to 'apache-jstl')
-rw-r--r--apache-jstl/src/test/java/org/eclipse/jetty/jstl/JspConfig.java12
-rw-r--r--apache-jstl/src/test/java/org/eclipse/jetty/jstl/JstlTest.java41
-rw-r--r--apache-jstl/src/test/taglibjar/META-INF/etag.tld21
-rw-r--r--apache-jstl/src/test/taglibjar/META-INF/tags/errorhandler.tag13
-rw-r--r--apache-jstl/src/test/taglibjar/META-INF/tags/errortest.tag3
-rw-r--r--apache-jstl/src/test/webapp/catch-basic.jsp16
-rw-r--r--apache-jstl/src/test/webapp/catch-taglib.jsp11
7 files changed, 99 insertions, 18 deletions
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 3ca87d679c..df145af94a 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 858701f67e..6221c1d694 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("<c:url")));
assertThat("Response", resp, containsString("[c:url value] = /ref.jsp;jsessionid="));
assertThat("Response", resp, containsString("[c:url param] = ref.jsp;key=value;jsessionid="));
-
- System.err.println("Response:");
- System.err.println(resp);
+ }
+
+ @Test
+ public void testCatchBasic() throws IOException
+ {
+ SimpleRequest req = new SimpleRequest(baseUri);
+ String resp = req.getString("/catch-basic.jsp");
+ assertThat("Response should be JSP processed", resp, not(containsString("<c:catch")));
+ assertThat("Response", resp, containsString("[c:catch] exception : " + JspException.class.getName()));
+ assertThat("Response", resp, containsString("[c:catch] exception.message : In &lt;parseNumber&gt;"));
+ }
+
+ @Test
+ @Ignore
+ public void testCatchTaglib() throws IOException
+ {
+ SimpleRequest req = new SimpleRequest(baseUri);
+ String resp = req.getString("/catch-taglib.jsp");
+ System.out.println("resp = " + resp);
+ assertThat("Response should be JSP processed", resp, not(containsString("<c:catch")));
+ assertThat("Response should be JSP processed", resp, not(containsString("<jtest:errortest")));
+ assertThat("Response", resp, containsString("[jtest:errorhandler] exception : "));
+ assertThat("Response", resp, containsString("[jtest:errorhandler] exception.message : "));
}
}
diff --git a/apache-jstl/src/test/taglibjar/META-INF/etag.tld b/apache-jstl/src/test/taglibjar/META-INF/etag.tld
new file mode 100644
index 0000000000..61f568c41d
--- /dev/null
+++ b/apache-jstl/src/test/taglibjar/META-INF/etag.tld
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<taglib xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
+ version="2.0">
+
+ <description>eclipse jetty test taglib</description>
+ <tlib-version>1.0</tlib-version>
+
+ <short-name>jtest</short-name>
+ <uri>org.eclipse.jetty.jstl.jtest</uri>
+
+ <tag-file>
+ <name>errortest</name>
+ <path>/META-INF/tags/errortest.tag</path>
+ </tag-file>
+
+ <tag-file>
+ <name>errorhandler</name>
+ <path>/META-INF/tags/errorhandler.tag</path>
+ </tag-file>
+</taglib> \ 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 0000000000..854952bc2f
--- /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"%>
+
+<c:catch var="error">
+ <jsp:doBody />
+</c:catch>
+
+<c:if test="${error != null}">
+[jtest:errorhandler] exception : ${error}
+[jtest:errorhandler] exception.message : ${error.message}
+</c:if>
+<c:if test="${error == null}">
+[jtest:errorhandler] exception is null
+</c:if>
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 0000000000..c41a875c0c
--- /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" %>
+
+<c:out value="content from jtest:errortest tag"/> \ 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 0000000000..06e2bcfd2b
--- /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 var ="catchException">
+ <fmt:parseNumber var="parsedNum" value="aaa" />
+</c:catch>
+
+<c:if test = "${catchException != null}">
+[c:catch] exception : ${catchException}
+[c:catch] exception.message : ${catchException.message}
+</c:if>
+<c:if test = "${catchException == null}">
+[c:catch] exception is null
+</c:if>
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 0000000000..68c7b8f50e
--- /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
+
+<jtest:errortest>
+ <fmt:parseNumber var="parsedNum" value="aaa" />
+</jtest:errortest>
+
+parsedNum = <c:out value="${parsedNum}"/> \ No newline at end of file

Back to the top