Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
Merge pull request #39 from sjones4/s3-tag-status-code
Browse files Browse the repository at this point in the history
Update s3 bucket tags test to check http status code for EUCA-12867.  Thanks sjones
  • Loading branch information
ccassler authored Mar 16, 2017
2 parents 99bc4eb + 42b9bbb commit 651b6d5
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/main/java/com/eucalyptus/tests/awssdk/S3BucketTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static com.eucalyptus.tests.awssdk.N4j.initS3ClientWithNewAccount;
import static com.eucalyptus.tests.awssdk.N4j.print;
import static com.eucalyptus.tests.awssdk.N4j.testInfo;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertTrue;

import java.util.ArrayList;
Expand All @@ -19,7 +20,11 @@
import org.testng.annotations.Test;

import com.amazonaws.AmazonServiceException;
import com.amazonaws.Request;
import com.amazonaws.Response;
import com.amazonaws.handlers.RequestHandler2;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3Client;
import com.amazonaws.services.s3.model.AccessControlList;
import com.amazonaws.services.s3.model.AmazonS3Exception;
import com.amazonaws.services.s3.model.Bucket;
Expand Down Expand Up @@ -350,7 +355,16 @@ public void testBucketTagging() throws Exception {
List<TagSet> tagSetList = new ArrayList<TagSet>();
tagSetList.add(tagSet1);
bucketTaggingConfiguration.setTagSets(tagSetList);
final RequestHandler2 statusCodeCheckingHandler = new RequestHandler2( ) {
@Override
public void afterResponse( final Request<?> request, final Response<?> response ) {
print(account + ": Got response status code " + response.getHttpResponse( ).getStatusCode( ));
assertEquals( "Status code", 204, response.getHttpResponse( ).getStatusCode( ) );
}
};
((AmazonS3Client)s3).addRequestHandler( statusCodeCheckingHandler );
s3.setBucketTaggingConfiguration(bucketName, bucketTaggingConfiguration);
((AmazonS3Client)s3).removeRequestHandler( statusCodeCheckingHandler );

print(account + ": Getting TagSets for bucket '" + bucketName + "'");
List<TagSet> tagSets = bucketTaggingConfiguration.getAllTagSets();
Expand Down

0 comments on commit 651b6d5

Please sign in to comment.