use of com.vaadin.flow.server.startup.ApplicationConfiguration in project flow by vaadin.
the class PropertyDeploymentConfigurationTest method useV14Bootstrap_valueIsProvidedViaPropertiesAndParent_valueFromPropertiesIsReturned.
@Test
public void useV14Bootstrap_valueIsProvidedViaPropertiesAndParent_valueFromPropertiesIsReturned() {
ApplicationConfiguration appConfig = mockAppConfig();
Mockito.when(appConfig.useV14Bootstrap()).thenReturn(false);
Properties properties = new Properties();
properties.put(InitParameters.SERVLET_PARAMETER_USE_V14_BOOTSTRAP, Boolean.TRUE.toString());
PropertyDeploymentConfiguration config = createConfiguration(appConfig, properties);
Assert.assertTrue(config.useV14Bootstrap());
Assert.assertEquals(properties, config.getInitParameters());
}
use of com.vaadin.flow.server.startup.ApplicationConfiguration in project flow by vaadin.
the class PropertyDeploymentConfigurationTest method isProductionMode_modeIsProvidedViaPropertiesAndParent_valueFromPropertiesIsReturned.
@Test
public void isProductionMode_modeIsProvidedViaPropertiesAndParent_valueFromPropertiesIsReturned() {
ApplicationConfiguration appConfig = mockAppConfig();
Mockito.when(appConfig.isProductionMode()).thenReturn(false);
Properties properties = new Properties();
properties.put(InitParameters.SERVLET_PARAMETER_PRODUCTION_MODE, Boolean.TRUE.toString());
PropertyDeploymentConfiguration config = createConfiguration(appConfig, properties);
Assert.assertTrue(config.isProductionMode());
Assert.assertEquals(properties, config.getInitParameters());
}
use of com.vaadin.flow.server.startup.ApplicationConfiguration in project flow by vaadin.
the class PropertyDeploymentConfigurationTest method enableDevServer_valueIsProvidedViaParentOnly_valueFromParentIsReturned.
@Test
public void enableDevServer_valueIsProvidedViaParentOnly_valueFromParentIsReturned() {
ApplicationConfiguration appConfig = mockAppConfig();
Mockito.when(appConfig.enableDevServer()).thenReturn(true);
PropertyDeploymentConfiguration config = createConfiguration(appConfig, new Properties());
Assert.assertTrue(config.enableDevServer());
// 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 TaskGenerateFeatureFlagsTest method setUp.
@Before
public void setUp() throws Exception {
VaadinContext context = new MockVaadinContext();
ApplicationConfiguration configuration = Mockito.mock(ApplicationConfiguration.class);
context.setAttribute(ApplicationConfiguration.class, configuration);
File frontendFolder = temporaryFolder.newFolder(FRONTEND);
featureFlags = FeatureFlags.get(context);
taskGenerateFeatureFlags = new TaskGenerateFeatureFlags(frontendFolder, featureFlags);
}
use of com.vaadin.flow.server.startup.ApplicationConfiguration in project flow by vaadin.
the class AbstractScopeTest method mockSession.
@SuppressWarnings("unchecked")
protected VaadinSession mockSession() {
SpringVaadinSession session = Mockito.mock(TestSession.class, Mockito.withSettings().useConstructor());
doCallRealMethod().when(session).setAttribute(Mockito.any(Class.class), Mockito.any());
doCallRealMethod().when(session).getAttribute(Mockito.any(Class.class));
doCallRealMethod().when(session).getAttribute(Mockito.any(String.class));
doCallRealMethod().when(session).addUI(Mockito.any());
doCallRealMethod().when(session).removeUI(Mockito.any());
doCallRealMethod().when(session).getService();
doCallRealMethod().when(session).getUIs();
when(session.getState()).thenReturn(VaadinSessionState.OPEN);
final Properties initParameters = new Properties();
ApplicationConfiguration appConfig = Mockito.mock(ApplicationConfiguration.class);
Mockito.when(appConfig.getPropertyNames()).thenReturn(Collections.emptyEnumeration());
VaadinContext context = Mockito.mock(VaadinContext.class);
Lookup lookup = Mockito.mock(Lookup.class);
Mockito.when(context.getAttribute(Lookup.class)).thenReturn(lookup);
Mockito.when(appConfig.getContext()).thenReturn(context);
DefaultDeploymentConfiguration config = new DefaultDeploymentConfiguration(appConfig, getClass(), initParameters);
when(session.getConfiguration()).thenReturn(config);
VaadinSession.setCurrent(session);
when(session.hasLock()).thenReturn(true);
// keep a reference to the session so that it cannot be GCed.
this.session = session;
return session;
}
Aggregations