Class MockService

All Implemented Interfaces:
Serializable

public class MockService extends VaadinServletService
The VaadinServletService of the mocked environment.

It stands in for a deployed service in the three places a browserless test has nothing to offer:

Object creation is not mocked. The service uses whatever Instantiator the environment's Lookup provides, which is how views and beans still come from the real container.

The class is not final, so a custom service can be registered by overriding MockVaadinServlet.createServletService(DeploymentConfiguration), but the shape of what it overrides is not part of the published API.

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

See Also:
  • Constructor Details

    • MockService

      public MockService(VaadinServlet servlet, DeploymentConfiguration deploymentConfiguration)
      Creates a service whose sessions produce MockedUI instances.
      Parameters:
      servlet - the servlet owning this service
      deploymentConfiguration - the configuration to run with
    • MockService

      public MockService(VaadinServlet servlet, DeploymentConfiguration deploymentConfiguration, UIFactory uiFactory)
      Creates a service whose sessions produce UIs from the given factory.
      Parameters:
      servlet - the servlet owning this service
      deploymentConfiguration - the configuration to run with
      uiFactory - creates the UI of the session that replaces a closed session; it must return a new instance every time, or a test inherits the previous test's state
  • Method Details

    • getUiFactory

      public UIFactory getUiFactory()
      Returns the factory creating the UI of the session that replaces a closed session of this service.
      Returns:
      the UI factory
    • isAtmosphereAvailable

      protected boolean isAtmosphereAvailable()
      Description copied from class: VaadinService
      Checks whether Atmosphere is available for use.
      Overrides:
      isAtmosphereAvailable in class VaadinService
      Returns:
      true if Atmosphere is available, false otherwise
    • getMainDivId

      public String getMainDivId(VaadinSession session, VaadinRequest request)
      Description copied from class: VaadinService
      Creates and returns a unique ID for the DIV where the UI is to be rendered.
      Overrides:
      getMainDivId in class VaadinServletService
      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

      protected VaadinSession createVaadinSession(VaadinRequest request)
      Description copied from class: VaadinService
      Creates a new Vaadin session for this service and request.
      Overrides:
      createVaadinSession in class VaadinService
      Parameters:
      request - The request for which to create a VaadinSession
      Returns:
      A new VaadinSession