FunSpec { 9 implicit val system = ActorSystem() 10 implicit val mat = ActorMaterializer() 11 12 describe("flow basic test") { 13 it("use probe") { 14 val primeFilterFlow: Flow[Int, Int, NotUsed] = Flow[Int].filter { 15 case i if i <= 1 => false 16 case i if i.==(2) => true 17 case i => !(2 until i).exists(x => i % x == 0) 18 } 19 20 val testSrc = Source(1 to 20) 21 val probe = testSrc 22 .via(primeFilterFlow) 23 .toMat(TestSink.probe[Int])(Keep.right) 24 .run() 25 26 probe.request(8) 27 probe.expectNext(2, 3, 5, 7, 11, 13, 17, 19) 28 } 29 } 30 } FYBNQMFTTSDUFTUTDBMB'MPX5FTU4QFDTDBMB ˡ1SPCF Λड͚औΔͨΊʹ .BU Λ༻