Package com.google.appengine.api.urlfetch

Examples of com.google.appengine.api.urlfetch.HTTPRequest


    }
   
    @Test
    public void testWriteRequestHeaders() throws Exception {
        GHttpEndpoint endpoint = createEndpoint("ghttp://somewhere.com:9090/path");
        HTTPRequest request = createRequest();
        // Shouldn't be filtered out
        exchange.getIn().setHeader("test", "abc");
        // Should be filtered out
        exchange.getIn().setHeader("org.apache.camel.whatever", "xyz");
        exchange.getIn().setHeader("CamelWhatever", "xyz");
        exchange.getIn().setHeader(Exchange.HTTP_QUERY, "x=y");
        binding.writeRequestHeaders(endpoint, exchange, request);
        assertEquals(1, request.getHeaders().size());
        assertEquals("test", request.getHeaders().get(0).getName());
        assertEquals("abc", request.getHeaders().get(0).getValue());
    }
View Full Code Here


        assertEquals("abc", request.getHeaders().get(0).getValue());
    }

    @Test
    public void testWriteRequestBody() throws Exception {
        HTTPRequest request = createRequest();
        String body = "abc";
        exchange.getIn().setBody(body);
        binding.writeRequestBody(null, exchange, request);
        assertArrayEquals(body.getBytes(), request.getPayload());
    }
View Full Code Here

    }
   
    @Test
    public void testWriteRequest() throws Exception {
        GHttpEndpoint endpoint = createEndpoint("ghttp://somewhere.com:9090/path");
        HTTPRequest request = binding.writeRequest(endpoint, exchange, null);
        assertEquals("http://somewhere.com:9090/path", request.getURL().toString());
        assertEquals(HTTPMethod.GET, request.getMethod());
    }
View Full Code Here

    public static HTTPRequest createRequest() throws Exception {
        return createRequest("http://localhost:8080");
    }
   
    public static HTTPRequest createRequest(String url) throws Exception {
        return new HTTPRequest(new URL(url));
    }
View Full Code Here

     *            ignored.
     * @return a newly created {@link HTTPRequest} instance containing data from
     *         <code>exchange</code>.
     */
    public HTTPRequest writeRequest(GHttpEndpoint endpoint, Exchange exchange, HTTPRequest request) throws Exception {
        HTTPRequest answer = new HTTPRequest(
                getRequestUrl(endpoint, exchange),
                getRequestMethod(endpoint, exchange));
        writeRequestHeaders(endpoint, exchange, answer);
        writeRequestBody(endpoint, exchange, answer);
        return answer;
View Full Code Here

    }
   
    @Test
    public void testWriteRequestHeaders() throws Exception {
        GHttpEndpoint endpoint = createEndpoint("ghttp://somewhere.com:9090/path");
        HTTPRequest request = createRequest();
        // Shouldn't be filtered out
        exchange.getIn().setHeader("test", "abc");
        // Should be filtered out
        exchange.getIn().setHeader("org.apache.camel.whatever", "xyz");
        exchange.getIn().setHeader("CamelWhatever", "xyz");
        exchange.getIn().setHeader(Exchange.HTTP_QUERY, "x=y");
        binding.writeRequestHeaders(endpoint, exchange, request);
        assertEquals(1, request.getHeaders().size());
        assertEquals("test", request.getHeaders().get(0).getName());
        assertEquals("abc", request.getHeaders().get(0).getValue());
    }
View Full Code Here

        assertEquals("abc", request.getHeaders().get(0).getValue());
    }

    @Test
    public void testWriteRequestBody() throws Exception {
        HTTPRequest request = createRequest();
        String body = "abc";
        exchange.getIn().setBody(body);
        binding.writeRequestBody(null, exchange, request);
        assertArrayEquals(body.getBytes(), request.getPayload());
    }
View Full Code Here

    }
   
    @Test
    public void testWriteRequest() throws Exception {
        GHttpEndpoint endpoint = createEndpoint("ghttp://somewhere.com:9090/path");
        HTTPRequest request = binding.writeRequest(endpoint, exchange, null);
        assertEquals("http://somewhere.com:9090/path", request.getURL().toString());
        assertEquals(HTTPMethod.GET, request.getMethod());
    }
View Full Code Here

    }
   
    @Test
    public void testReadResponseHeaders() throws Exception {
        GHttpEndpoint endpoint = createEndpoint(getBaseUri("ghttp") + "/test");
        HTTPRequest request = new HTTPRequest(endpoint.getEndpointUrl());
        request.addHeader(new HTTPHeader("test", "abc"));
        request.addHeader(new HTTPHeader("content-type", "text/plain"));
        HTTPResponse response = service.fetch(request);
        binding.readResponseHeaders(endpoint, exchange, response);
        assertEquals(200, exchange.getOut().getHeader(Exchange.HTTP_RESPONSE_CODE));
        assertEquals("abc", exchange.getOut().getHeader("test"));
        assertEquals("text/plain", exchange.getOut().getHeader("content-type"));
View Full Code Here

    }

    @Test
    public void testReadResponseBody() throws Exception {
        GHttpEndpoint endpoint = createEndpoint(getBaseUri("ghttp") + "/test");
        HTTPRequest request = new HTTPRequest(endpoint.getEndpointUrl(), HTTPMethod.POST);
        request.setPayload("abc".getBytes());
        HTTPResponse response = service.fetch(request);
        binding.readResponseBody(null, exchange, response);
        assertEquals("abc", exchange.getOut().getBody(String.class));
    }
View Full Code Here

TOP

Related Classes of com.google.appengine.api.urlfetch.HTTPRequest

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.