|
2 | 2 |
|
3 | 3 | import com.qiniu.TempFile;
|
4 | 4 | import com.qiniu.TestConfig;
|
| 5 | +import com.qiniu.common.Config; |
5 | 6 | import com.qiniu.common.QiniuException;
|
6 | 7 | import com.qiniu.http.Response;
|
7 | 8 | import com.qiniu.util.StringMap;
|
8 | 9 | import org.junit.Test;
|
9 | 10 |
|
10 | 11 | import java.io.File;
|
| 12 | +import java.io.FileInputStream; |
11 | 13 | import java.io.IOException;
|
12 | 14 | import java.util.concurrent.CountDownLatch;
|
13 | 15 | import java.util.concurrent.TimeUnit;
|
@@ -250,5 +252,60 @@ class MyRet {
|
250 | 252 | public String mimeType;
|
251 | 253 | }
|
252 | 254 |
|
| 255 | + // @Test |
| 256 | + public void testFormLargeSize() { |
| 257 | + Config.PUT_THRESHOLD = 25 * 1024 * 1024; |
| 258 | + |
| 259 | + final String expectKey = "yyyyyy"; |
| 260 | + File f = null; |
| 261 | + try { |
| 262 | + f = TempFile.createFile(Config.PUT_THRESHOLD / 1024 - 1); |
| 263 | + } catch (IOException e) { |
| 264 | + e.printStackTrace(); |
| 265 | + } |
| 266 | + String token = TestConfig.testAuth.uploadToken(TestConfig.bucket, expectKey); |
| 267 | + Response r = null; |
| 268 | + try { |
| 269 | + r = uploadManager.put(f, expectKey, token, null, null, false); |
| 270 | + } catch (QiniuException e) { |
| 271 | + try { |
| 272 | + assertEquals("_", e.response.bodyString()); |
| 273 | + } catch (QiniuException e1) { |
| 274 | + e1.printStackTrace(); |
| 275 | + } |
| 276 | + } |
| 277 | + |
| 278 | + } |
| 279 | + |
| 280 | + |
| 281 | + // @Test |
| 282 | + public void testFormLargeSize2() { |
| 283 | + Config.PUT_THRESHOLD = 25 * 1024 * 1024; |
| 284 | + |
| 285 | + final String expectKey = "xxxxxxx"; |
| 286 | + byte[] bb = null; |
| 287 | + File f = null; |
| 288 | + try { |
| 289 | + f = TempFile.createFile(Config.PUT_THRESHOLD / 1024 - 1); |
| 290 | + bb = new byte[(int) (f.length())]; |
| 291 | + FileInputStream fis = new FileInputStream(f); |
| 292 | + fis.read(bb, 0, (int) (f.length())); |
| 293 | + } catch (IOException e) { |
| 294 | + e.printStackTrace(); |
| 295 | + } |
| 296 | + |
| 297 | + String token = TestConfig.testAuth.uploadToken(TestConfig.bucket, expectKey); |
| 298 | + Response r = null; |
| 299 | + try { |
| 300 | + r = uploadManager.put(bb, expectKey, token, null, null, false); |
| 301 | + } catch (QiniuException e) { |
| 302 | + try { |
| 303 | + assertEquals("_", e.response.bodyString()); |
| 304 | + } catch (QiniuException e1) { |
| 305 | + e1.printStackTrace(); |
| 306 | + } |
| 307 | + } |
| 308 | + |
| 309 | + } |
253 | 310 |
|
254 | 311 | }
|
0 commit comments