Search in sources :

Example 1 with MockDeploymentConfiguration

use of com.vaadin.base.devserver.MockDeploymentConfiguration in project flow by vaadin.

the class AbstractDevModeTest method setup.

@Before
public void setup() throws Exception {
    baseDir = temporaryFolder.getRoot().getPath();
    npmFolder = temporaryFolder.getRoot();
    Boolean enablePnpm = Boolean.TRUE;
    appConfig = Mockito.mock(ApplicationConfiguration.class);
    servletContext = Mockito.mock(ServletContext.class);
    Mockito.when(servletContext.getAttribute(ApplicationConfiguration.class.getName())).thenReturn(appConfig);
    Mockito.when(servletContext.getClassLoader()).thenReturn(servletContext.getClass().getClassLoader());
    vaadinContext = new VaadinServletContext(servletContext);
    mockApplicationConfiguration(appConfig, enablePnpm);
    lookup = Mockito.mock(Lookup.class);
    Mockito.when(servletContext.getAttribute(Lookup.class.getName())).thenReturn(lookup);
    ResourceProvider resourceProvider = Mockito.mock(ResourceProvider.class);
    Mockito.when(lookup.lookup(ResourceProvider.class)).thenReturn(resourceProvider);
    devModeHandlerManager = new DevModeHandlerManagerImpl();
    Mockito.when(lookup.lookup(DevModeHandlerManager.class)).thenReturn(devModeHandlerManager);
    configuration = new MockDeploymentConfiguration();
    Mockito.when(lookup.lookup(DeploymentConfiguration.class)).thenReturn(configuration);
    Mockito.when(lookup.lookup(ApplicationConfiguration.class)).thenReturn(appConfig);
    Mockito.when(lookup.lookup(StaticFileHandlerFactory.class)).thenReturn(service -> new StaticFileServer(service));
    vaadinService = Mockito.mock(VaadinService.class);
    Mockito.when(vaadinService.getContext()).thenReturn(vaadinContext);
    Mockito.when(vaadinService.getDeploymentConfiguration()).thenReturn(configuration);
}
Also used : VaadinServletContext(com.vaadin.flow.server.VaadinServletContext) StaticFileServer(com.vaadin.flow.server.StaticFileServer) ResourceProvider(com.vaadin.flow.di.ResourceProvider) DevModeHandlerManagerImpl(com.vaadin.base.devserver.DevModeHandlerManagerImpl) MockDeploymentConfiguration(com.vaadin.base.devserver.MockDeploymentConfiguration) VaadinService(com.vaadin.flow.server.VaadinService) VaadinServletContext(com.vaadin.flow.server.VaadinServletContext) ServletContext(javax.servlet.ServletContext) Lookup(com.vaadin.flow.di.Lookup) ApplicationConfiguration(com.vaadin.flow.server.startup.ApplicationConfiguration) Before(org.junit.Before)

Aggregations

DevModeHandlerManagerImpl (com.vaadin.base.devserver.DevModeHandlerManagerImpl)1 MockDeploymentConfiguration (com.vaadin.base.devserver.MockDeploymentConfiguration)1 Lookup (com.vaadin.flow.di.Lookup)1 ResourceProvider (com.vaadin.flow.di.ResourceProvider)1 StaticFileServer (com.vaadin.flow.server.StaticFileServer)1 VaadinService (com.vaadin.flow.server.VaadinService)1 VaadinServletContext (com.vaadin.flow.server.VaadinServletContext)1 ApplicationConfiguration (com.vaadin.flow.server.startup.ApplicationConfiguration)1 ServletContext (javax.servlet.ServletContext)1 Before (org.junit.Before)1