Class MockVaadinHelper.BrowserlessLookupInitializer
- All Implemented Interfaces:
ClassLoaderAwareServletContainerInitializer,jakarta.servlet.ServletContainerInitializer
- Enclosing class:
MockVaadinHelper
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
FieldsModifier and TypeFieldDescriptionServices the testing environment wires through theLookup, mapping a service interface to its default implementation. -
Constructor Summary
ConstructorsConstructorDescriptionCreates an initializer registering the browserless environment's own services. -
Method Summary
Modifier and TypeMethodDescriptionprotected Collection<Class<?>> Gets the service types that are used to set services into theLookupbased on found subtypes by theServletContainerInitializer.voidupdateServices(Set<Class<?>> services) Adds the default implementation of everyadditionalServicesentry the caller has not already covered.Methods inherited from class com.vaadin.flow.server.startup.LookupServletContainerInitializer
process, requiresLookupMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.server.startup.ClassLoaderAwareServletContainerInitializer
onStartup
-
Field Details
-
additionalServices
Services the testing environment wires through theLookup, 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
Objectto 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
Adds the default implementation of everyadditionalServicesentry the caller has not already covered.- Parameters:
services- the service implementations to register, modified in place
-
getServiceTypes
Description copied from class:LookupServletContainerInitializerGets the service types that are used to set services into theLookupbased on found subtypes by theServletContainerInitializer.LookupServletContainerInitializerusesServletContainerInitializerclasses discovering mechanism based onHandlesTypesannotation. The method may be overridden to return the service types which should be put into theLookupinstance if another mechanism of class searching is used (e.g. Spring boot case).The set of classes (passed into the
LookupServletContainerInitializer.process(Set, ServletContext)method) will be filtered via checking whether they are assignable to the service types and the resulting classes will be instantiated via reflection.- Overrides:
getServiceTypesin classLookupServletContainerInitializer- Returns:
- a collection of service types which should be available via Lookup
- See Also:
-