forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade to SmallRye Fault Tolerance 6.4.0
- Loading branch information
1 parent
0c47660
commit c5ab66e
Showing
20 changed files
with
415 additions
and
12 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
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
34 changes: 34 additions & 0 deletions
34
.../io/quarkus/smallrye/faulttolerance/test/retry/beforeretry/BeforeRetryHandlerService.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.smallrye.faulttolerance.test.retry.beforeretry; | ||
|
||
import java.util.Set; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
import jakarta.enterprise.context.Dependent; | ||
import jakarta.inject.Inject; | ||
|
||
import org.eclipse.microprofile.faulttolerance.ExecutionContext; | ||
import org.eclipse.microprofile.faulttolerance.Retry; | ||
|
||
import io.smallrye.faulttolerance.api.BeforeRetry; | ||
import io.smallrye.faulttolerance.api.BeforeRetryHandler; | ||
|
||
@Dependent | ||
public class BeforeRetryHandlerService { | ||
static final Set<Integer> ids = ConcurrentHashMap.newKeySet(); | ||
|
||
@Retry | ||
@BeforeRetry(MyBeforeRetryHandler.class) | ||
public void hello() { | ||
throw new IllegalArgumentException(); | ||
} | ||
|
||
static class MyBeforeRetryHandler implements BeforeRetryHandler { | ||
@Inject | ||
MyDependency dep; | ||
|
||
@Override | ||
public void handle(ExecutionContext context) { | ||
ids.add(dep.id); | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...ava/io/quarkus/smallrye/faulttolerance/test/retry/beforeretry/BeforeRetryHandlerTest.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,29 @@ | ||
package io.quarkus.smallrye.faulttolerance.test.retry.beforeretry; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
import jakarta.inject.Inject; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class BeforeRetryHandlerTest { | ||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(BeforeRetryHandlerService.class, MyDependency.class)); | ||
|
||
@Inject | ||
BeforeRetryHandlerService service; | ||
|
||
@Test | ||
public void test() { | ||
assertThrows(IllegalArgumentException.class, service::hello); | ||
assertThat(BeforeRetryHandlerService.ids) | ||
.hasSize(3) | ||
.containsExactly(1, 2, 3); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...a/io/quarkus/smallrye/faulttolerance/test/retry/beforeretry/BeforeRetryMethodService.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,27 @@ | ||
package io.quarkus.smallrye.faulttolerance.test.retry.beforeretry; | ||
|
||
import java.util.Set; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
|
||
import jakarta.enterprise.context.Dependent; | ||
|
||
import org.eclipse.microprofile.faulttolerance.Retry; | ||
|
||
import io.smallrye.faulttolerance.api.BeforeRetry; | ||
|
||
@Dependent | ||
public class BeforeRetryMethodService { | ||
static final Set<Integer> ids = ConcurrentHashMap.newKeySet(); | ||
private static final AtomicInteger counter = new AtomicInteger(); | ||
|
||
@Retry | ||
@BeforeRetry(methodName = "beforeRetry") | ||
public void hello() { | ||
throw new IllegalArgumentException(); | ||
} | ||
|
||
void beforeRetry() { | ||
ids.add(counter.incrementAndGet()); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...java/io/quarkus/smallrye/faulttolerance/test/retry/beforeretry/BeforeRetryMethodTest.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,29 @@ | ||
package io.quarkus.smallrye.faulttolerance.test.retry.beforeretry; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
import jakarta.inject.Inject; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class BeforeRetryMethodTest { | ||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(BeforeRetryMethodService.class)); | ||
|
||
@Inject | ||
BeforeRetryMethodService service; | ||
|
||
@Test | ||
public void test() { | ||
assertThrows(IllegalArgumentException.class, service::hello); | ||
assertThat(BeforeRetryMethodService.ids) | ||
.hasSize(3) | ||
.containsExactly(1, 2, 3); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...rkus/smallrye/faulttolerance/test/retry/beforeretry/BothValueAndMethodNameSetService.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,27 @@ | ||
package io.quarkus.smallrye.faulttolerance.test.retry.beforeretry; | ||
|
||
import jakarta.enterprise.context.Dependent; | ||
|
||
import org.eclipse.microprofile.faulttolerance.ExecutionContext; | ||
import org.eclipse.microprofile.faulttolerance.Retry; | ||
|
||
import io.smallrye.faulttolerance.api.BeforeRetry; | ||
import io.smallrye.faulttolerance.api.BeforeRetryHandler; | ||
|
||
@Dependent | ||
public class BothValueAndMethodNameSetService { | ||
@Retry | ||
@BeforeRetry(value = MyHandler.class, methodName = "beforeRetry") | ||
public void hello() { | ||
throw new IllegalArgumentException(); | ||
} | ||
|
||
void beforeRetry() { | ||
} | ||
|
||
static class MyHandler implements BeforeRetryHandler { | ||
@Override | ||
public void handle(ExecutionContext context) { | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...quarkus/smallrye/faulttolerance/test/retry/beforeretry/BothValueAndMethodNameSetTest.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,28 @@ | ||
package io.quarkus.smallrye.faulttolerance.test.retry.beforeretry; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import jakarta.enterprise.inject.spi.DeploymentException; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class BothValueAndMethodNameSetTest { | ||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(BothValueAndMethodNameSetService.class)) | ||
.assertException(e -> { | ||
assertEquals(DeploymentException.class, e.getClass()); | ||
assertTrue(e.getMessage().contains("Invalid @BeforeRetry")); | ||
assertTrue(e.getMessage().contains( | ||
"before retry handler class and before retry method can't be specified both at the same time")); | ||
}); | ||
|
||
@Test | ||
public void test() { | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...src/test/java/io/quarkus/smallrye/faulttolerance/test/retry/beforeretry/MyDependency.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,12 @@ | ||
package io.quarkus.smallrye.faulttolerance.test.retry.beforeretry; | ||
|
||
import java.util.concurrent.atomic.AtomicInteger; | ||
|
||
import jakarta.enterprise.context.Dependent; | ||
|
||
@Dependent | ||
public class MyDependency { | ||
private static final AtomicInteger counter = new AtomicInteger(); | ||
|
||
public final int id = counter.incrementAndGet(); | ||
} |
20 changes: 20 additions & 0 deletions
20
...arkus/smallrye/faulttolerance/test/retry/beforeretry/NoBeforeRetryMethodFoundService.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,20 @@ | ||
package io.quarkus.smallrye.faulttolerance.test.retry.beforeretry; | ||
|
||
import jakarta.enterprise.context.Dependent; | ||
|
||
import org.eclipse.microprofile.faulttolerance.Retry; | ||
|
||
import io.smallrye.faulttolerance.api.BeforeRetry; | ||
|
||
@Dependent | ||
public class NoBeforeRetryMethodFoundService { | ||
@Retry | ||
@BeforeRetry(methodName = "beforeRetry") | ||
public void hello() { | ||
throw new IllegalArgumentException(); | ||
} | ||
|
||
public int beforeRetry(int param) { | ||
return 0; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
.../quarkus/smallrye/faulttolerance/test/retry/beforeretry/NoBeforeRetryMethodFoundTest.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,27 @@ | ||
package io.quarkus.smallrye.faulttolerance.test.retry.beforeretry; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import jakarta.enterprise.inject.spi.DeploymentException; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class NoBeforeRetryMethodFoundTest { | ||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(NoBeforeRetryMethodFoundService.class)) | ||
.assertException(e -> { | ||
assertEquals(DeploymentException.class, e.getClass()); | ||
assertTrue(e.getMessage().contains("Invalid @BeforeRetry")); | ||
assertTrue(e.getMessage().contains("can't find before retry method")); | ||
}); | ||
|
||
@Test | ||
public void test() { | ||
} | ||
} |
Oops, something went wrong.