!str #16039 Remove old scaladsl, rename scaladsl2
* and impl2, testkit2 * keeping io2 for now
This commit is contained in:
parent
5562ceb94b
commit
7c0c618791
221 changed files with 1540 additions and 7985 deletions
|
|
@ -0,0 +1,62 @@
|
|||
/**
|
||||
* Copyright (C) 2009-2014 Typesafe Inc. <http://www.typesafe.com>
|
||||
*/
|
||||
package akka.stream.scaladsl
|
||||
|
||||
import akka.actor.ActorSystem
|
||||
import akka.stream.FlowMaterializer
|
||||
import akka.stream.MaterializerSettings
|
||||
import akka.stream.testkit.{ AkkaSpec, StreamTestKit }
|
||||
import org.reactivestreams.Subscriber
|
||||
import org.scalatest.Matchers
|
||||
|
||||
class FlowAppendSpec extends AkkaSpec with River {
|
||||
|
||||
val settings = MaterializerSettings(system)
|
||||
implicit val materializer = FlowMaterializer(settings)
|
||||
|
||||
"Flow" should {
|
||||
"append Flow" in riverOf[String] { subscriber ⇒
|
||||
val flow = Flow[Int].connect(otherFlow)
|
||||
Source(elements).connect(flow).connect(Sink(subscriber)).run()
|
||||
}
|
||||
|
||||
"append Sink" in riverOf[String] { subscriber ⇒
|
||||
val sink = Flow[Int].connect(otherFlow.connect(Sink(subscriber)))
|
||||
Source(elements).connect(sink).run()
|
||||
}
|
||||
}
|
||||
|
||||
"Source" should {
|
||||
"append Flow" in riverOf[String] { subscriber ⇒
|
||||
Source(elements)
|
||||
.connect(otherFlow)
|
||||
.connect(Sink(subscriber)).run()
|
||||
}
|
||||
|
||||
"append Sink" in riverOf[String] { subscriber ⇒
|
||||
Source(elements)
|
||||
.connect(otherFlow.connect(Sink(subscriber)))
|
||||
.run()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
trait River { self: Matchers ⇒
|
||||
|
||||
val elements = (1 to 10)
|
||||
val otherFlow = Flow[Int].map(_.toString)
|
||||
|
||||
def riverOf[T](flowConstructor: Subscriber[T] ⇒ Unit)(implicit system: ActorSystem) = {
|
||||
val subscriber = StreamTestKit.SubscriberProbe[T]()
|
||||
|
||||
flowConstructor(subscriber)
|
||||
|
||||
val subscription = subscriber.expectSubscription()
|
||||
subscription.request(elements.size)
|
||||
subscriber.probe.receiveN(elements.size) should be(elements.map(_.toString).map(StreamTestKit.OnNext(_)))
|
||||
subscription.request(1)
|
||||
subscriber.expectComplete()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue