|
Play Framework/Scala example source code file (ByteChunksJava8Test.java)
The ByteChunksJava8Test.java Play Framework example source code/* * Copyright (C) 2009-2013 Typesafe Inc. <http://www.typesafe.com> */ package play.mvc; import java.util.ArrayList; import java.util.Arrays; import java.util.concurrent.CountDownLatch; import org.junit.Test; import play.api.libs.iteratee.TestChannel; import play.libs.F; import play.mvc.Results.ByteChunks; import play.mvc.Results.Chunks; import static java.util.concurrent.TimeUnit.SECONDS; import static org.junit.Assert.assertTrue; public class ByteChunksJava8Test { @Test public void testWhenReadyFactory() throws Exception { final TestChannel<byte[]> testChannel = new TestChannel<byte[]>(); final Chunks.Out<byte[]> testOut = new Chunks.Out<byte[]>(testChannel, new ArrayList<F.Callback0>()); final CountDownLatch ready = new CountDownLatch(1); Chunks<byte[]> chunks = ByteChunks.whenReady(out -> { ready.countDown(); out.write("a".getBytes()); out.write("b".getBytes()); out.close(); }); chunks.onReady(testOut); assertTrue("ByteChunks.onReady callback was not invoked", ready.await(1, SECONDS)); testChannel.expect("a".getBytes(), Arrays::equals); testChannel.expect("b".getBytes(), Arrays::equals); testChannel.expectEOF(); testChannel.expectEnd(); testChannel.expectEmpty(); } } Other Play Framework source code examplesHere is a short list of links related to this Play Framework ByteChunksJava8Test.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.