Package com.google.appengine.api.urlfetch

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


@RunWith(Arquillian.class)
public class FetchOptionsBuilderTest extends URLFetchTestBase {

    @Test
    public void testWithDefaults() throws Exception {
        FetchOptions options = FetchOptions.Builder.withDefaults();
        testOptions(options);
    }
View Full Code Here


    }

    @Test
    public void testFollowRedirects() throws Exception {
        final URL redirect = getUrl("redirect");
        FetchOptions options = FetchOptions.Builder.followRedirects();
        testOptions(redirect, options, new ResponseHandler() {
            public void handle(HTTPResponse response) throws Exception {
                URL finalURL = response.getFinalUrl();
                Assert.assertEquals(getUrl(""), finalURL);
            }
View Full Code Here

    @Test
    public void testFollowRedirectsExternal() throws Exception {
        final URL redirectUrl = new URL("http://google.com/");
        final String expectedDestinationURLPrefix = "http://www.google.";

        FetchOptions options = FetchOptions.Builder.followRedirects();

        HTTPRequest request = new HTTPRequest(redirectUrl, HTTPMethod.GET, options);
        URLFetchService service = URLFetchServiceFactory.getURLFetchService();
        HTTPResponse response = service.fetch(request);
        String destinationUrl = response.getFinalUrl().toString();
View Full Code Here

    }

    @Test
    public void testDoNotFollowRedirects() throws Exception {
        final URL redirect = getUrl("redirect");
        FetchOptions options = FetchOptions.Builder.doNotFollowRedirects();
        testOptions(redirect, options, new ResponseHandler() {
            public void handle(HTTPResponse response) throws Exception {
                Assert.assertEquals(302, response.getResponseCode());
            }
        });
View Full Code Here

        });
    }

    @Test
    public void testAllowTruncate() throws Exception {
        FetchOptions options = FetchOptions.Builder.allowTruncate();
        testOptions(options);
    }
View Full Code Here

        testOptions(options);
    }

    @Test
    public void testDisallowTruncate() throws Exception {
        FetchOptions options = FetchOptions.Builder.disallowTruncate();
        testOptions(options);
    }
View Full Code Here

        testOptions(options);
    }

    @Test
    public void testValidateCertificate() throws Exception {
        FetchOptions options = FetchOptions.Builder.validateCertificate();
        testOptions(options);
    }
View Full Code Here

        testOptions(options);
    }

    @Test
    public void testDoNotValidateCertificate() throws Exception {
        FetchOptions options = FetchOptions.Builder.doNotValidateCertificate();
        testOptions(options);
    }
View Full Code Here

        testOptions(options);
    }

    @Test
    public void testWithDeadline() throws Exception {
        FetchOptions options = FetchOptions.Builder.withDeadline(10 * 1000.0);
        testOptions(options);
    }
View Full Code Here

         url = request.getEndpoint().toURL();
      } catch (MalformedURLException e) {
         Throwables.propagate(e);
      }

      FetchOptions options = disallowTruncate();
      options.doNotFollowRedirects();
      if (utils.relaxHostname() || utils.trustAllCerts())
         options.doNotFollowRedirects();
      options.setDeadline(10.0);

      HTTPRequest gaeRequest = new HTTPRequest(url, HTTPMethod.valueOf(request.getMethod().toString()), options);

      for (Entry<String, String> entry : request.getHeaders().entries()) {
         String header = entry.getKey();
View Full Code Here

TOP

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

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.