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.
Merge pull request quarkusio#8536 from mkouba/vertx-web-route-perf
Reactive routes - improve @route method invocation performance
- Loading branch information
Showing
4 changed files
with
210 additions
and
28 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
51 changes: 51 additions & 0 deletions
51
extensions/vertx-web/deployment/src/test/java/io/quarkus/vertx/web/DependentRouteTest.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,51 @@ | ||
package io.quarkus.vertx.web; | ||
|
||
import static io.restassured.RestAssured.when; | ||
import static org.hamcrest.Matchers.is; | ||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import java.util.concurrent.atomic.AtomicBoolean; | ||
|
||
import javax.annotation.PreDestroy; | ||
import javax.enterprise.context.Dependent; | ||
|
||
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.vertx.ext.web.RoutingContext; | ||
|
||
public class DependentRouteTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(SimpleBean.class)); | ||
|
||
@Test | ||
public void testSimpleRoute() { | ||
assertFalse(SimpleBean.DESTROYED.get()); | ||
when().get("/hello").then().statusCode(200).body(is("Hello!")); | ||
assertTrue(SimpleBean.DESTROYED.get()); | ||
} | ||
|
||
@Dependent | ||
static class SimpleBean { | ||
|
||
static final AtomicBoolean DESTROYED = new AtomicBoolean(false); | ||
|
||
@Route(path = "/hello") | ||
void hello(RoutingContext context) { | ||
context.response().setStatusCode(200).end("Hello!"); | ||
} | ||
|
||
@PreDestroy | ||
void destroy() { | ||
DESTROYED.set(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
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