From 9e68f057656d1dccc5c9fa04815645c546455c7e Mon Sep 17 00:00:00 2001 From: thomas Date: Wed, 21 Jun 2023 08:17:39 +0200 Subject: [PATCH 01/23] junit5 extension and tests --- .../testkit/typed/javadsl/Junit5TestKit.java | 20 +++++ .../typed/javadsl/Junit5TestKitBuilder.scala | 48 +++++++++++ .../typed/javadsl/LogCapturingExtension.scala | 54 ++++++++++++ .../javadsl/TestKitJunit5Extension.scala | 43 ++++++++++ .../testkit/typed/javadsl/GreeterMain.scala | 62 ++++++++++++++ .../javadsl/Junit5IntegrationExampleTest.java | 59 +++++++++++++ .../LogCapturingExtensionExampleTest.java | 49 +++++++++++ .../typed/javadsl/ActorTestKitJunit5Test.java | 76 +++++++++++++++++ .../scaladsl/Junit5TestKitBuilderSpec.scala | 83 +++++++++++++++++++ 9 files changed, 494 insertions(+) create mode 100644 actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/Junit5TestKit.java create mode 100644 actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/Junit5TestKitBuilder.scala create mode 100644 actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/LogCapturingExtension.scala create mode 100644 actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala create mode 100644 actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/GreeterMain.scala create mode 100644 actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/Junit5IntegrationExampleTest.java create mode 100644 actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/LogCapturingExtensionExampleTest.java create mode 100644 actor-testkit-typed/src/test/java/org/apache/pekko/actor/testkit/typed/javadsl/ActorTestKitJunit5Test.java create mode 100644 actor-testkit-typed/src/test/scala/org/apache/pekko/actor/testkit/typed/scaladsl/Junit5TestKitBuilderSpec.scala diff --git a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/Junit5TestKit.java b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/Junit5TestKit.java new file mode 100644 index 00000000000..e62beeda34f --- /dev/null +++ b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/Junit5TestKit.java @@ -0,0 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * license agreements; and to You under the Apache License, version 2.0: + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * This file is part of the Apache Pekko project, derived from Akka. + */ + +package org.apache.pekko.actor.testkit.typed.javadsl; + +import java.lang.annotation.*; + +@Documented +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface Junit5TestKit { +} + + diff --git a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/Junit5TestKitBuilder.scala b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/Junit5TestKitBuilder.scala new file mode 100644 index 00000000000..05e5d368b64 --- /dev/null +++ b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/Junit5TestKitBuilder.scala @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * license agreements; and to You under the Apache License, version 2.0: + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * This file is part of the Apache Pekko project, derived from Akka. + */ + +package org.apache.pekko.actor.testkit.typed.javadsl + +import com.typesafe.config.Config +import org.apache.pekko.actor.testkit.typed.internal.TestKitUtils +import org.apache.pekko.actor.testkit.typed.scaladsl.ActorTestKit.ApplicationTestConfig +import org.apache.pekko.actor.typed.ActorSystem + + case class Junit5TestKitBuilder() { + + var system: Option[ActorSystem[_]] = None + + var customConfig: Config = ApplicationTestConfig + + var name: String = TestKitUtils.testNameFromCallStack(classOf[Junit5TestKitBuilder]) + + def withSystem(system: ActorSystem[_]): Junit5TestKitBuilder = { + this.system = Some(system) + this + } + + def withCustomConfig(customConfig: Config): Junit5TestKitBuilder = { + this.customConfig = customConfig + this + } + + def withName(name: String): Junit5TestKitBuilder = { + this.name = name + this + } + + def build(): ActorTestKit = { + if (system.isDefined) { + return ActorTestKit.create(system.get) + } + ActorTestKit.create(name, customConfig) + } + +} + diff --git a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/LogCapturingExtension.scala b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/LogCapturingExtension.scala new file mode 100644 index 00000000000..462faea84ad --- /dev/null +++ b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/LogCapturingExtension.scala @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * license agreements; and to You under the Apache License, version 2.0: + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * This file is part of the Apache Pekko project, derived from Akka. + */ + +package org.apache.pekko.actor.testkit.typed.javadsl + +import org.junit.jupiter.api.extension.InvocationInterceptor.Invocation +import org.junit.jupiter.api.extension.{ ExtensionContext, InvocationInterceptor, ReflectiveInvocationContext } +import org.slf4j.LoggerFactory +import org.apache.pekko.actor.testkit.typed.internal.CapturingAppender + +import java.lang.reflect.Method +import scala.util.control.NonFatal + +final class LogCapturingExtension extends InvocationInterceptor { + + private val capturingAppender = CapturingAppender.get("") + + private val myLogger = LoggerFactory.getLogger(classOf[LogCapturing]) + + @throws[Throwable] + override def interceptTestMethod(invocation: Invocation[Void], invocationContext: ReflectiveInvocationContext[Method], + extensionContext: ExtensionContext): Unit = { + + + val testClassName = invocationContext.getTargetClass.getSimpleName + val testMethodName = invocationContext.getExecutable.getName + + try { + myLogger.info(s"Logging started for test [${testClassName}: ${testMethodName}]") + invocation.proceed + myLogger.info( + s"Logging finished for test [${testClassName}: ${testMethodName}] that was successful") + } catch { + case NonFatal(e) => + println( + s"--> [${Console.BLUE}${testClassName}: ${testMethodName}${Console.RESET}] " + + s"Start of log messages of test that failed with ${e.getMessage}") + capturingAppender.flush() + println( + s"<-- [${Console.BLUE}${testClassName}: ${testMethodName}${Console.RESET}] " + + s"End of log messages of test that failed with ${e.getMessage}") + throw e + } finally { + + capturingAppender.clear() + } + } +} diff --git a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala new file mode 100644 index 00000000000..e60afb609b7 --- /dev/null +++ b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * license agreements; and to You under the Apache License, version 2.0: + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * This file is part of the Apache Pekko project, derived from Akka. + */ + +package org.apache.pekko.actor.testkit.typed.javadsl + +import org.apache.pekko +import org.junit.jupiter.api.extension.{AfterAllCallback, BeforeTestExecutionCallback, ExtensionContext} +import org.junit.platform.commons.support.AnnotationSupport + +import scala.jdk.CollectionConverters._ + +final class TestKitJunit5Extension() extends AfterAllCallback with BeforeTestExecutionCallback { + + var testKit: Option[ActorTestKit] = None + + + /** + * Get a reference to the field annotated with @Junit5Testkit [[pekko.actor.testkit.typed.javadsl.Junit5TestKit]] + * + */ + override def beforeTestExecution(context: ExtensionContext): Unit = { + + context.getTestInstance.ifPresent(instance => { + val fielValue = AnnotationSupport.findAnnotatedFieldValues(instance, classOf[Junit5TestKit]).asScala.toList.head + testKit = Some(fielValue.asInstanceOf[ActorTestKit]) + }) + } + + + /** + * Shutdown testKit + */ + override def afterAll(context: ExtensionContext): Unit = { + testKit.get.shutdownTestKit() + } + +} diff --git a/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/GreeterMain.scala b/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/GreeterMain.scala new file mode 100644 index 00000000000..dfccafffa8d --- /dev/null +++ b/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/GreeterMain.scala @@ -0,0 +1,62 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * license agreements; and to You under the Apache License, version 2.0: + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * This file is part of the Apache Pekko project, derived from Akka. + */ + +package jdocs.org.apache.pekko.actor.testkit.typed.javadsl + +import org.apache.pekko.actor.typed.{ActorRef, Behavior} +import org.apache.pekko.actor.typed.scaladsl.Behaviors + + +object Greeter { + final case class Greet(whom: String, replyTo: ActorRef[Greeted]) + final case class Greeted(whom: String, from: ActorRef[Greet]) + + def apply(): Behavior[Greet] = Behaviors.receive { (context, message) => + context.log.info("Hello {}!", message.whom) + //#greeter-send-messages + message.replyTo ! Greeted(message.whom, context.self) + //#greeter-send-messages + Behaviors.same + } +} + +object GreeterBot { + + def apply(max: Int): Behavior[Greeter.Greeted] = { + bot(0, max) + } + + private def bot(greetingCounter: Int, max: Int): Behavior[Greeter.Greeted] = + Behaviors.receive { (context, message) => + val n = greetingCounter + 1 + context.log.info("Greeting {} for {}", n, message.whom) + if (n == max) { + Behaviors.stopped + } else { + message.from ! Greeter.Greet(message.whom, context.self) + bot(n, max) + } + } +} + +object GreeterMain { + + final case class SayHello(name: String) + + def apply(): Behavior[SayHello] = + Behaviors.setup { context => + val greeter = context.spawn(Greeter(), "greeter") + + Behaviors.receiveMessage { message => + val replyTo = context.spawn(GreeterBot(max = 3), message.name) + greeter ! Greeter.Greet(message.name, replyTo) + Behaviors.same + } + } +} \ No newline at end of file diff --git a/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/Junit5IntegrationExampleTest.java b/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/Junit5IntegrationExampleTest.java new file mode 100644 index 00000000000..a67b75ff431 --- /dev/null +++ b/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/Junit5IntegrationExampleTest.java @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * license agreements; and to You under the Apache License, version 2.0: + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * This file is part of the Apache Pekko project, derived from Akka. + */ + +package jdocs.org.apache.pekko.actor.testkit.typed.javadsl; + +import org.apache.pekko.actor.Address; +import org.apache.pekko.actor.testkit.typed.javadsl.*; +import org.apache.pekko.actor.testkit.typed.javadsl.Junit5TestKitBuilder; +import org.apache.pekko.actor.typed.ActorRef; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +// #junit5-integration +@DisplayName("Junit5") +@ExtendWith(TestKitJunit5Extension.class) +class Junit5IntegrationExampleTest { + + @Junit5TestKit public ActorTestKit testKit = new Junit5TestKitBuilder().build(); + + @Test + void junit5Test() { + Address address = testKit.system().address(); + assertNotNull(address); + } + + @Test + void testSomething() { + + ActorRef pinger = + testKit.spawn(AsyncTestingExampleTest.Echo.create(), "ping"); + TestProbe probe = testKit.createTestProbe(); + pinger.tell(new AsyncTestingExampleTest.Echo.Ping("hello", probe.ref())); + AsyncTestingExampleTest.Echo.Pong pong = + probe.expectMessage(new AsyncTestingExampleTest.Echo.Pong("hello")); + assertEquals("hello", pong.message); + } + + @Test + void testSomething2() { + ActorRef pinger2 = + testKit.spawn(AsyncTestingExampleTest.Echo.create(), "ping2"); + TestProbe probe2 = testKit.createTestProbe(); + pinger2.tell(new AsyncTestingExampleTest.Echo.Ping("hello", probe2.ref())); + AsyncTestingExampleTest.Echo.Pong pong = + probe2.expectMessage(new AsyncTestingExampleTest.Echo.Pong("hello")); + assertEquals("hello", pong.message); + } +} +// #junit5-integration diff --git a/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/LogCapturingExtensionExampleTest.java b/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/LogCapturingExtensionExampleTest.java new file mode 100644 index 00000000000..a799a76d104 --- /dev/null +++ b/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/LogCapturingExtensionExampleTest.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * license agreements; and to You under the Apache License, version 2.0: + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * This file is part of the Apache Pekko project, derived from Akka. + */ + +/* + * Copyright (C) 2009-2022 Lightbend Inc. + */ + +package jdocs.org.apache.pekko.actor.testkit.typed.javadsl; + +// #log-capturing-junit5 +import org.apache.pekko.actor.testkit.typed.javadsl.*; +import org.apache.pekko.actor.testkit.typed.javadsl.Junit5TestKitBuilder; +import org.apache.pekko.actor.typed.ActorRef; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import static jdocs.org.apache.pekko.actor.testkit.typed.javadsl.AsyncTestingExampleTest.Echo; + +@DisplayName("Junit5 log capturing") +@ExtendWith(TestKitJunit5Extension.class) +@ExtendWith(LogCapturingExtension.class) +class LogCapturingExtensionExampleTest { + + @Junit5TestKit public ActorTestKit testKit = new Junit5TestKitBuilder().build(); + + @Test + void testSomething() { + ActorRef pinger = testKit.spawn(Echo.create(), "ping"); + TestProbe probe = testKit.createTestProbe(); + pinger.tell(new Echo.Ping("hello", probe.ref())); + probe.expectMessage(new Echo.Pong("hello")); + } + + @Test + void testSomething2() { + ActorRef pinger = testKit.spawn(Echo.create(), "ping"); + TestProbe probe = testKit.createTestProbe(); + pinger.tell(new Echo.Ping("hello", probe.ref())); + probe.expectMessage(new Echo.Pong("hello")); + } +} +// #log-capturing-junit5 diff --git a/actor-testkit-typed/src/test/java/org/apache/pekko/actor/testkit/typed/javadsl/ActorTestKitJunit5Test.java b/actor-testkit-typed/src/test/java/org/apache/pekko/actor/testkit/typed/javadsl/ActorTestKitJunit5Test.java new file mode 100644 index 00000000000..2f77fbe33b9 --- /dev/null +++ b/actor-testkit-typed/src/test/java/org/apache/pekko/actor/testkit/typed/javadsl/ActorTestKitJunit5Test.java @@ -0,0 +1,76 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * license agreements; and to You under the Apache License, version 2.0: + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * This file is part of the Apache Pekko project, derived from Akka. + */ + +/* + * Copyright (C) 2018-2022 Lightbend Inc. + */ + +package org.apache.pekko.actor.testkit.typed.javadsl; + +import org.apache.pekko.Done; +import org.apache.pekko.actor.typed.javadsl.Behaviors; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.scalatestplus.junit.JUnitSuite; + +import java.util.HashMap; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.TimeUnit; + +import static org.apache.pekko.Done.done; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +@DisplayName("ActorTestKitTestJunit5") +@ExtendWith(TestKitJunit5Extension.class) +@ExtendWith(LogCapturingExtension.class) +class ActorTestKitJunit5Test extends JUnitSuite { + + @Junit5TestKit public ActorTestKit testKit = new Junit5TestKitBuilder().build(); + + @Test + void systemNameShouldComeFromTestClassViaJunitResource() { + assertEquals("ActorTestKitJunit5Test", testKit.system().name()); + } + + @Test + void systemNameShouldComeFromTestClass() { + final ActorTestKit testKit2 = ActorTestKit.create(); + try { + assertEquals("ActorTestKitJunit5Test", testKit2.system().name()); + } finally { + testKit2.shutdownTestKit(); + } + } + + @Test + void systemNameShouldComeFromGivenClassName() { + final ActorTestKit testKit2 = ActorTestKit.create(HashMap.class.getName()); + try { + // removing package name and such + assertEquals("HashMap", testKit2.system().name()); + } finally { + testKit2.shutdownTestKit(); + } + } + + @Test + void testKitShouldSpawnActor() throws Exception { + final CompletableFuture started = new CompletableFuture<>(); + testKit.spawn( + Behaviors.setup( + (context) -> { + started.complete(done()); + return Behaviors.same(); + })); + assertNotNull(started.get(3, TimeUnit.SECONDS)); + } +} diff --git a/actor-testkit-typed/src/test/scala/org/apache/pekko/actor/testkit/typed/scaladsl/Junit5TestKitBuilderSpec.scala b/actor-testkit-typed/src/test/scala/org/apache/pekko/actor/testkit/typed/scaladsl/Junit5TestKitBuilderSpec.scala new file mode 100644 index 00000000000..f18f24681ec --- /dev/null +++ b/actor-testkit-typed/src/test/scala/org/apache/pekko/actor/testkit/typed/scaladsl/Junit5TestKitBuilderSpec.scala @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * license agreements; and to You under the Apache License, version 2.0: + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * This file is part of the Apache Pekko project, derived from Akka. + */ + +package org.apache.pekko.actor.testkit.typed.scaladsl + +import com.typesafe.config.ConfigFactory +import jdocs.org.apache.pekko.actor.testkit.typed.javadsl.GreeterMain +import org.apache.pekko.actor.testkit.typed.javadsl.Junit5TestKitBuilder +import org.apache.pekko.actor.typed.ActorSystem +import org.scalatest.wordspec.AnyWordSpec + + + +class Junit5TestKitBuilderSpec extends AnyWordSpec{ + + + "the Junit5TestKitBuilder" should { + "create a Testkit with name hello" in { + val actualTestKit = Junit5TestKitBuilder() + .withName("hello") + .build() + + assertResult("hello")(actualTestKit.system.name) + } + } + + "the Junit5TestKitBuilder" should { + "create a Testkit with the classname as name" in { + val actualTestKit = Junit5TestKitBuilder() + .build() + + assertResult("Junit5TestKitBuilderSpec")(actualTestKit.system.name) + } + } + + + "the Junit5TestKitBuilder" should { + "create a Testkit with a custom config" in { + + val conf = ConfigFactory.load("application.conf") + val actualTestKit = Junit5TestKitBuilder() + .withCustomConfig(conf) + .build() + assertResult("someValue")(actualTestKit.system.settings.config.getString("test.value")) + assertResult("Junit5TestKitBuilderSpec")(actualTestKit.system.name) + + } + } + + "the Junit5TestKitBuilder" should { + "create a Testkit with a custom config and name" in { + + val conf = ConfigFactory.load("application.conf") + val actualTestKit = Junit5TestKitBuilder() + .withCustomConfig(conf) + .withName("hello") + .build() + assertResult("someValue")(actualTestKit.system.settings.config.getString("test.value")) + assertResult("hello")(actualTestKit.system.name) + + } + } + + "the Junit5TestKitBuilder" should { + "create a Testkit with a custom system" in { + + val system: ActorSystem[GreeterMain.SayHello] = ActorSystem(GreeterMain(), "AkkaQuickStart") + + val actualTestKit = Junit5TestKitBuilder() + .withSystem(system) + .build() + assertResult("AkkaQuickStart")(actualTestKit.system.name) + } + } + + +} From 2e6ae544b92947e19b2f06e00dae3875c7d4e87f Mon Sep 17 00:00:00 2001 From: thomas Date: Wed, 21 Jun 2023 20:19:01 +0200 Subject: [PATCH 02/23] cleanup merge residuals in Dependencies.scala --- project/Dependencies.scala | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index a40c37149a3..8846cbf3827 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -24,6 +24,8 @@ object Dependencies { .withRank(KeyRanks.Invisible) // avoid 'unused key' warning val junitVersion = "4.13.2" + val junit5Version = "5.10.0-M1" + val slf4jVersion = "1.7.36" // check agrona version when updating this val aeronVersion = "1.38.1" @@ -86,6 +88,8 @@ object Dependencies { val lmdb = "org.lmdbjava" % "lmdbjava" % "0.7.0" val junit = "junit" % "junit" % junitVersion + val junit5 = "org.junit.jupiter" % "junit-jupiter-engine" % junit5Version + // For Java 8 Conversions val java8Compat = Def.setting { @@ -138,8 +142,10 @@ object Dependencies { val commonsIo = "commons-io" % "commons-io" % "2.11.0" % Test val commonsCodec = "commons-codec" % "commons-codec" % "1.15" % Test val commonsCompress = "org.apache.commons" % "commons-compress" % "1.23.0" % Test - val junit = "junit" % "junit" % junitVersion % Test val httpClient = "org.apache.httpcomponents" % "httpclient" % "4.5.14" % Test + val junit = "junit" % "junit" % junitVersion % "test" + val junit5 = "org.junit.jupiter" % "junit-jupiter-engine" % junit5Version % Test + val logback = Compile.logback % Test @@ -213,6 +219,7 @@ object Dependencies { val levelDBNative = "org.fusesource.leveldbjni" % "leveldbjni-all" % "1.8" % "optional;provided" val junit = Compile.junit % "optional;provided;test" + val junit5 = Compile.junit5 % "optional;provided;test" val scalatest = Def.setting { "org.scalatest" %% "scalatest" % scalaTestVersion % "optional;provided;test" } @@ -266,6 +273,7 @@ object Dependencies { val actorTestkitTyped = l ++= Seq( Provided.logback, Provided.junit, + Provided.junit5, Provided.scalatest.value, TestDependencies.scalatestJUnit.value) From d8952344c24d68ba403eafdf649afe0e7867b4ac Mon Sep 17 00:00:00 2001 From: thomas Date: Wed, 21 Jun 2023 21:19:05 +0200 Subject: [PATCH 03/23] added config value for test --- actor-testkit-typed/src/test/resources/application.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/actor-testkit-typed/src/test/resources/application.conf b/actor-testkit-typed/src/test/resources/application.conf index 594856dc472..f2a746dd9b7 100644 --- a/actor-testkit-typed/src/test/resources/application.conf +++ b/actor-testkit-typed/src/test/resources/application.conf @@ -2,3 +2,4 @@ # used by ActorTestKitSpec test.from-application = yes +test.value = someValue From 7e6a2306fbbf2562e33912310442fa90e5a9e4be Mon Sep 17 00:00:00 2001 From: thomas Date: Wed, 21 Jun 2023 21:44:19 +0200 Subject: [PATCH 04/23] changed junit5 version to 5.9.3 --- project/Dependencies.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 8846cbf3827..e32c4bd2492 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -24,7 +24,7 @@ object Dependencies { .withRank(KeyRanks.Invisible) // avoid 'unused key' warning val junitVersion = "4.13.2" - val junit5Version = "5.10.0-M1" + val junit5Version = "5.9.3" val slf4jVersion = "1.7.36" // check agrona version when updating this From 07ae196c08a71d7ab1ba5fb2f3dd1225c7d09fa3 Mon Sep 17 00:00:00 2001 From: thomas Date: Wed, 21 Jun 2023 21:49:47 +0200 Subject: [PATCH 05/23] added results of scalafmt run --- .../testkit/typed/javadsl/Junit5TestKitBuilder.scala | 9 ++++----- .../testkit/typed/javadsl/LogCapturingExtension.scala | 1 - .../testkit/typed/javadsl/TestKitJunit5Extension.scala | 9 +++------ 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/Junit5TestKitBuilder.scala b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/Junit5TestKitBuilder.scala index 05e5d368b64..b9711e3bf13 100644 --- a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/Junit5TestKitBuilder.scala +++ b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/Junit5TestKitBuilder.scala @@ -14,13 +14,13 @@ import org.apache.pekko.actor.testkit.typed.internal.TestKitUtils import org.apache.pekko.actor.testkit.typed.scaladsl.ActorTestKit.ApplicationTestConfig import org.apache.pekko.actor.typed.ActorSystem - case class Junit5TestKitBuilder() { +case class Junit5TestKitBuilder() { - var system: Option[ActorSystem[_]] = None + var system: Option[ActorSystem[_]] = None - var customConfig: Config = ApplicationTestConfig + var customConfig: Config = ApplicationTestConfig - var name: String = TestKitUtils.testNameFromCallStack(classOf[Junit5TestKitBuilder]) + var name: String = TestKitUtils.testNameFromCallStack(classOf[Junit5TestKitBuilder]) def withSystem(system: ActorSystem[_]): Junit5TestKitBuilder = { this.system = Some(system) @@ -45,4 +45,3 @@ import org.apache.pekko.actor.typed.ActorSystem } } - diff --git a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/LogCapturingExtension.scala b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/LogCapturingExtension.scala index 462faea84ad..f8ae1023710 100644 --- a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/LogCapturingExtension.scala +++ b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/LogCapturingExtension.scala @@ -27,7 +27,6 @@ final class LogCapturingExtension extends InvocationInterceptor { override def interceptTestMethod(invocation: Invocation[Void], invocationContext: ReflectiveInvocationContext[Method], extensionContext: ExtensionContext): Unit = { - val testClassName = invocationContext.getTargetClass.getSimpleName val testMethodName = invocationContext.getExecutable.getName diff --git a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala index e60afb609b7..5941c0d2b08 100644 --- a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala +++ b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala @@ -10,7 +10,7 @@ package org.apache.pekko.actor.testkit.typed.javadsl import org.apache.pekko -import org.junit.jupiter.api.extension.{AfterAllCallback, BeforeTestExecutionCallback, ExtensionContext} +import org.junit.jupiter.api.extension.{ AfterAllCallback, BeforeTestExecutionCallback, ExtensionContext } import org.junit.platform.commons.support.AnnotationSupport import scala.jdk.CollectionConverters._ @@ -19,12 +19,10 @@ final class TestKitJunit5Extension() extends AfterAllCallback with BeforeTestExe var testKit: Option[ActorTestKit] = None - /** * Get a reference to the field annotated with @Junit5Testkit [[pekko.actor.testkit.typed.javadsl.Junit5TestKit]] - * */ - override def beforeTestExecution(context: ExtensionContext): Unit = { + override def beforeTestExecution(context: ExtensionContext): Unit = { context.getTestInstance.ifPresent(instance => { val fielValue = AnnotationSupport.findAnnotatedFieldValues(instance, classOf[Junit5TestKit]).asScala.toList.head @@ -32,12 +30,11 @@ final class TestKitJunit5Extension() extends AfterAllCallback with BeforeTestExe }) } - /** * Shutdown testKit */ override def afterAll(context: ExtensionContext): Unit = { - testKit.get.shutdownTestKit() + testKit.get.shutdownTestKit() } } From b7e06eee1501d3145ef873b654e2a15f20643f75 Mon Sep 17 00:00:00 2001 From: thomas Date: Wed, 21 Jun 2023 22:09:57 +0200 Subject: [PATCH 06/23] removed unnecessary license header --- .../typed/javadsl/LogCapturingExtensionExampleTest.java | 3 --- .../actor/testkit/typed/javadsl/ActorTestKitJunit5Test.java | 3 --- 2 files changed, 6 deletions(-) diff --git a/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/LogCapturingExtensionExampleTest.java b/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/LogCapturingExtensionExampleTest.java index a799a76d104..02a1351b5fb 100644 --- a/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/LogCapturingExtensionExampleTest.java +++ b/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/LogCapturingExtensionExampleTest.java @@ -7,9 +7,6 @@ * This file is part of the Apache Pekko project, derived from Akka. */ -/* - * Copyright (C) 2009-2022 Lightbend Inc. - */ package jdocs.org.apache.pekko.actor.testkit.typed.javadsl; diff --git a/actor-testkit-typed/src/test/java/org/apache/pekko/actor/testkit/typed/javadsl/ActorTestKitJunit5Test.java b/actor-testkit-typed/src/test/java/org/apache/pekko/actor/testkit/typed/javadsl/ActorTestKitJunit5Test.java index 2f77fbe33b9..d62ca45efbe 100644 --- a/actor-testkit-typed/src/test/java/org/apache/pekko/actor/testkit/typed/javadsl/ActorTestKitJunit5Test.java +++ b/actor-testkit-typed/src/test/java/org/apache/pekko/actor/testkit/typed/javadsl/ActorTestKitJunit5Test.java @@ -7,9 +7,6 @@ * This file is part of the Apache Pekko project, derived from Akka. */ -/* - * Copyright (C) 2018-2022 Lightbend Inc. - */ package org.apache.pekko.actor.testkit.typed.javadsl; From 3a96f7111b79dea97003e88ce546bd2201424810 Mon Sep 17 00:00:00 2001 From: thomas Date: Wed, 21 Jun 2023 22:16:00 +0200 Subject: [PATCH 07/23] added class copy notice --- .../testkit/typed/javadsl/Junit5IntegrationExampleTest.java | 2 ++ .../typed/javadsl/LogCapturingExtensionExampleTest.java | 3 +++ 2 files changed, 5 insertions(+) diff --git a/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/Junit5IntegrationExampleTest.java b/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/Junit5IntegrationExampleTest.java index a67b75ff431..2c4ccef9dd8 100644 --- a/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/Junit5IntegrationExampleTest.java +++ b/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/Junit5IntegrationExampleTest.java @@ -7,6 +7,8 @@ * This file is part of the Apache Pekko project, derived from Akka. */ +// test code copied from JunitIntegrationTest.java + package jdocs.org.apache.pekko.actor.testkit.typed.javadsl; import org.apache.pekko.actor.Address; diff --git a/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/LogCapturingExtensionExampleTest.java b/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/LogCapturingExtensionExampleTest.java index 02a1351b5fb..baa5745f9a8 100644 --- a/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/LogCapturingExtensionExampleTest.java +++ b/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/LogCapturingExtensionExampleTest.java @@ -11,6 +11,7 @@ package jdocs.org.apache.pekko.actor.testkit.typed.javadsl; // #log-capturing-junit5 + import org.apache.pekko.actor.testkit.typed.javadsl.*; import org.apache.pekko.actor.testkit.typed.javadsl.Junit5TestKitBuilder; import org.apache.pekko.actor.typed.ActorRef; @@ -20,6 +21,8 @@ import static jdocs.org.apache.pekko.actor.testkit.typed.javadsl.AsyncTestingExampleTest.Echo; +// test code copied from LogCapturingExampleTest.java + @DisplayName("Junit5 log capturing") @ExtendWith(TestKitJunit5Extension.class) @ExtendWith(LogCapturingExtension.class) From 367ec78652aa63b6e8d576d45739b9871218a42d Mon Sep 17 00:00:00 2001 From: thomas Date: Thu, 22 Jun 2023 15:59:20 +0200 Subject: [PATCH 08/23] deleted unnecessary import --- .../actor/testkit/typed/javadsl/TestKitJunit5Extension.scala | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala index 5941c0d2b08..585b4c90a96 100644 --- a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala +++ b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala @@ -9,8 +9,7 @@ package org.apache.pekko.actor.testkit.typed.javadsl -import org.apache.pekko -import org.junit.jupiter.api.extension.{ AfterAllCallback, BeforeTestExecutionCallback, ExtensionContext } +import org.junit.jupiter.api.extension.{AfterAllCallback, BeforeTestExecutionCallback, ExtensionContext} import org.junit.platform.commons.support.AnnotationSupport import scala.jdk.CollectionConverters._ From 9f0a81aecab5d66ad76e278d9e8b8398c72e9e3e Mon Sep 17 00:00:00 2001 From: thomas Date: Thu, 22 Jun 2023 16:03:39 +0200 Subject: [PATCH 09/23] scalafmt reformat --- .../actor/testkit/typed/javadsl/TestKitJunit5Extension.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala index 585b4c90a96..7ea1c7e40e2 100644 --- a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala +++ b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala @@ -9,7 +9,7 @@ package org.apache.pekko.actor.testkit.typed.javadsl -import org.junit.jupiter.api.extension.{AfterAllCallback, BeforeTestExecutionCallback, ExtensionContext} +import org.junit.jupiter.api.extension.{ AfterAllCallback, BeforeTestExecutionCallback, ExtensionContext } import org.junit.platform.commons.support.AnnotationSupport import scala.jdk.CollectionConverters._ From b8c83b6d6705636b1395cf8fd8cdebb747e7d32c Mon Sep 17 00:00:00 2001 From: thomas Date: Thu, 22 Jun 2023 20:07:12 +0200 Subject: [PATCH 10/23] scalafmt reformat --- .../pekko/actor/testkit/typed/javadsl/GreeterMain.scala | 9 ++++----- .../typed/scaladsl/Junit5TestKitBuilderSpec.scala | 7 +------ 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/GreeterMain.scala b/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/GreeterMain.scala index dfccafffa8d..bde702a86a3 100644 --- a/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/GreeterMain.scala +++ b/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/GreeterMain.scala @@ -9,19 +9,18 @@ package jdocs.org.apache.pekko.actor.testkit.typed.javadsl -import org.apache.pekko.actor.typed.{ActorRef, Behavior} +import org.apache.pekko.actor.typed.{ ActorRef, Behavior } import org.apache.pekko.actor.typed.scaladsl.Behaviors - object Greeter { final case class Greet(whom: String, replyTo: ActorRef[Greeted]) final case class Greeted(whom: String, from: ActorRef[Greet]) def apply(): Behavior[Greet] = Behaviors.receive { (context, message) => context.log.info("Hello {}!", message.whom) - //#greeter-send-messages + // #greeter-send-messages message.replyTo ! Greeted(message.whom, context.self) - //#greeter-send-messages + // #greeter-send-messages Behaviors.same } } @@ -59,4 +58,4 @@ object GreeterMain { Behaviors.same } } -} \ No newline at end of file +} diff --git a/actor-testkit-typed/src/test/scala/org/apache/pekko/actor/testkit/typed/scaladsl/Junit5TestKitBuilderSpec.scala b/actor-testkit-typed/src/test/scala/org/apache/pekko/actor/testkit/typed/scaladsl/Junit5TestKitBuilderSpec.scala index f18f24681ec..f6b8d9a493e 100644 --- a/actor-testkit-typed/src/test/scala/org/apache/pekko/actor/testkit/typed/scaladsl/Junit5TestKitBuilderSpec.scala +++ b/actor-testkit-typed/src/test/scala/org/apache/pekko/actor/testkit/typed/scaladsl/Junit5TestKitBuilderSpec.scala @@ -15,10 +15,7 @@ import org.apache.pekko.actor.testkit.typed.javadsl.Junit5TestKitBuilder import org.apache.pekko.actor.typed.ActorSystem import org.scalatest.wordspec.AnyWordSpec - - -class Junit5TestKitBuilderSpec extends AnyWordSpec{ - +class Junit5TestKitBuilderSpec extends AnyWordSpec { "the Junit5TestKitBuilder" should { "create a Testkit with name hello" in { @@ -39,7 +36,6 @@ class Junit5TestKitBuilderSpec extends AnyWordSpec{ } } - "the Junit5TestKitBuilder" should { "create a Testkit with a custom config" in { @@ -79,5 +75,4 @@ class Junit5TestKitBuilderSpec extends AnyWordSpec{ } } - } From 449b0410ade229f91475448d498039ad20bae02e Mon Sep 17 00:00:00 2001 From: thomas Date: Sat, 24 Jun 2023 20:40:07 +0200 Subject: [PATCH 11/23] scalafmt reformat --- .../actor/testkit/typed/javadsl/TestKitJunit5Extension.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala index 7ea1c7e40e2..029780f4d6c 100644 --- a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala +++ b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala @@ -12,7 +12,7 @@ package org.apache.pekko.actor.testkit.typed.javadsl import org.junit.jupiter.api.extension.{ AfterAllCallback, BeforeTestExecutionCallback, ExtensionContext } import org.junit.platform.commons.support.AnnotationSupport -import scala.jdk.CollectionConverters._ +import scala.jdk.CollectionConverters.CollectionHasAsScala final class TestKitJunit5Extension() extends AfterAllCallback with BeforeTestExecutionCallback { From fb1a88abe1f07e52e69d55b6941b3c66d18bffea Mon Sep 17 00:00:00 2001 From: thomas Date: Mon, 26 Jun 2023 15:22:58 +0200 Subject: [PATCH 12/23] scalafmt reformat --- project/Dependencies.scala | 2 -- 1 file changed, 2 deletions(-) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index bd174a7d9f1..80ab0fde774 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -90,7 +90,6 @@ object Dependencies { val junit = "junit" % "junit" % junitVersion val junit5 = "org.junit.jupiter" % "junit-jupiter-engine" % junit5Version - // For Java 8 Conversions val java8Compat = Def.setting { "org.scala-lang.modules" %% "scala-java8-compat" % java8CompatVersion.value @@ -146,7 +145,6 @@ object Dependencies { val junit = "junit" % "junit" % junitVersion % "test" val junit5 = "org.junit.jupiter" % "junit-jupiter-engine" % junit5Version % Test - val logback = Compile.logback % Test val scalatest = Def.setting { "org.scalatest" %% "scalatest" % scalaTestVersion % Test } // ApacheV2 From f07bd6971241205e2b8ea3a8327eff0e985d4c58 Mon Sep 17 00:00:00 2001 From: thomas Date: Mon, 26 Jun 2023 16:08:49 +0200 Subject: [PATCH 13/23] recreate headers --- .../testkit/typed/javadsl/LogCapturingExtensionExampleTest.java | 1 - .../actor/testkit/typed/javadsl/ActorTestKitJunit5Test.java | 1 - 2 files changed, 2 deletions(-) diff --git a/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/LogCapturingExtensionExampleTest.java b/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/LogCapturingExtensionExampleTest.java index baa5745f9a8..e6b8d7cfea2 100644 --- a/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/LogCapturingExtensionExampleTest.java +++ b/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/LogCapturingExtensionExampleTest.java @@ -7,7 +7,6 @@ * This file is part of the Apache Pekko project, derived from Akka. */ - package jdocs.org.apache.pekko.actor.testkit.typed.javadsl; // #log-capturing-junit5 diff --git a/actor-testkit-typed/src/test/java/org/apache/pekko/actor/testkit/typed/javadsl/ActorTestKitJunit5Test.java b/actor-testkit-typed/src/test/java/org/apache/pekko/actor/testkit/typed/javadsl/ActorTestKitJunit5Test.java index d62ca45efbe..875164881ef 100644 --- a/actor-testkit-typed/src/test/java/org/apache/pekko/actor/testkit/typed/javadsl/ActorTestKitJunit5Test.java +++ b/actor-testkit-typed/src/test/java/org/apache/pekko/actor/testkit/typed/javadsl/ActorTestKitJunit5Test.java @@ -7,7 +7,6 @@ * This file is part of the Apache Pekko project, derived from Akka. */ - package org.apache.pekko.actor.testkit.typed.javadsl; import org.apache.pekko.Done; From a07a0e1f199baf5d2296dac8df5ab5206bec6b7c Mon Sep 17 00:00:00 2001 From: thomas Date: Mon, 26 Jun 2023 16:12:55 +0200 Subject: [PATCH 14/23] replaced headers --- .../pekko/actor/testkit/typed/javadsl/Junit5TestKit.java | 3 ++- .../actor/testkit/typed/javadsl/Junit5TestKitBuilder.scala | 2 +- .../actor/testkit/typed/javadsl/LogCapturingExtension.scala | 2 +- .../actor/testkit/typed/javadsl/TestKitJunit5Extension.scala | 2 +- .../apache/pekko/actor/testkit/typed/javadsl/GreeterMain.scala | 2 +- .../testkit/typed/javadsl/Junit5IntegrationExampleTest.java | 2 +- .../typed/javadsl/LogCapturingExtensionExampleTest.java | 2 +- .../actor/testkit/typed/javadsl/ActorTestKitJunit5Test.java | 2 +- .../testkit/typed/scaladsl/Junit5TestKitBuilderSpec.scala | 2 +- 9 files changed, 10 insertions(+), 9 deletions(-) diff --git a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/Junit5TestKit.java b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/Junit5TestKit.java index e62beeda34f..d6f3f70708c 100644 --- a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/Junit5TestKit.java +++ b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/Junit5TestKit.java @@ -4,11 +4,12 @@ * * https://www.apache.org/licenses/LICENSE-2.0 * - * This file is part of the Apache Pekko project, derived from Akka. + * This file is part of the Apache Pekko project, which was derived from Akka. */ package org.apache.pekko.actor.testkit.typed.javadsl; + import java.lang.annotation.*; @Documented diff --git a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/Junit5TestKitBuilder.scala b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/Junit5TestKitBuilder.scala index b9711e3bf13..b9a3eb47f55 100644 --- a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/Junit5TestKitBuilder.scala +++ b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/Junit5TestKitBuilder.scala @@ -4,7 +4,7 @@ * * https://www.apache.org/licenses/LICENSE-2.0 * - * This file is part of the Apache Pekko project, derived from Akka. + * This file is part of the Apache Pekko project, which was derived from Akka. */ package org.apache.pekko.actor.testkit.typed.javadsl diff --git a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/LogCapturingExtension.scala b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/LogCapturingExtension.scala index f8ae1023710..e4fd37c41eb 100644 --- a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/LogCapturingExtension.scala +++ b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/LogCapturingExtension.scala @@ -4,7 +4,7 @@ * * https://www.apache.org/licenses/LICENSE-2.0 * - * This file is part of the Apache Pekko project, derived from Akka. + * This file is part of the Apache Pekko project, which was derived from Akka. */ package org.apache.pekko.actor.testkit.typed.javadsl diff --git a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala index 029780f4d6c..d45d2c45719 100644 --- a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala +++ b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala @@ -4,7 +4,7 @@ * * https://www.apache.org/licenses/LICENSE-2.0 * - * This file is part of the Apache Pekko project, derived from Akka. + * This file is part of the Apache Pekko project, which was derived from Akka. */ package org.apache.pekko.actor.testkit.typed.javadsl diff --git a/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/GreeterMain.scala b/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/GreeterMain.scala index bde702a86a3..75b17920b8e 100644 --- a/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/GreeterMain.scala +++ b/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/GreeterMain.scala @@ -4,7 +4,7 @@ * * https://www.apache.org/licenses/LICENSE-2.0 * - * This file is part of the Apache Pekko project, derived from Akka. + * This file is part of the Apache Pekko project, which was derived from Akka. */ package jdocs.org.apache.pekko.actor.testkit.typed.javadsl diff --git a/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/Junit5IntegrationExampleTest.java b/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/Junit5IntegrationExampleTest.java index 2c4ccef9dd8..6b9431fd9f1 100644 --- a/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/Junit5IntegrationExampleTest.java +++ b/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/Junit5IntegrationExampleTest.java @@ -4,7 +4,7 @@ * * https://www.apache.org/licenses/LICENSE-2.0 * - * This file is part of the Apache Pekko project, derived from Akka. + * This file is part of the Apache Pekko project, which was derived from Akka. */ // test code copied from JunitIntegrationTest.java diff --git a/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/LogCapturingExtensionExampleTest.java b/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/LogCapturingExtensionExampleTest.java index e6b8d7cfea2..96171d57fd2 100644 --- a/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/LogCapturingExtensionExampleTest.java +++ b/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/LogCapturingExtensionExampleTest.java @@ -4,7 +4,7 @@ * * https://www.apache.org/licenses/LICENSE-2.0 * - * This file is part of the Apache Pekko project, derived from Akka. + * This file is part of the Apache Pekko project, which was derived from Akka. */ package jdocs.org.apache.pekko.actor.testkit.typed.javadsl; diff --git a/actor-testkit-typed/src/test/java/org/apache/pekko/actor/testkit/typed/javadsl/ActorTestKitJunit5Test.java b/actor-testkit-typed/src/test/java/org/apache/pekko/actor/testkit/typed/javadsl/ActorTestKitJunit5Test.java index 875164881ef..635fa3da1c4 100644 --- a/actor-testkit-typed/src/test/java/org/apache/pekko/actor/testkit/typed/javadsl/ActorTestKitJunit5Test.java +++ b/actor-testkit-typed/src/test/java/org/apache/pekko/actor/testkit/typed/javadsl/ActorTestKitJunit5Test.java @@ -4,7 +4,7 @@ * * https://www.apache.org/licenses/LICENSE-2.0 * - * This file is part of the Apache Pekko project, derived from Akka. + * This file is part of the Apache Pekko project, which was derived from Akka. */ package org.apache.pekko.actor.testkit.typed.javadsl; diff --git a/actor-testkit-typed/src/test/scala/org/apache/pekko/actor/testkit/typed/scaladsl/Junit5TestKitBuilderSpec.scala b/actor-testkit-typed/src/test/scala/org/apache/pekko/actor/testkit/typed/scaladsl/Junit5TestKitBuilderSpec.scala index f6b8d9a493e..685e615d094 100644 --- a/actor-testkit-typed/src/test/scala/org/apache/pekko/actor/testkit/typed/scaladsl/Junit5TestKitBuilderSpec.scala +++ b/actor-testkit-typed/src/test/scala/org/apache/pekko/actor/testkit/typed/scaladsl/Junit5TestKitBuilderSpec.scala @@ -4,7 +4,7 @@ * * https://www.apache.org/licenses/LICENSE-2.0 * - * This file is part of the Apache Pekko project, derived from Akka. + * This file is part of the Apache Pekko project, which was derived from Akka. */ package org.apache.pekko.actor.testkit.typed.scaladsl From ef1ec6388a6109b9faf0868ed4ccc1e4b5827abe Mon Sep 17 00:00:00 2001 From: thomas Date: Mon, 26 Jun 2023 20:29:59 +0200 Subject: [PATCH 15/23] replaced 2.13 list handling with ccoompat to support 2.12/2.13 --- .../testkit/typed/javadsl/TestKitJunit5Extension.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala index d45d2c45719..0668c8b93e7 100644 --- a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala +++ b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala @@ -11,8 +11,8 @@ package org.apache.pekko.actor.testkit.typed.javadsl import org.junit.jupiter.api.extension.{ AfterAllCallback, BeforeTestExecutionCallback, ExtensionContext } import org.junit.platform.commons.support.AnnotationSupport - -import scala.jdk.CollectionConverters.CollectionHasAsScala +import org.apache.pekko +import pekko.util.ccompat.JavaConverters.CollectionHasAsScala final class TestKitJunit5Extension() extends AfterAllCallback with BeforeTestExecutionCallback { @@ -23,7 +23,7 @@ final class TestKitJunit5Extension() extends AfterAllCallback with BeforeTestExe */ override def beforeTestExecution(context: ExtensionContext): Unit = { - context.getTestInstance.ifPresent(instance => { + context.getTestInstance.ifPresent((instance: AnyRef) => { val fielValue = AnnotationSupport.findAnnotatedFieldValues(instance, classOf[Junit5TestKit]).asScala.toList.head testKit = Some(fielValue.asInstanceOf[ActorTestKit]) }) From cccc892e6cc3a7e2418f1db002601e930be5cf5c Mon Sep 17 00:00:00 2001 From: thomas Date: Mon, 26 Jun 2023 21:12:02 +0200 Subject: [PATCH 16/23] added error handling if annotated field is missing --- .../typed/javadsl/TestKitJunit5Extension.scala | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala index 0668c8b93e7..8bd4e0cc5e5 100644 --- a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala +++ b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala @@ -23,9 +23,14 @@ final class TestKitJunit5Extension() extends AfterAllCallback with BeforeTestExe */ override def beforeTestExecution(context: ExtensionContext): Unit = { - context.getTestInstance.ifPresent((instance: AnyRef) => { - val fielValue = AnnotationSupport.findAnnotatedFieldValues(instance, classOf[Junit5TestKit]).asScala.toList.head - testKit = Some(fielValue.asInstanceOf[ActorTestKit]) + context.getTestInstance.ifPresent((instance: AnyRef) => { + val annotations = AnnotationSupport.findAnnotatedFieldValues(instance, classOf[Junit5TestKit]) + if (annotations.isEmpty) { + throw new IllegalArgumentException("Could not find field annotated with @Junit5TestKit") + } else { + val fieldValue = annotations.asScala.toList.head + testKit = Some(fieldValue.asInstanceOf[ActorTestKit]) + } }) } From 3046170c985ec1d8fe79abe0bc08ef5b932f2a31 Mon Sep 17 00:00:00 2001 From: thomas Date: Wed, 28 Jun 2023 07:08:06 +0200 Subject: [PATCH 17/23] moved annotation to java package --- .../actor/testkit/typed/annotations}/Junit5TestKit.java | 8 ++------ .../testkit/typed/javadsl/TestKitJunit5Extension.scala | 5 +++-- .../typed/javadsl/Junit5IntegrationExampleTest.java | 4 +++- .../typed/javadsl/LogCapturingExtensionExampleTest.java | 4 +++- .../testkit/typed/javadsl/ActorTestKitJunit5Test.java | 4 +++- 5 files changed, 14 insertions(+), 11 deletions(-) rename actor-testkit-typed/src/main/{scala/org/apache/pekko/actor/testkit/typed/javadsl => java/org/apache/pekko/actor/testkit/typed/annotations}/Junit5TestKit.java (80%) diff --git a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/Junit5TestKit.java b/actor-testkit-typed/src/main/java/org/apache/pekko/actor/testkit/typed/annotations/Junit5TestKit.java similarity index 80% rename from actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/Junit5TestKit.java rename to actor-testkit-typed/src/main/java/org/apache/pekko/actor/testkit/typed/annotations/Junit5TestKit.java index d6f3f70708c..9249c51774e 100644 --- a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/Junit5TestKit.java +++ b/actor-testkit-typed/src/main/java/org/apache/pekko/actor/testkit/typed/annotations/Junit5TestKit.java @@ -7,15 +7,11 @@ * This file is part of the Apache Pekko project, which was derived from Akka. */ -package org.apache.pekko.actor.testkit.typed.javadsl; - +package org.apache.pekko.actor.testkit.typed.annotations; import java.lang.annotation.*; @Documented @Target(ElementType.FIELD) @Retention(RetentionPolicy.RUNTIME) -public @interface Junit5TestKit { -} - - +public @interface Junit5TestKit {} diff --git a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala index 8bd4e0cc5e5..8708178b123 100644 --- a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala +++ b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala @@ -9,9 +9,10 @@ package org.apache.pekko.actor.testkit.typed.javadsl -import org.junit.jupiter.api.extension.{ AfterAllCallback, BeforeTestExecutionCallback, ExtensionContext } +import org.junit.jupiter.api.extension.{AfterAllCallback, BeforeTestExecutionCallback, ExtensionContext} import org.junit.platform.commons.support.AnnotationSupport import org.apache.pekko +import org.apache.pekko.actor.testkit.typed.annotations.Junit5TestKit import pekko.util.ccompat.JavaConverters.CollectionHasAsScala final class TestKitJunit5Extension() extends AfterAllCallback with BeforeTestExecutionCallback { @@ -19,7 +20,7 @@ final class TestKitJunit5Extension() extends AfterAllCallback with BeforeTestExe var testKit: Option[ActorTestKit] = None /** - * Get a reference to the field annotated with @Junit5Testkit [[pekko.actor.testkit.typed.javadsl.Junit5TestKit]] + * Get a reference to the field annotated with @Junit5Testkit [[Junit5TestKit]] */ override def beforeTestExecution(context: ExtensionContext): Unit = { diff --git a/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/Junit5IntegrationExampleTest.java b/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/Junit5IntegrationExampleTest.java index 6b9431fd9f1..2a0dc9c65b7 100644 --- a/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/Junit5IntegrationExampleTest.java +++ b/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/Junit5IntegrationExampleTest.java @@ -11,6 +11,7 @@ package jdocs.org.apache.pekko.actor.testkit.typed.javadsl; +import org.apache.pekko.actor.testkit.typed.annotations.Junit5TestKit; import org.apache.pekko.actor.Address; import org.apache.pekko.actor.testkit.typed.javadsl.*; import org.apache.pekko.actor.testkit.typed.javadsl.Junit5TestKitBuilder; @@ -27,7 +28,8 @@ @ExtendWith(TestKitJunit5Extension.class) class Junit5IntegrationExampleTest { - @Junit5TestKit public ActorTestKit testKit = new Junit5TestKitBuilder().build(); + @Junit5TestKit + public ActorTestKit testKit = new Junit5TestKitBuilder().build(); @Test void junit5Test() { diff --git a/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/LogCapturingExtensionExampleTest.java b/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/LogCapturingExtensionExampleTest.java index 96171d57fd2..8d2c149c2f9 100644 --- a/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/LogCapturingExtensionExampleTest.java +++ b/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/LogCapturingExtensionExampleTest.java @@ -11,6 +11,7 @@ // #log-capturing-junit5 +import org.apache.pekko.actor.testkit.typed.annotations.Junit5TestKit; import org.apache.pekko.actor.testkit.typed.javadsl.*; import org.apache.pekko.actor.testkit.typed.javadsl.Junit5TestKitBuilder; import org.apache.pekko.actor.typed.ActorRef; @@ -27,7 +28,8 @@ @ExtendWith(LogCapturingExtension.class) class LogCapturingExtensionExampleTest { - @Junit5TestKit public ActorTestKit testKit = new Junit5TestKitBuilder().build(); + @Junit5TestKit + public ActorTestKit testKit = new Junit5TestKitBuilder().build(); @Test void testSomething() { diff --git a/actor-testkit-typed/src/test/java/org/apache/pekko/actor/testkit/typed/javadsl/ActorTestKitJunit5Test.java b/actor-testkit-typed/src/test/java/org/apache/pekko/actor/testkit/typed/javadsl/ActorTestKitJunit5Test.java index 635fa3da1c4..ded2bf97bef 100644 --- a/actor-testkit-typed/src/test/java/org/apache/pekko/actor/testkit/typed/javadsl/ActorTestKitJunit5Test.java +++ b/actor-testkit-typed/src/test/java/org/apache/pekko/actor/testkit/typed/javadsl/ActorTestKitJunit5Test.java @@ -9,6 +9,7 @@ package org.apache.pekko.actor.testkit.typed.javadsl; +import org.apache.pekko.actor.testkit.typed.annotations.Junit5TestKit; import org.apache.pekko.Done; import org.apache.pekko.actor.typed.javadsl.Behaviors; @@ -30,7 +31,8 @@ @ExtendWith(LogCapturingExtension.class) class ActorTestKitJunit5Test extends JUnitSuite { - @Junit5TestKit public ActorTestKit testKit = new Junit5TestKitBuilder().build(); + @Junit5TestKit + public ActorTestKit testKit = new Junit5TestKitBuilder().build(); @Test void systemNameShouldComeFromTestClassViaJunitResource() { From d9b314282d93919c17e669675ddfff639370fdc0 Mon Sep 17 00:00:00 2001 From: thomas Date: Sun, 2 Jul 2023 21:10:54 +0200 Subject: [PATCH 18/23] simplified code --- .../typed/javadsl/TestKitJunit5Extension.scala | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala index 8708178b123..9b9154f6bc8 100644 --- a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala +++ b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala @@ -9,11 +9,9 @@ package org.apache.pekko.actor.testkit.typed.javadsl -import org.junit.jupiter.api.extension.{AfterAllCallback, BeforeTestExecutionCallback, ExtensionContext} -import org.junit.platform.commons.support.AnnotationSupport -import org.apache.pekko import org.apache.pekko.actor.testkit.typed.annotations.Junit5TestKit -import pekko.util.ccompat.JavaConverters.CollectionHasAsScala +import org.junit.jupiter.api.extension.{ AfterAllCallback, BeforeTestExecutionCallback, ExtensionContext } +import org.junit.platform.commons.support.AnnotationSupport final class TestKitJunit5Extension() extends AfterAllCallback with BeforeTestExecutionCallback { @@ -26,12 +24,9 @@ final class TestKitJunit5Extension() extends AfterAllCallback with BeforeTestExe context.getTestInstance.ifPresent((instance: AnyRef) => { val annotations = AnnotationSupport.findAnnotatedFieldValues(instance, classOf[Junit5TestKit]) - if (annotations.isEmpty) { - throw new IllegalArgumentException("Could not find field annotated with @Junit5TestKit") - } else { - val fieldValue = annotations.asScala.toList.head - testKit = Some(fieldValue.asInstanceOf[ActorTestKit]) - } + val fieldValue = annotations.stream().findFirst().orElseThrow(() => + throw new IllegalArgumentException("Could not find field annotated with @Junit5TestKit")) + testKit = Some(fieldValue.asInstanceOf[ActorTestKit]) }) } From d9a2ca0e2e68b8f71d2c6a23ae26d8b436090b46 Mon Sep 17 00:00:00 2001 From: thomas Date: Mon, 3 Jul 2023 19:47:36 +0200 Subject: [PATCH 19/23] updated headers --- .../pekko/actor/testkit/typed/annotations/Junit5TestKit.java | 3 +-- .../actor/testkit/typed/javadsl/Junit5TestKitBuilder.scala | 3 +-- .../actor/testkit/typed/javadsl/TestKitJunit5Extension.scala | 3 +-- .../testkit/typed/javadsl/Junit5IntegrationExampleTest.java | 2 -- .../testkit/typed/scaladsl/Junit5TestKitBuilderSpec.scala | 3 +-- 5 files changed, 4 insertions(+), 10 deletions(-) diff --git a/actor-testkit-typed/src/main/java/org/apache/pekko/actor/testkit/typed/annotations/Junit5TestKit.java b/actor-testkit-typed/src/main/java/org/apache/pekko/actor/testkit/typed/annotations/Junit5TestKit.java index 9249c51774e..71a3cf6bc6a 100644 --- a/actor-testkit-typed/src/main/java/org/apache/pekko/actor/testkit/typed/annotations/Junit5TestKit.java +++ b/actor-testkit-typed/src/main/java/org/apache/pekko/actor/testkit/typed/annotations/Junit5TestKit.java @@ -1,10 +1,9 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * license agreements; and to You under the Apache License, version 2.0: + * contributor license agreements; and to You under the Apache License, Version 2.0. * * https://www.apache.org/licenses/LICENSE-2.0 * - * This file is part of the Apache Pekko project, which was derived from Akka. */ package org.apache.pekko.actor.testkit.typed.annotations; diff --git a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/Junit5TestKitBuilder.scala b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/Junit5TestKitBuilder.scala index b9a3eb47f55..b3a99a1db2a 100644 --- a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/Junit5TestKitBuilder.scala +++ b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/Junit5TestKitBuilder.scala @@ -1,10 +1,9 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * license agreements; and to You under the Apache License, version 2.0: + * contributor license agreements; and to You under the Apache License, Version 2.0. * * https://www.apache.org/licenses/LICENSE-2.0 * - * This file is part of the Apache Pekko project, which was derived from Akka. */ package org.apache.pekko.actor.testkit.typed.javadsl diff --git a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala index 9b9154f6bc8..38233492570 100644 --- a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala +++ b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala @@ -1,10 +1,9 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * license agreements; and to You under the Apache License, version 2.0: + * contributor license agreements; and to You under the Apache License, Version 2.0. * * https://www.apache.org/licenses/LICENSE-2.0 * - * This file is part of the Apache Pekko project, which was derived from Akka. */ package org.apache.pekko.actor.testkit.typed.javadsl diff --git a/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/Junit5IntegrationExampleTest.java b/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/Junit5IntegrationExampleTest.java index 2a0dc9c65b7..eb7289637ae 100644 --- a/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/Junit5IntegrationExampleTest.java +++ b/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/Junit5IntegrationExampleTest.java @@ -7,8 +7,6 @@ * This file is part of the Apache Pekko project, which was derived from Akka. */ -// test code copied from JunitIntegrationTest.java - package jdocs.org.apache.pekko.actor.testkit.typed.javadsl; import org.apache.pekko.actor.testkit.typed.annotations.Junit5TestKit; diff --git a/actor-testkit-typed/src/test/scala/org/apache/pekko/actor/testkit/typed/scaladsl/Junit5TestKitBuilderSpec.scala b/actor-testkit-typed/src/test/scala/org/apache/pekko/actor/testkit/typed/scaladsl/Junit5TestKitBuilderSpec.scala index 685e615d094..ccca43fa1e5 100644 --- a/actor-testkit-typed/src/test/scala/org/apache/pekko/actor/testkit/typed/scaladsl/Junit5TestKitBuilderSpec.scala +++ b/actor-testkit-typed/src/test/scala/org/apache/pekko/actor/testkit/typed/scaladsl/Junit5TestKitBuilderSpec.scala @@ -1,10 +1,9 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * license agreements; and to You under the Apache License, version 2.0: + * contributor license agreements; and to You under the Apache License, Version 2.0. * * https://www.apache.org/licenses/LICENSE-2.0 * - * This file is part of the Apache Pekko project, which was derived from Akka. */ package org.apache.pekko.actor.testkit.typed.scaladsl From 85c0df12a025920658b638d8a5f02993f6620c31 Mon Sep 17 00:00:00 2001 From: thomas Date: Mon, 3 Jul 2023 20:24:29 +0200 Subject: [PATCH 20/23] updated headers to full ASF header lic --- .../testkit/typed/annotations/Junit5TestKit.java | 13 +++++++++++-- .../typed/javadsl/Junit5TestKitBuilder.scala | 13 +++++++++++-- .../typed/javadsl/TestKitJunit5Extension.scala | 13 +++++++++++-- .../typed/scaladsl/Junit5TestKitBuilderSpec.scala | 13 +++++++++++-- 4 files changed, 44 insertions(+), 8 deletions(-) diff --git a/actor-testkit-typed/src/main/java/org/apache/pekko/actor/testkit/typed/annotations/Junit5TestKit.java b/actor-testkit-typed/src/main/java/org/apache/pekko/actor/testkit/typed/annotations/Junit5TestKit.java index 71a3cf6bc6a..adbbf80d378 100644 --- a/actor-testkit-typed/src/main/java/org/apache/pekko/actor/testkit/typed/annotations/Junit5TestKit.java +++ b/actor-testkit-typed/src/main/java/org/apache/pekko/actor/testkit/typed/annotations/Junit5TestKit.java @@ -1,9 +1,18 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements; and to You under the Apache License, Version 2.0. + * 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 * - * https://www.apache.org/licenses/LICENSE-2.0 + * 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.pekko.actor.testkit.typed.annotations; diff --git a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/Junit5TestKitBuilder.scala b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/Junit5TestKitBuilder.scala index b3a99a1db2a..0056b32706f 100644 --- a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/Junit5TestKitBuilder.scala +++ b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/Junit5TestKitBuilder.scala @@ -1,9 +1,18 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements; and to You under the Apache License, Version 2.0. + * 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 * - * https://www.apache.org/licenses/LICENSE-2.0 + * 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.pekko.actor.testkit.typed.javadsl diff --git a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala index 38233492570..a0731353507 100644 --- a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala +++ b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala @@ -1,9 +1,18 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements; and to You under the Apache License, Version 2.0. + * 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 * - * https://www.apache.org/licenses/LICENSE-2.0 + * 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.pekko.actor.testkit.typed.javadsl diff --git a/actor-testkit-typed/src/test/scala/org/apache/pekko/actor/testkit/typed/scaladsl/Junit5TestKitBuilderSpec.scala b/actor-testkit-typed/src/test/scala/org/apache/pekko/actor/testkit/typed/scaladsl/Junit5TestKitBuilderSpec.scala index ccca43fa1e5..37acd0fef27 100644 --- a/actor-testkit-typed/src/test/scala/org/apache/pekko/actor/testkit/typed/scaladsl/Junit5TestKitBuilderSpec.scala +++ b/actor-testkit-typed/src/test/scala/org/apache/pekko/actor/testkit/typed/scaladsl/Junit5TestKitBuilderSpec.scala @@ -1,9 +1,18 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements; and to You under the Apache License, Version 2.0. + * 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 * - * https://www.apache.org/licenses/LICENSE-2.0 + * 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.pekko.actor.testkit.typed.scaladsl From 2ae605df8ee8ad3fa379d582690a590a75f09480 Mon Sep 17 00:00:00 2001 From: thomas Date: Sat, 14 Oct 2023 20:19:59 +0200 Subject: [PATCH 21/23] updated deps, changed case class to class, aligned imports --- .../typed/javadsl/Junit5TestKitBuilder.scala | 9 +++++---- .../typed/javadsl/TestKitJunit5Extension.scala | 3 ++- .../testkit/typed/javadsl/GreeterMain.scala | 5 +++-- .../typed/javadsl/ActorTestKitJunit5Test.java | 2 +- .../scaladsl/Junit5TestKitBuilderSpec.scala | 18 +++++++++--------- .../actor/typed/internal/jfr/Events.scala | 5 +++-- project/Dependencies.scala | 2 +- 7 files changed, 24 insertions(+), 20 deletions(-) diff --git a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/Junit5TestKitBuilder.scala b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/Junit5TestKitBuilder.scala index 0056b32706f..cdf171dd500 100644 --- a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/Junit5TestKitBuilder.scala +++ b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/Junit5TestKitBuilder.scala @@ -17,12 +17,13 @@ package org.apache.pekko.actor.testkit.typed.javadsl +import org.apache.pekko import com.typesafe.config.Config -import org.apache.pekko.actor.testkit.typed.internal.TestKitUtils -import org.apache.pekko.actor.testkit.typed.scaladsl.ActorTestKit.ApplicationTestConfig -import org.apache.pekko.actor.typed.ActorSystem +import pekko.actor.testkit.typed.internal.TestKitUtils +import pekko.actor.testkit.typed.scaladsl.ActorTestKit.ApplicationTestConfig +import pekko.actor.typed.ActorSystem -case class Junit5TestKitBuilder() { +final class Junit5TestKitBuilder() { var system: Option[ActorSystem[_]] = None diff --git a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala index a0731353507..fe63017c299 100644 --- a/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala +++ b/actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/javadsl/TestKitJunit5Extension.scala @@ -17,7 +17,8 @@ package org.apache.pekko.actor.testkit.typed.javadsl -import org.apache.pekko.actor.testkit.typed.annotations.Junit5TestKit +import org.apache.pekko +import pekko.actor.testkit.typed.annotations.Junit5TestKit import org.junit.jupiter.api.extension.{ AfterAllCallback, BeforeTestExecutionCallback, ExtensionContext } import org.junit.platform.commons.support.AnnotationSupport diff --git a/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/GreeterMain.scala b/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/GreeterMain.scala index 75b17920b8e..206f97f0eb6 100644 --- a/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/GreeterMain.scala +++ b/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/GreeterMain.scala @@ -9,8 +9,9 @@ package jdocs.org.apache.pekko.actor.testkit.typed.javadsl -import org.apache.pekko.actor.typed.{ ActorRef, Behavior } -import org.apache.pekko.actor.typed.scaladsl.Behaviors +import org.apache.pekko +import pekko.actor.typed.{ ActorRef, Behavior } +import pekko.actor.typed.scaladsl.Behaviors object Greeter { final case class Greet(whom: String, replyTo: ActorRef[Greeted]) diff --git a/actor-testkit-typed/src/test/java/org/apache/pekko/actor/testkit/typed/javadsl/ActorTestKitJunit5Test.java b/actor-testkit-typed/src/test/java/org/apache/pekko/actor/testkit/typed/javadsl/ActorTestKitJunit5Test.java index ded2bf97bef..8b0de839fd3 100644 --- a/actor-testkit-typed/src/test/java/org/apache/pekko/actor/testkit/typed/javadsl/ActorTestKitJunit5Test.java +++ b/actor-testkit-typed/src/test/java/org/apache/pekko/actor/testkit/typed/javadsl/ActorTestKitJunit5Test.java @@ -9,6 +9,7 @@ package org.apache.pekko.actor.testkit.typed.javadsl; + import org.apache.pekko.actor.testkit.typed.annotations.Junit5TestKit; import org.apache.pekko.Done; import org.apache.pekko.actor.typed.javadsl.Behaviors; @@ -33,7 +34,6 @@ class ActorTestKitJunit5Test extends JUnitSuite { @Junit5TestKit public ActorTestKit testKit = new Junit5TestKitBuilder().build(); - @Test void systemNameShouldComeFromTestClassViaJunitResource() { assertEquals("ActorTestKitJunit5Test", testKit.system().name()); diff --git a/actor-testkit-typed/src/test/scala/org/apache/pekko/actor/testkit/typed/scaladsl/Junit5TestKitBuilderSpec.scala b/actor-testkit-typed/src/test/scala/org/apache/pekko/actor/testkit/typed/scaladsl/Junit5TestKitBuilderSpec.scala index 37acd0fef27..63090dcddbc 100644 --- a/actor-testkit-typed/src/test/scala/org/apache/pekko/actor/testkit/typed/scaladsl/Junit5TestKitBuilderSpec.scala +++ b/actor-testkit-typed/src/test/scala/org/apache/pekko/actor/testkit/typed/scaladsl/Junit5TestKitBuilderSpec.scala @@ -17,19 +17,19 @@ package org.apache.pekko.actor.testkit.typed.scaladsl +import org.apache.pekko +import pekko.actor.testkit.typed.javadsl.Junit5TestKitBuilder +import pekko.actor.typed.ActorSystem import com.typesafe.config.ConfigFactory import jdocs.org.apache.pekko.actor.testkit.typed.javadsl.GreeterMain -import org.apache.pekko.actor.testkit.typed.javadsl.Junit5TestKitBuilder -import org.apache.pekko.actor.typed.ActorSystem + import org.scalatest.wordspec.AnyWordSpec class Junit5TestKitBuilderSpec extends AnyWordSpec { "the Junit5TestKitBuilder" should { "create a Testkit with name hello" in { - val actualTestKit = Junit5TestKitBuilder() - .withName("hello") - .build() + val actualTestKit = new Junit5TestKitBuilder().withName("hello").build() assertResult("hello")(actualTestKit.system.name) } @@ -37,7 +37,7 @@ class Junit5TestKitBuilderSpec extends AnyWordSpec { "the Junit5TestKitBuilder" should { "create a Testkit with the classname as name" in { - val actualTestKit = Junit5TestKitBuilder() + val actualTestKit = new Junit5TestKitBuilder() .build() assertResult("Junit5TestKitBuilderSpec")(actualTestKit.system.name) @@ -48,7 +48,7 @@ class Junit5TestKitBuilderSpec extends AnyWordSpec { "create a Testkit with a custom config" in { val conf = ConfigFactory.load("application.conf") - val actualTestKit = Junit5TestKitBuilder() + val actualTestKit = new Junit5TestKitBuilder() .withCustomConfig(conf) .build() assertResult("someValue")(actualTestKit.system.settings.config.getString("test.value")) @@ -61,7 +61,7 @@ class Junit5TestKitBuilderSpec extends AnyWordSpec { "create a Testkit with a custom config and name" in { val conf = ConfigFactory.load("application.conf") - val actualTestKit = Junit5TestKitBuilder() + val actualTestKit = new Junit5TestKitBuilder() .withCustomConfig(conf) .withName("hello") .build() @@ -76,7 +76,7 @@ class Junit5TestKitBuilderSpec extends AnyWordSpec { val system: ActorSystem[GreeterMain.SayHello] = ActorSystem(GreeterMain(), "AkkaQuickStart") - val actualTestKit = Junit5TestKitBuilder() + val actualTestKit = new Junit5TestKitBuilder() .withSystem(system) .build() assertResult("AkkaQuickStart")(actualTestKit.system.name) diff --git a/actor-typed/src/main/scala-jdk-9/org/apache/pekko/actor/typed/internal/jfr/Events.scala b/actor-typed/src/main/scala-jdk-9/org/apache/pekko/actor/typed/internal/jfr/Events.scala index 02311044278..8fd6978ea84 100644 --- a/actor-typed/src/main/scala-jdk-9/org/apache/pekko/actor/typed/internal/jfr/Events.scala +++ b/actor-typed/src/main/scala-jdk-9/org/apache/pekko/actor/typed/internal/jfr/Events.scala @@ -18,9 +18,10 @@ import jdk.jfr.Enabled import jdk.jfr.Event import jdk.jfr.Label import jdk.jfr.StackTrace - import org.apache.pekko.annotation.InternalApi +import scala.annotation.unused + // requires jdk9+ to compile // for editing these in IntelliJ, open module settings, change JDK dependency to 11 for only this module @@ -96,7 +97,7 @@ final class DeliveryProducerReceived(val producerId: String, val currentSeqNr: L @StackTrace(false) @Category(Array("Pekko", "Delivery", "ProducerController")) @Label( "Delivery ProducerController received demand request") -final class DeliveryProducerReceivedRequest(val producerId: String, val requestedSeqNr: Long, confirmedSeqNr: Long) +final class DeliveryProducerReceivedRequest(val producerId: String, val requestedSeqNr: Long, @unused confirmedSeqNr: Long) extends Event /** INTERNAL API */ diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 3748959d152..6c02f9b6cbc 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -22,7 +22,7 @@ object Dependencies { .withRank(KeyRanks.Invisible) // avoid 'unused key' warning val junitVersion = "4.13.2" - val junit5Version = "5.9.3" + val junit5Version = "5.10.0" val slf4jVersion = "1.7.36" // check agrona version when updating this From b8823799dadcf52d89026e18a2904bb917f80bbb Mon Sep 17 00:00:00 2001 From: thomas Date: Sat, 14 Oct 2023 20:39:26 +0200 Subject: [PATCH 22/23] reverted change --- .../org/apache/pekko/actor/typed/internal/jfr/Events.scala | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/actor-typed/src/main/scala-jdk-9/org/apache/pekko/actor/typed/internal/jfr/Events.scala b/actor-typed/src/main/scala-jdk-9/org/apache/pekko/actor/typed/internal/jfr/Events.scala index 8fd6978ea84..c0296f6cce1 100644 --- a/actor-typed/src/main/scala-jdk-9/org/apache/pekko/actor/typed/internal/jfr/Events.scala +++ b/actor-typed/src/main/scala-jdk-9/org/apache/pekko/actor/typed/internal/jfr/Events.scala @@ -20,8 +20,6 @@ import jdk.jfr.Label import jdk.jfr.StackTrace import org.apache.pekko.annotation.InternalApi -import scala.annotation.unused - // requires jdk9+ to compile // for editing these in IntelliJ, open module settings, change JDK dependency to 11 for only this module @@ -97,7 +95,7 @@ final class DeliveryProducerReceived(val producerId: String, val currentSeqNr: L @StackTrace(false) @Category(Array("Pekko", "Delivery", "ProducerController")) @Label( "Delivery ProducerController received demand request") -final class DeliveryProducerReceivedRequest(val producerId: String, val requestedSeqNr: Long, @unused confirmedSeqNr: Long) +final class DeliveryProducerReceivedRequest(val producerId: String, val requestedSeqNr: Long, confirmedSeqNr: Long) extends Event /** INTERNAL API */ From 57d6421977b71ca2914cc86e8d3cdfab9199c379 Mon Sep 17 00:00:00 2001 From: thomas Date: Sat, 14 Oct 2023 20:44:49 +0200 Subject: [PATCH 23/23] formating javafmtCheck --- .../testkit/typed/javadsl/Junit5IntegrationExampleTest.java | 3 +-- .../typed/javadsl/LogCapturingExtensionExampleTest.java | 3 +-- .../actor/testkit/typed/javadsl/ActorTestKitJunit5Test.java | 5 ++--- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/Junit5IntegrationExampleTest.java b/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/Junit5IntegrationExampleTest.java index eb7289637ae..5f14d5f0106 100644 --- a/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/Junit5IntegrationExampleTest.java +++ b/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/Junit5IntegrationExampleTest.java @@ -26,8 +26,7 @@ @ExtendWith(TestKitJunit5Extension.class) class Junit5IntegrationExampleTest { - @Junit5TestKit - public ActorTestKit testKit = new Junit5TestKitBuilder().build(); + @Junit5TestKit public ActorTestKit testKit = new Junit5TestKitBuilder().build(); @Test void junit5Test() { diff --git a/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/LogCapturingExtensionExampleTest.java b/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/LogCapturingExtensionExampleTest.java index 8d2c149c2f9..a4d249ad832 100644 --- a/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/LogCapturingExtensionExampleTest.java +++ b/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/LogCapturingExtensionExampleTest.java @@ -28,8 +28,7 @@ @ExtendWith(LogCapturingExtension.class) class LogCapturingExtensionExampleTest { - @Junit5TestKit - public ActorTestKit testKit = new Junit5TestKitBuilder().build(); + @Junit5TestKit public ActorTestKit testKit = new Junit5TestKitBuilder().build(); @Test void testSomething() { diff --git a/actor-testkit-typed/src/test/java/org/apache/pekko/actor/testkit/typed/javadsl/ActorTestKitJunit5Test.java b/actor-testkit-typed/src/test/java/org/apache/pekko/actor/testkit/typed/javadsl/ActorTestKitJunit5Test.java index 8b0de839fd3..663705ac940 100644 --- a/actor-testkit-typed/src/test/java/org/apache/pekko/actor/testkit/typed/javadsl/ActorTestKitJunit5Test.java +++ b/actor-testkit-typed/src/test/java/org/apache/pekko/actor/testkit/typed/javadsl/ActorTestKitJunit5Test.java @@ -9,7 +9,6 @@ package org.apache.pekko.actor.testkit.typed.javadsl; - import org.apache.pekko.actor.testkit.typed.annotations.Junit5TestKit; import org.apache.pekko.Done; import org.apache.pekko.actor.typed.javadsl.Behaviors; @@ -32,8 +31,8 @@ @ExtendWith(LogCapturingExtension.class) class ActorTestKitJunit5Test extends JUnitSuite { - @Junit5TestKit - public ActorTestKit testKit = new Junit5TestKitBuilder().build(); + @Junit5TestKit public ActorTestKit testKit = new Junit5TestKitBuilder().build(); + @Test void systemNameShouldComeFromTestClassViaJunitResource() { assertEquals("ActorTestKitJunit5Test", testKit.system().name());