### Question:
VaadinSession implements HttpSessionBindingListener, Serializable { @Override public void valueUnbound(HttpSessionBindingEvent event) { if (service == null) { getLogger() .warning( "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) { assert hasLock(); if (getAttribute(VaadinService.PRESERVE_UNBOUND_SESSION_ATTRIBUTE) == Boolean.TRUE) { return; } if (getState() == State.OPEN) { close(); } } else { service.fireSessionDestroy(this); } session = null; } VaadinSession(VaadinService service); @Override void valueBound(HttpSessionBindingEvent arg0); @Override void valueUnbound(HttpSessionBindingEvent event); @Deprecated WebBrowser getBrowser(); long getCumulativeRequestDuration(); void setLastRequestDuration(long time); long getLastRequestDuration(); void setLastRequestTimestamp(long timestamp); long getLastRequestTimestamp(); WrappedSession getSession(); @Deprecated LegacyCommunicationManager getCommunicationManager(); DragAndDropService getDragAndDropService(); @Deprecated static VaadinSession getForSession(VaadinService service,
            WrappedSession underlyingSession); static Collection<VaadinSession> getAllSessions(
            HttpSession httpSession); @Deprecated void removeFromSession(VaadinService service); @Deprecated void storeInSession(VaadinService service, WrappedSession session); void setCommunicationManager(
            LegacyCommunicationManager communicationManager); void setConfiguration(DeploymentConfiguration configuration); DeploymentConfiguration getConfiguration(); Locale getLocale(); void setLocale(Locale locale); ErrorHandler getErrorHandler(); void setErrorHandler(ErrorHandler errorHandler); ConverterFactory getConverterFactory(); void setConverterFactory(ConverterFactory converterFactory); void addRequestHandler(RequestHandler handler); void removeRequestHandler(RequestHandler handler); Collection<RequestHandler> getRequestHandlers(); static VaadinSession getCurrent(); static void setCurrent(VaadinSession session); Collection<UI> getUIs(); @Deprecated String createConnectorId(ClientConnector connector); UI getUIById(int uiId); boolean hasLock(); void addBootstrapListener(BootstrapListener listener); void removeBootstrapListener(BootstrapListener listener); @Deprecated void modifyBootstrapResponse(BootstrapResponse response); void removeUI(UI ui); GlobalResourceHandler getGlobalResourceHandler(boolean createOnDemand); 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); void addUIProvider(UIProvider uiProvider); void removeUIProvider(UIProvider uiProvider); List<UIProvider> getUIProviders(); VaadinService getService(); void close(); @Deprecated boolean isClosing(); State getState(); void accessSynchronously(Runnable runnable); Future<Void> access(Runnable runnable); Queue<FutureAccess> getPendingAccessQueue(); String getCsrfToken(); UI getUIByEmbedId(String embedId); void refreshTransients(WrappedSession wrappedSession,
            VaadinService vaadinService); static final String UI_PARAMETER; }### Answer:
@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()); }