Search in sources :

Example 26 with VaadinContext

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

the class BrowserLiveReloadAccessorImplTest method getLiveReload_liveReloadDisabled_instanceIsCreated.

@Test
public void getLiveReload_liveReloadDisabled_instanceIsCreated() {
    VaadinService service = Mockito.mock(VaadinService.class);
    DeploymentConfiguration config = Mockito.mock(DeploymentConfiguration.class);
    Mockito.when(service.getDeploymentConfiguration()).thenReturn(config);
    Mockito.when(config.isProductionMode()).thenReturn(false);
    Mockito.when(config.isDevModeLiveReloadEnabled()).thenReturn(false);
    VaadinContext context = Mockito.mock(VaadinContext.class);
    Mockito.when(context.getAttribute(Mockito.eq(BrowserLiveReload.class), Mockito.any())).thenReturn(Mockito.mock(BrowserLiveReload.class));
    Mockito.when(service.getContext()).thenReturn(context);
    Assert.assertNotNull(access.getLiveReload(service));
}
Also used : VaadinContext(com.vaadin.flow.server.VaadinContext) VaadinService(com.vaadin.flow.server.VaadinService) BrowserLiveReload(com.vaadin.flow.internal.BrowserLiveReload) DeploymentConfiguration(com.vaadin.flow.function.DeploymentConfiguration) Test(org.junit.Test)

Example 27 with VaadinContext

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

the class SpringApplicationConfigurationFactory method doCreate.

@Override
protected ApplicationConfigurationImpl doCreate(VaadinContext context, FallbackChunk chunk, Map<String, String> properties) {
    ApplicationContext appContext = SpringLookupInitializer.getApplicationContext(context);
    Environment env = appContext.getBean(Environment.class);
    // Collect any vaadin.XZY properties from application.properties
    SpringServlet.PROPERTY_NAMES.stream().filter(name -> env.getProperty("vaadin." + name) != null).forEach(name -> properties.put(name, env.getProperty("vaadin." + name)));
    return super.doCreate(context, chunk, properties);
}
Also used : VaadinContext(com.vaadin.flow.server.VaadinContext) FallbackChunk(com.vaadin.flow.server.frontend.FallbackChunk) Environment(org.springframework.core.env.Environment) Map(java.util.Map) ApplicationContext(org.springframework.context.ApplicationContext) DefaultApplicationConfigurationFactory(com.vaadin.flow.server.startup.DefaultApplicationConfigurationFactory) ApplicationContext(org.springframework.context.ApplicationContext) Environment(org.springframework.core.env.Environment)

Example 28 with VaadinContext

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

the class DevModeBrowserLauncher method isProductionMode.

private static boolean isProductionMode(GenericWebApplicationContext app) {
    ServletContext servletContext = app.getServletContext();
    VaadinContext context = new VaadinServletContext(servletContext);
    ApplicationConfiguration applicationConfiguration = ApplicationConfiguration.get(context);
    return applicationConfiguration.isProductionMode();
}
Also used : VaadinServletContext(com.vaadin.flow.server.VaadinServletContext) VaadinContext(com.vaadin.flow.server.VaadinContext) VaadinServletContext(com.vaadin.flow.server.VaadinServletContext) ServletContext(javax.servlet.ServletContext) ApplicationConfiguration(com.vaadin.flow.server.startup.ApplicationConfiguration)

Example 29 with VaadinContext

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

the class DebugWindowConnectionTest method getMockContext.

private VaadinContext getMockContext() {
    VaadinContext context = new MockVaadinContext();
    context.setAttribute(Lookup.class, Lookup.of(Mockito.mock(ApplicationConfiguration.class), ApplicationConfiguration.class));
    return context;
}
Also used : VaadinContext(com.vaadin.flow.server.VaadinContext) ApplicationConfiguration(com.vaadin.flow.server.startup.ApplicationConfiguration)

Example 30 with VaadinContext

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

the class PushHandler method isProductionMode.

private boolean isProductionMode() {
    VaadinContext context = service.getContext();
    ApplicationConfiguration conf = ApplicationConfiguration.get(context);
    return conf.isProductionMode();
}
Also used : VaadinContext(com.vaadin.flow.server.VaadinContext) ApplicationConfiguration(com.vaadin.flow.server.startup.ApplicationConfiguration)

Aggregations

VaadinContext (com.vaadin.flow.server.VaadinContext)42 Test (org.junit.Test)16 ApplicationConfiguration (com.vaadin.flow.server.startup.ApplicationConfiguration)15 VaadinService (com.vaadin.flow.server.VaadinService)11 Lookup (com.vaadin.flow.di.Lookup)8 ResourceProvider (com.vaadin.flow.di.ResourceProvider)8 DeploymentConfiguration (com.vaadin.flow.function.DeploymentConfiguration)5 BrowserLiveReload (com.vaadin.flow.internal.BrowserLiveReload)5 DefaultDeploymentConfiguration (com.vaadin.flow.server.DefaultDeploymentConfiguration)5 MockVaadinContext (com.vaadin.flow.server.MockVaadinContext)5 Properties (java.util.Properties)5 MockVaadinServletService (com.vaadin.flow.server.MockVaadinServletService)4 VaadinConfig (com.vaadin.flow.server.VaadinConfig)4 MockDeploymentConfiguration (com.vaadin.tests.util.MockDeploymentConfiguration)4 File (java.io.File)4 Before (org.junit.Before)4 VaadinSession (com.vaadin.flow.server.VaadinSession)3 WebComponentConfigurationRegistry (com.vaadin.flow.server.webcomponent.WebComponentConfigurationRegistry)3 AppShellRegistry (com.vaadin.flow.server.AppShellRegistry)2 VaadinServletContext (com.vaadin.flow.server.VaadinServletContext)2