forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow using @Blocking on implementation in addition to interface for …
…JAX-RS Resources Fixes: quarkusio#15940
- Loading branch information
Showing
2 changed files
with
126 additions
and
41 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
.../src/test/java/io/quarkus/resteasy/reactive/server/test/simple/InterfaceWithImplTest.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,67 @@ | ||
package io.quarkus.resteasy.reactive.server.test.simple; | ||
|
||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
import org.hamcrest.Matchers; | ||
import org.jboss.resteasy.reactive.server.core.BlockingOperationSupport; | ||
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.smallrye.common.annotation.Blocking; | ||
|
||
public class InterfaceWithImplTest { | ||
|
||
@RegisterExtension | ||
static QuarkusUnitTest test = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(Greeting.class, GreetingImpl.class)); | ||
|
||
@Test | ||
public void test() { | ||
RestAssured.get("/hello/greeting/universe") | ||
.then().body(Matchers.equalTo("name: universe / blocking: true")); | ||
|
||
RestAssured.get("/hello/greeting2/universe") | ||
.then().body(Matchers.equalTo("name: universe / blocking: false")); | ||
} | ||
|
||
@Path("/hello") | ||
public interface Greeting { | ||
|
||
@GET | ||
@Produces(MediaType.TEXT_PLAIN) | ||
@Path("/greeting/{name}") | ||
String greeting(String name); | ||
|
||
@GET | ||
@Produces(MediaType.TEXT_PLAIN) | ||
@Path("/greeting2/{name}") | ||
String greeting2(String name); | ||
} | ||
|
||
public static class GreetingImpl implements Greeting { | ||
|
||
@Override | ||
@Blocking | ||
public String greeting(String name) { | ||
return resultString(name); | ||
} | ||
|
||
@Override | ||
public String greeting2(String name) { | ||
return resultString(name); | ||
} | ||
|
||
private String resultString(String name) { | ||
return "name: " + name + " / blocking: " + BlockingOperationSupport.isBlockingAllowed(); | ||
} | ||
} | ||
|
||
} |
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