Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
f2e39c7
commit ccf5d46
Showing
12 changed files
with
321 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphWireTapSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package akka.stream.scaladsl | ||
|
||
import akka.stream._ | ||
import akka.stream.testkit.Utils._ | ||
import akka.stream.testkit._ | ||
import akka.stream.testkit.scaladsl.TestSink | ||
|
||
class GraphWireTapSpec extends StreamSpec { | ||
|
||
val settings = ActorMaterializerSettings(system) | ||
.withInputBuffer(initialSize = 2, maxSize = 16) | ||
|
||
implicit val materializer = ActorMaterializer(settings) | ||
|
||
"A wire tap" must { | ||
|
||
"wireTap must broadcast to the tap" in assertAllStagesStopped { | ||
val tp, mp = TestSink.probe[Int](system) | ||
val (tps, mps) = Source(1 to 2).wireTapMat(tp)(Keep.right).toMat(mp)(Keep.both).run() | ||
tps.request(2) | ||
mps.requestNext(1) | ||
mps.requestNext(2) | ||
tps.expectNext(1, 2) | ||
mps.expectComplete() | ||
tps.expectComplete() | ||
} | ||
|
||
"wireTap must drop elements while the tap has no demand, buffering up to one element" in assertAllStagesStopped { | ||
val tp, mp = TestSink.probe[Int](system) | ||
val (tps, mps) = Source(1 to 6).wireTapMat(tp)(Keep.right).toMat(mp)(Keep.both).run() | ||
mps.request(3) | ||
mps.expectNext(1, 2, 3) | ||
tps.request(4) | ||
mps.requestNext(4) | ||
mps.requestNext(5) | ||
mps.requestNext(6) | ||
tps.expectNext(3, 4, 5, 6) | ||
mps.expectComplete() | ||
tps.expectComplete() | ||
} | ||
|
||
"wireTap must cancel if main sink cancels" in assertAllStagesStopped { | ||
val tp, mp = TestSink.probe[Int](system) | ||
val (tps, mps) = Source(1 to 6).wireTapMat(tp)(Keep.right).toMat(mp)(Keep.both).run() | ||
tps.request(6) | ||
mps.cancel() | ||
tps.expectComplete() | ||
} | ||
|
||
"wireTap must continue if tap sink cancels" in assertAllStagesStopped { | ||
val tp, mp = TestSink.probe[Int](system) | ||
val (tps, mps) = Source(1 to 6).wireTapMat(tp)(Keep.right).toMat(mp)(Keep.both).run() | ||
tps.cancel() | ||
mps.request(6) | ||
mps.expectNext(1, 2, 3, 4, 5, 6) | ||
mps.expectComplete() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.