### Question:
StoreFileStreamingProtocol { void stream( ChannelHandlerContext ctx, StoreResource resource ) { ctx.write( ResponseMessageType.FILE ); ctx.write( new FileHeader( resource.path(), resource.recordSize() ) ); ctx.write( new FileSender( resource ) ); }    }### Answer:
@Test public void shouldStreamResources() throws Exception { StoreFileStreamingProtocol protocol = new StoreFileStreamingProtocol(); ChannelHandlerContext ctx = mock( ChannelHandlerContext.class ); fs.mkdir( new File( "dirA" ) ); fs.mkdir( new File( "dirB" ) ); String[] files = new String[]{"dirA/one", "dirA/two", "dirB/one", "dirB/two", "one", "two", "three"}; List<StoreResource> resourceList = new ArrayList<>(); for ( String file : files ) { resourceList.add( createResource( new File( file ), ThreadLocalRandom.current().nextInt( 1, 4096 ) ) ); } RawCursor<StoreResource,IOException> resources = rawCursorOf( resourceList ); while ( resources.next() ) { protocol.stream( ctx, resources.get() ); } InOrder inOrder = Mockito.inOrder( ctx ); for ( StoreResource resource : resourceList ) { inOrder.verify( ctx ).write( ResponseMessageType.FILE ); inOrder.verify( ctx ).write( new FileHeader( resource.path(), resource.recordSize() ) ); inOrder.verify( ctx ).write( new FileSender( resource ) ); } verifyNoMoreInteractions( ctx ); }