-
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.
Merge pull request #19609 from Ladicek/fix-fault-tolerance-buildtime-…
…classloading Fix SmallRye Fault Tolerance build-time class loading
- Loading branch information
Showing
8 changed files
with
223 additions
and
134 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
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
68 changes: 68 additions & 0 deletions
68
...loyment/src/test/java/io/quarkus/rest/client/reactive/ft/AsyncRestClientFallbackTest.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,68 @@ | ||
package io.quarkus.rest.client.reactive.ft; | ||
|
||
import static io.quarkus.rest.client.reactive.RestClientTestUtil.setUrlForClass; | ||
import static java.util.concurrent.CompletableFuture.completedFuture; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.util.concurrent.CompletionStage; | ||
import java.util.concurrent.ExecutionException; | ||
|
||
import javax.inject.Inject; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.WebApplicationException; | ||
|
||
import org.eclipse.microprofile.faulttolerance.Asynchronous; | ||
import org.eclipse.microprofile.faulttolerance.ExecutionContext; | ||
import org.eclipse.microprofile.faulttolerance.Fallback; | ||
import org.eclipse.microprofile.faulttolerance.FallbackHandler; | ||
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; | ||
import org.eclipse.microprofile.rest.client.inject.RestClient; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class AsyncRestClientFallbackTest { | ||
@RegisterExtension | ||
static final QuarkusUnitTest TEST = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(TestEndpoint.class, Client.class, MyFallback.class) | ||
.addAsResource(new StringAsset(setUrlForClass(Client.class)), "application.properties")); | ||
|
||
@Inject | ||
@RestClient | ||
Client client; | ||
|
||
@Test | ||
public void testFallbackWasUsed() throws ExecutionException, InterruptedException { | ||
assertEquals("pong", client.ping().toCompletableFuture().get()); | ||
} | ||
|
||
@Path("/test") | ||
public static class TestEndpoint { | ||
@GET | ||
public String get() { | ||
throw new WebApplicationException(404); | ||
} | ||
} | ||
|
||
@RegisterRestClient | ||
public interface Client { | ||
@GET | ||
@Path("/test") | ||
@Asynchronous | ||
@Fallback(MyFallback.class) | ||
CompletionStage<String> ping(); | ||
} | ||
|
||
public static class MyFallback implements FallbackHandler<CompletionStage<String>> { | ||
@Override | ||
public CompletionStage<String> handle(ExecutionContext context) { | ||
return completedFuture("pong"); | ||
} | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
...e/deployment/src/test/java/io/quarkus/rest/client/reactive/ft/RestClientFallbackTest.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,63 @@ | ||
package io.quarkus.rest.client.reactive.ft; | ||
|
||
import static io.quarkus.rest.client.reactive.RestClientTestUtil.setUrlForClass; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import javax.inject.Inject; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.WebApplicationException; | ||
|
||
import org.eclipse.microprofile.faulttolerance.ExecutionContext; | ||
import org.eclipse.microprofile.faulttolerance.Fallback; | ||
import org.eclipse.microprofile.faulttolerance.FallbackHandler; | ||
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; | ||
import org.eclipse.microprofile.rest.client.inject.RestClient; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class RestClientFallbackTest { | ||
@RegisterExtension | ||
static final QuarkusUnitTest TEST = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(TestEndpoint.class, Client.class, MyFallback.class) | ||
.addAsResource(new StringAsset(setUrlForClass(Client.class)), "application.properties")); | ||
|
||
@Inject | ||
@RestClient | ||
Client client; | ||
|
||
@Test | ||
public void testFallbackWasUsed() { | ||
assertEquals("pong", client.ping()); | ||
} | ||
|
||
@Path("/test") | ||
public static class TestEndpoint { | ||
@GET | ||
public String get() { | ||
throw new WebApplicationException(404); | ||
} | ||
} | ||
|
||
@RegisterRestClient | ||
public interface Client { | ||
@GET | ||
@Path("/test") | ||
@Fallback(MyFallback.class) | ||
String ping(); | ||
} | ||
|
||
public static class MyFallback implements FallbackHandler<String> { | ||
@Override | ||
public String handle(ExecutionContext context) { | ||
return "pong"; | ||
} | ||
|
||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
...eployment/src/test/java/io/quarkus/rest/client/reactive/ft/UniRestClientFallbackTest.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,63 @@ | ||
package io.quarkus.rest.client.reactive.ft; | ||
|
||
import static io.quarkus.rest.client.reactive.RestClientTestUtil.setUrlForClass; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import javax.inject.Inject; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.WebApplicationException; | ||
|
||
import org.eclipse.microprofile.faulttolerance.ExecutionContext; | ||
import org.eclipse.microprofile.faulttolerance.Fallback; | ||
import org.eclipse.microprofile.faulttolerance.FallbackHandler; | ||
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; | ||
import org.eclipse.microprofile.rest.client.inject.RestClient; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.smallrye.mutiny.Uni; | ||
|
||
public class UniRestClientFallbackTest { | ||
@RegisterExtension | ||
static final QuarkusUnitTest TEST = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(TestEndpoint.class, Client.class, MyFallback.class) | ||
.addAsResource(new StringAsset(setUrlForClass(Client.class)), "application.properties")); | ||
|
||
@Inject | ||
@RestClient | ||
Client client; | ||
|
||
@Test | ||
public void testFallbackWasUsed() { | ||
assertEquals("pong", client.ping().await().indefinitely()); | ||
} | ||
|
||
@Path("/test") | ||
public static class TestEndpoint { | ||
@GET | ||
public String get() { | ||
throw new WebApplicationException(404); | ||
} | ||
} | ||
|
||
@RegisterRestClient | ||
public interface Client { | ||
@GET | ||
@Path("/test") | ||
@Fallback(MyFallback.class) | ||
Uni<String> ping(); | ||
} | ||
|
||
public static class MyFallback implements FallbackHandler<Uni<String>> { | ||
@Override | ||
public Uni<String> handle(ExecutionContext context) { | ||
return Uni.createFrom().item("pong"); | ||
} | ||
} | ||
} |
Oops, something went wrong.