use of com.yahoo.processing.test.ProcessorLibrary.MapData in project vespa by vespa-engine.
the class ProcessingHandlerTestCase method testStreamedRendering.
@SuppressWarnings("unchecked")
@Test
public void testStreamedRendering() throws Exception {
// Set up
Chain<Processor> streamChain = new Chain<Processor>(new StreamProcessor());
ProcessorLibrary.ListenableFutureDataSource futureDataSource = new ProcessorLibrary.ListenableFutureDataSource();
Chain<Processor> mainChain = new Chain<Processor>("main", new ProcessorLibrary.StreamProcessingInitiator(streamChain), futureDataSource);
driver = new ProcessingTestDriver(mainChain);
ProcessingTestDriver.MockResponseHandler responseHandler = driver.sendRequest("http://localhost/?chain=main");
// Add one data element
futureDataSource.incomingData.get().add(new MapData(null));
assertEquals("{\"datalist\":[" + "{\"data\":\"map data: {streamProcessed=true}\"}", responseHandler.read());
// add another
futureDataSource.incomingData.get().add(new MapData(null));
assertEquals(",{\"data\":\"map data: {streamProcessed=true}\"}", responseHandler.read());
// add last
futureDataSource.incomingData.get().addLast(new MapData(null));
assertEquals(",{\"data\":\"map data: {streamProcessed=true}\"}]}", responseHandler.read());
assertTrue("Transmission completed", null == responseHandler.read());
}
Aggregations