Skip to content

Commit 0776a59

Browse files
committed
port backup
1 parent 155cfbd commit 0776a59

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

library/src/androidTest/java/com/qiniu/android/FormUploadTest.java

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,4 +323,48 @@ public void complete(String k, ResponseInfo rinfo, JSONObject response) {
323323
Assert.assertNotNull(resp);
324324
}
325325

326+
@SmallTest
327+
public void testPortBackup() throws Throwable {
328+
329+
Configuration c = new Configuration.Builder()
330+
.zone(new Zone("upload.qiniu.com", Zone.zone0.upHostBackup, Zone.zone0.upIp))
331+
.upPort(9999)
332+
.build();
333+
UploadManager _up = new UploadManager(c);
334+
final String expectKey = "你好;\"\r\n\r\n\r\n";
335+
Map<String, String> params = new HashMap<String, String>();
336+
params.put("x:foo", "fooval");
337+
final UploadOptions opt = new UploadOptions(params, null, true, null, null);
338+
339+
uploadManager.put("hello".getBytes(), expectKey, TestConfig.token, new UpCompletionHandler() {
340+
public void complete(String k, ResponseInfo rinfo, JSONObject response) {
341+
Log.i("qiniutest", k + rinfo);
342+
key = k;
343+
info = rinfo;
344+
resp = response;
345+
signal.countDown();
346+
}
347+
}, opt);
348+
349+
350+
try {
351+
signal.await(120, TimeUnit.SECONDS); // wait for callback
352+
} catch (InterruptedException e) {
353+
e.printStackTrace();
354+
}
355+
// 尝试获取info信息。
356+
// key == null : 没进入 complete ? 什么导致的?
357+
if (!expectKey.equals(key)) {
358+
//此处通不过, travis 会打印信息
359+
Assert.assertEquals("", info);
360+
}
361+
if (info == null || !info.isOK()) {
362+
//此处通不过, travis 会打印信息
363+
Assert.assertEquals("", info);
364+
}
365+
Assert.assertEquals(expectKey, key);
366+
Assert.assertTrue(info.isOK());
367+
Assert.assertNotNull(info.reqId);
368+
Assert.assertNotNull(resp);
369+
}
326370
}

library/src/androidTest/java/com/qiniu/android/ResumeUploadTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import android.util.Log;
77

88
import com.qiniu.android.http.ResponseInfo;
9+
import com.qiniu.android.storage.Configuration;
910
import com.qiniu.android.storage.UpCompletionHandler;
1011
import com.qiniu.android.storage.UploadManager;
1112

@@ -26,7 +27,8 @@ public class ResumeUploadTest extends InstrumentationTestCase {
2627
private volatile JSONObject resp;
2728

2829
public void setUp() throws Exception {
29-
uploadManager = new UploadManager();
30+
Configuration config = new Configuration.Builder().upPort(9999).build();
31+
uploadManager = new UploadManager(config);
3032
}
3133

3234
private void template(int size) throws Throwable {

0 commit comments

Comments
 (0)