Search in sources :

Example 1 with RestoreObjectResult

use of com.aliyun.oss.model.RestoreObjectResult in project aliyun-oss-java-sdk by aliyun.

the class ArchiveTest method testRestoreResultClassSetter.

@Test
public void testRestoreResultClassSetter() {
    // update coverage.
    RestoreObjectResult result = new RestoreObjectResult(200);
    result.setStatusCode(400);
    Assert.assertEquals(400, result.getStatusCode());
}
Also used : RestoreObjectResult(com.aliyun.oss.model.RestoreObjectResult) Test(org.junit.Test)

Example 2 with RestoreObjectResult

use of com.aliyun.oss.model.RestoreObjectResult in project aliyun-oss-java-sdk by aliyun.

the class ObjectVersionTest method testRestoreObject.

@Test
public void testRestoreObject() {
    String key = "version-test-restore-object";
    long inputStreamLength = 1024;
    try {
        // put
        InputStream instream = genFixedLengthInputStream(inputStreamLength);
        ObjectMetadata metadata = new ObjectMetadata();
        metadata.setHeader("x-oss-storage-class", "Archive");
        PutObjectResult putResult = ossClient.putObject(bucketName, key, instream, metadata);
        Assert.assertNotNull(putResult.getVersionId());
        Assert.assertEquals(64, putResult.getVersionId().length());
        // restore
        GenericRequest genericRequest = new GenericRequest(bucketName, key, putResult.getVersionId());
        RestoreObjectResult restoreObjectResult = ossClient.restoreObject(genericRequest);
        Assert.assertEquals(202, restoreObjectResult.getStatusCode());
        Assert.assertNotNull(restoreObjectResult.getVersionId());
        Assert.assertEquals(64, restoreObjectResult.getVersionId().length());
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }
}
Also used : PutObjectResult(com.aliyun.oss.model.PutObjectResult) InputStream(java.io.InputStream) RestoreObjectResult(com.aliyun.oss.model.RestoreObjectResult) ObjectMetadata(com.aliyun.oss.model.ObjectMetadata) GenericRequest(com.aliyun.oss.model.GenericRequest) OSSException(com.aliyun.oss.OSSException) Test(org.junit.Test)

Aggregations

RestoreObjectResult (com.aliyun.oss.model.RestoreObjectResult)2 Test (org.junit.Test)2 OSSException (com.aliyun.oss.OSSException)1 GenericRequest (com.aliyun.oss.model.GenericRequest)1 ObjectMetadata (com.aliyun.oss.model.ObjectMetadata)1 PutObjectResult (com.aliyun.oss.model.PutObjectResult)1 InputStream (java.io.InputStream)1