Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id BB23D200B9B for ; Wed, 28 Sep 2016 03:19:20 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id B9A2D160AE5; Wed, 28 Sep 2016 01:19:20 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 62D50160AD2 for ; Wed, 28 Sep 2016 03:19:19 +0200 (CEST) Received: (qmail 514 invoked by uid 500); 28 Sep 2016 01:19:18 -0000 Mailing-List: contact commits-help@iota.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@iota.incubator.apache.org Delivered-To: mailing list commits@iota.incubator.apache.org Received: (qmail 505 invoked by uid 99); 28 Sep 2016 01:19:18 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Sep 2016 01:19:18 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 2B37CC2033 for ; Wed, 28 Sep 2016 01:19:18 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.344 X-Spam-Level: X-Spam-Status: No, score=-4.344 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-1.124] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id aZ5AMFn2BWnD for ; Wed, 28 Sep 2016 01:19:15 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id 8683D60D59 for ; Wed, 28 Sep 2016 01:19:12 +0000 (UTC) Received: (qmail 99916 invoked by uid 99); 28 Sep 2016 01:19:11 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Sep 2016 01:19:11 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 92CF2E0FCA; Wed, 28 Sep 2016 01:19:11 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: tonyfaustini@apache.org To: commits@iota.incubator.apache.org Date: Wed, 28 Sep 2016 01:19:13 -0000 Message-Id: <8d760c5e6c6d45af93bb082fe09921dd@git.apache.org> In-Reply-To: <21904e761a0b45659bfde365c0fe3e76@git.apache.org> References: <21904e761a0b45659bfde365c0fe3e76@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [03/10] incubator-iota git commit: [IOTA-28] Adding tests for GenericReceiver archived-at: Wed, 28 Sep 2016 01:19:20 -0000 [IOTA-28] Adding tests for GenericReceiver Project: http://git-wip-us.apache.org/repos/asf/incubator-iota/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-iota/commit/a37164e6 Tree: http://git-wip-us.apache.org/repos/asf/incubator-iota/tree/a37164e6 Diff: http://git-wip-us.apache.org/repos/asf/incubator-iota/diff/a37164e6 Branch: refs/heads/master Commit: a37164e6150d8bb64bd4dc9cbc50f5ab27b97972 Parents: a865f2f Author: Barbara Gomes Authored: Fri Jul 22 14:38:05 2016 -0700 Committer: Barbara Gomes Committed: Fri Jul 22 14:38:05 2016 -0700 ---------------------------------------------------------------------- fey-core/src/test/resources/fey-test-actor.jar | Bin 12703 -> 17735 bytes .../org/apache/iota/fey/BaseAkkaSpec.scala | 13 ++ .../scala/org/apache/iota/fey/FeyCoreSpec.scala | 77 +++++++++- .../iota/fey/FeyGenericActorReceiverSpec.scala | 139 +++++++++++++++++++ .../iota/fey/FeyGenericActorReceiverTest.scala | 70 ++++++++++ .../org/apache/iota/fey/JsonReceiverSpec.scala | 2 +- .../org/apache/iota/fey/Utils_JSONTest.scala | 131 +++++++++++++++++ 7 files changed, 428 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-iota/blob/a37164e6/fey-core/src/test/resources/fey-test-actor.jar ---------------------------------------------------------------------- diff --git a/fey-core/src/test/resources/fey-test-actor.jar b/fey-core/src/test/resources/fey-test-actor.jar index d440cd1..e072c7b 100644 Binary files a/fey-core/src/test/resources/fey-test-actor.jar and b/fey-core/src/test/resources/fey-test-actor.jar differ http://git-wip-us.apache.org/repos/asf/incubator-iota/blob/a37164e6/fey-core/src/test/scala/org/apache/iota/fey/BaseAkkaSpec.scala ---------------------------------------------------------------------- diff --git a/fey-core/src/test/scala/org/apache/iota/fey/BaseAkkaSpec.scala b/fey-core/src/test/scala/org/apache/iota/fey/BaseAkkaSpec.scala index d77d28b..19c3b71 100644 --- a/fey-core/src/test/scala/org/apache/iota/fey/BaseAkkaSpec.scala +++ b/fey-core/src/test/scala/org/apache/iota/fey/BaseAkkaSpec.scala @@ -68,6 +68,19 @@ class BaseAkkaSpec extends BaseSpec with BeforeAndAfterAll with LoggingTest{ } } + def expectActorInSystem(path: String, lookInSystem: ActorSystem, max: FiniteDuration = 3.seconds): ActorRef = { + probe.within(max) { + var actor = null: ActorRef + probe.awaitAssert { + (lookInSystem actorSelection path).tell(Identify(path), probe.ref) + probe.expectMsgPF(100 milliseconds) { + case ActorIdentity(`path`, Some(ref)) => actor = ref + } + } + actor + } + } + def verifyActorTermination(actor: ActorRef)(implicit system: ActorSystem): Unit = { val watcher = TestProbe() watcher.watch(actor) http://git-wip-us.apache.org/repos/asf/incubator-iota/blob/a37164e6/fey-core/src/test/scala/org/apache/iota/fey/FeyCoreSpec.scala ---------------------------------------------------------------------- diff --git a/fey-core/src/test/scala/org/apache/iota/fey/FeyCoreSpec.scala b/fey-core/src/test/scala/org/apache/iota/fey/FeyCoreSpec.scala index c616821..5ae55c2 100644 --- a/fey-core/src/test/scala/org/apache/iota/fey/FeyCoreSpec.scala +++ b/fey-core/src/test/scala/org/apache/iota/fey/FeyCoreSpec.scala @@ -18,11 +18,10 @@ package org.apache.iota.fey -import java.io.File +import java.nio.file.{Files, Paths} import akka.actor.{ActorRef, PoisonPill, Props} import akka.testkit.{EventFilter, TestProbe} - import scala.concurrent.duration.DurationInt class FeyCoreSpec extends BaseAkkaSpec { @@ -62,8 +61,8 @@ class FeyCoreSpec extends BaseAkkaSpec { val orchestration_name = "TEST-ACTOR" "Sending FeyCore.ORCHESTRATION_RECEIVED with CREATE command to FeyCore" should { - feyCoreRef ! FeyCore.ORCHESTRATION_RECEIVED(getJSValueFromString(Utils_JSONTest.create_json_test), None) s"result in creating an Orchestration child actor with the name '$orchestration_name'" in { + feyCoreRef ! FeyCore.ORCHESTRATION_RECEIVED(getJSValueFromString(Utils_JSONTest.create_json_test), None) orchestrationref = TestProbe().expectActor(s"$feyPath/$orchestration_name") } s"result in creating an Ensemble child actor with the name '$orchestration_name/MY-ENSEMBLE-0001'" in { @@ -155,10 +154,82 @@ class FeyCoreSpec extends BaseAkkaSpec { } } + var receiverRef:ActorRef = _ + var receiverEnsenble:ActorRef = _ + var receiverOrch:ActorRef = _ + val receiverJSON = getJSValueFromString(Utils_JSONTest.generic_receiver_json) + val receiverOrchName = (receiverJSON \ JSON_PATH.GUID).as[String] + + "Sending FeyCore.ORCHESTRATION_RECEIVED with CREATE command to FeyCore of a GenericReceiverActor" should { + s"result in creating an Orchestration child actor with the name '$receiverOrchName'" in { + feyCoreRef ! FeyCore.ORCHESTRATION_RECEIVED(receiverJSON, None) + receiverOrch = TestProbe().expectActor(s"$feyPath/$receiverOrchName") + } + s"result in creating an Ensemble child actor with the name '$receiverOrchName/RECEIVER-ENSEMBLE'" in { + receiverEnsenble = TestProbe().expectActor(s"$feyPath/$receiverOrchName/RECEIVER-ENSEMBLE") + } + s"result in creating a Performer child actor with the name '$receiverOrchName/RECEIVER-ENSEMBLE/MY_RECEIVER_PERFORMER'" in { + receiverRef = TestProbe().expectActor(s"$feyPath/$receiverOrchName/RECEIVER-ENSEMBLE/MY_RECEIVER_PERFORMER") + } + s"result in new entry to FEY_CACHE.activeOrchestrations with key '$receiverOrchName'" in { + FEY_CACHE.activeOrchestrations should contain key(receiverOrchName) + } + } + + "Sending PROCESS message to the Receiver Performer" should { + "Send FeyCore.ORCHESTRATION_RECEIVED to FeyCore" in { + receiverRef ! FeyGenericActor.PROCESS(Utils_JSONTest.json_for_receiver_test) + TestProbe().expectActorInSystem(s"${FEY_CORE_ACTOR.actorRef.path}/RECEIVED-BY-ACTOR-RECEIVER", FEY_SYSTEM.system) + } + s"result in creating an Orchestration child actor with the name 'RECEIVED-BY-ACTOR-RECEIVER'" in { + TestProbe().expectActorInSystem(s"${FEY_CORE_ACTOR.actorRef.path}/RECEIVED-BY-ACTOR-RECEIVER", FEY_SYSTEM.system) + } + s"result in creating an Ensemble child actor with the name 'RECEIVED-BY-ACTOR-RECEIVER/MY-ENSEMBLE-REC-0001'" in { + TestProbe().expectActorInSystem(s"${FEY_CORE_ACTOR.actorRef.path}/RECEIVED-BY-ACTOR-RECEIVER/MY-ENSEMBLE-REC-0001", FEY_SYSTEM.system) + } + s"result in creating an Ensemble child actor with the name 'RECEIVED-BY-ACTOR-RECEIVER/MY-ENSEMBLE-REC-0002'" in { + TestProbe().expectActorInSystem(s"${FEY_CORE_ACTOR.actorRef.path}/RECEIVED-BY-ACTOR-RECEIVER/MY-ENSEMBLE-REC-0002", FEY_SYSTEM.system) + } + s"result in creating a Performer child actor with the name 'RECEIVED-BY-ACTOR-RECEIVER/MY-ENSEMBLE-REC-0002/TEST-0001'" in { + TestProbe().expectActorInSystem(s"${FEY_CORE_ACTOR.actorRef.path}/RECEIVED-BY-ACTOR-RECEIVER/MY-ENSEMBLE-REC-0002/TEST-0001", FEY_SYSTEM.system) + } + s"result in creating a Performer child actor with the name 'RECEIVED-BY-ACTOR-RECEIVER/MY-ENSEMBLE-REC-0001/TEST-0001'" in { + TestProbe().expectActorInSystem(s"${FEY_CORE_ACTOR.actorRef.path}/RECEIVED-BY-ACTOR-RECEIVER/MY-ENSEMBLE-REC-0001/TEST-0001", FEY_SYSTEM.system) + } + s"result in one new entry to FEY_CACHE.activeOrchestrations with key 'RECEIVED-BY-ACTOR-RECEIVER'" in { + FEY_CACHE.activeOrchestrations should have size(2) + FEY_CACHE.activeOrchestrations should contain key(receiverOrchName) + FEY_CACHE.activeOrchestrations should contain key("RECEIVED-BY-ACTOR-RECEIVER") + } + } + + "Sending PROCESS message to the Receiver Performer with command DELETE" should { + "STOP running orchestration" in { + val ref = TestProbe().expectActorInSystem(s"${FEY_CORE_ACTOR.actorRef.path}/RECEIVED-BY-ACTOR-RECEIVER", FEY_SYSTEM.system) + receiverRef ! FeyGenericActor.PROCESS(Utils_JSONTest.json_for_receiver_test_delete) + TestProbe().verifyActorTermination(ref) + } + s"result in one entry in FEY_CACHE.activeOrchestrations" in { + FEY_CACHE.activeOrchestrations should have size(1) + FEY_CACHE.activeOrchestrations should contain key(receiverOrchName) + } + } + + "Sending PROCESS message to Receiver with checkpoint enabled" should { + "Save received JSON to checkpoint dir" in { + CONFIG.CHEKPOINT_ENABLED = true + receiverRef ! FeyGenericActor.PROCESS(Utils_JSONTest.json_for_receiver_test) + TestProbe().expectActorInSystem(s"${FEY_CORE_ACTOR.actorRef.path}/RECEIVED-BY-ACTOR-RECEIVER", FEY_SYSTEM.system) + Files.exists(Paths.get(s"${CONFIG.CHECKPOINT_DIR}/RECEIVED-BY-ACTOR-RECEIVER.json")) should be(true) + CONFIG.CHEKPOINT_ENABLED = false + } + } + "Stopping FeyCore" should { "result in sending STOP message to Monitor actor" in { feyCoreRef ! PoisonPill monitor.expectMsgClass(1.seconds, classOf[Monitor.STOP]) + TestProbe().verifyActorTermination(receiverRef) } } http://git-wip-us.apache.org/repos/asf/incubator-iota/blob/a37164e6/fey-core/src/test/scala/org/apache/iota/fey/FeyGenericActorReceiverSpec.scala ---------------------------------------------------------------------- diff --git a/fey-core/src/test/scala/org/apache/iota/fey/FeyGenericActorReceiverSpec.scala b/fey-core/src/test/scala/org/apache/iota/fey/FeyGenericActorReceiverSpec.scala new file mode 100644 index 0000000..34235db --- /dev/null +++ b/fey-core/src/test/scala/org/apache/iota/fey/FeyGenericActorReceiverSpec.scala @@ -0,0 +1,139 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.iota.fey + +import java.nio.file.{Files, Paths} + +import akka.actor.Props +import akka.testkit.{EventFilter, TestActorRef, TestProbe} + +import scala.concurrent.duration.{DurationInt, FiniteDuration} + +class FeyGenericActorReceiverSpec extends BaseAkkaSpec{ + + val parent = TestProbe("GENERIC-RECEIVER-PARENT") + val monitor = TestProbe("MONITOR-GENERIC") + val feyTB = TestProbe("GENERIC-FEY") + val connectToTB = TestProbe("REC-CONNECT") + + val genericRef: TestActorRef[FeyGenericActorReceiverTest] = + TestActorRef[FeyGenericActorReceiverTest]( Props(new FeyGenericActorReceiverTest(Map.empty, 0.seconds, + Map("connect" -> connectToTB.ref),300.milliseconds,"MY-ORCH", "MY-ORCH", false){ + override private[fey] val monitoring_actor = monitor.ref + override private[fey] val feyCore = feyTB.ref + }),parent.ref, "GENERIC-RECEIVER-TEST") + + var genericState:FeyGenericActorReceiverTest = genericRef.underlyingActor + val path = genericRef.path.toString + + + "Creating a GenericActor with Schedule time defined" should { + "result in scheduler started" in{ + genericState.isShedulerRunning() should be(true) + } + "result in onStart method called" in { + genericState.started should be(true) + } + "result in START message sent to Monitor" in{ + monitor.expectMsgClass(classOf[Monitor.START]) + } + "result in one active actor" in { + globalIdentifierRef ! IdentifyFeyActors.IDENTIFY_TREE(parent.ref.path.toString) + Thread.sleep(500) + IdentifyFeyActors.actorsPath should have size(1) + IdentifyFeyActors.actorsPath should contain(s"${parent.ref.path}/GENERIC-RECEIVER-TEST") + } + s"result in normal functioning of GenericActor" in { + genericRef ! "PROPAGATE" + connectToTB.expectMsg(FeyGenericActor.PROCESS("PROPAGATE-CALLED")) + } + } + + "Sending PROCESS message to GenericReceiver" should { + "log message to Warn saying that the JSON could not be forwarded to FeyCore when JSON is invalid" in { + EventFilter.warning(message = s"Could not forward Orchestration TEST-ACTOR. Invalid JSON schema", occurrences = 1) intercept { + genericRef ! FeyGenericActor.PROCESS("INVALID_JSON") + feyTB.expectNoMsg(1.seconds) + } + } + "send ORCHESTRATION_RECEIVED to FeyCore when JSON to be processed has a valid schema" in { + genericRef ! FeyGenericActor.PROCESS("VALID_JSON") + feyTB.expectMsgClass(classOf[FeyCore.ORCHESTRATION_RECEIVED]) + } + "Download jar from location and send ORCHESTRATION_RECEIVED to FeyCore when JSON has a location defined" in { + genericRef ! FeyGenericActor.PROCESS("JSON_LOCATION") + Files.exists(Paths.get(s"${CONFIG.DYNAMIC_JAR_REPO}/fey-virtual-sensor.jar")) + feyTB.expectMsgClass(classOf[FeyCore.ORCHESTRATION_RECEIVED]) + } + } + + "Scheduler component" should { + "call execute() method" in { + genericState.executing should be(true) + } + } + + "Sending EXCEPTION(IllegalArgumentException) message to GenericActor" should { + "Throw IllegalArgumentException" in { + EventFilter[IllegalArgumentException](occurrences = 1) intercept { + genericRef ! FeyGenericActor.EXCEPTION(new IllegalArgumentException("Testing")) + } + } + "Result in restart of the actor with sequence of Monitoring: STOP -> RESTART -> START" in { + monitor.expectMsgClass(classOf[Monitor.STOP]) + monitor.expectMsgClass(classOf[Monitor.RESTART]) + //Restart does not change the actorRef but does change the object inside the ActorReference + genericState = genericRef.underlyingActor + monitor.expectMsgClass(classOf[Monitor.START]) + } + "call onStart method" in { + genericState.started should be(true) + } + "call onRestart method" in { + Thread.sleep(100) + genericState.restarted should be(true) + } + "restart scheduler" in { + genericState.isShedulerRunning() should be(true) + } + } + + "Sending STOP to GenericActor" should{ + "terminate GenericActor" in{ + genericRef ! FeyGenericActor.STOP + TestProbe().verifyActorTermination(genericRef) + TestProbe().notExpectActor(path) + } + "call onStop method" in { + genericState.stopped should be(true) + } + "cancel scheduler" in{ + genericState.isShedulerRunning() should be(false) + } + "send STOP - TERMINATE message to Monitor" in{ + monitor.expectMsgClass(classOf[Monitor.STOP]) + } + "result in no active actors" in { + globalIdentifierRef ! IdentifyFeyActors.IDENTIFY_TREE(parent.ref.path.toString) + Thread.sleep(500) + IdentifyFeyActors.actorsPath shouldBe empty + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-iota/blob/a37164e6/fey-core/src/test/scala/org/apache/iota/fey/FeyGenericActorReceiverTest.scala ---------------------------------------------------------------------- diff --git a/fey-core/src/test/scala/org/apache/iota/fey/FeyGenericActorReceiverTest.scala b/fey-core/src/test/scala/org/apache/iota/fey/FeyGenericActorReceiverTest.scala new file mode 100644 index 0000000..c110923 --- /dev/null +++ b/fey-core/src/test/scala/org/apache/iota/fey/FeyGenericActorReceiverTest.scala @@ -0,0 +1,70 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.iota.fey + +import akka.actor.ActorRef +import scala.concurrent.duration.{DurationInt, FiniteDuration} +import scala.concurrent.duration.FiniteDuration + +class FeyGenericActorReceiverTest(override val params: Map[String,String] = Map.empty, + override val backoff: FiniteDuration = 1.minutes, + override val connectTo: Map[String,ActorRef] = Map.empty, + override val schedulerTimeInterval: FiniteDuration = 2.seconds, + override val orchestrationName: String = "", + override val orchestrationID: String = "", + override val autoScale: Boolean = false) extends FeyGenericActorReceiver { + + override def customReceive:Receive = { + case "PROPAGATE" => propagateMessage("PROPAGATE-CALLED") + case x => log.debug(s"Message not treated: $x") + } + + override def getJSONString[T](input: T): String = { + input match{ + case "VALID_JSON" => Utils_JSONTest.create_json_test + case "INVALID_JSON" => Utils_JSONTest.test_json_schema_invalid + case "JSON_LOCATION" => Utils_JSONTest.location_test_2 + } + } + + var count = 0 + var started = false + var executing = false + var stopped = false + var restarted = false + + override def onStart(): Unit = { + started = true + } + + override def execute(): Unit = { + log.info(s"Executing action in ${self.path.name}") + executing = true + } + + override def onStop(): Unit = { + log.info(s"Actor ${self.path.name} stopped.") + stopped = true + } + + override def onRestart(reason: Throwable): Unit = { + restarted = true + } + +} http://git-wip-us.apache.org/repos/asf/incubator-iota/blob/a37164e6/fey-core/src/test/scala/org/apache/iota/fey/JsonReceiverSpec.scala ---------------------------------------------------------------------- diff --git a/fey-core/src/test/scala/org/apache/iota/fey/JsonReceiverSpec.scala b/fey-core/src/test/scala/org/apache/iota/fey/JsonReceiverSpec.scala index 1cf25ee..5691aef 100644 --- a/fey-core/src/test/scala/org/apache/iota/fey/JsonReceiverSpec.scala +++ b/fey-core/src/test/scala/org/apache/iota/fey/JsonReceiverSpec.scala @@ -63,7 +63,7 @@ class JsonReceiverSpec extends BaseAkkaSpec with LoggingTest{ } "download jar dynamically from URL" in { receiver.checkForLocation(getJSValueFromString(Utils_JSONTest.location_test)) - Files.exists(Paths.get(s"${CONFIG.DYNAMIC_JAR_REPO}/fey-stream.jar")) + Files.exists(Paths.get(s"${CONFIG.DYNAMIC_JAR_REPO}/fey-stream.jar")) should be(true) } } http://git-wip-us.apache.org/repos/asf/incubator-iota/blob/a37164e6/fey-core/src/test/scala/org/apache/iota/fey/Utils_JSONTest.scala ---------------------------------------------------------------------- diff --git a/fey-core/src/test/scala/org/apache/iota/fey/Utils_JSONTest.scala b/fey-core/src/test/scala/org/apache/iota/fey/Utils_JSONTest.scala index 417ba54..70d3ddc 100644 --- a/fey-core/src/test/scala/org/apache/iota/fey/Utils_JSONTest.scala +++ b/fey-core/src/test/scala/org/apache/iota/fey/Utils_JSONTest.scala @@ -417,4 +417,135 @@ object Utils_JSONTest { } ] }""" + + val location_test_2 = + """{ + "guid": "Orch2", + "command": "CREATE", + "timestamp": "591997890", + "name": "DESCRIPTION", + "ensembles": [ + { + "guid": "En2", + "command": "NONE", + "performers": [ + { + "guid": "S2", + "schedule": 1000, + "backoff": 0, + "source": { + "name": "fey-virtual-sensor.jar", + "classPath": "org.apache.iota.fey.performer.Sensor", + "location" :{ + "url" : "https://github.com/apache/incubator-iota/raw/master/fey-examples/active-jar-repo" + }, + "parameters": { + } + } + } + ], + "connections": [ + ] + } + ] + }""" + + val generic_receiver_json = """{ + "guid": "RECEIVER_ORCHESTRATION", + "command": "CREATE", + "timestamp": "591997890", + "name": "DESCRIPTION", + "ensembles": [ + { + "guid": "RECEIVER-ENSEMBLE", + "command": "NONE", + "performers": [ + { + "guid": "MY_RECEIVER_PERFORMER", + "schedule": 0, + "backoff": 0, + "source": { + "name": "fey-test-actor.jar", + "classPath": "org.apache.iota.fey.TestReceiverActor", + "parameters": { + } + } + } + ], + "connections": [ + ] + } + ] + }""" + + val json_for_receiver_test = + """{ + "guid" : "RECEIVED-BY-ACTOR-RECEIVER", + "command" : "CREATE", + "timestamp": "213263914979", + "name" : "ORCHESTRATION FOR TEST", + "ensembles" : [ + { + "guid":"MY-ENSEMBLE-REC-0001", + "command": "NONE", + "performers":[ + { + "guid": "TEST-0001", + "schedule": 0, + "backoff": 0, + "source": { + "name": "fey-test-actor.jar", + "classPath": "org.apache.iota.fey.TestActor", + "parameters": {} + } + } + ], + "connections":[] + }, + { + "guid":"MY-ENSEMBLE-REC-0002", + "command": "NONE", + "performers":[ + { + "guid": "TEST-0001", + "schedule": 0, + "backoff": 0, + "source": { + "name": "fey-test-actor.jar", + "classPath": "org.apache.iota.fey.TestActor_2", + "parameters": {} + } + } + ], + "connections":[] + } + ] + }""" + + val json_for_receiver_test_delete = + """{ + "guid" : "RECEIVED-BY-ACTOR-RECEIVER", + "command" : "DELETE", + "timestamp": "213263914979", + "name" : "ORCHESTRATION FOR TEST", + "ensembles" : [ + { + "guid":"MY-ENSEMBLE-REC-0001", + "command": "NONE", + "performers":[ + { + "guid": "TEST-0001", + "schedule": 0, + "backoff": 0, + "source": { + "name": "fey-test-actor.jar", + "classPath": "org.apache.iota.fey.TestActor", + "parameters": {} + } + } + ], + "connections":[] + } + ] + }""" }