Package com.google.api.client.testing.http

Examples of com.google.api.client.testing.http.MockLowLevelHttpResponse.addHeader()


              // send a server error in the 1st request
              response.setStatusCode(500);
              return response;
            }
            response.setStatusCode(200);
            response.addHeader("Content-Length", String.valueOf(contentLength));
            response.setContent(
                new ByteArrayInputStream(new byte[contentLength - bytesDownloaded]));
            return response;
          }
View Full Code Here


            return response;
          }

          response.setStatusCode(206);
          int upper = Math.min(bytesDownloaded + TEST_CHUNK_SIZE, contentLength) - 1;
          response.addHeader(
              "Content-Range", "bytes " + bytesDownloaded + "-" + upper + "/" + contentLength);
          int bytesDownloadedCur = upper - bytesDownloaded + 1;
          response.setContent(new ByteArrayInputStream(new byte[bytesDownloadedCur]));
          bytesDownloaded += bytesDownloadedCur;
          return response;
View Full Code Here

    } else if (url.equals(METADATA_SERVER_URL)) {
      MockLowLevelHttpRequest request = new MockLowLevelHttpRequest(url) {
        @Override
        public LowLevelHttpResponse execute() {
          MockLowLevelHttpResponse response = new MockLowLevelHttpResponse();
          response.addHeader("Metadata-Flavor", "Google");
          return response;
        }
      };
      return request;
    }
View Full Code Here

            private LowLevelHttpResponse getResponse(String endpoint,
                                                     int status, String body, String content_type) {
                MockLowLevelHttpResponse response = new MockLowLevelHttpResponse();

                response.addHeader("Content-Length",
                        String.valueOf(body.length()));
                response.setStatusCode(status);

                if (content_type != null) {
                    response.setContentType(content_type);
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.