dgrove-oss closed pull request #62: Add test for init twice.
URL: https://github.com/apache/incubator-openwhisk-runtime-java/pull/62
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
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 void handle(HttpExchange t) throws IOException {
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(
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services