-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19408 from stuartwdouglas/19404
Fix handling multipart requests manually
- Loading branch information
Showing
5 changed files
with
90 additions
and
3 deletions.
There are no files selected for viewing
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
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
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
21 changes: 21 additions & 0 deletions
21
...x/src/test/java/org/jboss/resteasy/reactive/server/vertx/test/multipart/EchoResource.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,21 @@ | ||
package org.jboss.resteasy.reactive.server.vertx.test.multipart; | ||
|
||
import io.smallrye.common.annotation.NonBlocking; | ||
import java.nio.charset.StandardCharsets; | ||
import javax.ws.rs.Consumes; | ||
import javax.ws.rs.POST; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
@Path("/echo") | ||
public class EchoResource { | ||
|
||
@POST | ||
@Consumes(MediaType.MULTIPART_FORM_DATA) | ||
@Produces(MediaType.TEXT_PLAIN) | ||
@NonBlocking | ||
public String echo(byte[] request) { | ||
return new String(request, StandardCharsets.UTF_8); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...st/java/org/jboss/resteasy/reactive/server/vertx/test/multipart/RawMultipartTestCase.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,34 @@ | ||
package org.jboss.resteasy.reactive.server.vertx.test.multipart; | ||
|
||
import io.restassured.RestAssured; | ||
import java.util.function.Supplier; | ||
import org.hamcrest.Matchers; | ||
import org.jboss.resteasy.reactive.server.vertx.test.framework.ResteasyReactiveUnitTest; | ||
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; | ||
|
||
public class RawMultipartTestCase { | ||
|
||
@RegisterExtension | ||
static ResteasyReactiveUnitTest test = new ResteasyReactiveUnitTest() | ||
.setArchiveProducer(new Supplier<JavaArchive>() { | ||
@Override | ||
public JavaArchive get() { | ||
return ShrinkWrap.create(JavaArchive.class).addClass(EchoResource.class); | ||
} | ||
}); | ||
|
||
@Test | ||
public void testHelloEndpoint() { | ||
RestAssured.given() | ||
.when() | ||
.multiPart("testName", "testValue") | ||
.post("/echo") | ||
.then() | ||
.statusCode(200) | ||
.body(Matchers.containsString("testValue")); | ||
} | ||
|
||
} |