diff --git a/bindings/java/pom.xml b/bindings/java/pom.xml
index 54e141efe11..5b542b5ce73 100644
--- a/bindings/java/pom.xml
+++ b/bindings/java/pom.xml
@@ -35,18 +35,56 @@
1.0.0
+
+
+
+ io.cucumber
+ cucumber-bom
+ 7.11.2
+ pom
+ import
+
+
+ org.junit
+ junit-bom
+ 5.9.2
+ pom
+ import
+
+
+
+
-
- junit
- junit
- 4.12
- test
- org.questdbjar-jni${rust-maven-plugin.version}
+
+ io.cucumber
+ cucumber-java
+ test
+
+
+
+ io.cucumber
+ cucumber-junit-platform-engine
+ test
+
+
+
+ org.junit.platform
+ junit-platform-suite
+ test
+
+
+
+ org.junit.jupiter
+ junit-jupiter
+ test
+
+
+
@@ -67,23 +105,47 @@
build
-
../java
-
-
true
-
${project.build.directory}/classes/org/apache/opendal/rust/libs
-
true
-
-
--color=always
-
- Great Scott, A reversed string!
-
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.11.0
+
+ UTF-8
+
+ 1.8
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 3.0.0
+
+
+ com.coderplus.maven.plugins
+ copy-rename-maven-plugin
+ 1.0
+
+
+ copy-file
+ generate-sources
+
+ copy
+
+
+ ../tests/features/binding.feature
+ target/test-classes/features/binding.feature
diff --git a/bindings/java/src/lib.rs b/bindings/java/src/lib.rs
index 370017bb9ea..323f485ae5a 100644
--- a/bindings/java/src/lib.rs
+++ b/bindings/java/src/lib.rs
@@ -38,10 +38,21 @@ pub extern "system" fn Java_org_apache_opendal_Operator_getOperator(
.get_string(&input)
.expect("Couldn't get java string!")
.into();
- let schema = Scheme::from_str(&input).unwrap();
+
+ let scheme = Scheme::from_str(&input).unwrap();
+
let map = convert_map(&mut env, ¶ms);
- let operator = build_operator(schema, map).expect("Couldn't found operator");
- Box::into_raw(Box::new(operator)) as *const i32
+ if let Ok(operator) = build_operator(scheme, map) {
+ Box::into_raw(Box::new(operator)) as *const i32
+ } else {
+ env.exception_clear().expect("Couldn't clear exception");
+ env.throw_new(
+ "java/lang/IllegalArgumentException",
+ "Unsupported operator.",
+ )
+ .expect("Couldn't throw exception");
+ std::ptr::null()
+ }
}
fn convert_map(env: &mut JNIEnv, params: &JObject) -> HashMap {
diff --git a/bindings/java/src/main/java/org/apache/opendal/Operator.java b/bindings/java/src/main/java/org/apache/opendal/Operator.java
index 96df85a289b..7a033bee892 100644
--- a/bindings/java/src/main/java/org/apache/opendal/Operator.java
+++ b/bindings/java/src/main/java/org/apache/opendal/Operator.java
@@ -17,22 +17,6 @@
* under the License.
*/
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
package org.apache.opendal;
diff --git a/bindings/java/src/test/java/org/apache/opendal/AsyncStepsTest.java b/bindings/java/src/test/java/org/apache/opendal/AsyncStepsTest.java
new file mode 100644
index 00000000000..fb3ed034234
--- /dev/null
+++ b/bindings/java/src/test/java/org/apache/opendal/AsyncStepsTest.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.opendal;
+
+import io.cucumber.java.en.Given;
+import io.cucumber.java.en.Then;
+import io.cucumber.java.en.When;
+
+
+public class AsyncStepsTest {
+
+
+ @Given("A new OpenDAL Async Operator")
+ public void a_new_open_dal_async_operator() {
+ }
+
+ @When("Async write path {string} with content {string}")
+ public void async_write_path_test_with_content_hello_world(String fileName, String content) {
+ }
+
+ @Then("The async file {string} should exist")
+ public void the_async_file_test_should_exist(String fileName) {
+ }
+
+ @Then("The async file {string} entry mode must be file")
+ public void the_async_file_test_entry_mode_must_be_file(String fileName) {
+ }
+
+ @Then("The async file {string} content length must be {int}")
+ public void the_async_file_test_content_length_must_be_13(String fileName, int length) {
+ }
+
+ @Then("The async file {string} must have content {string}")
+ public void the_async_file_test_must_have_content_hello_world(String fileName, String content) {
+ }
+}
diff --git a/bindings/java/src/test/java/org/apache/opendal/CucumberTest.java b/bindings/java/src/test/java/org/apache/opendal/CucumberTest.java
new file mode 100644
index 00000000000..785ac34cec4
--- /dev/null
+++ b/bindings/java/src/test/java/org/apache/opendal/CucumberTest.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.opendal;
+
+import org.junit.platform.suite.api.ConfigurationParameter;
+import org.junit.platform.suite.api.IncludeEngines;
+import org.junit.platform.suite.api.SelectClasspathResource;
+import org.junit.platform.suite.api.Suite;
+
+import static io.cucumber.junit.platform.engine.Constants.GLUE_PROPERTY_NAME;
+
+@Suite
+@IncludeEngines("cucumber")
+@SelectClasspathResource("features")
+@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "org.apache.opendal")
+public class CucumberTest {
+
+}
\ No newline at end of file
diff --git a/bindings/java/src/test/java/org/apache/opendal/StepsTest.java b/bindings/java/src/test/java/org/apache/opendal/StepsTest.java
new file mode 100644
index 00000000000..bca3c774d48
--- /dev/null
+++ b/bindings/java/src/test/java/org/apache/opendal/StepsTest.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.opendal;
+
+import io.cucumber.java.en.Given;
+import io.cucumber.java.en.Then;
+import io.cucumber.java.en.When;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class StepsTest {
+
+ Operator operator;
+
+ @Given("A new OpenDAL Blocking Operator")
+ public void a_new_open_dal_blocking_operator() {
+ Map params = new HashMap<>();
+ params.put("root", "/tmp");
+ this.operator = new Operator("Memory", params);
+ }
+
+ @When("Blocking write path {string} with content {string}")
+ public void blocking_write_path_test_with_content_hello_world(String fileName, String content) {
+ this.operator.write(fileName, content);
+ }
+
+
+ @Then("The blocking file {string} should exist")
+ public void the_blocking_file_test_should_exist(String content) {
+
+ }
+
+
+ @Then("The blocking file {string} entry mode must be file")
+ public void the_blocking_file_test_entry_mode_must_be_file(String fileName) {
+
+ }
+
+ @Then("The blocking file {string} content length must be {int}")
+ public void the_blocking_file_test_content_length_must_be_13(String fileName, int length) {
+ String content = this.operator.read(fileName);
+
+ assertEquals(content.length(), length);
+ }
+
+ @Then("The blocking file {string} must have content {string}")
+ public void the_blocking_file_test_must_have_content_hello_world(String fileName, String content) {
+ String readContent = this.operator.read(fileName);
+
+ assertEquals(content, readContent);
+ }
+
+
+}
diff --git a/bindings/java/src/test/java/org/apache/opendal/operator/OperatorTest.java b/bindings/java/src/test/java/org/apache/opendal/operator/OperatorTest.java
deleted file mode 100644
index b72a49531cd..00000000000
--- a/bindings/java/src/test/java/org/apache/opendal/operator/OperatorTest.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package org.apache.opendal.operator;
-
-import org.apache.opendal.Operator;
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class OperatorTest {
-
- @Test
- public void testBuilder() {
- Map params = new HashMap<>();
- params.put("root", "/tmp");
- Operator op = new Operator("Memory", params);
-
- op.write("hello1.txt", "hello world");
- String rs = op.read("hello1.txt");
- op.delete("hello1.txt");
-
- Assert.assertEquals(rs, "hello world");
-
- }
-
-}
\ No newline at end of file