also fix FlowInterleaveSpec

Also-by: Johan Andrén <johan@markatta.com>
Also-by: Roland Kuhn <rk@rkuhn.info>
Also-by: Martynas Mickevičius <mmartynas@gmail.com>
This commit is contained in:
Endre Sándor Varga 2016-01-20 10:00:37 +02:00 committed by Martynas Mickevičius
parent ef77b56e66
commit 60497f6561
195 changed files with 1110 additions and 857 deletions

View file

@ -3,6 +3,7 @@
*/
package akka.stream.javadsl;
import akka.NotUsed;
import akka.japi.Pair;
import akka.pattern.Patterns;
import akka.japi.tuple.Tuple4;
@ -20,7 +21,7 @@ import org.reactivestreams.Publisher;
import scala.concurrent.Await;
import scala.concurrent.Future;
import scala.concurrent.duration.Duration;
import scala.runtime.BoxedUnit;
import java.util.*;
import java.util.concurrent.TimeUnit;
import static org.junit.Assert.assertEquals;
@ -56,23 +57,23 @@ public class FlowGraphTest extends StreamTest {
@Test
public void mustBeAbleToUseMerge() throws Exception {
final Flow<String, String, BoxedUnit> f1 =
final Flow<String, String, NotUsed> f1 =
Flow.of(String.class).transform(FlowGraphTest.this.<String> op()).named("f1");
final Flow<String, String, BoxedUnit> f2 =
final Flow<String, String, NotUsed> f2 =
Flow.of(String.class).transform(FlowGraphTest.this.<String> op()).named("f2");
@SuppressWarnings("unused")
final Flow<String, String, BoxedUnit> f3 =
final Flow<String, String, NotUsed> f3 =
Flow.of(String.class).transform(FlowGraphTest.this.<String> op()).named("f3");
final Source<String, BoxedUnit> in1 = Source.from(Arrays.asList("a", "b", "c"));
final Source<String, BoxedUnit> in2 = Source.from(Arrays.asList("d", "e", "f"));
final Source<String, NotUsed> in1 = Source.from(Arrays.asList("a", "b", "c"));
final Source<String, NotUsed> in2 = Source.from(Arrays.asList("d", "e", "f"));
final Sink<String, Publisher<String>> publisher = Sink.asPublisher(false);
final Source<String, BoxedUnit> source = Source.fromGraph(
GraphDSL.create(new Function<GraphDSL.Builder<BoxedUnit>, SourceShape<String>>() {
final Source<String, NotUsed> source = Source.fromGraph(
GraphDSL.create(new Function<GraphDSL.Builder<NotUsed>, SourceShape<String>>() {
@Override
public SourceShape<String> apply(Builder<BoxedUnit> b) throws Exception {
public SourceShape<String> apply(Builder<NotUsed> b) throws Exception {
final UniformFanInShape<String, String> merge = b.add(Merge.<String>create(2));
b.from(b.add(in1)).via(b.add(f1)).toInlet(merge.in(0));
b.from(b.add(in2)).via(b.add(f2)).toInlet(merge.in(1));
@ -95,13 +96,13 @@ public class FlowGraphTest extends StreamTest {
final Iterable<Integer> input2 = Arrays.asList(1, 2, 3);
RunnableGraph.fromGraph( GraphDSL.create(
new Function<Builder<BoxedUnit>,ClosedShape>() {
new Function<Builder<NotUsed>,ClosedShape>() {
@Override
public ClosedShape apply(final Builder<BoxedUnit> b) throws Exception {
final Source<String, BoxedUnit> in1 = Source.from(input1);
final Source<Integer, BoxedUnit> in2 = Source.from(input2);
public ClosedShape apply(final Builder<NotUsed> b) throws Exception {
final Source<String, NotUsed> in1 = Source.from(input1);
final Source<Integer, NotUsed> in2 = Source.from(input2);
final FanInShape2<String, Integer, Pair<String,Integer>> zip = b.add(Zip.<String, Integer>create());
final Sink<Pair<String, Integer>, BoxedUnit> out = createSink(probe);
final Sink<Pair<String, Integer>, NotUsed> out = createSink(probe);
b.from(b.add(in1)).toInlet(zip.in0());
b.from(b.add(in2)).toInlet(zip.in1());
@ -130,9 +131,9 @@ public class FlowGraphTest extends StreamTest {
final Iterable<Integer> expected2 = Arrays.asList(1, 2, 3);
RunnableGraph.fromGraph(GraphDSL.create(
new Function<Builder<BoxedUnit>, ClosedShape>() {
new Function<Builder<NotUsed>, ClosedShape>() {
@Override
public ClosedShape apply(final Builder<BoxedUnit> b) throws Exception {
public ClosedShape apply(final Builder<NotUsed> b) throws Exception {
final SourceShape<Pair<String, Integer>> in = b.add(Source.from(input));
final FanOutShape2<Pair<String, Integer>, String, Integer> unzip = b.add(Unzip.<String, Integer>create());
@ -152,7 +153,7 @@ public class FlowGraphTest extends StreamTest {
assertEquals(expected2, output2);
}
private static <T> Sink<T, BoxedUnit> createSink(final JavaTestKit probe){
private static <T> Sink<T, NotUsed> createSink(final JavaTestKit probe){
return Sink.actorRef(probe.getRef(), "onComplete");
}
@ -162,10 +163,10 @@ public class FlowGraphTest extends StreamTest {
final JavaTestKit probe2 = new JavaTestKit(system);
RunnableGraph.fromGraph(GraphDSL.create(
new Function<Builder<BoxedUnit>, ClosedShape>() {
new Function<Builder<NotUsed>, ClosedShape>() {
@Override
public ClosedShape apply(final Builder<BoxedUnit> b) throws Exception {
final Source<Integer, BoxedUnit> in = Source.single(1);
public ClosedShape apply(final Builder<NotUsed> b) throws Exception {
final Source<Integer, NotUsed> in = Source.single(1);
final FanOutShape2<Integer, String, Integer> unzip = b.add(UnzipWith.create(
new Function<Integer, Pair<String, Integer>>() {
@ -205,10 +206,10 @@ public class FlowGraphTest extends StreamTest {
final JavaTestKit probe4 = new JavaTestKit(system);
RunnableGraph.fromGraph(GraphDSL.create(
new Function<Builder<BoxedUnit>, ClosedShape>() {
new Function<Builder<NotUsed>, ClosedShape>() {
@Override
public ClosedShape apply(final Builder<BoxedUnit> b) throws Exception {
final Source<Integer, BoxedUnit> in = Source.single(1);
public ClosedShape apply(final Builder<NotUsed> b) throws Exception {
final Source<Integer, NotUsed> in = Source.single(1);
final FanOutShape4<Integer, String, Integer, String, Integer> unzip = b.add(UnzipWith.create4(
new Function<Integer, Tuple4<String, Integer, String, Integer>>() {
@ -248,10 +249,10 @@ public class FlowGraphTest extends StreamTest {
@Test
public void mustBeAbleToUseZipWith() throws Exception {
final Source<Integer, BoxedUnit> in1 = Source.single(1);
final Source<Integer, BoxedUnit> in2 = Source.single(10);
final Source<Integer, NotUsed> in1 = Source.single(1);
final Source<Integer, NotUsed> in2 = Source.single(10);
final Graph<FanInShape2<Integer, Integer, Integer>, BoxedUnit> sumZip = ZipWith.create(
final Graph<FanInShape2<Integer, Integer, Integer>, NotUsed> sumZip = ZipWith.create(
new Function2<Integer, Integer, Integer>() {
@Override public Integer apply(Integer l, Integer r) throws Exception {
return l + r;
@ -276,12 +277,12 @@ public class FlowGraphTest extends StreamTest {
@Test
public void mustBeAbleToUseZip4With() throws Exception {
final Source<Integer, BoxedUnit> in1 = Source.single(1);
final Source<Integer, BoxedUnit> in2 = Source.single(10);
final Source<Integer, BoxedUnit> in3 = Source.single(100);
final Source<Integer, BoxedUnit> in4 = Source.single(1000);
final Source<Integer, NotUsed> in1 = Source.single(1);
final Source<Integer, NotUsed> in2 = Source.single(10);
final Source<Integer, NotUsed> in3 = Source.single(100);
final Source<Integer, NotUsed> in4 = Source.single(1000);
final Graph<FanInShape4<Integer, Integer, Integer, Integer, Integer>, BoxedUnit> sumZip = ZipWith.create4(
final Graph<FanInShape4<Integer, Integer, Integer, Integer, Integer>, NotUsed> sumZip = ZipWith.create4(
new Function4<Integer, Integer, Integer, Integer, Integer>() {
@Override public Integer apply(Integer i1, Integer i2, Integer i3, Integer i4) throws Exception {
return i1 + i2 + i3 + i4;
@ -310,7 +311,7 @@ public class FlowGraphTest extends StreamTest {
@Test
public void mustBeAbleToUseMatValue() throws Exception {
@SuppressWarnings("unused")
final Source<Integer, BoxedUnit> in1 = Source.single(1);
final Source<Integer, NotUsed> in1 = Source.single(1);
final TestProbe probe = TestProbe.apply(system);
final Future<Integer> future = RunnableGraph.fromGraph(