fix memory leaks in tests, #20659

This commit is contained in:
Patrik Nordwall 2016-05-30 12:54:27 +02:00
parent 6a13d99bfc
commit be448e9fbb
36 changed files with 144 additions and 153 deletions

View file

@ -6,16 +6,15 @@ package docs.io
import java.net.{ Inet6Address, InetSocketAddress, NetworkInterface, StandardProtocolFamily }
import java.nio.channels.DatagramChannel
import scala.util.Random
import akka.actor.{ ActorSystem, Props }
import akka.io.Udp
import akka.testkit.TestKit
import org.scalatest.{ BeforeAndAfter, WordSpecLike }
import scala.collection.JavaConversions.enumerationAsScalaIterator
import org.scalatest.BeforeAndAfterAll
class ScalaUdpMulticastSpec extends TestKit(ActorSystem("ScalaUdpMulticastSpec")) with WordSpecLike with BeforeAndAfter {
class ScalaUdpMulticastSpec extends TestKit(ActorSystem("ScalaUdpMulticastSpec")) with WordSpecLike with BeforeAndAfterAll {
"listener" should {
"send message back to sink" in {
@ -65,7 +64,7 @@ class ScalaUdpMulticastSpec extends TestKit(ActorSystem("ScalaUdpMulticastSpec")
}
}
def afterAll(): Unit = {
override def afterAll(): Unit = {
TestKit.shutdownActorSystem(system)
}

View file

@ -11,6 +11,8 @@ import akka.testkit.ImplicitSender
import akka.testkit.TestProbe
import akka.testkit.TestActorRef
import akka.actor.ActorRefFactory
import akka.testkit.TestKit
import org.scalatest.BeforeAndAfterAll
/**
* Parent-Child examples
@ -74,8 +76,12 @@ class MockedChild extends Actor {
}
}
class ParentChildSpec extends WordSpec with Matchers with TestKitBase {
implicit lazy val system = ActorSystem()
class ParentChildSpec extends WordSpec with Matchers with TestKitBase with BeforeAndAfterAll {
implicit lazy val system = ActorSystem("ParentChildSpec")
override def afterAll(): Unit = {
TestKit.shutdownActorSystem(system)
}
"A DependentChild" should {
"be tested without its parent" in {
@ -132,4 +138,4 @@ class ParentChildSpec extends WordSpec with Matchers with TestKitBase {
}
}
//#test-fabricated-parent
}
}