Search in sources :

Example 16 with VaadinServlet

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

the class FrontendUtilsTest method mockServletService.

private VaadinServletService mockServletService() {
    VaadinServletService service = Mockito.mock(VaadinServletService.class);
    VaadinServlet servlet = Mockito.mock(VaadinServlet.class);
    Mockito.when(service.getServlet()).thenReturn(servlet);
    return service;
}
Also used : VaadinServlet(com.vaadin.flow.server.VaadinServlet) MockVaadinServletService(com.vaadin.flow.server.MockVaadinServletService) VaadinServletService(com.vaadin.flow.server.VaadinServletService)

Example 17 with VaadinServlet

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

the class SpringClassesSerializableTest method createStore.

private TestBeanStore createStore() {
    final Properties initParameters = new Properties();
    ApplicationConfiguration appConfig = Mockito.mock(ApplicationConfiguration.class);
    Mockito.when(appConfig.getPropertyNames()).thenReturn(Collections.emptyEnumeration());
    VaadinContext context = Mockito.mock(VaadinContext.class);
    Mockito.when(context.getAttribute(Mockito.eq(ApplicationConfiguration.class), Mockito.any())).thenReturn(appConfig);
    Mockito.when(appConfig.getContext()).thenReturn(context);
    Lookup lookup = Mockito.mock(Lookup.class);
    Mockito.when(context.getAttribute(Lookup.class)).thenReturn(lookup);
    VaadinService service = new VaadinServletService(new VaadinServlet(), new DefaultDeploymentConfiguration(appConfig, getClass(), initParameters)) {

        @Override
        public VaadinContext getContext() {
            return context;
        }
    };
    VaadinSession session = new TestSession(service);
    TestBeanStore store = new TestBeanStore(session);
    return store;
}
Also used : VaadinContext(com.vaadin.flow.server.VaadinContext) TestBeanStore(com.vaadin.flow.spring.scopes.TestBeanStore) VaadinSession(com.vaadin.flow.server.VaadinSession) VaadinService(com.vaadin.flow.server.VaadinService) VaadinServlet(com.vaadin.flow.server.VaadinServlet) VaadinServletService(com.vaadin.flow.server.VaadinServletService) Lookup(com.vaadin.flow.di.Lookup) DefaultDeploymentConfiguration(com.vaadin.flow.server.DefaultDeploymentConfiguration) Properties(java.util.Properties) ApplicationConfiguration(com.vaadin.flow.server.startup.ApplicationConfiguration)

Aggregations

VaadinServlet (com.vaadin.flow.server.VaadinServlet)17 Test (org.junit.Test)8 VaadinService (com.vaadin.flow.server.VaadinService)5 VaadinServletService (com.vaadin.flow.server.VaadinServletService)5 ServletException (javax.servlet.ServletException)5 Before (org.junit.Before)5 VaadinSession (com.vaadin.flow.server.VaadinSession)4 StandardCharsets (java.nio.charset.StandardCharsets)4 Properties (java.util.Properties)4 DependencyFilter (com.vaadin.flow.server.DependencyFilter)3 Dependency (com.vaadin.flow.shared.ui.Dependency)3 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 URL (java.net.URL)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 Stream (java.util.stream.Stream)3 ServletConfig (javax.servlet.ServletConfig)3 ServletContext (javax.servlet.ServletContext)3