Enable tests for unicode for python, swift. (#2070)

Re-enable build swift/python containers (for tests to run).
Add unicode unit test for swift action container.
Allow for reinit with swift for use with invoke.py.
Fix unicode regression for swift actions.
Refactor unicode tests to add coverage - now also for base action container.
Set string encoding to utf-8 for swift action proxy.
Rewrite result extraction to avoid splitting and printing logs one line at a time.
Skip decoding when process output is a string; already utf-8.

Consolidate base64 encoding in CLI; remove Jar field in exec.
diff --git a/tests/src/test/scala/actionContainers/ActionProxyContainerTests.scala b/tests/src/test/scala/actionContainers/ActionProxyContainerTests.scala
index cee440b..a39026c 100644
--- a/tests/src/test/scala/actionContainers/ActionProxyContainerTests.scala
+++ b/tests/src/test/scala/actionContainers/ActionProxyContainerTests.scala
@@ -74,6 +74,21 @@
         Seq(("bash", bash), ("python", python))
     }
 
+    val stdUnicodeSamples = {
+        // python 3 in base image
+        val python = """
+                |#!/usr/bin/env python
+                |import json, sys
+                |j = json.loads(sys.argv[1])
+                |sep = j["delimiter"]
+                |s = sep + " ☃ " + sep
+                |print(s)
+                |print(json.dumps({"winter": s}))
+            """.stripMargin.trim
+
+        Seq(("python", python))
+    }
+
     /** Standard code samples, should print 'hello' to stdout and echo the input args. */
     val stdEnvSamples = {
         val bash = """
@@ -200,6 +215,7 @@
 
     testNotReturningJson(codeNotReturningJson, checkResultInLogs = true)
     testEcho(stdCodeSamples)
+    testUnicode(stdUnicodeSamples)
     testEnv(stdEnvSamples)
 }
 
@@ -238,10 +254,11 @@
      * and print hello [stdout, stderr].
      */
     def testEcho(stdCodeSamples: Seq[(String, String)]) = {
-        for (s <- stdCodeSamples) {
+        stdCodeSamples.foreach { s =>
             it should s"run a ${s._1} script" in {
                 val argss = List(
                     JsObject("string" -> JsString("hello")),
+                    JsObject("string" -> JsString("❄ ☃ ❄")),
                     JsObject("numbers" -> JsArray(JsNumber(42), JsNumber(1))),
                     // JsObject("boolean" -> JsBoolean(true)), // fails with swift3 returning boolean: 1
                     JsObject("object" -> JsObject("a" -> JsString("A"))))
@@ -266,9 +283,28 @@
         }
     }
 
+    def testUnicode(stdUnicodeSamples: Seq[(String, String)]) = {
+        stdUnicodeSamples.foreach { s =>
+            it should s"run a ${s._1} action and handle unicode in source, input params, logs, and result" in {
+                val (out, err) = withActionContainer() { c =>
+                    val (initCode, _) = c.init(initPayload(s._2))
+                    initCode should be(200)
+
+                    val (runCode, runRes) = c.run(runPayload(JsObject("delimiter" -> JsString("❄"))))
+                    runRes.get.fields.get("winter") shouldBe Some(JsString("❄ ☃ ❄"))
+                }
+
+                checkStreams(out, err, {
+                    case (o, _) =>
+                        o.toLowerCase should include("❄ ☃ ❄")
+                })
+            }
+        }
+    }
+
     /** Runs tests for code samples which are expected to return the expected standard environment {auth, edge}. */
     def testEnv(stdEnvSamples: Seq[(String, String)], enforceEmptyOutputStream: Boolean = true, enforceEmptyErrorStream: Boolean = true) = {
-        for (s <- stdEnvSamples) {
+        stdEnvSamples.foreach { s =>
             it should s"run a ${s._1} script and confirm expected environment variables" in {
                 val props = Seq(
                     "api_host" -> "xyz",
diff --git a/tests/src/test/scala/actionContainers/SwiftActionContainerTests.scala b/tests/src/test/scala/actionContainers/SwiftActionContainerTests.scala
index 25a88cf..3369e2a 100644
--- a/tests/src/test/scala/actionContainers/SwiftActionContainerTests.scala
+++ b/tests/src/test/scala/actionContainers/SwiftActionContainerTests.scala
@@ -95,25 +95,41 @@
         |}
         """.stripMargin)
     */
+
     testEcho(Seq {
         ("swift", """
-        |import Foundation
-        |
-        |extension FileHandle : TextOutputStream {
-        |   public func write(_ string: String) {
-        |       guard let data = string.data(using: .utf8) else { return }
-        |       self.write(data)
-        |   }
-        |}
-        |func main(args: [String: Any]) -> [String: Any] {
-        |     print("hello stdout")
-        |     var standardError = FileHandle.standardError
-        |     print("hello stderr", to: &standardError)
-        |     return args
-        |}
+         | import Foundation
+         |
+         | extension FileHandle : TextOutputStream {
+         |     public func write(_ string: String) {
+         |         guard let data = string.data(using: .utf8) else { return }
+         |         self.write(data)
+         |     }
+         | }
+         |
+         | func main(args: [String: Any]) -> [String: Any] {
+         |     print("hello stdout")
+         |     var standardError = FileHandle.standardError
+         |     print("hello stderr", to: &standardError)
+         |     return args
+         | }
         """.stripMargin)
     })
 
+    testUnicode(Seq {
+        ("swift", """
+         | func main(args: [String: Any]) -> [String: Any] {
+         |     if let str = args["delimiter"] as? String {
+         |         let msg = "\(str) ☃ \(str)"
+         |         print(msg)
+         |         return [ "winter" : msg ]
+         |     } else {
+         |         return [ "error" : "no delimiter" ]
+         |     }
+         | }
+         """.stripMargin.trim)
+    })
+
     testEnv(Seq {
         ("swift", envCode)
     }, enforceEmptyOutputStream)
@@ -122,7 +138,7 @@
         withActionContainer() { c =>
             val code = """
                 | func niam(args: [String: Any]) -> [String: Any] {
-                |   return [ "result": "it works" ]
+                |     return [ "result": "it works" ]
                 | }
                 |""".stripMargin
 
@@ -298,7 +314,7 @@
                 | import AlchemyVision
                 |
                 | func main(args: [String:Any]) -> [String:Any] {
-                |   return ["message": "I compiled and was able to import Watson SDKs"]
+                |     return ["message": "I compiled and was able to import Watson SDKs"]
                 | }
             """.stripMargin