Search in sources :

Example 1 with MapData

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());
}
Also used : Chain(com.yahoo.component.chain.Chain) Processor(com.yahoo.processing.Processor) MapData(com.yahoo.processing.test.ProcessorLibrary.MapData) ProcessorLibrary(com.yahoo.processing.test.ProcessorLibrary) Test(org.junit.Test)

Aggregations

Chain (com.yahoo.component.chain.Chain)1 Processor (com.yahoo.processing.Processor)1 ProcessorLibrary (com.yahoo.processing.test.ProcessorLibrary)1 MapData (com.yahoo.processing.test.ProcessorLibrary.MapData)1 Test (org.junit.Test)1