This is an automated email from the ASF dual-hosted git repository.
panjuan 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 a3e392d Refactor Revise (#6932)
a3e392d is described below
commit a3e392d825038af1339854a6efcd725db17f1c02
Author: Liang Zhang <[email protected]>
AuthorDate: Wed Aug 19 17:05:53 2020 +0800
Refactor Revise (#6932)
* Refactor SpringBootStarterTest
* Refactor SpringBootJNDIDataSourceTest
* Remove useless raw test
* fix test case
---
.../boot/MasterSlaveSpringBootStarterTest.java | 4 +-
.../spring/boot/SpringBootConfiguration.java | 2 +-
...Test.java => SpringBootJNDIDataSourceTest.java} | 38 +++---
.../spring/boot/SpringBootStarterTest.java | 95 +++++++++++++++
.../spring/boot/fixture/TestEncryptAlgorithm.java | 50 --------
.../spring/boot/type/SpringBootEncryptTest.java | 66 ----------
.../spring/boot/type/SpringBootJNDITest.java | 91 --------------
.../boot/type/SpringBootMasterSlaveTest.java | 66 ----------
.../boot/type/SpringBootRawDataSourceTest.java | 45 -------
.../spring/boot/type/SpringBootShardingTest.java | 133 ---------------------
...che.shardingsphere.encrypt.spi.EncryptAlgorithm | 18 ---
.../test/resources/application-common.properties | 48 ++++++++
.../test/resources/application-encrypt.properties | 31 -----
.../resources/application-masterslave.properties | 31 -----
.../src/test/resources/application-raw.properties | 20 ----
.../test/resources/application-shadow.properties | 27 -----
.../test/resources/application-sharding.properties | 60 ----------
.../binder/metadata/table/TableMetaDataLoader.java | 6 +-
18 files changed, 169 insertions(+), 662 deletions(-)
diff --git
a/shardingsphere-features/shardingsphere-master-slave/shardingsphere-master-slave-spring/shardingsphere-master-slave-spring-boot-starter/src/test/java/org/apache/shardingsphere/masterslave/spring/boot/MasterSlaveSpringBootStarterTest.java
b/shardingsphere-features/shardingsphere-master-slave/shardingsphere-master-slave-spring/shardingsphere-master-slave-spring-boot-starter/src/test/java/org/apache/shardingsphere/masterslave/spring/boot/MasterSlaveSpringBootStarterTest.java
index 59e8f08..64634cb 100644
---
a/shardingsphere-features/shardingsphere-master-slave/shardingsphere-master-slave-spring/shardingsphere-master-slave-spring-boot-starter/src/test/java/org/apache/shardingsphere/masterslave/spring/boot/MasterSlaveSpringBootStarterTest.java
+++
b/shardingsphere-features/shardingsphere-master-slave/shardingsphere-master-slave-spring/shardingsphere-master-slave-spring-boot-starter/src/test/java/org/apache/shardingsphere/masterslave/spring/boot/MasterSlaveSpringBootStarterTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.masterslave.spring.boot;
import
org.apache.shardingsphere.masterslave.algorithm.RandomMasterSlaveLoadBalanceAlgorithm;
-import
org.apache.shardingsphere.masterslave.api.config.MasterSlaveRuleConfiguration;
+import
org.apache.shardingsphere.masterslave.algorithm.config.AlgorithmProvidedMasterSlaveRuleConfiguration;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -40,7 +40,7 @@ public class MasterSlaveSpringBootStarterTest {
private RandomMasterSlaveLoadBalanceAlgorithm random;
@Resource
- private MasterSlaveRuleConfiguration masterSlaveRuleConfiguration;
+ private AlgorithmProvidedMasterSlaveRuleConfiguration
masterSlaveRuleConfiguration;
@Test
public void assertLoadBalanceAlgorithm() {
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/main/java/org/apache/shardingsphere/spring/boot/SpringBootConfiguration.java
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/main/java/org/apache/shardingsphere/spring/boot/SpringBootConfiguration.java
index 98e2378..73a2514 100644
---
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/main/java/org/apache/shardingsphere/spring/boot/SpringBootConfiguration.java
+++
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/main/java/org/apache/shardingsphere/spring/boot/SpringBootConfiguration.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.spring.boot;
-import java.util.List;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.driver.api.ShardingSphereDataSourceFactory;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
@@ -41,6 +40,7 @@ import java.sql.SQLException;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
import java.util.Optional;
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/type/SpringBootShadowTest.java
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/SpringBootJNDIDataSourceTest.java
similarity index 58%
rename from
shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/type/SpringBootShadowTest.java
rename to
shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/SpringBootJNDIDataSourceTest.java
index 90b4357..11e3356 100644
---
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/type/SpringBootShadowTest.java
+++
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/SpringBootJNDIDataSourceTest.java
@@ -15,11 +15,12 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.spring.boot.type;
+package org.apache.shardingsphere.spring.boot;
import
org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource;
-import
org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
-import org.apache.shardingsphere.shadow.rule.ShadowRule;
+import
org.apache.shardingsphere.spring.boot.fixture.TestJndiInitialContextFactory;
+import org.apache.shardingsphere.test.MockedDataSource;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -28,34 +29,35 @@ import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import javax.annotation.Resource;
+import javax.naming.Context;
import javax.sql.DataSource;
+import java.util.Map;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
@RunWith(SpringJUnit4ClassRunner.class)
-@SpringBootTest(classes = SpringBootShadowTest.class)
+@SpringBootTest(classes = SpringBootJNDIDataSourceTest.class)
@SpringBootApplication
-@ActiveProfiles("shadow")
-public class SpringBootShadowTest {
+@ActiveProfiles("jndi")
+public class SpringBootJNDIDataSourceTest {
@Resource
- private DataSource dataSource;
+ private ShardingSphereDataSource dataSource;
- @Test
- public void assertSqlShow() {
- assertTrue(((ShardingSphereDataSource)
dataSource).getSchemaContexts().getProps().<Boolean>getValue(ConfigurationPropertyKey.SQL_SHOW));
+ @BeforeClass
+ public static void setUp() {
+ System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
TestJndiInitialContextFactory.class.getName());
+ TestJndiInitialContextFactory.bind("java:comp/env/jdbc/jndi0", new
MockedDataSource());
+ TestJndiInitialContextFactory.bind("java:comp/env/jdbc/jndi1", new
MockedDataSource());
}
@Test
- public void assertDataSource() {
- assertTrue(dataSource instanceof ShardingSphereDataSource);
- assertShadowRule();
- }
-
- private void assertShadowRule() {
- ShadowRule shadowRule = (ShadowRule) ((ShardingSphereDataSource)
dataSource).getSchemaContexts().getDefaultSchemaContext().getSchema().getRules().iterator().next();
- assertThat(shadowRule.getColumn(), is("is_shadow"));
+ public void assertDatasourceMap() {
+ Map<String, DataSource> dataSourceMap = dataSource.getDataSourceMap();
+ assertThat(dataSourceMap.size(), is(2));
+ assertTrue(dataSourceMap.containsKey("jndi0"));
+ assertTrue(dataSourceMap.containsKey("jndi1"));
}
}
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/SpringBootStarterTest.java
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/SpringBootStarterTest.java
new file mode 100644
index 0000000..407a000
--- /dev/null
+++
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/SpringBootStarterTest.java
@@ -0,0 +1,95 @@
+/*
+ * 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.spring.boot;
+
+import
org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource;
+import org.apache.shardingsphere.encrypt.rule.EncryptRule;
+import
org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+import org.apache.shardingsphere.masterslave.rule.MasterSlaveRule;
+import org.apache.shardingsphere.shadow.rule.ShadowRule;
+import org.apache.shardingsphere.sharding.rule.ShardingRule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import javax.annotation.Resource;
+import java.util.Collection;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@SpringBootTest(classes = SpringBootStarterTest.class)
+@SpringBootApplication
+@ActiveProfiles("common")
+public class SpringBootStarterTest {
+
+ @Resource
+ private ShardingSphereDataSource dataSource;
+
+ @Test
+ public void assertDataSourceMap() {
+ assertThat(dataSource.getDataSourceMap().size(), is(2));
+ assertTrue(dataSource.getDataSourceMap().containsKey("ds_0"));
+ assertTrue(dataSource.getDataSourceMap().containsKey("ds_1"));
+ }
+
+ @Test
+ public void assertRules() {
+ Collection<ShardingSphereRule> rules =
dataSource.getSchemaContexts().getDefaultSchemaContext().getSchema().getRules();
+ assertThat(rules.size(), is(2));
+ for (ShardingSphereRule each : rules) {
+ if (each instanceof ShardingRule) {
+ assertShardingRule((ShardingRule) each);
+ } else if (each instanceof MasterSlaveRule) {
+ assertMasterSlaveRule((MasterSlaveRule) each);
+ } else if (each instanceof EncryptRule) {
+ assertEncryptRule((EncryptRule) each);
+ } else if (each instanceof ShadowRule) {
+ assertShadowRule((ShadowRule) each);
+ }
+ }
+ }
+
+ private void assertShardingRule(final ShardingRule rule) {
+ // TODO
+ }
+
+ private void assertMasterSlaveRule(final MasterSlaveRule rule) {
+ // TODO
+ }
+
+ private void assertEncryptRule(final EncryptRule rule) {
+ // TODO
+ }
+
+ private void assertShadowRule(final ShadowRule rule) {
+ // TODO
+ }
+
+ @Test
+ public void assertProperties() {
+
assertTrue(dataSource.getSchemaContexts().getProps().<Boolean>getValue(ConfigurationPropertyKey.SQL_SHOW));
+
assertThat(dataSource.getSchemaContexts().getProps().getValue(ConfigurationPropertyKey.EXECUTOR_SIZE),
is(10));
+ }
+}
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/fixture/TestEncryptAlgorithm.java
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/fixture/TestEncryptAlgorithm.java
deleted file mode 100644
index 79d9f85..0000000
---
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/fixture/TestEncryptAlgorithm.java
+++ /dev/null
@@ -1,50 +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.
- */
-
-package org.apache.shardingsphere.spring.boot.fixture;
-
-import lombok.Getter;
-import lombok.Setter;
-import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
-
-import java.util.Properties;
-
-@Getter
-@Setter
-public final class TestEncryptAlgorithm implements EncryptAlgorithm {
-
- private Properties props = new Properties();
-
- @Override
- public void init() {
- }
-
- @Override
- public String encrypt(final Object plaintext) {
- return "";
- }
-
- @Override
- public Object decrypt(final String ciphertext) {
- return "";
- }
-
- @Override
- public String getType() {
- return "test";
- }
-}
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/type/SpringBootEncryptTest.java
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/type/SpringBootEncryptTest.java
deleted file mode 100644
index d3b052c..0000000
---
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/type/SpringBootEncryptTest.java
+++ /dev/null
@@ -1,66 +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.
- */
-
-package org.apache.shardingsphere.spring.boot.type;
-
-import
org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource;
-import org.apache.shardingsphere.encrypt.rule.EncryptRule;
-import
org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-import javax.annotation.Resource;
-import javax.sql.DataSource;
-import java.util.Optional;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@SpringBootTest(classes = SpringBootEncryptTest.class)
-@SpringBootApplication
-@ActiveProfiles("encrypt")
-public class SpringBootEncryptTest {
-
- @Resource
- private DataSource dataSource;
-
- @Test
- public void assertSqlShow() {
- assertTrue(((ShardingSphereDataSource)
dataSource).getSchemaContexts().getProps().<Boolean>getValue(ConfigurationPropertyKey.SQL_SHOW));
- }
-
- @Test
- public void assertWithEncryptDataSource() {
- assertTrue(dataSource instanceof ShardingSphereDataSource);
- assertThat(((ShardingSphereDataSource)
dataSource).getDataSourceMap().size(), is(1));
- }
-
- @Test
- public void assertWithEncryptRule() {
- EncryptRule encryptRule = (EncryptRule) ((ShardingSphereDataSource)
dataSource).getSchemaContexts().getDefaultSchemaContext().getSchema().getRules().iterator().next();
- assertThat(encryptRule.getEncryptTableNames().size(), is(1));
- assertTrue(encryptRule.findEncryptor("t_order",
"user_id").isPresent());
- assertThat(encryptRule.getCipherColumn("t_order", "user_id"),
is("user_encrypt"));
- assertThat(encryptRule.findPlainColumn("t_order", "user_id"),
is(Optional.of("user_decrypt")));
- }
-}
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/type/SpringBootJNDITest.java
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/type/SpringBootJNDITest.java
deleted file mode 100644
index 814b3e0..0000000
---
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/type/SpringBootJNDITest.java
+++ /dev/null
@@ -1,91 +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.
- */
-
-package org.apache.shardingsphere.spring.boot.type;
-
-import org.apache.commons.dbcp2.BasicDataSource;
-import
org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource;
-import
org.apache.shardingsphere.spring.boot.fixture.TestJndiInitialContextFactory;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-import javax.annotation.Resource;
-import javax.naming.Context;
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.util.Map;
-
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@SpringBootTest(classes = SpringBootJNDITest.class)
-@SpringBootApplication
-@ActiveProfiles("jndi")
-public class SpringBootJNDITest {
-
- private static final String TEST_DATA_SOURCE_URL =
"jdbc:h2:mem:%s;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL";
-
- private static final String JNDI_DATA_SOURCE_0 =
"java:comp/env/jdbc/jndi0";
-
- private static final String JNDI_DATA_SOURCE_1 =
"java:comp/env/jdbc/jndi1";
-
- @Resource
- private DataSource dataSource;
-
- @BeforeClass
- public static void setUpBeforeClass() {
- System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
TestJndiInitialContextFactory.class.getName());
- TestJndiInitialContextFactory.bind(JNDI_DATA_SOURCE_0,
createNewDataSource("jndi0"));
- TestJndiInitialContextFactory.bind(JNDI_DATA_SOURCE_1,
createNewDataSource("jndi1"));
- }
-
- private static DataSource createNewDataSource(final String dsName) {
- BasicDataSource result = new BasicDataSource();
- result.setUrl(String.format(TEST_DATA_SOURCE_URL, dsName));
- result.setUsername("sa");
- result.setPassword("");
- result.setDriverClassName("org.h2.Driver");
- return result;
- }
-
- @Test
- public void assertJndiDatasource() throws SQLException {
- assertThat(dataSource, instanceOf(ShardingSphereDataSource.class));
- Map<String, DataSource> dataSourceMap = ((ShardingSphereDataSource)
dataSource).getDataSourceMap();
- assertThat(dataSourceMap.size(), is(2));
- assertTrue(dataSourceMap.containsKey("jndi0"));
- assertTrue(dataSourceMap.containsKey("jndi1"));
- assertDatasource(dataSourceMap.get("jndi0"),
String.format(TEST_DATA_SOURCE_URL, "jndi0"));
- assertDatasource(dataSourceMap.get("jndi1"),
String.format(TEST_DATA_SOURCE_URL, "jndi1"));
- }
-
- private void assertDatasource(final DataSource actualDatasource, final
String expectedJDBCUrl) throws SQLException {
- String expected = expectedJDBCUrl.substring(0,
expectedJDBCUrl.indexOf(';'));
- try (Connection connection = actualDatasource.getConnection()) {
- assertThat(connection.getMetaData().getURL(), is(expected));
- }
- }
-}
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/type/SpringBootMasterSlaveTest.java
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/type/SpringBootMasterSlaveTest.java
deleted file mode 100644
index 3fe2756..0000000
---
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/type/SpringBootMasterSlaveTest.java
+++ /dev/null
@@ -1,66 +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.
- */
-
-package org.apache.shardingsphere.spring.boot.type;
-
-import
org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource;
-import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
-import org.apache.shardingsphere.masterslave.rule.MasterSlaveDataSourceRule;
-import org.apache.shardingsphere.masterslave.rule.MasterSlaveRule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-import javax.annotation.Resource;
-import javax.sql.DataSource;
-import java.util.Collection;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@SpringBootTest(classes = SpringBootMasterSlaveTest.class)
-@SpringBootApplication
-@ActiveProfiles("masterslave")
-public class SpringBootMasterSlaveTest {
-
- @Resource
- private DataSource dataSource;
-
- @Test
- public void assertDataSource() {
- assertTrue(dataSource instanceof ShardingSphereDataSource);
- assertThat(((ShardingSphereDataSource)
dataSource).getDataSourceMap().size(), is(3));
- Collection<ShardingSphereRule> rules = ((ShardingSphereDataSource)
dataSource).getSchemaContexts().getDefaultSchemaContext().getSchema().getRules();
- assertThat(rules.size(), is(1));
- assertMasterSlaveRule((MasterSlaveRule) rules.iterator().next());
- }
-
- private void assertMasterSlaveRule(final MasterSlaveRule rule) {
- MasterSlaveDataSourceRule dataSourceRule =
rule.getSingleDataSourceRule();
- assertThat(dataSourceRule.getName(), is("ds_ms"));
- assertThat(dataSourceRule.getMasterDataSourceName(), is("ds_master"));
- assertThat(dataSourceRule.getSlaveDataSourceNames().size(), is(2));
- assertThat(dataSourceRule.getSlaveDataSourceNames().get(0),
is("ds_slave_0"));
- assertThat(dataSourceRule.getSlaveDataSourceNames().get(1),
is("ds_slave_1"));
- assertThat(dataSourceRule.getLoadBalancer().getType(), is("RANDOM"));
- }
-}
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/type/SpringBootRawDataSourceTest.java
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/type/SpringBootRawDataSourceTest.java
deleted file mode 100644
index 03da236..0000000
---
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/type/SpringBootRawDataSourceTest.java
+++ /dev/null
@@ -1,45 +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.
- */
-
-package org.apache.shardingsphere.spring.boot.type;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.NoSuchBeanDefinitionException;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.context.ApplicationContext;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-import javax.annotation.Resource;
-import javax.sql.DataSource;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@SpringBootTest(classes = SpringBootRawDataSourceTest.class)
-@ActiveProfiles("raw")
-@SpringBootApplication
-public class SpringBootRawDataSourceTest {
-
- @Resource
- private ApplicationContext context;
-
- @Test(expected = NoSuchBeanDefinitionException.class)
- public void assertDataSource() {
- context.getBean(DataSource.class);
- }
-}
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/type/SpringBootShardingTest.java
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/type/SpringBootShardingTest.java
deleted file mode 100644
index 2994c3f..0000000
---
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/type/SpringBootShardingTest.java
+++ /dev/null
@@ -1,133 +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.
- */
-
-package org.apache.shardingsphere.spring.boot.type;
-
-import
org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource;
-import
org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
-import org.apache.shardingsphere.infra.datanode.DataNode;
-import org.apache.shardingsphere.kernel.context.SchemaContexts;
-import org.apache.shardingsphere.sharding.rule.ShardingRule;
-import org.apache.shardingsphere.sharding.rule.TableRule;
-import
org.apache.shardingsphere.sharding.strategy.standard.StandardShardingStrategy;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-import javax.annotation.Resource;
-import javax.sql.DataSource;
-
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@SpringBootTest(classes = SpringBootShardingTest.class)
-@SpringBootApplication
-@ActiveProfiles("sharding")
-public class SpringBootShardingTest {
-
- @Resource
- private DataSource dataSource;
-
- @Test
- public void assertWithShardingSphereDataSource() {
- assertThat(dataSource, instanceOf(ShardingSphereDataSource.class));
- SchemaContexts schemaContexts = ((ShardingSphereDataSource)
dataSource).getSchemaContexts();
- assertThat(((ShardingSphereDataSource)
dataSource).getDataSourceMap().size(), is(3));
-
assertTrue(schemaContexts.getProps().<Boolean>getValue(ConfigurationPropertyKey.SQL_SHOW));
-
assertTrue(schemaContexts.getProps().getValue(ConfigurationPropertyKey.SQL_SHOW));
-
assertThat(schemaContexts.getProps().getValue(ConfigurationPropertyKey.EXECUTOR_SIZE),
is(100));
- }
-
- @Test
- public void assertWithShardingSphereDataSourceNames() {
- SchemaContexts schemaContexts = ((ShardingSphereDataSource)
dataSource).getSchemaContexts();
- ShardingRule shardingRule = (ShardingRule)
schemaContexts.getDefaultSchemaContext().getSchema().getRules().iterator().next();
- assertThat(shardingRule.getDataSourceNames().size(), is(2));
- assertTrue(shardingRule.getDataSourceNames().contains("ds_0"));
- assertTrue(shardingRule.getDataSourceNames().contains("ds_1"));
- }
-
- @Test
- public void assertWithTableRules() {
- SchemaContexts schemaContexts = ((ShardingSphereDataSource)
dataSource).getSchemaContexts();
- ShardingRule shardingRule = (ShardingRule)
schemaContexts.getDefaultSchemaContext().getSchema().getRules().iterator().next();
- assertThat(shardingRule.getTableRules().size(), is(2));
- TableRule tableRule1 = shardingRule.getTableRule("t_order");
- assertThat(tableRule1.getActualDataNodes().size(), is(4));
- assertTrue(tableRule1.getActualDataNodes().contains(new
DataNode("ds_0", "t_order_0")));
- assertTrue(tableRule1.getActualDataNodes().contains(new
DataNode("ds_0", "t_order_1")));
- assertTrue(tableRule1.getActualDataNodes().contains(new
DataNode("ds_1", "t_order_0")));
- assertTrue(tableRule1.getActualDataNodes().contains(new
DataNode("ds_1", "t_order_1")));
- assertThat(tableRule1.getTableShardingStrategy(),
instanceOf(StandardShardingStrategy.class));
-
assertThat(tableRule1.getTableShardingStrategy().getShardingColumns().iterator().next(),
is("order_id"));
- assertTrue(tableRule1.getGenerateKeyColumn().isPresent());
- assertThat(tableRule1.getGenerateKeyColumn().get(), is("order_id"));
- TableRule tableRule2 = shardingRule.getTableRule("t_order_item");
- assertThat(tableRule2.getActualDataNodes().size(), is(4));
- assertTrue(tableRule2.getActualDataNodes().contains(new
DataNode("ds_0", "t_order_item_0")));
- assertTrue(tableRule2.getActualDataNodes().contains(new
DataNode("ds_0", "t_order_item_1")));
- assertTrue(tableRule2.getActualDataNodes().contains(new
DataNode("ds_1", "t_order_item_0")));
- assertTrue(tableRule2.getActualDataNodes().contains(new
DataNode("ds_1", "t_order_item_1")));
- assertThat(tableRule1.getTableShardingStrategy(),
instanceOf(StandardShardingStrategy.class));
-
assertThat(tableRule1.getTableShardingStrategy().getShardingColumns().iterator().next(),
is("order_id"));
- assertTrue(tableRule2.getGenerateKeyColumn().isPresent());
- assertThat(tableRule2.getGenerateKeyColumn().get(),
is("order_item_id"));
- }
-
- @Test
- public void assertWithBindingTableRules() {
- SchemaContexts schemaContexts = ((ShardingSphereDataSource)
dataSource).getSchemaContexts();
- ShardingRule shardingRule = (ShardingRule)
schemaContexts.getDefaultSchemaContext().getSchema().getRules().iterator().next();
- assertThat(shardingRule.getBindingTableRules().size(), is(2));
- TableRule tableRule1 = shardingRule.getTableRule("t_order");
- assertThat(tableRule1.getLogicTable(), is("t_order"));
- assertThat(tableRule1.getActualDataNodes().size(), is(4));
- assertTrue(tableRule1.getActualDataNodes().contains(new
DataNode("ds_0", "t_order_0")));
- assertTrue(tableRule1.getActualDataNodes().contains(new
DataNode("ds_0", "t_order_1")));
- assertTrue(tableRule1.getActualDataNodes().contains(new
DataNode("ds_1", "t_order_0")));
- assertTrue(tableRule1.getActualDataNodes().contains(new
DataNode("ds_1", "t_order_1")));
- assertThat(tableRule1.getTableShardingStrategy(),
instanceOf(StandardShardingStrategy.class));
-
assertThat(tableRule1.getTableShardingStrategy().getShardingColumns().iterator().next(),
is("order_id"));
- assertTrue(tableRule1.getGenerateKeyColumn().isPresent());
- assertThat(tableRule1.getGenerateKeyColumn().get(), is("order_id"));
- TableRule tableRule2 = shardingRule.getTableRule("t_order_item");
- assertThat(tableRule2.getLogicTable(), is("t_order_item"));
- assertThat(tableRule2.getActualDataNodes().size(), is(4));
- assertTrue(tableRule2.getActualDataNodes().contains(new
DataNode("ds_0", "t_order_item_0")));
- assertTrue(tableRule2.getActualDataNodes().contains(new
DataNode("ds_0", "t_order_item_1")));
- assertTrue(tableRule2.getActualDataNodes().contains(new
DataNode("ds_1", "t_order_item_0")));
- assertTrue(tableRule2.getActualDataNodes().contains(new
DataNode("ds_1", "t_order_item_1")));
- assertThat(tableRule1.getTableShardingStrategy(),
instanceOf(StandardShardingStrategy.class));
-
assertThat(tableRule1.getTableShardingStrategy().getShardingColumns().iterator().next(),
is("order_id"));
- assertTrue(tableRule2.getGenerateKeyColumn().isPresent());
- assertThat(tableRule2.getGenerateKeyColumn().get(),
is("order_item_id"));
- }
-
- @Test
- public void assertWithBroadcastTables() {
- SchemaContexts schemaContexts = ((ShardingSphereDataSource)
dataSource).getSchemaContexts();
- ShardingRule shardingRule = (ShardingRule)
schemaContexts.getDefaultSchemaContext().getSchema().getRules().iterator().next();
- assertThat(shardingRule.getBroadcastTables().size(), is(1));
- assertThat(shardingRule.getBroadcastTables().iterator().next(),
is("t_config"));
- }
-}
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm
deleted file mode 100644
index 380a7a4..0000000
---
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm
+++ /dev/null
@@ -1,18 +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.
-#
-
-org.apache.shardingsphere.spring.boot.fixture.TestEncryptAlgorithm
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/resources/application-common.properties
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/resources/application-common.properties
new file mode 100644
index 0000000..b84d543
--- /dev/null
+++
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/resources/application-common.properties
@@ -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.
+#
+
+spring.shardingsphere.datasource.names=ds_${0..1}
+
+spring.shardingsphere.datasource.ds_0.type=org.apache.shardingsphere.test.MockedDataSource
+spring.shardingsphere.datasource.ds_1.type=org.apache.shardingsphere.test.MockedDataSource
+
+# TODO add master-slave config
+
+spring.shardingsphere.rules.sharding.sharding-algorithms.databaseShardingAlgorithm.type=INLINE
+spring.shardingsphere.rules.sharding.sharding-algorithms.databaseShardingAlgorithm.props.algorithm.expression=ds_$->{user_id
% 2}
+
+spring.shardingsphere.rules.sharding.sharding-algorithms.orderTableShardingAlgorithm.type=INLINE
+spring.shardingsphere.rules.sharding.sharding-algorithms.orderTableShardingAlgorithm.props.algorithm.expression=t_order_$->{order_id
% 2}
+
+spring.shardingsphere.rules.sharding.tables.t_order.actual-data-nodes=ds_$->{0..1}.t_order_$->{0..1}
+
+spring.shardingsphere.rules.sharding.tables.t_order.database-strategy.standard.sharding-column=user_id
+spring.shardingsphere.rules.sharding.tables.t_order.database-strategy.standard.sharding-algorithm-name=databaseShardingAlgorithm
+spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.standard.sharding-column=order_id
+spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.standard.sharding-algorithm-name=orderTableShardingAlgorithm
+
+spring.shardingsphere.rules.encrypt.encryptors.aesEncryptor.type=AES
+spring.shardingsphere.rules.encrypt.encryptors.aesEncryptor.props.aes.key.value=123456
+
+spring.shardingsphere.rules.encrypt.tables.t_order.columns.pwd.cipher-column=pwd_cipher
+spring.shardingsphere.rules.encrypt.tables.t_order.columns.pwd.plain-column=pwd_plain
+spring.shardingsphere.rules.encrypt.tables.t_order.columns.pwd.encryptor-name=aesEncryptor
+
+# TODO add shadow config
+
+spring.shardingsphere.props.sql.show=true
+spring.shardingsphere.props.executor.size=10
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/resources/application-encrypt.properties
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/resources/application-encrypt.properties
deleted file mode 100644
index 340c349..0000000
---
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/resources/application-encrypt.properties
+++ /dev/null
@@ -1,31 +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.
-#
-
-spring.shardingsphere.datasource.name=ds
-
-spring.shardingsphere.datasource.ds.type=org.apache.shardingsphere.test.MockedDataSource
-
-spring.shardingsphere.rules.encrypt.tables.t_order.columns.user_id.cipher-column=user_encrypt
-spring.shardingsphere.rules.encrypt.tables.t_order.columns.user_id.assisted-query-column=user_assisted
-spring.shardingsphere.rules.encrypt.tables.t_order.columns.user_id.plain-column=user_decrypt
-spring.shardingsphere.rules.encrypt.tables.t_order.columns.user_id.encryptor-name=aes_encryptor
-
-spring.shardingsphere.rules.encrypt.encryptors.aes_encryptor.type=AES
-spring.shardingsphere.rules.encrypt.encryptors.aes_encryptor.props.aes.key.value=123456
-
-spring.shardingsphere.props.sql.show=true
-spring.shardingsphere.props.query.with.cipher.column=true
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/resources/application-masterslave.properties
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/resources/application-masterslave.properties
deleted file mode 100644
index 142bedf..0000000
---
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/resources/application-masterslave.properties
+++ /dev/null
@@ -1,31 +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.
-#
-
-spring.example.datasource.name=ds_master
-spring.shardingsphere.datasource.names=${spring.example.datasource.name},ds_slave_${0..1}
-
-spring.shardingsphere.datasource.ds_master.type=org.apache.shardingsphere.test.MockedDataSource
-spring.shardingsphere.datasource.ds_slave_0.type=org.apache.shardingsphere.test.MockedDataSource
-spring.shardingsphere.datasource.ds_slave_1.type=org.apache.shardingsphere.test.MockedDataSource
-
-spring.shardingsphere.rules.master-slave.data-sources.ds_ms.master-data-source-name=ds_master
-spring.shardingsphere.rules.master-slave.data-sources.ds_ms.slave-data-source-names=ds_slave_0,ds_slave_1
-spring.shardingsphere.rules.master-slave.data-sources.ds_ms.load-balancer-name=random
-
-spring.shardingsphere.rules.master-slave.load-balancers.random.type=RANDOM
-
-spring.shardingsphere.props.sql.show=true
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/resources/application-raw.properties
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/resources/application-raw.properties
deleted file mode 100644
index 36a8bd3..0000000
---
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/resources/application-raw.properties
+++ /dev/null
@@ -1,20 +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.
-#
-
-spring.application.name=none.sharding.test
-spring.datasource.type=com.zaxxer.hikari.HikariDataSource
-spring.shardingsphere.enabled=false
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/resources/application-shadow.properties
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/resources/application-shadow.properties
deleted file mode 100644
index 894a141..0000000
---
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/resources/application-shadow.properties
+++ /dev/null
@@ -1,27 +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.
-#
-
-spring.shardingsphere.datasource.names=ds,shadow_ds
-
-spring.shardingsphere.datasource.ds.type=org.apache.shardingsphere.test.MockedDataSource
-spring.shardingsphere.datasource.shadow_ds.type=org.apache.shardingsphere.test.MockedDataSource
-
-spring.shardingsphere.rules.shadow.column=is_shadow
-spring.shardingsphere.rules.shadow.shadow-mappings.ds=shadow_ds
-
-spring.shardingsphere.props.sql.show=true
-spring.shardingsphere.props.executor.size=100
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/resources/application-sharding.properties
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/resources/application-sharding.properties
deleted file mode 100644
index e4acfb6..0000000
---
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/resources/application-sharding.properties
+++ /dev/null
@@ -1,60 +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.
-#
-
-spring.shardingsphere.datasource.names=ds,ds_${0..1}
-
-spring.shardingsphere.datasource.ds.type=org.apache.shardingsphere.test.MockedDataSource
-spring.shardingsphere.datasource.ds_0.type=org.apache.shardingsphere.test.MockedDataSource
-spring.shardingsphere.datasource.ds_1.type=org.apache.shardingsphere.test.MockedDataSource
-
-spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-column=user_id
-spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-algorithm-name=database_inline
-spring.shardingsphere.rules.sharding.tables.t_order.actual-data-nodes=ds_${0..1}.t_order_${0..1}
-spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.standard.sharding-column=order_id
-spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.standard.sharding-algorithm-name=t_order_inline
-
-spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.column=order_id
-spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.key-generator-name=snowflake
-
-spring.shardingsphere.rules.sharding.tables.t_order_item.actual-data-nodes=ds_${0..1}.t_order_item_${0..1}
-spring.shardingsphere.rules.sharding.tables.t_order_item.table-strategy.standard.sharding-column=order_id
-spring.shardingsphere.rules.sharding.tables.t_order_item.table-strategy.standard.sharding-algorithm-name=t_order_item_inline
-spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.column=order_item_id
-spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.key-generator-name=snowflake
-spring.shardingsphere.rules.sharding.binding-tables=t_order,t_order_item
-spring.shardingsphere.rules.sharding.broadcast-tables=t_config
-
-spring.shardingsphere.rules.sharding.sharding-algorithms.database_inline.type=INLINE
-spring.shardingsphere.rules.sharding.sharding-algorithms.database_inline.props.algorithm.expression=ds_$->{user_id
% 2}
-spring.shardingsphere.rules.sharding.sharding-algorithms.t_order_inline.type=INLINE
-spring.shardingsphere.rules.sharding.sharding-algorithms.t_order_inline.props.algorithm.expression=t_order_$->{order_id
% 2}
-spring.shardingsphere.rules.sharding.sharding-algorithms.t_order_item_inline.type=INLINE
-spring.shardingsphere.rules.sharding.sharding-algorithms.t_order_item_inline.props.algorithm.expression=t_order_item_$->{order_id
% 2}
-
-spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
-spring.shardingsphere.rules.sharding.key-generators.snowflake.props.worker.id=123
-
-spring.shardingsphere.rules.encrypt.encryptors.order_encrypt.type=test
-spring.shardingsphere.rules.encrypt.encryptors.order_encrypt.props.appToken=business
-spring.shardingsphere.rules.encrypt.tables.t_order.columns.pwd.cipher-column=cipher_pwd
-spring.shardingsphere.rules.encrypt.tables.t_order.columns.pwd.encryptor-name=order_encrypt
-spring.shardingsphere.rules.encrypt.tables.t_order.columns.name.cipher-column=cipher_name
-spring.shardingsphere.rules.encrypt.tables.t_order.columns.name.plain-column=plain_name
-spring.shardingsphere.rules.encrypt.tables.t_order.columns.name.encryptor-name=order_encrypt
-
-spring.shardingsphere.props.sql.show=true
-spring.shardingsphere.props.executor.size=100
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-binder/src/main/java/org/apache/shardingsphere/sql/parser/binder/metadata/table/TableMetaDataLoader.java
b/shardingsphere-sql-parser/shardingsphere-sql-parser-binder/src/main/java/org/apache/shardingsphere/sql/parser/binder/metadata/table/TableMetaDataLoader.java
index b49c292..72db0e6 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-binder/src/main/java/org/apache/shardingsphere/sql/parser/binder/metadata/table/TableMetaDataLoader.java
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-binder/src/main/java/org/apache/shardingsphere/sql/parser/binder/metadata/table/TableMetaDataLoader.java
@@ -17,18 +17,18 @@
package org.apache.shardingsphere.sql.parser.binder.metadata.table;
-import java.sql.ResultSet;
-import java.util.Optional;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.sql.parser.binder.metadata.MetaDataConnection;
import
org.apache.shardingsphere.sql.parser.binder.metadata.column.ColumnMetaDataLoader;
import
org.apache.shardingsphere.sql.parser.binder.metadata.index.IndexMetaDataLoader;
+import org.apache.shardingsphere.sql.parser.binder.metadata.util.JdbcUtil;
import javax.sql.DataSource;
import java.sql.Connection;
+import java.sql.ResultSet;
import java.sql.SQLException;
-import org.apache.shardingsphere.sql.parser.binder.metadata.util.JdbcUtil;
+import java.util.Optional;
/**
* Table meta data loader.