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 33cb9093f20 fix DatabaseDiscoveryRuleTest NPE (#19721)
33cb9093f20 is described below
commit 33cb9093f208a547dbc995d2689983d1bb020f4f
Author: skai <[email protected]>
AuthorDate: Sun Jul 31 21:09:28 2022 +0800
fix DatabaseDiscoveryRuleTest NPE (#19721)
---
.../dbdiscovery/rule/DatabaseDiscoveryRuleTest.java | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/rule/DatabaseDiscoveryRuleTest.java
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/rule/DatabaseDiscoveryRuleTest.java
index 8761503c605..90eb8a29e9a 100644
---
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/rule/DatabaseDiscoveryRuleTest.java
+++
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/rule/DatabaseDiscoveryRuleTest.java
@@ -21,9 +21,13 @@ import
org.apache.shardingsphere.dbdiscovery.api.config.DatabaseDiscoveryRuleCon
import
org.apache.shardingsphere.dbdiscovery.api.config.rule.DatabaseDiscoveryDataSourceRuleConfiguration;
import
org.apache.shardingsphere.dbdiscovery.api.config.rule.DatabaseDiscoveryHeartBeatConfiguration;
import
org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
+import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
+import
org.apache.shardingsphere.infra.config.mode.PersistRepositoryConfiguration;
import org.apache.shardingsphere.infra.distsql.constant.ExportableConstants;
import org.apache.shardingsphere.infra.instance.InstanceContext;
+import org.apache.shardingsphere.schedule.core.ScheduleContextFactory;
import org.apache.shardingsphere.test.mock.MockedDataSource;
+import org.junit.Before;
import org.junit.Test;
import javax.sql.DataSource;
@@ -45,7 +49,12 @@ import static org.mockito.Mockito.when;
public final class DatabaseDiscoveryRuleTest {
private final Map<String, DataSource> dataSourceMap =
Collections.singletonMap("primary_ds", new MockedDataSource());
-
+
+ @Before
+ public void init() {
+ ScheduleContextFactory.getInstance().init("foo_id", new
ModeConfiguration("Cluster", mock(PersistRepositoryConfiguration.class),
false));
+ }
+
@Test
public void assertFindDataSourceRule() {
Optional<DatabaseDiscoveryDataSourceRule> actual =
createRule().findDataSourceRule("replica_ds");