File tree Expand file tree Collapse file tree 5 files changed +53
-10
lines changed
aws-android-sdk-s3-test/src/androidTest
java/com/amazonaws/services/s3 Expand file tree Collapse file tree 5 files changed +53
-10
lines changed Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <DeleteResult >
3+ <Deleted >
4+ <Key >object1</Key >
5+ <VersionId >123</VersionId >
6+ </Deleted >
7+ <Error >
8+ <Key >object2</Key >
9+ <Code >AccessDenied</Code >
10+ <Message >Access Denied</Message >
11+ </Error >
12+ </DeleteResult >
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <DeleteResult >
3+ <Deleted >
4+ <Key >key1</Key >
5+ <VersionId >Version1</VersionId >
6+ </Deleted >
7+ <Error >
8+ <Key >key2</Key >
9+ <VersionId >Version2</VersionId >
10+ <Code >Code</Code >
11+ <Message >Message</Message >
12+ </Error >
13+ <Deleted >
14+ <Key >key3</Key >
15+ <DeleteMarker >true</DeleteMarker >
16+ <DeleteMarkerVersionId >Version3</DeleteMarkerVersionId >
17+ </Deleted >
18+ </DeleteResult >
Original file line number Diff line number Diff line change 1+ {
2+ "Version" :" 2008-10-17" ,
3+ "Statement" :[{
4+ "Sid" :" AddPerm" ,
5+ "Effect" :" Allow" ,
6+ "Principal" : {
7+ "AWS" : " *"
8+ },
9+ "Action" :[" s3:GetObject" ],
10+ "Resource" :[" arn:aws:s3:::@BUCKET_NAME@/*" ]
11+ }]
12+ }
Original file line number Diff line number Diff line change 1515
1616package com .amazonaws .services .s3 ;
1717
18+ import android .support .test .InstrumentationRegistry ;
19+
1820import static org .junit .Assert .assertNotNull ;
1921import static org .junit .Assert .assertNull ;
2022import static org .junit .Assert .assertTrue ;
2729import org .junit .Before ;
2830import org .junit .Test ;
2931
32+ import java .io .InputStream ;
33+
3034/**
3135 * Integration tests for S3 bucket policy operations.
3236 */
@@ -36,7 +40,7 @@ public class BucketPolicyIntegrationTest extends S3IntegrationTestBase {
3640 private final String bucketName = "java-bucket-policy-integ-test-" + System .currentTimeMillis ();
3741
3842 /** Path to the sample policy for this test */
39- private static final String POLICY_FILE = "/com/amazonaws/services/s3/ samplePolicy.json" ;
43+ private static final String POLICY_FILE = "samplePolicy.json" ;
4044
4145 /** Create bucket and wait for creation */
4246 @ Before
@@ -58,7 +62,8 @@ public void tearDown() {
5862 /** Tests that we can get/put/delete bucket policies. */
5963 @ Test
6064 public void testBucketPolicies () throws Exception {
61- String policyText = IOUtils .toString (getClass ().getResourceAsStream (POLICY_FILE ));
65+ InputStream policyInputStream = InstrumentationRegistry .getContext ().getResources ().getAssets ().open (POLICY_FILE );
66+ String policyText = IOUtils .toString (policyInputStream );
6267 policyText = replace (policyText , "@BUCKET_NAME@" , bucketName );
6368
6469 // Verify that no policy exists yet
Original file line number Diff line number Diff line change 1515
1616package com .amazonaws .services .s3 ;
1717
18+ import android .support .test .InstrumentationRegistry ;
19+
1820import static org .junit .Assert .assertEquals ;
1921import static org .junit .Assert .assertFalse ;
2022import static org .junit .Assert .assertNull ;
@@ -146,10 +148,7 @@ public void testErrorHandling() throws Exception {
146148
147149 DeleteObjectsResultUnmarshaller unmarshaller = new Unmarshallers .DeleteObjectsResultUnmarshaller ();
148150 DeleteObjectsResponse response = unmarshaller
149- .unmarshall (this
150- .getClass ()
151- .getResourceAsStream (
152- "/com/amazonaws/services/s3/multiObjectDelete/testResponses/errorResponse.xml" ));
151+ .unmarshall (InstrumentationRegistry .getContext ().getResources ().getAssets ().open ("errorResponse.xml" ));
153152
154153 assertEquals (1 , response .getDeletedObjects ().size ());
155154 assertEquals (1 , response .getErrors ().size ());
@@ -170,10 +169,7 @@ public void testErrorHandling() throws Exception {
170169 public void testFullServiceResponse () throws Exception {
171170 DeleteObjectsResultUnmarshaller unmarshaller = new Unmarshallers .DeleteObjectsResultUnmarshaller ();
172171 DeleteObjectsResponse response = unmarshaller
173- .unmarshall (this
174- .getClass ()
175- .getResourceAsStream (
176- "/com/amazonaws/services/s3/multiObjectDelete/testResponses/fullResponse.xml" ));
172+ .unmarshall (InstrumentationRegistry .getContext ().getResources ().getAssets ().open ("fullResponse.xml" ));
177173
178174 assertEquals (2 , response .getDeletedObjects ().size ());
179175 assertEquals (1 , response .getErrors ().size ());
You can’t perform that action at this time.
0 commit comments