Search in sources :

Example 6 with DeploymentConfiguration

use of com.vaadin.flow.function.DeploymentConfiguration in project flow by vaadin.

the class PolymerServerEventHandlersTest 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 DeploymentConfiguration

use of com.vaadin.flow.function.DeploymentConfiguration in project flow by vaadin.

the class ApplicationRunnerServlet method createServletService.

@Override
protected VaadinServletService createServletService(DeploymentConfiguration deploymentConfiguration) throws ServiceException {
    VaadinServletService service = super.createServletService(deploymentConfiguration);
    final SystemMessagesProvider provider = service.getSystemMessagesProvider();
    service.setSystemMessagesProvider((SystemMessagesProvider) systemMessagesInfo -> {
        if (systemMessagesInfo.getRequest() == null) {
            return provider.getSystemMessages(systemMessagesInfo);
        }
        Object messages = systemMessagesInfo.getRequest().getAttribute(CUSTOM_SYSTEM_MESSAGES_PROPERTY);
        if (messages instanceof SystemMessages) {
            return (SystemMessages) messages;
        }
        return provider.getSystemMessages(systemMessagesInfo);
    });
    return service;
}
Also used : Proxy(java.lang.reflect.Proxy) ServletException(javax.servlet.ServletException) SystemMessagesProvider(com.vaadin.flow.server.SystemMessagesProvider) URL(java.net.URL) CurrentInstance(com.vaadin.flow.internal.CurrentInstance) URISyntaxException(java.net.URISyntaxException) LoggerFactory(org.slf4j.LoggerFactory) DeploymentConfiguration(com.vaadin.flow.function.DeploymentConfiguration) HttpServletRequest(javax.servlet.http.HttpServletRequest) DefaultDeploymentConfiguration(com.vaadin.flow.server.DefaultDeploymentConfiguration) Map(java.util.Map) VaadinServletRequest(com.vaadin.flow.server.VaadinServletRequest) URI(java.net.URI) Method(java.lang.reflect.Method) Path(java.nio.file.Path) LinkedHashSet(java.util.LinkedHashSet) SimpleFileVisitor(java.nio.file.SimpleFileVisitor) HttpSession(javax.servlet.http.HttpSession) VaadinSession(com.vaadin.flow.server.VaadinSession) SystemMessages(com.vaadin.flow.server.SystemMessages) Properties(java.util.Properties) Logger(org.slf4j.Logger) ServletConfig(javax.servlet.ServletConfig) MalformedURLException(java.net.MalformedURLException) Files(java.nio.file.Files) VaadinServlet(com.vaadin.flow.server.VaadinServlet) HttpServletResponse(javax.servlet.http.HttpServletResponse) Set(java.util.Set) IOException(java.io.IOException) File(java.io.File) Serializable(java.io.Serializable) WebServlet(javax.servlet.annotation.WebServlet) FileVisitResult(java.nio.file.FileVisitResult) Conf(com.vaadin.flow.uitest.servlet.CustomDeploymentConfiguration.Conf) VaadinService(com.vaadin.flow.server.VaadinService) InvocationHandler(java.lang.reflect.InvocationHandler) ServiceException(com.vaadin.flow.server.ServiceException) Collections(java.util.Collections) VaadinServletService(com.vaadin.flow.server.VaadinServletService) SystemMessagesProvider(com.vaadin.flow.server.SystemMessagesProvider) VaadinServletService(com.vaadin.flow.server.VaadinServletService) SystemMessages(com.vaadin.flow.server.SystemMessages)

Example 8 with DeploymentConfiguration

use of com.vaadin.flow.function.DeploymentConfiguration in project flow by vaadin.

the class AbstractDeploymentConfigurationTest method getClassLoader_returnsClassloaderPropertyValue.

@Test
public void getClassLoader_returnsClassloaderPropertyValue() {
    String classLoader = UUID.randomUUID().toString();
    DeploymentConfiguration config = getConfig("ClassLoader", classLoader);
    Assert.assertEquals("Unexpected classLoader configuration option value", classLoader, config.getClassLoaderName());
}
Also used : AbstractDeploymentConfiguration(com.vaadin.flow.server.AbstractDeploymentConfiguration) DefaultDeploymentConfiguration(com.vaadin.flow.server.DefaultDeploymentConfiguration) DeploymentConfiguration(com.vaadin.flow.function.DeploymentConfiguration) Test(org.junit.Test)

Example 9 with DeploymentConfiguration

use of com.vaadin.flow.function.DeploymentConfiguration in project flow by vaadin.

the class AbstractDeploymentConfigurationTest method getUIClass_returnsUIParameterPropertyValue.

@Test
public void getUIClass_returnsUIParameterPropertyValue() {
    String ui = UUID.randomUUID().toString();
    DeploymentConfiguration config = getConfig(VaadinSession.UI_PARAMETER, ui);
    Assert.assertEquals("Unexpected UI class configuration option value", ui, config.getUIClassName());
}
Also used : AbstractDeploymentConfiguration(com.vaadin.flow.server.AbstractDeploymentConfiguration) DefaultDeploymentConfiguration(com.vaadin.flow.server.DefaultDeploymentConfiguration) DeploymentConfiguration(com.vaadin.flow.function.DeploymentConfiguration) Test(org.junit.Test)

Example 10 with DeploymentConfiguration

use of com.vaadin.flow.function.DeploymentConfiguration in project flow by vaadin.

the class WebJarServerTest method init.

@Before
public void init() throws Exception {
    DeploymentConfiguration configuration = Mockito.mock(DeploymentConfiguration.class);
    Mockito.when(configuration.getDevelopmentFrontendPrefix()).thenReturn(Constants.FRONTEND_URL_DEV_DEFAULT);
    VaadinServletService servletService = Mockito.mock(VaadinServletService.class);
    ServletContext servletContext = Mockito.mock(ServletContext.class);
    servlet = new VaadinServlet() {

        @Override
        protected VaadinServletService createServletService() throws ServletException, ServiceException {
            return servletService;
        }

        @Override
        public ServletContext getServletContext() {
            return servletContext;
        }
    };
    Mockito.when(servletService.getDeploymentConfiguration()).thenReturn(configuration);
    Mockito.when(configuration.areWebJarsEnabled()).thenReturn(true);
    servlet.init(Mockito.mock(ServletConfig.class));
    Field webJarServerField = VaadinServlet.class.getDeclaredField("webJarServer");
    webJarServerField.setAccessible(true);
    webJarServer = (WebJarServer) webJarServerField.get(servlet);
    // webJarServer = new WebJarServer(configuration);
    // context = Mockito.mock(ServletContext.class);
    Mockito.when(servletContext.getResource(GRID_WEBJAR)).thenReturn(new URL("http://localhost:8080" + GRID_DEPENDENCY));
}
Also used : ServletException(javax.servlet.ServletException) Field(java.lang.reflect.Field) ServiceException(com.vaadin.flow.server.ServiceException) VaadinServlet(com.vaadin.flow.server.VaadinServlet) ServletConfig(javax.servlet.ServletConfig) VaadinServletService(com.vaadin.flow.server.VaadinServletService) ServletContext(javax.servlet.ServletContext) DeploymentConfiguration(com.vaadin.flow.function.DeploymentConfiguration) URL(java.net.URL) Before(org.junit.Before)

Aggregations

DeploymentConfiguration (com.vaadin.flow.function.DeploymentConfiguration)25 VaadinService (com.vaadin.flow.server.VaadinService)8 Test (org.junit.Test)7 URL (java.net.URL)6 DefaultDeploymentConfiguration (com.vaadin.flow.server.DefaultDeploymentConfiguration)4 VaadinServletRequest (com.vaadin.flow.server.VaadinServletRequest)4 Before (org.junit.Before)4 VaadinServlet (com.vaadin.flow.server.VaadinServlet)3 VaadinServletService (com.vaadin.flow.server.VaadinServletService)3 VaadinSession (com.vaadin.flow.server.VaadinSession)3 Properties (java.util.Properties)3 ServletConfig (javax.servlet.ServletConfig)3 ServletException (javax.servlet.ServletException)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 UI (com.vaadin.flow.component.UI)2 CurrentInstance (com.vaadin.flow.internal.CurrentInstance)2 AbstractDeploymentConfiguration (com.vaadin.flow.server.AbstractDeploymentConfiguration)2 ServiceException (com.vaadin.flow.server.ServiceException)2 VaadinUriResolver (com.vaadin.flow.shared.VaadinUriResolver)2 Conf (com.vaadin.flow.uitest.servlet.CustomDeploymentConfiguration.Conf)2