Package com.vaadin.browserless.mocks
Class MockSpringServlet
java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
com.vaadin.flow.server.VaadinServlet
com.vaadin.flow.spring.SpringServlet
com.vaadin.browserless.mocks.MockSpringServlet
- All Implemented Interfaces:
jakarta.servlet.Servlet,jakarta.servlet.ServletConfig,Serializable
public class MockSpringServlet
extends com.vaadin.flow.spring.SpringServlet
Makes sure that the
routes are properly registered, and that
MockSpringServletService is used instead of vanilla
SpringVaadinServletService.
For internal use only. May be renamed or removed in a future release.
- Since:
- 1.0
- Author:
- mavi
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal @NonNull org.springframework.context.ApplicationContextThe Spring context the views are instantiated from.final @NonNull com.vaadin.browserless.internal.RoutesThe routes registered when the service is created.final @NonNull com.vaadin.browserless.internal.UIFactoryCreates the UI of the session that replaces a closed session of this servlet.Fields inherited from class com.vaadin.flow.spring.SpringServlet
PROPERTY_NAMESFields inherited from class com.vaadin.flow.server.VaadinServlet
INTERNAL_VAADIN_SERVLET_VITE_DEV_MODE_FRONTEND_PATHFields inherited from class jakarta.servlet.http.HttpServlet
LEGACY_DO_HEAD -
Constructor Summary
ConstructorsConstructorDescriptionMockSpringServlet(@NonNull com.vaadin.browserless.internal.Routes routes, @NonNull org.springframework.context.ApplicationContext ctx, @NonNull com.vaadin.browserless.internal.UIFactory uiFactory) Creates the servlet. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidapplySpringSecurityIfPresent(com.vaadin.browserless.mocks.MockRequest request) Augments the mock HTTP request backed by Vaadin request, with authentication information provided by Spring Security framework.protected com.vaadin.flow.function.DeploymentConfigurationprotected com.vaadin.flow.server.VaadinServletServicecreateServletService(com.vaadin.flow.function.DeploymentConfiguration deploymentConfiguration) protected com.vaadin.flow.server.VaadinServletRequestcreateVaadinRequest(jakarta.servlet.http.HttpServletRequest request) Methods inherited from class com.vaadin.flow.spring.SpringServlet
createDeploymentConfiguration, serviceMethods inherited from class com.vaadin.flow.server.VaadinServlet
createServletService, createStaticFileHandler, destroy, getCurrent, getFrontendMapping, getLastPathParameter, getService, getServletConfig, handleContextOrServletRootWithoutSlash, init, serveStaticOrWebJarRequest, servletInitialized, whenFrontendMappingAvailableMethods inherited from class jakarta.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPatch, doPost, doPut, doTrace, getLastModified, isSensitiveHeader, serviceMethods inherited from class jakarta.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletContext, getServletInfo, getServletName, init, log, log
-
Field Details
-
routes
public final @NonNull com.vaadin.browserless.internal.Routes routesThe routes registered when the service is created. -
ctx
public final @NonNull org.springframework.context.ApplicationContext ctxThe Spring context the views are instantiated from. -
uiFactory
public final @NonNull com.vaadin.browserless.internal.UIFactory uiFactoryCreates the UI of the session that replaces a closed session of this servlet.
-
-
Constructor Details
-
MockSpringServlet
public MockSpringServlet(@NonNull com.vaadin.browserless.internal.Routes routes, @NonNull org.springframework.context.ApplicationContext ctx, @NonNull com.vaadin.browserless.internal.UIFactory uiFactory) Creates the servlet.- Parameters:
routes- the routes to registerctx- the Spring context the views are instantiated fromuiFactory- creates the UI of the session that replaces a closed session
-
-
Method Details
-
createDeploymentConfiguration
protected com.vaadin.flow.function.DeploymentConfiguration createDeploymentConfiguration() throws jakarta.servlet.ServletException- Overrides:
createDeploymentConfigurationin classcom.vaadin.flow.server.VaadinServlet- Throws:
jakarta.servlet.ServletException
-
createServletService
protected com.vaadin.flow.server.VaadinServletService createServletService(com.vaadin.flow.function.DeploymentConfiguration deploymentConfiguration) throws com.vaadin.flow.server.ServiceException - Overrides:
createServletServicein classcom.vaadin.flow.spring.SpringServlet- Throws:
com.vaadin.flow.server.ServiceException
-
createVaadinRequest
protected com.vaadin.flow.server.VaadinServletRequest createVaadinRequest(jakarta.servlet.http.HttpServletRequest request) - Overrides:
createVaadinRequestin classcom.vaadin.flow.server.VaadinServlet
-
applySpringSecurityIfPresent
public static void applySpringSecurityIfPresent(com.vaadin.browserless.mocks.MockRequest request) Augments the mock HTTP request backed by Vaadin request, with authentication information provided by Spring Security framework. Nothing is done if Spring Security is not present on classpath.- Parameters:
request- the mock request instance
-