-
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.
Browse files
Browse the repository at this point in the history
Allow executing tests on Vert.x blocking thread pool
- Loading branch information
Showing
7 changed files
with
167 additions
and
9 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
31 changes: 31 additions & 0 deletions
31
...est-client-reactive/src/main/java/io/quarkus/it/rest/client/main/CorrelationIdClient.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,31 @@ | ||
package io.quarkus.it.rest.client.main; | ||
|
||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.client.ClientRequestContext; | ||
import jakarta.ws.rs.client.ClientRequestFilter; | ||
|
||
import org.eclipse.microprofile.rest.client.annotation.RegisterProvider; | ||
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; | ||
|
||
import io.smallrye.common.vertx.ContextLocals; | ||
|
||
@Path("/correlation") | ||
@RegisterRestClient(configKey = "correlation") | ||
@RegisterProvider(CorrelationIdClient.CorrelationIdClientFilter.class) | ||
public interface CorrelationIdClient { | ||
|
||
String CORRELATION_ID_HEADER_NAME = "CorrelationId"; | ||
|
||
@GET | ||
String get(); | ||
|
||
class CorrelationIdClientFilter implements ClientRequestFilter { | ||
|
||
@Override | ||
public void filter(ClientRequestContext requestContext) { | ||
String correlationId = ContextLocals.<String> get(CORRELATION_ID_HEADER_NAME).orElse(null); | ||
requestContext.getHeaders().putSingle(CORRELATION_ID_HEADER_NAME, correlationId); | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
integration-tests/rest-client-reactive/src/main/resources/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
25 changes: 25 additions & 0 deletions
25
...active/src/test/java/io/quarkus/it/rest/client/RestClientInTestMethodWithContextTest.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,25 @@ | ||
package io.quarkus.it.rest.client; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import org.eclipse.microprofile.rest.client.inject.RestClient; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.it.rest.client.main.CorrelationIdClient; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
import io.quarkus.test.vertx.RunOnVertxContext; | ||
import io.smallrye.common.vertx.ContextLocals; | ||
|
||
@QuarkusTest | ||
public class RestClientInTestMethodWithContextTest { | ||
|
||
@RestClient | ||
CorrelationIdClient client; | ||
|
||
@RunOnVertxContext(runOnEventLoop = false) | ||
@Test | ||
public void test() { | ||
ContextLocals.put(CorrelationIdClient.CORRELATION_ID_HEADER_NAME, "dummy"); | ||
assertThat(client.get()).isEqualTo("dummy"); | ||
} | ||
} |
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