-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure that connection issues can be handled in Reactive REST Client #24368
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
...nt-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/InvalidHostTest.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,53 @@ | ||
package io.quarkus.rest.client.reactive; | ||
|
||
import java.net.URI; | ||
|
||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.core.MultivaluedMap; | ||
import javax.ws.rs.core.Response; | ||
|
||
import org.assertj.core.api.Assertions; | ||
import org.eclipse.microprofile.rest.client.RestClientBuilder; | ||
import org.eclipse.microprofile.rest.client.ext.ResponseExceptionMapper; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class InvalidHostTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest TEST = new QuarkusUnitTest(); | ||
|
||
@Test | ||
void shouldThrowDummyException() { | ||
Client client = RestClientBuilder.newBuilder().baseUri(URI.create("http://localhost2:1234/")) | ||
.register(DummyExceptionMapper.class).build(Client.class); | ||
|
||
Assertions.assertThatThrownBy(client::get).isInstanceOf(DummyException.class); | ||
} | ||
|
||
@Path("/foo") | ||
public interface Client { | ||
@GET | ||
String get(); | ||
} | ||
|
||
public static class DummyException extends RuntimeException { | ||
|
||
} | ||
|
||
public static class DummyExceptionMapper implements ResponseExceptionMapper<DummyException> { | ||
|
||
@Override | ||
public boolean handles(int status, MultivaluedMap<String, Object> headers) { | ||
return status == 0 && headers.isEmpty(); | ||
} | ||
|
||
@Override | ||
public DummyException toThrowable(Response response) { | ||
return new DummyException(); | ||
} | ||
} | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this always the first handler invoked? Curious if the response headers could be overwritten if they were set previously
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't really matter if it gets overridden. All that matters in this case is that it's not null