Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Wilkins2013-05-31 04:07:01 -0400
committerGreg Wilkins2013-05-31 04:07:01 -0400
commit0e11c8230712c2ce2206fc30f9606d640a231c0d (patch)
treeb52e29a8ed7f1768876d5f6ddd03bdd6ff265acd /jetty-servlets/src
parent842309e656f8ca6e99a523ddbf98542fcab9ac47 (diff)
downloadorg.eclipse.jetty.project-0e11c8230712c2ce2206fc30f9606d640a231c0d.tar.gz
org.eclipse.jetty.project-0e11c8230712c2ce2206fc30f9606d640a231c0d.tar.xz
org.eclipse.jetty.project-0e11c8230712c2ce2206fc30f9606d640a231c0d.zip
fixed merge
Diffstat (limited to 'jetty-servlets/src')
-rw-r--r--jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipFilterDefaultTest.java6
-rw-r--r--jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/GzipTester.java43
2 files changed, 44 insertions, 5 deletions
diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipFilterDefaultTest.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipFilterDefaultTest.java
index c496f0563d..1aaa301097 100644
--- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipFilterDefaultTest.java
+++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipFilterDefaultTest.java
@@ -289,8 +289,8 @@ public class GzipFilterDefaultTest
try
{
tester.start();
- HttpTester http = tester.assertIsResponseGzipCompressed("GET","file.txt",System.currentTimeMillis()-4000);
- Assert.assertEquals("Accept-Encoding",http.getHeader("Vary"));
+ HttpTester.Response http = tester.assertIsResponseGzipCompressed("GET","file.txt",System.currentTimeMillis()-4000);
+ Assert.assertEquals("Accept-Encoding",http.get("Vary"));
}
finally
{
@@ -315,7 +315,7 @@ public class GzipFilterDefaultTest
try
{
tester.start();
- HttpTester http = tester.assertIsResponseNotModified("GET","file.txt",System.currentTimeMillis()+4000);
+ tester.assertIsResponseNotModified("GET","file.txt",System.currentTimeMillis()+4000);
}
finally
{
diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/GzipTester.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/GzipTester.java
index 177af43474..3cf181a5ee 100644
--- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/GzipTester.java
+++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/gzip/GzipTester.java
@@ -47,6 +47,8 @@ import javax.servlet.DispatcherType;
import javax.servlet.Servlet;
import javax.servlet.http.HttpServletResponse;
+import org.eclipse.jetty.http.HttpFields;
+import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpTester;
import org.eclipse.jetty.servlet.FilterHolder;
import org.eclipse.jetty.servlet.ServletHolder;
@@ -77,11 +79,21 @@ public class GzipTester
public HttpTester.Response assertIsResponseGzipCompressed(String method, String filename) throws Exception
{
- return assertIsResponseGzipCompressed(method,filename,filename);
+ return assertIsResponseGzipCompressed(method,filename,filename,-1);
+ }
+
+ public HttpTester.Response assertIsResponseGzipCompressed(String method, String filename, long ifmodifiedsince) throws Exception
+ {
+ return assertIsResponseGzipCompressed(method,filename,filename,ifmodifiedsince);
}
public HttpTester.Response assertIsResponseGzipCompressed(String method, String requestedFilename, String serverFilename) throws Exception
{
+ return assertIsResponseGzipCompressed(method,requestedFilename,serverFilename,-1);
+ }
+
+ public HttpTester.Response assertIsResponseGzipCompressed(String method, String requestedFilename, String serverFilename, long ifmodifiedsince) throws Exception
+ {
// System.err.printf("[GzipTester] requesting /context/%s%n",requestedFilename);
HttpTester.Request request = HttpTester.newRequest();
HttpTester.Response response;
@@ -90,13 +102,15 @@ public class GzipTester
request.setVersion("HTTP/1.0");
request.setHeader("Host","tester");
request.setHeader("Accept-Encoding",compressionType);
+ if (ifmodifiedsince>0)
+ request.setHeader(HttpHeader.IF_MODIFIED_SINCE.asString(),HttpFields.formatDate(ifmodifiedsince));
if (this.userAgent != null)
request.setHeader("User-Agent", this.userAgent);
request.setURI("/context/" + requestedFilename);
// Issue the request
response = HttpTester.parseResponse(tester.getResponses(request.generate()));
-
+
// Assert the response headers
// Assert.assertThat("Response.status",response.getStatus(),is(HttpServletResponse.SC_OK));
Assert.assertThat("Response.header[Content-Length]",response.get("Content-Length"),notNullValue());
@@ -143,6 +157,31 @@ public class GzipTester
return response;
}
+
+ public HttpTester.Response assertIsResponseNotModified(String method, String requestedFilename, long ifmodifiedsince) throws Exception
+ { // System.err.printf("[GzipTester] requesting /context/%s%n",requestedFilename);
+ HttpTester.Request request = HttpTester.newRequest();
+ HttpTester.Response response;
+
+ request.setMethod(method);
+ request.setVersion("HTTP/1.0");
+ request.setHeader("Host","tester");
+ request.setHeader("Accept-Encoding",compressionType);
+ if (ifmodifiedsince>0)
+ request.setHeader(HttpHeader.IF_MODIFIED_SINCE.asString(),HttpFields.formatDate(ifmodifiedsince));
+ if (this.userAgent != null)
+ request.setHeader("User-Agent", this.userAgent);
+ request.setURI("/context/" + requestedFilename);
+
+ // Issue the request
+ response = HttpTester.parseResponse(tester.getResponses(request.generate()));
+
+ Assert.assertThat(response.getStatus(),Matchers.equalTo(304));
+ Assert.assertThat(response.get("ETag"),Matchers.startsWith("W/"));
+
+ return response;
+ }
+
/**
* Makes sure that the response contains an unfiltered file contents.
* <p>

Back to the top