From 9e68f057656d1dccc5c9fa04815645c546455c7e Mon Sep 17 00:00:00 2001 From: thomas Date: Wed, 21 Jun 2023 08:17:39 +0200 Subject: [PATCH 01/69] 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/69] 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/69] 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/69] 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/69] 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/69] 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/69] 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/69] 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/69] 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/69] 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/69] 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/69] 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/69] 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/69] 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/69] 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/69] 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/69] 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/69] 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/69] 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/69] 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/69] 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/69] 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/69] 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()); From 0b3dc44f8b18755ddf2241320bb11e9ac6a93b13 Mon Sep 17 00:00:00 2001 From: "scala-steward-asf[bot]" <147768647+scala-steward-asf[bot]@users.noreply.github.com> Date: Sun, 15 Oct 2023 02:04:08 +0100 Subject: [PATCH 24/69] Update sbt-scalafix to 0.11.1 (#709) Co-authored-by: scala-steward-asf[bot] <147768647+scala-steward-asf[bot]@users.noreply.github.com> --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 482c31d3619..138b947088f 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -12,7 +12,7 @@ addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.1.3") addSbtPlugin("com.lightbend.sbt" % "sbt-java-formatter" % "0.7.0") addSbtPlugin("com.lightbend.sbt" % "sbt-bill-of-materials" % "1.0.2") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") -addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.33") +addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.11.1") // sbt-osgi 0.9.5 is available but breaks including jdk9-only classes // sbt-osgi 0.9.6 is available but breaks populating pekko-protobuf-v3 addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.9.4") From 3101167ffe483202b266a38296db78e83e35a897 Mon Sep 17 00:00:00 2001 From: "scala-steward-asf[bot]" <147768647+scala-steward-asf[bot]@users.noreply.github.com> Date: Sun, 15 Oct 2023 02:06:30 +0100 Subject: [PATCH 25/69] Update sbt-dynver to 5.0.1 (#711) Co-authored-by: scala-steward-asf[bot] <147768647+scala-steward-asf[bot]@users.noreply.github.com> --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 138b947088f..b44199a8b2e 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -26,7 +26,7 @@ addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.10.0") addSbtPlugin("com.hpe.sbt" % "sbt-pull-request-validator" % "1.0.0") addSbtPlugin("net.bzzt" % "sbt-reproducible-builds" % "0.31") -addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.1.1") +addSbtPlugin("com.github.sbt" % "sbt-dynver" % "5.0.1") addSbtPlugin("com.github.pjfanning" % "sbt-source-dist" % "0.1.10") addSbtPlugin("org.mdedetrich" % "sbt-apache-sonatype" % "0.1.10") addSbtPlugin("com.github.reibitto" % "sbt-welcome" % "0.2.2") From fa0a509119d97d1d9353f968b170c376116824c0 Mon Sep 17 00:00:00 2001 From: "scala-steward-asf[bot]" <147768647+scala-steward-asf[bot]@users.noreply.github.com> Date: Sun, 15 Oct 2023 02:08:56 +0100 Subject: [PATCH 26/69] Update sbt-license-report to 1.6.1 (#716) Co-authored-by: scala-steward-asf[bot] <147768647+scala-steward-asf[bot]@users.noreply.github.com> --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index b44199a8b2e..6373b3cc646 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -30,7 +30,7 @@ addSbtPlugin("com.github.sbt" % "sbt-dynver" % "5.0.1") addSbtPlugin("com.github.pjfanning" % "sbt-source-dist" % "0.1.10") addSbtPlugin("org.mdedetrich" % "sbt-apache-sonatype" % "0.1.10") addSbtPlugin("com.github.reibitto" % "sbt-welcome" % "0.2.2") -addSbtPlugin("com.github.sbt" % "sbt-license-report" % "1.5.0") +addSbtPlugin("com.github.sbt" % "sbt-license-report" % "1.6.1") // We have to deliberately use older versions of sbt-paradox because current Pekko sbt build // only loads on JDK 1.8 so we need to bring in older versions of parboiled which support JDK 1.8 From 3d47f0565d001891a34f4c5559685617c7dc8146 Mon Sep 17 00:00:00 2001 From: "scala-steward-asf[bot]" <147768647+scala-steward-asf[bot]@users.noreply.github.com> Date: Sun, 15 Oct 2023 02:10:11 +0100 Subject: [PATCH 27/69] Update gson to 2.10.1 (#717) Co-authored-by: scala-steward-asf[bot] <147768647+scala-steward-asf[bot]@users.noreply.github.com> --- project/Dependencies.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 5e792d0a45f..0b64ae1855d 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -129,7 +129,7 @@ object Dependencies { object Docs { val sprayJson = "io.spray" %% "spray-json" % "1.3.6" % Test - val gson = "com.google.code.gson" % "gson" % "2.9.1" % Test + val gson = "com.google.code.gson" % "gson" % "2.10.1" % Test } object TestDependencies { From 77ff42d99bbe68f5f55ef1f742bca6656a6c1717 Mon Sep 17 00:00:00 2001 From: "scala-steward-asf[bot]" <147768647+scala-steward-asf[bot]@users.noreply.github.com> Date: Sun, 15 Oct 2023 02:11:24 +0100 Subject: [PATCH 28/69] Update logback-classic to 1.2.12 (#710) Co-authored-by: scala-steward-asf[bot] <147768647+scala-steward-asf[bot]@users.noreply.github.com> --- project/Dependencies.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 0b64ae1855d..3bf314b525f 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -30,7 +30,7 @@ object Dependencies { val agronaVersion = "1.19.2" val nettyVersion = "4.1.100.Final" val protobufJavaVersion = "3.19.6" - val logbackVersion = "1.2.11" + val logbackVersion = "1.2.12" val jacksonCoreVersion = "2.14.3" val jacksonDatabindVersion = jacksonCoreVersion From e72dfa58a749e1e6745d2ea9b00b8044f5600af1 Mon Sep 17 00:00:00 2001 From: "scala-steward-asf[bot]" <147768647+scala-steward-asf[bot]@users.noreply.github.com> Date: Sun, 15 Oct 2023 02:12:51 +0100 Subject: [PATCH 29/69] Update lmdbjava to 0.8.3 (#731) Co-authored-by: scala-steward-asf[bot] <147768647+scala-steward-asf[bot]@users.noreply.github.com> --- project/Dependencies.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 3bf314b525f..2f3f3f1d4d0 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -83,7 +83,7 @@ object Dependencies { "com.typesafe" %% "ssl-config-core" % sslConfigVersion } - val lmdb = "org.lmdbjava" % "lmdbjava" % "0.7.0" + val lmdb = "org.lmdbjava" % "lmdbjava" % "0.8.3" val junit = "junit" % "junit" % junitVersion From 567c4b64ae002c3c71e30a878505132242898788 Mon Sep 17 00:00:00 2001 From: "scala-steward-asf[bot]" <147768647+scala-steward-asf[bot]@users.noreply.github.com> Date: Sun, 15 Oct 2023 02:13:50 +0100 Subject: [PATCH 30/69] Update sbt-jmh to 0.4.6 (#734) Co-authored-by: scala-steward-asf[bot] <147768647+scala-steward-asf[bot]@users.noreply.github.com> --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 6373b3cc646..11dadcd801e 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -19,7 +19,7 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.9.4") addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.3") addSbtPlugin("com.github.sbt" % "sbt-unidoc" % "0.5.0") addSbtPlugin("com.thoughtworks.sbt-api-mappings" % "sbt-api-mappings" % "3.0.2") -addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.3") +addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.6") addSbtPlugin("io.spray" % "sbt-boilerplate" % "0.6.1") addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.10.0") From 6d25bb063dae3826d6682ba93063c4564bc9ca3e Mon Sep 17 00:00:00 2001 From: "scala-steward-asf[bot]" <147768647+scala-steward-asf[bot]@users.noreply.github.com> Date: Sun, 15 Oct 2023 02:14:31 +0100 Subject: [PATCH 31/69] Update jctools-core to 4.0.1 (#730) Co-authored-by: scala-steward-asf[bot] <147768647+scala-steward-asf[bot]@users.noreply.github.com> --- project/Dependencies.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 2f3f3f1d4d0..3c66389deb9 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -73,7 +73,7 @@ object Dependencies { val sigar = "org.fusesource" % "sigar" % "1.6.4" - val jctools = "org.jctools" % "jctools-core" % "3.3.0" + val jctools = "org.jctools" % "jctools-core" % "4.0.1" // reactive streams val reactiveStreams = "org.reactivestreams" % "reactive-streams" % reactiveStreamsVersion From a8d8ece4cc89eda6d6fa6c999d72004fa9fe556a Mon Sep 17 00:00:00 2001 From: "scala-steward-asf[bot]" <147768647+scala-steward-asf[bot]@users.noreply.github.com> Date: Sun, 15 Oct 2023 02:15:19 +0100 Subject: [PATCH 32/69] Update commons-compress to 1.24.0 (#728) Co-authored-by: scala-steward-asf[bot] <147768647+scala-steward-asf[bot]@users.noreply.github.com> --- project/Dependencies.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 3c66389deb9..a06aecde4f2 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -137,7 +137,7 @@ object Dependencies { val commonsMath = "org.apache.commons" % "commons-math" % "2.2" % Test 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 commonsCompress = "org.apache.commons" % "commons-compress" % "1.24.0" % Test val junit = "junit" % "junit" % junitVersion % Test val httpClient = "org.apache.httpcomponents" % "httpclient" % "4.5.14" % Test From 279ec93ce0b6fbc75ed441e610ad70614ee3268c Mon Sep 17 00:00:00 2001 From: "scala-steward-asf[bot]" <147768647+scala-steward-asf[bot]@users.noreply.github.com> Date: Sun, 15 Oct 2023 02:18:02 +0100 Subject: [PATCH 33/69] Update bcpkix-jdk15on to 1.70 (#729) Co-authored-by: scala-steward-asf[bot] <147768647+scala-steward-asf[bot]@users.noreply.github.com> --- project/Dependencies.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index a06aecde4f2..324b54defc3 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -133,7 +133,7 @@ object Dependencies { } object TestDependencies { - val bcpkix = "org.bouncycastle" % "bcpkix-jdk15on" % "1.68" % Test + val bcpkix = "org.bouncycastle" % "bcpkix-jdk15on" % "1.70" % Test val commonsMath = "org.apache.commons" % "commons-math" % "2.2" % Test val commonsIo = "commons-io" % "commons-io" % "2.11.0" % Test val commonsCodec = "commons-codec" % "commons-codec" % "1.15" % Test From 21bb4dde07451be19bbae42affb9960b60ce7293 Mon Sep 17 00:00:00 2001 From: "scala-steward-asf[bot]" <147768647+scala-steward-asf[bot]@users.noreply.github.com> Date: Sun, 15 Oct 2023 02:23:47 +0100 Subject: [PATCH 34/69] Update metrics-core, metrics-jvm to 4.2.21 (#726) Co-authored-by: scala-steward-asf[bot] <147768647+scala-steward-asf[bot]@users.noreply.github.com> --- project/Dependencies.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 324b54defc3..8b42752acdd 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -182,8 +182,8 @@ object Dependencies { } // metrics, measurements, perf testing - val metrics = "io.dropwizard.metrics" % "metrics-core" % "4.2.10" % Test - val metricsJvm = "io.dropwizard.metrics" % "metrics-jvm" % "4.2.10" % Test + val metrics = "io.dropwizard.metrics" % "metrics-core" % "4.2.21" % Test + val metricsJvm = "io.dropwizard.metrics" % "metrics-jvm" % "4.2.21" % Test val latencyUtils = "org.latencyutils" % "LatencyUtils" % "2.0.3" % Test val hdrHistogram = "org.hdrhistogram" % "HdrHistogram" % "2.1.12" % Test val metricsAll = Seq(metrics, metricsJvm, latencyUtils, hdrHistogram) From 69e192b5d46c29fcbf86c3f19f7865663283c078 Mon Sep 17 00:00:00 2001 From: "scala-steward-asf[bot]" <147768647+scala-steward-asf[bot]@users.noreply.github.com> Date: Sun, 15 Oct 2023 02:29:00 +0100 Subject: [PATCH 35/69] Update commons-io to 2.14.0 (#725) Co-authored-by: scala-steward-asf[bot] <147768647+scala-steward-asf[bot]@users.noreply.github.com> --- project/Dependencies.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 8b42752acdd..8de9e969383 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -135,7 +135,7 @@ object Dependencies { object TestDependencies { val bcpkix = "org.bouncycastle" % "bcpkix-jdk15on" % "1.70" % Test val commonsMath = "org.apache.commons" % "commons-math" % "2.2" % Test - val commonsIo = "commons-io" % "commons-io" % "2.11.0" % Test + val commonsIo = "commons-io" % "commons-io" % "2.14.0" % Test val commonsCodec = "commons-codec" % "commons-codec" % "1.15" % Test val commonsCompress = "org.apache.commons" % "commons-compress" % "1.24.0" % Test val junit = "junit" % "junit" % junitVersion % Test From 45d6b7df4b2dc7ec745a39ff819874b208216f74 Mon Sep 17 00:00:00 2001 From: "scala-steward-asf[bot]" <147768647+scala-steward-asf[bot]@users.noreply.github.com> Date: Sun, 15 Oct 2023 02:33:04 +0100 Subject: [PATCH 36/69] Update asn-one to 0.6.0 (#719) Co-authored-by: scala-steward-asf[bot] <147768647+scala-steward-asf[bot]@users.noreply.github.com> --- project/Dependencies.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 8de9e969383..c59e33b2938 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -97,7 +97,7 @@ object Dependencies { // Added explicitly for when artery tcp is used val agrona = "org.agrona" % "agrona" % agronaVersion - val asnOne = ("com.hierynomus" % "asn-one" % "0.5.0").exclude("org.slf4j", "slf4j-api") + val asnOne = ("com.hierynomus" % "asn-one" % "0.6.0").exclude("org.slf4j", "slf4j-api") val jacksonCore = Def.setting { "com.fasterxml.jackson.core" % "jackson-core" % jacksonCoreVersion From 2615e358c182800c87e017baba5201187099b6c1 Mon Sep 17 00:00:00 2001 From: "scala-steward-asf[bot]" <147768647+scala-steward-asf[bot]@users.noreply.github.com> Date: Sun, 15 Oct 2023 03:31:46 +0100 Subject: [PATCH 37/69] Update jimfs to 1.3.0 (#718) Co-authored-by: scala-steward-asf[bot] <147768647+scala-steward-asf[bot]@users.noreply.github.com> --- project/Dependencies.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index c59e33b2938..a15d6112715 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -166,7 +166,7 @@ object Dependencies { val log4j = "log4j" % "log4j" % "1.2.17" % Test // in-memory filesystem for file related tests - val jimfs = "com.google.jimfs" % "jimfs" % "1.1" % Test + val jimfs = "com.google.jimfs" % "jimfs" % "1.3.0" % Test // docker utils val dockerClient = "com.spotify" % "docker-client" % "8.16.0" % Test From 49f2f07dcb8578a8f26e4bb33e7cb2cff1e1f57f Mon Sep 17 00:00:00 2001 From: "scala-steward-asf[bot]" <147768647+scala-steward-asf[bot]@users.noreply.github.com> Date: Sun, 15 Oct 2023 04:14:45 +0100 Subject: [PATCH 38/69] Update commons-codec to 1.16.0 (#724) Co-authored-by: scala-steward-asf[bot] <147768647+scala-steward-asf[bot]@users.noreply.github.com> Co-authored-by: PJ Fanning --- project/Dependencies.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index a15d6112715..3865a7f4497 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -136,7 +136,7 @@ object Dependencies { val bcpkix = "org.bouncycastle" % "bcpkix-jdk15on" % "1.70" % Test val commonsMath = "org.apache.commons" % "commons-math" % "2.2" % Test val commonsIo = "commons-io" % "commons-io" % "2.14.0" % Test - val commonsCodec = "commons-codec" % "commons-codec" % "1.15" % Test + val commonsCodec = "commons-codec" % "commons-codec" % "1.16.0" % Test val commonsCompress = "org.apache.commons" % "commons-compress" % "1.24.0" % Test val junit = "junit" % "junit" % junitVersion % Test val httpClient = "org.apache.httpcomponents" % "httpclient" % "4.5.14" % Test From ddb49094c5f23e887fd3bcca4b257ab2c557baca Mon Sep 17 00:00:00 2001 From: Arnout Engelen Date: Sun, 15 Oct 2023 11:53:50 +0200 Subject: [PATCH 39/69] Sidestep reproducibility issue (#708) Avoids https://github.com/lampepfl/dotty/issues/18248 --- .../apache/pekko/actor/typed/internal/ExtensionsImpl.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/actor-typed/src/main/scala/org/apache/pekko/actor/typed/internal/ExtensionsImpl.scala b/actor-typed/src/main/scala/org/apache/pekko/actor/typed/internal/ExtensionsImpl.scala index 834b5e3b1ff..09854cd264b 100644 --- a/actor-typed/src/main/scala/org/apache/pekko/actor/typed/internal/ExtensionsImpl.scala +++ b/actor-typed/src/main/scala/org/apache/pekko/actor/typed/internal/ExtensionsImpl.scala @@ -42,7 +42,7 @@ private[pekko] trait ExtensionsImpl extends Extensions { self: ActorSystem[_] wi /* * @param throwOnLoadFail Throw exception when an extension fails to load (needed for backwards compatibility) */ - def loadExtensions(key: String, throwOnLoadFail: Boolean): Unit = { + def loadExtensionsFor(key: String, throwOnLoadFail: Boolean): Unit = { settings.config.getStringList(key).asScala.foreach { extensionIdFQCN => // it is either a Scala object or it is a Java class with a static singleton accessor @@ -72,8 +72,8 @@ private[pekko] trait ExtensionsImpl extends Extensions { self: ActorSystem[_] wi } } - loadExtensions("pekko.actor.typed.library-extensions", throwOnLoadFail = true) - loadExtensions("pekko.actor.typed.extensions", throwOnLoadFail = false) + loadExtensionsFor("pekko.actor.typed.library-extensions", throwOnLoadFail = true) + loadExtensionsFor("pekko.actor.typed.extensions", throwOnLoadFail = false) } final override def hasExtension(ext: ExtensionId[_ <: Extension]): Boolean = findExtension(ext) != null From 955b6224fc349be14c9099ccae87108ef478278c Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Sun, 15 Oct 2023 11:48:33 +0100 Subject: [PATCH 40/69] scalatest 3.2.17 (#735) --- project/Dependencies.scala | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 3865a7f4497..8a20d983a84 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -46,10 +46,9 @@ object Dependencies { val sslConfigVersion = "0.6.1" - val scalaTestVersion = "3.2.14" - val scalaTestBaseVersion = "3.2.10" - val scalaTestScalaCheckVersion = "1-16" - val scalaCheckVersion = "1.15.1" + val scalaTestVersion = "3.2.17" + val scalaTestScalaCheckVersion = "1-17" + val scalaCheckVersion = "1.17.0" val Versions = Seq(crossScalaVersions := allScalaVersions, scalaVersion := allScalaVersions.head, @@ -152,13 +151,13 @@ object Dependencies { "org.scalatestplus" %% "junit-4-13" % (scalaTestVersion + ".0") % Test } val scalatestTestNG = Def.setting { - "org.scalatestplus" %% "testng-6-7" % (scalaTestBaseVersion + ".0") % Test + "org.scalatestplus" %% "testng-7-5" % (scalaTestVersion + ".0") % Test } val scalatestScalaCheck = Def.setting { "org.scalatestplus" %% s"scalacheck-$scalaTestScalaCheckVersion" % (scalaTestVersion + ".0") % Test } val scalatestMockito = Def.setting { - "org.scalatestplus" %% "mockito-3-4" % (scalaTestBaseVersion + ".0") % Test + "org.scalatestplus" %% "mockito-4-11" % (scalaTestVersion + ".0") % Test } val pojosr = "com.googlecode.pojosr" % "de.kalpatec.pojosr.framework" % "0.2.1" % Test From 5314dcf7ccd980587fa03b850deb0f375932cb56 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Sun, 15 Oct 2023 02:21:53 +0100 Subject: [PATCH 41/69] use bcpkix-jdk18on (jdk15on no longer published) --- project/Dependencies.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 8a20d983a84..087187268e3 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -132,7 +132,7 @@ object Dependencies { } object TestDependencies { - val bcpkix = "org.bouncycastle" % "bcpkix-jdk15on" % "1.70" % Test + val bcpkix = "org.bouncycastle" % "bcpkix-jdk18on" % "1.76" % Test val commonsMath = "org.apache.commons" % "commons-math" % "2.2" % Test val commonsIo = "commons-io" % "commons-io" % "2.14.0" % Test val commonsCodec = "commons-codec" % "commons-codec" % "1.16.0" % Test From a603d47f9d35356fef9fc865aa41c8f6e613e658 Mon Sep 17 00:00:00 2001 From: "scala-steward-asf[bot]" <147768647+scala-steward-asf[bot]@users.noreply.github.com> Date: Mon, 16 Oct 2023 10:05:11 +0100 Subject: [PATCH 42/69] Update sigar-loader to 1.6.6 (#727) Co-authored-by: scala-steward-asf[bot] <147768647+scala-steward-asf[bot]@users.noreply.github.com> --- project/Dependencies.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 087187268e3..1ce30be7ed4 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -203,7 +203,7 @@ object Dependencies { object Provided { // TODO remove from "test" config - val sigarLoader = "io.kamon" % "sigar-loader" % "1.6.6-rev002" % "optional;provided;test" + val sigarLoader = "io.kamon" % "sigar-loader" % "1.6.6" % "optional;provided;test" val activation = "com.sun.activation" % "javax.activation" % "1.2.0" % "provided;test" From a99dbda47b7e78e6477dafc5561640db4e384646 Mon Sep 17 00:00:00 2001 From: He-Pin Date: Mon, 16 Oct 2023 12:53:29 +0800 Subject: [PATCH 43/69] =sbt Update sbt-welcome to 0.3.2 --- project/PekkoBuild.scala | 33 +++++++++++++++++---------------- project/plugins.sbt | 2 +- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/project/PekkoBuild.scala b/project/PekkoBuild.scala index b637f8c647e..491ca445fdc 100644 --- a/project/PekkoBuild.scala +++ b/project/PekkoBuild.scala @@ -284,24 +284,25 @@ object PekkoBuild { }, logoColor := scala.Console.BLUE, usefulTasks := Seq( - UsefulTask("", "compile", "Compile the current project"), - UsefulTask("", "test", "Run all the tests"), - UsefulTask("", "testQuick", + UsefulTask("compile", "Compile the current project"), + UsefulTask("test", "Run all the tests"), + UsefulTask("testQuick", "Runs all the tests. When run multiple times will only run previously failing tests (shell mode only)"), - UsefulTask("", "testOnly *.AnySpec", "Only run a selected test"), - UsefulTask("", "testQuick *.AnySpec", + UsefulTask("testOnly *.AnySpec", "Only run a selected test"), + UsefulTask("testQuick *.AnySpec", "Only run a selected test. When run multiple times will only run previously failing tests (shell mode only)"), - UsefulTask("", "testQuickUntilPassed", "Runs all tests in a continuous loop until all tests pass"), - UsefulTask("", "publishLocal", "Publish current snapshot version to local ~/.ivy2 repo"), - UsefulTask("", "verifyCodeStyle", "Verify code style"), - UsefulTask("", "applyCodeStyle", "Apply code style"), - UsefulTask("", "sortImports", "Sort the imports"), - UsefulTask("", "mimaReportBinaryIssues ", "Check binary issues"), - UsefulTask("", "validatePullRequest ", "Validate pull request"), - UsefulTask("", "docs/paradox", "Build documentation"), - UsefulTask("", "docs/paradoxBrowse", "Browse the generated documentation"), - UsefulTask("", "tips:", "prefix commands with `+` to run against cross Scala versions."), - UsefulTask("", "Contributing guide:", "https://github.com/apache/incubator-pekko/blob/main/CONTRIBUTING.md"))) + UsefulTask("testQuickUntilPassed", "Runs all tests in a continuous loop until all tests pass"), + UsefulTask("publishLocal", "Publish current snapshot version to local ~/.ivy2 repo"), + UsefulTask("verifyCodeStyle", "Verify code style"), + UsefulTask("applyCodeStyle", "Apply code style"), + UsefulTask("sortImports", "Sort the imports"), + UsefulTask("mimaReportBinaryIssues ", "Check binary issues"), + UsefulTask("validatePullRequest ", "Validate pull request"), + UsefulTask("docs/paradox", "Build documentation"), + UsefulTask("docs/paradoxBrowse", "Browse the generated documentation"), + UsefulTask("tips:", "prefix commands with `+` to run against cross Scala versions."), + UsefulTask("Contributing guide:", "https://github.com/apache/incubator-pekko/blob/main/CONTRIBUTING.md")).map( + _.noAlias)) } private def optionalDir(path: String): Option[File] = diff --git a/project/plugins.sbt b/project/plugins.sbt index 11dadcd801e..87dc0d08203 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -29,7 +29,7 @@ addSbtPlugin("net.bzzt" % "sbt-reproducible-builds" % "0.31") addSbtPlugin("com.github.sbt" % "sbt-dynver" % "5.0.1") addSbtPlugin("com.github.pjfanning" % "sbt-source-dist" % "0.1.10") addSbtPlugin("org.mdedetrich" % "sbt-apache-sonatype" % "0.1.10") -addSbtPlugin("com.github.reibitto" % "sbt-welcome" % "0.2.2") +addSbtPlugin("com.github.reibitto" % "sbt-welcome" % "0.3.2") addSbtPlugin("com.github.sbt" % "sbt-license-report" % "1.6.1") // We have to deliberately use older versions of sbt-paradox because current Pekko sbt build From 2e19bf159ba2dd0257c09d9cc666a5ca135e93b7 Mon Sep 17 00:00:00 2001 From: Matthew de Detrich Date: Mon, 16 Oct 2023 09:49:11 -0300 Subject: [PATCH 44/69] Add more ignored dependencies to .scala-steward.conf --- .scala-steward.conf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.scala-steward.conf b/.scala-steward.conf index 695935f43cf..0fbf051a110 100644 --- a/.scala-steward.conf +++ b/.scala-steward.conf @@ -11,6 +11,8 @@ updates.ignore = [ { groupId = "com.fasterxml.jackson.datatype", artifactId = "jackson-datatype-jsr310" } { groupId = "com.fasterxml.jackson.datatype", artifactId = "jackson-datatype-jdk8" } { groupId = "com.google.protobuf", artifactId = "protobuf-java" } + { groupId = "com.lightbend.paradox", artifactId = "sbt-paradox-project-info" } + { groupId = "com.lightbend.paradox", artifactId = "sbt-paradox "} { groupId = "com.typesafe", artifactId = "ssl-config-core" } { groupId = "com.typesafe.sbt", artifactId = "sbt-osgi" } { groupId = "org.agrona", artifactId = "agrona" } From a5899c756dfb6a96e6b71beed055c32a1282306d Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Mon, 16 Oct 2023 18:20:06 +0100 Subject: [PATCH 45/69] on each PR, do a full local publish (#691) * on each PR, do a full local publish * apply review suggestion * Update publish-check.yml --- .../workflows/binary-compatibility-checks.yml | 4 +- .github/workflows/publish-check.yml | 52 +++++++++++++++++++ 2 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/publish-check.yml diff --git a/.github/workflows/binary-compatibility-checks.yml b/.github/workflows/binary-compatibility-checks.yml index c2f8ae064b1..8e8f6c6dd56 100644 --- a/.github/workflows/binary-compatibility-checks.yml +++ b/.github/workflows/binary-compatibility-checks.yml @@ -4,10 +4,8 @@ on: pull_request: push: branches: - - master - main - tags: - - v2.6.* + - 1.0.x permissions: {} diff --git a/.github/workflows/publish-check.yml b/.github/workflows/publish-check.yml new file mode 100644 index 00000000000..ad34b4b7099 --- /dev/null +++ b/.github/workflows/publish-check.yml @@ -0,0 +1,52 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more 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 +# +# 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. + +name: Generate doc check + +on: + pull_request: + +permissions: + contents: read + +jobs: + generate-doc-check: + name: Generate doc check + runs-on: ubuntu-20.04 + if: github.repository == 'apache/incubator-pekko' + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true + + - name: Setup Java 11 + uses: actions/setup-java@v3 + with: + distribution: temurin + java-version: 11 + + - name: Cache Coursier cache + uses: coursier/cache-action@v6 + + - name: Install Graphviz + run: |- + sudo apt-get install graphviz + + - name: Publish to Apache Maven Local repo + run: sbt +compile:doc From a0811b2526d7019df7acd0de7b9697a3319405d3 Mon Sep 17 00:00:00 2001 From: thomas Date: Wed, 21 Jun 2023 08:17:39 +0200 Subject: [PATCH 46/69] 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 e656dd3579db9e3999d60268a6434eb84783fd6d Mon Sep 17 00:00:00 2001 From: thomas Date: Wed, 21 Jun 2023 20:19:01 +0200 Subject: [PATCH 47/69] cleanup merge residuals in Dependencies.scala --- project/Dependencies.scala | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 1ce30be7ed4..f844a4b6e75 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -4,13 +4,15 @@ * * https://www.apache.org/licenses/LICENSE-2.0 * - * This file is part of the Apache Pekko project, which was derived from Akka. + * This file is part of the Apache Pekko project, derived from Akka. */ /* * Copyright (C) 2016-2022 Lightbend Inc. */ +package org.apache.pekko + import sbt._ import Keys._ import scala.language.implicitConversions @@ -22,6 +24,8 @@ object Dependencies { .withRank(KeyRanks.Invisible) // avoid 'unused key' warning val junitVersion = "4.13.2" + val junit5Version = "5.10.0" + val slf4jVersion = "1.7.36" // check agrona version when updating this val aeronVersion = "1.42.1" @@ -85,6 +89,7 @@ object Dependencies { val lmdb = "org.lmdbjava" % "lmdbjava" % "0.8.3" val junit = "junit" % "junit" % junitVersion + val junit5 = "org.junit.jupiter" % "junit-jupiter-engine" % junit5Version // For Java 8 Conversions val java8Compat = Def.setting { @@ -139,6 +144,9 @@ object Dependencies { val commonsCompress = "org.apache.commons" % "commons-compress" % "1.24.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 @@ -212,6 +220,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" } @@ -265,6 +274,7 @@ object Dependencies { val actorTestkitTyped = l ++= Seq( Provided.logback, Provided.junit, + Provided.junit5, Provided.scalatest.value, TestDependencies.scalatestJUnit.value) From 51d1fb58384a594fdf14d316baf329cd7c4b0ee6 Mon Sep 17 00:00:00 2001 From: thomas Date: Wed, 21 Jun 2023 21:19:05 +0200 Subject: [PATCH 48/69] 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 478ff7d7b9e3aaef86317bf54916bf56886e22d5 Mon Sep 17 00:00:00 2001 From: thomas Date: Wed, 21 Jun 2023 21:44:19 +0200 Subject: [PATCH 49/69] changed junit5 version to 5.9.3 --- project/Dependencies.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index f844a4b6e75..5dd3317b155 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -91,6 +91,7 @@ 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 @@ -142,9 +143,8 @@ object Dependencies { val commonsIo = "commons-io" % "commons-io" % "2.14.0" % Test val commonsCodec = "commons-codec" % "commons-codec" % "1.16.0" % Test val commonsCompress = "org.apache.commons" % "commons-compress" % "1.24.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 junit = "junit" % "junit" % junitVersion % Test val junit5 = "org.junit.jupiter" % "junit-jupiter-engine" % junit5Version % Test From 92e8cc39f97b79752a5da42b3c468f2863fec1cb Mon Sep 17 00:00:00 2001 From: thomas Date: Wed, 21 Jun 2023 21:49:47 +0200 Subject: [PATCH 50/69] 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 74787871d0ebef5af0a09dd840c72c53f2e0366a Mon Sep 17 00:00:00 2001 From: thomas Date: Wed, 21 Jun 2023 22:09:57 +0200 Subject: [PATCH 51/69] 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 3e94070024fa5214ddb9ad832ce6523fd63db3ef Mon Sep 17 00:00:00 2001 From: thomas Date: Wed, 21 Jun 2023 22:16:00 +0200 Subject: [PATCH 52/69] 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 0ac34964fc13d7b63f466a45fdf378e2be80f786 Mon Sep 17 00:00:00 2001 From: thomas Date: Thu, 22 Jun 2023 15:59:20 +0200 Subject: [PATCH 53/69] 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 691706ada5d606fcadea4fcfe127a1927f6d5176 Mon Sep 17 00:00:00 2001 From: thomas Date: Thu, 22 Jun 2023 16:03:39 +0200 Subject: [PATCH 54/69] 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 e7564552d71996ef91f715120b80f3e7cf6c27a4 Mon Sep 17 00:00:00 2001 From: thomas Date: Thu, 22 Jun 2023 20:07:12 +0200 Subject: [PATCH 55/69] 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 9d91038ac4bcc9331b01408641700054812a6c57 Mon Sep 17 00:00:00 2001 From: thomas Date: Sat, 24 Jun 2023 20:40:07 +0200 Subject: [PATCH 56/69] 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 c71034cd6a8fcecf7ed7300d4959bb96c2bc7e2d Mon Sep 17 00:00:00 2001 From: thomas Date: Mon, 26 Jun 2023 15:22:58 +0200 Subject: [PATCH 57/69] scalafmt reformat --- project/Dependencies.scala | 2 -- 1 file changed, 2 deletions(-) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 5dd3317b155..925983c5d3f 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -91,7 +91,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 @@ -147,7 +146,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 46a1f747e4f873bcb9d0d30915dd12c13f151df4 Mon Sep 17 00:00:00 2001 From: thomas Date: Mon, 26 Jun 2023 16:08:49 +0200 Subject: [PATCH 58/69] 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 448c927fcd3f0498bdd654370bf255e29e0df3cd Mon Sep 17 00:00:00 2001 From: thomas Date: Mon, 26 Jun 2023 16:12:55 +0200 Subject: [PATCH 59/69] 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 656feb50c0266f60980dcf46175f8cbd3e0e61a9 Mon Sep 17 00:00:00 2001 From: thomas Date: Mon, 26 Jun 2023 20:29:59 +0200 Subject: [PATCH 60/69] 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 3786acbfa95ff28ca4befd1fc7e75985832ca3f3 Mon Sep 17 00:00:00 2001 From: thomas Date: Mon, 26 Jun 2023 21:12:02 +0200 Subject: [PATCH 61/69] 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 aa9ae7af4a89986610f0c6a397aaaefe52d39ed6 Mon Sep 17 00:00:00 2001 From: thomas Date: Wed, 28 Jun 2023 07:08:06 +0200 Subject: [PATCH 62/69] 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 fb9c333be7f8cd2c11d7692c65a75c65a2612c0f Mon Sep 17 00:00:00 2001 From: thomas Date: Sun, 2 Jul 2023 21:10:54 +0200 Subject: [PATCH 63/69] 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 cd923da6ece30ff0f87d714758dd840c4b0c6b47 Mon Sep 17 00:00:00 2001 From: thomas Date: Mon, 3 Jul 2023 19:47:36 +0200 Subject: [PATCH 64/69] 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 dace9118570c3b9c11abc95f55ffad94f1367a7d Mon Sep 17 00:00:00 2001 From: thomas Date: Mon, 3 Jul 2023 20:24:29 +0200 Subject: [PATCH 65/69] 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 9eed963f89bca54ebe0363bd2616a7f44c8e94b5 Mon Sep 17 00:00:00 2001 From: thomas Date: Sat, 14 Oct 2023 20:19:59 +0200 Subject: [PATCH 66/69] 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 +++-- 6 files changed, 23 insertions(+), 19 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 */ From e421ef45d3870b283ce8d5d4eafcbb2ce54caaad Mon Sep 17 00:00:00 2001 From: thomas Date: Sat, 14 Oct 2023 20:39:26 +0200 Subject: [PATCH 67/69] 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 b05b40f5058942151c232e302fad581962cb92b3 Mon Sep 17 00:00:00 2001 From: thomas Date: Sat, 14 Oct 2023 20:44:49 +0200 Subject: [PATCH 68/69] 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()); From e717dec4d93b7236dfd0657ee38f3cbfa6cfb06d Mon Sep 17 00:00:00 2001 From: thomas Date: Mon, 16 Oct 2023 21:31:02 +0200 Subject: [PATCH 69/69] rebased --- build.sbt | 1 + 1 file changed, 1 insertion(+) diff --git a/build.sbt b/build.sbt index b98261030f9..3d533ac7f38 100644 --- a/build.sbt +++ b/build.sbt @@ -8,6 +8,7 @@ */ import net.bzzt.reproduciblebuilds.ReproducibleBuildsPlugin.reproducibleBuildsCheckResolver +import org.apache.pekko.Dependencies ThisBuild / scalafixScalaBinaryVersion := scalaBinaryVersion.value