-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for VertxOptionsCustomizer
- Loading branch information
1 parent
fee39a6
commit 5e4d11b
Showing
5 changed files
with
110 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
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
53 changes: 53 additions & 0 deletions
53
...rtx/deployment/src/test/java/io/quarkus/vertx/customizers/VertxOptionsCustomizerTest.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,53 @@ | ||
package io.quarkus.vertx.customizers; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.inject.Inject; | ||
|
||
import org.assertj.core.api.Assertions; | ||
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.quarkus.vertx.VertxOptionsCustomizer; | ||
import io.vertx.core.VertxOptions; | ||
import io.vertx.core.file.FileSystemOptions; | ||
import io.vertx.mutiny.core.Vertx; | ||
|
||
public class VertxOptionsCustomizerTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap | ||
.create(JavaArchive.class).addClasses(MyCustomizer.class)); | ||
|
||
@Inject | ||
Vertx vertx; | ||
|
||
@Inject | ||
MyCustomizer customizer; | ||
|
||
@Test | ||
public void testCustomizer() { | ||
Assertions.assertThat(customizer.wasInvoked()).isTrue(); | ||
String test = vertx.fileSystem().createTempDirectoryAndAwait("test"); | ||
Assertions.assertThat(test).contains("target", "test"); | ||
} | ||
|
||
@ApplicationScoped | ||
public static class MyCustomizer implements VertxOptionsCustomizer { | ||
|
||
volatile boolean invoked; | ||
|
||
@Override | ||
public void accept(VertxOptions options) { | ||
invoked = true; | ||
options.setFileSystemOptions(new FileSystemOptions().setFileCacheDir("target")); | ||
} | ||
|
||
public boolean wasInvoked() { | ||
return invoked; | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
extensions/vertx/runtime/src/main/java/io/quarkus/vertx/VertxOptionsCustomizer.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,15 @@ | ||
package io.quarkus.vertx; | ||
|
||
import java.util.function.Consumer; | ||
|
||
import io.vertx.core.VertxOptions; | ||
|
||
/** | ||
* Allows customizing the {@link VertxOptions} used to create the managed {@link io.vertx.core.Vertx} instance. | ||
* <p> | ||
* Beans exposing this interface receive the {@link VertxOptions} computed from the application configuration, and | ||
* extensions customizing the options. | ||
*/ | ||
public interface VertxOptionsCustomizer extends Consumer<VertxOptions> { | ||
|
||
} |
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