VaadinSession implements HttpSessionBindingListener, Serializable { @Override public void valueUnbound(HttpSessionBindingEvent event) { if (service == null) { getLogger() .warn("A VaadinSession instance not associated to any service is getting unbound. " + "Session destroy events will not be fired and UIs in the session will not get detached. " + "This might happen if a session is deserialized but never used before it expires."); } else if (VaadinService.getCurrentRequest() != null && getCurrent() == this) { checkHasLock(); if (getAttribute( VaadinService.PRESERVE_UNBOUND_SESSION_ATTRIBUTE) == Boolean.TRUE) { return; } if (getState() == VaadinSessionState.OPEN) { close(); } } else { service.fireSessionDestroy(this); } session = null; } VaadinSession(VaadinService service); @Override void valueBound(HttpSessionBindingEvent arg0); @Override void valueUnbound(HttpSessionBindingEvent event); WebBrowser getBrowser(); long getCumulativeRequestDuration(); void setLastRequestDuration(long time); long getLastRequestDuration(); void setLastRequestTimestamp(long timestamp); long getLastRequestTimestamp(); WrappedSession getSession(); static Collection<VaadinSession> getAllSessions(
            HttpSession httpSession); void setConfiguration(DeploymentConfiguration configuration); DeploymentConfiguration getConfiguration(); Locale getLocale(); void setLocale(Locale locale); ErrorHandler getErrorHandler(); void setErrorHandler(ErrorHandler errorHandler); void addRequestHandler(RequestHandler handler); void removeRequestHandler(RequestHandler handler); Collection<RequestHandler> getRequestHandlers(); static VaadinSession getCurrent(); static void setCurrent(VaadinSession session); Collection<UI> getUIs(); UI getUIById(int uiId); boolean hasLock(); void checkHasLock(String message); void checkHasLock(); void removeUI(UI ui); Lock getLockInstance(); void lock(); void unlock(); void setAttribute(String name, Object value); void setAttribute(Class<T> type, T value); Object getAttribute(String name); T getAttribute(Class<T> type); int getNextUIid(); void addUI(UI ui); VaadinService getService(); void close(); VaadinSessionState getState(); void accessSynchronously(Command command); Future<Void> access(Command command); Queue<FutureAccess> getPendingAccessQueue(); String getPushId(); void refreshTransients(WrappedSession wrappedSession,
            VaadinService vaadinService); StreamResourceRegistry getResourceRegistry(); String getCsrfToken(); @Deprecated
    static final String UI_PARAMETER; }
@Test public void testValueUnbound() { MockVaadinSession vaadinSession = new MockVaadinSession(mockService); vaadinSession.valueUnbound( EasyMock.createMock(HttpSessionBindingEvent.class)); org.junit.Assert.assertEquals( "'valueUnbound' method doesn't call 'close' for the session", 1, vaadinSession.getCloseCount()); vaadinSession.valueUnbound( EasyMock.createMock(HttpSessionBindingEvent.class)); org.junit.Assert.assertEquals( "'valueUnbound' method may not call 'close' " + "method for closing session", 1, vaadinSession.getCloseCount()); }