2424
2525public class UploadTest extends AndroidTestCase {
2626 private String uptoken = "acmKu7Hie1OQ3t31bAovR6JORFX72MMpTicc2xje:n6I4SuMAxBgZ6o3qh8z1bMWqKow=:eyJzY29wZSI6ImFhYTUiLCJyZXR1cm5Cb2R5Ijoie1wiaGFzaFwiOlwiJChldGFnKVwiLFwia2V5XCI6XCIkKGtleSlcIixcImZuYW1lXCI6XCIgJChmbmFtZSkgXCIsXCJmc2l6ZVwiOlwiJChmc2l6ZSlcIixcImF2aW5mb1wiOlwiJChhdmluZm8pXCIsXCJ4OnRlc3RfbmFtZVwiOlwiJCh4OnRlc3RfbmFtZSlcIixcIm5vbnh0ZXN05Lit5paHX25hbWVcIjpcIiQobm9ueHRlc3TkuK3mlodfbmFtZSlcIn0iLCJkZWFkbGluZSI6MTQzMjg2ODA3NH0=" ;
27-
27+
2828 private File file ;
29-
29+
3030 private boolean uploading ;
3131 private boolean success ;
3232 private JSONObjectRet jsonRet ;
3333 private JSONObject resp ;
3434 private Exception e ;
35-
35+
3636 private Context context ;
3737 private Uri uri ;
3838 private com .qiniu .io .PutExtra extra ;
3939 private String key = IO .UNDEFINED_KEY ;
40-
40+
4141 private com .qiniu .resumableio .PutExtra rextra ;
4242
4343 public void setUp () throws Exception {
4444 key = UUID .randomUUID ().toString ();
4545 uploading = true ;
4646 success = false ;
47-
47+
4848 extra = new com .qiniu .io .PutExtra ();
4949 extra .params = new HashMap <String , String >();
5050 extra .params .put ("x:a" , "测试中文信息" );
51-
51+
5252 rextra = new com .qiniu .resumableio .PutExtra ();
5353 rextra .params = new HashMap <String , String >();
5454 rextra .params .put ("x:a" , "测试中文信息" );
55-
55+
5656 context = this .getContext ();
5757 jsonRet = new JSONObjectRet () {
5858 @ Override
@@ -94,16 +94,16 @@ public void testS() throws IOException, JSONException {
9494 sleepLimit (60 );
9595 successCheck ();
9696 }
97-
97+
9898 @ MediumTest
9999 public void testM () throws IOException , JSONException {
100- file = createFile (4 , ".test" );
100+ file = createFile (4 , "--—— 地 方 .test" );
101101 uri = Uri .fromFile (file );
102102 IO .putFile (context , uptoken , key , uri , extra , jsonRet );
103103 sleepLimit (60 * 5 );
104104 successCheck ();
105105 }
106-
106+
107107 @ SmallTest
108108 public void testRS () throws IOException , JSONException {
109109 file = createFile (0.2 , ".test" );
@@ -112,7 +112,7 @@ public void testRS() throws IOException, JSONException {
112112 sleepLimit (60 );
113113 successCheck ();
114114 }
115-
115+
116116 @ MediumTest
117117 public void testRM () throws IOException , JSONException {
118118 file = createFile (4 , ".test" );
@@ -121,7 +121,7 @@ public void testRM() throws IOException, JSONException {
121121 sleepLimit (60 * 5 );
122122 successCheck ();
123123 }
124-
124+
125125 @ MediumTest
126126 public void testRL () throws IOException , JSONException {
127127 file = createFile (8.6 , ".test" );
@@ -130,14 +130,14 @@ public void testRL() throws IOException, JSONException {
130130 sleepLimit (60 * 5 );
131131 successCheck ();
132132 }
133-
133+
134134
135135 private void successCheck () throws JSONException {
136136 Assert .assertTrue (success );
137137 Assert .assertNotNull (resp .optString ("hash" ));
138138 Assert .assertEquals (file .length (), resp .getLong ("fsize" ));
139139 }
140-
140+
141141 private void sleepLimit (int limit ){
142142 int t = 5 ;
143143 while (uploading && t < limit ){
@@ -149,7 +149,7 @@ private void sleepLimit(int limit){
149149 }
150150 }
151151 }
152-
152+
153153 private File createFile (double fileSize , String suf ) throws IOException {
154154 FileOutputStream fos = null ;
155155 try {
@@ -188,4 +188,4 @@ private byte[] getByte(){
188188 return b ;
189189 }
190190
191- }
191+ }
0 commit comments