+ * Read the document of + * opendal::ErrorKind + * for the details of each code. + */ public enum Code { Unexpected, Unsupported, diff --git a/bindings/java/src/test/java/org/apache/opendal/ExceptionTest.java b/bindings/java/src/test/java/org/apache/opendal/BlockingOperatorTest.java similarity index 60% rename from bindings/java/src/test/java/org/apache/opendal/ExceptionTest.java rename to bindings/java/src/test/java/org/apache/opendal/BlockingOperatorTest.java index d91e6f91bfe7..8964cd17bf04 100644 --- a/bindings/java/src/test/java/org/apache/opendal/ExceptionTest.java +++ b/bindings/java/src/test/java/org/apache/opendal/BlockingOperatorTest.java @@ -19,17 +19,16 @@ package org.apache.opendal; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import java.util.HashMap; import java.util.Map; -import org.apache.opendal.exception.ODException; +import org.apache.opendal.exception.OpenDALException; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; - -public class ExceptionTest { +public class BlockingOperatorTest { private BlockingOperator op; @BeforeEach @@ -46,7 +45,20 @@ public void clean() { @Test public void testStatNotExistFile() { - final ODException exception = assertThrows(ODException.class, () -> op.stat("not_exist_file")); - assertEquals(ODException.Code.NotFound, exception.getCode()); + assertThatExceptionOfType(OpenDALException.class) + .isThrownBy(() -> op.stat("nonexistence")) + .extracting(OpenDALException::getCode) + .isEqualTo(OpenDALException.Code.NotFound); + } + + @Test + public void testCreateAndDelete() { + op.write("testCreateAndDelete", "Odin"); + assertThat(op.read("testCreateAndDelete")).isEqualTo("Odin"); + op.delete("testCreateAndDelete"); + assertThatExceptionOfType(OpenDALException.class) + .isThrownBy(() -> op.stat("testCreateAndDelete")) + .extracting(OpenDALException::getCode) + .isEqualTo(OpenDALException.Code.NotFound); } } diff --git a/bindings/java/tools/build.py b/bindings/java/tools/build.py index 816e88170958..bae9f8b78184 100755 --- a/bindings/java/tools/build.py +++ b/bindings/java/tools/build.py @@ -59,7 +59,7 @@ def get_cargo_artifact_name(classifier: str) -> str: target = classifier_to_target(args.classifier) if target: command = ['rustup', 'target', 'add', target] - print(subprocess.list2cmdline(command)) + print('$ ' + subprocess.list2cmdline(command)) subprocess.run(command, cwd=basedir, check=True) cmd += ['--target', target] @@ -67,7 +67,7 @@ def get_cargo_artifact_name(classifier: str) -> str: Path(output).mkdir(exist_ok=True, parents=True) cmd += ['--target-dir', output] - print(subprocess.list2cmdline(cmd)) + print('$ ' + subprocess.list2cmdline(cmd)) subprocess.run(cmd, cwd=basedir, check=True) artifact = get_cargo_artifact_name(args.classifier)