fix memory leaks in tests, #20659
This commit is contained in:
parent
6a13d99bfc
commit
be448e9fbb
36 changed files with 144 additions and 153 deletions
|
|
@ -151,7 +151,7 @@ public class FaultHandlingTest extends AbstractJavaTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void start() {
|
||||
system = ActorSystem.create("test");
|
||||
system = ActorSystem.create("FaultHandlingTest");
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
|
|
|||
|
|
@ -22,10 +22,10 @@ import akka.testkit.AkkaJUnitActorSystemResource;
|
|||
import org.junit.*;
|
||||
|
||||
public class SchedulerDocTest extends AbstractJavaTest {
|
||||
|
||||
@Rule
|
||||
public AkkaJUnitActorSystemResource actorSystemResource =
|
||||
new AkkaJUnitActorSystemResource("SchedulerDocTest", AkkaSpec.testConf());
|
||||
|
||||
@ClassRule
|
||||
public static AkkaJUnitActorSystemResource actorSystemResource = new AkkaJUnitActorSystemResource("SchedulerDocTest",
|
||||
AkkaSpec.testConf());
|
||||
|
||||
private final ActorSystem system = actorSystemResource.getSystem();
|
||||
private ActorRef testActor = system.actorOf(Props.create(MyUntypedActor.class));
|
||||
|
|
|
|||
|
|
@ -11,11 +11,14 @@ public class CustomRouteTestBase {
|
|||
public void customRoute() throws Exception{
|
||||
//#CustomRoute
|
||||
ActorSystem system = ActorSystem.create("some-system");
|
||||
Camel camel = CamelExtension.get(system);
|
||||
ActorRef responder = system.actorOf(Props.create(Responder.class), "TestResponder");
|
||||
camel.context().addRoutes(new CustomRouteBuilder(responder));
|
||||
//#CustomRoute
|
||||
system.stop(responder);
|
||||
JavaTestKit.shutdownActorSystem(system);
|
||||
try {
|
||||
Camel camel = CamelExtension.get(system);
|
||||
ActorRef responder = system.actorOf(Props.create(Responder.class), "TestResponder");
|
||||
camel.context().addRoutes(new CustomRouteBuilder(responder));
|
||||
//#CustomRoute
|
||||
system.stop(responder);
|
||||
} finally {
|
||||
JavaTestKit.shutdownActorSystem(system);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,6 +130,11 @@ public class SchedulerPatternTest extends AbstractJavaTest {
|
|||
testSchedule(probe, props, duration("3000 millis"), duration("2500 millis"));
|
||||
}};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void doNothing() {
|
||||
// actorSystemResource.after is not called when all tests are ignored
|
||||
}
|
||||
|
||||
public static class TestSchedule extends JavaTestKit {
|
||||
private ActorSystem system;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue