You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2021/08/29 03:57:20 UTC
[shardingsphere] branch master updated: Add test case for
OptionalSPIRegistry (#12079)
This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 1a5914b Add test case for OptionalSPIRegistry (#12079)
1a5914b is described below
commit 1a5914bcd942283d5fa87b40cad6917259bbb9ba
Author: Serendipity <ja...@163.com>
AuthorDate: Sun Aug 29 11:56:48 2021 +0800
Add test case for OptionalSPIRegistry (#12079)
---
.../spi/fixture/optinal/OptionalSPIFixture.java | 24 ++++++++++++++
.../fixture/optinal/OptionalSPIFixtureImpl.java | 22 +++++++++++++
.../spi/optional/OptionalSPIRegistryTest.java | 38 ++++++++++++++++++++++
...ngsphere.spi.fixture.optinal.OptionalSPIFixture | 18 ++++++++++
4 files changed, 102 insertions(+)
diff --git a/shardingsphere-spi/src/test/java/org/apache/shardingsphere/spi/fixture/optinal/OptionalSPIFixture.java b/shardingsphere-spi/src/test/java/org/apache/shardingsphere/spi/fixture/optinal/OptionalSPIFixture.java
new file mode 100644
index 0000000..85dc588
--- /dev/null
+++ b/shardingsphere-spi/src/test/java/org/apache/shardingsphere/spi/fixture/optinal/OptionalSPIFixture.java
@@ -0,0 +1,24 @@
+/*
+ * 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.shardingsphere.spi.fixture.optinal;
+
+import org.apache.shardingsphere.spi.optional.OptionalSPI;
+
+public interface OptionalSPIFixture extends OptionalSPI {
+}
+
diff --git a/shardingsphere-spi/src/test/java/org/apache/shardingsphere/spi/fixture/optinal/OptionalSPIFixtureImpl.java b/shardingsphere-spi/src/test/java/org/apache/shardingsphere/spi/fixture/optinal/OptionalSPIFixtureImpl.java
new file mode 100644
index 0000000..257ba79
--- /dev/null
+++ b/shardingsphere-spi/src/test/java/org/apache/shardingsphere/spi/fixture/optinal/OptionalSPIFixtureImpl.java
@@ -0,0 +1,22 @@
+/*
+ * 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.shardingsphere.spi.fixture.optinal;
+
+public class OptionalSPIFixtureImpl implements OptionalSPIFixture {
+}
+
diff --git a/shardingsphere-spi/src/test/java/org/apache/shardingsphere/spi/optional/OptionalSPIRegistryTest.java b/shardingsphere-spi/src/test/java/org/apache/shardingsphere/spi/optional/OptionalSPIRegistryTest.java
new file mode 100644
index 0000000..9e812e9
--- /dev/null
+++ b/shardingsphere-spi/src/test/java/org/apache/shardingsphere/spi/optional/OptionalSPIRegistryTest.java
@@ -0,0 +1,38 @@
+/*
+ * 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.shardingsphere.spi.optional;
+
+import java.util.Optional;
+import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
+import org.apache.shardingsphere.spi.fixture.optinal.OptionalSPIFixture;
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+
+public final class OptionalSPIRegistryTest {
+
+ static {
+ ShardingSphereServiceLoader.register(OptionalSPIFixture.class);
+ }
+
+ @Test
+ public void assertFindRegisteredService() {
+ Optional<OptionalSPIFixture> actual = OptionalSPIRegistry.findRegisteredService(OptionalSPIFixture.class);
+ assertTrue(actual.isPresent());
+ }
+}
diff --git a/shardingsphere-spi/src/test/resources/META-INF/services/org.apache.shardingsphere.spi.fixture.optinal.OptionalSPIFixture b/shardingsphere-spi/src/test/resources/META-INF/services/org.apache.shardingsphere.spi.fixture.optinal.OptionalSPIFixture
new file mode 100644
index 0000000..cb27355
--- /dev/null
+++ b/shardingsphere-spi/src/test/resources/META-INF/services/org.apache.shardingsphere.spi.fixture.optinal.OptionalSPIFixture
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+org.apache.shardingsphere.spi.fixture.optinal.OptionalSPIFixtureImpl