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 acb410d6ac0 Add UT for ShardingSphereDatabasesFactory . (#18895)
acb410d6ac0 is described below
commit acb410d6ac06058c1e224d87953755651b709054
Author: VOPEN.XYZ <[email protected]>
AuthorDate: Thu Jul 7 12:07:18 2022 +0800
Add UT for ShardingSphereDatabasesFactory . (#18895)
* Add UT for ShardingSphereDatabasesFactory .
* Using assertThat instead of assertEquals .
---
.../metadata/database/ShardingSphereDatabasesFactoryTest.java | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/database/ShardingSphereDatabasesFactoryTest.java
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/database/ShardingSphereDatabasesFactoryTest.java
index 3c334780c79..1fca5bc915a 100644
---
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/database/ShardingSphereDatabasesFactoryTest.java
+++
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/database/ShardingSphereDatabasesFactoryTest.java
@@ -50,4 +50,13 @@ public final class ShardingSphereDatabasesFactoryTest {
assertThat(rules.iterator().next(),
instanceOf(FixtureDatabaseRule.class));
assertTrue(actual.get("foo_db").getResource().getDataSources().isEmpty());
}
+
+ @Test
+ public void assertCreateSingleDatabase() throws SQLException {
+ DatabaseConfiguration databaseConfig = new
DataSourceProvidedDatabaseConfiguration(Collections.emptyMap(),
Collections.singleton(new FixtureRuleConfiguration()));
+ ShardingSphereDatabase actual =
ShardingSphereDatabasesFactory.create("foo_db", databaseConfig, new
ConfigurationProperties(new Properties()), mock(InstanceContext.class));
+ assertThat(actual.getName(), is("foo_db"));
+ assertThat(actual.getRuleMetaData().getRules().iterator().next(),
instanceOf(FixtureDatabaseRule.class));
+ assertTrue(actual.getResource().getDataSources().isEmpty());
+ }
}