private void assertIsGzipCompressed(String filename, int filesize) throws Exception {
    GzipTester tester = new GzipTester(testingdir, compressionType);

    File testfile =
        tester.prepareServerFile(testServlet.getSimpleName() + "-" + filename, filesize);

    FilterHolder holder = tester.setContentServlet(testServlet);
    holder.setInitParameter("mimeTypes", "text/plain");

    try {
      tester.start();
      tester.assertIsResponseGzipCompressed("GET", testfile.getName());
    } finally {
      tester.stop();
    }
  }
  @Test
  public void testIsGzipCompressedTiny() throws Exception {
    GzipTester tester = new GzipTester(testingdir, compressionType);

    // Test content that is smaller than the buffer.
    int filesize = CompressedResponseWrapper.DEFAULT_BUFFER_SIZE / 4;
    tester.prepareServerFile("file.txt", filesize);

    FilterHolder holder = tester.setContentServlet(org.eclipse.jetty.servlet.DefaultServlet.class);
    holder.setInitParameter("mimeTypes", "text/plain");

    try {
      tester.start();
      HttpTester.Response http = tester.assertIsResponseGzipCompressed("file.txt");
      Assert.assertEquals("Accept-Encoding", http.get("Vary"));
    } finally {
      tester.stop();
    }
  }
示例#3
0
 public void assertIsResponseGzipCompressed(String filename) throws Exception {
   assertIsResponseGzipCompressed(filename, filename);
 }