Removing GzipTester.assertIsResponseNotGzipCompressedAndEqualToExpectedString

This commit is contained in:
Joakim Erdfelt 2014-11-10 17:51:46 -07:00
parent 5de887f00f
commit f8e431da1f
2 changed files with 24 additions and 30 deletions

View File

@ -18,10 +18,16 @@
package org.eclipse.jetty.servlets;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import java.io.IOException;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.servlet.DispatcherType;
import javax.servlet.Filter;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
@ -48,7 +54,7 @@ import org.junit.runners.Parameterized.Parameters;
@RunWith(Parameterized.class)
public class GzipFilterDefaultTest
{
@Parameters
@Parameters(name="{1} - {0}")
public static List<Object[]> data()
{
return Arrays.asList(new Object[][]
@ -518,22 +524,31 @@ public class GzipFilterDefaultTest
public void testIsNotGzipCompressedHttpBadRequestStatus() throws Exception
{
GzipTester tester = new GzipTester(testingdir, compressionType);
tester.setGzipFilterClass(testFilter);
// Add Gzip Filter first
FilterHolder gzipHolder = new FilterHolder(testFilter);
gzipHolder.setAsyncSupported(true);
tester.addFilter(gzipHolder,"/*",EnumSet.of(DispatcherType.REQUEST,DispatcherType.ASYNC));
gzipHolder.setInitParameter("mimeTypes","text/plain");
// Test error code 400
FilterHolder holder = tester.setContentServlet(HttpErrorServlet.class);
holder.setInitParameter("mimeTypes","text/plain");
tester.setContentServlet(HttpErrorServlet.class);
try
{
tester.start();
tester.assertIsResponseNotGzipCompressedAndEqualToExpectedString("GET","error message", -1, 400);
HttpTester.Response response = tester.executeRequest("GET","/context/",2,TimeUnit.SECONDS);
assertThat("Response status", response.getStatus(), is(HttpStatus.BAD_REQUEST_400));
String content = tester.readResponse(response);
assertThat("Response content", content, is("error message"));
}
finally
{
tester.stop();
}
}
@Test

View File

@ -461,28 +461,6 @@ public class GzipTester
return response;
}
/**
* Asserts that the request results in a properly structured GzipFilter response, where the content is not compressed, and the content-length is returned
* appropriately.
*
* @param expectedResponse
* the expected response body string
* @param expectedFilesize
* the expected filesize to be specified on the Content-Length portion of the response headers. (note: passing -1 will disable the Content-Length
* assertion)
* @throws Exception
*/
public void assertIsResponseNotGzipCompressedAndEqualToExpectedString(String method, String expectedResponse, int expectedFilesize, int status)
throws Exception
{
String uri = "/context/";
HttpTester.Response response = executeRequest(method,uri);
assertResponseHeaders(expectedFilesize,status,response);
String actual = readResponse(response);
Assert.assertEquals("Expected response equals actual response",expectedResponse,actual);
}
/**
* Asserts that the request results in a properly structured GzipFilter response, where the content is not compressed, and the content-length is returned
* appropriately.
@ -546,7 +524,7 @@ public class GzipTester
return executeRequest(method,path,2,TimeUnit.SECONDS);
}
private String readResponse(HttpTester.Response response) throws IOException, UnsupportedEncodingException
public String readResponse(HttpTester.Response response) throws IOException, UnsupportedEncodingException
{
String actual = null;
InputStream in = null;
@ -688,7 +666,8 @@ public class GzipTester
{
return gzipFilterClass;
}
@Deprecated
public void setGzipFilterClass(Class<? extends Filter> gzipFilterClass)
{
this.gzipFilterClass = gzipFilterClass;