forked from aliyun/aliyun-oss-android-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into dev_request_getobjectacl
Conflicts: oss-android-sdk/src/main/java/com/alibaba/sdk/android/oss/OSS.java oss-android-sdk/src/main/java/com/alibaba/sdk/android/oss/OSSClient.java oss-android-sdk/src/main/java/com/alibaba/sdk/android/oss/OSSImpl.java oss-android-sdk/src/main/java/com/alibaba/sdk/android/oss/common/utils/OSSUtils.java oss-android-sdk/src/main/java/com/alibaba/sdk/android/oss/internal/InternalRequestOperation.java oss-android-sdk/src/main/java/com/alibaba/sdk/android/oss/internal/ResponseParsers.java
- Loading branch information
Showing
36 changed files
with
1,415 additions
and
761 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
64 changes: 64 additions & 0 deletions
64
oss-android-sdk/src/androidTest/java/com/alibaba/sdk/android/BaseTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.alibaba.sdk.android; | ||
|
||
import android.test.AndroidTestCase; | ||
|
||
import com.alibaba.sdk.android.oss.ClientConfiguration; | ||
import com.alibaba.sdk.android.oss.OSS; | ||
import com.alibaba.sdk.android.oss.OSSClient; | ||
import com.alibaba.sdk.android.oss.common.OSSLog; | ||
import com.alibaba.sdk.android.oss.model.CreateBucketRequest; | ||
|
||
import static com.alibaba.sdk.android.oss.model.CannedAccessControlList.PublicReadWrite; | ||
|
||
/** | ||
* Created by jingdan on 2018/3/1. | ||
*/ | ||
|
||
public abstract class BaseTestCase extends AndroidTestCase { | ||
protected String mBucketName; | ||
protected String mPublicBucketName; | ||
protected OSS oss; | ||
|
||
abstract void initTestData() throws Exception; | ||
|
||
protected void initOSSClient() { | ||
ClientConfiguration conf = new ClientConfiguration(); | ||
conf.setConnectionTimeout(15 * 1000); // 连接超时,默认15秒 | ||
conf.setSocketTimeout(15 * 1000); // socket超时,默认15秒 | ||
conf.setMaxConcurrentRequest(5); // 最大并发请求书,默认5个 | ||
conf.setMaxErrorRetry(2); // 失败后最大重试次数,默认2次 | ||
oss = new OSSClient(getContext(), OSSTestConfig.ENDPOINT, OSSTestConfig.credentialProvider); | ||
} | ||
|
||
@Override | ||
protected void setUp() throws Exception { | ||
super.setUp(); | ||
mBucketName = OSSTestUtils.produceBucketName(getName()); | ||
mPublicBucketName = OSSTestUtils.produceBucketName("public" + getName()); | ||
OSSTestConfig.instance(getContext()); | ||
if (oss == null) { | ||
OSSLog.enableLog(); | ||
initOSSClient(); | ||
try { | ||
CreateBucketRequest request = new CreateBucketRequest(mBucketName); | ||
oss.createBucket(request); | ||
CreateBucketRequest request2 = new CreateBucketRequest(mPublicBucketName); | ||
request2.setBucketACL(PublicReadWrite); | ||
oss.createBucket(request2); | ||
initTestData(); | ||
} catch (Exception e) { | ||
} | ||
|
||
} | ||
} | ||
|
||
@Override | ||
protected void tearDown() throws Exception { | ||
super.tearDown(); | ||
try { | ||
OSSTestUtils.cleanBucket(oss, mBucketName); | ||
OSSTestUtils.cleanBucket(oss, mPublicBucketName); | ||
} catch (Exception e) { | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.