aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Wilkins2013-01-16 19:00:20 -0500
committerGreg Wilkins2013-01-16 19:00:20 -0500
commit46e13b305baee73b46359311cac4ff4959c7b500 (patch)
tree110170fe3f20ba8aa58aeb467c3795f9ded0605a
parente0b3c1b926dd506bd91fdfb7477ae713a4b81d6b (diff)
parent9cf08249e0ea94ea4e9fd3bf2cb6660066b2e936 (diff)
downloadorg.eclipse.jetty.project-46e13b305baee73b46359311cac4ff4959c7b500.zip
org.eclipse.jetty.project-46e13b305baee73b46359311cac4ff4959c7b500.tar.gz
org.eclipse.jetty.project-46e13b305baee73b46359311cac4ff4959c7b500.tar.xz
Merge remote-tracking branch 'origin/jetty-8'
Conflicts: jetty-util/src/test/java/org/eclipse/jetty/util/URLEncodedTest.java
-rw-r--r--jetty-util/src/main/java/org/eclipse/jetty/util/UrlEncoded.java2
-rw-r--r--jetty-util/src/test/java/org/eclipse/jetty/util/URLEncodedTest.java10
-rw-r--r--tests/test-integration/src/test/java/org/eclipse/jetty/test/jsp/FakeJspServlet.java65
-rw-r--r--tests/test-integration/src/test/java/org/eclipse/jetty/test/jsp/JspAndDefaultWithAliasesTest.java7
-rw-r--r--tests/test-integration/src/test/java/org/eclipse/jetty/test/jsp/JspAndDefaultWithoutAliasesTest.java3
5 files changed, 79 insertions, 8 deletions
diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/UrlEncoded.java b/jetty-util/src/main/java/org/eclipse/jetty/util/UrlEncoded.java
index 5460db9..f62e025 100644
--- a/jetty-util/src/main/java/org/eclipse/jetty/util/UrlEncoded.java
+++ b/jetty-util/src/main/java/org/eclipse/jetty/util/UrlEncoded.java
@@ -566,7 +566,7 @@ public class UrlEncoded extends MultiMap<String> implements Cloneable
StringWriter buf = new StringWriter(8192);
IO.copy(input,buf,maxLength);
- decodeTo(buf.getBuffer().toString(),map,ENCODING,maxKeys);
+ decodeTo(buf.getBuffer().toString(),map,StringUtil.__UTF16,maxKeys);
}
/* -------------------------------------------------------------- */
diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/URLEncodedTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/URLEncodedTest.java
index 80cde73..258d023 100644
--- a/jetty-util/src/test/java/org/eclipse/jetty/util/URLEncodedTest.java
+++ b/jetty-util/src/test/java/org/eclipse/jetty/util/URLEncodedTest.java
@@ -175,16 +175,16 @@ public class URLEncodedTest
{
String [][] charsets = new String[][]
{
- {StringUtil.__UTF8,null},
- {StringUtil.__ISO_8859_1,StringUtil.__ISO_8859_1},
- {StringUtil.__UTF8,StringUtil.__UTF8},
- {StringUtil.__UTF16,StringUtil.__UTF16},
+ {StringUtil.__UTF8,null,"%30"},
+ {StringUtil.__ISO_8859_1,StringUtil.__ISO_8859_1,"%30"},
+ {StringUtil.__UTF8,StringUtil.__UTF8,"%30"},
+ {StringUtil.__UTF16,StringUtil.__UTF16,"%00%30"},
};
for (int i=0;i<charsets.length;i++)
{
- ByteArrayInputStream in = new ByteArrayInputStream("name\n=value+%30&name1=&name2&n\u00e3me3=value+3".getBytes(charsets[i][0]));
+ ByteArrayInputStream in = new ByteArrayInputStream(("name\n=value+"+charsets[i][2]+"&name1=&name2&n\u00e3me3=value+3").getBytes(charsets[i][0]));
MultiMap<String> m = new MultiMap<>();
UrlEncoded.decodeTo(in, m, charsets[i][1]==null?null:Charset.forName(charsets[i][1]), -1,-1);
assertEquals(charsets[i][1]+" stream length",4,m.size());
diff --git a/tests/test-integration/src/test/java/org/eclipse/jetty/test/jsp/FakeJspServlet.java b/tests/test-integration/src/test/java/org/eclipse/jetty/test/jsp/FakeJspServlet.java
new file mode 100644
index 0000000..2397fae
--- /dev/null
+++ b/tests/test-integration/src/test/java/org/eclipse/jetty/test/jsp/FakeJspServlet.java
@@ -0,0 +1,65 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+//
+
+package org.eclipse.jetty.test.jsp;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class FakeJspServlet extends HttpServlet
+{
+
+ /* ------------------------------------------------------------ */
+ /*
+ * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ */
+ protected void doGet(HttpServletRequest req, HttpServletResponse response) throws ServletException, IOException
+ {
+ String path = req.getServletPath();
+ URL url =getServletContext().getResource(path);
+ if (url==null)
+ {
+ response.sendError(404);
+ return;
+ }
+
+ try
+ {
+ File file=new File(url.toURI());
+ if (file.exists())
+ {
+ response.sendError(200,"fake JSP response");
+ return;
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+
+ response.sendError(404);
+ }
+
+}
diff --git a/tests/test-integration/src/test/java/org/eclipse/jetty/test/jsp/JspAndDefaultWithAliasesTest.java b/tests/test-integration/src/test/java/org/eclipse/jetty/test/jsp/JspAndDefaultWithAliasesTest.java
index 6dc439d..019a3c7 100644
--- a/tests/test-integration/src/test/java/org/eclipse/jetty/test/jsp/JspAndDefaultWithAliasesTest.java
+++ b/tests/test-integration/src/test/java/org/eclipse/jetty/test/jsp/JspAndDefaultWithAliasesTest.java
@@ -34,6 +34,7 @@ import org.eclipse.jetty.security.HashLoginService;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.nio.SelectChannelConnector;
import org.eclipse.jetty.servlet.DefaultServlet;
+import org.eclipse.jetty.servlet.NoJspServlet;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
@@ -106,7 +107,8 @@ public class JspAndDefaultWithAliasesTest
defaultServHolder.setInitParameter("aliases","true"); // important! must be TRUE
// add jsp
- ServletHolder jsp = context.addServlet(JspServlet.class,"*.jsp");
+ ServletHolder jsp = new ServletHolder(new FakeJspServlet());
+ context.addServlet(jsp,"*.jsp");
jsp.setInitParameter("classpath",context.getClassPath());
// add context
@@ -157,6 +159,9 @@ public class JspAndDefaultWithAliasesTest
return;
}
+ if (conn.getResponseCode()!=404)
+ System.err.println(conn.getResponseMessage());
+
// Of other possible paths, only 404 Not Found is expected
Assert.assertThat("Response Code",conn.getResponseCode(),is(404));
}
diff --git a/tests/test-integration/src/test/java/org/eclipse/jetty/test/jsp/JspAndDefaultWithoutAliasesTest.java b/tests/test-integration/src/test/java/org/eclipse/jetty/test/jsp/JspAndDefaultWithoutAliasesTest.java
index 8ff5160..3a82d88 100644
--- a/tests/test-integration/src/test/java/org/eclipse/jetty/test/jsp/JspAndDefaultWithoutAliasesTest.java
+++ b/tests/test-integration/src/test/java/org/eclipse/jetty/test/jsp/JspAndDefaultWithoutAliasesTest.java
@@ -106,7 +106,8 @@ public class JspAndDefaultWithoutAliasesTest
defaultServHolder.setInitParameter("aliases","false"); // important! must be FALSE
// add jsp
- ServletHolder jsp = context.addServlet(JspServlet.class,"*.jsp");
+ ServletHolder jsp = new ServletHolder(new FakeJspServlet());
+ context.addServlet(jsp,"*.jsp");
jsp.setInitParameter("classpath",context.getClassPath());
// add context