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 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 Details

    • routes

      public final @NonNull Routes routes
      The routes registered when the service is created.
    • ctx

      public final @NonNull org.springframework.context.ApplicationContext ctx
      The Spring context the views are instantiated from.
    • uiFactory

      public final @NonNull UIFactory uiFactory
      Creates the UI of the session that replaces a closed session of this servlet.
  • Constructor Details

    • MockSpringServlet

      public MockSpringServlet(@NonNull Routes routes, @NonNull org.springframework.context.ApplicationContext ctx, @NonNull UIFactory uiFactory)
      Creates the servlet.
      Parameters:
      routes - the routes to register
      ctx - the Spring context the views are instantiated from
      uiFactory - creates the UI of the session that replaces a closed session
  • Method Details

    • createDeploymentConfiguration

      protected DeploymentConfiguration createDeploymentConfiguration() throws jakarta.servlet.ServletException
      Description copied from class: VaadinServlet
      Creates a deployment configuration to be used for the creation of a VaadinService. Intended to be used by dependency injection frameworks.
      Overrides:
      createDeploymentConfiguration in class VaadinServlet
      Returns:
      the created deployment configuration
      Throws:
      jakarta.servlet.ServletException - if creating the deployment configuration fails
    • createServletService

      protected VaadinServletService createServletService(DeploymentConfiguration deploymentConfiguration) throws ServiceException
      Description copied from class: VaadinServlet
      Creates a vaadin servlet service.
      Overrides:
      createServletService in class SpringServlet
      Parameters:
      deploymentConfiguration - the deployment configuration to be used
      Returns:
      the created vaadin servlet service
      Throws:
      ServiceException - if creating the vaadin servlet service fails
    • createVaadinRequest

      protected VaadinServletRequest createVaadinRequest(jakarta.servlet.http.HttpServletRequest request)
      Description copied from class: VaadinServlet
      Creates a Vaadin request for a http servlet request. This method can be overridden if the Vaadin request should have special properties.
      Overrides:
      createVaadinRequest in class VaadinServlet
      Parameters:
      request - the original http servlet request
      Returns:
      a Vaadin request for the original request
    • applySpringSecurityIfPresent

      public static void applySpringSecurityIfPresent(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