Package io.reactivex.netty.contexts

Examples of io.reactivex.netty.contexts.MapBackedKeySupplier


    }

    @Test
    public void testOnServerRequest() throws Exception {
        RequestIdProvider provider = new HttpRequestIdProvider(REQUEST_ID_HEADER_NAME, CORRELATOR);
        MapBackedKeySupplier keySupplier = new MapBackedKeySupplier(new HashMap<String, String>());
        AttributeMap attributeMap = new DefaultAttributeMap();
        String requestId = provider.onServerRequest(keySupplier, attributeMap);
        Assert.assertNull("Request Id should be null.", requestId);

        String expectedId = "hellothere";
        keySupplier.put(REQUEST_ID_HEADER_NAME, expectedId);

        requestId = provider.onServerRequest(keySupplier, attributeMap);

        Assert.assertEquals("Unexpected request id.", expectedId, requestId);
    }
View Full Code Here


    }

    @Test
    public void testNewRequestId() throws Exception {
        RequestIdProvider provider = new HttpRequestIdProvider("request_id", CORRELATOR);
        ContextKeySupplier keySupplier = new MapBackedKeySupplier(new HashMap<String, String>());
        AttributeMap attributeMap = new DefaultAttributeMap();
        String requestId = provider.newRequestId(keySupplier, attributeMap);
        ConcurrentLinkedQueue<String> ids = attributeMap.attr(HttpRequestIdProvider.REQUEST_IDS_KEY).get();
        Assert.assertNotNull("Request Id not added to context.", ids);
        Assert.assertNotNull("Request Id not added to context.", ids.peek());
View Full Code Here

    @Test
    public void testBeforeServerResponse() throws Exception {
        RequestIdProvider provider = new HttpRequestIdProvider(REQUEST_ID_HEADER_NAME, CORRELATOR);
        AttributeMap attributeMap = new DefaultAttributeMap();
        MapBackedKeySupplier keySupplier = new MapBackedKeySupplier(new HashMap<String, String>());
        String expectedId1 = "hellothere1";
        String expectedId2 = "hellothere2";
        String expectedId3 = "hellothere3";

        // Simulate HTTP pipelining
View Full Code Here

    @Test
    public void testBeforeClientRequest() throws Exception {
        RequestIdProvider provider = new HttpRequestIdProvider(REQUEST_ID, CORRELATOR);
        AttributeMap attributeMap = new DefaultAttributeMap();
        ContextKeySupplier keySupplier = new MapBackedKeySupplier(new HashMap<String, String>());
        String expectedId = "daah";
        CORRELATOR.onNewServerRequest(expectedId, new ContextsContainerImpl(keySupplier));
        String requestId = provider.beforeClientRequest(attributeMap);

        Assert.assertSame("Unexpected request Id", expectedId, requestId);
View Full Code Here

    @Test
    public void testOnClientResponse() throws Exception {
        RequestIdProvider provider = new HttpRequestIdProvider("request_id", CORRELATOR);
        AttributeMap attributeMap = new DefaultAttributeMap();
        ContextKeySupplier keySupplier = new MapBackedKeySupplier(new HashMap<String, String>());
        String expectedId = "daah";
        CORRELATOR.onNewServerRequest(expectedId, new ContextsContainerImpl(keySupplier));
        String requestId = provider.beforeClientRequest(attributeMap);
        Assert.assertSame("Unexpected request Id", expectedId, requestId);
        Assert.assertSame("Unexpected request Id on client response.", expectedId, provider.onClientResponse(attributeMap));
View Full Code Here

                RxContexts.<ByteBuf, ByteBuf>newHttpClientBuilder("localhost", mockServer.getServerPort(),
                                                                  REQUEST_ID_HEADER_NAME,
                                                                  RxContexts.DEFAULT_CORRELATOR)
                          .withMaxConnections(1).enableWireLogging(LogLevel.ERROR)
                          .withIdleConnectionsTimeoutMillis(100000).build();
        ContextsContainer container = new ContextsContainerImpl(new MapBackedKeySupplier());
        container.addContext(CTX_1_NAME, CTX_1_VAL);
        container.addContext(CTX_2_NAME, CTX_2_VAL, new TestContextSerializer());

        String reqId = "testWithPooledConnections";
        RxContexts.DEFAULT_CORRELATOR.onNewServerRequest(reqId, container);
View Full Code Here

                                                                  REQUEST_ID_HEADER_NAME,
                                                                  RxContexts.DEFAULT_CORRELATOR)
                          .withMaxConnections(1).enableWireLogging(LogLevel.ERROR)
                          .withIdleConnectionsTimeoutMillis(100000).build();

        ContextsContainer container = new ContextsContainerImpl(new MapBackedKeySupplier());
        container.addContext(CTX_1_NAME, CTX_1_VAL);
        container.addContext(CTX_2_NAME, CTX_2_VAL, new TestContextSerializer());

        String reqId = "testNoStateLeakOnThreadReuse";
        RxContexts.DEFAULT_CORRELATOR.onNewServerRequest(reqId, container);
View Full Code Here

                return requestId;
            }
        };

        provider = new HttpRequestIdProvider(generator, correlator, headerName);
        keySupplier = new MapBackedKeySupplier();
        if (server) {
            handler = new HttpServerContextHandler(provider, correlator);
        } else {
            handler = new HttpClientContextHandler(provider, correlator);
        }
View Full Code Here

TOP

Related Classes of io.reactivex.netty.contexts.MapBackedKeySupplier

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.