use of com.aliyun.oss.model.GetBucketReplicationProgressRequest in project aliyun-oss-java-sdk by aliyun.
the class BucketReplicationTest method testUnormalGetBucketReplicationProgressInvalidParam.
@Test
public void testUnormalGetBucketReplicationProgressInvalidParam() throws ParseException {
final String bucketName = "test-unormal-bucket-replication-progress";
final String ruleId = "bucket-replication-rule-id";
try {
ossClient.createBucket(bucketName);
AddBucketReplicationRequest request = new AddBucketReplicationRequest(bucketName);
request.setTargetBucketName(targetBucketName);
request.setTargetBucketLocation(targetBucketLoc);
request.setReplicationRuleID(ruleId);
ossClient.addBucketReplication(request);
try {
ossClient.getBucketReplicationProgress(new GetBucketReplicationProgressRequest(bucketName));
Assert.fail("Get bucket replication should not be successful.");
} catch (NullPointerException e) {
}
ossClient.deleteBucketReplication(new DeleteBucketReplicationRequest(bucketName, ruleId));
} catch (OSSException e) {
Assert.fail(e.getMessage());
} finally {
ossClient.deleteBucket(bucketName);
}
}
use of com.aliyun.oss.model.GetBucketReplicationProgressRequest in project aliyun-oss-java-sdk by aliyun.
the class BucketReplicationTest method testNormalGetBucketReplicationProgressWithDisableHistory.
@Test
public void testNormalGetBucketReplicationProgressWithDisableHistory() throws ParseException {
final String bucketName = "test-bucket-replication-progress-disable-history";
final String repRuleID = "test-replication-ruleid";
try {
ossClient.createBucket(bucketName);
AddBucketReplicationRequest request = new AddBucketReplicationRequest(bucketName);
request.setReplicationRuleID(repRuleID);
request.setTargetBucketName(targetBucketName);
request.setTargetBucketLocation(targetBucketLoc);
request.setEnableHistoricalObjectReplication(false);
ossClient.addBucketReplication(request);
List<ReplicationRule> rules = ossClient.getBucketReplication(bucketName);
Assert.assertEquals(rules.size(), 1);
ReplicationRule r0 = rules.get(0);
Assert.assertEquals(r0.getReplicationRuleID(), repRuleID);
Assert.assertEquals(r0.getTargetBucketName(), targetBucketName);
Assert.assertEquals(r0.getTargetBucketLocation(), targetBucketLoc);
Assert.assertEquals(r0.isEnableHistoricalObjectReplication(), false);
Assert.assertEquals(r0.getReplicationStatus(), ReplicationStatus.Starting);
BucketReplicationProgress process = ossClient.getBucketReplicationProgress(new GetBucketReplicationProgressRequest(bucketName).withReplicationRuleID(repRuleID));
Assert.assertEquals(process.getReplicationRuleID(), repRuleID);
Assert.assertEquals(process.getTargetBucketName(), targetBucketName);
Assert.assertEquals(process.getTargetBucketLocation(), targetBucketLoc);
Assert.assertEquals(process.getReplicationStatus(), ReplicationStatus.Starting);
Assert.assertEquals(process.getHistoricalObjectProgress(), Float.valueOf(0));
Assert.assertEquals(process.isEnableHistoricalObjectReplication(), false);
Assert.assertEquals(process.getNewObjectProgress(), null);
// Assert.assertEquals(diffSecond(process.getNewObjectProgress(), now) < 5, true);
ossClient.deleteBucketReplication(new DeleteBucketReplicationRequest(bucketName, repRuleID));
} catch (OSSException e) {
Assert.fail(e.getMessage());
} finally {
ossClient.deleteBucket(bucketName);
}
}
Aggregations