Search in sources :

Example 41 with DeploymentConfiguration

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

the class TemplateModelWithEncodersTest 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 42 with DeploymentConfiguration

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

the class LitTemplateTest method setUp.

@Before
public void setUp() {
    DeploymentConfiguration configuration = Mockito.mock(DeploymentConfiguration.class);
    Mockito.when(service.getDeploymentConfiguration()).thenReturn(configuration);
}
Also used : DeploymentConfiguration(com.vaadin.flow.function.DeploymentConfiguration) Before(org.junit.Before)

Example 43 with DeploymentConfiguration

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

the class UITest method initUI.

private static void initUI(UI ui, String initialLocation, ArgumentCaptor<Integer> statusCodeCaptor) throws InvalidRouteConfigurationException {
    VaadinServletRequest request = Mockito.mock(VaadinServletRequest.class);
    VaadinResponse response = Mockito.mock(VaadinResponse.class);
    String pathInfo;
    if (initialLocation.isEmpty()) {
        pathInfo = null;
    } else {
        Assert.assertFalse(initialLocation.startsWith("/"));
        pathInfo = "/" + initialLocation;
    }
    Mockito.when(request.getPathInfo()).thenReturn(pathInfo);
    VaadinService service = new MockVaadinServletService() {

        @Override
        public VaadinContext getContext() {
            return new MockVaadinContext();
        }
    };
    service.setCurrentInstances(request, response);
    MockVaadinSession session = new AlwaysLockedVaadinSession(service);
    DeploymentConfiguration config = Mockito.mock(DeploymentConfiguration.class);
    Mockito.when(config.isProductionMode()).thenReturn(false);
    session.lock();
    session.setConfiguration(config);
    ui.getInternals().setSession(session);
    RouteConfiguration routeConfiguration = RouteConfiguration.forRegistry(ui.getInternals().getRouter().getRegistry());
    routeConfiguration.update(() -> {
        routeConfiguration.getHandledRegistry().clean();
        Arrays.asList(RootNavigationTarget.class, FooBarNavigationTarget.class, Parameterized.class, FooBarParamNavigationTarget.class).forEach(routeConfiguration::setAnnotatedRoute);
    });
    ui.doInit(request, 0);
    ui.getInternals().getRouter().initializeUI(ui, BootstrapHandlerTest.requestToLocation(request));
    session.unlock();
    if (statusCodeCaptor != null) {
        Mockito.verify(response).setStatus(statusCodeCaptor.capture());
    }
}
Also used : MockVaadinContext(com.vaadin.flow.server.MockVaadinContext) MockVaadinServletService(com.vaadin.flow.server.MockVaadinServletService) RouteConfiguration(com.vaadin.flow.router.RouteConfiguration) VaadinServletRequest(com.vaadin.flow.server.VaadinServletRequest) VaadinResponse(com.vaadin.flow.server.VaadinResponse) MockVaadinSession(com.vaadin.flow.server.MockVaadinSession) AlwaysLockedVaadinSession(com.vaadin.tests.util.AlwaysLockedVaadinSession) VaadinService(com.vaadin.flow.server.VaadinService) DeploymentConfiguration(com.vaadin.flow.function.DeploymentConfiguration)

Example 44 with DeploymentConfiguration

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

the class LookupInitializerTest method initialize_noStaticFileHandlerFactory_defaultStaticFileHandlerFactoryCreated.

@Test
public void initialize_noStaticFileHandlerFactory_defaultStaticFileHandlerFactoryCreated() throws ServletException {
    AtomicReference<Lookup> capture = new AtomicReference<>();
    initializer.initialize(null, new HashMap<>(), capture::set);
    Lookup lookup = capture.get();
    StaticFileHandlerFactory factory = lookup.lookup(StaticFileHandlerFactory.class);
    VaadinService service = Mockito.mock(VaadinService.class);
    DeploymentConfiguration configuration = Mockito.mock(DeploymentConfiguration.class);
    Mockito.when(service.getDeploymentConfiguration()).thenReturn(configuration);
    ClassLoader loader = Mockito.mock(ClassLoader.class);
    Mockito.when(service.getClassLoader()).thenReturn(loader);
    StaticFileHandler handler = factory.createHandler(service);
    Assert.assertNotNull(handler);
    Assert.assertEquals(StaticFileServer.class, handler.getClass());
}
Also used : StaticFileHandler(com.vaadin.flow.server.StaticFileHandler) StaticFileHandlerFactory(com.vaadin.flow.server.StaticFileHandlerFactory) VaadinService(com.vaadin.flow.server.VaadinService) AtomicReference(java.util.concurrent.atomic.AtomicReference) DeploymentConfiguration(com.vaadin.flow.function.DeploymentConfiguration) Test(org.junit.Test)

Example 45 with DeploymentConfiguration

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

the class UIInternalsTest method useV14Bootstrap.

private void useV14Bootstrap() {
    DeploymentConfiguration deploymentConfiguration = vaadinService.getDeploymentConfiguration();
    Mockito.when(deploymentConfiguration.useV14Bootstrap()).thenReturn(true);
}
Also used : DeploymentConfiguration(com.vaadin.flow.function.DeploymentConfiguration)

Aggregations

DeploymentConfiguration (com.vaadin.flow.function.DeploymentConfiguration)63 Test (org.junit.Test)24 VaadinService (com.vaadin.flow.server.VaadinService)23 VaadinSession (com.vaadin.flow.server.VaadinSession)9 UI (com.vaadin.flow.component.UI)8 Before (org.junit.Before)8 VaadinServletRequest (com.vaadin.flow.server.VaadinServletRequest)6 URL (java.net.URL)6 Properties (java.util.Properties)6 VaadinContext (com.vaadin.flow.server.VaadinContext)5 PushConfiguration (com.vaadin.flow.component.PushConfiguration)4 HashMap (java.util.HashMap)4 BrowserLiveReload (com.vaadin.flow.internal.BrowserLiveReload)3 Location (com.vaadin.flow.router.Location)3 VaadinServletService (com.vaadin.flow.server.VaadinServletService)3 Method (java.lang.reflect.Method)3 Set (java.util.Set)3 ServletConfig (javax.servlet.ServletConfig)3 ServletException (javax.servlet.ServletException)3 Div (com.vaadin.flow.component.html.Div)2