|
1 | 1 | package io.quarkus.restclient.configuration;
|
2 | 2 |
|
3 |
| -import java.util.Set; |
4 |
| - |
5 |
| -import jakarta.enterprise.inject.spi.Bean; |
6 |
| -import jakarta.enterprise.inject.spi.BeanManager; |
7 |
| -import jakarta.inject.Singleton; |
8 |
| - |
9 |
| -import org.eclipse.microprofile.rest.client.inject.RestClient; |
10 |
| -import org.junit.jupiter.api.Assertions; |
11 |
| -import org.junit.jupiter.api.Test; |
12 | 3 | import org.junit.jupiter.api.extension.RegisterExtension;
|
13 | 4 |
|
14 |
| -import io.quarkus.arc.Arc; |
15 | 5 | import io.quarkus.test.QuarkusUnitTest;
|
16 | 6 |
|
17 | 7 | /**
|
18 | 8 | * Tests clients configured with MicroProfile-style configuration.
|
19 | 9 | */
|
20 |
| -public class MPRestClientsTest { |
| 10 | +public class MPRestClientsTest extends AbstractRestClientsTest { |
21 | 11 |
|
22 | 12 | @RegisterExtension
|
23 | 13 | static final QuarkusUnitTest config = new QuarkusUnitTest()
|
24 | 14 | .withApplicationRoot((jar) -> jar
|
25 | 15 | .addClasses(EchoResource.class,
|
26 | 16 | EchoClient.class, EchoClientWithConfigKey.class, ShortNameEchoClient.class))
|
27 | 17 | .withConfigurationResource("mp-restclients-test-application.properties");
|
28 |
| - |
29 |
| - @RestClient |
30 |
| - EchoClientWithConfigKey clientWithConfigKey; |
31 |
| - |
32 |
| - @RestClient |
33 |
| - EchoClient fullClassNameClient; |
34 |
| - |
35 |
| - @Test |
36 |
| - public void clientWithConfigKeyShouldConnect() { |
37 |
| - Assertions.assertEquals("Hello", clientWithConfigKey.echo("Hello")); |
38 |
| - } |
39 |
| - |
40 |
| - @Test |
41 |
| - void clientWithConfigShouldHaveSingletonScope() { |
42 |
| - verifyClientScope(EchoClientWithConfigKey.class, Singleton.class); |
43 |
| - } |
44 |
| - |
45 |
| - @Test |
46 |
| - public void fullClassNameClientShouldConnect() { |
47 |
| - Assertions.assertEquals("Hello", fullClassNameClient.echo("Hello")); |
48 |
| - } |
49 |
| - |
50 |
| - @Test |
51 |
| - void fullClassNameClientShouldHaveSingletonScope() { |
52 |
| - verifyClientScope(EchoClient.class, Singleton.class); |
53 |
| - } |
54 |
| - |
55 |
| - static void verifyClientScope(Class clientInterface, Class expectedScope) { |
56 |
| - BeanManager beanManager = Arc.container().beanManager(); |
57 |
| - Set<Bean<?>> beans = beanManager.getBeans(clientInterface, RestClient.LITERAL); |
58 |
| - Bean<?> resolvedBean = beanManager.resolve(beans); |
59 |
| - Assertions.assertEquals(expectedScope, resolvedBean.getScope()); |
60 |
| - } |
61 |
| - |
62 | 18 | }
|
0 commit comments