From e2a07f4f8e1a17e87668596f50f0b1dfa37c56b0 Mon Sep 17 00:00:00 2001 From: Eugeny Karpov Date: Sun, 21 Jan 2018 13:12:00 +0300 Subject: [PATCH 1/3] implement database delegate abstraction for ScriptUtils --- modules/database-commons/pom.xml | 23 +++++++ .../delegate/AbstractDatabaseDelegate.java | 61 +++++++++++++++++++ .../delegate/DatabaseDelegate.java | 31 ++++++++++ .../ConnectionCreationException.java | 13 ++++ .../org/testcontainers}/ext/ScriptUtils.java | 61 +++++-------------- modules/jdbc/pom.xml | 6 ++ .../jdbc/ContainerDatabaseDriver.java | 12 ++-- .../jdbc/JdbcDatabaseDelegate.java | 58 ++++++++++++++++++ pom.xml | 1 + 9 files changed, 214 insertions(+), 52 deletions(-) create mode 100644 modules/database-commons/pom.xml create mode 100644 modules/database-commons/src/main/java/org/testcontainers/delegate/AbstractDatabaseDelegate.java create mode 100644 modules/database-commons/src/main/java/org/testcontainers/delegate/DatabaseDelegate.java create mode 100644 modules/database-commons/src/main/java/org/testcontainers/exception/ConnectionCreationException.java rename modules/{jdbc/src/main/java/org/testcontainers/jdbc => database-commons/src/main/java/org/testcontainers}/ext/ScriptUtils.java (82%) create mode 100644 modules/jdbc/src/main/java/org/testcontainers/jdbc/JdbcDatabaseDelegate.java diff --git a/modules/database-commons/pom.xml b/modules/database-commons/pom.xml new file mode 100644 index 00000000000..965c0c0070c --- /dev/null +++ b/modules/database-commons/pom.xml @@ -0,0 +1,23 @@ + + + 4.0.0 + + + org.testcontainers + testcontainers-parent + 0-SNAPSHOT + ../../pom.xml + + + database-commons + TestContainers :: Database-Commons + + + + ${project.groupId} + testcontainers + ${project.version} + + + + diff --git a/modules/database-commons/src/main/java/org/testcontainers/delegate/AbstractDatabaseDelegate.java b/modules/database-commons/src/main/java/org/testcontainers/delegate/AbstractDatabaseDelegate.java new file mode 100644 index 00000000000..e1e88b54f4f --- /dev/null +++ b/modules/database-commons/src/main/java/org/testcontainers/delegate/AbstractDatabaseDelegate.java @@ -0,0 +1,61 @@ +package org.testcontainers.delegate; + +import java.util.Collection; + +/** + * @param testcontainers container + * @param connection to the database + * @author Eugeny Karpov + */ +public abstract class AbstractDatabaseDelegate implements DatabaseDelegate { + + /** + * Testcontainers container + */ + protected CONTAINER container; + + /** + * Database connection + */ + private CONNECTION connection; + + public AbstractDatabaseDelegate(CONTAINER container) { + this.container = container; + } + + /** + * Get or create new connection to the database + */ + protected CONNECTION getConnection() { + if (connection == null) { + connection = createNewConnection(); + } + return connection; + } + + @Override + public void execute(Collection statements, String scriptPath, boolean continueOnError, boolean ignoreFailedDrops) { + int lineNumber = 0; + for (String statement : statements) { + lineNumber++; + execute(statement, scriptPath, lineNumber, continueOnError, ignoreFailedDrops); + } + } + + @Override + public void close() { + if (connection != null) { + closeConnectionQuietly(connection); + } + } + + /** + * Quietly close the connection + */ + protected abstract void closeConnectionQuietly(CONNECTION connection); + + /** + * Template method for creating new connections to the database + */ + protected abstract CONNECTION createNewConnection(); +} diff --git a/modules/database-commons/src/main/java/org/testcontainers/delegate/DatabaseDelegate.java b/modules/database-commons/src/main/java/org/testcontainers/delegate/DatabaseDelegate.java new file mode 100644 index 00000000000..55886d88143 --- /dev/null +++ b/modules/database-commons/src/main/java/org/testcontainers/delegate/DatabaseDelegate.java @@ -0,0 +1,31 @@ +package org.testcontainers.delegate; + +import java.util.Collection; + +/** + * Database delegate + * + * Gives an abstraction from concrete database + * + * @author Eugeny Karpov + */ +public interface DatabaseDelegate extends AutoCloseable { + + /** + * Execute statement by the implementation of the delegate + */ + void execute(String statement, String scriptPath, int lineNumber, boolean continueOnError, boolean ignoreFailedDrops); + + /** + * Execute collection of statements + */ + void execute(Collection statements, String scriptPath, boolean continueOnError, boolean ignoreFailedDrops); + + /** + * Close connection to the database + * + * Overridden to suppress throwing Exception + */ + @Override + void close(); +} diff --git a/modules/database-commons/src/main/java/org/testcontainers/exception/ConnectionCreationException.java b/modules/database-commons/src/main/java/org/testcontainers/exception/ConnectionCreationException.java new file mode 100644 index 00000000000..3b8852dbddc --- /dev/null +++ b/modules/database-commons/src/main/java/org/testcontainers/exception/ConnectionCreationException.java @@ -0,0 +1,13 @@ +package org.testcontainers.exception; + +/** + * Inability to create connection to the database + * + * @author Eugeny Karpov + */ +public class ConnectionCreationException extends RuntimeException { + + public ConnectionCreationException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/modules/jdbc/src/main/java/org/testcontainers/jdbc/ext/ScriptUtils.java b/modules/database-commons/src/main/java/org/testcontainers/ext/ScriptUtils.java similarity index 82% rename from modules/jdbc/src/main/java/org/testcontainers/jdbc/ext/ScriptUtils.java rename to modules/database-commons/src/main/java/org/testcontainers/ext/ScriptUtils.java index 286ea324f42..e9fa2d18a80 100644 --- a/modules/jdbc/src/main/java/org/testcontainers/jdbc/ext/ScriptUtils.java +++ b/modules/database-commons/src/main/java/org/testcontainers/ext/ScriptUtils.java @@ -14,16 +14,14 @@ * limitations under the License. */ -package org.testcontainers.jdbc.ext; +package org.testcontainers.ext; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.testcontainers.delegate.DatabaseDelegate; import javax.script.ScriptException; -import java.sql.Connection; -import java.sql.SQLException; -import java.sql.Statement; import java.util.LinkedList; import java.util.List; @@ -212,17 +210,16 @@ public static boolean containsSqlScriptDelimiters(String script, String delim) { return false; } - public static void executeSqlScript(Connection connection, String scriptPath, String script) throws ScriptException { - executeSqlScript(connection, scriptPath, script, false, false, DEFAULT_COMMENT_PREFIX, DEFAULT_STATEMENT_SEPARATOR, DEFAULT_BLOCK_COMMENT_START_DELIMITER, DEFAULT_BLOCK_COMMENT_END_DELIMITER); + public static void executeDatabaseScript(DatabaseDelegate databaseDelegate, String scriptPath, String script) throws ScriptException { + executeDatabaseScript(databaseDelegate, scriptPath, script, false, false, DEFAULT_COMMENT_PREFIX, DEFAULT_STATEMENT_SEPARATOR, DEFAULT_BLOCK_COMMENT_START_DELIMITER, DEFAULT_BLOCK_COMMENT_END_DELIMITER); } /** - * Execute the given SQL script. + * Execute the given database script. *

Statement separators and comments will be removed before executing * individual statements within the supplied script. *

Do not use this method to execute DDL if you expect rollback. - * @param connection the JDBC connection to use to execute the script; already - * configured and ready to use + * @param databaseDelegate database delegate for script execution * @param scriptPath the resource (potentially associated with a specific encoding) * to load the SQL script from * @param script the raw script content @@ -240,13 +237,13 @@ public static void executeSqlScript(Connection connection, String scriptPath, St * @param blockCommentEndDelimiter the end block comment delimiter; never * {@code null} or empty @throws ScriptException if an error occurred while executing the SQL script */ - public static void executeSqlScript(Connection connection, String scriptPath, String script, boolean continueOnError, + public static void executeDatabaseScript(DatabaseDelegate databaseDelegate, String scriptPath, String script, boolean continueOnError, boolean ignoreFailedDrops, String commentPrefix, String separator, String blockCommentStartDelimiter, String blockCommentEndDelimiter) throws ScriptException { try { if (LOGGER.isInfoEnabled()) { - LOGGER.info("Executing SQL script from " + scriptPath); + LOGGER.info("Executing database script from " + scriptPath); } long startTime = System.currentTimeMillis(); @@ -261,44 +258,14 @@ public static void executeSqlScript(Connection connection, String scriptPath, St splitSqlScript(scriptPath, script, separator, commentPrefix, blockCommentStartDelimiter, blockCommentEndDelimiter, statements); - int lineNumber = 0; - Statement stmt = connection.createStatement(); - try { - for (String statement : statements) { - lineNumber++; - try { - stmt.execute(statement); - int rowsAffected = stmt.getUpdateCount(); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug(rowsAffected + " returned as updateCount for SQL: " + statement); - } - } - catch (SQLException ex) { - boolean dropStatement = statement.trim().toLowerCase().startsWith("drop"); - if (continueOnError || (dropStatement && ignoreFailedDrops)) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Failed to execute SQL script statement at line " + lineNumber - + " of resource " + scriptPath + ": " + statement, ex); - } - } - else { - throw new ScriptStatementFailedException(statement, lineNumber, scriptPath, ex); - } - } - } - } - finally { - try { - stmt.close(); - } - catch (Throwable ex) { - LOGGER.debug("Could not close JDBC Statement", ex); - } + + try (DatabaseDelegate closeableDelegate = databaseDelegate) { + closeableDelegate.execute(statements, scriptPath, continueOnError, ignoreFailedDrops); } long elapsedTime = System.currentTimeMillis() - startTime; if (LOGGER.isInfoEnabled()) { - LOGGER.info("Executed SQL script from " + scriptPath + " in " + elapsedTime + " ms."); + LOGGER.info("Executed database script from " + scriptPath + " in " + elapsedTime + " ms."); } } catch (Exception ex) { @@ -317,8 +284,8 @@ public ScriptParseException(String format, String scriptPath) { } } - private static class ScriptStatementFailedException extends RuntimeException { - public ScriptStatementFailedException(String statement, int lineNumber, String scriptPath, SQLException ex) { + public static class ScriptStatementFailedException extends RuntimeException { + public ScriptStatementFailedException(String statement, int lineNumber, String scriptPath, Exception ex) { super(String.format("Script execution failed (%s:%d): %s", scriptPath, lineNumber, statement), ex); } } diff --git a/modules/jdbc/pom.xml b/modules/jdbc/pom.xml index 0fe42c3f4f0..72614a410e6 100644 --- a/modules/jdbc/pom.xml +++ b/modules/jdbc/pom.xml @@ -18,6 +18,12 @@ testcontainers ${project.version} + + + ${project.groupId} + database-commons + ${project.version} + diff --git a/modules/jdbc/src/main/java/org/testcontainers/jdbc/ContainerDatabaseDriver.java b/modules/jdbc/src/main/java/org/testcontainers/jdbc/ContainerDatabaseDriver.java index d965fb83d03..b7bd9fb4925 100644 --- a/modules/jdbc/src/main/java/org/testcontainers/jdbc/ContainerDatabaseDriver.java +++ b/modules/jdbc/src/main/java/org/testcontainers/jdbc/ContainerDatabaseDriver.java @@ -4,7 +4,8 @@ import org.slf4j.LoggerFactory; import org.testcontainers.containers.JdbcDatabaseContainer; import org.testcontainers.containers.JdbcDatabaseContainerProvider; -import org.testcontainers.jdbc.ext.ScriptUtils; +import org.testcontainers.delegate.DatabaseDelegate; +import org.testcontainers.ext.ScriptUtils; import javax.script.ScriptException; import java.io.IOException; @@ -153,7 +154,8 @@ public synchronized Connection connect(String url, final Properties info) throws an init script or function has been specified, use it */ if (!initializedContainers.contains(container.getContainerId())) { - runInitScriptIfRequired(url, connection); + DatabaseDelegate databaseDelegate = new JdbcDatabaseDelegate(container); + runInitScriptIfRequired(url, databaseDelegate); runInitFunctionIfRequired(url, connection); initializedContainers.add(container.getContainerId()); } @@ -214,10 +216,10 @@ private Connection wrapConnection(final Connection connection, final JdbcDatabas * Run an init script from the classpath. * * @param url the JDBC URL to check for init script declarations. - * @param connection JDBC connection to apply init scripts to. + * @param databaseDelegate database delegate to apply init scripts to the database * @throws SQLException on script or DB error */ - private void runInitScriptIfRequired(String url, Connection connection) throws SQLException { + private void runInitScriptIfRequired(String url, DatabaseDelegate databaseDelegate) throws SQLException { Matcher matcher = INITSCRIPT_MATCHING_PATTERN.matcher(url); if (matcher.matches()) { String initScriptPath = matcher.group(2); @@ -230,7 +232,7 @@ private void runInitScriptIfRequired(String url, Connection connection) throws S } String sql = IOUtils.toString(resource, StandardCharsets.UTF_8); - ScriptUtils.executeSqlScript(connection, initScriptPath, sql); + ScriptUtils.executeDatabaseScript(databaseDelegate, initScriptPath, sql); } catch (IOException e) { LOGGER.warn("Could not load classpath init script: {}", initScriptPath); throw new SQLException("Could not load classpath init script: " + initScriptPath, e); diff --git a/modules/jdbc/src/main/java/org/testcontainers/jdbc/JdbcDatabaseDelegate.java b/modules/jdbc/src/main/java/org/testcontainers/jdbc/JdbcDatabaseDelegate.java new file mode 100644 index 00000000000..87c32736baa --- /dev/null +++ b/modules/jdbc/src/main/java/org/testcontainers/jdbc/JdbcDatabaseDelegate.java @@ -0,0 +1,58 @@ +package org.testcontainers.jdbc; + +import lombok.extern.slf4j.Slf4j; +import org.testcontainers.containers.JdbcDatabaseContainer; +import org.testcontainers.delegate.AbstractDatabaseDelegate; +import org.testcontainers.exception.ConnectionCreationException; +import org.testcontainers.ext.ScriptUtils; + +import java.sql.SQLException; +import java.sql.Statement; + +/** + * JDBC database delegate + * + * @author Eugeny Karpov + */ +@Slf4j +public class JdbcDatabaseDelegate extends AbstractDatabaseDelegate { + + public JdbcDatabaseDelegate(JdbcDatabaseContainer jdbcDatabaseContainer) { + super(jdbcDatabaseContainer); + } + + @Override + protected Statement createNewConnection() { + try { + return container.createConnection("").createStatement(); + } catch (SQLException e) { + log.error("Could not obtain JDBC connection"); + throw new ConnectionCreationException("Could not obtain JDBC connection", e); + } + } + + + @Override + public void execute(String statement, String scriptPath, int lineNumber, boolean continueOnError, boolean ignoreFailedDrops) { + try { + boolean rowsAffected = getConnection().execute(statement); + log.debug("{} returned as updateCount for SQL: {}", rowsAffected, statement); + } catch (SQLException ex) { + boolean dropStatement = statement.trim().toLowerCase().startsWith("drop"); + if (continueOnError || (dropStatement && ignoreFailedDrops)) { + log.debug("Failed to execute SQL script statement at line {} of resource {}: {}", lineNumber, scriptPath, statement, ex); + } else { + throw new ScriptUtils.ScriptStatementFailedException(statement, lineNumber, scriptPath, ex); + } + } + } + + @Override + protected void closeConnectionQuietly(Statement statement) { + try { + statement.close(); + } catch (Exception e) { + log.error("Could not close JDBC connection", e); + } + } +} diff --git a/pom.xml b/pom.xml index bf158718386..d7b41b916b7 100644 --- a/pom.xml +++ b/pom.xml @@ -166,6 +166,7 @@ modules/selenium modules/nginx modules/jdbc-test + modules/database-commons From c0aec137bcc8de215e6022f0a0443b800145fe03 Mon Sep 17 00:00:00 2001 From: Eugeny Karpov Date: Sun, 21 Jan 2018 23:33:48 +0300 Subject: [PATCH 2/3] add ability to reuse closed database delegate --- .../testcontainers/delegate/AbstractDatabaseDelegate.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/database-commons/src/main/java/org/testcontainers/delegate/AbstractDatabaseDelegate.java b/modules/database-commons/src/main/java/org/testcontainers/delegate/AbstractDatabaseDelegate.java index e1e88b54f4f..b599df79628 100644 --- a/modules/database-commons/src/main/java/org/testcontainers/delegate/AbstractDatabaseDelegate.java +++ b/modules/database-commons/src/main/java/org/testcontainers/delegate/AbstractDatabaseDelegate.java @@ -19,6 +19,8 @@ public abstract class AbstractDatabaseDelegate implements */ private CONNECTION connection; + private boolean isConnectionStarted = false; + public AbstractDatabaseDelegate(CONTAINER container) { this.container = container; } @@ -27,8 +29,9 @@ public AbstractDatabaseDelegate(CONTAINER container) { * Get or create new connection to the database */ protected CONNECTION getConnection() { - if (connection == null) { + if (!isConnectionStarted) { connection = createNewConnection(); + isConnectionStarted = true; } return connection; } @@ -44,8 +47,9 @@ public void execute(Collection statements, String scriptPath, boolean co @Override public void close() { - if (connection != null) { + if (isConnectionStarted) { closeConnectionQuietly(connection); + isConnectionStarted = false; } } From c5267e188bc6cf97bf0a6b3f6a348e9425a4fc36 Mon Sep 17 00:00:00 2001 From: Eugeny Karpov Date: Fri, 26 Jan 2018 00:37:40 +0300 Subject: [PATCH 3/3] move container field to children keep public API of ScriptUtils --- .../delegate/AbstractDatabaseDelegate.java | 12 +-- .../jdbc/ContainerLessJdbcDelegate.java | 36 +++++++ .../jdbc/JdbcDatabaseDelegate.java | 8 +- .../testcontainers/jdbc/ext/ScriptUtils.java | 102 ++++++++++++++++++ 4 files changed, 144 insertions(+), 14 deletions(-) create mode 100644 modules/jdbc/src/main/java/org/testcontainers/jdbc/ContainerLessJdbcDelegate.java create mode 100644 modules/jdbc/src/main/java/org/testcontainers/jdbc/ext/ScriptUtils.java diff --git a/modules/database-commons/src/main/java/org/testcontainers/delegate/AbstractDatabaseDelegate.java b/modules/database-commons/src/main/java/org/testcontainers/delegate/AbstractDatabaseDelegate.java index b599df79628..14572dec421 100644 --- a/modules/database-commons/src/main/java/org/testcontainers/delegate/AbstractDatabaseDelegate.java +++ b/modules/database-commons/src/main/java/org/testcontainers/delegate/AbstractDatabaseDelegate.java @@ -3,16 +3,10 @@ import java.util.Collection; /** - * @param testcontainers container * @param connection to the database * @author Eugeny Karpov */ -public abstract class AbstractDatabaseDelegate implements DatabaseDelegate { - - /** - * Testcontainers container - */ - protected CONTAINER container; +public abstract class AbstractDatabaseDelegate implements DatabaseDelegate { /** * Database connection @@ -21,10 +15,6 @@ public abstract class AbstractDatabaseDelegate implements private boolean isConnectionStarted = false; - public AbstractDatabaseDelegate(CONTAINER container) { - this.container = container; - } - /** * Get or create new connection to the database */ diff --git a/modules/jdbc/src/main/java/org/testcontainers/jdbc/ContainerLessJdbcDelegate.java b/modules/jdbc/src/main/java/org/testcontainers/jdbc/ContainerLessJdbcDelegate.java new file mode 100644 index 00000000000..7a22d139bea --- /dev/null +++ b/modules/jdbc/src/main/java/org/testcontainers/jdbc/ContainerLessJdbcDelegate.java @@ -0,0 +1,36 @@ +package org.testcontainers.jdbc; + +import lombok.extern.slf4j.Slf4j; +import org.testcontainers.exception.ConnectionCreationException; + +import java.sql.Connection; +import java.sql.SQLException; +import java.sql.Statement; + +/** + * Containerless jdbc database delegate + * + * Is used only with deprecated ScriptUtils + * + * @see org.testcontainers.ext.ScriptUtils + */ +@Slf4j +public class ContainerLessJdbcDelegate extends JdbcDatabaseDelegate { + + private Connection connection; + + public ContainerLessJdbcDelegate(Connection connection) { + super(null); + this.connection = connection; + } + + @Override + protected Statement createNewConnection() { + try { + return connection.createStatement(); + } catch (SQLException e) { + log.error("Could create JDBC statement"); + throw new ConnectionCreationException("Could create JDBC statement", e); + } + } +} diff --git a/modules/jdbc/src/main/java/org/testcontainers/jdbc/JdbcDatabaseDelegate.java b/modules/jdbc/src/main/java/org/testcontainers/jdbc/JdbcDatabaseDelegate.java index 87c32736baa..e490da87c4a 100644 --- a/modules/jdbc/src/main/java/org/testcontainers/jdbc/JdbcDatabaseDelegate.java +++ b/modules/jdbc/src/main/java/org/testcontainers/jdbc/JdbcDatabaseDelegate.java @@ -15,10 +15,12 @@ * @author Eugeny Karpov */ @Slf4j -public class JdbcDatabaseDelegate extends AbstractDatabaseDelegate { +public class JdbcDatabaseDelegate extends AbstractDatabaseDelegate { - public JdbcDatabaseDelegate(JdbcDatabaseContainer jdbcDatabaseContainer) { - super(jdbcDatabaseContainer); + private JdbcDatabaseContainer container; + + public JdbcDatabaseDelegate(JdbcDatabaseContainer container) { + this.container = container; } @Override diff --git a/modules/jdbc/src/main/java/org/testcontainers/jdbc/ext/ScriptUtils.java b/modules/jdbc/src/main/java/org/testcontainers/jdbc/ext/ScriptUtils.java new file mode 100644 index 00000000000..76b7a044c9d --- /dev/null +++ b/modules/jdbc/src/main/java/org/testcontainers/jdbc/ext/ScriptUtils.java @@ -0,0 +1,102 @@ +/* + * Copyright 2002-2014 the original author or authors. + * + * Licensed 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.testcontainers.jdbc.ext; + +import org.testcontainers.jdbc.ContainerLessJdbcDelegate; + +import javax.script.ScriptException; +import java.sql.Connection; +import java.util.List; + +/** + * Wrapper for database-agnostic ScriptUtils + * + * @see org.testcontainers.ext.ScriptUtils + * @deprecated Needed only to keep binary compatibility for this internal API. Consider using database-agnostic ScriptUtils + */ +public abstract class ScriptUtils { + + /** + * Default statement separator within SQL scripts. + */ + public static final String DEFAULT_STATEMENT_SEPARATOR = ";"; + + /** + * Fallback statement separator within SQL scripts. + *

Used if neither a custom defined separator nor the + * {@link #DEFAULT_STATEMENT_SEPARATOR} is present in a given script. + */ + public static final String FALLBACK_STATEMENT_SEPARATOR = "\n"; + + /** + * Default prefix for line comments within SQL scripts. + */ + public static final String DEFAULT_COMMENT_PREFIX = "--"; + + /** + * Default start delimiter for block comments within SQL scripts. + */ + public static final String DEFAULT_BLOCK_COMMENT_START_DELIMITER = "/*"; + + /** + * Default end delimiter for block comments within SQL scripts. + */ + public static final String DEFAULT_BLOCK_COMMENT_END_DELIMITER = "*/"; + + /** + * Prevent instantiation of this utility class. + */ + private ScriptUtils() { + /* no-op */ + } + + /** + * @see org.testcontainers.ext.ScriptUtils + * @deprecated Needed only to keep binary compatibility for this internal API. Consider using database-agnostic ScriptUtils + */ + public static void splitSqlScript(String resource, String script, String separator, String commentPrefix, + String blockCommentStartDelimiter, String blockCommentEndDelimiter, List statements) { + org.testcontainers.ext.ScriptUtils.splitSqlScript(resource, script, separator, commentPrefix, blockCommentStartDelimiter, blockCommentEndDelimiter, statements); + } + + /** + * @see org.testcontainers.ext.ScriptUtils + * @deprecated Needed only to keep binary compatibility for this internal API. Consider using database-agnostic ScriptUtils + */ + public static boolean containsSqlScriptDelimiters(String script, String delim) { + return org.testcontainers.ext.ScriptUtils.containsSqlScriptDelimiters(script, delim); + } + + /** + * @see org.testcontainers.ext.ScriptUtils + * @deprecated Needed only to keep binary compatibility for this internal API. Consider using database-agnostic ScriptUtils + */ + public static void executeSqlScript(Connection connection, String scriptPath, String script) throws ScriptException { + org.testcontainers.ext.ScriptUtils.executeDatabaseScript(new ContainerLessJdbcDelegate(connection), scriptPath, script); + } + + /** + * @see org.testcontainers.ext.ScriptUtils + * @deprecated Needed only to keep binary compatibility for this internal API. Consider using database-agnostic ScriptUtils + */ + public static void executeSqlScript(Connection connection, String scriptPath, String script, boolean continueOnError, + boolean ignoreFailedDrops, String commentPrefix, String separator, String blockCommentStartDelimiter, + String blockCommentEndDelimiter) throws ScriptException { + org.testcontainers.ext.ScriptUtils.executeDatabaseScript(new ContainerLessJdbcDelegate(connection), scriptPath, + script, continueOnError, ignoreFailedDrops, commentPrefix, separator, blockCommentStartDelimiter, blockCommentEndDelimiter); + } +} \ No newline at end of file