Package com.vaadin.browserless.mocks
Class MockVaadinSession
java.lang.Object
com.vaadin.flow.server.VaadinSession
com.vaadin.browserless.mocks.MockVaadinSession
- All Implemented Interfaces:
jakarta.servlet.http.HttpSessionBindingListener,Serializable,EventListener
public class MockVaadinSession
extends com.vaadin.flow.server.VaadinSession
A
VaadinSession that is replaced by a fresh one when it is closed.
Closing the session is how an application logs a user out: it then tells the
browser to reload, and the servlet container hands the reloaded page a brand
new session. There is no browser here, so close() does that itself
and the test can go on to assert that a login view is shown.
A subclass that overrides close() has to keep both halves: call
super.close(), then
MockVaadin.afterSessionClose(VaadinSession, UIFactory).
For internal use only. May be renamed or removed in a future release.
- See Also:
-
Field Summary
Fields inherited from class com.vaadin.flow.server.VaadinSession
browser -
Constructor Summary
ConstructorsConstructorDescriptionMockVaadinSession(com.vaadin.flow.server.VaadinService service, UIFactory uiFactory) Creates a session for the given service. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Returns the factory producing theUIof the session that replaces this one once it is closed.Methods inherited from class com.vaadin.flow.server.VaadinSession
access, accessSynchronously, addRequestHandler, addSessionDestroyListener, addUI, applyLockStrategy, checkHasLock, checkHasLock, createStreamResourceRegistry, findElement, getAllSessions, getAttribute, getAttribute, getBrowser, getConfiguration, getCumulativeRequestDuration, getCurrent, getCurrentOrThrow, getErrorHandler, getLastLocked, getLastRequestDuration, getLastRequestTimestamp, getLastUnlocked, getLocale, getLockInstance, getNextUIid, getPendingAccessQueue, getPushId, getRequestHandlers, getResourceRegistry, getService, getSession, getState, getUIById, getUIs, hasLock, hasLock, localeSignal, lock, refreshTransients, removeRequestHandler, removeUI, setAttribute, setAttribute, setBrowser, setCurrent, setErrorHandler, setLastRequestDuration, setLastRequestTimestamp, setLocale, setState, unlock, valueBound, valueUnbound
-
Constructor Details
-
MockVaadinSession
Creates a session for the given service.- Parameters:
service- the service owning this sessionuiFactory- produces the UI of the replacement session; it must return a fresh instance, not one already attached to a session
-
-
Method Details
-
getUiFactory
Returns the factory producing theUIof the session that replaces this one once it is closed.- Returns:
- the UI factory
-
close
public void close()- Overrides:
closein classcom.vaadin.flow.server.VaadinSession
-