* add example for Source.fromIterator #25468 * scala fmt code style fix * don't use test as a sample for docs
This commit is contained in:
parent
6120b73918
commit
dcdaa5a0dd
4 changed files with 72 additions and 0 deletions
|
|
@ -22,6 +22,7 @@ import akka.stream.stage.*;
|
|||
import akka.testkit.AkkaSpec;
|
||||
import akka.stream.testkit.TestPublisher;
|
||||
import akka.testkit.javadsl.TestKit;
|
||||
import com.google.common.collect.Iterables;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import scala.concurrent.duration.FiniteDuration;
|
||||
|
|
@ -1157,4 +1158,16 @@ public class SourceTest extends StreamTest {
|
|||
akka.stream.scaladsl.Source.empty();
|
||||
Source<Integer, NotUsed> javaSource = scalaSource.asJava();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mustProperlyIterate() throws Exception {
|
||||
final Creator<Iterator<Boolean>> input = () -> Iterables.cycle(false, true).iterator();
|
||||
|
||||
final CompletableFuture<List<Boolean>> future =
|
||||
Source.fromIterator(input).grouped(10).runWith(Sink.head(), system).toCompletableFuture();
|
||||
|
||||
assertArrayEquals(
|
||||
new Boolean[] {false, true, false, true, false, true, false, true, false, true},
|
||||
future.get(1, TimeUnit.SECONDS).toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue