Search in sources :

Example 6 with VaadinService

use of com.vaadin.flow.server.VaadinService in project flow by vaadin.

the class TemplateModelTest method createService.

@Override
protected VaadinService createService() {
    VaadinService service = Mockito.mock(VaadinService.class);
    DeploymentConfiguration configuration = Mockito.mock(DeploymentConfiguration.class);
    Mockito.when(configuration.isProductionMode()).thenReturn(true);
    Mockito.when(service.getDeploymentConfiguration()).thenReturn(configuration);
    return service;
}
Also used : VaadinService(com.vaadin.flow.server.VaadinService) DeploymentConfiguration(com.vaadin.flow.function.DeploymentConfiguration)

Example 7 with VaadinService

use of com.vaadin.flow.server.VaadinService in project flow by vaadin.

the class KnownUnsupportedTypesTest method createService.

@Override
protected VaadinService createService() {
    VaadinService service = Mockito.mock(VaadinService.class);
    DeploymentConfiguration configuration = Mockito.mock(DeploymentConfiguration.class);
    Mockito.when(configuration.isProductionMode()).thenReturn(true);
    Mockito.when(service.getDeploymentConfiguration()).thenReturn(configuration);
    return service;
}
Also used : VaadinService(com.vaadin.flow.server.VaadinService) DeploymentConfiguration(com.vaadin.flow.function.DeploymentConfiguration)

Example 8 with VaadinService

use of com.vaadin.flow.server.VaadinService in project flow by vaadin.

the class TemplateModelProxyHandlerTest method createService.

@Override
protected VaadinService createService() {
    VaadinService service = Mockito.mock(VaadinService.class);
    DeploymentConfiguration configuration = Mockito.mock(DeploymentConfiguration.class);
    Mockito.when(configuration.isProductionMode()).thenReturn(true);
    Mockito.when(service.getDeploymentConfiguration()).thenReturn(configuration);
    return service;
}
Also used : VaadinService(com.vaadin.flow.server.VaadinService) DeploymentConfiguration(com.vaadin.flow.function.DeploymentConfiguration)

Example 9 with VaadinService

use of com.vaadin.flow.server.VaadinService in project flow by vaadin.

the class HeartbeatHandlerTest method synchronizedHandleRequest_uiPresent_setLastHeartbeatTimestampIsCalledOnce.

@Test
public void synchronizedHandleRequest_uiPresent_setLastHeartbeatTimestampIsCalledOnce() throws IOException {
    VaadinService service = mock(VaadinService.class);
    VaadinSession session = mock(VaadinSession.class);
    VaadinRequest request = mock(VaadinRequest.class);
    VaadinResponse response = mock(VaadinResponse.class);
    UI ui = mock(UI.class);
    UIInternals uiInternals = mock(UIInternals.class);
    when(ui.getInternals()).thenReturn(uiInternals);
    when(session.getService()).thenReturn(service);
    when(service.findUI(request)).thenReturn(ui);
    HeartbeatHandler handler = new HeartbeatHandler();
    handler.synchronizedHandleRequest(session, request, response);
    Mockito.verify(ui.getInternals(), times(1)).setLastHeartbeatTimestamp(anyLong());
}
Also used : VaadinResponse(com.vaadin.flow.server.VaadinResponse) VaadinSession(com.vaadin.flow.server.VaadinSession) UI(com.vaadin.flow.component.UI) VaadinService(com.vaadin.flow.server.VaadinService) UIInternals(com.vaadin.flow.component.internal.UIInternals) VaadinRequest(com.vaadin.flow.server.VaadinRequest) Test(org.junit.Test)

Example 10 with VaadinService

use of com.vaadin.flow.server.VaadinService in project flow by vaadin.

the class SerializationTest method testSerializeVaadinSession_notProductionMode_canSerializeWithoutTransients.

@Test
public void testSerializeVaadinSession_notProductionMode_canSerializeWithoutTransients() throws Exception {
    VaadinService vaadinService = new MockVaadinService(false, true);
    VaadinSession session = Mockito.spy(new VaadinSession(vaadinService));
    Assert.assertEquals(vaadinService, session.getService());
    VaadinSession serializedAndDeserializedSession = serializeAndDeserialize(session);
    Assert.assertNull(serializedAndDeserializedSession.getService());
    VaadinSession againSerializedAndDeserializedSession = serializeAndDeserialize(serializedAndDeserializedSession);
    Assert.assertNull(againSerializedAndDeserializedSession.getService());
}
Also used : VaadinSession(com.vaadin.flow.server.VaadinSession) VaadinService(com.vaadin.flow.server.VaadinService) Test(org.junit.Test)

Aggregations

VaadinService (com.vaadin.flow.server.VaadinService)86 Test (org.junit.Test)39 DeploymentConfiguration (com.vaadin.flow.function.DeploymentConfiguration)19 VaadinSession (com.vaadin.flow.server.VaadinSession)18 Properties (java.util.Properties)15 VaadinContext (com.vaadin.flow.server.VaadinContext)12 Before (org.junit.Before)11 SpringInstantiatorTest (com.vaadin.flow.spring.instantiator.SpringInstantiatorTest)10 UI (com.vaadin.flow.component.UI)9 ApplicationConfiguration (com.vaadin.flow.server.startup.ApplicationConfiguration)8 Lookup (com.vaadin.flow.di.Lookup)7 VaadinResponse (com.vaadin.flow.server.VaadinResponse)7 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)7 ServletContext (javax.servlet.ServletContext)6 MockVaadinContext (com.vaadin.flow.server.MockVaadinContext)5 DefaultInstantiator (com.vaadin.flow.di.DefaultInstantiator)4 Instantiator (com.vaadin.flow.di.Instantiator)4 BrowserLiveReload (com.vaadin.flow.internal.BrowserLiveReload)4 DefaultDeploymentConfiguration (com.vaadin.flow.server.DefaultDeploymentConfiguration)4 MockVaadinServletService (com.vaadin.flow.server.MockVaadinServletService)4