Skip to content

Commit 12c1df0

Browse files
committed
Add a test case that test returning a large file using RestResponse
1 parent 669f8c2 commit 12c1df0

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

extensions/resteasy-reactive/rest/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/providers/FileResource.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package io.quarkus.resteasy.reactive.server.test.providers;
22

33
import java.io.File;
4+
import java.io.IOException;
5+
import java.io.RandomAccessFile;
46
import java.nio.file.Paths;
57

68
import jakarta.ws.rs.GET;
79
import jakarta.ws.rs.Path;
10+
import jakarta.ws.rs.core.HttpHeaders;
811

912
import org.jboss.resteasy.reactive.FilePart;
1013
import org.jboss.resteasy.reactive.PathPart;
@@ -91,4 +94,19 @@ public Uni<AsyncFile> getAsyncFilePartial(RoutingContext vertxRequest) {
9194
});
9295
});
9396
}
97+
98+
static final long ONE_GIGA = 1024L * 1024L * 1024L;
99+
100+
@Path("large-path-rest-response")
101+
@GET
102+
public RestResponse<java.nio.file.Path> largePathRestResponse() throws IOException {
103+
File largeFile = File.createTempFile("rr-large-file-rest-response", ".tmp");
104+
largeFile.deleteOnExit();
105+
RandomAccessFile f = new RandomAccessFile(largeFile, "rw");
106+
f.setLength(ONE_GIGA);
107+
108+
return RestResponse.ResponseBuilder.ok(largeFile.toPath())
109+
.header(HttpHeaders.CONTENT_DISPOSITION, "large-file")
110+
.build();
111+
}
94112
}

extensions/resteasy-reactive/rest/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/providers/FileTestCase.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.jboss.resteasy.reactive.PathPart;
1515
import org.junit.jupiter.api.Assertions;
1616
import org.junit.jupiter.api.Test;
17+
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
1718
import org.junit.jupiter.api.extension.RegisterExtension;
1819

1920
import io.quarkus.test.QuarkusUnitTest;
@@ -168,4 +169,16 @@ public void testChecks() throws IOException {
168169
} catch (IllegalArgumentException x) {
169170
}
170171
}
172+
173+
@EnabledIfSystemProperty(named = "test-resteasy-reactive-large-files", matches = "true")
174+
@Test
175+
public void testWithLargeFile() {
176+
RestAssured.given()
177+
.get("/providers/file/large-path-rest-response")
178+
.then()
179+
.statusCode(200)
180+
.contentType("application/octet-stream")
181+
.header(HttpHeaders.CONTENT_DISPOSITION, "large-file")
182+
.header(HttpHeaders.CONTENT_LENGTH, "1073741824");
183+
}
171184
}

0 commit comments

Comments
 (0)