forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix dev-mode CL issue with multipart form handling
Fixes: quarkusio#16794
- Loading branch information
Showing
2 changed files
with
93 additions
and
2 deletions.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
...ava/io/quarkus/resteasy/reactive/server/test/multipart/MultipartFormInputDevModeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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")); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters