Skip to content

Commit

Permalink
test case: exception don't print
Browse files Browse the repository at this point in the history
  • Loading branch information
YangSen-qn committed Oct 27, 2023
1 parent e477179 commit ba3073b
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/qiniu/http/Response.java
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public synchronized InputStream bodyStream() throws QiniuException {
}

public synchronized void close() {
if (this.response != null) {
if (this.response != null && this.response.body() != null) {
this.response.close();
}
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/qiniu/storage/BucketManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ public FileListing listFiles(String bucket, String prefix, String marker, int li
throws QiniuException {
Response response = listV1(bucket, prefix, marker, limit, delimiter);
if (!response.isOK()) {
response.close();
throw new QiniuException(response);
}
FileListing fileListing = response.jsonToObject(FileListing.class);
Expand Down
1 change: 0 additions & 1 deletion src/test/java/test/com/qiniu/sms/SmsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ public void sendFulltextMessage() {
Response response = smsManager.sendFulltextMessage(mobiles, "【七牛云】尊敬的用户你好,您的验证码是 38232");
assertNotNull(response);
} catch (QiniuException e) {
e.printStackTrace();
assertTrue(ResCode.find(e.code(), ResCode.getPossibleResCode(401)));
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/test/java/test/com/qiniu/storage/ApiUploadV2Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,7 @@ public void testAbortUpload() {
assertTrue(initUploadResponse.isOK(), initUploadResponse.getResponse() + "");
assertNotNull(initUploadResponse.getUploadId(), initUploadResponse.getUploadId() + "");
assertNotNull(initUploadResponse.getExpireAt(), initUploadResponse.getExpireAt() + "");
} catch (QiniuException e) {
e.printStackTrace();
} catch (QiniuException ignore) {
}

// 2. 上传文件数据
Expand Down Expand Up @@ -393,7 +392,7 @@ public void testAbortUpload() {
// 列举结束
break;
} catch (QiniuException e) {
e.printStackTrace();
// e.printStackTrace();
assertTrue(e.response.statusCode == 612, e.response + "");
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/test/com/qiniu/storage/BucketTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public void testListIterator() throws Exception {
testFileWithHandler(new TestFileHandler() {
@Override
public void testFile(TestConfig.TestFile file, BucketManager bucketManager) throws IOException {
BucketManager.FileListIterator it = bucketManager.createFileListIterator(file.getBucketName(), "", 20,
BucketManager.FileListIterator it = bucketManager.createFileListIterator(file.getBucketName(), "", 500,
null);
assertTrue(it.hasNext());
FileInfo[] items0 = it.next();
Expand Down
11 changes: 4 additions & 7 deletions src/test/java/test/com/qiniu/storage/BucketTest2.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public void testListUseDelimiter() {
public void testListIterator() {
String[] buckets = new String[]{TestConfig.testBucket_z0};
for (String bucket : buckets) {
BucketManager.FileListIterator it = bucketManager.createFileListIterator(bucket, "", 300, null);
BucketManager.FileListIterator it = bucketManager.createFileListIterator(bucket, "", 500, null);

assertTrue(it.hasNext());
FileInfo[] items0 = it.next();
Expand Down Expand Up @@ -230,8 +230,7 @@ public void testStat() {

try {
bucketManager.deleteBucketLifecycleRule(TestConfig.testBucket_z0, ruleName);
} catch (QiniuException e) {
e.printStackTrace();
} catch (QiniuException ignore) {
}

try {
Expand Down Expand Up @@ -265,8 +264,7 @@ public void testStat() {
} finally {
try {
bucketManager.deleteBucketLifecycleRule(TestConfig.testBucket_z0, ruleName);
} catch (QiniuException e) {
e.printStackTrace();
} catch (QiniuException ignore) {
}
}

Expand Down Expand Up @@ -1470,8 +1468,7 @@ public void testIndexPage() throws QiniuException {

try {
bucketManager.setIndexPage(TestConfig.dummyBucket, IndexPageType.HAS);
} catch (QiniuException e) {
e.printStackTrace();
} catch (QiniuException ignore) {
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,7 @@ public void testKey2() throws IOException {
try {
Response res = up.upload(f, token, null);
fail("key not match, should failed");
} catch (QiniuException e) {
e.printStackTrace();
} catch (QiniuException ignore) {
// TODO
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/test/java/test/com/qiniu/storage/FormUploadTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,6 @@ public void testInvalidToken() {
if (e.code() != -1) {
assertEquals(401, e.code());
assertNotNull(e.response.reqId);
} else {
e.printStackTrace();
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/test/java/test/com/qiniu/storage/RecordUploadTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,8 @@ public void run() {
System.out.println("UP: " + i + ", enter run");
response = up.up(region);
System.out.println("UP: " + i + ", left run");
} catch (Exception e) {
} catch (Exception ignore) {
System.out.println("UP: " + i + ", exception run");
e.printStackTrace();
}
complete.isComplete.set(true);
}
Expand Down

0 comments on commit ba3073b

Please sign in to comment.