-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RestEasy Reactive client ApplicationScoped by default, added a note a…
…bout the client to the resteasy-reactive doc
- Loading branch information
1 parent
3625df0
commit f0dd8a1
Showing
7 changed files
with
100 additions
and
8 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
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
34 changes: 34 additions & 0 deletions
34
...ment/src/test/java/io/quarkus/resteasy/reactive/client/MpRestClientScopeOverrideTest.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,34 @@ | ||
package io.quarkus.resteasy.reactive.client; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.util.Set; | ||
|
||
import javax.enterprise.context.Dependent; | ||
import javax.enterprise.inject.spi.Bean; | ||
import javax.enterprise.inject.spi.BeanManager; | ||
|
||
import org.eclipse.microprofile.rest.client.inject.RestClient; | ||
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.arc.Arc; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class MpRestClientScopeOverrideTest { | ||
@RegisterExtension | ||
static final QuarkusUnitTest TEST = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(HelloClient2.class)) | ||
.withConfigurationResource("basic-test-application.properties"); | ||
|
||
@Test | ||
void shouldHaveDependentScope() { | ||
BeanManager beanManager = Arc.container().beanManager(); | ||
Set<Bean<?>> beans = beanManager.getBeans(HelloClient2.class, RestClient.LITERAL); | ||
Bean<?> resolvedBean = beanManager.resolve(beans); | ||
assertThat(resolvedBean.getScope()).isEqualTo(Dependent.class); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...t-client-microprofile/deployment/src/test/resources/dependent-test-application.properties
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,3 @@ | ||
hello2/mp-rest/url=http://localhost:${quarkus.http.test-port:8081}/hello | ||
|
||
quarkus.rest-client.scope=javax.enterprise.context.Dependent |
15 changes: 15 additions & 0 deletions
15
...java/io/quarkus/resteasy/reactive/client/microprofile/ReactiveResteasyMpClientConfig.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.resteasy.reactive.client.microprofile; | ||
|
||
import io.quarkus.runtime.annotations.ConfigItem; | ||
import io.quarkus.runtime.annotations.ConfigPhase; | ||
import io.quarkus.runtime.annotations.ConfigRoot; | ||
|
||
@ConfigRoot(phase = ConfigPhase.BUILD_TIME, name = "rest-client") | ||
public class ReactiveResteasyMpClientConfig { | ||
|
||
/** | ||
* Default scope for MicroProfile Rest Client. Use `javax.enterprise.context.Dependent` for spec-compliant behavior | ||
*/ | ||
@ConfigItem(name = "scope", defaultValue = "javax.enterprise.context.SessionScoped") | ||
public String scope; | ||
} |
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