This is an automated email from the ASF dual-hosted git repository. machen 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 e29bdc8659a Refactor standalone-mode-repository-jdbc module (#19910) e29bdc8659a is described below commit e29bdc8659af0a5fff2732fce8f1f6b5158726b3 Author: Liang Zhang <zhangli...@apache.org> AuthorDate: Fri Aug 5 22:57:00 2022 +0800 Refactor standalone-mode-repository-jdbc module (#19910) * Refactor standalone-mode-repository-jdbc module * Refactor standalone-mode-repository-jdbc module * Refactor standalone-mode-repository-jdbc module * Rename H2JDBCRepositoryTest --- .../context/AbstractPipelineProcessContext.java | 3 ++ .../repository/standalone/jdbc/JDBCRepository.java | 28 +++++++++-------- .../jdbc/{ => props}/JDBCRepositoryProperties.java | 2 +- .../{ => props}/JDBCRepositoryPropertyKey.java | 2 +- .../{ => provider}/JDBCRepositoryProvider.java | 2 +- .../JDBCRepositoryProviderFactory.java | 9 +++--- .../pom.xml | 1 - .../standalone/h2/H2JDBCRepositoryProvider.java | 12 ++++---- ...tandalone.jdbc.provider.JDBCRepositoryProvider} | 0 ...positoryTest.java => H2JDBCRepositoryTest.java} | 35 +++++++++++----------- 10 files changed, 49 insertions(+), 45 deletions(-) diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/context/AbstractPipelineProcessContext.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/context/AbstractPipelineProcessContext.java index aafe6962271..d8dfabf7fb5 100644 --- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/context/AbstractPipelineProcessContext.java +++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/context/AbstractPipelineProcessContext.java @@ -75,18 +75,21 @@ public abstract class AbstractPipelineProcessContext { AlgorithmConfiguration streamChannel = processConfig.getStreamChannel(); pipelineChannelCreator = PipelineChannelCreatorFactory.newInstance(streamChannel); inventoryDumperExecuteEngineLazyInitializer = new LazyInitializer<ExecuteEngine>() { + @Override protected ExecuteEngine initialize() { return ExecuteEngine.newFixedThreadInstance(inputConfig.getWorkerThread(), "Inventory-" + jobId); } }; incrementalDumperExecuteEngineLazyInitializer = new LazyInitializer<ExecuteEngine>() { + @Override protected ExecuteEngine initialize() { return ExecuteEngine.newCachedThreadInstance("Incremental-" + jobId); } }; importerExecuteEngineLazyInitializer = new LazyInitializer<ExecuteEngine>() { + @Override protected ExecuteEngine initialize() { return ExecuteEngine.newFixedThreadInstance(outputConfig.getWorkerThread(), "Importer-" + jobId); diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-core/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/JDBCRepository.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/ [...] index e6e5053b9c0..e603700e5c4 100644 --- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-core/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/JDBCRepository.java +++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-core/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/JDBCRepository.java @@ -21,6 +21,10 @@ import com.google.common.base.Strings; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.apache.shardingsphere.mode.repository.standalone.StandalonePersistRepository; +import org.apache.shardingsphere.mode.repository.standalone.jdbc.props.JDBCRepositoryProperties; +import org.apache.shardingsphere.mode.repository.standalone.jdbc.props.JDBCRepositoryPropertyKey; +import org.apache.shardingsphere.mode.repository.standalone.jdbc.provider.JDBCRepositoryProvider; +import org.apache.shardingsphere.mode.repository.standalone.jdbc.provider.JDBCRepositoryProviderFactory; import java.sql.Connection; import java.sql.DriverManager; @@ -46,24 +50,24 @@ public final class JDBCRepository implements StandalonePersistRepository { private Connection connection; - private JDBCRepositoryProvider jdbcRepositoryProvider; + private JDBCRepositoryProvider provider; @SneakyThrows @Override public void init(final Properties props) { - JDBCRepositoryProperties localRepositoryProps = new JDBCRepositoryProperties(props); - connection = DriverManager.getConnection(localRepositoryProps.getValue(JDBCRepositoryPropertyKey.JDBC_URL), - localRepositoryProps.getValue(JDBCRepositoryPropertyKey.USERNAME), localRepositoryProps.getValue(JDBCRepositoryPropertyKey.PASSWORD)); - jdbcRepositoryProvider = JDBCRepositoryProviderFactory.getInstance(localRepositoryProps.getValue(JDBCRepositoryPropertyKey.PROVIDER)); + JDBCRepositoryProperties jdbcRepositoryProps = new JDBCRepositoryProperties(props); + connection = DriverManager.getConnection(jdbcRepositoryProps.getValue(JDBCRepositoryPropertyKey.JDBC_URL), + jdbcRepositoryProps.getValue(JDBCRepositoryPropertyKey.USERNAME), jdbcRepositoryProps.getValue(JDBCRepositoryPropertyKey.PASSWORD)); + provider = JDBCRepositoryProviderFactory.getInstance(jdbcRepositoryProps.getValue(JDBCRepositoryPropertyKey.PROVIDER)); try (Statement statement = connection.createStatement()) { - statement.execute(jdbcRepositoryProvider.dropTableSQL()); - statement.execute(jdbcRepositoryProvider.createTableSQL()); + statement.execute(provider.dropTableSQL()); + statement.execute(provider.createTableSQL()); } } @Override public String get(final String key) { - try (PreparedStatement preparedStatement = connection.prepareStatement(jdbcRepositoryProvider.selectByKeySQL())) { + try (PreparedStatement preparedStatement = connection.prepareStatement(provider.selectByKeySQL())) { preparedStatement.setString(1, key); try (ResultSet resultSet = preparedStatement.executeQuery()) { if (resultSet.next()) { @@ -78,7 +82,7 @@ public final class JDBCRepository implements StandalonePersistRepository { @Override public List<String> getChildrenKeys(final String key) { - try (PreparedStatement preparedStatement = connection.prepareStatement(jdbcRepositoryProvider.selectByParentKeySQL())) { + try (PreparedStatement preparedStatement = connection.prepareStatement(provider.selectByParentKeySQL())) { preparedStatement.setString(1, key); try (ResultSet resultSet = preparedStatement.executeQuery()) { List<String> resultChildren = new LinkedList<>(); @@ -129,7 +133,7 @@ public final class JDBCRepository implements StandalonePersistRepository { } private void insert(final String key, final String value, final String parent) throws SQLException { - try (PreparedStatement preparedStatement = connection.prepareStatement(jdbcRepositoryProvider.insertSQL())) { + try (PreparedStatement preparedStatement = connection.prepareStatement(provider.insertSQL())) { preparedStatement.setString(1, UUID.randomUUID().toString()); preparedStatement.setString(2, key); preparedStatement.setString(3, value); @@ -139,7 +143,7 @@ public final class JDBCRepository implements StandalonePersistRepository { } private void update(final String key, final String value) throws SQLException { - try (PreparedStatement preparedStatement = connection.prepareStatement(jdbcRepositoryProvider.updateSQL())) { + try (PreparedStatement preparedStatement = connection.prepareStatement(provider.updateSQL())) { preparedStatement.setString(1, value); preparedStatement.setString(2, key); preparedStatement.executeUpdate(); @@ -148,7 +152,7 @@ public final class JDBCRepository implements StandalonePersistRepository { @Override public void delete(final String key) { - try (PreparedStatement preparedStatement = connection.prepareStatement(jdbcRepositoryProvider.deleteSQL())) { + try (PreparedStatement preparedStatement = connection.prepareStatement(provider.deleteSQL())) { preparedStatement.setString(1, key); preparedStatement.executeUpdate(); } catch (final SQLException ex) { diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-core/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/JDBCRepositoryProperties.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-r [...] similarity index 99% rename from shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-core/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/JDBCRepositoryProperties.java rename to shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-core/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/props/JDBCRepositoryProperties.java index 1fb668029b4..577d5070a18 100644 --- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-core/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/JDBCRepositoryProperties.java +++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-core/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/props/JDBCRepositoryProperties.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shardingsphere.mode.repository.standalone.jdbc; +package org.apache.shardingsphere.mode.repository.standalone.jdbc.props; import org.apache.shardingsphere.infra.util.props.TypedProperties; diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-core/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/JDBCRepositoryPropertyKey.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode- [...] similarity index 99% rename from shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-core/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/JDBCRepositoryPropertyKey.java rename to shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-core/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/props/JDBCRepositoryPropertyKey.java index 9efa8469727..7135f7524ab 100644 --- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-core/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/JDBCRepositoryPropertyKey.java +++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-core/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/props/JDBCRepositoryPropertyKey.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shardingsphere.mode.repository.standalone.jdbc; +package org.apache.shardingsphere.mode.repository.standalone.jdbc.props; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-core/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/JDBCRepositoryProvider.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-rep [...] similarity index 99% rename from shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-core/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/JDBCRepositoryProvider.java rename to shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-core/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/provider/JDBCRepositoryProvider.java index 8db4893694b..264bfe2dbad 100644 --- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-core/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/JDBCRepositoryProvider.java +++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-core/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/provider/JDBCRepositoryProvider.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shardingsphere.mode.repository.standalone.jdbc; +package org.apache.shardingsphere.mode.repository.standalone.jdbc.provider; import org.apache.shardingsphere.spi.annotation.SingletonSPI; import org.apache.shardingsphere.spi.type.required.RequiredSPI; diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-core/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/JDBCRepositoryProviderFactory.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-m [...] similarity index 83% rename from shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-core/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/JDBCRepositoryProviderFactory.java rename to shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-core/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/provider/JDBCRepositoryProviderFactory.java index 308e0b6de1b..e7e88bcced0 100644 --- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-core/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/JDBCRepositoryProviderFactory.java +++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-core/src/main/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/provider/JDBCRepositoryProviderFactory.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shardingsphere.mode.repository.standalone.jdbc; +package org.apache.shardingsphere.mode.repository.standalone.jdbc.provider; import lombok.AccessLevel; import lombok.NoArgsConstructor; @@ -36,11 +36,10 @@ public final class JDBCRepositoryProviderFactory { /** * Get instance of JDBC repository provider. * - * @param jdbcRepositoryType JDBC repository type + * @param type JDBC repository type * @return got instance */ - public static JDBCRepositoryProvider getInstance(final Object jdbcRepositoryType) { - return jdbcRepositoryType == null ? RequiredSPIRegistry.getRegisteredService(JDBCRepositoryProvider.class) - : TypedSPIRegistry.getRegisteredService(JDBCRepositoryProvider.class, jdbcRepositoryType.toString()); + public static JDBCRepositoryProvider getInstance(final Object type) { + return null == type ? RequiredSPIRegistry.getRegisteredService(JDBCRepositoryProvider.class) : TypedSPIRegistry.getRegisteredService(JDBCRepositoryProvider.class, type.toString()); } } diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-h2/pom.xml b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repo [...] index eb80e25f8e4..a5dca3de232 100644 --- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-h2/pom.xml +++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-h2/pom.xml @@ -32,7 +32,6 @@ <artifactId>shardingsphere-standalone-mode-repository-api</artifactId> <version>${project.version}</version> </dependency> - <dependency> <groupId>org.apache.shardingsphere</groupId> <artifactId>shardingsphere-standalone-mode-repository-jdbc-core</artifactId> diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-h2/src/main/java/org/apache/shardingsphere/mode/repository/standalone/h2/H2JDBCRepositoryProvider.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repos [...] index 17c8ac9f490..b8c2403f6a0 100644 --- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-h2/src/main/java/org/apache/shardingsphere/mode/repository/standalone/h2/H2JDBCRepositoryProvider.java +++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-h2/src/main/java/org/apache/shardingsphere/mode/repository/standalone/h2/H2JDBCRepositoryProvider.java @@ -17,18 +17,13 @@ package org.apache.shardingsphere.mode.repository.standalone.h2; -import org.apache.shardingsphere.mode.repository.standalone.jdbc.JDBCRepositoryProvider; +import org.apache.shardingsphere.mode.repository.standalone.jdbc.provider.JDBCRepositoryProvider; /** * H2 JDBC repository provider. */ public final class H2JDBCRepositoryProvider implements JDBCRepositoryProvider { - @Override - public String getType() { - return "H2"; - } - @Override public String dropTableSQL() { return "DROP TABLE IF EXISTS `repository`"; @@ -64,6 +59,11 @@ public final class H2JDBCRepositoryProvider implements JDBCRepositoryProvider { return "DELETE FROM `repository` WHERE `key` = ?"; } + @Override + public String getType() { + return "H2"; + } + @Override public boolean isDefault() { return true; diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-h2/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.repository.standalone.jdbc.JDBCRepositoryProvider b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-sta [...] similarity index 100% rename from shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-h2/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.repository.standalone.jdbc.JDBCRepositoryProvider rename to shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-h2/src/main/resources/META-INF/services/org.apache.shardingsphere.mode.repository.standalone.jdbc.provider.JDBCRepositoryProvider diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-h2/src/test/java/org/apache/shardingsphere/mode/repository/standalone/h2/H2RepositoryTest.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/sh [...] similarity index 68% rename from shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-h2/src/test/java/org/apache/shardingsphere/mode/repository/standalone/h2/H2RepositoryTest.java rename to shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-h2/src/test/java/org/apache/shardingsphere/mode/repository/standalone/h2/H2JDBCRepositoryTest.java index 62cea87e893..deef6d58be9 100644 --- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-h2/src/test/java/org/apache/shardingsphere/mode/repository/standalone/h2/H2RepositoryTest.java +++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-jdbc/shardingsphere-standalone-mode-repository-jdbc-h2/src/test/java/org/apache/shardingsphere/mode/repository/standalone/h2/H2JDBCRepositoryTest.java @@ -28,9 +28,9 @@ import java.util.Properties; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; -public final class H2RepositoryTest { +public final class H2JDBCRepositoryTest { - private final JDBCRepository jdbcRepository = new JDBCRepository(); + private final JDBCRepository repository = new JDBCRepository(); @Before public void setUp() { @@ -38,36 +38,35 @@ public final class H2RepositoryTest { props.setProperty("jdbc_url", "jdbc:h2:mem:config;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL"); props.setProperty("username", "sa"); props.setProperty("password", ""); - props.setProperty("driver_class", "org.h2.Driver"); props.setProperty("provider", "H2"); - jdbcRepository.init(props); + repository.init(props); + } + + @After + public void stop() { + repository.close(); } @Test public void assertPersistAndGet() { - jdbcRepository.persist("/testPath/test1", "test1_content"); - assertThat(jdbcRepository.get("/testPath/test1"), is("test1_content")); - jdbcRepository.persist("/testPath/test1", "modify_content"); - assertThat(jdbcRepository.get("/testPath/test1"), is("modify_content")); + repository.persist("/testPath/test1", "test1_content"); + assertThat(repository.get("/testPath/test1"), is("test1_content")); + repository.persist("/testPath/test1", "modify_content"); + assertThat(repository.get("/testPath/test1"), is("modify_content")); } @Test public void assertPersistAndGetChildrenKeys() { - jdbcRepository.persist("/testPath/test1", "test1_content"); - jdbcRepository.persist("/testPath/test2", "test2_content"); - List<String> childrenKeys = jdbcRepository.getChildrenKeys("/testPath"); + repository.persist("/testPath/test1", "test1_content"); + repository.persist("/testPath/test2", "test2_content"); + List<String> childrenKeys = repository.getChildrenKeys("/testPath"); assertThat(childrenKeys.get(0), is("test1")); assertThat(childrenKeys.get(1), is("test2")); } @Test public void assertDelete() { - jdbcRepository.delete("/testPath"); - assertThat(jdbcRepository.get("/testPath"), is("")); - } - - @After - public void stop() { - jdbcRepository.close(); + repository.delete("/testPath"); + assertThat(repository.get("/testPath"), is("")); } }