-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test coverage for containerResponseFilter issue (#1616)
* Add test coverage for containerResponseFilter issue Issue quarkusio/quarkus#31024
- Loading branch information
Showing
7 changed files
with
131 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>io.quarkus.ts.qe</groupId> | ||
<artifactId>parent</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
<relativePath>../..</relativePath> | ||
</parent> | ||
<artifactId>http-rest-client-reactive-vanilla</artifactId> | ||
<packaging>jar</packaging> | ||
<name>Quarkus QE TS: HTTP: Rest Client Reactive Vanilla</name> | ||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-rest-client-reactive-jackson</artifactId> | ||
</dependency> | ||
</dependencies> | ||
</project> |
26 changes: 26 additions & 0 deletions
26
...active-vanilla/src/main/java/io/quarkus/ts/http/restclient/vanilla/RestCallerService.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,26 @@ | ||
package io.quarkus.ts.http.restclient.vanilla; | ||
|
||
import java.net.URI; | ||
|
||
import jakarta.annotation.PostConstruct; | ||
|
||
import org.eclipse.microprofile.rest.client.RestClientBuilder; | ||
|
||
import io.quarkus.runtime.Startup; | ||
|
||
/** | ||
* This class is used to reproduce issue https://github.com/quarkusio/quarkus/issues/31024 | ||
* Also requires {@link UselessRestApi} and {@link VersionHeaderFilter} for this | ||
*/ | ||
@Startup | ||
public class RestCallerService { | ||
|
||
@PostConstruct | ||
void initRestApi() { | ||
RestClientBuilder builder = RestClientBuilder.newBuilder()// | ||
.baseUri(URI.create("localhost")); | ||
|
||
// API needs to be created for issue to manifest | ||
UselessRestApi api = builder.build(UselessRestApi.class); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...-reactive-vanilla/src/main/java/io/quarkus/ts/http/restclient/vanilla/UselessRestApi.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,23 @@ | ||
package io.quarkus.ts.http.restclient.vanilla; | ||
|
||
import java.io.Closeable; | ||
import java.util.List; | ||
|
||
import jakarta.ws.rs.Consumes; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.core.MediaType; | ||
|
||
/** | ||
* Useless API, used just for passing type controls in {@link RestCallerService} | ||
*/ | ||
@Path("/useless") | ||
@Consumes(MediaType.APPLICATION_JSON) | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public interface UselessRestApi extends Closeable { | ||
|
||
@GET | ||
@Path("all") | ||
List<String> getAll(); | ||
} |
24 changes: 24 additions & 0 deletions
24
...tive-vanilla/src/main/java/io/quarkus/ts/http/restclient/vanilla/VersionHeaderFilter.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,24 @@ | ||
package io.quarkus.ts.http.restclient.vanilla; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.ws.rs.container.ContainerRequestContext; | ||
import jakarta.ws.rs.container.ContainerResponseContext; | ||
import jakarta.ws.rs.container.ContainerResponseFilter; | ||
import jakarta.ws.rs.container.PreMatching; | ||
import jakarta.ws.rs.ext.Provider; | ||
|
||
/** | ||
* Used for {@link RestCallerService} | ||
* Does nothing we just need quarkus to have a possibility to use a ContainerResponseFilter | ||
*/ | ||
@Provider | ||
@PreMatching | ||
@ApplicationScoped | ||
public class VersionHeaderFilter implements ContainerResponseFilter { | ||
public VersionHeaderFilter() { | ||
} | ||
|
||
public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) { | ||
// do nothing. implements this method just because ContainerResponseFilter requires it | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...illa/src/test/java/io/quarkus/ts/http/restclient/vanilla/VanillaReactiveRestClientIT.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.ts.http.restclient.vanilla; | ||
|
||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
import java.util.List; | ||
|
||
import org.junit.jupiter.api.Tag; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.test.bootstrap.RestService; | ||
import io.quarkus.test.scenarios.QuarkusScenario; | ||
import io.quarkus.test.services.QuarkusApplication; | ||
|
||
@QuarkusScenario | ||
public class VanillaReactiveRestClientIT { | ||
private static final String CONTAINER_FILTER_ERROR_TEXT = "CDI: programmatic lookup problem detected"; | ||
|
||
@QuarkusApplication | ||
static RestService app = new RestService(); | ||
|
||
@Test | ||
@Tag("https://github.com/quarkusio/quarkus/issues/31024") | ||
public void restClientContainerFilterTest() { | ||
List<String> logs = app.getLogs(); | ||
|
||
// app produces error log (not stack trace) after startup in its log if issue in not fixed, | ||
// search for this error text | ||
for (String log : logs) { | ||
if (log.contains(CONTAINER_FILTER_ERROR_TEXT)) { | ||
fail("Detected failure-indicating text in app's log. Issue https://github.com/quarkusio/quarkus/issues/31024 might not be fixed."); | ||
} | ||
} | ||
} | ||
} |
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