This is an automated email from the ASF dual-hosted git repository. zhonghongsheng 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 30e590ea9e7 Revise #17910 (#18026) 30e590ea9e7 is described below commit 30e590ea9e7b65643a60be0fbdd240acc8627d99 Author: Liang Zhang <zhangli...@apache.org> AuthorDate: Sat May 28 16:20:53 2022 +0800 Revise #17910 (#18026) --- .../shardingsphere-data-pipeline-api/pom.xml | 1 + ...java => DialectDDLSQLGeneratorFactoryTest.java} | 18 +++++------------- ...e.java => DDLGeneratorDatabaseTypeFixture.java} | 22 ++++++++++++---------- .../spi/fixture/DialectDDLGeneratorFixture.java | 12 +++++------- ...shardingsphere.infra.database.type.DatabaseType | 2 +- 5 files changed, 24 insertions(+), 31 deletions(-) diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/pom.xml b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/pom.xml index d6bd90ec6a8..20bfa3933bd 100644 --- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/pom.xml +++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/pom.xml @@ -33,6 +33,7 @@ <artifactId>shardingsphere-infra-common</artifactId> <version>${project.version}</version> </dependency> + <dependency> <groupId>org.apache.shardingsphere</groupId> <artifactId>shardingsphere-test-common</artifactId> diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/java/org/apache/shardingsphere/data/pipeline/spi/ddlgenerator/DialectDDLGeneratorFactoryTest.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/java/org/apache/shardingsphere/data/pipeline/spi/ddlgenerator/DialectDDLSQLGeneratorFactoryTest.java similarity index 56% rename from shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/java/org/apache/shardingsphere/data/pipeline/spi/ddlgenerator/DialectDDLGeneratorFactoryTest.java rename to shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/java/org/apache/shardingsphere/data/pipeline/spi/ddlgenerator/DialectDDLSQLGeneratorFactoryTest.java index 30ed017061e..8602785da6d 100644 --- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/java/org/apache/shardingsphere/data/pipeline/spi/ddlgenerator/DialectDDLGeneratorFactoryTest.java +++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/java/org/apache/shardingsphere/data/pipeline/spi/ddlgenerator/DialectDDLSQLGeneratorFactoryTest.java @@ -17,23 +17,15 @@ package org.apache.shardingsphere.data.pipeline.spi.ddlgenerator; -import java.sql.SQLException; -import org.apache.shardingsphere.infra.database.type.DatabaseType; import org.apache.shardingsphere.infra.database.type.DatabaseTypeFactory; -import org.apache.shardingsphere.test.mock.MockedDataSource; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; import org.junit.Test; -public final class DialectDDLGeneratorFactoryTest { +import static org.junit.Assert.assertTrue; +public final class DialectDDLSQLGeneratorFactoryTest { + @Test - public void assertFindInstanceWithDialectDDLGenerator() throws SQLException { - String databaseType = "FIXTURE"; - DatabaseType type = DatabaseTypeFactory.getInstance(databaseType); - assertTrue(DialectDDLSQLGeneratorFactory.findInstance(type).isPresent()); - DialectDDLGenerator dialectDDLGenerator = DialectDDLSQLGeneratorFactory.findInstance(type).get(); - assertThat(dialectDDLGenerator.generateDDLSQL("tableA", "", new MockedDataSource()), is("SHOW CREATE TABLE tableA")); + public void assertFindInstance() { + assertTrue(DialectDDLSQLGeneratorFactory.findInstance(DatabaseTypeFactory.getInstance("DDL.GENERATOR.FIXTURE")).isPresent()); } } diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/java/org/apache/shardingsphere/data/pipeline/spi/fixture/DatabaseTypeFixture.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/java/org/apache/shardingsphere/data/pipeline/spi/fixture/DDLGeneratorDatabaseTypeFixture.java similarity index 91% rename from shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/java/org/apache/shardingsphere/data/pipeline/spi/fixture/DatabaseTypeFixture.java rename to shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/java/org/apache/shardingsphere/data/pipeline/spi/fixture/DDLGeneratorDatabaseTypeFixture.java index b37eae06a94..546523425fe 100644 --- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/java/org/apache/shardingsphere/data/pipeline/spi/fixture/DatabaseTypeFixture.java +++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/java/org/apache/shardingsphere/data/pipeline/spi/fixture/DDLGeneratorDatabaseTypeFixture.java @@ -17,21 +17,18 @@ package org.apache.shardingsphere.data.pipeline.spi.fixture; +import org.apache.shardingsphere.infra.database.metadata.DataSourceMetaData; +import org.apache.shardingsphere.infra.database.type.DatabaseType; +import org.apache.shardingsphere.sql.parser.sql.common.constant.QuoteCharacter; + import java.util.Collection; import java.util.Collections; import java.util.Map; import java.util.Optional; -import org.apache.shardingsphere.infra.database.metadata.DataSourceMetaData; -import org.apache.shardingsphere.infra.database.type.DatabaseType; -import org.apache.shardingsphere.sql.parser.sql.common.constant.QuoteCharacter; + import static org.mockito.Mockito.mock; -public final class DatabaseTypeFixture implements DatabaseType { - - @Override - public String getType() { - return "FIXTURE"; - } +public final class DDLGeneratorDatabaseTypeFixture implements DatabaseType { @Override public QuoteCharacter getQuoteCharacter() { @@ -40,7 +37,7 @@ public final class DatabaseTypeFixture implements DatabaseType { @Override public Collection<String> getJdbcUrlPrefixes() { - return Collections.singleton("jdbc:fixture"); + return Collections.singleton("jdbc:ddl.generator.fixture"); } @Override @@ -62,4 +59,9 @@ public final class DatabaseTypeFixture implements DatabaseType { public Collection<String> getSystemSchemas() { return Collections.emptyList(); } + + @Override + public String getType() { + return "DDL.GENERATOR.FIXTURE"; + } } diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/java/org/apache/shardingsphere/data/pipeline/spi/fixture/DialectDDLGeneratorFixture.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/java/org/apache/shardingsphere/data/pipeline/spi/fixture/DialectDDLGeneratorFixture.java index acc1607e22f..308658aa8ee 100644 --- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/java/org/apache/shardingsphere/data/pipeline/spi/fixture/DialectDDLGeneratorFixture.java +++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/java/org/apache/shardingsphere/data/pipeline/spi/fixture/DialectDDLGeneratorFixture.java @@ -17,21 +17,19 @@ package org.apache.shardingsphere.data.pipeline.spi.fixture; -import java.sql.SQLException; -import javax.sql.DataSource; import org.apache.shardingsphere.data.pipeline.spi.ddlgenerator.DialectDDLGenerator; +import javax.sql.DataSource; + public final class DialectDDLGeneratorFixture implements DialectDDLGenerator { - private static final String SHOW_CREATE_SQL = "SHOW CREATE TABLE %s"; - @Override - public String generateDDLSQL(final String tableName, final String schemaName, final DataSource dataSource) throws SQLException { - return String.format(SHOW_CREATE_SQL, tableName); + public String generateDDLSQL(final String tableName, final String schemaName, final DataSource dataSource) { + return ""; } @Override public String getType() { - return "FIXTURE"; + return "DDL.GENERATOR.FIXTURE"; } } diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.database.type.DatabaseType b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.database.type.DatabaseType index 87ea61e5839..eb024c680eb 100644 --- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.database.type.DatabaseType +++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.database.type.DatabaseType @@ -15,4 +15,4 @@ # limitations under the License. # -org.apache.shardingsphere.data.pipeline.spi.fixture.DatabaseTypeFixture +org.apache.shardingsphere.data.pipeline.spi.fixture.DDLGeneratorDatabaseTypeFixture