iota-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tonyfaust...@apache.org
Subject [07/12] incubator-iota git commit: IdentifyFeyActors tests
Date Mon, 18 Jul 2016 20:43:30 GMT
IdentifyFeyActors tests


Project: http://git-wip-us.apache.org/repos/asf/incubator-iota/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-iota/commit/619d3e0e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-iota/tree/619d3e0e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-iota/diff/619d3e0e

Branch: refs/heads/master
Commit: 619d3e0e090f09a6b94d9906ba46bb4d653c75fe
Parents: 0ced675
Author: Barbara Gomes <barbaramaltagomes@gmail.com>
Authored: Fri Jul 15 18:30:14 2016 -0700
Committer: Barbara Gomes <barbaramaltagomes@gmail.com>
Committed: Fri Jul 15 18:30:14 2016 -0700

----------------------------------------------------------------------
 .../org/apache/iota/fey/IdentifyFeyActors.scala |  2 +-
 .../org/apache/iota/fey/BaseAkkaSpec.scala      |  3 +-
 .../apache/iota/fey/IdentifyFeyActorsSpec.scala | 63 ++++++++++++++++++++
 3 files changed, 66 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-iota/blob/619d3e0e/fey-core/src/main/scala/org/apache/iota/fey/IdentifyFeyActors.scala
----------------------------------------------------------------------
diff --git a/fey-core/src/main/scala/org/apache/iota/fey/IdentifyFeyActors.scala b/fey-core/src/main/scala/org/apache/iota/fey/IdentifyFeyActors.scala
index 9a09df4..f3852fe 100644
--- a/fey-core/src/main/scala/org/apache/iota/fey/IdentifyFeyActors.scala
+++ b/fey-core/src/main/scala/org/apache/iota/fey/IdentifyFeyActors.scala
@@ -27,7 +27,7 @@ protected class IdentifyFeyActors extends Actor with ActorLogging {
 
   import IdentifyFeyActors._
 
-  def receive = {
+  override def receive: Receive = {
     case IDENTIFY_TREE(startPath) =>
       log.info("Current Actors in system:")
       actorsPath = HashSet.empty

http://git-wip-us.apache.org/repos/asf/incubator-iota/blob/619d3e0e/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 673538e..3476718 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
@@ -39,7 +39,8 @@ class BaseAkkaSpec extends BaseSpec with BeforeAndAfterAll{
   CONFIG.loadUserConfiguration(Paths.get(conf.toURI()).toFile().getAbsolutePath)
   copyTestActorToTmp()
 
-  implicit val system = ActorSystem("FEY-TEST", ConfigFactory.parseString("""akka.loggers
= ["akka.testkit.TestEventListener"]"""))
+  val systemName = "FEY-TEST"
+  implicit val system = ActorSystem(systemName, ConfigFactory.parseString("""akka.loggers
= ["akka.testkit.TestEventListener"]"""))
   system.eventStream.publish(TestEvent.Mute(EventFilter.debug()))
   system.eventStream.publish(TestEvent.Mute(EventFilter.info()))
   system.eventStream.publish(TestEvent.Mute(EventFilter.warning()))

http://git-wip-us.apache.org/repos/asf/incubator-iota/blob/619d3e0e/fey-core/src/test/scala/org/apache/iota/fey/IdentifyFeyActorsSpec.scala
----------------------------------------------------------------------
diff --git a/fey-core/src/test/scala/org/apache/iota/fey/IdentifyFeyActorsSpec.scala b/fey-core/src/test/scala/org/apache/iota/fey/IdentifyFeyActorsSpec.scala
new file mode 100644
index 0000000..7a618fc
--- /dev/null
+++ b/fey-core/src/test/scala/org/apache/iota/fey/IdentifyFeyActorsSpec.scala
@@ -0,0 +1,63 @@
+
+/*
+ * 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, Props}
+
+class IdentifyFeyActorsSpec extends BaseAkkaSpec {
+
+  val identifyRef = system.actorOf(Props[IdentifyFeyActors],"IDENTIFIER")
+
+  "Sending IdentifyFeyActors.IDENTIFY_TREE to IdentifyFeyActors" should {
+    s"result in one path added to IdentifyFeyActors.actorsPath" in {
+      identifyRef ! IdentifyFeyActors.IDENTIFY_TREE(s"akka://$systemName/user")
+      Thread.sleep(1000)
+      IdentifyFeyActors.actorsPath.size should equal(1)
+    }
+    s"result in path 'akka://FEY-TEST/user/IDENTIFIER' " in {
+      IdentifyFeyActors.actorsPath should contain("akka://FEY-TEST/user/IDENTIFIER")
+    }
+  }
+
+  var actor2: ActorRef = _
+
+  "Creating a new actor in the system and sending IdentifyFeyActors.IDENTIFY_TREE to IdentifyFeyActors"
should {
+    s"result in two paths added to IdentifyFeyActors.actorsPath" in {
+      actor2 = system.actorOf(Props[Monitor],"MONITOR")
+      identifyRef ! IdentifyFeyActors.IDENTIFY_TREE(s"akka://$systemName/user")
+      Thread.sleep(1000)
+      IdentifyFeyActors.actorsPath.size should equal(2)
+    }
+    s"result in matching paths" in {
+      IdentifyFeyActors.actorsPath should contain("akka://FEY-TEST/user/IDENTIFIER")
+      IdentifyFeyActors.actorsPath should contain("akka://FEY-TEST/user/MONITOR")
+    }
+  }
+
+  "Stopping precious added actor and sending IdentifyFeyActors.IDENTIFY_TREE to IdentifyFeyActors"
should {
+    "result in going back to have just one path added to IdentifyFeyActors.actorsPath" in
{
+      identifyRef ! IdentifyFeyActors.IDENTIFY_TREE(s"akka://$systemName/user")
+      Thread.sleep(1000)
+      IdentifyFeyActors.actorsPath.size should equal(2)
+    }
+    s"result in path 'akka://FEY-TEST/user/IDENTIFIER' " in {
+      IdentifyFeyActors.actorsPath should contain("akka://FEY-TEST/user/IDENTIFIER")
+    }
+  }
+}


Mime
View raw message