use of com.yahoo.container.jdisc.ContentChannelOutputStream in project vespa by vespa-engine.
the class AsynchronousSectionedRendererTest method render.
@SuppressWarnings("unchecked")
public String render(Renderer renderer, DataList data) throws InterruptedException, IOException {
TestContentChannel contentChannel = new TestContentChannel();
Execution execution = Execution.createRoot(new NoopProcessor(), 0, null);
final ContentChannelOutputStream stream = new ContentChannelOutputStream(contentChannel);
ListenableFuture result = renderer.render(stream, new Response(data), execution, null);
int waitCounter = 1000;
while (!result.isDone()) {
Thread.sleep(60);
--waitCounter;
if (waitCounter < 0) {
throw new IllegalStateException();
}
}
stream.close();
contentChannel.close(null);
String str = "";
for (ByteBuffer buf : contentChannel.getBuffers()) {
str += Utf8.toString(buf);
}
return str;
}
Aggregations