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

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


          GenericData responseData;
          if (statusCode == 401 || wwwAuthenticate != null) {
            // return 401 or invalid_token error (with the given status code), and then reset
            // wwwAuthenticate and statusCode - so next request to refresh the token will succeed
            if (wwwAuthenticate != null) {
              response.addHeader("WWW-Authenticate", wwwAuthenticate);
              wwwAuthenticate = null;
            }

            response.setStatusCode(statusCode);
            statusCode = 200;
View Full Code Here


            }
            assertEquals(TEST_CONTENT_TYPE, getFirstHeaderValue("x-upload-content-type"));
            // This is the initiation call. Return 200 with the upload URI.
            MockLowLevelHttpResponse response = new MockLowLevelHttpResponse();
            response.setStatusCode(200);
            response.addHeader("Location", TEST_UPLOAD_URL);
            return response;
          }
        };
      }
      assertEquals(TEST_UPLOAD_URL, url);
View Full Code Here

            response.setContent("{\"foo\":\"somevalue\"}");
            response.setContentType(Json.MEDIA_TYPE);
          } else {
            // Return 308 and the range since the upload is incomplete.
            response.setStatusCode(308);
            response.addHeader("Range", bytesRange);
          }
          return response;
        }
      };
    }
View Full Code Here

              response.setStatusCode(404);
            } else {
              // Return 200 with the upload URI.
              response.setStatusCode(200);
              if (!directUploadEnabled) {
                response.addHeader("Location", TEST_UPLOAD_URL);
              }
            }
            return response;
          }
        };
View Full Code Here

                // Return 308 in case there are more bytes to upload, otherwise return 200.
                // set the Range header with the bytes uploaded so far.
                response.setStatusCode(
                    contentLength == maxByteIndexUploadedOnError + 1 ? 200 : 308);
                bytesUploaded = maxByteIndexUploadedOnError + 1;
                response.addHeader("Range", "bytes=0-" + maxByteIndexUploadedOnError);
                return response;
              default:
                break;
            }
          } else if (testClientError) {
View Full Code Here

            // Return 200 since the upload is complete.
            response.setStatusCode(200);
          } else {
            // Return 308 and the range since the upload is incomplete.
            response.setStatusCode(308);
            response.addHeader("Range", "bytes=" + bytesRange);
          }
          return response;
        }

        void copyBytesToBytesReceivedArray(int length) throws IOException {
View Full Code Here

            ByteArrayOutputStream out = new ByteArrayOutputStream();
            getStreamingContent().writeTo(out);
            assertEquals(expectedOutput, out.toString("UTF-8"));
            MockLowLevelHttpResponse response = new MockLowLevelHttpResponse();
            response.setStatusCode(200);
            response.addHeader("Content-Type", "multipart/mixed; boundary=" + RESPONSE_BOUNDARY);
            String content2 = "{\"name\": \"" + TEST_NAME + "\", \"number\": \"" + TEST_NUM + "\"}";
            StringBuilder responseContent = new StringBuilder();
            responseContent.append("--" + RESPONSE_BOUNDARY + "\n")
                .append("Content-Type: application/http\n")
                .append("Content-Transfer-Encoding: binary\n").append("Content-ID: response-1\n\n")
View Full Code Here

      return new MockLowLevelHttpRequest() {
          @Override
        public LowLevelHttpResponse execute() throws IOException {
          MockLowLevelHttpResponse response = new MockLowLevelHttpResponse();
          response.setStatusCode(200);
          response.addHeader("Content-Type", "multipart/mixed; boundary=" + RESPONSE_BOUNDARY);
          String contentType =
              testBinary ? "application/x-protobuf" : "application/json; charset=UTF-8";
          byte[] content1 = testBinary ? MockData.Class1.newBuilder()
              .setId(TEST_ID)
              .setKind(TEST_KIND)
View Full Code Here

      return new MockLowLevelHttpRequest() {
          @Override
        public LowLevelHttpResponse execute() {
          MockLowLevelHttpResponse r = new MockLowLevelHttpResponse();
          r.setStatusCode(200);
          r.addHeader("Cache-Control", "max-age=" + MAX_AGE);
          if (useAgeHeader) {
            r.addHeader("Age", String.valueOf(AGE));
          }
          r.setContentType(Json.MEDIA_TYPE);
          r.setContent(TEST_CERTIFICATES);
View Full Code Here

        public LowLevelHttpResponse execute() {
          MockLowLevelHttpResponse r = new MockLowLevelHttpResponse();
          r.setStatusCode(200);
          r.addHeader("Cache-Control", "max-age=" + MAX_AGE);
          if (useAgeHeader) {
            r.addHeader("Age", String.valueOf(AGE));
          }
          r.setContentType(Json.MEDIA_TYPE);
          r.setContent(TEST_CERTIFICATES);
          return r;
        }
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.