StreamReceiverHandler implements Serializable { protected void doHandleXhrFilePost(VaadinSession session, VaadinRequest request, VaadinResponse response, StreamReceiver streamReceiver, StateNode owner, long contentLength) throws IOException { final String filename = "unknown"; final String mimeType = filename; final InputStream stream = request.getInputStream(); boolean success = false; try { success = handleFileUploadValidationAndData(session, stream, streamReceiver, filename, mimeType, contentLength, owner); } catch (UploadException e) { session.getErrorHandler().error(new ErrorEvent(e)); } sendUploadResponse(response, success); }  void handleRequest(VaadinSession session, VaadinRequest request,
            VaadinResponse response, StreamReceiver streamReceiver, String uiId,
            String securityKey); static final int DEFAULT_STREAMING_PROGRESS_EVENT_INTERVAL_MS; }
@Test public void doHandleXhrFilePost_outputStreamGetterThrows_responseStatusIs500() throws IOException { Mockito.doThrow(RuntimeException.class).when(streamVariable) .getOutputStream(); handler.doHandleXhrFilePost(session, request, response, streamReceiver, stateNode, 1); Mockito.verify(response) .setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); }
@Test public void doHandleXhrFilePost_outputStreamThrowsOnWrite_responseStatusIs500() throws IOException { Mockito.doThrow(RuntimeException.class).when(outputStream) .write(Mockito.any(), Mockito.anyInt(), Mockito.anyInt()); handler.doHandleXhrFilePost(session, request, response, streamReceiver, stateNode, 1); Mockito.verify(response) .setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); }
@Test public void doHandleXhrFilePost_happyPath_setContentTypeNoExplicitSetStatus() throws IOException { handler.doHandleXhrFilePost(session, request, response, streamReceiver, stateNode, 1); Mockito.verify(response).setContentType( ApplicationConstants.CONTENT_TYPE_TEXT_HTML_UTF_8); Mockito.verify(response, Mockito.times(0)).setStatus(Mockito.anyInt()); }