Package com.github.kristofa.test.http

Examples of com.github.kristofa.test.http.HttpRequestImpl.method()


    @Test
    public void testTracingTrue() throws ClientProtocolException, IOException, UnsatisfiedExpectationException {
        when(clientTracer.startNewSpan(PATH)).thenReturn(spanId);

        final HttpRequestImpl request = new HttpRequestImpl();
        request.method(Method.GET).path(FULL_PATH)
            .httpMessageHeader(BraveHttpHeaders.TraceId.getName(), Long.toString(TRACE_ID, 16))
            .httpMessageHeader(BraveHttpHeaders.SpanId.getName(), Long.toString(SPAN_ID, 16))
            .httpMessageHeader(BraveHttpHeaders.Sampled.getName(), "true");
        final HttpResponseImpl response = new HttpResponseImpl(200, null, null);
        responseProvider.set(request, response);
View Full Code Here


    @Test
    public void testTracingFalse() throws ClientProtocolException, IOException, UnsatisfiedExpectationException {
        when(clientTracer.startNewSpan(PATH)).thenReturn(null);

        final HttpRequestImpl request = new HttpRequestImpl();
        request.method(Method.GET).path(FULL_PATH).httpMessageHeader(BraveHttpHeaders.Sampled.getName(), "false");
        final HttpResponseImpl response = new HttpResponseImpl(200, null, null);
        responseProvider.set(request, response);

        final CloseableHttpClient httpclient =
            HttpClients.custom().addInterceptorFirst(new BraveHttpRequestInterceptor(clientTracer, Optional.<String>absent()))
View Full Code Here

    @Test
    public void testQueryParams() throws ClientProtocolException, IOException, UnsatisfiedExpectationException {
        when(clientTracer.startNewSpan(PATH)).thenReturn(spanId);

        final HttpRequestImpl request = new HttpRequestImpl();
        request.method(Method.GET).path(FULL_PATH).queryParameter("x", "1").queryParameter("y", "2")
            .httpMessageHeader(BraveHttpHeaders.TraceId.getName(), Long.toString(TRACE_ID, 16))
            .httpMessageHeader(BraveHttpHeaders.SpanId.getName(), Long.toString(SPAN_ID, 16))
            .httpMessageHeader(BraveHttpHeaders.Sampled.getName(), "true");
        final HttpResponseImpl response = new HttpResponseImpl(200, null, null);
        responseProvider.set(request, response);
View Full Code Here

    @Test
    public void testTracingTrueWithServiceNameOverride() throws ClientProtocolException, IOException, UnsatisfiedExpectationException {
        when(clientTracer.startNewSpan(FULL_PATH)).thenReturn(spanId);

        final HttpRequestImpl request = new HttpRequestImpl();
        request.method(Method.GET).path(FULL_PATH)
                .httpMessageHeader(BraveHttpHeaders.TraceId.getName(), Long.toString(TRACE_ID, 16))
                .httpMessageHeader(BraveHttpHeaders.SpanId.getName(), Long.toString(SPAN_ID, 16))
                .httpMessageHeader(BraveHttpHeaders.Sampled.getName(), "true");
        final HttpResponseImpl response = new HttpResponseImpl(200, null, null);
        responseProvider.set(request, response);
View Full Code Here

        final HttpRequestResponseFileLoggerFactory factory =
            new HttpRequestResponseFileLoggerFactory(DIRECTORY, FILE_NAME, true);
        final HttpRequestResponseLogger logger = factory.getHttpRequestResponseLogger();
        final HttpRequestImpl request = new HttpRequestImpl();
        request.method(Method.POST).path("/").content(new String("content").getBytes());
        logger.log(request);
        final HttpResponseImpl response = new HttpResponseImpl(200, "application/json", "{}".getBytes());
        logger.log(response);

        for (final File file : getFiles(1)) {
View Full Code Here

    }

    @Test
    public void testWrite() throws IOException {
        final HttpRequestImpl httpRequestImpl = new HttpRequestImpl();
        httpRequestImpl.method(METHOD).httpMessageHeader(HEADER_NAME_1, HEADER_VALUE_1)
            .httpMessageHeader(HEADER_NAME_2, HEADER_VALUE_2).path(PATH).queryParameter(PARAM_NAME_1, PARAM_VALUE_1)
            .queryParameter(PARAM_NAME_2, PARAM_VALUE_2).content(CONTENT);

        final File requestFile = new File(TEMP_DIR, FILE_NAME);
        final File requestEntityFile = new File(TEMP_DIR, FILE_NAME_ENTITY);
View Full Code Here

    public void testGetResponseSucces() throws UnsatisfiedExpectationException {
        final FileHttpResponseProvider expectedHttpResponseFileProvider =
            new FileHttpResponseProvider(TEST_FILE_DIRECTORY, "ExpectedHttpResponseFileProviderTest");

        final HttpRequestImpl request1 = new HttpRequestImpl();
        request1.method(Method.GET).httpMessageHeader("Content-Type", "application/json").queryParameter("a", "b")
            .path("/a/b");
        final HttpResponse response1 = expectedHttpResponseFileProvider.getResponse(request1);
        assertEquals(200, response1.getHttpCode());
        assertEquals("application/json", response1.getContentType());
        assertNull(response1.getContent());
View Full Code Here

        assertEquals(200, response1.getHttpCode());
        assertEquals("application/json", response1.getContentType());
        assertNull(response1.getContent());

        final HttpRequestImpl request2 = new HttpRequestImpl();
        request2.method(Method.POST).httpMessageHeader("Content-Type", "application/json").queryParameter("b", "c")
            .path("/b/c");
        final HttpResponse response2 = expectedHttpResponseFileProvider.getResponse(request2);
        assertEquals(200, response2.getHttpCode());
        assertEquals("application/json", response2.getContentType());
        assertNull(response2.getContent());
View Full Code Here

        assertEquals("application/json", response2.getContentType());
        assertNull(response2.getContent());

        // Same request as request 1 but expect different return value.
        final HttpRequestImpl request3 = new HttpRequestImpl();
        request3.method(Method.GET).httpMessageHeader("Content-Type", "application/json").queryParameter("a", "b")
            .path("/a/b");
        final HttpResponse response3 = expectedHttpResponseFileProvider.getResponse(request3);
        assertEquals(401, response3.getHttpCode());
        assertEquals("application/json", response3.getContentType());
        assertNull(response3.getContent());
View Full Code Here

    public void testGetResponseUnExpectedRequest() {
        final FileHttpResponseProvider expectedHttpResponseFileProvider =
            new FileHttpResponseProvider(TEST_FILE_DIRECTORY, "ExpectedHttpResponseFileProviderTest");

        final HttpRequestImpl request1 = new HttpRequestImpl();
        request1.method(Method.GET).httpMessageHeader("Content-Type", "application/json").queryParameter("b", "c")
            .path("/a/b");
        assertNull(expectedHttpResponseFileProvider.getResponse(request1));

        try {
            expectedHttpResponseFileProvider.verify();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.