Skip to content

Commit

Permalink
Use custom marker annotation instead of @ConfigProperty
Browse files Browse the repository at this point in the history
quarkusio/quarkus#24579 - @ConfigProperty is not intended for integration tests
  • Loading branch information
rsvoboda committed Mar 31, 2022
1 parent edd66d6 commit 16b8362
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import java.util.concurrent.TimeUnit;

import org.apache.http.HttpStatus;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.junit.jupiter.api.Test;

import io.quarkus.qe.containers.JaegerApiEndpointAddress;
import io.quarkus.qe.containers.JaegerTestResource;
import io.quarkus.test.common.QuarkusTestResource;

Expand All @@ -24,7 +24,7 @@ public abstract class AbstractPingPongResourceTest {
private static final String PING_RESOURCE = "PingResource";
private static final String PONG_RESOURCE = "PongResource";

@ConfigProperty(name = JaegerTestResource.JAEGER_API_ENDPOINT, defaultValue = "http://localhost:16686/api/traces")
@JaegerApiEndpointAddress
String jaegerEndpoint;

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package io.quarkus.qe.containers;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

@Retention(RetentionPolicy.RUNTIME)
public @interface JaegerApiEndpointAddress {
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.util.Map;
import java.util.Optional;

import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;

Expand Down Expand Up @@ -44,8 +43,8 @@ public void inject(Object testInstance) {
Class<?> c = testInstance.getClass();
while (c != Object.class) {
for (Field f : c.getDeclaredFields()) {
ConfigProperty configProperty = f.getAnnotation(ConfigProperty.class);
if (configProperty != null && JAEGER_API_ENDPOINT.equals(configProperty.name())) {
JaegerApiEndpointAddress jaegerEndpoint = f.getAnnotation(JaegerApiEndpointAddress.class);
if (jaegerEndpoint != null) {
setFieldValue(f, testInstance, apiEndpoint());
}
}
Expand Down

0 comments on commit 16b8362

Please sign in to comment.