Package com.google.step2.discovery

Examples of com.google.step2.discovery.XrdLocationSelectorTest


   *
   * @throws FetchException
   */
  private XrdRepresentations fetchXrd(URI uri) throws FetchException {

    FetchRequest request = FetchRequest.createGetRequest(uri);

    XRDS xrds;
    byte[] documentBytes;
    String signature;

View Full Code Here


    String signatureHref = signatureLocation.getTextTrim();
    if (signatureHref == null) {
      throw new XmlSimpleSignException("No SignatureLocation text found");
    }

    FetchRequest request = FetchRequest.createGetRequest(URI.create(signatureHref));
    try {
      FetchResponse r = fetcher.fetch(request);
      return EncodingUtil.decodeBase64(r.getContentAsBytes());
    } catch (FetchException e) {
      throw new XmlSimpleSignException("couldn't fetch signature from " +
View Full Code Here

  }

  public HostMeta getHostMeta(String host) throws HostMetaException {
    try {
      URI uri = getHostMetaUriForHost(host);
      FetchRequest request = FetchRequest.createGetRequest(uri);

      FetchResponse response = fetcher.fetch(request);

      int status = response.getStatusCode();
View Full Code Here

    XRDS xrds;
    byte[] documentBytes;
    String signature;

    try {
      FetchResponse response = httpFetcher.fetch(request);

      documentBytes = response.getContentAsBytes();
      signature = response.getFirstHeader("Signature"); // could be null

      Document document =
          XmlUtil.getDocument(new ByteArrayInputStream(documentBytes));

      xrds = new XRDS(document.getDocumentElement(), false);
View Full Code Here

    try {
      URI uri = getHostMetaUriForHost(host);
      FetchRequest request = FetchRequest.createGetRequest(uri);

      FetchResponse response = fetcher.fetch(request);

      int status = response.getStatusCode();

      responseStream = response.getContentAsStream();

      if (status != HttpStatus.SC_OK) {
        throw new HttpResponseException(status, "fetching host-meta from " +
            host + " return status " + status);
      }
View Full Code Here

      throw new XmlSimpleSignException("No SignatureLocation text found");
    }

    FetchRequest request = FetchRequest.createGetRequest(URI.create(signatureHref));
    try {
      FetchResponse r = fetcher.fetch(request);
      return EncodingUtil.decodeBase64(r.getContentAsBytes());
    } catch (FetchException e) {
      throw new XmlSimpleSignException("couldn't fetch signature from " +
          signatureHref, e);
    }
  }
View Full Code Here

        } else if ("head".equals(request.method.toLowerCase())) {
          fetchRequest = FetchRequest.createHeadRequest(request.url.toURI());
        } else {
          fetchRequest = FetchRequest.createGetRequest(request.url.toURI());
        }
        FetchResponse response = httpFetcher.fetch(fetchRequest);
        return new Step2HttpResponseMessage(response, request);
      } catch (URISyntaxException e) {
        throw new IOException("couldn't convert " + request.url.toString() +
            " into a URI: " + e.getMessage());
      } catch (FetchException e) {
View Full Code Here


  public FetchResponse fetch(FetchRequest request) throws FetchException {
    String url = request.getUri().toString();
    if (url.equals(signatureLocation)) {
      return new FetchResponse() {

        public byte[] getContentAsBytes() {
          return EncodingUtil.getUtf8Bytes(signature);
        }
View Full Code Here

  public void testGet() throws Exception {
    String host = "host.com";
    FetchRequest request =
        FetchRequest.createGetRequest(new URI("http://host.com/host-meta"));
    FetchResponse response = new FakeFetchResponse(200,
        "Link: <http://foo.com/bar>; rel=foobar; type=foo\n");

    expect(http.fetch(request)).andReturn(response);

    control.replay();
View Full Code Here

  public void testGet_syntaxError() throws Exception {
    String host = "host.com";
    FetchRequest request =
        FetchRequest.createGetRequest(new URI("http://host.com/host-meta"));
    FetchResponse response = new FakeFetchResponse(200,
        "Link: <http://foo.com/bar>; rel=foobar type=foo\n");

    expect(http.fetch(request)).andReturn(response);

    control.replay();
View Full Code Here

TOP

Related Classes of com.google.step2.discovery.XrdLocationSelectorTest

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.