@@ -50,40 +50,45 @@ public class TestS3Ds extends TestCaseBase {
50
50
51
51
protected Properties props ;
52
52
53
+ protected String config ;
54
+
53
55
public TestS3Ds () throws IOException {
54
- config = System .getProperty (CONFIG );
55
- memoryBackend = false ;
56
- noCache = false ;
57
- props = Utils .readConfig (config );
58
- }
56
+ System .setProperty (
57
+ TestCaseBase .CONFIG ,
58
+ "C:/src/apache/jackrabbit-encryp-changes/jackrabbit/jackrabbit-aws-ext/src/test/resources/aws.properties" );
59
+ config = System .getProperty (CONFIG );
60
+ props = Utils .readConfig (System .getProperty (CONFIG ));
61
+ }
59
62
63
+ @ Override
60
64
protected void setUp () throws Exception {
61
65
startTime = new Date ();
62
66
super .setUp ();
63
67
String bucket = String .valueOf (randomGen .nextInt (9999 )) + "-"
64
- + String .valueOf (randomGen .nextInt (9999 )) + "-test" ;
65
- props .setProperty (S3Constants .S3_BUCKET , bucket );
68
+ + String .valueOf (randomGen .nextInt (9999 )) + "-test" ;
69
+ props .setProperty (S3Constants .S3_BUCKET , bucket );
66
70
// delete bucket if exists
67
71
deleteBucket (bucket );
68
72
}
69
- protected void tearDown () {
73
+
74
+ @ Override
75
+ protected void tearDown () {
70
76
try {
71
77
deleteBucket ();
72
78
super .tearDown ();
73
- } catch ( Exception ignore ) {
79
+ } catch (Exception ignore ) {
74
80
75
81
}
76
82
}
77
83
84
+ @ Override
78
85
protected CachingDataStore createDataStore () throws RepositoryException {
79
- ds = new S3TestDataStore (props );
80
- ds .setConfig (config );
81
- if (noCache ) {
82
- ds .setCacheSize (0 );
83
- }
84
- ds .init (dataStoreDir );
86
+ S3DataStore s3ds = new S3DataStore ();
87
+ s3ds .setProperties (props );
88
+ s3ds .setSecret ("123456" );
89
+ s3ds .init (dataStoreDir );
85
90
sleep (1000 );
86
- return ds ;
91
+ return s3ds ;
87
92
}
88
93
89
94
/**
@@ -93,20 +98,22 @@ protected CachingDataStore createDataStore() throws RepositoryException {
93
98
* Cleaning of bucket after test run.
94
99
*/
95
100
public void deleteBucket () throws Exception {
96
- Backend backend = ds .getBackend ();
97
- String bucket = ((S3Backend )backend ).getBucket ();
101
+ Backend backend = (( S3DataStore ) ds ) .getBackend ();
102
+ String bucket = ((S3Backend ) backend ).getBucket ();
98
103
deleteBucket (bucket );
99
104
}
105
+
100
106
public void deleteBucket (String bucket ) throws Exception {
101
107
LOG .info ("deleting bucket [" + bucket + "]" );
102
108
Properties props = Utils .readConfig (config );
103
109
AmazonS3Client s3service = Utils .openService (props );
104
110
TransferManager tmx = new TransferManager (s3service );
111
+
105
112
if (s3service .doesBucketExist (bucket )) {
106
113
for (int i = 0 ; i < 4 ; i ++) {
107
114
tmx .abortMultipartUploads (bucket , startTime );
108
115
ObjectListing prevObjectListing = s3service .listObjects (bucket );
109
- while (prevObjectListing != null ) {
116
+ while (prevObjectListing != null ) {
110
117
List <DeleteObjectsRequest .KeyVersion > deleteList = new ArrayList <DeleteObjectsRequest .KeyVersion >();
111
118
for (S3ObjectSummary s3ObjSumm : prevObjectListing .getObjectSummaries ()) {
112
119
deleteList .add (new DeleteObjectsRequest .KeyVersion (
@@ -124,11 +131,11 @@ public void deleteBucket(String bucket) throws Exception {
124
131
}
125
132
s3service .deleteBucket (bucket );
126
133
LOG .info ("bucket [ " + bucket + "] deleted" );
134
+
127
135
} else {
128
136
LOG .info ("bucket [" + bucket + "] doesn't exists" );
129
137
}
130
- tmx .shutdownNow ();
131
- s3service .shutdown ();
138
+ tmx .shutdownNow ();
139
+ s3service .shutdown ();
132
140
}
133
-
134
- }
141
+ }
0 commit comments