Package io.reactivex.netty.contexts

Examples of io.reactivex.netty.contexts.ContextKeySupplier


    }

    @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 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

                if (null == requestId) {
                    System.err.println("Request Id not found.");
                    return Observable.error(new AssertionError("Request Id not found in mock server."));
                }
                response.getHeaders().add(REQUEST_ID_HEADER_NAME, requestId);
                ContextKeySupplier supplier = new ContextKeySupplier() {
                    @Override
                    public String getContextValue(String key) {
                        return request.getHeaders().get(key);
                    }
                };
View Full Code Here

            holder.handler.write(holder.ctx, request, holder.ctx.newPromise());

            Assert.assertNotNull("Context container not set after request sent.",
                                 ContextAttributeStorageHelper.getContainer(holder.ctx, holder.requestId));

            ContextKeySupplier supplier = new HttpContextKeySupplier(request.headers());
            ContextsContainer container = new ContextsContainerImpl(supplier);

            Assert.assertEquals("Context not available in the container.", CTX_1_VAL, container.getContext(CTX_1_NAME));
            Assert.assertEquals("Request Id header not added.", holder.getRequestId(),
                                request.headers().get(holder.getProvider().getRequestIdContextKeyName()));
View Full Code Here

        HttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);

        holder.handler.write(holder.ctx, response, holder.ctx.newPromise());

        ContextKeySupplier supplier = new HttpContextKeySupplier(response.headers());
        ContextsContainer containerToRead = new ContextsContainerImpl(supplier);
        Assert.assertEquals("Bi-directional context not written in response.", ctx2, containerToRead.getContext(
                ctx2Name));
    }
View Full Code Here

TOP

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

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.