forked from jooby-project/jooby
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIssue1676.java
More file actions
33 lines (29 loc) · 1.17 KB
/
Copy pathIssue1676.java
File metadata and controls
33 lines (29 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package io.jooby;
import io.jooby.junit.ServerTest;
import io.jooby.junit.ServerTestRunner;
import okhttp3.MultipartBody;
import java.util.stream.Collectors;
import static okhttp3.RequestBody.create;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class Issue1676 {
@ServerTest
public void shouldParseFileKeyFromMultipartUpload(ServerTestRunner runner) {
String content = "Proin pulvinar purus ac lacus pharetra, tristique fringilla lacus finibus. "
+ "Praesent bibendum tellus feugiat euismod sollicitudin. Integer sed sem vestibulum sem "
+ "imperdiet blandit. Vivamus in lorem quis orci gravida hendrerit.";
runner.define(app -> {
app.post("/1676", ctx ->
ctx.files().stream()
.collect(Collectors.toMap(FileUpload::getName, FileUpload::getFileName))
);
}).ready(client -> {
client.post("/1676", new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("filekey", "19kb.txt",
create(content, okhttp3.MediaType.parse("text/plain")))
.build(), rsp -> {
assertEquals("{filekey=19kb.txt}", rsp.body().string());
});
});
}
}