UidlRequestHandler extends SynchronizedRequestHandler implements SessionExpiredHandler { @Override public boolean handleSessionExpired(VaadinRequest request, VaadinResponse response) throws IOException { if (!HandlerHelper.isRequestType(request, RequestType.UIDL)) { return false; } VaadinService service = request.getService(); service.writeUncachedStringResponse(response, JsonConstants.JSON_CONTENT_TYPE, VaadinService.createSessionExpiredJSON(false)); return true; }  @Override boolean synchronizedHandleRequest(VaadinSession session,
            VaadinRequest request, VaadinResponse response); @Override boolean handleSessionExpired(VaadinRequest request,
            VaadinResponse response); static void commitJsonResponse(VaadinResponse response, String json); static final Pattern HASH_PATTERN; static final Pattern URL_PATTERN; static final String PUSH_STATE_HASH; static final String PUSH_STATE_LOCATION; }
@Test public void writeSessionExpired() throws Exception { VaadinService service = new VaadinServletService(null, new DefaultDeploymentConfiguration(getClass(), new Properties())); when(request.getService()).thenReturn(service); when(request .getParameter(ApplicationConstants.REQUEST_TYPE_PARAMETER)) .thenReturn(RequestType.UIDL.getIdentifier()); boolean result = handler.handleSessionExpired(request, response); Assert.assertTrue("Result should be true", result); String responseContent = CommunicationUtil .getStringWhenWriteBytesOffsetLength(outputStream); Assert.assertEquals("Invalid response", "for(;;);[{\"meta\":{\"sessionExpired\":true}}]", responseContent); }