mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-03-27 15:59:12 +00:00
Restructure repository
* Move /common/src to /src * Move services to net.psforever package * Move /pslogin to /server
This commit is contained in:
parent
89a30ae6f6
commit
f4fd78fc5d
958 changed files with 527 additions and 725 deletions
49
src/test/scala/objects/DefaultTest.scala
Normal file
49
src/test/scala/objects/DefaultTest.scala
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
// Copyright (c) 2020 PSForever
|
||||
package objects
|
||||
|
||||
import akka.actor.DeadLetter
|
||||
import akka.testkit.TestProbe
|
||||
import base.ActorTest
|
||||
import net.psforever.objects.Default
|
||||
import org.specs2.mutable.Specification
|
||||
|
||||
import scala.concurrent.duration._
|
||||
|
||||
class DefaultTest extends Specification {
|
||||
"Default.Cancellable" should {
|
||||
"always act like it can be cancelled successfully" in {
|
||||
Default.Cancellable.cancel() mustEqual true
|
||||
}
|
||||
|
||||
"always act like it was cancelled successfully" in {
|
||||
Default.Cancellable.isCancelled mustEqual true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class DefaultActorStartedTest extends ActorTest {
|
||||
"Default.Actor" should {
|
||||
"send messages to deadLetters" in {
|
||||
//after being started
|
||||
Default(system)
|
||||
val probe = new TestProbe(system)
|
||||
system.eventStream.subscribe(probe.ref, classOf[DeadLetter])
|
||||
Default.Actor ! "hello world"
|
||||
val msg1 = probe.receiveOne(250 milliseconds)
|
||||
assert(msg1.isInstanceOf[DeadLetter])
|
||||
assert(msg1.asInstanceOf[DeadLetter].message equals "hello world")
|
||||
|
||||
//if it was stopped
|
||||
system.stop(Default.Actor)
|
||||
Default.Actor ! "hello world"
|
||||
val msg2 = probe.receiveOne(250 milliseconds)
|
||||
assert(msg2.isInstanceOf[DeadLetter])
|
||||
assert(msg2.asInstanceOf[DeadLetter].message equals "hello world")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object DefaultActorTest {
|
||||
//due to being a singleton, the original original value of the Default.Actor is cached here
|
||||
val Original = Default.Actor
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue