G-XD commented on code in PR #3238:
URL:
https://github.com/apache/incubator-opendal/pull/3238#discussion_r1349616871
##########
bindings/java/src/test/java/org/apache/opendal/test/behavior/AbstractBehaviorTest.java:
##########
@@ -605,6 +757,158 @@ public void testBlockingCopyOverwrite() {
}
}
+ @TestInstance(TestInstance.Lifecycle.PER_CLASS)
+ @Nested
+ class BlockingRenameTest {
+ @BeforeAll
+ public void precondition() {
+ final Capability capability = blockingOperator.info.fullCapability;
+ assumeTrue(
+ capability.read && capability.write && capability.copy &&
capability.blocking && capability.rename);
+ }
+
+ /**
+ * Rename a file and test with stat.
+ */
+ @Test
+ public void testBlockingRenameFile() {
+ final String sourcePath = UUID.randomUUID().toString();
+ final byte[] sourceContent = generateBytes();
+
+ blockingOperator.write(sourcePath, sourceContent);
+
+ final String targetPath = UUID.randomUUID().toString();
+
+ blockingOperator.rename(sourcePath, targetPath);
+
+ assertThatThrownBy(() -> blockingOperator.stat(sourcePath))
+
.is(OpenDALExceptionCondition.ofAsync(OpenDALException.Code.NotFound));
+
+
assertThat(blockingOperator.stat(targetPath).getContentLength()).isEqualTo(sourceContent.length);
+
+ blockingOperator.delete(sourcePath);
+ blockingOperator.delete(targetPath);
+ }
+
+ /**
+ * Rename a nonexistent source should return an error.
+ */
+ @Test
+ public void testBlockingRenameNonExistingSource() {
+ final String sourcePath = UUID.randomUUID().toString();
+ final String targetPath = UUID.randomUUID().toString();
+
+ assertThatThrownBy(() -> blockingOperator.rename(sourcePath,
targetPath))
+
.is(OpenDALExceptionCondition.ofAsync(OpenDALException.Code.NotFound));
+ }
+
+ /**
+ * Rename a dir as source should return an error.
+ */
+ @Test
+ public void testBlockingRenameSourceDir() {
Review Comment:
But the `test_blocking_rename_source_dir` test is also defined in opendal's
behavior test.
https://github.com/apache/incubator-opendal/blob/3176d21a66052244e7f0a9f05014afd6d075c859/core/tests/behavior/blocking_rename.rs#L76
##########
bindings/java/src/test/java/org/apache/opendal/test/behavior/AbstractBehaviorTest.java:
##########
@@ -605,6 +757,158 @@ public void testBlockingCopyOverwrite() {
}
}
+ @TestInstance(TestInstance.Lifecycle.PER_CLASS)
+ @Nested
+ class BlockingRenameTest {
+ @BeforeAll
+ public void precondition() {
+ final Capability capability = blockingOperator.info.fullCapability;
+ assumeTrue(
+ capability.read && capability.write && capability.copy &&
capability.blocking && capability.rename);
Review Comment:
Ok, does it need to be changed in opendal's behavior test later?
https://github.com/apache/incubator-opendal/blob/3176d21a66052244e7f0a9f05014afd6d075c859/core/tests/behavior/blocking_rename.rs#L25
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]