Class MockServletConfig

java.lang.Object
com.vaadin.browserless.mocks.MockServletConfig
All Implemented Interfaces:
jakarta.servlet.ServletConfig

public class MockServletConfig extends Object implements jakarta.servlet.ServletConfig
The ServletConfig the mocked servlet is initialized with.

It carries the per-servlet init parameters and the ServletContext, which is the whole of what a Vaadin servlet reads from its config. The servlet name is fixed at "Vaadin Servlet".

Init parameters are read while the servlet initializes, so they have to be in getServletInitParams() before Servlet.init(ServletConfig) is called; setting one afterwards has no effect.

For internal use only. May be renamed or removed in a future release.

  • Constructor Details

    • MockServletConfig

      public MockServletConfig(jakarta.servlet.ServletContext context)
      Creates a config for a servlet in the given context, with no init parameters.
      Parameters:
      context - the context the servlet belongs to
  • Method Details

    • getContext

      public jakarta.servlet.ServletContext getContext()
      Returns the context the configured servlet belongs to. Same value as getServletContext().
      Returns:
      the servlet context
    • getServletInitParams

      public Map<String,String> getServletInitParams()
      Returns the per-servlet init parameters, live and directly modifiable. Populate before the servlet is initialized.
      Returns:
      the init parameters
    • setServletInitParams

      public void setServletInitParams(Map<String,String> servletInitParams)
      Replaces the per-servlet init parameters.
      Parameters:
      servletInitParams - the init parameters
    • getInitParameter

      public String getInitParameter(String name)
      Specified by:
      getInitParameter in interface jakarta.servlet.ServletConfig
    • getInitParameterNames

      public Enumeration<String> getInitParameterNames()
      Specified by:
      getInitParameterNames in interface jakarta.servlet.ServletConfig
    • getServletName

      public String getServletName()
      Specified by:
      getServletName in interface jakarta.servlet.ServletConfig
    • getServletContext

      public jakarta.servlet.ServletContext getServletContext()
      Specified by:
      getServletContext in interface jakarta.servlet.ServletConfig