@@ -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}
0 commit comments