Skip to content

Commit

Permalink
Merge pull request #571 from zhangzqs/master
Browse files Browse the repository at this point in the history
add some method
  • Loading branch information
bachue authored Mar 29, 2023
2 parents a8b5f34 + b370551 commit 1c54058
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/com/qiniu/http/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,10 @@ private Response patch(String url, RequestBody body, StringMap headers) throws Q
return send(requestBuilder, headers);
}

public Response head(String url, StringMap headers) throws QiniuException {
Request.Builder requestBuilder = new Request.Builder().url(url).head();
return send(requestBuilder, headers);
}

public Response send(final Request.Builder requestBuilder, StringMap headers) throws QiniuException {
if (headers != null) {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/qiniu/storage/BucketManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -1342,6 +1342,10 @@ private void setExecBucket(String bucket) {
public String execBucket() {
return execBucket;
}

public int size() {
return ops.size();
}
}

/**
Expand Down
27 changes: 27 additions & 0 deletions src/test/java/test/com/qiniu/storage/BucketManagerTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package test.com.qiniu.storage;

import com.qiniu.storage.BucketManager;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

public class BucketManagerTest {
@Test
@Tag("UnitTest")
public void testBatchOperationsSize() {
BucketManager.BatchOperations batchOperations = new BucketManager.BatchOperations();
Assertions.assertEquals(0, batchOperations.size());

batchOperations.addDeleteOp("bucket1", "1", "2");
Assertions.assertEquals(2, batchOperations.size());

batchOperations.addCopyOp(
"fromBucket", "fromFileKey",
"toBucket", "toFileKey"
);
Assertions.assertEquals(3, batchOperations.size());

batchOperations.addRenameOp("fromBucket", "fromFileKey", "toFileKey");
Assertions.assertEquals(4, batchOperations.size());
}
}

0 comments on commit 1c54058

Please sign in to comment.