aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From csie...@apache.org
Subject [aries-component-dsl] 03/03: Add test for new applyTo fix
Date Thu, 14 May 2020 17:30:09 GMT
This is an automated email from the ASF dual-hosted git repository.

csierra pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/aries-component-dsl.git

commit 0787a70a68077ddadc4c2d4a830ab04ee4fa2350
Author: Carlos Sierra Andrés <carlos.sierra@liferay.com>
AuthorDate: Thu May 14 18:55:36 2020 +0200

    Add test for new applyTo fix
---
 .../apache/aries/component/dsl/test/DSLTest.java   | 50 +++++++++++++++++-----
 1 file changed, 39 insertions(+), 11 deletions(-)

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 a5cf8df..6fed6bf 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
@@ -51,17 +51,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicReference;
 
-import static org.apache.aries.component.dsl.OSGi.NOOP;
-import static org.apache.aries.component.dsl.OSGi.coalesce;
-import static org.apache.aries.component.dsl.OSGi.configuration;
-import static org.apache.aries.component.dsl.OSGi.configurations;
-import static org.apache.aries.component.dsl.OSGi.just;
-import static org.apache.aries.component.dsl.OSGi.nothing;
-import static org.apache.aries.component.dsl.OSGi.onClose;
-import static org.apache.aries.component.dsl.OSGi.once;
-import static org.apache.aries.component.dsl.OSGi.register;
-import static org.apache.aries.component.dsl.OSGi.serviceReferences;
-import static org.apache.aries.component.dsl.OSGi.services;
+import static org.apache.aries.component.dsl.OSGi.*;
 import static org.apache.aries.component.dsl.Utils.accumulate;
 import static org.apache.aries.component.dsl.Utils.highest;
 import static org.junit.Assert.assertEquals;
@@ -236,6 +226,44 @@ public class DSLTest {
     }
 
     @Test
+    public void testCombine() {
+        List<Integer> list = new ArrayList<>();
+
+        ProbeImpl<Integer> probe1 = new ProbeImpl<>();
+        ProbeImpl<Integer> probe2 = new ProbeImpl<>();
+
+        OSGi<Integer> program = combine(
+            (x, y) -> x * y, probe1, probe2
+        ).effects(
+            list::add, list::remove
+        );
+
+        OSGiResult run = program.run(bundleContext);
+
+        Publisher<? super Integer> publisher1 = probe1.getPublisher();
+        Publisher<? super Integer> publisher2 = probe2.getPublisher();
+
+        OSGiResult osgiResult1 = publisher1.publish(3);
+        OSGiResult osgiResult2 = publisher2.publish(5);
+
+        assertTrue(list.contains(15));
+
+        osgiResult1.close();
+
+        assertFalse(list.contains(15));
+
+        publisher1.publish(3);
+
+        assertTrue(list.contains(15));
+
+        osgiResult2.close();
+
+        assertFalse(list.contains(15));
+
+        run.close();
+    }
+
+    @Test
     public void testEffectsOrder() {
         ArrayList<Object> effects = new ArrayList<>();
 


Mime
View raw message