* Add expectNext(d: FiniteDuration) and requestNext(d: FiniteDuration) for issue 20815 * add some comments on requestNext
This commit is contained in:
parent
00c5f49c7a
commit
d6eebd22ef
1 changed files with 22 additions and 1 deletions
|
|
@ -252,7 +252,14 @@ object TestSubscriber {
|
|||
* Expect and return a stream element.
|
||||
*/
|
||||
def expectNext(): I = {
|
||||
val t = probe.remainingOr(probe.testKitSettings.SingleExpectDefaultTimeout.dilated)
|
||||
expectNext(probe.testKitSettings.SingleExpectDefaultTimeout.dilated)
|
||||
}
|
||||
|
||||
/**
|
||||
* Expect and return a stream element during specified time or timeout.
|
||||
*/
|
||||
def expectNext(d: FiniteDuration): I = {
|
||||
val t = probe.remainingOr(d)
|
||||
probe.receiveOne(t) match {
|
||||
case null ⇒ throw new AssertionError(s"Expected OnNext(_), yet no element signaled during $t")
|
||||
case OnNext(elem) ⇒ elem.asInstanceOf[I]
|
||||
|
|
@ -598,6 +605,9 @@ object TestSubscriber {
|
|||
this
|
||||
}
|
||||
|
||||
/**
|
||||
* Request and expect a stream element.
|
||||
*/
|
||||
def requestNext(element: T): Self = {
|
||||
subscription.request(1)
|
||||
expectNext(element)
|
||||
|
|
@ -609,10 +619,21 @@ object TestSubscriber {
|
|||
this
|
||||
}
|
||||
|
||||
/**
|
||||
* Request and expect a stream element.
|
||||
*/
|
||||
def requestNext(): T = {
|
||||
subscription.request(1)
|
||||
expectNext()
|
||||
}
|
||||
|
||||
/**
|
||||
* Request and expect a stream element during the specified time or timeout.
|
||||
*/
|
||||
def requestNext(d: FiniteDuration): T = {
|
||||
subscription.request(1)
|
||||
expectNext(d)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue