@@ -20,6 +20,7 @@ package actionContainers
2020import common .WskActorSystem
2121import org .junit .runner .RunWith
2222import org .scalatest .junit .JUnitRunner
23+ import spray .json .{JsArray , JsNumber , JsObject }
2324
2425@ RunWith (classOf [JUnitRunner ])
2526class Java11ActionLoopSourceTests extends JavaActionLoopSourceTests with WskActorSystem {
@@ -28,4 +29,50 @@ class Java11ActionLoopSourceTests extends JavaActionLoopSourceTests with WskActo
2829
2930 behavior of " Java 11 actionloop"
3031
32+ it should s " support local-variable syntax for lambda parameters (JEP 323) " in {
33+ val config = TestConfig (
34+ """
35+ |package example;
36+ |
37+ |import com.google.gson.JsonArray;
38+ |import com.google.gson.JsonObject;
39+ |import java.util.stream.IntStream;
40+ |
41+ |/**
42+ | * Test JEP 323: Local-Variable Syntax for Lambda Parameters
43+ | * http://openjdk.java.net/jeps/323
44+ | */
45+ |public class Java11Jep323Test {
46+ | public static JsonObject main(JsonObject args) throws Exception {
47+ | JsonObject response = new JsonObject();
48+ | JsonArray list = new JsonArray();
49+ |
50+ | IntStream.range(1, 5)
51+ | // local-variable syntax
52+ | .filter((var i) -> i % 2 == 0)
53+ | .forEach(list::add);
54+ |
55+ | response.add("list", list);
56+ | return response;
57+ | }
58+ |}
59+ """ .stripMargin,
60+ main = " example.Java11Jep323Test" )
61+
62+ val (out, err) = withActionContainer() { c =>
63+ val (initCode, _) = c.init(initPayload(config.code, config.main))
64+ initCode should be(200 )
65+
66+ val response = JsObject (" list" -> JsArray (JsNumber (2 ), JsNumber (4 )))
67+ val (runCode, out) = c.run(JsObject .empty)
68+ runCode should be(200 )
69+ out should be(Some (response))
70+ }
71+
72+ checkStreams(out, err, {
73+ case (o, e) =>
74+ o shouldBe empty
75+ e shouldBe empty
76+ })
77+ }
3178}
0 commit comments