This is an automated email from the ASF dual-hosted git repository.
menghaoran 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 85139a9 FIX issue #12077 (#12107)
85139a9 is described below
commit 85139a96ad6cb00211435d849889a7fc008b9787
Author: hoorf <[email protected]>
AuthorDate: Tue Aug 31 19:20:25 2021 +0800
FIX issue #12077 (#12107)
* FIX issue #12077
* FIX issue #12077
---
.../manager/ContextManagerBuilderFactoryTest.java | 48 ++++++++++++++++++++++
.../DefaultFixtureContextManagerBuilder.java | 47 +++++++++++++++++++++
.../fixture/FixtureContextManagerBuilder.java | 42 +++++++++++++++++++
...ardingsphere.mode.manager.ContextManagerBuilder | 19 +++++++++
4 files changed, 156 insertions(+)
diff --git
a/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/ContextManagerBuilderFactoryTest.java
b/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/ContextManagerBuilderFactoryTest.java
new file mode 100644
index 0000000..3af0744
--- /dev/null
+++
b/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/ContextManagerBuilderFactoryTest.java
@@ -0,0 +1,48 @@
+/*
+ * 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.mode.manager;
+
+import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
+import
org.apache.shardingsphere.mode.manager.fixture.DefaultFixtureContextManagerBuilder;
+import
org.apache.shardingsphere.mode.manager.fixture.FixtureContextManagerBuilder;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.junit.MockitoJUnitRunner;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+@RunWith(MockitoJUnitRunner.class)
+public final class ContextManagerBuilderFactoryTest {
+
+ @Test
+ public void assertNewInstanceWithConfiguration() {
+ ModeConfiguration config = mock(ModeConfiguration.class);
+ when(config.getType()).thenReturn("fixture");
+ ContextManagerBuilder contextManagerBuilder =
ContextManagerBuilderFactory.newInstance(config);
+ assertThat(contextManagerBuilder,
instanceOf(FixtureContextManagerBuilder.class));
+ }
+
+ @Test
+ public void assertNewInstanceWithoutConfiguration() {
+ ContextManagerBuilder contextManagerBuilder =
ContextManagerBuilderFactory.newInstance(null);
+ assertThat(contextManagerBuilder,
instanceOf(DefaultFixtureContextManagerBuilder.class));
+ }
+}
diff --git
a/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/fixture/DefaultFixtureContextManagerBuilder.java
b/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/fixture/DefaultFixtureContextManagerBuilder.java
new file mode 100644
index 0000000..11e515b
--- /dev/null
+++
b/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/fixture/DefaultFixtureContextManagerBuilder.java
@@ -0,0 +1,47 @@
+/*
+ * 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.mode.manager.fixture;
+
+import java.sql.SQLException;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Properties;
+import javax.sql.DataSource;
+import org.apache.shardingsphere.infra.config.RuleConfiguration;
+import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
+import org.apache.shardingsphere.mode.manager.ContextManager;
+import org.apache.shardingsphere.mode.manager.ContextManagerBuilder;
+
+public final class DefaultFixtureContextManagerBuilder implements
ContextManagerBuilder {
+
+ @Override
+ public ContextManager build(final ModeConfiguration modeConfig, final
Map<String, Map<String, DataSource>> dataSourcesMap, final Map<String,
Collection<RuleConfiguration>> schemaRuleConfigs,
+ final Collection<RuleConfiguration>
globalRuleConfigs, final Properties props, final boolean isOverwrite) throws
SQLException {
+ return null;
+ }
+
+ @Override
+ public String getType() {
+ return "DefaultFixture";
+ }
+
+ @Override
+ public boolean isDefault() {
+ return true;
+ }
+}
diff --git
a/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/fixture/FixtureContextManagerBuilder.java
b/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/fixture/FixtureContextManagerBuilder.java
new file mode 100644
index 0000000..2e1122b
--- /dev/null
+++
b/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/fixture/FixtureContextManagerBuilder.java
@@ -0,0 +1,42 @@
+/*
+ * 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.mode.manager.fixture;
+
+import java.sql.SQLException;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Properties;
+import javax.sql.DataSource;
+import org.apache.shardingsphere.infra.config.RuleConfiguration;
+import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
+import org.apache.shardingsphere.mode.manager.ContextManager;
+import org.apache.shardingsphere.mode.manager.ContextManagerBuilder;
+
+public final class FixtureContextManagerBuilder implements
ContextManagerBuilder {
+
+ @Override
+ public ContextManager build(final ModeConfiguration modeConfig, final
Map<String, Map<String, DataSource>> dataSourcesMap, final Map<String,
Collection<RuleConfiguration>> schemaRuleConfigs,
+ final Collection<RuleConfiguration>
globalRuleConfigs, final Properties props, final boolean isOverwrite) throws
SQLException {
+ return null;
+ }
+
+ @Override
+ public String getType() {
+ return "fixture";
+ }
+}
diff --git
a/shardingsphere-mode/shardingsphere-mode-core/src/test/resources/META-INF/services/org.apache.shardingsphere.mode.manager.ContextManagerBuilder
b/shardingsphere-mode/shardingsphere-mode-core/src/test/resources/META-INF/services/org.apache.shardingsphere.mode.manager.ContextManagerBuilder
new file mode 100644
index 0000000..47a3b12
--- /dev/null
+++
b/shardingsphere-mode/shardingsphere-mode-core/src/test/resources/META-INF/services/org.apache.shardingsphere.mode.manager.ContextManagerBuilder
@@ -0,0 +1,19 @@
+#
+# 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.mode.manager.fixture.FixtureContextManagerBuilder
+org.apache.shardingsphere.mode.manager.fixture.DefaultFixtureContextManagerBuilder