Search in sources :

Example 81 with VaadinService

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

the class SpringServletTest method pushURL_rootMappingAndCustomURLWithoutPrecedingSlash_isPrefixedWithContextVaadinMapping.

@Test
public void pushURL_rootMappingAndCustomURLWithoutPrecedingSlash_isPrefixedWithContextVaadinMapping() throws ServletException {
    final Properties configProperties = new Properties();
    configProperties.setProperty("pushURL", "customUrl");
    VaadinService service = SpringInstantiatorTest.getService(context, configProperties, true);
    Assert.assertEquals("context://vaadinServlet/customUrl", service.getDeploymentConfiguration().getPushURL());
}
Also used : VaadinService(com.vaadin.flow.server.VaadinService) Properties(java.util.Properties) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) SpringInstantiatorTest(com.vaadin.flow.spring.instantiator.SpringInstantiatorTest)

Example 82 with VaadinService

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

the class SpringVaadinServletServiceTest method getInstantiator_springManagedBean_instantiatorBeanReturned.

@Test
public void getInstantiator_springManagedBean_instantiatorBeanReturned() throws ServletException {
    Properties properties = new Properties(BASE_PROPERTIES);
    properties.setProperty(FOO, Boolean.TRUE.toString());
    VaadinService service = SpringInstantiatorTest.getService(context, properties);
    Instantiator instantiator = service.getInstantiator();
    Assert.assertEquals(TestInstantiator.class, instantiator.getClass());
}
Also used : VaadinService(com.vaadin.flow.server.VaadinService) Instantiator(com.vaadin.flow.di.Instantiator) Properties(java.util.Properties) Test(org.junit.Test) SpringInstantiatorTest(com.vaadin.flow.spring.instantiator.SpringInstantiatorTest)

Example 83 with VaadinService

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

the class SpringVaadinServletServiceTest method uiInitListenerAsSpringBean_listenerIsAutoregisteredAsUIInitiLietnerInSpringService.

@Test
public void uiInitListenerAsSpringBean_listenerIsAutoregisteredAsUIInitiLietnerInSpringService() throws ServletException, ServiceException {
    VaadinService service = SpringInstantiatorTest.getService(context, new Properties());
    UI ui = new UI();
    TestUIInitListener listener = context.getBean(TestUIInitListener.class);
    service.fireUIInitListeners(ui);
    Assert.assertEquals(1, listener.events.size());
    Assert.assertSame(ui, listener.events.get(0).getUI());
}
Also used : UI(com.vaadin.flow.component.UI) VaadinService(com.vaadin.flow.server.VaadinService) Properties(java.util.Properties) Test(org.junit.Test) SpringInstantiatorTest(com.vaadin.flow.spring.instantiator.SpringInstantiatorTest)

Example 84 with VaadinService

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

the class DefaultInstantiatorTest method getOrCreate_lookupHasNoObject_createNewObject.

@Test
public void getOrCreate_lookupHasNoObject_createNewObject() {
    VaadinService service = Mockito.mock(VaadinService.class);
    mockLookup(service);
    DefaultInstantiator instantiator = new DefaultInstantiator(service);
    TestComponent component = instantiator.getOrCreate(TestComponent.class);
    Assert.assertNotNull(component);
}
Also used : VaadinService(com.vaadin.flow.server.VaadinService) Test(org.junit.Test)

Example 85 with VaadinService

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

the class DefaultInstantiatorTest method getOrCreate_lookupHasObject_returnObjectFromLookup.

@Test
public void getOrCreate_lookupHasObject_returnObjectFromLookup() {
    VaadinService service = Mockito.mock(VaadinService.class);
    Lookup lookup = mockLookup(service);
    DefaultInstantiator instantiator = new DefaultInstantiator(service);
    Mockito.when(lookup.lookup(List.class)).thenReturn(new ArrayList<>());
    List<?> list = instantiator.getOrCreate(List.class);
    Assert.assertTrue(list instanceof ArrayList);
}
Also used : VaadinService(com.vaadin.flow.server.VaadinService) ArrayList(java.util.ArrayList) 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