You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2022/10/29 09:21:11 UTC

[shardingsphere] branch master updated: Revise pr 21789 (#21840)

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 8005d948cc5 Revise pr 21789 (#21840)
8005d948cc5 is described below

commit 8005d948cc5d24b12f0681207db74cbf8e1b5f64
Author: Zhengqiang Duan <du...@apache.org>
AuthorDate: Sat Oct 29 17:21:04 2022 +0800

    Revise pr 21789 (#21840)
---
 .../spring/boot/ShardingSphereAutoConfiguration.java        |  2 +-
 .../ShardingSphereSpringBootCondition.java                  |  8 ++++----
 .../ShardingSphereSpringBootConditionTest.java}             | 13 +++++++------
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/jdbc/spring/core/spring-boot-starter/src/main/java/org/apache/shardingsphere/spring/boot/ShardingSphereAutoConfiguration.java b/jdbc/spring/core/spring-boot-starter/src/main/java/org/apache/shardingsphere/spring/boot/ShardingSphereAutoConfiguration.java
index 054260f441b..8fd2c05c4ab 100644
--- a/jdbc/spring/core/spring-boot-starter/src/main/java/org/apache/shardingsphere/spring/boot/ShardingSphereAutoConfiguration.java
+++ b/jdbc/spring/core/spring-boot-starter/src/main/java/org/apache/shardingsphere/spring/boot/ShardingSphereAutoConfiguration.java
@@ -22,9 +22,9 @@ import org.apache.shardingsphere.driver.api.ShardingSphereDataSourceFactory;
 import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
 import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
 import org.apache.shardingsphere.infra.yaml.config.swapper.mode.YamlModeConfigurationSwapper;
+import org.apache.shardingsphere.spring.boot.condition.ShardingSphereSpringBootCondition;
 import org.apache.shardingsphere.spring.boot.datasource.DataSourceMapSetter;
 import org.apache.shardingsphere.spring.boot.prop.SpringBootPropertiesConfiguration;
-import org.apache.shardingsphere.spring.boot.rule.ShardingSphereSpringBootCondition;
 import org.apache.shardingsphere.spring.boot.schema.DatabaseNameSetter;
 import org.apache.shardingsphere.spring.transaction.TransactionTypeScanner;
 import org.springframework.beans.factory.ObjectProvider;
diff --git a/jdbc/spring/core/spring-boot-starter/src/main/java/org/apache/shardingsphere/spring/boot/rule/ShardingSphereSpringBootCondition.java b/jdbc/spring/core/spring-boot-starter/src/main/java/org/apache/shardingsphere/spring/boot/condition/ShardingSphereSpringBootCondition.java
similarity index 87%
rename from jdbc/spring/core/spring-boot-starter/src/main/java/org/apache/shardingsphere/spring/boot/rule/ShardingSphereSpringBootCondition.java
rename to jdbc/spring/core/spring-boot-starter/src/main/java/org/apache/shardingsphere/spring/boot/condition/ShardingSphereSpringBootCondition.java
index 1887e90aec8..c9327e4bed0 100644
--- a/jdbc/spring/core/spring-boot-starter/src/main/java/org/apache/shardingsphere/spring/boot/rule/ShardingSphereSpringBootCondition.java
+++ b/jdbc/spring/core/spring-boot-starter/src/main/java/org/apache/shardingsphere/spring/boot/condition/ShardingSphereSpringBootCondition.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.spring.boot.rule;
+package org.apache.shardingsphere.spring.boot.condition;
 
 import org.apache.shardingsphere.spring.boot.util.PropertyUtil;
 import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
@@ -24,15 +24,15 @@ import org.springframework.context.annotation.ConditionContext;
 import org.springframework.core.type.AnnotatedTypeMetadata;
 
 /**
- * Local configuration condition.
+ * ShardingSphere spring boot condition.
  */
 public final class ShardingSphereSpringBootCondition extends SpringBootCondition {
     
-    private static final String SHARDING_PREFIX = "spring.shardingsphere";
+    private static final String SHARDINGSPHERE_PREFIX = "spring.shardingsphere";
     
     @Override
     public ConditionOutcome getMatchOutcome(final ConditionContext conditionContext, final AnnotatedTypeMetadata annotatedTypeMetadata) {
-        return PropertyUtil.containPropertyPrefix(conditionContext.getEnvironment(), SHARDING_PREFIX)
+        return PropertyUtil.containPropertyPrefix(conditionContext.getEnvironment(), SHARDINGSPHERE_PREFIX)
                 ? ConditionOutcome.match()
                 : ConditionOutcome.noMatch("Can't find ShardingSphere configuration in local file.");
     }
diff --git a/jdbc/spring/core/spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/SpringBootStarterWithoutRulesTest.java b/jdbc/spring/core/spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/condition/ShardingSphereSpringBootConditionTest.java
similarity index 83%
rename from jdbc/spring/core/spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/SpringBootStarterWithoutRulesTest.java
rename to jdbc/spring/core/spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/condition/ShardingSphereSpringBootConditionTest.java
index f9086faae72..1870ea4dda5 100644
--- a/jdbc/spring/core/spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/SpringBootStarterWithoutRulesTest.java
+++ b/jdbc/spring/core/spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/condition/ShardingSphereSpringBootConditionTest.java
@@ -15,30 +15,31 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.spring.boot;
+package org.apache.shardingsphere.spring.boot.condition;
 
 import org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
 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.SpringRunner;
 
+import javax.annotation.Resource;
+
 import static org.junit.Assert.assertNotNull;
 
 @RunWith(SpringRunner.class)
-@SpringBootTest(classes = SpringBootStarterWithoutRulesTest.class)
+@SpringBootTest(classes = ShardingSphereSpringBootConditionTest.class)
 @SpringBootApplication
 @ActiveProfiles("no-rules")
-public class SpringBootStarterWithoutRulesTest {
+public class ShardingSphereSpringBootConditionTest {
     
-    @Autowired
+    @Resource
     private ShardingSphereDataSource dataSource;
     
     @Test
-    public void assertSpringBootStartup() {
+    public void assertCreateDataSourceWhenConfigNoRules() {
         assertNotNull(dataSource);
     }
 }