-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure that connection issues can be handled in Reactive REST Client
Fixes: #24364
- Loading branch information
Showing
2 changed files
with
58 additions
and
0 deletions.
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