Search in sources :

Example 26 with DeploymentConfiguration

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

the class WebComponentWrapperTest method constructWebComponentUI.

private static WebComponentUI constructWebComponentUI(Element wrapperElement) {
    WebComponentUI ui = mock(WebComponentUI.class);
    when(ui.getUI()).thenReturn(Optional.of(ui));
    Element body = new Element("body");
    when(ui.getElement()).thenReturn(body);
    UIInternals internals = new UIInternals(ui);
    internals.setSession(new AlwaysLockedVaadinSession(mock(VaadinService.class)));
    when(ui.getInternals()).thenReturn(internals);
    Component parent = new Parent();
    parent.getElement().appendVirtualChild(wrapperElement);
    VaadinSession session = mock(VaadinSession.class);
    DeploymentConfiguration configuration = mock(DeploymentConfiguration.class);
    when(ui.getSession()).thenReturn(session);
    when(session.getConfiguration()).thenReturn(configuration);
    when(configuration.getWebComponentDisconnect()).thenReturn(1);
    return ui;
}
Also used : VaadinSession(com.vaadin.flow.server.VaadinSession) AlwaysLockedVaadinSession(com.vaadin.tests.util.AlwaysLockedVaadinSession) AlwaysLockedVaadinSession(com.vaadin.tests.util.AlwaysLockedVaadinSession) Element(com.vaadin.flow.dom.Element) UIInternals(com.vaadin.flow.component.internal.UIInternals) Component(com.vaadin.flow.component.Component) DeploymentConfiguration(com.vaadin.flow.function.DeploymentConfiguration)

Example 27 with DeploymentConfiguration

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

the class UIInternalsTest method setUpInitialPush.

private PushConfiguration setUpInitialPush() {
    DeploymentConfiguration config = Mockito.mock(DeploymentConfiguration.class);
    Mockito.when(vaadinService.getDeploymentConfiguration()).thenReturn(config);
    PushConfiguration pushConfig = Mockito.mock(PushConfiguration.class);
    Mockito.when(ui.getPushConfiguration()).thenReturn(pushConfig);
    Mockito.when(config.getPushMode()).thenReturn(PushMode.DISABLED);
    return pushConfig;
}
Also used : PushConfiguration(com.vaadin.flow.component.PushConfiguration) DeploymentConfiguration(com.vaadin.flow.function.DeploymentConfiguration)

Example 28 with DeploymentConfiguration

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

the class UIInternalsTest method showRouteTarget_componentHasNoPush_pushIsDisabled.

@Test
public void showRouteTarget_componentHasNoPush_pushIsDisabled() {
    PushConfiguration pushConfig = setUpInitialPush();
    useV14Bootstrap();
    DeploymentConfiguration deploymentConfiguration = vaadinService.getDeploymentConfiguration();
    Mockito.when(deploymentConfiguration.getPushMode()).thenReturn(PushMode.AUTOMATIC);
    internals.showRouteTarget(Mockito.mock(Location.class), new Text(""), Collections.emptyList());
    Mockito.verify(pushConfig).setPushMode(PushMode.AUTOMATIC);
    Mockito.verify(pushConfig, Mockito.times(0)).setTransport(Mockito.any());
}
Also used : PushConfiguration(com.vaadin.flow.component.PushConfiguration) Text(com.vaadin.flow.component.Text) DeploymentConfiguration(com.vaadin.flow.function.DeploymentConfiguration) Location(com.vaadin.flow.router.Location) Test(org.junit.Test)

Example 29 with DeploymentConfiguration

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

the class InfoView method update.

private void update(UI ui) {
    VaadinSession session = ui.getSession();
    WebBrowser webBrowser = session.getBrowser();
    DeploymentConfiguration deploymentConfiguration = session.getConfiguration();
    List<String> device = new ArrayList<>();
    List<String> os = new ArrayList<>();
    List<String> browser = new ArrayList<>();
    removeAll();
    add(new NativeButton("Refresh", e -> {
        update(ui);
    }));
    header("Browser");
    info("Address", webBrowser.getAddress());
    add(device, "Android", webBrowser.isAndroid());
    add(device, "iPhone", webBrowser.isIPhone());
    add(device, "Windows Phone", webBrowser.isWindowsPhone());
    info("Device", device.stream().collect(Collectors.joining(", ")));
    add(os, "Linux", webBrowser.isLinux());
    add(os, "Mac", webBrowser.isMacOSX());
    add(os, "Windows", webBrowser.isWindows());
    info("Os", os.stream().collect(Collectors.joining(", ")));
    add(browser, "Chrome", webBrowser.isChrome());
    add(browser, "Edge", webBrowser.isEdge());
    add(browser, "Firefox", webBrowser.isFirefox());
    add(browser, "IE", webBrowser.isIE());
    add(browser, "Safari", webBrowser.isSafari());
    info("Browser", browser.stream().collect(Collectors.joining(", ")));
    if (webBrowser.isTooOldToFunctionProperly()) {
        header("Browser is too old to function properly");
    }
    info("User-agent", webBrowser.getBrowserApplication());
    info("Browser major", webBrowser.getBrowserMajorVersion());
    info("Browser minor", webBrowser.getBrowserMinorVersion());
    info("Locale", webBrowser.getLocale());
    info("Secure connection (https)", webBrowser.isSecureConnection());
    separator();
    header("Push configuration");
    info("Push mode", ui.getPushConfiguration().getPushMode());
    info("Push transport", ui.getPushConfiguration().getTransport());
    separator();
    header("Deployment configuration");
    info("Heartbeat interval", deploymentConfiguration.getHeartbeatInterval());
    info("UI class", deploymentConfiguration.getUIClassName());
    info("Close idle sessions", deploymentConfiguration.isCloseIdleSessions());
    info("Send URLs as parameters", deploymentConfiguration.isSendUrlsAsParameters());
    info("Sync id enabled", deploymentConfiguration.isSyncIdCheckEnabled());
    info("XSRF protection enabled", deploymentConfiguration.isXsrfProtectionEnabled());
    info("Production mode", deploymentConfiguration.isProductionMode());
}
Also used : VaadinSession(com.vaadin.flow.server.VaadinSession) Html(com.vaadin.flow.component.Html) Div(com.vaadin.flow.component.html.Div) NativeButton(com.vaadin.flow.component.html.NativeButton) ViewTestLayout(com.vaadin.flow.uitest.servlet.ViewTestLayout) Hr(com.vaadin.flow.component.html.Hr) Collectors(java.util.stream.Collectors) DeploymentConfiguration(com.vaadin.flow.function.DeploymentConfiguration) ArrayList(java.util.ArrayList) Route(com.vaadin.flow.router.Route) List(java.util.List) WebBrowser(com.vaadin.flow.server.WebBrowser) UI(com.vaadin.flow.component.UI) AttachEvent(com.vaadin.flow.component.AttachEvent) NativeButton(com.vaadin.flow.component.html.NativeButton) VaadinSession(com.vaadin.flow.server.VaadinSession) WebBrowser(com.vaadin.flow.server.WebBrowser) ArrayList(java.util.ArrayList) DeploymentConfiguration(com.vaadin.flow.function.DeploymentConfiguration)

Example 30 with DeploymentConfiguration

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

the class EndpointAccessCheckerTest method should_notShowHelpfulMessage_When_accessDeniedInProductionMode.

@Test
public void should_notShowHelpfulMessage_When_accessDeniedInProductionMode() throws Exception {
    VaadinService mockService = Mockito.mock(VaadinService.class);
    DeploymentConfiguration mockDeploymentConfiguration = Mockito.mock(DeploymentConfiguration.class);
    Mockito.when(mockService.getDeploymentConfiguration()).thenReturn(mockDeploymentConfiguration);
    Mockito.when(mockDeploymentConfiguration.isProductionMode()).thenReturn(true);
    CurrentInstance.set(VaadinService.class, mockService);
    try {
        class Test {

            public void test() {
            }
        }
        Method method = Test.class.getMethod("test");
        String accessDeniedMessage = checker.check(method, requestMock);
        assertEquals(EndpointAccessChecker.ACCESS_DENIED_MSG, accessDeniedMessage);
    } finally {
        CurrentInstance.clearAll();
    }
}
Also used : VaadinService(com.vaadin.flow.server.VaadinService) Method(java.lang.reflect.Method) DeploymentConfiguration(com.vaadin.flow.function.DeploymentConfiguration) Test(org.junit.Test)

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