use of com.vaadin.flow.server.startup.ApplicationConfiguration in project flow by vaadin.
the class PropertyDeploymentConfigurationTest method useV14Bootstrap_valueIsProvidedViaParentOnly_propertyIsSetToAnotherValue_valueFromParentIsReturnedViaAPI.
@Test
public void useV14Bootstrap_valueIsProvidedViaParentOnly_propertyIsSetToAnotherValue_valueFromParentIsReturnedViaAPI() {
ApplicationConfiguration appConfig = mockAppConfig();
// The property value is provided via API
Mockito.when(appConfig.useV14Bootstrap()).thenReturn(true);
// The property whose value is overridden above via API is different
Mockito.when(appConfig.getPropertyNames()).thenReturn(Collections.enumeration(Collections.singleton(InitParameters.SERVLET_PARAMETER_USE_V14_BOOTSTRAP)));
Mockito.when(appConfig.getStringProperty(InitParameters.SERVLET_PARAMETER_USE_V14_BOOTSTRAP, null)).thenReturn(Boolean.FALSE.toString());
PropertyDeploymentConfiguration config = createConfiguration(appConfig, new Properties());
// Several things are checked: the value from parent is used via API and
// deployment configuration doesn't read the property directly even
// though its "getInitParameters" method returns the property. Also
// "getApplicationProperty" method checks the parent properties which
// should not be taken into account here
Assert.assertTrue(config.useV14Bootstrap());
Assert.assertTrue(config.getInitParameters().containsKey(InitParameters.SERVLET_PARAMETER_USE_V14_BOOTSTRAP));
}
use of com.vaadin.flow.server.startup.ApplicationConfiguration in project flow by vaadin.
the class PropertyDeploymentConfigurationTest method reuseDevServer_valueIsProvidedViaParentOnly_valueFromParentIsReturned.
@Test
public void reuseDevServer_valueIsProvidedViaParentOnly_valueFromParentIsReturned() {
ApplicationConfiguration appConfig = mockAppConfig();
Mockito.when(appConfig.reuseDevServer()).thenReturn(true);
PropertyDeploymentConfiguration config = createConfiguration(appConfig, new Properties());
Assert.assertTrue(config.reuseDevServer());
// there is no any property
Assert.assertTrue(config.getInitParameters().isEmpty());
}
use of com.vaadin.flow.server.startup.ApplicationConfiguration in project flow by vaadin.
the class PropertyDeploymentConfigurationTest method isPnpmEnabled_valueIsProvidedViaPropertiesAndParent_valueFromPropertiesIsReturned.
@Test
public void isPnpmEnabled_valueIsProvidedViaPropertiesAndParent_valueFromPropertiesIsReturned() {
ApplicationConfiguration appConfig = mockAppConfig();
Mockito.when(appConfig.isPnpmEnabled()).thenReturn(false);
Properties properties = new Properties();
properties.put(InitParameters.SERVLET_PARAMETER_ENABLE_PNPM, Boolean.TRUE.toString());
PropertyDeploymentConfiguration config = createConfiguration(appConfig, properties);
Assert.assertTrue(config.isPnpmEnabled());
Assert.assertEquals(properties, config.getInitParameters());
}
use of com.vaadin.flow.server.startup.ApplicationConfiguration in project flow by vaadin.
the class PropertyDeploymentConfigurationTest method getInitParameters_prorprtiesAreMergedFromParentAndDeploymentConfig.
@Test
public void getInitParameters_prorprtiesAreMergedFromParentAndDeploymentConfig() {
ApplicationConfiguration appConfig = Mockito.mock(ApplicationConfiguration.class);
Mockito.when(appConfig.getPropertyNames()).thenReturn(Collections.enumeration(Collections.singleton("foo")));
Mockito.when(appConfig.getStringProperty("foo", null)).thenReturn("foobar");
Properties properties = new Properties();
properties.put("bar", "baz");
PropertyDeploymentConfiguration configuration = createConfiguration(appConfig, properties);
Properties initParameters = configuration.getInitParameters();
Assert.assertEquals("foobar", initParameters.get("foo"));
Assert.assertEquals("baz", initParameters.get("bar"));
}
use of com.vaadin.flow.server.startup.ApplicationConfiguration in project flow by vaadin.
the class PropertyDeploymentConfigurationTest method reuseDevServer_valueIsProvidedViaPropertiesAndParent_valueFromPropertiesIsReturned.
@Test
public void reuseDevServer_valueIsProvidedViaPropertiesAndParent_valueFromPropertiesIsReturned() {
ApplicationConfiguration appConfig = mockAppConfig();
Mockito.when(appConfig.reuseDevServer()).thenReturn(false);
Properties properties = new Properties();
properties.put(InitParameters.SERVLET_PARAMETER_REUSE_DEV_SERVER, Boolean.TRUE.toString());
PropertyDeploymentConfiguration config = createConfiguration(appConfig, properties);
Assert.assertTrue(config.reuseDevServer());
Assert.assertEquals(properties, config.getInitParameters());
}
Aggregations