Exemplo n.º 1
0
        public void TestBucketLogging()
        {
            try
            {
                PutBucketLoggingRequest request = new PutBucketLoggingRequest(bucket);

                request.SetTarget("bucket-cssg-source-1253653367", "/abc");
                PutBucketLoggingResult putResult = cosXml.PutBucketLogging(request);

                Assert.IsTrue(putResult.httpCode == 200);

                GetBucketLoggingResult getResult = cosXml.GetBucketLogging(new GetBucketLoggingRequest(bucket));
                Assert.AreEqual(getResult.httpCode, 200);

                // Console.WriteLine(getResult.GetResultInfo());
                Assert.IsNotEmpty((getResult.GetResultInfo()));
                Assert.IsNotEmpty(getResult.RawContentBodyString);

                BucketLoggingStatus status = getResult.bucketLoggingStatus;

                Assert.NotNull(status);
                Assert.NotNull(status.loggingEnabled);
                Assert.NotNull(status.GetInfo());

                string targetBucket = status.loggingEnabled.targetBucket;
                string targetPrefix = status.loggingEnabled.targetPrefix;
                Assert.NotNull(targetBucket);
                Assert.NotNull(targetPrefix);
            }
            catch (COSXML.CosException.CosClientException clientEx)
            {
                Console.WriteLine("CosClientException: " + clientEx.Message);
                Assert.Fail();
            }
            catch (COSXML.CosException.CosServerException serverEx)
            {
                Console.WriteLine("CosServerException: " + serverEx.GetInfo());

                if (serverEx.statusCode != 409 && serverEx.statusCode != 451)
                {
                    Assert.Fail();
                }
            }
        }
Exemplo n.º 2
0
 public override string GetResultInfo()
 {
     return(base.GetResultInfo() + (bucketLoggingStatus == null ? "" : "\n" + bucketLoggingStatus.GetInfo()));
 }