Skip to content

Commit

Permalink
Add test case for content-range
Browse files Browse the repository at this point in the history
Submitted by Justin Chen.
  • Loading branch information
rmaucher committed Nov 18, 2024
1 parent 631500b commit 0229838
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ public static Collection<Object[]> parameters() {
// Valid range
parameterSets.add(new Object[] {
"bytes=0-9", null, Integer.valueOf(206), "10", "0-9/" + len });
parameterSets.add(new Object[] {
"bytes=0-9,10-10", null, Integer.valueOf(206), null, "0-9/" + len });
parameterSets.add(new Object[] {
"bytes=-100", null, Integer.valueOf(206), "100", (len - 100) + "-" + (len - 1) + "/" + len });
parameterSets.add(new Object[] {
Expand Down Expand Up @@ -140,7 +142,7 @@ public void testRange() throws Exception {
// Check the result
Assert.assertEquals(responseCodeExpected, rc);

if (contentLengthExpected.length() > 0) {
if (contentLengthExpected != null && contentLengthExpected.length() > 0) {
String contentLength = responseHeaders.get("Content-Length").get(0);
Assert.assertEquals(contentLengthExpected, contentLength);
}
Expand All @@ -151,7 +153,14 @@ public void testRange() throws Exception {
if (headerValues != null && headerValues.size() == 1) {
responseRange = headerValues.get(0);
}
Assert.assertEquals("bytes " + responseRangeExpected, responseRange);
if (responseRange != null) {
Assert.assertEquals("bytes " + responseRangeExpected, responseRange);
} else {
Assert.assertTrue(
"Expected `Content-Range: " + "bytes " + responseRangeExpected +
"` in multipart/byteranges response body not found!",
responseBody.toString().contains("bytes " + responseRangeExpected));
}
}
}

Expand Down

0 comments on commit 0229838

Please sign in to comment.