コード例 #1
0
  @Test
  public void testIsNotGzipCompressedHttpStatus() throws Exception {
    GzipTester tester = new GzipTester(testingdir, compressionType);

    // Test error code 204
    FilterHolder holder = tester.setContentServlet(HttpStatusServlet.class);
    holder.setInitParameter("mimeTypes", "text/plain");

    try {
      tester.start();
      tester.assertIsResponseNotGzipCompressed(-1, 204);
    } finally {
      tester.stop();
    }
  }
コード例 #2
0
  @Test
  public void testExcludePathPatterns() throws Exception {
    GzipTester tester = new GzipTester(testingdir, compressionType);

    FilterHolder holder = tester.setContentServlet(DefaultServlet.class);
    holder.setInitParameter("excludePathPatterns", "/cont.*");

    int filesize = CompressedResponseWrapper.DEFAULT_BUFFER_SIZE * 4;
    tester.prepareServerFile("file.txt", filesize);

    try {
      tester.start();
      tester.assertIsResponseNotGzipCompressed("file.txt", filesize, HttpStatus.OK_200);
    } finally {
      tester.stop();
    }
  }
コード例 #3
0
  @Test
  public void testIsNotGzipCompressed() throws Exception {
    GzipTester tester = new GzipTester(testingdir, compressionType);

    int filesize = CompressedResponseWrapper.DEFAULT_BUFFER_SIZE * 4;
    tester.prepareServerFile("file.mp3", filesize);

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

    try {
      tester.start();
      HttpTester.Response http =
          tester.assertIsResponseNotGzipCompressed("file.mp3", filesize, HttpStatus.OK_200);
      Assert.assertNull(http.get("Vary"));
    } finally {
      tester.stop();
    }
  }
コード例 #4
0
  private void assertIsNotGzipCompressed(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();
      HttpTester.Response response =
          tester.assertIsResponseNotGzipCompressed(
              "GET", testfile.getName(), filesize, HttpStatus.OK_200);
      Assert.assertThat(response.get("ETAG"), Matchers.startsWith("W/etag-"));
    } finally {
      tester.stop();
    }
  }