Search in sources :

Example 1 with StaticFileHandler

use of com.vaadin.flow.server.StaticFileHandler in project flow by vaadin.

the class LookupInitializerTest method initialize_noStaticFileHandlerFactory_defaultStaticFileHandlerFactoryCreated.

@Test
public void initialize_noStaticFileHandlerFactory_defaultStaticFileHandlerFactoryCreated() throws ServletException {
    AtomicReference<Lookup> capture = new AtomicReference<>();
    initializer.initialize(null, new HashMap<>(), capture::set);
    Lookup lookup = capture.get();
    StaticFileHandlerFactory factory = lookup.lookup(StaticFileHandlerFactory.class);
    VaadinService service = Mockito.mock(VaadinService.class);
    DeploymentConfiguration configuration = Mockito.mock(DeploymentConfiguration.class);
    Mockito.when(service.getDeploymentConfiguration()).thenReturn(configuration);
    ClassLoader loader = Mockito.mock(ClassLoader.class);
    Mockito.when(service.getClassLoader()).thenReturn(loader);
    StaticFileHandler handler = factory.createHandler(service);
    Assert.assertNotNull(handler);
    Assert.assertEquals(StaticFileServer.class, handler.getClass());
}
Also used : StaticFileHandler(com.vaadin.flow.server.StaticFileHandler) StaticFileHandlerFactory(com.vaadin.flow.server.StaticFileHandlerFactory) VaadinService(com.vaadin.flow.server.VaadinService) AtomicReference(java.util.concurrent.atomic.AtomicReference) DeploymentConfiguration(com.vaadin.flow.function.DeploymentConfiguration) Test(org.junit.Test)

Aggregations

DeploymentConfiguration (com.vaadin.flow.function.DeploymentConfiguration)1 StaticFileHandler (com.vaadin.flow.server.StaticFileHandler)1 StaticFileHandlerFactory (com.vaadin.flow.server.StaticFileHandlerFactory)1 VaadinService (com.vaadin.flow.server.VaadinService)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Test (org.junit.Test)1