This is an automated email from the ASF dual-hosted git repository.
He-Pin pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko.git
The following commit(s) were added to refs/heads/main by this push:
new 3e578d8a75 chore: upgrade sbt-java-formatter to 0.12.0 (#3066)
3e578d8a75 is described below
commit 3e578d8a75acdfdb12584ac2c8fb13e23edacb76
Author: He-Pin(kerr) <[email protected]>
AuthorDate: Mon Jun 15 00:34:33 2026 +0800
chore: upgrade sbt-java-formatter to 0.12.0 (#3066)
* chore: upgrade sbt-java-formatter to 0.12.0
Motivation:
Align sbt-java-formatter version with other pekko sub-projects to
reduce maintenance burden and ensure consistent Java formatting.
Modification:
Upgrade sbt-java-formatter from 0.11.0 to 0.12.0 in project/plugins.sbt.
Result:
All pekko sub-projects now use the same sbt-java-formatter version (0.12.0).
Tests:
Not run - build config change only
References:
None - formatter unification across pekko sub-projects
* fix: use checkCodeStyle alias in CI instead of javafmtCheckAll
Motivation:
The CI workflow was only checking Java formatting. The checkCodeStyle
alias covers scalafmt, javafmt, and header checks in one command.
Modification:
Replace javafmtCheckAll with checkCodeStyle in build-test-prValidation.yml.
Result:
CI now runs the full code style check (scalafmt + javafmt + headers).
* fix: add javafmtFormatterCompatibleJavaVersion := 17 to build.sbt
Motivation:
As suggested by @pjfanning, google-java-format requires the JDK
compatibility version to be set explicitly in build.sbt to avoid
formatting issues with the upgraded sbt-java-formatter 0.12.0.
Modification:
Add `ThisBuild / javafmtFormatterCompatibleJavaVersion := 17`
before the addCommandAlias lines.
Result:
Code Style check should pass with consistent formatting across
local and CI environments.
* fix: move Paradox snippet markers below import blocks in 60 Java files
google-java-format requires import statements to be contiguous (no comments
between them). Moved Paradox snippet markers (// #tag-name) from within
import blocks to below the last import statement, then ran javafmtAll.
* fix: exclude documentation test Java files from javafmt
Files in jdocs/ and docs/ directories use Paradox snippet markers
(// #tag-name) between import statements for documentation extraction.
google-java-format requires imports to be contiguous, so these files
cannot be auto-formatted. Added excludeFilter to skip them.
* fix: use javafmtSortImports := false to preserve Paradox markers
Motivation:
The previous approach of either excluding doc files from javafmt or
manually repositioning Paradox markers broke documentation rendering.
google-java-format requires contiguous imports, and alphabetically
sorting imports moves Paradox snippet markers (// #tag) to wrong
positions relative to the imports they wrap.
Modification:
- Replace javafmt/excludeFilter with javafmtSortImports := false
- Restore 60 doc files to their original import order
- Run javafmtAll which now formats code without reordering imports
- Paradox markers stay in their original positions between imports
Result:
All Java files are formatted by javafmt while Paradox snippet markers
correctly wrap their intended imports for documentation rendering.
* fix: align string continuation indentation with google-java-format 1.28.0
Motivation:
google-java-format 1.28.0 (used by sbt-java-formatter 0.12.0 with
javafmtFormatterCompatibleJavaVersion := 17) expects 24-space indentation
for string continuation lines inside nested method calls. The file had
21-space indentation, causing the Check / Code Style CI job to fail.
Modification:
Fix indentation of two string continuation lines in filterExample and
filterNotExample methods to match google-java-format 1.28.0 expectations.
Result:
The checkCodeStyle CI check passes for the docs module.
Tests:
- sbt checkCodeStyle → success
- google-java-format 1.28.0 --skip-sorting-imports --dry-run → exit 0
References:
Refs #3066
---
.github/workflows/build-test-prValidation.yml | 2 +-
.../typed/javadsl/AsyncTestingExampleTest.java | 5 +-
.../apache/pekko/typed/GracefulStopDocTest.java | 2 +
.../InteractionPatternsAskWithStatusTest.java | 2 +
.../jdocs/org/apache/pekko/typed/IntroTest.java | 10 +
.../org/apache/pekko/typed/LoggingDocExamples.java | 3 +
.../jdocs/org/apache/pekko/typed/OOIntroTest.java | 5 +
.../apache/pekko/typed/SpawnProtocolDocTest.java | 1 +
.../eventstream/EventStreamSuperClassDocTest.java | 1 +
build.sbt | 3 +
.../jdocs/delivery/PointToPointDocExample.java | 2 +
.../java/jdocs/delivery/ShardingDocExample.java | 2 +
.../java/jdocs/delivery/WorkPullingDocExample.java | 2 +
.../sharding/typed/AccountExampleDocTest.java | 8 +-
.../AccountExamplePersistenceProbeDocTest.java | 219 +++++++++++----------
.../typed/HelloWorldPersistentEntityExample.java | 3 +-
.../sharding/typed/ShardingCompileOnlyTest.java | 2 +
.../cluster/typed/SingletonCompileOnlyTest.java | 1 +
docs/src/test/java/jdocs/actor/ActorDocTest.java | 17 ++
.../jdocs/actor/ByteBufferSerializerDocTest.java | 1 +
.../jdocs/actor/DependencyInjectionDocTest.java | 2 +
.../test/java/jdocs/actor/SchedulerDocTest.java | 2 -
docs/src/test/java/jdocs/actor/fsm/Buncher.java | 1 +
.../actor/typed/CoordinatedActorShutdownTest.java | 1 +
.../singleton/ClusterSingletonSupervision.java | 1 +
.../java/jdocs/dispatcher/DispatcherDocTest.java | 3 +
.../src/test/java/jdocs/event/EventBusDocTest.java | 4 +
docs/src/test/java/jdocs/event/LoggingDocTest.java | 3 +
.../jdocs/extension/SettingsExtensionDocTest.java | 1 +
docs/src/test/java/jdocs/future/FutureDocTest.java | 92 ++++-----
.../test/java/jdocs/io/UdpConnectedDocTest.java | 1 -
docs/src/test/java/jdocs/io/japi/IODocTest.java | 3 +
.../persistence/testkit/PersistenceInitTest.java | 23 ++-
.../routing/ConsistentHashingRouterDocTest.java | 2 +
.../java/jdocs/routing/CustomRouterDocTest.java | 1 -
.../src/test/java/jdocs/routing/RouterDocTest.java | 2 +
.../jdocs/serialization/SerializationDocTest.java | 2 +
.../java/jdocs/sharding/ClusterShardingTest.java | 12 +-
.../stream/operators/BroadcastDocExample.java | 1 +
.../stream/operators/MergeSequenceDocExample.java | 1 +
.../stream/operators/PartitionDocExample.java | 1 +
.../java/jdocs/stream/operators/SourceOrFlow.java | 13 +-
.../tutorial_1/ActorHierarchyExperiments.java | 4 +
.../typed/BasicPersistentBehaviorTest.java | 11 ++
.../typed/DurableStatePersistentBehaviorTest.java | 4 +
project/plugins.sbt | 2 +-
.../org/apache/pekko/stream/javadsl/TcpTest.java | 1 -
47 files changed, 298 insertions(+), 187 deletions(-)
diff --git a/.github/workflows/build-test-prValidation.yml
b/.github/workflows/build-test-prValidation.yml
index a684a3c484..478c5bee6a 100644
--- a/.github/workflows/build-test-prValidation.yml
+++ b/.github/workflows/build-test-prValidation.yml
@@ -51,7 +51,7 @@ jobs:
sbt \
-Dsbt.override.build.repos=false \
-Dsbt.log.noformat=false \
- javafmtCheckAll
+ checkCodeStyle
pull-request-validation:
name: Check / Tests
runs-on: ubuntu-22.04
diff --git
a/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/AsyncTestingExampleTest.java
b/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/AsyncTestingExampleTest.java
index c0538b76e6..c1f375b3e9 100644
---
a/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/AsyncTestingExampleTest.java
+++
b/actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/AsyncTestingExampleTest.java
@@ -41,11 +41,12 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
// #test-header
@ExtendWith({TestKitJUnitJupiterExtension.class, LogCapturingExtension.class})
public class AsyncTestingExampleTest
- // #test-header
+// #test-header
// #test-header
{
@JUnitJupiterTestKit public ActorTestKit testKit = new
JUnitJupiterTestKitBuilder().build();
+
// #test-header
// #under-test
@@ -93,6 +94,7 @@ public class AsyncTestingExampleTest
.build();
}
}
+
// #under-test
// #under-test-2
@@ -129,6 +131,7 @@ public class AsyncTestingExampleTest
scheduler);
}
}
+
// #under-test-2
// #test-shutdown
diff --git
a/actor-typed-tests/src/test/java/jdocs/org/apache/pekko/typed/GracefulStopDocTest.java
b/actor-typed-tests/src/test/java/jdocs/org/apache/pekko/typed/GracefulStopDocTest.java
index 2352faa2ce..d501bc6c62 100644
---
a/actor-typed-tests/src/test/java/jdocs/org/apache/pekko/typed/GracefulStopDocTest.java
+++
b/actor-typed-tests/src/test/java/jdocs/org/apache/pekko/typed/GracefulStopDocTest.java
@@ -86,6 +86,7 @@ interface GracefulStopDocTest {
return this;
}
}
+
// #master-actor
public static void main(String[] args) throws Exception {
@@ -130,6 +131,7 @@ interface GracefulStopDocTest {
return this;
}
}
+
// #worker-actor
interface IllustrateWatch {
diff --git
a/actor-typed-tests/src/test/java/jdocs/org/apache/pekko/typed/InteractionPatternsAskWithStatusTest.java
b/actor-typed-tests/src/test/java/jdocs/org/apache/pekko/typed/InteractionPatternsAskWithStatusTest.java
index d4ddeec0b1..6906a2811f 100644
---
a/actor-typed-tests/src/test/java/jdocs/org/apache/pekko/typed/InteractionPatternsAskWithStatusTest.java
+++
b/actor-typed-tests/src/test/java/jdocs/org/apache/pekko/typed/InteractionPatternsAskWithStatusTest.java
@@ -184,6 +184,7 @@ public class InteractionPatternsAskWithStatusTest {
return this;
}
}
+
// #standalone-ask-with-status
static class NotShown {
@@ -209,6 +210,7 @@ public class InteractionPatternsAskWithStatusTest {
else System.out.println("Boo! didn't get cookies in time. " +
failure);
});
}
+
// #standalone-ask-with-status
public void askAndMapInvalid(
diff --git
a/actor-typed-tests/src/test/java/jdocs/org/apache/pekko/typed/IntroTest.java
b/actor-typed-tests/src/test/java/jdocs/org/apache/pekko/typed/IntroTest.java
index fec211298a..03386d1cf9 100644
---
a/actor-typed-tests/src/test/java/jdocs/org/apache/pekko/typed/IntroTest.java
+++
b/actor-typed-tests/src/test/java/jdocs/org/apache/pekko/typed/IntroTest.java
@@ -78,6 +78,7 @@ public interface IntroTest {
return this;
}
}
+
// #hello-world-actor
// #hello-world-bot
@@ -111,6 +112,7 @@ public interface IntroTest {
}
}
}
+
// #hello-world-bot
// #hello-world-main
@@ -137,6 +139,7 @@ public interface IntroTest {
super(context);
greeter = context.spawn(HelloWorld.create(), "greeter");
}
+
// #hello-world-main-setup
@Override
@@ -152,6 +155,7 @@ public interface IntroTest {
}
// #hello-world-main-setup
}
+
// #hello-world-main-setup
// #hello-world-main
@@ -168,6 +172,7 @@ public interface IntroTest {
this.name = name;
}
}
+
// #hello-world-main-with-dispatchers
public static Behavior<SayHello> create() {
@@ -224,6 +229,7 @@ public interface IntroTest {
this.replyTo = replyTo;
}
}
+
// #chatroom-protocol
// #chatroom-behavior
private static final class PublishSessionMessage implements RoomCommand {
@@ -235,6 +241,7 @@ public interface IntroTest {
this.message = message;
}
}
+
// #chatroom-behavior
// #chatroom-protocol
@@ -283,6 +290,7 @@ public interface IntroTest {
this.message = message;
}
}
+
// #chatroom-protocol
// #chatroom-behavior
@@ -351,6 +359,7 @@ public interface IntroTest {
}
}
}
+
// #chatroom-behavior
// #chatroom-gabbler
@@ -390,6 +399,7 @@ public interface IntroTest {
return Behaviors.stopped();
}
}
+
// #chatroom-gabbler
// #chatroom-main
diff --git
a/actor-typed-tests/src/test/java/jdocs/org/apache/pekko/typed/LoggingDocExamples.java
b/actor-typed-tests/src/test/java/jdocs/org/apache/pekko/typed/LoggingDocExamples.java
index b087ee6f48..d6477792dc 100644
---
a/actor-typed-tests/src/test/java/jdocs/org/apache/pekko/typed/LoggingDocExamples.java
+++
b/actor-typed-tests/src/test/java/jdocs/org/apache/pekko/typed/LoggingDocExamples.java
@@ -58,6 +58,7 @@ public interface LoggingDocExamples {
return this;
}
}
+
// #context-log
// #logger-name
@@ -86,6 +87,7 @@ public interface LoggingDocExamples {
return this;
}
}
+
// #logger-name
// #logger-factory
@@ -106,6 +108,7 @@ public interface LoggingDocExamples {
});
}
}
+
// #logger-factory
static void logMessages() {
diff --git
a/actor-typed-tests/src/test/java/jdocs/org/apache/pekko/typed/OOIntroTest.java
b/actor-typed-tests/src/test/java/jdocs/org/apache/pekko/typed/OOIntroTest.java
index f04b405776..c9b62232cc 100644
---
a/actor-typed-tests/src/test/java/jdocs/org/apache/pekko/typed/OOIntroTest.java
+++
b/actor-typed-tests/src/test/java/jdocs/org/apache/pekko/typed/OOIntroTest.java
@@ -50,6 +50,7 @@ public interface OOIntroTest {
this.replyTo = replyTo;
}
}
+
// #chatroom-protocol
// #chatroom-behavior
private static final class PublishSessionMessage implements RoomCommand {
@@ -61,6 +62,7 @@ public interface OOIntroTest {
this.message = message;
}
}
+
// #chatroom-behavior
// #chatroom-protocol
@@ -109,6 +111,7 @@ public interface OOIntroTest {
this.message = message;
}
}
+
// #chatroom-protocol
// #chatroom-behavior
@@ -197,6 +200,7 @@ public interface OOIntroTest {
}
}
}
+
// #chatroom-behavior
// #chatroom-gabbler
@@ -236,6 +240,7 @@ public interface OOIntroTest {
return Behaviors.stopped();
}
}
+
// #chatroom-gabbler
// #chatroom-main
diff --git
a/actor-typed-tests/src/test/java/jdocs/org/apache/pekko/typed/SpawnProtocolDocTest.java
b/actor-typed-tests/src/test/java/jdocs/org/apache/pekko/typed/SpawnProtocolDocTest.java
index 9d628f1945..8991cda4b9 100644
---
a/actor-typed-tests/src/test/java/jdocs/org/apache/pekko/typed/SpawnProtocolDocTest.java
+++
b/actor-typed-tests/src/test/java/jdocs/org/apache/pekko/typed/SpawnProtocolDocTest.java
@@ -49,6 +49,7 @@ public interface SpawnProtocolDocTest {
});
}
}
+
// #main
public static void main(String[] args) throws Exception {
diff --git
a/actor-typed-tests/src/test/java/org/apache/pekko/actor/typed/eventstream/EventStreamSuperClassDocTest.java
b/actor-typed-tests/src/test/java/org/apache/pekko/actor/typed/eventstream/EventStreamSuperClassDocTest.java
index 15f800f117..0d4d7ac89b 100644
---
a/actor-typed-tests/src/test/java/org/apache/pekko/actor/typed/eventstream/EventStreamSuperClassDocTest.java
+++
b/actor-typed-tests/src/test/java/org/apache/pekko/actor/typed/eventstream/EventStreamSuperClassDocTest.java
@@ -33,6 +33,7 @@ import org.apache.pekko.actor.AllDeadLetters;
import org.apache.pekko.actor.Dropped;
import org.apache.pekko.actor.SuppressedDeadLetter;
import org.apache.pekko.actor.UnhandledMessage;
+
// #listen-to-super-class-imports
public class EventStreamSuperClassDocTest {
diff --git a/build.sbt b/build.sbt
index f49e77f6a3..4ac7e32996 100644
--- a/build.sbt
+++ b/build.sbt
@@ -38,6 +38,9 @@ enablePlugins(
JavaFormatterPlugin)
disablePlugins(MimaPlugin)
+ThisBuild / javafmtFormatterCompatibleJavaVersion := 17
+ThisBuild / javafmtSortImports := false
+
addCommandAlias("checkCodeStyle", "scalafmtCheckAll; scalafmtSbtCheck;
javafmtCheckAll; +headerCheckAll")
addCommandAlias("applyCodeStyle", "+headerCreateAll; scalafmtAll; scalafmtSbt;
javafmtAll")
diff --git
a/cluster-sharding-typed/src/test/java/jdocs/delivery/PointToPointDocExample.java
b/cluster-sharding-typed/src/test/java/jdocs/delivery/PointToPointDocExample.java
index 0e02f6d599..6accf53e20 100644
---
a/cluster-sharding-typed/src/test/java/jdocs/delivery/PointToPointDocExample.java
+++
b/cluster-sharding-typed/src/test/java/jdocs/delivery/PointToPointDocExample.java
@@ -92,6 +92,7 @@ interface PointToPointDocExample {
}
}
}
+
// #producer
// #consumer
@@ -145,6 +146,7 @@ interface PointToPointDocExample {
return this;
}
}
+
// #consumer
public class Guardian {
diff --git
a/cluster-sharding-typed/src/test/java/jdocs/delivery/ShardingDocExample.java
b/cluster-sharding-typed/src/test/java/jdocs/delivery/ShardingDocExample.java
index 768a0e05e2..02ea8b6cfb 100644
---
a/cluster-sharding-typed/src/test/java/jdocs/delivery/ShardingDocExample.java
+++
b/cluster-sharding-typed/src/test/java/jdocs/delivery/ShardingDocExample.java
@@ -250,6 +250,7 @@ interface ShardingDocExample {
}
}
}
+
// #consumer
// #producer
@@ -407,6 +408,7 @@ interface ShardingDocExample {
}
}
}
+
// #producer
static void illustrateInit() {
diff --git
a/cluster-sharding-typed/src/test/java/jdocs/delivery/WorkPullingDocExample.java
b/cluster-sharding-typed/src/test/java/jdocs/delivery/WorkPullingDocExample.java
index 9a41b5709c..d6a6c3f92e 100644
---
a/cluster-sharding-typed/src/test/java/jdocs/delivery/WorkPullingDocExample.java
+++
b/cluster-sharding-typed/src/test/java/jdocs/delivery/WorkPullingDocExample.java
@@ -101,6 +101,7 @@ interface WorkPullingDocExample {
return Behaviors.same();
}
}
+
// #consumer
// #producer
@@ -289,6 +290,7 @@ interface WorkPullingDocExample {
resultId, convert.fromFormat, convert.toFormat,
convert.image));
return waitForNext();
}
+
// #producer
Object askScope =
diff --git
a/cluster-sharding-typed/src/test/java/jdocs/org/apache/pekko/cluster/sharding/typed/AccountExampleDocTest.java
b/cluster-sharding-typed/src/test/java/jdocs/org/apache/pekko/cluster/sharding/typed/AccountExampleDocTest.java
index a9ffeb1103..0347162e01 100644
---
a/cluster-sharding-typed/src/test/java/jdocs/org/apache/pekko/cluster/sharding/typed/AccountExampleDocTest.java
+++
b/cluster-sharding-typed/src/test/java/jdocs/org/apache/pekko/cluster/sharding/typed/AccountExampleDocTest.java
@@ -40,19 +40,21 @@ import org.junit.jupiter.api.extension.ExtendWith;
@ExtendWith(TestKitJUnitJupiterExtension.class)
@ExtendWith(LogCapturingExtension.class)
public class AccountExampleDocTest
- // #test
-
+// #test
+
// #test
{
// #testkit
- @JUnitJupiterTestKit public ActorTestKit testKit =
ActorTestKit.create(EventSourcedBehaviorTestKit.config());
+ @JUnitJupiterTestKit
+ public ActorTestKit testKit =
ActorTestKit.create(EventSourcedBehaviorTestKit.config());
private EventSourcedBehaviorTestKit<
AccountEntity.Command, AccountEntity.Event, AccountEntity.Account>
eventSourcedTestKit =
EventSourcedBehaviorTestKit.create(
testKit.system(), AccountEntity.create("1",
PersistenceId.of("Account", "1")));
+
// #testkit
@BeforeEach
diff --git
a/cluster-sharding-typed/src/test/java/jdocs/org/apache/pekko/cluster/sharding/typed/AccountExamplePersistenceProbeDocTest.java
b/cluster-sharding-typed/src/test/java/jdocs/org/apache/pekko/cluster/sharding/typed/AccountExamplePersistenceProbeDocTest.java
index c48dad8574..3c17fddb8a 100644
---
a/cluster-sharding-typed/src/test/java/jdocs/org/apache/pekko/cluster/sharding/typed/AccountExamplePersistenceProbeDocTest.java
+++
b/cluster-sharding-typed/src/test/java/jdocs/org/apache/pekko/cluster/sharding/typed/AccountExamplePersistenceProbeDocTest.java
@@ -30,131 +30,134 @@ import org.apache.pekko.persistence.typed.PersistenceId;
import org.junit.jupiter.api.Test;
public class AccountExamplePersistenceProbeDocTest
- // #test
-
// #test
-{
- @Test
- public void createWithEmptyBalance() {
- PersistenceProbeBehavior<AccountEntity.Command, AccountEntity.Event,
AccountEntity.Account>
- persistenceProbe = emptyAccount();
- BehaviorTestKit<AccountEntity.Command> testkit =
persistenceProbe.getBehaviorTestKit();
+// #test
+{
+ @Test
+ public void createWithEmptyBalance() {
+ PersistenceProbeBehavior<AccountEntity.Command, AccountEntity.Event,
AccountEntity.Account>
+ persistenceProbe = emptyAccount();
- StatusReplyInbox<Done> ackInbox =
testkit.runAskWithStatus(AccountEntity.CreateAccount::new);
+ BehaviorTestKit<AccountEntity.Command> testkit =
persistenceProbe.getBehaviorTestKit();
- ackInbox.expectValue(Done.getInstance());
-
persistenceProbe.getEventProbe().expectPersisted(AccountEntity.AccountCreated.INSTANCE);
+ StatusReplyInbox<Done> ackInbox =
testkit.runAskWithStatus(AccountEntity.CreateAccount::new);
- // internal state is only exposed by the behavior via responses to
messages or if it happens
- // to snapshot. This particular behavior never snapshots, so we
query within the actor's
- // protocol
- assertFalse(persistenceProbe.getSnapshotProbe().hasEffects());
+ ackInbox.expectValue(Done.getInstance());
+
persistenceProbe.getEventProbe().expectPersisted(AccountEntity.AccountCreated.INSTANCE);
- ReplyInbox<AccountEntity.CurrentBalance> currentBalanceInbox =
- testkit.runAsk(AccountEntity.GetBalance::new);
+ // internal state is only exposed by the behavior via responses to
messages or if it happens
+ // to snapshot. This particular behavior never snapshots, so we query
within the actor's
+ // protocol
+ assertFalse(persistenceProbe.getSnapshotProbe().hasEffects());
- assertEquals(BigDecimal.ZERO,
currentBalanceInbox.receiveReply().balance);
- }
+ ReplyInbox<AccountEntity.CurrentBalance> currentBalanceInbox =
+ testkit.runAsk(AccountEntity.GetBalance::new);
- @Test
- public void handleDepositAndWithdraw() {
- PersistenceProbeBehavior<AccountEntity.Command, AccountEntity.Event,
AccountEntity.Account>
- persistenceProbe = openedAccount();
+ assertEquals(BigDecimal.ZERO, currentBalanceInbox.receiveReply().balance);
+ }
- BehaviorTestKit<AccountEntity.Command> testkit =
persistenceProbe.getBehaviorTestKit();
- BigDecimal currentBalance;
+ @Test
+ public void handleDepositAndWithdraw() {
+ PersistenceProbeBehavior<AccountEntity.Command, AccountEntity.Event,
AccountEntity.Account>
+ persistenceProbe = openedAccount();
- testkit
- .runAskWithStatus(
- Done.class, replyTo -> new
AccountEntity.Deposit(BigDecimal.valueOf(100), replyTo))
- .expectValue(Done.getInstance());
-
- assertEquals(
- BigDecimal.valueOf(100),
- persistenceProbe
- .getEventProbe()
- .expectPersistedClass(AccountEntity.Deposited.class)
- .persistedObject()
- .amount);
-
- currentBalance =
- testkit
- .runAsk(AccountEntity.CurrentBalance.class,
AccountEntity.GetBalance::new)
- .receiveReply()
- .balance;
-
- assertEquals(BigDecimal.valueOf(100), currentBalance);
+ BehaviorTestKit<AccountEntity.Command> testkit =
persistenceProbe.getBehaviorTestKit();
+ BigDecimal currentBalance;
- testkit
- .runAskWithStatus(
- Done.class, replyTo -> new
AccountEntity.Withdraw(BigDecimal.valueOf(10), replyTo))
- .expectValue(Done.getInstance());
+ testkit
+ .runAskWithStatus(
+ Done.class, replyTo -> new
AccountEntity.Deposit(BigDecimal.valueOf(100), replyTo))
+ .expectValue(Done.getInstance());
- // can save the persistence effect for in-depth inspection
- PersistenceEffect<AccountEntity.Withdrawn> withdrawEffect =
-
persistenceProbe.getEventProbe().expectPersistedClass(AccountEntity.Withdrawn.class);
- assertEquals(BigDecimal.valueOf(10),
withdrawEffect.persistedObject().amount);
- assertEquals(3L, withdrawEffect.sequenceNr());
- assertTrue(withdrawEffect.tags().isEmpty());
+ assertEquals(
+ BigDecimal.valueOf(100),
+ persistenceProbe
+ .getEventProbe()
+ .expectPersistedClass(AccountEntity.Deposited.class)
+ .persistedObject()
+ .amount);
- currentBalance =
- testkit
- .runAsk(AccountEntity.CurrentBalance.class,
AccountEntity.GetBalance::new)
- .receiveReply()
- .balance;
+ currentBalance =
+ testkit
+ .runAsk(AccountEntity.CurrentBalance.class,
AccountEntity.GetBalance::new)
+ .receiveReply()
+ .balance;
- assertEquals(BigDecimal.valueOf(90), currentBalance);
- }
+ assertEquals(BigDecimal.valueOf(100), currentBalance);
- @Test
- public void rejectWithdrawOverdraft() {
- PersistenceProbeBehavior<AccountEntity.Command, AccountEntity.Event,
AccountEntity.Account>
- persistenceProbe = accountWithBalance(BigDecimal.valueOf(100));
+ testkit
+ .runAskWithStatus(
+ Done.class, replyTo -> new
AccountEntity.Withdraw(BigDecimal.valueOf(10), replyTo))
+ .expectValue(Done.getInstance());
- BehaviorTestKit<AccountEntity.Command> testkit =
persistenceProbe.getBehaviorTestKit();
+ // can save the persistence effect for in-depth inspection
+ PersistenceEffect<AccountEntity.Withdrawn> withdrawEffect =
+
persistenceProbe.getEventProbe().expectPersistedClass(AccountEntity.Withdrawn.class);
+ assertEquals(BigDecimal.valueOf(10),
withdrawEffect.persistedObject().amount);
+ assertEquals(3L, withdrawEffect.sequenceNr());
+ assertTrue(withdrawEffect.tags().isEmpty());
+ currentBalance =
testkit
- .runAskWithStatus(
- Done.class, replyTo -> new
AccountEntity.Withdraw(BigDecimal.valueOf(110), replyTo))
- .expectErrorMessage("not enough funds to withdraw 110");
-
- assertFalse(persistenceProbe.getEventProbe().hasEffects());
- }
-
- // #test
- private PersistenceProbeBehavior<AccountEntity.Command,
AccountEntity.Event, AccountEntity.Account>
- emptyAccount() {
- return
- // #persistenceProbe-behavior
- PersistenceProbeBehavior.fromEventSourced(
- AccountEntity.create("1", PersistenceId.of("Account", "1")),
- null, // use the initial state
- 0 // initial sequence number
- );
- // #persistenceProbe-behavior
- }
-
- private PersistenceProbeBehavior<AccountEntity.Command,
AccountEntity.Event, AccountEntity.Account>
- openedAccount() {
- return
- // #persistenceProbe-behavior-provided-state
- PersistenceProbeBehavior.fromEventSourced(
- AccountEntity.create("1", PersistenceId.of("Account", "1")),
- new AccountEntity.EmptyAccount()
- .openedAccount(), // duplicate the event handler for
AccountCreated on an EmptyAccount
- 1 // assume that CreateAccount was the first command
- );
- // #persistenceProbe-behavior-provided-state
- }
-
- private PersistenceProbeBehavior<AccountEntity.Command,
AccountEntity.Event, AccountEntity.Account>
- accountWithBalance(BigDecimal balance) {
- return PersistenceProbeBehavior.fromEventSourced(
- AccountEntity.create("1", PersistenceId.of("Account", "1")),
- new AccountEntity.OpenedAccount(balance),
- 2);
- }
- // #test
+ .runAsk(AccountEntity.CurrentBalance.class,
AccountEntity.GetBalance::new)
+ .receiveReply()
+ .balance;
+
+ assertEquals(BigDecimal.valueOf(90), currentBalance);
+ }
+
+ @Test
+ public void rejectWithdrawOverdraft() {
+ PersistenceProbeBehavior<AccountEntity.Command, AccountEntity.Event,
AccountEntity.Account>
+ persistenceProbe = accountWithBalance(BigDecimal.valueOf(100));
+
+ BehaviorTestKit<AccountEntity.Command> testkit =
persistenceProbe.getBehaviorTestKit();
+
+ testkit
+ .runAskWithStatus(
+ Done.class, replyTo -> new
AccountEntity.Withdraw(BigDecimal.valueOf(110), replyTo))
+ .expectErrorMessage("not enough funds to withdraw 110");
+
+ assertFalse(persistenceProbe.getEventProbe().hasEffects());
+ }
+
+ // #test
+ private PersistenceProbeBehavior<
+ AccountEntity.Command, AccountEntity.Event, AccountEntity.Account>
+ emptyAccount() {
+ return
+ // #persistenceProbe-behavior
+ PersistenceProbeBehavior.fromEventSourced(
+ AccountEntity.create("1", PersistenceId.of("Account", "1")),
+ null, // use the initial state
+ 0 // initial sequence number
+ );
+ // #persistenceProbe-behavior
+ }
+
+ private PersistenceProbeBehavior<
+ AccountEntity.Command, AccountEntity.Event, AccountEntity.Account>
+ openedAccount() {
+ return
+ // #persistenceProbe-behavior-provided-state
+ PersistenceProbeBehavior.fromEventSourced(
+ AccountEntity.create("1", PersistenceId.of("Account", "1")),
+ new AccountEntity.EmptyAccount()
+ .openedAccount(), // duplicate the event handler for
AccountCreated on an EmptyAccount
+ 1 // assume that CreateAccount was the first command
+ );
+ // #persistenceProbe-behavior-provided-state
+ }
+
+ private PersistenceProbeBehavior<
+ AccountEntity.Command, AccountEntity.Event, AccountEntity.Account>
+ accountWithBalance(BigDecimal balance) {
+ return PersistenceProbeBehavior.fromEventSourced(
+ AccountEntity.create("1", PersistenceId.of("Account", "1")),
+ new AccountEntity.OpenedAccount(balance),
+ 2);
+ }
+ // #test
}
// #test
diff --git
a/cluster-sharding-typed/src/test/java/jdocs/org/apache/pekko/cluster/sharding/typed/HelloWorldPersistentEntityExample.java
b/cluster-sharding-typed/src/test/java/jdocs/org/apache/pekko/cluster/sharding/typed/HelloWorldPersistentEntityExample.java
index 0820b68dda..3a386263aa 100644
---
a/cluster-sharding-typed/src/test/java/jdocs/org/apache/pekko/cluster/sharding/typed/HelloWorldPersistentEntityExample.java
+++
b/cluster-sharding-typed/src/test/java/jdocs/org/apache/pekko/cluster/sharding/typed/HelloWorldPersistentEntityExample.java
@@ -38,8 +38,8 @@ import
org.apache.pekko.cluster.sharding.typed.javadsl.EntityRef;
import org.apache.pekko.cluster.sharding.typed.javadsl.Entity;
import org.apache.pekko.persistence.typed.javadsl.EventSourcedBehavior;
import org.apache.pekko.serialization.jackson.CborSerializable;
-import org.apache.pekko.util.Timeout;
import com.fasterxml.jackson.annotation.JsonCreator;
+
// #persistent-entity-usage-import
public class HelloWorldPersistentEntityExample {
@@ -76,6 +76,7 @@ public class HelloWorldPersistentEntityExample {
return result.thenApply(greeting -> greeting.numberOfPeople);
}
}
+
// #persistent-entity-usage
// #persistent-entity
diff --git
a/cluster-sharding-typed/src/test/java/jdocs/org/apache/pekko/cluster/sharding/typed/ShardingCompileOnlyTest.java
b/cluster-sharding-typed/src/test/java/jdocs/org/apache/pekko/cluster/sharding/typed/ShardingCompileOnlyTest.java
index a6a0db70ba..6ea19ac6af 100644
---
a/cluster-sharding-typed/src/test/java/jdocs/org/apache/pekko/cluster/sharding/typed/ShardingCompileOnlyTest.java
+++
b/cluster-sharding-typed/src/test/java/jdocs/org/apache/pekko/cluster/sharding/typed/ShardingCompileOnlyTest.java
@@ -95,6 +95,7 @@ interface ShardingCompileOnlyTest {
return this;
}
}
+
// #counter
// #counter-passivate
@@ -175,6 +176,7 @@ interface ShardingCompileOnlyTest {
return Behaviors.stopped();
}
}
+
// #counter-passivate
public static void initPassivateExample() {
diff --git
a/cluster-typed/src/test/java/jdocs/org/apache/pekko/cluster/typed/SingletonCompileOnlyTest.java
b/cluster-typed/src/test/java/jdocs/org/apache/pekko/cluster/typed/SingletonCompileOnlyTest.java
index 3b3f6831dd..3a2519563a 100644
---
a/cluster-typed/src/test/java/jdocs/org/apache/pekko/cluster/typed/SingletonCompileOnlyTest.java
+++
b/cluster-typed/src/test/java/jdocs/org/apache/pekko/cluster/typed/SingletonCompileOnlyTest.java
@@ -85,6 +85,7 @@ public interface SingletonCompileOnlyTest {
return this;
}
}
+
// #counter
ActorSystem system = ActorSystem.create(Behaviors.empty(),
"SingletonExample");
diff --git a/docs/src/test/java/jdocs/actor/ActorDocTest.java
b/docs/src/test/java/jdocs/actor/ActorDocTest.java
index 4cac762e6f..d6f8e51ea4 100644
--- a/docs/src/test/java/jdocs/actor/ActorDocTest.java
+++ b/docs/src/test/java/jdocs/actor/ActorDocTest.java
@@ -58,6 +58,7 @@ import java.util.concurrent.CompletionStage;
// #import-gracefulStop
// #import-terminated
import org.apache.pekko.actor.Terminated;
+
// #import-terminated
public class ActorDocTest extends AbstractJavaTest {
@@ -94,6 +95,7 @@ public class ActorDocTest extends AbstractJavaTest {
}
// #plus-some-behavior
}
+
// #context-actorOf
public static class SomeActor extends AbstractActor {
@@ -136,6 +138,7 @@ public class ActorDocTest extends AbstractJavaTest {
// actual work
}
}
+
// #well-structured
public
@@ -168,6 +171,7 @@ public class ActorDocTest extends AbstractJavaTest {
// actual work
}
}
+
// #optimized
public static class ActorWithArgs extends AbstractActor {
@@ -223,6 +227,7 @@ public class ActorDocTest extends AbstractJavaTest {
static class SomeOtherActor extends AbstractActor {
// Props(new DemoActor(42)) would not be safe
ActorRef demoActor = getContext().actorOf(DemoActor.props(42), "demo");
+
// ...
// #props-factory
@Override
@@ -231,6 +236,7 @@ public class ActorDocTest extends AbstractJavaTest {
}
// #props-factory
}
+
// #props-factory
public
@@ -260,6 +266,7 @@ public class ActorDocTest extends AbstractJavaTest {
.build();
}
}
+
// #messages-in-companion
public static class LifecycleMethods extends AbstractActor {
@@ -307,6 +314,7 @@ public class ActorDocTest extends AbstractJavaTest {
public void preStart() {
target = getContext().actorOf(Props.create(MyActor.class, "target"));
}
+
// #preStart
// #postStop
@Override
@@ -324,6 +332,7 @@ public class ActorDocTest extends AbstractJavaTest {
target = null;
// #clean-up-some-resources
}
+
// #postStop
// compilation test only
@@ -410,6 +419,7 @@ public class ActorDocTest extends AbstractJavaTest {
.build();
}
}
+
// #gracefulStop-actor
@Test
@@ -477,6 +487,7 @@ public class ActorDocTest extends AbstractJavaTest {
system.terminate();
}
}
+
// #swapper
@Test
@@ -549,6 +560,7 @@ public class ActorDocTest extends AbstractJavaTest {
static class ReceiveTimeoutActor extends AbstractActor {
// #receive-timeout
ActorRef target = getContext().getSystem().deadLetters();
+
// #receive-timeout
public ReceiveTimeoutActor() {
// To set an initial delay
@@ -580,6 +592,7 @@ public class ActorDocTest extends AbstractJavaTest {
.build();
}
}
+
// #receive-timeout
@Test
@@ -678,6 +691,7 @@ public class ActorDocTest extends AbstractJavaTest {
.build();
}
}
+
// #hot-swap-actor
@Test
@@ -730,6 +744,7 @@ public class ActorDocTest extends AbstractJavaTest {
.build();
}
}
+
// #stash
@Test
@@ -765,6 +780,7 @@ public class ActorDocTest extends AbstractJavaTest {
.build();
}
}
+
// #watch
@Test
@@ -816,6 +832,7 @@ public class ActorDocTest extends AbstractJavaTest {
.build();
}
}
+
// #identify
@Test
diff --git a/docs/src/test/java/jdocs/actor/ByteBufferSerializerDocTest.java
b/docs/src/test/java/jdocs/actor/ByteBufferSerializerDocTest.java
index 7e5b6f9762..474054f5b7 100644
--- a/docs/src/test/java/jdocs/actor/ByteBufferSerializerDocTest.java
+++ b/docs/src/test/java/jdocs/actor/ByteBufferSerializerDocTest.java
@@ -64,6 +64,7 @@ public class ByteBufferSerializerDocTest {
return null;
}
}
+
// #bytebufserializer-with-manifest
static class OnlyForDocInclude {
diff --git a/docs/src/test/java/jdocs/actor/DependencyInjectionDocTest.java
b/docs/src/test/java/jdocs/actor/DependencyInjectionDocTest.java
index 7f11da7192..682314f4d7 100644
--- a/docs/src/test/java/jdocs/actor/DependencyInjectionDocTest.java
+++ b/docs/src/test/java/jdocs/actor/DependencyInjectionDocTest.java
@@ -27,6 +27,7 @@ import org.apache.pekko.actor.Props;
// #import
import org.apache.pekko.actor.Actor;
import org.apache.pekko.actor.IndirectActorProducer;
+
// #import
public class DependencyInjectionDocTest extends AbstractJavaTest {
@@ -93,6 +94,7 @@ public class DependencyInjectionDocTest extends
AbstractJavaTest {
return result;
}
}
+
// #creating-indirectly
@Test
diff --git a/docs/src/test/java/jdocs/actor/SchedulerDocTest.java
b/docs/src/test/java/jdocs/actor/SchedulerDocTest.java
index 0fa606f104..b5b654e58b 100644
--- a/docs/src/test/java/jdocs/actor/SchedulerDocTest.java
+++ b/docs/src/test/java/jdocs/actor/SchedulerDocTest.java
@@ -29,8 +29,6 @@ import org.apache.pekko.actor.ActorSystem;
import org.apache.pekko.testkit.PekkoSpec;
import org.apache.pekko.testkit.PekkoJUnitJupiterActorSystemResource;
import org.junit.jupiter.api.extension.RegisterExtension;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
public class SchedulerDocTest extends AbstractJavaTest {
diff --git a/docs/src/test/java/jdocs/actor/fsm/Buncher.java
b/docs/src/test/java/jdocs/actor/fsm/Buncher.java
index 470e5a1d01..54acf9a7f4 100644
--- a/docs/src/test/java/jdocs/actor/fsm/Buncher.java
+++ b/docs/src/test/java/jdocs/actor/fsm/Buncher.java
@@ -27,6 +27,7 @@ import java.util.List;
import org.apache.pekko.actor.AbstractFSM;
import org.apache.pekko.actor.ActorRef;
import org.apache.pekko.japi.pf.UnitMatch;
+
// #simple-imports
// #simple-fsm
diff --git
a/docs/src/test/java/jdocs/actor/typed/CoordinatedActorShutdownTest.java
b/docs/src/test/java/jdocs/actor/typed/CoordinatedActorShutdownTest.java
index 141a6c6817..c3079d3b23 100644
--- a/docs/src/test/java/jdocs/actor/typed/CoordinatedActorShutdownTest.java
+++ b/docs/src/test/java/jdocs/actor/typed/CoordinatedActorShutdownTest.java
@@ -44,6 +44,7 @@ public class CoordinatedActorShutdownTest {
this.replyTo = replyTo;
}
}
+
// #coordinated-shutdown-addTask
public static Behavior<Messages> create() {
diff --git
a/docs/src/test/java/jdocs/cluster/singleton/ClusterSingletonSupervision.java
b/docs/src/test/java/jdocs/cluster/singleton/ClusterSingletonSupervision.java
index a9ae8cb606..1522c11c7b 100644
---
a/docs/src/test/java/jdocs/cluster/singleton/ClusterSingletonSupervision.java
+++
b/docs/src/test/java/jdocs/cluster/singleton/ClusterSingletonSupervision.java
@@ -23,6 +23,7 @@ import org.apache.pekko.actor.PoisonPill;
import org.apache.pekko.actor.Props;
import org.apache.pekko.cluster.singleton.ClusterSingletonManager;
import org.apache.pekko.cluster.singleton.ClusterSingletonManagerSettings;
+
// #singleton-supervisor-actor-usage-imports
abstract class ClusterSingletonSupervision extends AbstractActor {
diff --git a/docs/src/test/java/jdocs/dispatcher/DispatcherDocTest.java
b/docs/src/test/java/jdocs/dispatcher/DispatcherDocTest.java
index 248dd80b5e..37ed490ef2 100644
--- a/docs/src/test/java/jdocs/dispatcher/DispatcherDocTest.java
+++ b/docs/src/test/java/jdocs/dispatcher/DispatcherDocTest.java
@@ -244,11 +244,13 @@ public class DispatcherDocTest extends AbstractJavaTest {
});
}
}
+
// #prio-mailbox
public
// #control-aware-mailbox-messages
static class MyControlMessage implements ControlMessage {}
+
// #control-aware-mailbox-messages
@Test
@@ -269,6 +271,7 @@ public class DispatcherDocTest extends AbstractJavaTest {
// #require-mailbox-on-actor
// ...
}
+
// #require-mailbox-on-actor
@Test
diff --git a/docs/src/test/java/jdocs/event/EventBusDocTest.java
b/docs/src/test/java/jdocs/event/EventBusDocTest.java
index bec9602ae7..3b32f32524 100644
--- a/docs/src/test/java/jdocs/event/EventBusDocTest.java
+++ b/docs/src/test/java/jdocs/event/EventBusDocTest.java
@@ -145,6 +145,7 @@ public class EventBusDocTest extends AbstractJavaTest {
return 128;
}
}
+
// #lookup-bus
public
@@ -191,6 +192,7 @@ public class EventBusDocTest extends AbstractJavaTest {
subscriber.tell(event.payload, ActorRef.noSender());
}
}
+
// #subchannel-bus
public
@@ -228,6 +230,7 @@ public class EventBusDocTest extends AbstractJavaTest {
subscriber.tell(event, ActorRef.noSender());
}
}
+
// #scanning-bus
public
@@ -266,6 +269,7 @@ public class EventBusDocTest extends AbstractJavaTest {
return 128;
}
}
+
// #actor-bus
@RegisterExtension
diff --git a/docs/src/test/java/jdocs/event/LoggingDocTest.java
b/docs/src/test/java/jdocs/event/LoggingDocTest.java
index 1b7e7eae07..9a7f270282 100644
--- a/docs/src/test/java/jdocs/event/LoggingDocTest.java
+++ b/docs/src/test/java/jdocs/event/LoggingDocTest.java
@@ -43,6 +43,7 @@ import java.util.Map;
// #imports-deadletter
import org.apache.pekko.actor.ActorRef;
import org.apache.pekko.actor.ActorSystem;
+
// #imports-deadletter
public class LoggingDocTest extends AbstractJavaTest {
@@ -105,6 +106,7 @@ public class LoggingDocTest extends AbstractJavaTest {
.build();
}
}
+
// #superclass-subscription-eventstream
@Test
@@ -251,6 +253,7 @@ public class LoggingDocTest extends AbstractJavaTest {
.build();
}
}
+
// #my-event-listener
public
diff --git a/docs/src/test/java/jdocs/extension/SettingsExtensionDocTest.java
b/docs/src/test/java/jdocs/extension/SettingsExtensionDocTest.java
index 86cfc70bfd..2d01eab44b 100644
--- a/docs/src/test/java/jdocs/extension/SettingsExtensionDocTest.java
+++ b/docs/src/test/java/jdocs/extension/SettingsExtensionDocTest.java
@@ -85,6 +85,7 @@ public class SettingsExtensionDocTest extends
AbstractJavaTest {
}
// #extension-usage-actor
}
+
// #extension-usage-actor
public static class Connection {}
diff --git a/docs/src/test/java/jdocs/future/FutureDocTest.java
b/docs/src/test/java/jdocs/future/FutureDocTest.java
index 4e15109ade..5edc99a59a 100644
--- a/docs/src/test/java/jdocs/future/FutureDocTest.java
+++ b/docs/src/test/java/jdocs/future/FutureDocTest.java
@@ -47,34 +47,36 @@ public class FutureDocTest extends AbstractJavaTest {
@Test
@SuppressWarnings("deprecation")
public void useAfter() {
- Assertions.assertThrows(IllegalStateException.class, () -> {
- // #after
- CompletionStage<String> failWithException =
- CompletableFuture.supplyAsync(
- () -> {
- throw new IllegalStateException("OHNOES1");
- });
- CompletionStage<String> delayed =
- Patterns.after(Duration.ofMillis(200), system, () ->
failWithException);
- // #after
- CompletionStage<String> future =
- CompletableFuture.supplyAsync(
- () -> {
- try {
- Thread.sleep(1000);
- } catch (Throwable ex) {
- // ignore
- }
- return "foo";
- });
- CompletionStage<String> result =
- CompletionStages.firstCompletedOf(Arrays.asList(future, delayed));
- try {
- result.toCompletableFuture().get(2, SECONDS);
- } catch (Throwable ex) {
- throw (Exception) ex.getCause();
- }
- });
+ Assertions.assertThrows(
+ IllegalStateException.class,
+ () -> {
+ // #after
+ CompletionStage<String> failWithException =
+ CompletableFuture.supplyAsync(
+ () -> {
+ throw new IllegalStateException("OHNOES1");
+ });
+ CompletionStage<String> delayed =
+ Patterns.after(Duration.ofMillis(200), system, () ->
failWithException);
+ // #after
+ CompletionStage<String> future =
+ CompletableFuture.supplyAsync(
+ () -> {
+ try {
+ Thread.sleep(1000);
+ } catch (Throwable ex) {
+ // ignore
+ }
+ return "foo";
+ });
+ CompletionStage<String> result =
+ CompletionStages.firstCompletedOf(Arrays.asList(future,
delayed));
+ try {
+ result.toCompletableFuture().get(2, SECONDS);
+ } catch (Throwable ex) {
+ throw (Exception) ex.getCause();
+ }
+ });
}
@Test
@@ -102,21 +104,21 @@ public class FutureDocTest extends AbstractJavaTest {
retriedFuture.toCompletableFuture().get(2, SECONDS);
}
- @Test
- public void useRetryWithPredicateWithIntFunction() throws Exception {
- // #retry
- Callable<CompletionStage<String>> attempt = () ->
CompletableFuture.completedFuture("test");
-
- CompletionStage<String> retriedFuture =
- Patterns.retry(
- attempt,
- (notUsed, e) -> e != null,
- 3,
- current -> Optional.of(java.time.Duration.ofMillis(200)),
- system.classicSystem().scheduler(),
- system.executionContext());
- // #retry
-
- retriedFuture.toCompletableFuture().get(2, SECONDS);
- }
+ @Test
+ public void useRetryWithPredicateWithIntFunction() throws Exception {
+ // #retry
+ Callable<CompletionStage<String>> attempt = () ->
CompletableFuture.completedFuture("test");
+
+ CompletionStage<String> retriedFuture =
+ Patterns.retry(
+ attempt,
+ (notUsed, e) -> e != null,
+ 3,
+ current -> Optional.of(java.time.Duration.ofMillis(200)),
+ system.classicSystem().scheduler(),
+ system.executionContext());
+ // #retry
+
+ retriedFuture.toCompletableFuture().get(2, SECONDS);
+ }
}
diff --git a/docs/src/test/java/jdocs/io/UdpConnectedDocTest.java
b/docs/src/test/java/jdocs/io/UdpConnectedDocTest.java
index 6cc0216645..acd68034d7 100644
--- a/docs/src/test/java/jdocs/io/UdpConnectedDocTest.java
+++ b/docs/src/test/java/jdocs/io/UdpConnectedDocTest.java
@@ -33,7 +33,6 @@ import org.apache.pekko.util.ByteString;
// #imports
import org.junit.jupiter.api.Test;
-
public class UdpConnectedDocTest {
public static class Demo extends AbstractActor {
diff --git a/docs/src/test/java/jdocs/io/japi/IODocTest.java
b/docs/src/test/java/jdocs/io/japi/IODocTest.java
index a6c7755069..a39d238f59 100644
--- a/docs/src/test/java/jdocs/io/japi/IODocTest.java
+++ b/docs/src/test/java/jdocs/io/japi/IODocTest.java
@@ -86,6 +86,7 @@ public class IODocTest extends AbstractJavaTest {
.build();
}
}
+
// #server
public
@@ -109,6 +110,7 @@ public class IODocTest extends AbstractJavaTest {
.build();
}
}
+
// #simplistic-handler
public
@@ -179,6 +181,7 @@ public class IODocTest extends AbstractJavaTest {
.build();
}
}
+
// #client
@RegisterExtension
diff --git
a/docs/src/test/java/jdocs/persistence/testkit/PersistenceInitTest.java
b/docs/src/test/java/jdocs/persistence/testkit/PersistenceInitTest.java
index 8acc1a15dd..0aa453b487 100644
--- a/docs/src/test/java/jdocs/persistence/testkit/PersistenceInitTest.java
+++ b/docs/src/test/java/jdocs/persistence/testkit/PersistenceInitTest.java
@@ -38,16 +38,19 @@ import java.util.concurrent.TimeUnit;
@ExtendWith(TestKitJUnitJupiterExtension.class)
public class PersistenceInitTest extends AbstractJavaTest {
@JUnitJupiterTestKit
- public ActorTestKit testKit = new JUnitJupiterTestKitBuilder()
- .withCustomConfig(ConfigFactory.parseString(
- "pekko.persistence.journal.plugin =
\"pekko.persistence.journal.inmem\" \n"
- + "pekko.persistence.journal.inmem.test-serialization =
on \n"
- + "pekko.persistence.snapshot-store.plugin =
\"pekko.persistence.snapshot-store.local\" \n"
- + "pekko.persistence.snapshot-store.local.dir =
\"target/snapshot-"
- + UUID.randomUUID().toString()
- + "\" \n")
- .withFallback(ConfigFactory.defaultApplication()))
- .build();
+ public ActorTestKit testKit =
+ new JUnitJupiterTestKitBuilder()
+ .withCustomConfig(
+ ConfigFactory.parseString(
+ "pekko.persistence.journal.plugin =
\"pekko.persistence.journal.inmem\" \n"
+ +
"pekko.persistence.journal.inmem.test-serialization = on \n"
+ + "pekko.persistence.snapshot-store.plugin ="
+ + " \"pekko.persistence.snapshot-store.local\" \n"
+ + "pekko.persistence.snapshot-store.local.dir =
\"target/snapshot-"
+ + UUID.randomUUID().toString()
+ + "\" \n")
+ .withFallback(ConfigFactory.defaultApplication()))
+ .build();
@Test
public void testInit() throws Exception {
diff --git
a/docs/src/test/java/jdocs/routing/ConsistentHashingRouterDocTest.java
b/docs/src/test/java/jdocs/routing/ConsistentHashingRouterDocTest.java
index 00de90656a..d66a994952 100644
--- a/docs/src/test/java/jdocs/routing/ConsistentHashingRouterDocTest.java
+++ b/docs/src/test/java/jdocs/routing/ConsistentHashingRouterDocTest.java
@@ -37,6 +37,7 @@ import org.apache.pekko.actor.ActorRef;
import org.apache.pekko.routing.ConsistentHashingPool;
import org.apache.pekko.routing.ConsistentHashingRouter.ConsistentHashMapper;
import
org.apache.pekko.routing.ConsistentHashingRouter.ConsistentHashableEnvelope;
+
// #imports2
public class ConsistentHashingRouterDocTest extends AbstractJavaTest {
@@ -121,6 +122,7 @@ public class ConsistentHashingRouterDocTest extends
AbstractJavaTest {
public
// #cache-actor
static final String NOT_FOUND = "NOT_FOUND";
+
// #cache-actor
@Test
diff --git a/docs/src/test/java/jdocs/routing/CustomRouterDocTest.java
b/docs/src/test/java/jdocs/routing/CustomRouterDocTest.java
index 02fa549b61..1387f31958 100644
--- a/docs/src/test/java/jdocs/routing/CustomRouterDocTest.java
+++ b/docs/src/test/java/jdocs/routing/CustomRouterDocTest.java
@@ -39,7 +39,6 @@ import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.api.Test;
import scala.collection.immutable.IndexedSeq;
-
public class CustomRouterDocTest extends AbstractJavaTest {
@RegisterExtension
diff --git a/docs/src/test/java/jdocs/routing/RouterDocTest.java
b/docs/src/test/java/jdocs/routing/RouterDocTest.java
index 6bb67194ef..c375fb85d2 100644
--- a/docs/src/test/java/jdocs/routing/RouterDocTest.java
+++ b/docs/src/test/java/jdocs/routing/RouterDocTest.java
@@ -173,6 +173,7 @@ public class RouterDocTest extends AbstractJavaTest {
getContext().actorOf(Props.create(Worker.class), "w2");
getContext().actorOf(Props.create(Worker.class), "w3");
}
+
// ...
// #create-worker-actors
@@ -357,6 +358,7 @@ public class RouterDocTest extends AbstractJavaTest {
ActorRef router31 =
getContext()
.actorOf(FromConfig.getInstance().props(Props.create(Worker.class)),
"router31");
+
// #optimal-size-exploring-resize-pool
@Override
diff --git a/docs/src/test/java/jdocs/serialization/SerializationDocTest.java
b/docs/src/test/java/jdocs/serialization/SerializationDocTest.java
index 937d5bc802..df3ae8cf17 100644
--- a/docs/src/test/java/jdocs/serialization/SerializationDocTest.java
+++ b/docs/src/test/java/jdocs/serialization/SerializationDocTest.java
@@ -71,6 +71,7 @@ public class SerializationDocTest {
// #...
}
}
+
// #my-own-serializer
static class Customer {
@@ -131,6 +132,7 @@ public class SerializationDocTest {
else throw new IllegalArgumentException("Unknown manifest: " + manifest);
}
}
+
// #my-own-serializer2
@Test
diff --git a/docs/src/test/java/jdocs/sharding/ClusterShardingTest.java
b/docs/src/test/java/jdocs/sharding/ClusterShardingTest.java
index 6b7305b69b..7db1c69131 100644
--- a/docs/src/test/java/jdocs/sharding/ClusterShardingTest.java
+++ b/docs/src/test/java/jdocs/sharding/ClusterShardingTest.java
@@ -56,15 +56,13 @@ public class ClusterShardingTest {
public String entityId(Object message) {
if (message instanceof Counter.EntityEnvelope envelope)
return String.valueOf(envelope.id);
- else if (message instanceof Counter.Get get)
- return String.valueOf(get.counterId);
+ else if (message instanceof Counter.Get get) return
String.valueOf(get.counterId);
else return null;
}
@Override
public Object entityMessage(Object message) {
- if (message instanceof Counter.EntityEnvelope envelope)
- return envelope.payload;
+ if (message instanceof Counter.EntityEnvelope envelope) return
envelope.payload;
else return message;
}
@@ -125,15 +123,13 @@ public class ClusterShardingTest {
public String entityId(Object message) {
if (message instanceof Counter.EntityEnvelope envelope)
return String.valueOf(envelope.id);
- else if (message instanceof Counter.Get get)
- return String.valueOf(get.counterId);
+ else if (message instanceof Counter.Get get) return
String.valueOf(get.counterId);
else return null;
}
@Override
public Object entityMessage(Object message) {
- if (message instanceof Counter.EntityEnvelope envelope)
- return envelope.payload;
+ if (message instanceof Counter.EntityEnvelope envelope) return
envelope.payload;
else return message;
}
diff --git a/docs/src/test/java/jdocs/stream/operators/BroadcastDocExample.java
b/docs/src/test/java/jdocs/stream/operators/BroadcastDocExample.java
index f7c92c7aba..b7ab096f62 100644
--- a/docs/src/test/java/jdocs/stream/operators/BroadcastDocExample.java
+++ b/docs/src/test/java/jdocs/stream/operators/BroadcastDocExample.java
@@ -28,6 +28,7 @@ import org.apache.pekko.stream.javadsl.RunnableGraph;
import org.apache.pekko.stream.javadsl.Sink;
import org.apache.pekko.stream.javadsl.Source;
import java.util.concurrent.CompletionStage;
+
// #import
public class BroadcastDocExample {
diff --git
a/docs/src/test/java/jdocs/stream/operators/MergeSequenceDocExample.java
b/docs/src/test/java/jdocs/stream/operators/MergeSequenceDocExample.java
index f94d0ebd27..b0fc3fdf2e 100644
--- a/docs/src/test/java/jdocs/stream/operators/MergeSequenceDocExample.java
+++ b/docs/src/test/java/jdocs/stream/operators/MergeSequenceDocExample.java
@@ -28,6 +28,7 @@ import org.apache.pekko.stream.javadsl.Partition;
import org.apache.pekko.stream.javadsl.RunnableGraph;
import org.apache.pekko.stream.javadsl.Sink;
import org.apache.pekko.stream.javadsl.Source;
+
// #import
public class MergeSequenceDocExample {
diff --git a/docs/src/test/java/jdocs/stream/operators/PartitionDocExample.java
b/docs/src/test/java/jdocs/stream/operators/PartitionDocExample.java
index 609481215c..395d2bab36 100644
--- a/docs/src/test/java/jdocs/stream/operators/PartitionDocExample.java
+++ b/docs/src/test/java/jdocs/stream/operators/PartitionDocExample.java
@@ -26,6 +26,7 @@ import org.apache.pekko.stream.javadsl.Partition;
import org.apache.pekko.stream.javadsl.RunnableGraph;
import org.apache.pekko.stream.javadsl.Sink;
import org.apache.pekko.stream.javadsl.Source;
+
// #import
public class PartitionDocExample {
diff --git a/docs/src/test/java/jdocs/stream/operators/SourceOrFlow.java
b/docs/src/test/java/jdocs/stream/operators/SourceOrFlow.java
index 1a46e7fe1d..333d27e9f8 100644
--- a/docs/src/test/java/jdocs/stream/operators/SourceOrFlow.java
+++ b/docs/src/test/java/jdocs/stream/operators/SourceOrFlow.java
@@ -327,6 +327,7 @@ class SourceOrFlow {
CompletionStage<Integer> asyncFunction(int acc, int next) {
return CompletableFuture.supplyAsync(() -> acc + next);
}
+
// #scan-async
void scanAsyncExample() {
@@ -355,6 +356,7 @@ class SourceOrFlow {
return new Summed(this.el + other.el);
}
}
+
// #conflateWithSeed-type
void conflateWithSeedExample() {
@@ -385,6 +387,7 @@ class SourceOrFlow {
this.id = id;
}
}
+
// #collect-elements
void collectExample() {
@@ -516,6 +519,7 @@ class SourceOrFlow {
return new Histogram(low, high + 1L);
}
}
+
// #fold
// #foldAsync
@@ -528,6 +532,7 @@ class SourceOrFlow {
}
// #fold
}
+
// #fold // #foldAsync
void foldExample() {
@@ -597,8 +602,8 @@ class SourceOrFlow {
Source<String, NotUsed> words =
Source.from(
Arrays.asList(
- ("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed
do eiusmod tempor incididunt "
- + "ut labore et dolore magna aliqua")
+ ("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed
do eiusmod tempor"
+ + " incididunt ut labore et dolore magna aliqua")
.split(" ")));
Source<String, NotUsed> longWords = words.filter(w -> w.length() > 6);
@@ -616,8 +621,8 @@ class SourceOrFlow {
Source<String, NotUsed> words =
Source.from(
Arrays.asList(
- ("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed
do eiusmod tempor incididunt "
- + "ut labore et dolore magna aliqua")
+ ("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed
do eiusmod tempor"
+ + " incididunt ut labore et dolore magna aliqua")
.split(" ")));
Source<String, NotUsed> longWords = words.filterNot(w -> w.length() <= 6);
diff --git
a/docs/src/test/java/jdocs/typed/tutorial_1/ActorHierarchyExperiments.java
b/docs/src/test/java/jdocs/typed/tutorial_1/ActorHierarchyExperiments.java
index 60b85d1e49..6d41163e88 100644
--- a/docs/src/test/java/jdocs/typed/tutorial_1/ActorHierarchyExperiments.java
+++ b/docs/src/test/java/jdocs/typed/tutorial_1/ActorHierarchyExperiments.java
@@ -54,6 +54,7 @@ class PrintMyActorRefActor extends AbstractBehavior<String> {
return this;
}
}
+
// #print-refs
// #start-stop
@@ -105,6 +106,7 @@ class StartStopActor2 extends AbstractBehavior<String> {
return this;
}
}
+
// #start-stop
// #supervise
@@ -170,6 +172,7 @@ class SupervisedActor extends AbstractBehavior<String> {
return this;
}
}
+
// #supervise
// #print-refs
@@ -204,6 +207,7 @@ public class ActorHierarchyExperiments {
testSystem.tell("start");
}
}
+
// #print-refs
class StartingActorHierarchyActors {
diff --git
a/persistence-typed/src/test/java/jdocs/org/apache/pekko/persistence/typed/BasicPersistentBehaviorTest.java
b/persistence-typed/src/test/java/jdocs/org/apache/pekko/persistence/typed/BasicPersistentBehaviorTest.java
index 79f16eb8d2..f336d93943 100644
---
a/persistence-typed/src/test/java/jdocs/org/apache/pekko/persistence/typed/BasicPersistentBehaviorTest.java
+++
b/persistence-typed/src/test/java/jdocs/org/apache/pekko/persistence/typed/BasicPersistentBehaviorTest.java
@@ -121,6 +121,7 @@ public class BasicPersistentBehaviorTest {
public enum Cleared implements Event {
INSTANCE
}
+
// #command
// #state
@@ -143,6 +144,7 @@ public class BasicPersistentBehaviorTest {
return new State(latest);
}
}
+
// #state
// #behavior
@@ -170,6 +172,7 @@ public class BasicPersistentBehaviorTest {
.onCommand(Clear.class, command ->
Effect().persist(Cleared.INSTANCE))
.build();
}
+
// #command-handler
// #event-handler
@@ -306,6 +309,7 @@ public class BasicPersistentBehaviorTest {
interface Event {}
public static class State {}
+
// #supervision
public static Behavior<Command> create(PersistenceId persistenceId) {
@@ -352,6 +356,7 @@ public class BasicPersistentBehaviorTest {
})
.build();
}
+
// #recovery
// #recovery-disabled
@@ -359,6 +364,7 @@ public class BasicPersistentBehaviorTest {
public Recovery recovery() {
return Recovery.disabled();
}
+
// #recovery-disabled
// #tagging
@@ -388,6 +394,7 @@ public class BasicPersistentBehaviorTest {
interface Event {}
public static class State {}
+
// #wrapPersistentBehavior
public static Behavior<Command> create(PersistenceId persistenceId) {
@@ -429,6 +436,7 @@ public class BasicPersistentBehaviorTest {
public Optional<Integer> stashCapacity() {
return Optional.of(100);
}
+
// #custom-stash-buffer
// #wrapPersistentBehavior
@@ -525,6 +533,7 @@ public class BasicPersistentBehaviorTest {
public boolean shouldSnapshot(State state, Event event, long sequenceNr)
{
return event instanceof BookingCompleted;
}
+
// #snapshottingPredicate
// #retentionCriteria
@@ -532,6 +541,7 @@ public class BasicPersistentBehaviorTest {
public RetentionCriteria retentionCriteria() {
return RetentionCriteria.snapshotEvery(100, 2);
}
+
// #retentionCriteria
// #retentionCriteriaWithSignals
@@ -600,6 +610,7 @@ public class BasicPersistentBehaviorTest {
interface Event {}
public static class State {}
+
// #actor-context
public static Behavior<Command> create(PersistenceId persistenceId) {
diff --git
a/persistence-typed/src/test/java/jdocs/org/apache/pekko/persistence/typed/DurableStatePersistentBehaviorTest.java
b/persistence-typed/src/test/java/jdocs/org/apache/pekko/persistence/typed/DurableStatePersistentBehaviorTest.java
index eca52277de..d30deaf6c0 100644
---
a/persistence-typed/src/test/java/jdocs/org/apache/pekko/persistence/typed/DurableStatePersistentBehaviorTest.java
+++
b/persistence-typed/src/test/java/jdocs/org/apache/pekko/persistence/typed/DurableStatePersistentBehaviorTest.java
@@ -119,6 +119,7 @@ public class DurableStatePersistentBehaviorTest {
return value;
}
}
+
// #state
// #behavior
@@ -234,6 +235,7 @@ public class DurableStatePersistentBehaviorTest {
interface Command {}
public static class State {}
+
// #actor-context
public static Behavior<Command> create(PersistenceId persistenceId) {
@@ -279,6 +281,7 @@ public class DurableStatePersistentBehaviorTest {
interface Command {}
public static class State {}
+
// #supervision
public static Behavior<Command> create(PersistenceId persistenceId) {
@@ -327,6 +330,7 @@ public class DurableStatePersistentBehaviorTest {
interface Command {}
public static class State {}
+
// #wrapPersistentBehavior
public static Behavior<Command> create(PersistenceId persistenceId) {
diff --git a/project/plugins.sbt b/project/plugins.sbt
index efc9a459de..4fbd04fd9b 100644
--- a/project/plugins.sbt
+++ b/project/plugins.sbt
@@ -9,7 +9,7 @@
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.2.0")
-addSbtPlugin("com.github.sbt" % "sbt-java-formatter" % "0.11.0")
+addSbtPlugin("com.github.sbt" % "sbt-java-formatter" % "0.12.0")
addSbtPlugin("com.github.sbt.junit" % "sbt-jupiter-interface" % "0.19.0")
addSbtPlugin("com.lightbend.sbt" % "sbt-bill-of-materials" % "1.0.2")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.6.1")
diff --git
a/stream-tests/src/test/java/org/apache/pekko/stream/javadsl/TcpTest.java
b/stream-tests/src/test/java/org/apache/pekko/stream/javadsl/TcpTest.java
index 43000127de..b0b7d62ce5 100644
--- a/stream-tests/src/test/java/org/apache/pekko/stream/javadsl/TcpTest.java
+++ b/stream-tests/src/test/java/org/apache/pekko/stream/javadsl/TcpTest.java
@@ -49,7 +49,6 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
// #setting-up-ssl-engine
// imports
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]