Publish operations from InmemJournal (#28332)

* small feature that is useful for verifying that expected events were persisted
* doc example
* also enable serialization test config
This commit is contained in:
Patrik Nordwall 2020-01-13 09:46:43 +01:00 committed by GitHub
parent 4749b11be8
commit cdc45c128d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 177 additions and 10 deletions

View file

@ -31,6 +31,8 @@ Scala
Java
: @@snip [AccountExampleDocTest.java](/akka-cluster-sharding-typed/src/test/java/jdocs/akka/cluster/sharding/typed/AccountExampleDocTest.java) { #inmem-config }
The `test-serialization = on` configuration of the `InmemJournal` will verify that persisted events can be serialized and deserialized.
Optionally you can also configure a snapshot store. To enable the file based snapshot store you need to pass the
following configuration to the @scala[`ScalaTestWithActorTestKit`]@java[`TestKitJunitResource`].
@ -53,6 +55,16 @@ Java
Note that each test case is using a different `PersistenceId` to not interfere with each other.
The @apidoc[akka.persistence.journal.inmem.InmemJournal$] publishes `Write` and `Delete` operations to the
`eventStream`, which makes it possible to verify that the expected events have been emitted and stored by the
`EventSourcedBehavior`. You can subscribe to to the `eventStream` with a `TestProbe` like this:
Scala
: @@snip [AccountExampleDocSpec.scala](/akka-cluster-sharding-typed/src/test/scala/docs/akka/cluster/sharding/typed/AccountExampleDocSpec.scala) { #test-events }
Java
: @@snip [AccountExampleDocTest.java](/akka-cluster-sharding-typed/src/test/java/jdocs/akka/cluster/sharding/typed/AccountExampleDocTest.java) { #test-events }
## Integration testing
The in-memory journal and file based snapshot store can be used also for integration style testing of a single