Commit graph

51 commits

Author SHA1 Message Date
Johan Andrén
9fc3251a03 Update test and sample usages of ActorRef.? to .ask 2019-02-21 13:55:14 +01:00
Seth Tisue
fc23f03031 upgrade to latest ScalaTest (#26387)
stuff moved to a new package. you wouldn't expect that in a point
release, but they put type aliases in place so Scala users wouldn't
notice. but the change is visible to Java code.

the upgrade is not strictly necessary, but it would be convenient
for the Scala 2.13 community build to have this merged, so I don't
have to maintain these changes in our Akka fork
2019-02-17 19:45:39 +00:00
Johan Andrén
84e8e41193
Logger class for typed actors #25677
* Walk stack to figure out logger class
* User API for getting a customized logger
* API to set logger class, use in receptionists, auto-good-class for EventSourcedBehavior
2019-02-11 17:18:17 +01:00
Patrik Nordwall
794a8cc6ff Stashing in persistent behavior, #25717
* Effect.stash, Effect.thenUnstashAll
* unstash one at a time, and start with external stash if UnstashAll is in progress
* handle restarts
* handle PoisonPill
* fix PerformanceSpec, because now the internal stash is cleared if exception is thrown
* work with PoisonPill
2019-01-18 17:47:51 +01:00
Patrik Nordwall
b4fa591d64
Support stop or keep of child actors when parent is restarted, #25556
* stash messages and signals while waiting for children to be stopped
* handle watch of other actors
* exception from unstash
* exception from first setup
* merge RestartSupervisor and BackoffSupervisor
* API change: restartWithLimit => restart.withLimit
* remove unused PreStart
* docs
* move BubblingSample to separate class
* fix: fail after more than limit in restart.withLimit when deferred factory throws
* match case RestartOrBackoff instead
2019-01-17 16:48:22 +01:00
Patrik Nordwall
f4defb139b
use receiveOne instead of receiveMessageType, #25914
* use receiveOne instead of receiveMessageType, #25914

* when the type is the same as the probe's type

* formatting

* rename receiveOne to receiveMessage

* rename receiveN to receiveMessages

* have to use different name in javadsl so that became receiveSeveralMessages
2019-01-15 09:23:30 +01:00
hepin1989
998c5a9285 Formatting java codes with sbt-java-formatter. 2019-01-12 04:00:53 +08:00
Patrik Nordwall
19769e2a87 Cleanup Typed TestProbe implementation
* use a consistent api/impl technique
* _internal methods are not dilating
* add expectTerminated with default timeout
* FiniteDuration in awaitAssert
2019-01-10 11:34:29 +01:00
kerr
0848a5c02c Import akka.actor as untyped but not a. (#26079) 2019-01-07 14:45:51 +01:00
Martin Grotzke
f3b7d316b2 Document how to observe mocked behavior with typed ActorTestKit #26116 2019-01-02 15:30:55 +01:00
kerr
bdc90052aa Update headers from 2018 to 2019 once for all. (#26165)
* Add CopyrightHeader support for sbt-boilerplate plugin.
* Add CopyrightHeader support for `*.proto` files.
* Add regex match for both `–` and `-` for CopyrightHeader.
* Add CopyrightHeader support for sbt build files.
* Update copyright from 2018 to 2019.
2019-01-02 11:55:26 +01:00
Patrik Nordwall
5f409c17e0 clarify docs of ActorTestKit.stop, #24165 2018-12-21 12:53:18 +01:00
Michael Kholodov
220021b87f Akka-typed-testkit: Provides a way of stopping actors #24165
* Added ActorTestKit#stop method and corresponding tests.
* Added 'Stopping actors' section to the docs
* Stop actor now waits until the actor terminates.
2018-12-21 11:37:34 +01:00
Helena Edelson
d74426a255 Rename akka.actor.typed.ActorContext #25734 (#26146) 2018-12-21 11:17:26 +01:00
Helena Edelson
408fab3313
Fix compiler warnings in akka-remote, akka-actor-typed. (#26139)
Fix compiler warnings in akka-remote, akka-actor-typed. (#26139)
2018-12-20 09:10:54 -08:00
Christopher Batey
66fa541118
Make exception in Terminated explicit it is just for child termination (#25992)
* Remove exception from typed Terminated

This currently only works for direct child actors and breaks when using
typed supervision.

It could be re-introduced by supervision returning a new special
behavior that the actor adaper for failed with an exception.

* Try out keeping the terminated and adding a ChildTerminated subclass of Terminated

Some tests need updated will fix those if we decide this is better

* Fix duplicate logging + make it Terminated + ChildFailed
2018-12-06 17:49:25 +00:00
Patrik Nordwall
4966d5262e fix type bounds of expectMessageClass in javadsl in Typed 2018-12-06 14:52:38 +01:00
Patrik Nordwall
0d0a0e8018 fix javadsl awaitAssert in Typed, #25903
* returning null would result in retries until "timeout value is negative"
* use same implementation as in untyped
* real test
2018-12-06 14:52:38 +01:00
Patrik Nordwall
850a10443b support stop of TestProbe 2018-12-06 14:48:52 +01:00
Josep Prat
5ccfc12eb5 Add additional constructors for CapturedLogEvent (#26016)
As requested in PR #25907 - more constructors to cover more simple cases
2018-12-04 09:54:17 +01:00
Christopher Batey
629f462030 Fix 2.11 compilation
And avoid default params in a public api
2018-12-03 09:13:13 +00:00
Josep Prat
de02d5d6bd [ttk] Add access to logged events in BehaviorTestKit #25905
* [ttk] Add access to logged events in BehaviorTestKit #25905

`BehaviorTestKit` now has methods to:
 - Access to logged events
 - Clear all log events

Added section in docs explaining how to check for logs.

Note about the implementation: `CapturedLogEvent` was effectively private to akka. It uses `OptionVal` internally, this makes it impossible to be used from outside akka. To overcome this, I added some methods to translate it to the corresponding `Option` and `Optional`.

* Apply feedback

Clean up `CapturedLogEvent` by using only `Option` in public methods
Use `immutable.Seq` instead of plain `Seq`
2018-11-30 13:01:37 +01:00
Helena Edelson
e940643c12
Add receiveOne to TestProbe in Typed #25914 (#25994)
Add receiveOne to TestProbe in Typed (#25914)
2018-11-29 10:27:32 -08:00
Dale Wijnand
d48c82c247
Fix TestProbeImpl#receiveN_internal with the receiveOne change 2018-11-29 12:46:56 +00:00
Dale Wijnand
68b5fbb2ff Cleanups in typed TestProbe fishForMessage impl (#25863)
* Tighten MatchError handling in fishForMessage

Avoid a whole bunch of other code being accidentally handled.

Also it allows for the inner 'loop' method to be @tailrec (next commit).

* Guarantee match exhaustion in fishForMessage

... by introducing FishingOutcome.ContinueOutcome to the type hierarchy.

* Simplify some timeout calculation in fishForMessage

'timeout' is always finite, as it's a `FiniteDuration`, and, even if it
weren't, the calculation is safe for non-finite durations.

* Make fishForMessage's inner loop @tailrec!

Apparently @tailrec and try/catch (with a re-throw in the catch) don't
mix well.

* Avoid double handing of timeouts in fishForMessage

If 'newTimeout' is sub-zero, just loop again which will trigger the
other throw.

* Make receiveOne return Option[M] rather than nullable M

Avoid future users from forgetting to consider the null case, which
happened in fishForMessage_internal.

* Switch to pattern matching Options

* Cast properly

Thanks, type inferencer, for inferring Nothing there! o_O

* Make fish's PartialFunction convenience explicit

* Update the scaladsl fishForMessage Scaladocs

* Restore MatchError catching logic & docs

TIL partial functions aren't of class PartialFunction anymore, they're
lambda classes.

* Tweak assertFail so it can be used more

* Avoid name shadowing

... on request. (I <3 name shadowing)

* Fix formatting
2018-11-29 11:25:21 +01:00
Patrik Nordwall
42adfd781c
Merge pull request #25801 from akka/wip-25794-ClusterShardingSpec-patriknw
Hardening of typed./ClusterShardingSpec, #25794
2018-11-09 09:53:14 +01:00
Dale Wijnand
934a28ba5c Rename ActorContext#schedule with scheduleOnce (#25869) 2018-11-06 11:05:43 +01:00
Dale Wijnand
9941f7d800 Consistently bind ActorContext to 'context' in the docs (#25852)
* Consistently bind ActorContext to 'ctx' in the docs

... over the lesser uses 'context':

    $ rg 'Behavior[s]?.setup' akka-docs/src/test/scala/docs/actor/TypedActorDocSpec.scala akka-actor-typed-tests/ akka-actor-testkit-typed/ | rg ctx | wc -l
          59
    $ rg 'Behavior[s]?.setup' akka-docs/src/test/scala/docs/actor/TypedActorDocSpec.scala akka-actor-typed-tests/ akka-actor-testkit-typed/ | rg context | wc -l
           8
    $ rg 'Behavior[s]?.receive' akka-docs/src/test/scala/docs/actor/TypedActorDocSpec.scala akka-actor-typed-tests/ akka-actor-testkit-typed/ | rg ctx | wc -l
          66
    $ rg 'Behavior[s]?.receive' akka-docs/src/test/scala/docs/actor/TypedActorDocSpec.scala akka-actor-typed-tests/ akka-actor-testkit-typed/ | rg context | wc -l
           5

* Fix "variable ctx is already defined" warnings

* Replace ctx with context, in docs & doc snippets

    fastmod '\bctx\b' 'context' \
        akka-docs/src/main/paradox/typed
        akka-docs/src/test/scala/docs/actor/TypedActorDocSpec.scala \
        akka-actor-typed-tests/ \
        akka-actor-testkit-typed/ \

* Replace msg with message, in docs & doc snippets

    fastmod '\bmsg\b' 'message' \
        akka-docs/src/test/scala/docs/actor/TypedActorDocSpec.scala \
        akka-actor-typed-tests/ \
        akka-actor-testkit-typed/
        akka-docs/src/main/paradox/typed/

* Fix code alignment
2018-11-05 13:53:18 +00:00
Dale Wijnand
6a04731971 Dilation cleanups (#25861)
* Avoid calling asInstanceOf in dilated

* Fix the rounding in dilated for Java

* Delegate Java dilated to Scala dilated

* Import scala.concurrent.duration.Duration
2018-11-05 09:55:40 +00:00
kerr
fafc59b19d update headers to regular comment (#25807) 2018-10-29 05:19:37 -04:00
Patrik Nordwall
923a27cb60 Add receiveN to typed TestProbe
* had to use a different name in javadsl because TestProbeImpl extends both and
  it would conflict with different return types
2018-10-17 12:09:52 +02:00
Patrik Nordwall
bf4a6c37b4
Merge pull request #25577 from akka/getAnonymousChildInboxByActorRef
BehaviorTestKit: get child inbox by anonymous ActorRef
2018-10-17 11:41:22 +02:00
Mark Hammons
f32d6c5a68 Don't return Iterable(null) when Probe.fishForMessage times out (#25629)
* Fix for issue #25616

I haven't had a chance to test this, but it looks to me that this is the solution to issue #25616. 

My stacktrace in this issue is this: 
```
java.lang.NullPointerException
	at eu.phy_awaas.irods.typed.lockingsystem.IRODSLockManagerSpec.$anonfun$new$20(IRODSLockManagerSpec.scala:91)
	at akka.actor.testkit.typed.internal.TestProbeImpl.loop$1(TestProbeImpl.scala:189)
	at akka.actor.testkit.typed.internal.TestProbeImpl.loop$1(TestProbeImpl.scala:201)
	at akka.actor.testkit.typed.internal.TestProbeImpl.fishForMessage_internal(TestProbeImpl.scala:215)
	at akka.actor.testkit.typed.internal.TestProbeImpl.fishForMessage_internal(TestProbeImpl.scala:45)
	at akka.actor.testkit.typed.scaladsl.TestProbe.fishForMessage(TestProbe.scala:175)
	at akka.actor.testkit.typed.scaladsl.TestProbe.fishForMessage$(TestProbe.scala:174)
	at akka.actor.testkit.typed.internal.TestProbeImpl.fishForMessage(TestProbeImpl.scala:45)
	at akka.actor.testkit.typed.scaladsl.TestProbe.fishForMessage(TestProbe.scala:181)
	at akka.actor.testkit.typed.scaladsl.TestProbe.fishForMessage$(TestProbe.scala:180)
	at akka.actor.testkit.typed.internal.TestProbeImpl.fishForMessage(TestProbeImpl.scala:45)
	at eu.phy_awaas.irods.typed.lockingsystem.IRODSLockManagerSpec.$anonfun$new$18(IRODSLockManagerSpec.scala:88)
	at org.scalatest.OutcomeOf.outcomeOf(OutcomeOf.scala:85)
	at org.scalatest.OutcomeOf.outcomeOf$(OutcomeOf.scala:83)
	at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104)
	at org.scalatest.Transformer.apply(Transformer.scala:22)
	at org.scalatest.Transformer.apply(Transformer.scala:20)
	at org.scalatest.WordSpecLike$$anon$1.apply(WordSpecLike.scala:1078)
	at org.scalatest.TestSuite.withFixture(TestSuite.scala:196)
	at org.scalatest.TestSuite.withFixture$(TestSuite.scala:195)
	at org.scalatest.WordSpec.withFixture(WordSpec.scala:1881)
	at org.scalatest.WordSpecLike.invokeWithFixture$1(WordSpecLike.scala:1076)
	at org.scalatest.WordSpecLike.$anonfun$runTest$1(WordSpecLike.scala:1088)
	at org.scalatest.SuperEngine.runTestImpl(Engine.scala:289)
	at org.scalatest.WordSpecLike.runTest(WordSpecLike.scala:1088)
	at org.scalatest.WordSpecLike.runTest$(WordSpecLike.scala:1070)
	at org.scalatest.WordSpec.runTest(WordSpec.scala:1881)
	at org.scalatest.WordSpecLike.$anonfun$runTests$1(WordSpecLike.scala:1147)
	at org.scalatest.SuperEngine.$anonfun$runTestsInBranch$1(Engine.scala:396)
	at scala.collection.immutable.List.foreach(List.scala:389)
	at org.scalatest.SuperEngine.traverseSubNodes$1(Engine.scala:384)
	at org.scalatest.SuperEngine.runTestsInBranch(Engine.scala:373)
	at org.scalatest.SuperEngine.$anonfun$runTestsInBranch$1(Engine.scala:410)
	at scala.collection.immutable.List.foreach(List.scala:389)
	at org.scalatest.SuperEngine.traverseSubNodes$1(Engine.scala:384)
	at org.scalatest.SuperEngine.runTestsInBranch(Engine.scala:373)
	at org.scalatest.SuperEngine.$anonfun$runTestsInBranch$1(Engine.scala:410)
	at scala.collection.immutable.List.foreach(List.scala:389)
	at org.scalatest.SuperEngine.traverseSubNodes$1(Engine.scala:384)
	at org.scalatest.SuperEngine.runTestsInBranch(Engine.scala:379)
	at org.scalatest.SuperEngine.runTestsImpl(Engine.scala:461)
	at org.scalatest.WordSpecLike.runTests(WordSpecLike.scala:1147)
	at org.scalatest.WordSpecLike.runTests$(WordSpecLike.scala:1146)
	at org.scalatest.WordSpec.runTests(WordSpec.scala:1881)
	at org.scalatest.Suite.run(Suite.scala:1147)
	at org.scalatest.Suite.run$(Suite.scala:1129)
	at org.scalatest.WordSpec.org$scalatest$WordSpecLike$$super$run(WordSpec.scala:1881)
	at org.scalatest.WordSpecLike.$anonfun$run$1(WordSpecLike.scala:1192)
	at org.scalatest.SuperEngine.runImpl(Engine.scala:521)
	at org.scalatest.WordSpecLike.run(WordSpecLike.scala:1192)
	at org.scalatest.WordSpecLike.run$(WordSpecLike.scala:1190)
	at eu.phy_awaas.irods.typed.lockingsystem.IRODSLockManagerSpec.org$scalatest$BeforeAndAfterAll$$super$run(IRODSLockManagerSpec.scala:22)
	at org.scalatest.BeforeAndAfterAll.liftedTree1$1(BeforeAndAfterAll.scala:213)
	at org.scalatest.BeforeAndAfterAll.run(BeforeAndAfterAll.scala:210)
	at org.scalatest.BeforeAndAfterAll.run$(BeforeAndAfterAll.scala:208)
	at eu.phy_awaas.irods.typed.lockingsystem.IRODSLockManagerSpec.run(IRODSLockManagerSpec.scala:22)
	at org.scalatest.tools.SuiteRunner.run(SuiteRunner.scala:45)
	at org.scalatest.tools.Runner$.$anonfun$doRunRunRunDaDoRunRun$13(Runner.scala:1340)
	at org.scalatest.tools.Runner$.$anonfun$doRunRunRunDaDoRunRun$13$adapted(Runner.scala:1334)
	at scala.collection.immutable.List.foreach(List.scala:389)
	at org.scalatest.tools.Runner$.doRunRunRunDaDoRunRun(Runner.scala:1334)
	at org.scalatest.tools.Runner$.$anonfun$runOptionallyWithPassFailReporter$24(Runner.scala:1031)
	at org.scalatest.tools.Runner$.$anonfun$runOptionallyWithPassFailReporter$24$adapted(Runner.scala:1010)
	at org.scalatest.tools.Runner$.withClassLoaderAndDispatchReporter(Runner.scala:1500)
	at org.scalatest.tools.Runner$.runOptionallyWithPassFailReporter(Runner.scala:1010)
	at org.scalatest.tools.Runner$.run(Runner.scala:850)
	at org.scalatest.tools.Runner.run(Runner.scala)
	at org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner.runScalaTest2(ScalaTestRunner.java:131)
	at org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner.main(ScalaTestRunner.java:28)
```

With the calling code looking like this:

```scala
        val lockResults =
          probe.fishForMessage(Duration.create(10000, "ms"))(l => {
            r += 1
            if (r < 5) {
              l.lock.use(())//crash happens here
              FishingOutcomes.continue
            } else {
              l.lock.use(())
              FishingOutcomes.complete
            }
          })
```

It's pretty obvious receiveOne(timeout) returns a null when it receives nothing before the timeout, passes that along to my fisher function, which tries to perform work on the supposed message only to get a null instead.

* Added missing brace

* Manually formatted my code the way akka likes

I don't have the set up to compile this right now, so I just manually inserted the formatting that jenkins mentioned.

* More changes to fit the akka formatting standard

* Test for the new assertion error when fishing times out.

* Cleaned up a flaw I added from when I initially put this in async spec
2018-10-15 14:02:58 +02:00
Johan Andrén
83b30f1ed2
Merge pull request #25653 from chbatey/supervision-interceptor
Supervision with a BehaviorInterceptor
2018-09-24 09:44:36 +02:00
Patrik Nordwall
824e4196e7 Introduce RecipientRef interface for ActorRef and EntityRef, #24463
* to make it possible to use ActorContext.ask also with EntityRef
  destinations
* this abstraction will probably be useful for other things, where a
  full ActorRef is not required
* a RecipientRef only has to support tell (and ask), while a full ActorRef
  is watchable (destination has a lifecycle) and location transparent (serializable)
2018-09-21 14:39:18 +02:00
Christopher Batey
79c6320bfc Dropped messages when backing off 2018-09-20 11:51:31 +01:00
Arnout Engelen
50e9b14d0b BehaviorTestKit: get child inbox by anonymous ActorRef 2018-09-20 12:32:36 +02:00
Christopher Batey
6a8092480e Remove old restarters 2018-09-20 11:29:09 +01:00
Christopher Batey
ea454a733d Reset timeout for fixed restarts 2018-09-20 08:36:01 +01:00
Christopher Batey
85a4597e4a wip 2018-09-20 08:36:01 +01:00
Christopher Batey
1d0603dab9 make scalatest suite type agnostic 2018-09-17 17:54:54 +02:00
Patrik Nordwall
b16e4d5e4d ActorTestKit overhaul, #24598
* composition is the basic building block for ActorTestKit
* ActorTestKitWordSpec for integration with ScalaTest
  (automatic shutdown)

* Use ActorTestKitWordSpec in our own tests

* doc TestException
2018-09-17 17:00:15 +02:00
Patrik Nordwall
5371aa17e4 cleanup some systemActor stuff (#25606)
* remove the ActorRef.apply(Future) since that is uncertain, see ticket #25305
2018-09-14 14:18:47 +01:00
Arnout Engelen
e2c443b40f Allow restarting a named child in StubbedActorContext 2018-09-14 14:39:08 +02:00
Kazuhiro Sera
482eaea122 Fix several minor typos detected by github.com/client9/misspell (#25448)
* Fix several minor typos detected by github.com/client9/misspell

* Revert s/erminater/erminator/ in /ActorSystemSpec
2018-08-21 11:02:37 +09:00
kenji yoshida
5b3b191bac Remove procedure syntax (#25362) 2018-07-25 13:38:27 +02:00
Johan Andrén
159ba045cf
Race condition in ManualTimerExampleSpec fixed #24957 2018-07-03 09:36:50 +02:00
Christopher Batey
2a979fe296 Expose Effect classes for BehaviorTestKit Java DSL, #25070, #24781
* Expose Effect classes for BehaviorTestKit Java DSL

- Share effect classes between java and scala dsl
- make spawn adapter private
- add message adapter effect
- add tests for java behavior test kit

* Mirror Effect factory in java and scala dsl
2018-06-04 18:01:09 +02:00
Tim Moore
5c401584c3 Add static import convenience methods to Done and NotUsed (#25174)
* Add Done.done() convenience for static import
* Add NotUsed.notUsed() convenience for static import
2018-05-31 13:12:20 +01:00
Christopher Batey
8eb7b1ea81
Typed persistent event adapters/wrappers (#25050)
Typed persistent event adapters/wrappers
2018-05-25 10:23:04 +01:00