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.
Properly handle @Blocking on an JAX-RS Application class
Fixes: quarkusio#14397
- Loading branch information
Showing
4 changed files
with
74 additions
and
9 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
63 changes: 63 additions & 0 deletions
63
...est/java/io/quarkus/resteasy/reactive/server/test/simple/ApplicationWithBlockingTest.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,63 @@ | ||
package io.quarkus.resteasy.reactive.server.test.simple; | ||
|
||
import java.util.function.Supplier; | ||
|
||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.core.Application; | ||
|
||
import org.hamcrest.Matchers; | ||
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; | ||
import io.smallrye.common.annotation.NonBlocking; | ||
|
||
public class ApplicationWithBlockingTest { | ||
|
||
@RegisterExtension | ||
static QuarkusUnitTest test = new QuarkusUnitTest() | ||
.setArchiveProducer(new Supplier<JavaArchive>() { | ||
@Override | ||
public JavaArchive get() { | ||
return ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(BlockingApplication.class, ThreadNameResource.class); | ||
} | ||
}); | ||
|
||
@Test | ||
public void test() { | ||
RestAssured.get("/tname/blocking") | ||
.then().body(Matchers.containsString("executor"), Matchers.not(Matchers.containsString("loop"))); | ||
|
||
RestAssured.get("/tname/nonblocking") | ||
.then().body(Matchers.containsString("loop"), Matchers.not(Matchers.containsString("executor"))); | ||
} | ||
|
||
@Blocking | ||
public static class BlockingApplication extends Application { | ||
|
||
} | ||
|
||
@Path("tname") | ||
public static class ThreadNameResource { | ||
|
||
@Path("blocking") | ||
@GET | ||
public String threadName() { | ||
return Thread.currentThread().getName(); | ||
} | ||
|
||
@NonBlocking | ||
@Path("nonblocking") | ||
@GET | ||
public String nonBlocking() { | ||
return Thread.currentThread().getName(); | ||
} | ||
} | ||
|
||
} |
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