You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by cs...@apache.org on 2021/02/23 16:43:36 UTC
[aries-component-dsl] 09/10: Add test for delayed error on error
recovery branch
This is an automated email from the ASF dual-hosted git repository.
csierra pushed a commit to branch fix-recoverWith
in repository https://gitbox.apache.org/repos/asf/aries-component-dsl.git
commit 0e07202acab46ec4bbb021514ed81f1df633f9ca
Author: Carlos Sierra Andrés <ca...@liferay.com>
AuthorDate: Tue Feb 23 09:01:04 2021 +0100
Add test for delayed error on error recovery branch
---
.../apache/aries/component/dsl/test/DSLTest.java | 55 ++++++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/itests/src/main/java/org/apache/aries/component/dsl/test/DSLTest.java b/itests/src/main/java/org/apache/aries/component/dsl/test/DSLTest.java
index e24d630..4cc6144 100644
--- a/itests/src/main/java/org/apache/aries/component/dsl/test/DSLTest.java
+++ b/itests/src/main/java/org/apache/aries/component/dsl/test/DSLTest.java
@@ -1591,6 +1591,61 @@ public class DSLTest {
}
@Test
+ public void testNestedRecoverWithDelayedErrorOnRecoverBranch() {
+ ArrayList<Integer> result = new ArrayList<>();
+
+ ArrayList<ProbeImpl<Integer>> probes = new ArrayList<>();
+
+ OSGi<Integer> program = recoverWith(
+ recoverWith(
+ just(Arrays.asList(1, 2, 3, 4, 5, 6)).
+ effects(
+ t -> {
+ if (t % 5 == 0) {
+ throw new IllegalArgumentException();
+ }
+ }
+ , __ -> {
+ }
+ ),
+ (t, e) -> just(2).flatMap(s -> {
+ ProbeImpl<Integer> probe = new ProbeImpl<>();
+
+ probes.add(probe);
+
+ return probe.then(
+ just(0).effects(
+ __ -> {
+ throw (RuntimeException)e;
+ },
+ __ -> {}
+ ));
+ })).
+ effects(t -> {
+ if (t % 2 == 0) {
+ throw new IllegalArgumentException();
+ }
+ }
+ , __ -> {
+ }),
+ (t, e) -> just(8));
+
+ try (OSGiResult run = program.run(bundleContext, e -> {
+ result.add(e);
+
+ return NOOP;
+ })) {
+ assertEquals(Arrays.asList(1, 8, 3, 8, 8), result);
+
+ for (ProbeImpl<Integer> probe : probes) {
+ probe.getPublisher().publish(0);
+ }
+
+ assertEquals(Arrays.asList(1, 8, 3, 8, 8, 8), result);
+ }
+ }
+
+ @Test
public void testRegister() {
assertNull(bundleContext.getServiceReference(Service.class));