Package com.vaadin.testbench.unit.mocks
Class MockSpringServletService
java.lang.Object
com.vaadin.flow.server.VaadinService
com.vaadin.flow.server.VaadinServletService
com.vaadin.flow.spring.SpringVaadinServletService
com.vaadin.testbench.unit.mocks.MockSpringServletService
- All Implemented Interfaces:
Serializable
A mocking service that performs three very important tasks:
- Overrides
isAtmosphereAvailable()
to tell Vaadin that we don't have Atmosphere (otherwise Vaadin will crash) - Provides some dummy value as a root ID via
getMainDivId(com.vaadin.flow.server.VaadinSession, com.vaadin.flow.server.VaadinRequest)
(otherwise the mocked servlet env will crash). - Provides a
MockSpringVaadinSession
instead ofSpringVaadinSession
.
- Author:
- mavi
- See Also:
-
Field Summary
Fields inherited from class com.vaadin.flow.server.VaadinService
ATMOSPHERE_MISSING_ERROR, INVALID_ATMOSPHERE_VERSION_WARNING
-
Constructor Summary
ConstructorsConstructorDescriptionMockSpringServletService
(MockSpringServlet servlet, DeploymentConfiguration deploymentConfiguration, org.springframework.context.ApplicationContext ctx, kotlin.jvm.functions.Function0<UI> uiFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected VaadinSession
createVaadinSession
(VaadinRequest request) Creates a new Vaadin session for this service and request.Gets the instantiator used by this service.getMainDivId
(VaadinSession session, VaadinRequest request) Creates and returns a unique ID for the DIV where the UI is to be rendered.protected boolean
Checks whether Atmosphere is available for use.Methods inherited from class com.vaadin.flow.spring.SpringVaadinServletService
getStaticResource, init, loadInstantiators
Methods inherited from class com.vaadin.flow.server.VaadinServletService
constructVaadinContext, createRequestHandlers, getContextRootRelativePath, getCurrentResponse, getCurrentServletRequest, getMimeType, getPwaRegistry, getResource, getResourceAsStream, getResourceInServletContext, getRouteRegistry, getServiceName, getServlet, requestCanCreateSession, resolveResource, setDefaultClassLoader
Methods inherited from class com.vaadin.flow.server.VaadinService
accessSession, addServiceDestroyListener, addSessionDestroyListener, addSessionInitListener, addUIInitListener, closeSession, createCriticalNotificationJSON, createCriticalNotificationJSON, createInstantiator, createSessionExpiredJSON, createUINotFoundJSON, createVaadinRequestInterceptors, destroy, ensureAccessQueuePurged, ensurePushAvailable, findUI, findVaadinSession, fireSessionDestroy, fireUIInitListeners, getBootstrapInitialPredicate, getBootstrapUrlPredicate, getClassLoader, getContext, getCsrfTokenAttributeName, getCurrent, getCurrentRequest, getDependencyFilters, getDeploymentConfiguration, getExistingSession, getRequestHandlers, getRouter, getSessionAttributeName, getSessionLock, getSystemMessages, getSystemMessagesProvider, getVaadinRequestInterceptors, handleRequest, handleSessionExpired, isCsrfTokenValid, isOtherSessionLocked, isResourceAvailable, isUIActive, loadSession, lockSession, modifyIndexHtmlResponse, readFromHttpSession, reinitializeSession, removeFromHttpSession, removeSession, requestEnd, requestStart, runPendingAccessTasks, setBootstrapInitialPredicate, setBootstrapUrlPredicate, setClassLoader, setCurrent, setCurrentInstances, setSystemMessagesProvider, storeSession, unlockSession, verifyNoOtherSessionLocked, writeStringResponse, writeToHttpSession, writeUncachedStringResponse
-
Constructor Details
-
MockSpringServletService
public MockSpringServletService(@NotNull MockSpringServlet servlet, @NotNull DeploymentConfiguration deploymentConfiguration, @NotNull org.springframework.context.ApplicationContext ctx, @NotNull kotlin.jvm.functions.Function0<UI> uiFactory)
-
-
Method Details
-
isAtmosphereAvailable
protected boolean isAtmosphereAvailable()Description copied from class:VaadinService
Checks whether Atmosphere is available for use.- Overrides:
isAtmosphereAvailable
in classVaadinService
- Returns:
- true if Atmosphere is available, false otherwise
-
getMainDivId
Description copied from class:VaadinService
Creates and returns a unique ID for the DIV where the UI is to be rendered.- Overrides:
getMainDivId
in classVaadinServletService
- Parameters:
session
- The service session to which the bootstrapped UI will belong.request
- The request for which a div id is needed- Returns:
- the id to use in the DOM
-
createVaadinSession
Description copied from class:VaadinService
Creates a new Vaadin session for this service and request.- Overrides:
createVaadinSession
in classSpringVaadinServletService
- Parameters:
request
- The request for which to create a VaadinSession- Returns:
- A new VaadinSession
-
getInstantiator
Description copied from class:VaadinService
Gets the instantiator used by this service.- Overrides:
getInstantiator
in classVaadinService
- Returns:
- the used instantiator, or
null
if this service has not yet been initialized - See Also:
-