Search in sources :

Example 56 with ApplicationConfiguration

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());
}
Also used : Properties(java.util.Properties) ApplicationConfiguration(com.vaadin.flow.server.startup.ApplicationConfiguration) Test(org.junit.Test)

Example 57 with ApplicationConfiguration

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());
}
Also used : Properties(java.util.Properties) ApplicationConfiguration(com.vaadin.flow.server.startup.ApplicationConfiguration) Test(org.junit.Test)

Example 58 with ApplicationConfiguration

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());
}
Also used : Properties(java.util.Properties) ApplicationConfiguration(com.vaadin.flow.server.startup.ApplicationConfiguration) Test(org.junit.Test)

Example 59 with ApplicationConfiguration

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);
}
Also used : MockVaadinContext(com.vaadin.flow.server.MockVaadinContext) MockVaadinContext(com.vaadin.flow.server.MockVaadinContext) VaadinContext(com.vaadin.flow.server.VaadinContext) ApplicationConfiguration(com.vaadin.flow.server.startup.ApplicationConfiguration) File(java.io.File) Before(org.junit.Before)

Example 60 with ApplicationConfiguration

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;
}
Also used : SpringVaadinSession(com.vaadin.flow.spring.SpringVaadinSession) VaadinContext(com.vaadin.flow.server.VaadinContext) Lookup(com.vaadin.flow.di.Lookup) DefaultDeploymentConfiguration(com.vaadin.flow.server.DefaultDeploymentConfiguration) Properties(java.util.Properties) ApplicationConfiguration(com.vaadin.flow.server.startup.ApplicationConfiguration)

Aggregations

ApplicationConfiguration (com.vaadin.flow.server.startup.ApplicationConfiguration)61 Properties (java.util.Properties)39 Test (org.junit.Test)39 VaadinContext (com.vaadin.flow.server.VaadinContext)14 Lookup (com.vaadin.flow.di.Lookup)9 VaadinService (com.vaadin.flow.server.VaadinService)7 DefaultDeploymentConfiguration (com.vaadin.flow.server.DefaultDeploymentConfiguration)6 ServletContext (javax.servlet.ServletContext)5 MockVaadinContext (com.vaadin.flow.server.MockVaadinContext)4 VaadinServletService (com.vaadin.flow.server.VaadinServletService)4 VaadinSession (com.vaadin.flow.server.VaadinSession)4 File (java.io.File)4 Before (org.junit.Before)4 UI (com.vaadin.flow.component.UI)3 ResourceProvider (com.vaadin.flow.di.ResourceProvider)3 VaadinServletContext (com.vaadin.flow.server.VaadinServletContext)3 MockVaadinServletService (com.vaadin.flow.server.MockVaadinServletService)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2