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.
Merge pull request quarkusio#14101 from gsmet/resteasy-parttype
Collect providers required for RESTEasy's @PartType annotations
- Loading branch information
Showing
7 changed files
with
115 additions
and
1 deletion.
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
23 changes: 23 additions & 0 deletions
23
...ultipart/deployment/src/test/java/io/quarkus/resteasy/multipart/parttype/PartTypeDto.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,23 @@ | ||
package io.quarkus.resteasy.multipart.parttype; | ||
|
||
import java.util.Map; | ||
|
||
import javax.ws.rs.FormParam; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
import org.jboss.resteasy.annotations.providers.multipart.PartType; | ||
|
||
public class PartTypeDto { | ||
|
||
@FormParam("myMapping") | ||
@PartType(MediaType.APPLICATION_JSON) | ||
public Map<String, String> myMapping; | ||
|
||
@FormParam("flag") | ||
@PartType(MediaType.TEXT_PLAIN) | ||
public boolean flag; | ||
|
||
@FormParam("reproduceEnum") | ||
@PartType(MediaType.TEXT_PLAIN) | ||
public PartTypeEnum partTypeEnum; | ||
} |
6 changes: 6 additions & 0 deletions
6
...ltipart/deployment/src/test/java/io/quarkus/resteasy/multipart/parttype/PartTypeEnum.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,6 @@ | ||
package io.quarkus.resteasy.multipart.parttype; | ||
|
||
public enum PartTypeEnum { | ||
PENDING, | ||
ACTIVE; | ||
} |
41 changes: 41 additions & 0 deletions
41
...eployment/src/test/java/io/quarkus/resteasy/multipart/parttype/PartTypeMultipartTest.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,41 @@ | ||
package io.quarkus.resteasy.multipart.parttype; | ||
|
||
import java.net.URISyntaxException; | ||
|
||
import javax.ws.rs.core.MediaType; | ||
|
||
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.test.QuarkusUnitTest; | ||
import io.restassured.RestAssured; | ||
import io.restassured.builder.MultiPartSpecBuilder; | ||
import io.restassured.specification.MultiPartSpecification; | ||
|
||
public class PartTypeMultipartTest { | ||
|
||
@RegisterExtension | ||
static QuarkusUnitTest TEST = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(PartTypeDto.class, PartTypeEnum.class, PartTypeResource.class)); | ||
|
||
@Test | ||
public void testMultipartEncoding() throws URISyntaxException { | ||
MultiPartSpecification multiPartSpecification = new MultiPartSpecBuilder("{ \"key\": \"value\" }") | ||
.controlName("myMapping") | ||
.mimeType(MediaType.APPLICATION_JSON) | ||
.build(); | ||
|
||
RestAssured | ||
.given() | ||
.multiPart(multiPartSpecification) | ||
.multiPart("flag", "true") | ||
.multiPart("partTypeEnum", "ACTIVE") | ||
.post("/test/part-type/") | ||
.then() | ||
.statusCode(200); | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
...art/deployment/src/test/java/io/quarkus/resteasy/multipart/parttype/PartTypeResource.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,25 @@ | ||
package io.quarkus.resteasy.multipart.parttype; | ||
|
||
import javax.transaction.Transactional; | ||
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; | ||
import javax.ws.rs.core.Response; | ||
|
||
import org.jboss.resteasy.annotations.providers.multipart.MultipartForm; | ||
|
||
@Path("/test/part-type/") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
@Consumes(MediaType.APPLICATION_JSON) | ||
public final class PartTypeResource { | ||
|
||
@POST | ||
@Consumes({ MediaType.MULTIPART_FORM_DATA }) | ||
@Produces({ MediaType.APPLICATION_JSON }) | ||
@Transactional | ||
public Response reproduce(@MultipartForm PartTypeDto reproduceDto) { | ||
return Response.ok().build(); | ||
} | ||
} |