use of com.vaadin.flow.server.startup.ApplicationConfiguration in project flow by vaadin.
the class PropertyDeploymentConfigurationTest method isProductionMode_modeIsProvidedViaParentOnly_propertyIsSetToAnotherValue_valueFromParentIsReturnedViaAPI.
@Test
public void isProductionMode_modeIsProvidedViaParentOnly_propertyIsSetToAnotherValue_valueFromParentIsReturnedViaAPI() {
ApplicationConfiguration appConfig = mockAppConfig();
// The property value is provided via API
Mockito.when(appConfig.isProductionMode()).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_PRODUCTION_MODE)));
Mockito.when(appConfig.getStringProperty(InitParameters.SERVLET_PARAMETER_PRODUCTION_MODE, 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.isProductionMode());
Assert.assertTrue(config.getInitParameters().containsKey(InitParameters.SERVLET_PARAMETER_PRODUCTION_MODE));
}
use of com.vaadin.flow.server.startup.ApplicationConfiguration in project flow by vaadin.
the class PropertyDeploymentConfigurationTest method enableDevServer_valueIsProvidedViaParentOnly_propertyIsSetToAnotherValue_valueFromParentIsReturnedViaAPI.
@Test
public void enableDevServer_valueIsProvidedViaParentOnly_propertyIsSetToAnotherValue_valueFromParentIsReturnedViaAPI() {
ApplicationConfiguration appConfig = mockAppConfig();
// The property value is provided via API
Mockito.when(appConfig.enableDevServer()).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_ENABLE_DEV_SERVER)));
Mockito.when(appConfig.getStringProperty(InitParameters.SERVLET_PARAMETER_ENABLE_DEV_SERVER, 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.enableDevServer());
Assert.assertTrue(config.getInitParameters().containsKey(InitParameters.SERVLET_PARAMETER_ENABLE_DEV_SERVER));
}
use of com.vaadin.flow.server.startup.ApplicationConfiguration in project flow by vaadin.
the class PropertyDeploymentConfigurationTest method getApplicationProperty_propertyIsDefinedInParentOnly_valueFromParentIsReturned.
@Test
public void getApplicationProperty_propertyIsDefinedInParentOnly_valueFromParentIsReturned() {
ApplicationConfiguration appConfig = mockAppConfig();
Mockito.when(appConfig.getStringProperty("foo", null)).thenReturn("bar");
PropertyDeploymentConfiguration configuration = createConfiguration(appConfig, new Properties());
Assert.assertEquals("bar", configuration.getApplicationProperty("foo"));
// there is no any property
Assert.assertTrue(configuration.getInitParameters().isEmpty());
}
use of com.vaadin.flow.server.startup.ApplicationConfiguration in project flow by vaadin.
the class PropertyDeploymentConfigurationTest method isPnpmEnabled_valueIsProvidedViaParentOnly_valueFromParentIsReturned.
@Test
public void isPnpmEnabled_valueIsProvidedViaParentOnly_valueFromParentIsReturned() {
ApplicationConfiguration appConfig = mockAppConfig();
Mockito.when(appConfig.isPnpmEnabled()).thenReturn(true);
PropertyDeploymentConfiguration config = createConfiguration(appConfig, new Properties());
Assert.assertTrue(config.isPnpmEnabled());
// 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 useV14Bootstrap_valueIsProvidedViaParentOnly_valueFromParentIsReturned.
@Test
public void useV14Bootstrap_valueIsProvidedViaParentOnly_valueFromParentIsReturned() {
ApplicationConfiguration appConfig = mockAppConfig();
Mockito.when(appConfig.useV14Bootstrap()).thenReturn(true);
PropertyDeploymentConfiguration config = createConfiguration(appConfig, new Properties());
Assert.assertTrue(config.useV14Bootstrap());
// there is no any property
Assert.assertTrue(config.getInitParameters().isEmpty());
}
Aggregations