package com.riaektiv.fdp

import akka.actor.ActorRef
import akka.actor.ActorSystem
import akka.actor.Props
import org.junit.Test
import scala.concurrent.Await
import scala.concurrent.duration.FiniteDuration
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit

/**
 * Coding With Passion Since 1991
 *
 * Created: 5/14/2017, 8:29 PM Eastern Time
 *
 * @author Sergey Chuykov
 */
class SomeActorTest {

    val ONE_MINUTE = FiniteDuration(1, TimeUnit.MINUTES)

    @Test
    fun test() {

        val latch = CountDownLatch(1)

        val system = ActorSystem.create()

        val some = system.actorOf(Props.create(SomeActor::class.java))

        some.tell(Ticket("Ping", latch), ActorRef.noSender())

        latch.await(10, TimeUnit.SECONDS)

        Await.result(system.terminate(), ONE_MINUTE)

    }

}
