You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by dg...@apache.org on 2018/07/06 13:59:43 UTC
[incubator-openwhisk-runtime-java] branch master updated: Add test
for init twice. (#62)
This is an automated email from the ASF dual-hosted git repository.
dgrove pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-runtime-java.git
The following commit(s) were added to refs/heads/master by this push:
new d5caa45 Add test for init twice. (#62)
d5caa45 is described below
commit d5caa456ea9b4eca2f01b6411e611bc160368eac
Author: rodric rabbah <ro...@gmail.com>
AuthorDate: Fri Jul 6 09:59:41 2018 -0400
Add test for init twice. (#62)
---
.../src/main/java/openwhisk/java/action/Proxy.java | 6 ++---
.../JavaActionContainerTests.scala | 28 ++++++++++++++++++++++
2 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/java8/proxy/src/main/java/openwhisk/java/action/Proxy.java b/java8/proxy/src/main/java/openwhisk/java/action/Proxy.java
index 6233e92..fd80333 100644
--- a/java8/proxy/src/main/java/openwhisk/java/action/Proxy.java
+++ b/java8/proxy/src/main/java/openwhisk/java/action/Proxy.java
@@ -85,10 +85,8 @@ public class Proxy {
String base64Jar = message.getAsJsonPrimitive("code").getAsString();
// FIXME: this is obviously not very useful. The idea is that we
- // will implement/use
- // a streaming parser for the incoming JSON object so that we
- // can stream the contents
- // of the jar straight to a file.
+ // will implement/use a streaming parser for the incoming JSON object so that we
+ // can stream the contents of the jar straight to a file.
InputStream jarIs = new ByteArrayInputStream(base64Jar.getBytes(StandardCharsets.UTF_8));
// Save the bytes to a file.
diff --git a/tests/src/test/scala/actionContainers/JavaActionContainerTests.scala b/tests/src/test/scala/actionContainers/JavaActionContainerTests.scala
index f30ccd1..a3094a8 100644
--- a/tests/src/test/scala/actionContainers/JavaActionContainerTests.scala
+++ b/tests/src/test/scala/actionContainers/JavaActionContainerTests.scala
@@ -124,6 +124,34 @@ class JavaActionContainerTests extends FlatSpec with Matchers with WskActorSyste
err.trim shouldBe empty
}
+ it should "not allow initialization twice" in {
+ val (out, err) = withJavaContainer { c =>
+ val jar = JarBuilder.mkBase64Jar(
+ Seq("example", "HelloWhisk.java") ->
+ """
+ | package example;
+ |
+ | import com.google.gson.JsonObject;
+ |
+ | public class HelloWhisk {
+ | public static JsonObject main(JsonObject args) {
+ | return args;
+ | }
+ | }
+ """.stripMargin.trim)
+
+ val (initCode, _) = c.init(initPayload("example.HelloWhisk", jar))
+ initCode should be(200)
+
+ val (initCode2, out2) = c.init(initPayload("example.HelloWhisk", jar))
+ initCode2 should (be < 200 or be > 299) // the code does not matter, just cannot be 20x
+ out2 should be(Some(JsObject("error" -> JsString("Cannot initialize the action more than once."))))
+ }
+
+ out.trim shouldBe empty
+ err.trim shouldBe empty
+ }
+
it should "support valid actions with non 'main' names" in {
val (out, err) = withJavaContainer { c =>
val jar = JarBuilder.mkBase64Jar(