Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also add a test verifying that verticle instances can be beans.
- Loading branch information
1 parent
7b0a750
commit ec3b4c3
Showing
4 changed files
with
158 additions
and
0 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
20 changes: 20 additions & 0 deletions
20
extensions/vertx/deployment/src/test/java/io/quarkus/vertx/verticles/MyBeanVerticle.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,20 @@ | ||
package io.quarkus.vertx.verticles; | ||
|
||
import io.smallrye.mutiny.Uni; | ||
import io.smallrye.mutiny.vertx.core.AbstractVerticle; | ||
import org.eclipse.microprofile.config.inject.ConfigProperty; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
|
||
@ApplicationScoped | ||
public class MyBeanVerticle extends AbstractVerticle { | ||
|
||
@ConfigProperty(name = "address") String address; | ||
|
||
@Override | ||
public Uni<Void> asyncStart() { | ||
return vertx.eventBus().consumer(address) | ||
.handler(m -> m.replyAndForget("hello")) | ||
.completionHandler(); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
extensions/vertx/deployment/src/test/java/io/quarkus/vertx/verticles/VerticleDeployer.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,20 @@ | ||
package io.quarkus.vertx.verticles; | ||
|
||
import io.quarkus.runtime.StartupEvent; | ||
import io.vertx.mutiny.core.Vertx; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.enterprise.event.Observes; | ||
import javax.inject.Inject; | ||
|
||
@ApplicationScoped | ||
public class VerticleDeployer { | ||
|
||
@Inject Vertx vertx; | ||
@Inject MyBeanVerticle verticle; | ||
|
||
public void init(@Observes StartupEvent e) { | ||
vertx.deployVerticle(verticle).await().indefinitely(); | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
...ons/vertx/deployment/src/test/java/io/quarkus/vertx/verticles/VerticleDeploymentTest.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,38 @@ | ||
package io.quarkus.vertx.verticles; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.quarkus.vertx.AxleCodecTest; | ||
import io.quarkus.vertx.MyPetCodec; | ||
import io.quarkus.vertx.Person; | ||
import io.quarkus.vertx.Pet; | ||
import io.vertx.mutiny.core.Vertx; | ||
import io.vertx.mutiny.core.eventbus.Message; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import javax.inject.Inject; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class VerticleDeploymentTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap | ||
.create(JavaArchive.class) | ||
.addClasses(MyBeanVerticle.class, VerticleDeployer.class) | ||
.addAsResource(new StringAsset("address=foo"), "application.properties")); | ||
|
||
@Inject Vertx vertx; | ||
|
||
@Test | ||
public void test() { | ||
String s = vertx.eventBus().<String>request("foo", "anyone?") | ||
.onItem().apply(Message::body) | ||
.await().indefinitely(); | ||
assertThat(s).isEqualTo("hello"); | ||
} | ||
} |