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 2020/08/09 14:01:54 UTC

[shardingsphere] branch master updated: Add more test cases for TypedSPIRegistry‘s exception occur (#6740)

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 6c06c7d  Add more test cases for TypedSPIRegistry‘s exception occur (#6740)
6c06c7d is described below

commit 6c06c7deb5b146bfd932aa9b0fafece6e7409801
Author: Serendipity <ja...@163.com>
AuthorDate: Sun Aug 9 22:01:39 2020 +0800

    Add more test cases for TypedSPIRegistry‘s exception occur (#6740)
---
 .../infra/spi/fixture/NoImplTypedSPIFixture.java   | 24 ++++++++++++++++++++++
 .../infra/spi/type/TypedSPIRegistryTest.java       | 13 ++++++++++++
 2 files changed, 37 insertions(+)

diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/spi/fixture/NoImplTypedSPIFixture.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/spi/fixture/NoImplTypedSPIFixture.java
new file mode 100644
index 0000000..2f747fa
--- /dev/null
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/spi/fixture/NoImplTypedSPIFixture.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.infra.spi.fixture;
+
+import org.apache.shardingsphere.infra.spi.type.TypedSPI;
+
+public interface NoImplTypedSPIFixture extends TypedSPI {
+}
+
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/spi/type/TypedSPIRegistryTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/spi/type/TypedSPIRegistryTest.java
index 5b95f17..b0e0c3a 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/spi/type/TypedSPIRegistryTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/spi/type/TypedSPIRegistryTest.java
@@ -19,6 +19,8 @@ package org.apache.shardingsphere.infra.spi.type;
 
 import java.util.Properties;
 import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
+import org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundException;
+import org.apache.shardingsphere.infra.spi.fixture.NoImplTypedSPIFixture;
 import org.apache.shardingsphere.infra.spi.fixture.TypedSPIFixture;
 import org.junit.Before;
 import org.junit.Test;
@@ -44,4 +46,15 @@ public final class TypedSPIRegistryTest {
         TypedSPIFixture actual = TypedSPIRegistry.getRegisteredService(TypedSPIFixture.class);
         assertNotNull(actual);
     }
+    
+    @Test(expected = ServiceProviderNotFoundException.class)
+    public void assertGetRegisteredServiceWhenTypeIsNotExist() {
+        String type = "TEST_FIXTURE";
+        TypedSPIRegistry.getRegisteredService(TypedSPIFixture.class, type, new Properties());
+    }
+    
+    @Test(expected = ServiceProviderNotFoundException.class)
+    public void assertGetRegisteredServiceWhenSPIClassIsNotExist() {
+        TypedSPIRegistry.getRegisteredService(NoImplTypedSPIFixture.class);
+    }
 }