Skip to content

Commit

Permalink
Merge pull request #696 from mchoma/UNDERTOW-1444
Browse files Browse the repository at this point in the history
Regression test for Undertow 1444
  • Loading branch information
stuartwdouglas committed Dec 11, 2018
2 parents 51231e4 + ab6f13f commit cff7c3e
Showing 1 changed file with 25 additions and 1 deletion.
Expand Up @@ -60,6 +60,7 @@
@RunWith(DefaultServer.class)
public class DefaultServletCachingTestCase {

private static final int MAX_FILE_SIZE = 20;
private static final int METADATA_MAX_AGE = 2000;
public static final String DIR_NAME = "cacheTest";

Expand All @@ -86,7 +87,7 @@ public static void setup() throws ServletException, IOException {
.setClassLoader(ServletPathMappingTestCase.class.getClassLoader())
.setContextPath("/servletContext")
.setDeploymentName("servletContext.war")
.setResourceManager(new CachingResourceManager(100, 10000, dataCache, new PathResourceManager(tmpDir, 10485760, false, false, false), METADATA_MAX_AGE));
.setResourceManager(new CachingResourceManager(100, MAX_FILE_SIZE, dataCache, new PathResourceManager(tmpDir, 10485760, false, false, false), METADATA_MAX_AGE));

builder.addServlet(new ServletInfo("DefaultTestServlet", PathTestServlet.class)
.addMapping("/path/default"))
Expand Down Expand Up @@ -224,4 +225,27 @@ public void testRangeRequest() throws IOException {
}
}

/**
* Regression test for UNDERTOW-1444.
*
* Tested file is bigger then {@value #MAX_FILE_SIZE} bytes.
*/
@Test
public void testRangeRequestFileNotInCache() throws IOException {
TestHttpClient client = new TestHttpClient();
try {
String fileName = "range_not_in_cache.html";
Path f = tmpDir.resolve(fileName);
Files.write(f, "hello world and once again hello world".getBytes());
HttpGet get = new HttpGet(DefaultServer.getDefaultServerURL() + "/servletContext/range_not_in_cache.html");
get.addHeader("range", "bytes=2-3");
HttpResponse result = client.execute(get);
Assert.assertEquals(StatusCodes.PARTIAL_CONTENT, result.getStatusLine().getStatusCode());
String response = HttpClientUtils.readResponse(result);
Assert.assertEquals("ll", response);
} finally {
client.getConnectionManager().shutdown();
}
}

}

0 comments on commit cff7c3e

Please sign in to comment.