Example #1
0
        public void PutObject_InternalServerErrorExceptionMarshallTest()
        {
            var operation = service_model.FindOperation("PutObject");

            var request         = InstantiateClassGenerator.Execute <PutObjectRequest>();
            var marshaller      = new PutObjectRequestMarshaller();
            var internalRequest = marshaller.Marshall(request);

            TestTools.RequestValidator.Validate("PutObject", request, internalRequest, service_model);

            var exception   = operation.Exceptions.First(e => e.Name.Equals("InternalServerErrorException"));
            var webResponse = new WebResponseData
            {
                Headers =
                {
                    { "x-amzn-RequestId", Guid.NewGuid().ToString()      },
                    { "x-amz-crc32",      "0"                            },
                    { "x-amzn-ErrorType", "InternalServerErrorException" },
                }
            };

            var payloadResponse = new JsonSampleGenerator(service_model, exception).Execute();

            webResponse.Headers["Content-Length"] = UTF8Encoding.UTF8.GetBytes(payloadResponse).Length.ToString();
            var context  = new JsonUnmarshallerContext(Utils.CreateStreamFromString(payloadResponse), true, webResponse, true);
            var response = PutObjectResponseUnmarshaller.Instance.UnmarshallException(context, null, System.Net.HttpStatusCode.OK);

            InstantiateClassGenerator.ValidateObjectFullyInstantiated(response);
        }
        public void PutObjectMarshallTest()
        {
            var operation = service_model.FindOperation("PutObject");

            var request    = InstantiateClassGenerator.Execute <PutObjectRequest>();
            var marshaller = new PutObjectRequestMarshaller();

            var internalRequest = marshaller.Marshall(request);

            TestTools.RequestValidator.Validate("PutObject", request, internalRequest, service_model);

            var webResponse = new WebResponseData
            {
                Headers =
                {
                    { "x-amzn-RequestId", Guid.NewGuid().ToString() },
                    { "x-amz-crc32",      "0"                       }
                }
            };

            var payloadResponse = new JsonSampleGenerator(service_model, operation.ResponseStructure).Execute();

            webResponse.Headers["Content-Length"] = UTF8Encoding.UTF8.GetBytes(payloadResponse).Length.ToString();
            var context = new JsonUnmarshallerContext(Utils.CreateStreamFromString(payloadResponse), false, webResponse);
            ResponseUnmarshaller unmarshaller = PutObjectResponseUnmarshaller.Instance;
            var response = unmarshaller.Unmarshall(context)
                           as PutObjectResponse;

            InstantiateClassGenerator.ValidateObjectFullyInstantiated(response);
        }
Example #3
0
        public IRequest Marshall(PutObjectRequestECS putObjectRequest)
        {
            var marshaller = new PutObjectRequestMarshaller();
            var request    = marshaller.Marshall(putObjectRequest);

            if (putObjectRequest.IsSetRange())
            {
                request.Headers.Add(COMMON.HEADER_RANGE, "bytes=" + putObjectRequest.Range.ToString());
            }
            if (putObjectRequest.IsSetEtagToMatch())
            {
                request.Headers.Add(COMMON.HEADER_IF_MATCH, ECSTransforms.ToStringValue(putObjectRequest.EtagToMatch));
            }
            if (putObjectRequest.IsSetEtagToNotMatch())
            {
                request.Headers.Add(COMMON.HEADER_IF_NONE_MATCH, ECSTransforms.ToStringValue(putObjectRequest.EtagToNotMatch));
            }
            if (putObjectRequest.IsSetModifiedSinceDate())
            {
                request.Headers.Add(COMMON.HEADER_IF_MODIFIED_SINCE, ECSTransforms.ToStringValue(putObjectRequest.ModifiedSinceDate));
            }
            if (putObjectRequest.IsSetUnmodifiedSinceDate())
            {
                request.Headers.Add(COMMON.HEADER_IF_UNMODIFIED_SINCE, ECSTransforms.ToStringValue(putObjectRequest.UnmodifiedSinceDate));
            }
            if (putObjectRequest.IsSetRetentionPeriod())
            {
                request.Headers.Add(COMMON.EMC_RETENTION_PERIOD, ECSTransforms.ToStringValue(putObjectRequest.RetentionPeriod));
            }
            if (putObjectRequest.IsSetRetentionPolicy())
            {
                request.Headers.Add(COMMON.EMC_RETENTION_POLICY, ECSTransforms.ToStringValue(putObjectRequest.RetentionPolicy));
            }

            return(request);
        }