static BayeuxClient createClient(final SalesforceComponent component, final SalesforceSession session)
            throws SalesforceException {
        // use default Jetty client from SalesforceComponent, it's shared by all consumers
        final SalesforceHttpClient httpClient = component.getConfig().getHttpClient();

        Map<String, Object> options = new HashMap<>();
        /*
        The timeout should be greater than 110 sec as per https://github.com/cometd/cometd/issues/1142#issuecomment-1048256297
        and https://developer.salesforce.com/docs/atlas.en-us.api_streaming.meta/api_streaming/using_streaming_api_timeouts.htm
        */
        options.put(ClientTransport.MAX_NETWORK_DELAY_OPTION, 120000);
        if (component.getLongPollingTransportProperties() != null) {
            options.putAll(component.getLongPollingTransportProperties());
        }

        // check login access token
        if (session.getAccessToken() == null && !component.getLoginConfig().isLazyLogin()) {
            session.login(null);
        }

        CookieStore cookieStore = new CookieManager().getCookieStore();
        HttpCookieStore httpCookieStore = new HttpCookieStore.Default();

        ClientTransport transport = new JettyHttpClientTransport(options, httpClient) {
            @Override
            protected void customize(Request request) {
                super.customize(request);

                //accessToken might be null due to lazy login
                String accessToken = session.getAccessToken();
                if (accessToken == null) {
                    try {
                        accessToken = session.login(null);
                    } catch (SalesforceException e) {
                        throw new RuntimeException(e);
                    }
                }
                String finalAccessToken = new String(accessToken);
                request.headers(h -> h.add(HttpHeader.AUTHORIZATION, "OAuth " + finalAccessToken));
            }

            @Override
            protected void storeCookies(URI uri, Map<String, List<String>> cookies) {
                try {
                    CookieManager cookieManager = new CookieManager(cookieStore, CookiePolicy.ACCEPT_ALL);
                    cookieManager.put(uri, cookies);

                    for (java.net.HttpCookie httpCookie : cookieManager.getCookieStore().getCookies()) {
                        httpCookieStore.add(uri, HttpCookie.from(httpCookie));
                    }
                } catch (IOException x) {
                    if (LOG.isDebugEnabled()) {
                        LOG.debug("Could not parse cookies", x);
                    }
                }
            }

            @Override
            protected HttpCookieStore getHttpCookieStore() {
                return httpCookieStore;
            }
        };

        BayeuxClient client = new BayeuxClient(getEndpointUrl(component), transport);

        // added eagerly to check for support during handshake
        client.addExtension(REPLAY_EXTENSION);

        return client;
    }
@Test
    public void shouldLoginWhenAccessTokenIsNullAndLazyLoginIsFalse() throws SalesforceException {
        final SalesforceHttpClient httpClient = mock(SalesforceHttpClient.class);
        httpClient.setTimeout(0L);

        final SalesforceEndpointConfig endpointConfig = new SalesforceEndpointConfig();
        endpointConfig.setHttpClient(httpClient);

        final SalesforceLoginConfig loginConfig = new SalesforceLoginConfig();
        loginConfig.setLazyLogin(false);

        final SalesforceSession session = mock(SalesforceSession.class);
        final SalesforceComponent component = mock(SalesforceComponent.class);
        when(component.getLoginConfig()).thenReturn(loginConfig);
        when(component.getConfig()).thenReturn(endpointConfig);
        when(component.getSession()).thenReturn(session);

        BayeuxClient bayeuxClient = SubscriptionHelper.createClient(component, session);

        assertNotNull(bayeuxClient);
        verify(session).login(null);
    }