use of com.aliyun.oss.model.AddBucketReplicationRequest in project aliyun-oss-java-sdk by aliyun.
the class BucketReplicationTest method testUnormalSetBucketReplicationLocation.
@Test
public void testUnormalSetBucketReplicationLocation() throws ParseException {
final String bucketName = "test-unormal-bucket-replication-loc";
final String ruleId = "bucket-replication-rule-id";
try {
ossClient.createBucket(bucketName);
AddBucketReplicationRequest request = new AddBucketReplicationRequest(bucketName);
request.setTargetBucketName(targetBucketName);
request.setTargetBucketLocation("oss-cn-zhengzhou");
request.setReplicationRuleID(ruleId);
try {
ossClient.addBucketReplication(request);
Assert.fail("Set bucket replication should not be successful.");
} catch (OSSException e) {
Assert.assertEquals(e.getErrorCode(), "InvalidTargetLocation");
Assert.assertEquals(e.getMessage().startsWith("The target bucket you specified does not locate in the target location"), true);
}
} catch (OSSException e) {
Assert.fail(e.getMessage());
} finally {
ossClient.deleteBucket(bucketName);
}
}
use of com.aliyun.oss.model.AddBucketReplicationRequest in project aliyun-oss-java-sdk by aliyun.
the class BucketReplicationTest method testUnormalDeleteBucketReplicationInvalidParam.
@Test
public void testUnormalDeleteBucketReplicationInvalidParam() throws ParseException {
final String bucketName = "test-unormal-bucket-delete-replication-param";
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.deleteBucketReplication(new DeleteBucketReplicationRequest(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.AddBucketReplicationRequest in project aliyun-oss-java-sdk by aliyun.
the class BucketReplicationTest method testNormalGetBucketReplicationProgress.
@Test
public void testNormalGetBucketReplicationProgress() throws ParseException {
final String bucketName = "test-bucket-get-replication-progress";
final String repRuleID = "test-replication-progress-ruleid";
try {
ossClient.createBucket(bucketName);
AddBucketReplicationRequest request = new AddBucketReplicationRequest(bucketName);
request.setReplicationRuleID(repRuleID);
request.setTargetBucketName(targetBucketName);
request.setTargetBucketLocation(targetBucketLoc);
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(), true);
Assert.assertEquals(r0.getReplicationStatus(), ReplicationStatus.Starting);
BucketReplicationProgress process = ossClient.getBucketReplicationProgress(bucketName, 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.isEnableHistoricalObjectReplication(), true);
Assert.assertEquals(process.getHistoricalObjectProgress(), Float.valueOf(0));
Assert.assertEquals(process.getNewObjectProgress(), null);
ossClient.deleteBucketReplication(new DeleteBucketReplicationRequest(bucketName, repRuleID));
} catch (OSSException e) {
Assert.fail(e.getMessage());
} finally {
ossClient.deleteBucket(bucketName);
}
}
use of com.aliyun.oss.model.AddBucketReplicationRequest in project aliyun-oss-java-sdk by aliyun.
the class BucketReplicationTest method testNormalAddBucketReplicationWithDefaultRuleID.
@Test
public void testNormalAddBucketReplicationWithDefaultRuleID() throws ParseException {
final String bucketName = "test-bucket-replication-default-ruleid";
try {
ossClient.createBucket(bucketName);
AddBucketReplicationRequest request = new AddBucketReplicationRequest(bucketName);
request.setTargetBucketName(targetBucketName);
request.setTargetBucketLocation(targetBucketLoc);
ossClient.addBucketReplication(request);
List<ReplicationRule> rules = ossClient.getBucketReplication(bucketName);
Assert.assertEquals(rules.size(), 1);
ReplicationRule r0 = rules.get(0);
Assert.assertEquals(r0.getReplicationRuleID().length(), "d6a8bfe3-56f6-42dd-9e7f-b4301d99b0ed".length());
Assert.assertEquals(r0.getTargetBucketName(), targetBucketName);
Assert.assertEquals(r0.getTargetBucketLocation(), targetBucketLoc);
Assert.assertEquals(r0.isEnableHistoricalObjectReplication(), true);
Assert.assertEquals(r0.getReplicationStatus(), ReplicationStatus.Starting);
ossClient.deleteBucketReplication(new DeleteBucketReplicationRequest(bucketName, r0.getReplicationRuleID()));
} catch (OSSException e) {
Assert.fail(e.getMessage());
} finally {
ossClient.deleteBucket(bucketName);
}
}
use of com.aliyun.oss.model.AddBucketReplicationRequest in project aliyun-oss-java-sdk by aliyun.
the class BucketReplicationTest method testNormalDeleteBucketReplicationWithRuleID.
@Test
public void testNormalDeleteBucketReplicationWithRuleID() throws ParseException {
final String bucketName = "test-bucket-delete-replication-ruleid";
final String repRuleID = "test-replication-ruleid";
try {
ossClient.createBucket(bucketName);
AddBucketReplicationRequest request = new AddBucketReplicationRequest(bucketName);
request.setReplicationRuleID(repRuleID);
request.setTargetBucketName(targetBucketName);
request.setTargetBucketLocation(targetBucketLoc);
ossClient.addBucketReplication(request);
List<ReplicationRule> rules = ossClient.getBucketReplication(bucketName);
Assert.assertEquals(rules.size(), 1);
ReplicationRule r0 = rules.get(0);
Assert.assertEquals(r0.getReplicationStatus(), ReplicationStatus.Starting);
ossClient.deleteBucketReplication(new DeleteBucketReplicationRequest(bucketName).withReplicationRuleID(repRuleID));
rules = ossClient.getBucketReplication(bucketName);
Assert.assertEquals(rules.size(), 1);
r0 = rules.get(0);
Assert.assertEquals(r0.getReplicationStatus(), ReplicationStatus.Closing);
} catch (OSSException e) {
Assert.fail(e.getMessage());
} finally {
ossClient.deleteBucket(bucketName);
}
}
Aggregations