Class MockVaadinHelper.BrowserlessLookupInitializer

java.lang.Object
com.vaadin.flow.server.startup.LookupServletContainerInitializer
com.vaadin.browserless.mocks.MockVaadinHelper.BrowserlessLookupInitializer
All Implemented Interfaces:
com.vaadin.flow.server.startup.ClassLoaderAwareServletContainerInitializer, jakarta.servlet.ServletContainerInitializer
Enclosing class:
MockVaadinHelper

public static class MockVaadinHelper.BrowserlessLookupInitializer extends com.vaadin.flow.server.startup.LookupServletContainerInitializer
The lookup initializer of the mocked environment.

It extends Vaadin's own with the services a browserless test needs on top of the ones LookupServletContainerInitializer declares in its HandlesTypes annotation — the browserless geolocation client, for one. A test adds services of its own through the lookupServices passed to MockVaadinHelper.createMockContext(java.util.Set).

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

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected Map<Class<?>,Class<?>>
    Services the testing environment wires through the Lookup, mapping a service interface to its default implementation.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an initializer registering the browserless environment's own services.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected Collection<Class<?>>
     
    void
    updateServices(Set<Class<?>> services)
    Adds the default implementation of every additionalServices entry the caller has not already covered.

    Methods inherited from class com.vaadin.flow.server.startup.LookupServletContainerInitializer

    process, requiresLookup

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.vaadin.flow.server.startup.ClassLoaderAwareServletContainerInitializer

    onStartup
  • Field Details

    • additionalServices

      protected Map<Class<?>,Class<?>> additionalServices
      Services the testing environment wires through the Lookup, mapping a service interface to its default implementation.

      An entry is skipped when the caller already supplied an implementation of that interface. Map an interface to Object to declare a service that has no default but can be hooked in by a test, e.g. Map.of(Service.class, Object.class).

  • Constructor Details

    • BrowserlessLookupInitializer

      public BrowserlessLookupInitializer()
      Creates an initializer registering the browserless environment's own services.
  • Method Details

    • updateServices

      public void updateServices(Set<Class<?>> services)
      Adds the default implementation of every additionalServices entry the caller has not already covered.
      Parameters:
      services - the service implementations to register, modified in place
    • getServiceTypes

      protected Collection<Class<?>> getServiceTypes()
      Overrides:
      getServiceTypes in class com.vaadin.flow.server.startup.LookupServletContainerInitializer