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.
Author:
mavi
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final org.springframework.context.ApplicationContext
     
    final com.vaadin.browserless.internal.Routes
     
    final com.vaadin.browserless.internal.UIFactory
     

    Fields inherited from class com.vaadin.flow.spring.SpringServlet

    PROPERTY_NAMES

    Fields inherited from class com.vaadin.flow.server.VaadinServlet

    INTERNAL_VAADIN_SERVLET_VITE_DEV_MODE_FRONTEND_PATH

    Fields inherited from class jakarta.servlet.http.HttpServlet

    LEGACY_DO_HEAD
  • Constructor Summary

    Constructors
    Constructor
    Description
    MockSpringServlet(com.vaadin.browserless.internal.Routes routes, org.springframework.context.ApplicationContext ctx, com.vaadin.browserless.internal.UIFactory uiFactory)
     
    MockSpringServlet(com.vaadin.browserless.internal.Routes routes, org.springframework.context.ApplicationContext ctx, kotlin.jvm.functions.Function0<com.vaadin.flow.component.UI> uiFactory)
    Deprecated, for removal: This API element is subject to removal in a future version.
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    protected com.vaadin.flow.function.DeploymentConfiguration
     
    protected com.vaadin.flow.server.VaadinServletService
    createServletService(com.vaadin.flow.function.DeploymentConfiguration deploymentConfiguration)
     
    protected com.vaadin.flow.server.VaadinServletRequest
    createVaadinRequest(jakarta.servlet.http.HttpServletRequest request)
     

    Methods inherited from class com.vaadin.flow.spring.SpringServlet

    createDeploymentConfiguration, service

    Methods inherited from class com.vaadin.flow.server.VaadinServlet

    createServletService, createStaticFileHandler, destroy, getCurrent, getFrontendMapping, getLastPathParameter, getService, getServletConfig, handleContextOrServletRootWithoutSlash, init, serveStaticOrWebJarRequest, servletInitialized, whenFrontendMappingAvailable

    Methods inherited from class jakarta.servlet.http.HttpServlet

    doDelete, doGet, doHead, doOptions, doPatch, doPost, doPut, doTrace, getLastModified, isSensitiveHeader, service

    Methods inherited from class jakarta.servlet.GenericServlet

    getInitParameter, getInitParameterNames, getServletContext, getServletInfo, getServletName, init, log, log

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • routes

      @NotNull public final com.vaadin.browserless.internal.Routes routes
    • ctx

      @NotNull public final org.springframework.context.ApplicationContext ctx
    • uiFactory

      @NotNull public final com.vaadin.browserless.internal.UIFactory uiFactory
  • Constructor Details

    • MockSpringServlet

      @Deprecated(forRemoval=true) public MockSpringServlet(@NotNull com.vaadin.browserless.internal.Routes routes, @NotNull org.springframework.context.ApplicationContext ctx, @NotNull kotlin.jvm.functions.Function0<com.vaadin.flow.component.UI> uiFactory)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • MockSpringServlet

      public MockSpringServlet(@NotNull com.vaadin.browserless.internal.Routes routes, @NotNull org.springframework.context.ApplicationContext ctx, @NotNull com.vaadin.browserless.internal.UIFactory uiFactory)
  • Method Details

    • createDeploymentConfiguration

      protected com.vaadin.flow.function.DeploymentConfiguration createDeploymentConfiguration() throws jakarta.servlet.ServletException
      Overrides:
      createDeploymentConfiguration in class com.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:
      createServletService in class com.vaadin.flow.spring.SpringServlet
      Throws:
      com.vaadin.flow.server.ServiceException
    • createVaadinRequest

      protected com.vaadin.flow.server.VaadinServletRequest createVaadinRequest(jakarta.servlet.http.HttpServletRequest request)
      Overrides:
      createVaadinRequest in class com.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