|
18 | 18 | import test.com.qiniu.ResCode;
|
19 | 19 | import test.com.qiniu.TestConfig;
|
20 | 20 |
|
| 21 | +import static org.junit.jupiter.api.Assertions.assertArrayEquals; |
| 22 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 23 | +import static org.junit.jupiter.api.Assertions.assertNotEquals; |
| 24 | +import static org.junit.jupiter.api.Assertions.assertNotNull; |
| 25 | +import static org.junit.jupiter.api.Assertions.assertNull; |
| 26 | +import static org.junit.jupiter.api.Assertions.assertTrue; |
| 27 | +import static org.junit.jupiter.api.Assertions.fail; |
| 28 | + |
21 | 29 | import java.io.IOException;
|
22 | 30 | import java.text.SimpleDateFormat;
|
23 | 31 | import java.util.*;
|
@@ -215,6 +223,60 @@ public void testListMarkerV2() {
|
215 | 223 | @Test
|
216 | 224 | @Tag("IntegrationTest")
|
217 | 225 | public void testStat() {
|
| 226 | + String ruleName = "javaStatusRule"; |
| 227 | + String copyKey = TestConfig.testBucket_z0 + "_status_copy"; |
| 228 | + |
| 229 | + try { |
| 230 | + bucketManager.deleteBucketLifecycleRule(TestConfig.testBucket_z0, ruleName); |
| 231 | + } catch (QiniuException e) { |
| 232 | + e.printStackTrace(); |
| 233 | + } |
| 234 | + |
| 235 | + try { |
| 236 | + bucketManager.copy(TestConfig.testBucket_z0, TestConfig.testKey_z0, TestConfig.testBucket_z0, copyKey, true); |
| 237 | + bucketManager.changeType(TestConfig.testBucket_z0, copyKey, StorageType.Archive); |
| 238 | + bucketManager.restoreArchive(TestConfig.testBucket_z0, copyKey, 1); |
| 239 | + FileInfo info = bucketManager.stat(TestConfig.testBucket_z0, copyKey); |
| 240 | + assertNotNull(info.hash); |
| 241 | + assertNotNull(info.mimeType); |
| 242 | + assertNotNull(info.restoreStatus); |
| 243 | + |
| 244 | + bucketManager.delete(TestConfig.testBucket_z0, copyKey); |
| 245 | + BucketLifeCycleRule rule = new BucketLifeCycleRule(ruleName, ""); |
| 246 | + rule.setToLineAfterDays(1); |
| 247 | + rule.setToArchiveAfterDays(2); |
| 248 | + rule.setToDeepArchiveAfterDays(3); |
| 249 | + rule.setDeleteAfterDays(4); |
| 250 | + bucketManager.putBucketLifecycleRule(TestConfig.testBucket_z0, rule); |
| 251 | + bucketManager.copy(TestConfig.testBucket_z0, TestConfig.testKey_z0, TestConfig.testBucket_z0, copyKey, true); |
| 252 | + bucketManager.deleteAfterDays(TestConfig.testBucket_z0, copyKey, 1); |
| 253 | + info = bucketManager.stat(TestConfig.testBucket_z0, copyKey); |
| 254 | + assertNotNull(info.hash); |
| 255 | + assertNotNull(info.mimeType); |
| 256 | + assertNotNull(info.expiration); |
| 257 | +// assertNotNull(info.transitionToIA); |
| 258 | +// assertNotNull(info.transitionToArchive); |
| 259 | +// assertNotNull(info.transitionToDeepArchive); |
| 260 | + } catch (QiniuException e) { |
| 261 | + e.printStackTrace(); |
| 262 | + fail("status change type fail:" + e); |
| 263 | + } finally { |
| 264 | + try { |
| 265 | + bucketManager.deleteBucketLifecycleRule(TestConfig.testBucket_z0, ruleName); |
| 266 | + } catch (QiniuException e) { |
| 267 | + e.printStackTrace(); |
| 268 | + } |
| 269 | + } |
| 270 | + |
| 271 | + try { |
| 272 | + FileInfo info = bucketManager.stat(TestConfig.testBucket_z0, copyKey); |
| 273 | + assertNotNull(info.hash); |
| 274 | + assertNotNull(info.mimeType); |
| 275 | + assertNotNull(info.expiration); |
| 276 | + } catch (QiniuException e) { |
| 277 | + fail("status fail:" + e); |
| 278 | + } |
| 279 | + |
218 | 280 | // test exists
|
219 | 281 | Map<String, String> bucketKeyMap = new HashMap<String, String>();
|
220 | 282 | bucketKeyMap.put(TestConfig.testBucket_z0, TestConfig.testKey_z0);
|
|
0 commit comments