com.vaadin.flow.shared.ApplicationConstants Java Examples

The following examples show how to use com.vaadin.flow.shared.ApplicationConstants. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BootstrapHandler.java    From flow with Apache License 2.0 6 votes vote down vote up
protected static String getPushScript(BootstrapContext context) {
    VaadinRequest request = context.getRequest();
    // Parameter appended to JS to bypass caches after version upgrade.
    String versionQueryParam = "?v=" + Version.getFullVersion();
    // Load client-side dependencies for push support
    String pushJSPath = context.getRequest().getService()
            .getContextRootRelativePath(request);

    if (request.getService().getDeploymentConfiguration()
            .isProductionMode()) {
        pushJSPath += ApplicationConstants.VAADIN_PUSH_JS;
    } else {
        pushJSPath += ApplicationConstants.VAADIN_PUSH_DEBUG_JS;
    }

    pushJSPath += versionQueryParam;
    return pushJSPath;
}
 
Example #2
Source File: BootstrapHandler.java    From flow with Apache License 2.0 6 votes vote down vote up
private void setupMetaAndTitle(Element head, BootstrapContext context) {
    head.appendElement(META_TAG).attr("http-equiv", "Content-Type")
            .attr(CONTENT_ATTRIBUTE,
                    ApplicationConstants.CONTENT_TYPE_TEXT_HTML_UTF_8);

    head.appendElement(META_TAG).attr("http-equiv", "X-UA-Compatible")
            .attr(CONTENT_ATTRIBUTE, "IE=edge");

    head.appendElement("base").attr("href", getServiceUrl(context));

    head.appendElement(META_TAG).attr("name", VIEWPORT).attr(
            CONTENT_ATTRIBUTE,
            BootstrapUtils.getViewportContent(context)
                    .orElse(Viewport.DEFAULT));

    BootstrapUtils.getMetaTargets(context)
            .forEach((name, content) -> head.appendElement(META_TAG)
                    .attr("name", name)
                    .attr(CONTENT_ATTRIBUTE, content));

    resolvePageTitle(context).ifPresent(title -> {
        if (!title.isEmpty()) {
            head.appendElement("title").appendText(title);
        }
    });
}
 
Example #3
Source File: UidlRequestHandlerTest.java    From flow with Apache License 2.0 6 votes vote down vote up
@Test
public void writeSessionExpired() throws Exception {

    VaadinService service = new VaadinServletService(null,
            new DefaultDeploymentConfiguration(getClass(),
                    new Properties()));
    when(request.getService()).thenReturn(service);

    when(request
            .getParameter(ApplicationConstants.REQUEST_TYPE_PARAMETER))
            .thenReturn(RequestType.UIDL.getIdentifier());

    boolean result = handler.handleSessionExpired(request, response);
    Assert.assertTrue("Result should be true", result);

    String responseContent = CommunicationUtil
            .getStringWhenWriteBytesOffsetLength(outputStream);

    // response shouldn't contain async
    Assert.assertEquals("Invalid response",
            "for(;;);[{\"meta\":{\"sessionExpired\":true}}]",
            responseContent);
}
 
Example #4
Source File: ServerRpcHandlerTest.java    From flow with Apache License 2.0 6 votes vote down vote up
@Test
public void handleRpc_duplicateMessage_doNotThrow()
        throws InvalidUIDLSecurityKeyException, IOException {
    String msg = "{\"" + ApplicationConstants.CLIENT_TO_SERVER_ID + "\":1}";
    ServerRpcHandler handler = new ServerRpcHandler() {
        @Override
        protected String getMessage(Reader reader) throws IOException {
            return msg;
        };
    };

    ui = new UI();
    ui.getInternals().setSession(session);
    ui.getInternals().setLastProcessedClientToServerId(1,
            MessageDigestUtil.sha256(msg));

    // This invocation shouldn't throw. No other checks
    handler.handleRpc(ui, Mockito.mock(Reader.class), request);
}
 
Example #5
Source File: ServerRpcHandlerTest.java    From flow with Apache License 2.0 6 votes vote down vote up
@Test(expected = UnsupportedOperationException.class)
public void handleRpc_unexpectedMessage_throw()
        throws InvalidUIDLSecurityKeyException, IOException {
    ServerRpcHandler handler = new ServerRpcHandler() {
        @Override
        protected String getMessage(Reader reader) throws IOException {
            return "{\"" + ApplicationConstants.CLIENT_TO_SERVER_ID
                    + "\":1}";
        };
    };

    ui = new UI();
    ui.getInternals().setSession(session);

    handler.handleRpc(ui, Mockito.mock(Reader.class), request);
}
 
Example #6
Source File: BootstrapHandler.java    From flow with Apache License 2.0 6 votes vote down vote up
private static String readClientEngine() {
    // read client engine file name
    try (InputStream prop = ClientResourcesUtils
            .getResource("/META-INF/resources/"
                    + ApplicationConstants.CLIENT_ENGINE_PATH
                    + "/compile.properties")) {
        // null when running SDM or tests
        if (prop != null) {
            Properties properties = new Properties();
            properties.load(prop);
            return ApplicationConstants.CLIENT_ENGINE_PATH + "/"
                    + properties.getProperty("jsFile");
        } else {
            getLogger().warn(
                    "No compile.properties available on initialization, "
                            + "could not read client engine file name.");
        }
    } catch (IOException e) {
        throw new ExceptionInInitializerError(e);
    }
    return null;
}
 
Example #7
Source File: PushHandlerTest.java    From flow with Apache License 2.0 6 votes vote down vote up
@Test
public void onConnect_devMode_notWebsocket_refreshConnection_delegteCallWithUI()
        throws ServiceException, SessionExpiredException {
    MockVaadinServletService service = Mockito
            .spy(MockVaadinServletService.class);
    MockDeploymentConfiguration deploymentConfiguration = (MockDeploymentConfiguration) service
            .getDeploymentConfiguration();
    deploymentConfiguration.setProductionMode(false);
    runTest(service, (handler, resource) -> {
        AtmosphereRequest request = resource.getRequest();
        Mockito.when(request
                .getParameter(ApplicationConstants.LIVE_RELOAD_CONNECTION))
                .thenReturn("");
        Mockito.when(resource.transport()).thenReturn(TRANSPORT.AJAX);
        handler.onConnect(resource);
    });
    Mockito.verify(service).findVaadinSession(Mockito.any());
}
 
Example #8
Source File: PushHandlerTest.java    From flow with Apache License 2.0 6 votes vote down vote up
@Test
public void onConnect_devMode_websocket_noRefreshConnection_delegteCallWithUI()
        throws ServiceException {
    MockVaadinServletService service = Mockito
            .spy(MockVaadinServletService.class);
    MockDeploymentConfiguration deploymentConfiguration = (MockDeploymentConfiguration) service
            .getDeploymentConfiguration();
    deploymentConfiguration.setProductionMode(false);
    runTest(service, (handler, resource) -> {
        AtmosphereRequest request = resource.getRequest();
        Mockito.when(request
                .getParameter(ApplicationConstants.LIVE_RELOAD_CONNECTION))
                .thenReturn(null);
        Mockito.when(resource.transport()).thenReturn(TRANSPORT.WEBSOCKET);
        handler.onConnect(resource);
    });
    Mockito.verify(service).requestStart(Mockito.any(), Mockito.any());
}
 
Example #9
Source File: MessageSender.java    From flow with Apache License 2.0 6 votes vote down vote up
/**
 * Makes an UIDL request to the server.
 *
 * @param reqInvocations
 *            Data containing RPC invocations and all related information.
 * @param extraJson
 *            Parameters that are added to the payload
 */
protected void send(final JsonArray reqInvocations,
        final JsonObject extraJson) {
    registry.getRequestResponseTracker().startRequest();

    JsonObject payload = Json.createObject();
    String csrfToken = registry.getMessageHandler().getCsrfToken();
    if (!csrfToken.equals(ApplicationConstants.CSRF_TOKEN_DEFAULT_VALUE)) {
        payload.put(ApplicationConstants.CSRF_TOKEN, csrfToken);
    }
    payload.put(ApplicationConstants.RPC_INVOCATIONS, reqInvocations);
    payload.put(ApplicationConstants.SERVER_SYNC_ID,
            registry.getMessageHandler().getLastSeenServerSyncId());
    payload.put(ApplicationConstants.CLIENT_TO_SERVER_ID,
            clientToServerMessageId++);

    if (extraJson != null) {
        for (String key : extraJson.keys()) {
            JsonValue value = extraJson.get(key);
            payload.put(key, value);
        }
    }

    send(payload);

}
 
Example #10
Source File: StreamReceiverHandler.java    From flow with Apache License 2.0 6 votes vote down vote up
/**
 * Build response for handled download.
 *
 * @param response
 *            response to write to
 * @throws IOException
 *             exception when writing to stream
 */
private void sendUploadResponse(VaadinResponse response, boolean success)
        throws IOException {
    response.setContentType(
            ApplicationConstants.CONTENT_TYPE_TEXT_HTML_UTF_8);
    if (success) {
        try (OutputStream out = response.getOutputStream()) {
            final PrintWriter outWriter = new PrintWriter(
                    new BufferedWriter(new OutputStreamWriter(out, UTF_8)));
            try {
                outWriter.print(
                        "<html><body>download handled</body></html>");
            } finally {
                outWriter.flush();
            }
        }
    } else {
        response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    }
}
 
Example #11
Source File: JavaScriptBootstrapHandler.java    From flow with Apache License 2.0 6 votes vote down vote up
@Override
protected void initializeUIWithRouter(VaadinRequest request, UI ui) {
    String route = request
            .getParameter(ApplicationConstants.REQUEST_LOCATION_PARAMETER);
    if (route != null) {
        try {
            route = URLDecoder.decode(route, "UTF-8").replaceFirst("^/+",
                    "");
        } catch (UnsupportedEncodingException e) {
            throw new IllegalArgumentException(e);
        }
        Location location = new Location(route);

        // App is using classic server-routing, set a session attribute
        // to know that in future navigation calls
        ui.getSession().setAttribute(SERVER_ROUTING, Boolean.TRUE);

        ui.getRouter().initializeUI(ui, location);
    }
}
 
Example #12
Source File: PushHandlerTest.java    From flow with Apache License 2.0 6 votes vote down vote up
@Test
public void onConnect_productionMode_websocket_refreshConnection_delegteCallWithUI()
        throws ServiceException {
    MockVaadinServletService service = Mockito
            .spy(MockVaadinServletService.class);
    MockDeploymentConfiguration deploymentConfiguration = (MockDeploymentConfiguration) service
            .getDeploymentConfiguration();
    deploymentConfiguration.setProductionMode(true);
    runTest(service, (handler, resource) -> {
        AtmosphereRequest request = resource.getRequest();
        Mockito.when(request
                .getParameter(ApplicationConstants.LIVE_RELOAD_CONNECTION))
                .thenReturn("");
        Mockito.when(resource.transport()).thenReturn(TRANSPORT.WEBSOCKET);
        handler.onConnect(resource);
    });
    Mockito.verify(service).requestStart(Mockito.any(), Mockito.any());
}
 
Example #13
Source File: Heartbeat.java    From flow with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new instance connected to the given registry.
 *
 * @param registry
 *            the global registry
 */
public Heartbeat(Registry registry) {
    this.registry = registry;
    setInterval(
            registry.getApplicationConfiguration().getHeartbeatInterval());

    uri = registry.getApplicationConfiguration().getServiceUrl();
    uri = SharedUtil.addGetParameter(uri,
            ApplicationConstants.REQUEST_TYPE_PARAMETER,
            ApplicationConstants.REQUEST_TYPE_HEARTBEAT);
    uri = SharedUtil.addGetParameter(uri,
            ApplicationConstants.UI_ID_PARAMETER,
            registry.getApplicationConfiguration().getUIId());

    registry.getUILifecycle().addHandler(e -> {
        if (e.getUiLifecycle().isTerminated()) {
            setInterval(-1);
        }
    });
}
 
Example #14
Source File: VaadinService.java    From flow with Apache License 2.0 6 votes vote down vote up
/**
 * Finds the {@link UI} that belongs to the provided request. This is
 * generally only supported for UIDL requests as other request types are not
 * related to any particular UI or have the UI information encoded in a
 * non-standard way. The returned UI is also set as the current UI (
 * {@link UI#setCurrent(UI)}).
 *
 * @param request
 *            the request for which a UI is desired
 * @return the UI belonging to the request or null if no UI is found
 */
public UI findUI(VaadinRequest request) {
    // getForSession asserts that the lock is held
    VaadinSession session = loadSession(request.getWrappedSession());

    // Get UI id from the request
    String uiIdString = request
            .getParameter(ApplicationConstants.UI_ID_PARAMETER);
    UI ui = null;
    if (uiIdString != null && session != null) {
        int uiId = Integer.parseInt(uiIdString);
        ui = session.getUIById(uiId);
    }

    UI.setCurrent(ui);
    return ui;
}
 
Example #15
Source File: AtmospherePushConnection.java    From flow with Apache License 2.0 6 votes vote down vote up
private void connect() {
    String pushUrl = registry.getURIResolver().resolveVaadinUri(url);
    pushUrl = SharedUtil.addGetParameter(pushUrl,
            ApplicationConstants.REQUEST_TYPE_PARAMETER,
            ApplicationConstants.REQUEST_TYPE_PUSH);
    pushUrl = SharedUtil.addGetParameter(pushUrl,
            ApplicationConstants.UI_ID_PARAMETER,
            registry.getApplicationConfiguration().getUIId());

    String pushId = registry.getMessageHandler().getPushId();
    if (pushId != null) {
        pushUrl = SharedUtil.addGetParameter(pushUrl,
                ApplicationConstants.PUSH_ID_PARAMETER, pushId);
    }

    Console.log("Establishing push connection");
    pushUri = pushUrl;
    socket = doConnect(pushUrl, getConfig());
}
 
Example #16
Source File: VertxVaadin.java    From vertx-vaadin with MIT License 6 votes vote down vote up
private WebJars(DeploymentConfiguration deploymentConfiguration) {
    String frontendPrefix = deploymentConfiguration
        .getDevelopmentFrontendPrefix();
    if (!frontendPrefix.endsWith("/")) {
        throw new IllegalArgumentException(
            "Frontend prefix must end with a /. Got \"" + frontendPrefix
                + "\"");
    }
    if (!frontendPrefix
        .startsWith(ApplicationConstants.CONTEXT_PROTOCOL_PREFIX)) {
        throw new IllegalArgumentException(
            "Cannot host WebJars for a fronted prefix that isn't relative to 'context://'. Current frontend prefix: "
                + frontendPrefix);
    }

    webjarsLocation = "/"
        + frontendPrefix.substring(
        ApplicationConstants.CONTEXT_PROTOCOL_PREFIX.length());


    urlPattern = Pattern.compile("^((/\\.)?(/\\.\\.)*)" + webjarsLocation + "(bower_components/)?(?<webjar>.*)");
}
 
Example #17
Source File: VertxVaadin.java    From vertx-vaadin with MIT License 6 votes vote down vote up
private void initSockJS(Router vaadinRouter, SessionHandler sessionHandler) {
    if (this.config.supportsSockJS()) {
        SockJSHandlerOptions options = new SockJSHandlerOptions()
            .setSessionTimeout(config().sessionTimeout())
            .setHeartbeatInterval(service.getDeploymentConfiguration().getHeartbeatInterval() * 1000);
        SockJSHandler sockJSHandler = SockJSHandler.create(vertx, options);

        SockJSPushHandler pushHandler = new SockJSPushHandler(service, sessionHandler, sockJSHandler);

        String pushPath = config.pushURL().replaceFirst("/$", "") + "/*";
        logger.debug("Setup PUSH communication on {}", pushPath);

        vaadinRouter.route(pushPath).handler(rc -> {
            if (ApplicationConstants.REQUEST_TYPE_PUSH.equals(rc.request().getParam(ApplicationConstants.REQUEST_TYPE_PARAMETER))) {
                pushHandler.handle(rc);
            } else {
                rc.next();
            }
        });
    } else {
        logger.info("PUSH communication over SockJS is disabled");
    }
}
 
Example #18
Source File: SockJSPushConnection.java    From vertx-vaadin with MIT License 6 votes vote down vote up
private void connect() {
    String pushUrl = registry.getURIResolver().resolveVaadinUri(url);
    pushUrl = SharedUtil.addGetParameter(pushUrl,
        ApplicationConstants.REQUEST_TYPE_PARAMETER,
        ApplicationConstants.REQUEST_TYPE_PUSH);
    pushUrl = SharedUtil.addGetParameter(pushUrl,
        ApplicationConstants.UI_ID_PARAMETER,
        registry.getApplicationConfiguration().getUIId());

    String pushId = registry.getMessageHandler().getPushId();
    if (pushId != null) {
        pushUrl = SharedUtil.addGetParameter(pushUrl,
            ApplicationConstants.PUSH_ID_PARAMETER, pushId);
    }

    Console.log("Establishing push connection");
    socket = doConnect(pushUrl, getConfig());
}
 
Example #19
Source File: PushHandlerTest.java    From flow with Apache License 2.0 5 votes vote down vote up
@Test
public void onConnect_devMode_websocket_refreshConnection_onConnectIsCalled_callWithUIIsNotCalled()
        throws ServiceException {
    MockVaadinServletService service = Mockito
            .spy(MockVaadinServletService.class);
    MockDeploymentConfiguration deploymentConfiguration = (MockDeploymentConfiguration) service
            .getDeploymentConfiguration();
    deploymentConfiguration.setProductionMode(false);
    deploymentConfiguration.setDevModeLiveReloadEnabled(true);

    VaadinContext context = service.getContext();
    BrowserLiveReload liveReload = BrowserLiveReloadAccessTest
            .mockBrowserLiveReloadImpl(context);

    AtomicReference<AtmosphereResource> res = new AtomicReference<>();
    runTest(service, (handler, resource) -> {
        AtmosphereRequest request = resource.getRequest();
        Mockito.when(request
                .getParameter(ApplicationConstants.LIVE_RELOAD_CONNECTION))
                .thenReturn("");
        Mockito.when(resource.transport()).thenReturn(TRANSPORT.WEBSOCKET);
        handler.onConnect(resource);
        res.set(resource);
    });
    Mockito.verify(service, Mockito.times(0)).requestStart(Mockito.any(),
            Mockito.any());
    Mockito.verify(liveReload).onConnect(res.get());
}
 
Example #20
Source File: PushHandlerTest.java    From flow with Apache License 2.0 5 votes vote down vote up
@Test
public void onMessage_devMode_websocket_refreshConnection_callWithUIIsNotCalled()
        throws ServiceException {
    MockVaadinServletService service = Mockito
            .spy(MockVaadinServletService.class);
    MockDeploymentConfiguration deploymentConfiguration = (MockDeploymentConfiguration) service
            .getDeploymentConfiguration();
    deploymentConfiguration.setProductionMode(false);
    deploymentConfiguration.setDevModeLiveReloadEnabled(true);

    VaadinContext context = service.getContext();
    BrowserLiveReload liveReload = BrowserLiveReloadAccessTest
            .mockBrowserLiveReloadImpl(context);

    AtomicReference<AtmosphereResource> res = new AtomicReference<>();
    runTest(service, (handler, resource) -> {
        AtmosphereRequest request = resource.getRequest();
        Mockito.when(request
                .getParameter(ApplicationConstants.LIVE_RELOAD_CONNECTION))
                .thenReturn("");
        Mockito.when(resource.transport()).thenReturn(TRANSPORT.WEBSOCKET);
        handler.onMessage(resource);
        res.set(resource);
    });
    Mockito.verify(service, Mockito.times(0)).requestStart(Mockito.any(),
            Mockito.any());
}
 
Example #21
Source File: ClientEngineSizeIT.java    From flow with Apache License 2.0 5 votes vote down vote up
@Test
public void testClientEngineSize() throws Exception {
    File compiledModuleFolder = new File(
            "target/classes/META-INF/resources/"
                    + ApplicationConstants.CLIENT_ENGINE_PATH);
    if (!compiledModuleFolder.exists()) {
        throw new IOException(
                "Folder with compiled client engine does not exist: "
                        + compiledModuleFolder.getAbsolutePath());
    }

    boolean cacheJsReported = false;
    boolean cacheJsGzReported = false;

    for (File f : compiledModuleFolder.listFiles()) {
        if (f.getName().endsWith(".cache.js")) {
            if (cacheJsReported) {
                throw new IOException(
                        "Multiple uncompressed cache.js files found!");
            }
            printTeamcityStats("clientEngine", f.length());
            cacheJsReported = true;
        } else if (f.getName().endsWith(".cache.js.gz")) {
            if (cacheJsGzReported) {
                throw new IOException(
                        "Multiple compressed cache.js.gz files found!");
            }
            printTeamcityStats("clientEngineGzipped", f.length());
            cacheJsGzReported = true;
        }
    }
    if (!cacheJsReported) {
        throw new IOException("Uncompressed cache.js file not found!");
    }
    if (!cacheJsGzReported) {
        throw new IOException("Compressed cache.js.gz file not found!");
    }
}
 
Example #22
Source File: UidlWriterTest.java    From flow with Apache License 2.0 5 votes vote down vote up
@Test
public void resynchronizationRequested_responseFieldContainsResynchronize()
        throws Exception {
    UI ui = initializeUIForDependenciesTest(new TestUI());
    UidlWriter uidlWriter = new UidlWriter();

    JsonObject response = uidlWriter.createUidl(ui, false, true);
    assertTrue("Response contains resynchronize field",
            response.hasKey(ApplicationConstants.RESYNCHRONIZE_ID));
    assertTrue("Response resynchronize field is set to true",
            response.getBoolean(ApplicationConstants.RESYNCHRONIZE_ID));
}
 
Example #23
Source File: RouterLinkTest.java    From flow with Apache License 2.0 5 votes vote down vote up
@Test
public void createRouterLink_implicitCurrentVaadinServiceRouter() {
    // This method sets mock VaadinService instance which returns
    // Router from the UI.
    RouterLink link = new RouterLink("Show something", TestView.class,
            "something");
    Assert.assertEquals("Show something", link.getText());
    Assert.assertTrue(link.getElement()
            .hasAttribute(ApplicationConstants.ROUTER_LINK_ATTRIBUTE));

    Assert.assertTrue(link.getElement().hasAttribute("href"));

    Assert.assertEquals("bar/something",
            link.getElement().getAttribute("href"));
}
 
Example #24
Source File: RouterLinkTest.java    From flow with Apache License 2.0 5 votes vote down vote up
@Test
public void createRouterLink_explicitRouter() {
    RouterLink link = new RouterLink(router, "Show something",
            TestView.class, "something");
    Assert.assertEquals("Show something", link.getText());
    Assert.assertTrue(link.getElement()
            .hasAttribute(ApplicationConstants.ROUTER_LINK_ATTRIBUTE));

    Assert.assertTrue(link.getElement().hasAttribute("href"));

    Assert.assertEquals("bar/something",
            link.getElement().getAttribute("href"));
}
 
Example #25
Source File: MessageHandler.java    From flow with Apache License 2.0 5 votes vote down vote up
private int getServerId(ValueMap json) {
    if (json.containsKey(ApplicationConstants.SERVER_SYNC_ID)) {
        return json.getInt(ApplicationConstants.SERVER_SYNC_ID);
    } else {
        return -1;
    }
}
 
Example #26
Source File: MessageSender.java    From flow with Apache License 2.0 5 votes vote down vote up
/**
 * Resynchronize the client side, i.e. reload all component hierarchy and
 * state from the server
 */
public void resynchronize() {
    Console.log("Resynchronizing from server");
    JsonObject resyncParam = Json.createObject();
    resyncParam.put(ApplicationConstants.RESYNCHRONIZE_ID, true);
    send(Json.createArray(), resyncParam);
}
 
Example #27
Source File: XhrConnection.java    From flow with Apache License 2.0 5 votes vote down vote up
/**
 * Retrieves the URI to use when sending RPCs to the server
 *
 * @return The URI to use for server messages.
 */
protected String getUri() {
    // This code is in one line because an odd bug in GWT
    // compiler inlining this piece of code and not declaring
    // the variable in JS scope, breaking strict mode which is
    // needed for ES6 imports.
    // See https://github.com/vaadin/flow/pull/6227
    return SharedUtil.addGetParameter(
                SharedUtil.addGetParameter(
                    registry.getApplicationConfiguration().getServiceUrl(),
                    ApplicationConstants.REQUEST_TYPE_PARAMETER,
                    ApplicationConstants.REQUEST_TYPE_UIDL),
                ApplicationConstants.UI_ID_PARAMETER,
                registry.getApplicationConfiguration().getUIId());
}
 
Example #28
Source File: AtmospherePushConnection.java    From flow with Apache License 2.0 5 votes vote down vote up
private String getVersionedPushJs() {
    String pushJs;
    if (registry.getApplicationConfiguration().isProductionMode()) {
        pushJs = ApplicationConstants.VAADIN_PUSH_JS;
    } else {
        pushJs = ApplicationConstants.VAADIN_PUSH_DEBUG_JS;
    }
    return pushJs;
}
 
Example #29
Source File: GwtRouterLinkHandlerTest.java    From flow with Apache License 2.0 5 votes vote down vote up
private Element createTarget(String tag, String href, boolean routerLink) {
    Element target = Browser.getDocument().createElement(tag);
    target.setAttribute("href", href);
    if (routerLink) {
        target.setAttribute(ApplicationConstants.ROUTER_LINK_ATTRIBUTE, "");
    }
    return target;
}
 
Example #30
Source File: StreamReceiverHandlerTest.java    From flow with Apache License 2.0 5 votes vote down vote up
@Test
public void doHandleXhrFilePost_happyPath_setContentTypeNoExplicitSetStatus()
        throws IOException {
    handler.doHandleXhrFilePost(session, request, response, streamReceiver,
            stateNode, 1);

    Mockito.verify(response).setContentType(
            ApplicationConstants.CONTENT_TYPE_TEXT_HTML_UTF_8);
    Mockito.verify(response, Mockito.times(0)).setStatus(Mockito.anyInt());
}