use of com.vaadin.flow.server.startup.ApplicationConfiguration in project flow by vaadin.
the class DefaultDeploymentConfigurationTest method isXsrfProtectionEnabled_valueIsSetViaParentOnlyAndViaParent_valueIsTakenFromParent.
@Test
public void isXsrfProtectionEnabled_valueIsSetViaParentOnlyAndViaParent_valueIsTakenFromParent() {
ApplicationConfiguration appConfig = setupAppConfig();
Mockito.when(appConfig.isXsrfProtectionEnabled()).thenReturn(false);
Properties initParameters = new Properties();
initParameters.setProperty(InitParameters.SERVLET_PARAMETER_DISABLE_XSRF_PROTECTION, Boolean.FALSE.toString());
DefaultDeploymentConfiguration config = createDeploymentConfig(appConfig, initParameters);
// the deployment configuration parameter takes precedence over parent
// config
Assert.assertTrue(config.isXsrfProtectionEnabled());
}
use of com.vaadin.flow.server.startup.ApplicationConfiguration in project flow by vaadin.
the class DefaultDeploymentConfigurationTest method useV14Bootstrap_v14ModeIsSetViaParentOnlyAndViaParent_v14ModeIsTakenFromParent.
@Test
public void useV14Bootstrap_v14ModeIsSetViaParentOnlyAndViaParent_v14ModeIsTakenFromParent() {
ApplicationConfiguration appConfig = setupAppConfig();
Mockito.when(appConfig.useV14Bootstrap()).thenReturn(true);
Properties initParameters = new Properties();
initParameters.setProperty(InitParameters.SERVLET_PARAMETER_USE_V14_BOOTSTRAP, Boolean.TRUE.toString());
DefaultDeploymentConfiguration config = createDeploymentConfig(appConfig, initParameters);
// the deployment configuration parameter takes precedence over parent
// config
Assert.assertTrue(config.useV14Bootstrap());
}
use of com.vaadin.flow.server.startup.ApplicationConfiguration in project flow by vaadin.
the class CustomUIClassLoaderTest method createConfigurationMock.
private static DeploymentConfiguration createConfigurationMock() {
Properties properties = new Properties();
properties.put(InitParameters.UI_PARAMETER, MyUI.class.getName());
VaadinContext context = new MockVaadinContext();
ApplicationConfiguration config = Mockito.mock(ApplicationConfiguration.class);
Mockito.when(config.getPropertyNames()).thenReturn(Collections.emptyEnumeration());
Mockito.when(config.getBuildFolder()).thenReturn(".");
Mockito.when(config.getContext()).thenReturn(context);
return new DefaultDeploymentConfiguration(config, CustomUIClassLoaderTest.class, properties);
}
use of com.vaadin.flow.server.startup.ApplicationConfiguration in project flow by vaadin.
the class DeploymentConfigurationFactoryTest method createInitParameters_fallbackChunkIsCreatedViaAppConfig_fallbackChunkObjectIsInInitParams.
@Test
public void createInitParameters_fallbackChunkIsCreatedViaAppConfig_fallbackChunkObjectIsInInitParams() throws IOException {
ServletContext context = Mockito.mock(ServletContext.class);
ServletConfig config = Mockito.mock(ServletConfig.class);
ApplicationConfiguration appConfig = Mockito.mock(ApplicationConfiguration.class);
Mockito.when(config.getServletContext()).thenReturn(context);
Mockito.when(config.getInitParameterNames()).thenReturn(Collections.emptyEnumeration());
Mockito.when(context.getAttribute(ApplicationConfiguration.class.getName())).thenReturn(appConfig);
Mockito.when(appConfig.getFallbackChunk()).thenReturn(fallbackChunk);
Properties properties = new DeploymentConfigurationFactory().createInitParameters(Object.class, new VaadinServletConfig(config));
Object object = properties.get(DeploymentConfigurationFactory.FALLBACK_CHUNK);
Assert.assertSame(fallbackChunk, object);
}
use of com.vaadin.flow.server.startup.ApplicationConfiguration in project flow by vaadin.
the class DeploymentConfigurationFactoryTest method mockApplicationConfiguration.
private ApplicationConfiguration mockApplicationConfiguration() {
VaadinContext context = new MockVaadinContext();
ApplicationConfiguration configuration = Mockito.mock(ApplicationConfiguration.class);
Mockito.when(configuration.enableDevServer()).thenReturn(true);
Mockito.when(configuration.isProductionMode()).thenReturn(true);
Mockito.when(configuration.useV14Bootstrap()).thenReturn(false);
Mockito.when(configuration.getContext()).thenReturn(context);
Mockito.when(configuration.getStringProperty(Mockito.anyString(), Mockito.anyString())).thenReturn(null);
Mockito.when(configuration.isXsrfProtectionEnabled()).thenReturn(false);
Mockito.when(configuration.getPropertyNames()).thenReturn(Collections.emptyEnumeration());
fallbackChunk = Mockito.mock(FallbackChunk.class);
Mockito.when(configuration.getFallbackChunk()).thenReturn(fallbackChunk);
return configuration;
}
Aggregations