Skip to content

Commit

Permalink
Merge pull request #25544 from Postremus/fix-windows-filetestcase-tes…
Browse files Browse the repository at this point in the history
…tfiles

Fix FileTestCase.testFiles on windows with core.autocrlf input
  • Loading branch information
geoand authored May 13, 2022
2 parents 035447b + f380ae9 commit c34043b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,6 @@

public class FileTestCase {

private final static String LOREM = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut\n"
+
"enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor\n"
+
"in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident,\n"
+
" sunt in culpa qui officia deserunt mollit anim id est laborum.\n" +
"\n" +
"";
private static final String FILE = "src/test/resources/lorem.txt";

@TestHTTPResource
Expand All @@ -43,13 +34,7 @@ public class FileTestCase {

@Test
public void testFiles() throws Exception {
// adjusting expected file size for Windows, whose git checkout will adjust line separators
String content;
if (System.lineSeparator().length() == 2) {
content = LOREM.replace("\n", System.lineSeparator());
} else {
content = LOREM;
}
String content = Files.readString(Path.of(FILE));
String contentLength = String.valueOf(content.length());
RestAssured.get("/providers/file/file")
.then()
Expand Down Expand Up @@ -90,7 +75,7 @@ public void testFiles() throws Exception {
.then()
.statusCode(200)
.header(HttpHeaders.CONTENT_LENGTH, "10")
.body(Matchers.equalTo(LOREM.substring(20, 30)));
.body(Matchers.equalTo(content.substring(20, 30)));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,6 @@

public class FileTestCase {

private final static String LOREM = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut\n"
+
"enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor\n"
+
"in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident,\n"
+
" sunt in culpa qui officia deserunt mollit anim id est laborum.\n" +
"\n" +
"";
private static final String FILE = "src/test/resources/lorem.txt";

@RegisterExtension
Expand All @@ -35,13 +26,8 @@ public class FileTestCase {

@Test
public void testFiles() throws Exception {
// adjusting expected file size for Windows, whose git checkout will adjust line separators
String content;
if (System.lineSeparator().length() == 2) {
content = LOREM.replace("\n", System.lineSeparator());
} else {
content = LOREM;
}

String content = Files.readString(Path.of(FILE));
String contentLength = String.valueOf(content.length());
RestAssured.get("/providers/file/file")
.then()
Expand Down Expand Up @@ -77,7 +63,7 @@ public void testFiles() throws Exception {
.then()
.statusCode(200)
.header(HttpHeaders.CONTENT_LENGTH, "10")
.body(Matchers.equalTo(LOREM.substring(20, 30)));
.body(Matchers.equalTo(content.substring(20, 30)));
}

@Test
Expand Down

0 comments on commit c34043b

Please sign in to comment.