forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MultipartFormInputDevModeTest.java
79 lines (64 loc) · 2.75 KB
/
MultipartFormInputDevModeTest.java
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package io.quarkus.resteasy.reactive.server.test.multipart;
import static org.hamcrest.CoreMatchers.equalTo;
import java.io.File;
import java.util.function.Function;
import java.util.function.Supplier;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import io.quarkus.resteasy.reactive.server.test.multipart.other.OtherPackageFormDataBase;
import io.quarkus.test.QuarkusDevModeTest;
import io.restassured.RestAssured;
public class MultipartFormInputDevModeTest {
@RegisterExtension
static QuarkusDevModeTest TEST = new QuarkusDevModeTest()
.setArchiveProducer(new Supplier<JavaArchive>() {
@Override
public JavaArchive get() {
return ShrinkWrap.create(JavaArchive.class)
.addClasses(FormDataBase.class, OtherPackageFormDataBase.class, FormData.class, Status.class,
OtherFormData.class, OtherFormDataBase.class, MultipartResource.class);
}
});
private final File HTML_FILE = new File("./src/test/resources/test.html");
private final File XML_FILE = new File("./src/test/resources/test.html");
private final File TXT_FILE = new File("./src/test/resources/lorem.txt");
@Test
public void test() {
doTest("simple");
doTest("simple");
TEST.modifySourceFile(MultipartResource.class.getSimpleName() + ".java", new Function<String, String>() {
@Override
public String apply(String s) {
return s.replace("/simple", "/simple2");
}
});
doTest("simple2");
doTest("simple2");
TEST.modifySourceFile(MultipartResource.class.getSimpleName() + ".java", new Function<String, String>() {
@Override
public String apply(String s) {
return s.replace("/simple2", "/simple");
}
});
doTest("simple");
doTest("simple");
}
private void doTest(String path) {
RestAssured.given()
.multiPart("name", "Alice")
.multiPart("active", "true")
.multiPart("num", "25")
.multiPart("status", "WORKING")
.multiPart("htmlFile", HTML_FILE, "text/html")
.multiPart("xmlFile", XML_FILE, "text/xml")
.multiPart("txtFile", TXT_FILE, "text/plain")
.accept("text/plain")
.when()
.post("/multipart/" + path + "/2")
.then()
.statusCode(200)
.body(equalTo("Alice - true - 50 - WORKING - text/html - true - true"));
}
}