Skip to content

Commit

Permalink
[ServletTest] Always checkout test resources with UNIX line-ending
Browse files Browse the repository at this point in the history
  • Loading branch information
HannesWell committed May 2, 2024
1 parent d5e0f49 commit c0b03f6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Ensure the matching text-files are checked out with Unix-line endings (LF) on all platforms
rangerequest.mp4 text eol=lf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Ensure the matching text-files are checked out with Unix-line endings (LF) on all platforms
test text eol=lf
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import java.util.HashSet;
import java.util.Hashtable;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
Expand Down Expand Up @@ -126,7 +125,6 @@
import org.osgi.util.tracker.ServiceTracker;

public class ServletTest extends BaseTest {
public static final boolean IS_WINDOWS = System.getProperty("os.name").toLowerCase(Locale.ENGLISH).contains("win");

@Rule
public TestName testName = new TestName();
Expand Down Expand Up @@ -1970,7 +1968,7 @@ public void test_ResourceAliasSlash() throws Exception {
assertEquals("Wrong value.", "test\n", actual);
}

private static final int MP4_CONTENT_LENGTH = (20_400 + 255 * System.lineSeparator().length());
private static final int MP4_CONTENT_LENGTH = 81 * 255;
private static final List<String> EXPECTED_MP4_CONTENT_RANGE = List
.of("bytes 0-" + (MP4_CONTENT_LENGTH - 1) + "/" + MP4_CONTENT_LENGTH);
private static final List<String> EXPECTED_MP4_CONTENT_LENGTH = List.of(String.valueOf(MP4_CONTENT_LENGTH));
Expand Down Expand Up @@ -2035,10 +2033,8 @@ public String getMimeType(String filename) {
assertEquals("Content-Length", Collections.singletonList("9000"), actual.get("Content-Length"));
assertEquals("Accept-Ranges", Collections.singletonList("bytes"), actual.get("Accept-Ranges"));
assertEquals("Content-Range", List.of("bytes 1000-9999/" + MP4_CONTENT_LENGTH), actual.get("Content-Range"));
assertEquals("Response Body Prefix", IS_WINDOWS ? "789" : "901",
actual.get("responseBody").get(0).substring(0, 3));
assertEquals("Response Body Suffix", IS_WINDOWS ? "678" : "567",
actual.get("responseBody").get(0).substring(8997, 9000));
assertEquals("Response Body Prefix", "901", actual.get("responseBody").get(0).substring(0, 3));
assertEquals("Response Body Suffix", "567", actual.get("responseBody").get(0).substring(8997, 9000));
}

@Test
Expand Down Expand Up @@ -2077,8 +2073,7 @@ public boolean rangeableContentType(String contentType, String userAgent) {
assertEquals("Accept-Ranges", Collections.singletonList("bytes"), actual.get("Accept-Ranges"));
assertEquals("Content-Range", EXPECTED_MP4_CONTENT_RANGE, actual.get("Content-Range"));
assertEquals("Response Body Prefix", "123", actual.get("responseBody").get(0).substring(0, 3));
assertEquals("Response Body Suffix", IS_WINDOWS ? "012" : "789",
actual.get("responseBody").get(0).substring(8997, 9000));
assertEquals("Response Body Suffix", "789", actual.get("responseBody").get(0).substring(8997, 9000));
}

@Test
Expand Down Expand Up @@ -3116,9 +3111,9 @@ public void test_ServletContextHelper11() throws Exception {
getHttpService().registerResources("/" + HTTP_CONTEXT_TEST_ROOT + "/1", "", ctx1);
getHttpService().registerResources("/" + HTTP_CONTEXT_TEST_ROOT + "/2", "", ctx2);
actual = requestAdvisor.request(HTTP_CONTEXT_TEST_ROOT + "/1/test");
assertEquals("1" + System.lineSeparator(), actual);
assertEquals("1\n", actual);
actual = requestAdvisor.request(HTTP_CONTEXT_TEST_ROOT + "/2/test");
assertEquals("2" + System.lineSeparator(), actual);
assertEquals("2\n", actual);
} finally {
try {
getHttpService().unregister("/" + HTTP_CONTEXT_TEST_ROOT + "/1");
Expand Down

0 comments on commit c0b03f6

Please sign in to comment.