aboutsummaryrefslogtreecommitdiffstats
path: root/container-core/src/test/java/com/yahoo/processing/execution/test/AsyncExecutionTestCase.java
diff options
context:
space:
mode:
authorgjoranv <gv@verizonmedia.com>2021-02-17 16:16:19 +0100
committergjoranv <gv@verizonmedia.com>2021-02-17 17:13:44 +0100
commitda183fe82e5d9eaccf3cbf03a0751cc74851ec31 (patch)
tree70cb9d97a7d2bdd5785e7512d7f88d5823e1407e /container-core/src/test/java/com/yahoo/processing/execution/test/AsyncExecutionTestCase.java
parenta0ae5022c689578e456eba2b5f89ac077e0b07e1 (diff)
Add java source files from the processing module.
Diffstat (limited to 'container-core/src/test/java/com/yahoo/processing/execution/test/AsyncExecutionTestCase.java')
-rw-r--r--container-core/src/test/java/com/yahoo/processing/execution/test/AsyncExecutionTestCase.java46
1 files changed, 46 insertions, 0 deletions
diff --git a/container-core/src/test/java/com/yahoo/processing/execution/test/AsyncExecutionTestCase.java b/container-core/src/test/java/com/yahoo/processing/execution/test/AsyncExecutionTestCase.java
new file mode 100644
index 00000000000..b821461fdc6
--- /dev/null
+++ b/container-core/src/test/java/com/yahoo/processing/execution/test/AsyncExecutionTestCase.java
@@ -0,0 +1,46 @@
+// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.processing.execution.test;
+
+import com.yahoo.component.chain.Chain;
+import com.yahoo.processing.Processor;
+import com.yahoo.processing.Request;
+import com.yahoo.processing.Response;
+import com.yahoo.processing.execution.Execution;
+import org.junit.Test;
+
+import static com.yahoo.processing.test.ProcessorLibrary.*;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * @author bratseth
+ */
+public class AsyncExecutionTestCase {
+
+ /** Execute a processing chain which forks off into multiple threads */
+ @Test
+ public void testAsyncExecution() {
+ // Create a chain
+ Chain<Processor> chain=new Chain<>(new CombineData(),new BlockingSplitter(2),new Get6DataItems(), new DataSource());
+
+ // Execute it
+ Request request=new Request();
+ request.properties().set("appendage",1);
+ Response response=Execution.createRoot(chain,0,Execution.Environment.createEmpty()).process(request);
+
+ // Verify the result
+ assertEquals(6*2-1,response.data().asList().size());
+ assertEquals("first.2, third.2",response.data().get(0).toString());
+ assertEquals("second.2",response.data().get(1).toString());
+ assertEquals("first.3",response.data().get(2).toString());
+ assertEquals("second.3",response.data().get(3).toString());
+ assertEquals("third.3",response.data().get(4).toString());
+ // from the parallel execution
+ assertEquals("first.2",response.data().get(5).toString());
+ assertEquals("second.2",response.data().get(6).toString());
+ assertEquals("third.2",response.data().get(7).toString());
+ assertEquals("first.3",response.data().get(8).toString());
+ assertEquals("second.3",response.data().get(9).toString());
+ assertEquals("third.3",response.data().get(10).toString());
+ }
+
+}