This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang 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 652d77b Rename BaseITCase.getStatement to getSQL (#9821)
652d77b is described below
commit 652d77b94230abd176abeeb4daa2e56789bc94a3
Author: Liang Zhang <[email protected]>
AuthorDate: Thu Mar 25 20:19:33 2021 +0800
Rename BaseITCase.getStatement to getSQL (#9821)
* Rename BaseITCase.getStatement to getSQL
* Refactor ContainerCompose
---
.../junit/compose/ContainerCompose.java | 98 +++++++++++-----------
.../junit/param/TestCaseParameters.java | 2 +-
.../junit/runner/ShardingSphereCISubRunner.java | 2 +-
.../junit/runner/ShardingSphereITSubRunner.java | 2 +-
.../junit/runner/ShardingSphereRunner.java | 2 +-
.../test/integration/engine/it/BaseITCase.java | 28 +++----
.../integration/engine/it/dal/GeneralDALIT.java | 2 +-
.../integration/engine/it/dcl/GeneralDCLIT.java | 8 +-
.../integration/engine/it/ddl/GeneralDDLIT.java | 8 +-
.../integration/engine/it/dml/AdditionalDMLIT.java | 28 +++----
.../test/integration/engine/it/dml/BatchDMLIT.java | 4 +-
.../integration/engine/it/dml/GeneralDMLIT.java | 8 +-
.../integration/engine/it/dql/AdditionalDQLIT.java | 16 ++--
.../integration/engine/it/dql/GeneralDQLIT.java | 8 +-
14 files changed, 109 insertions(+), 107 deletions(-)
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/compose/ContainerCompose.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/compose/ContainerCompose.java
index da3201a..f690f0b 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/compose/ContainerCompose.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/compose/ContainerCompose.java
@@ -19,7 +19,6 @@ package
org.apache.shardingsphere.test.integration.junit.compose;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.SneakyThrows;
@@ -38,6 +37,7 @@ import
org.apache.shardingsphere.test.integration.junit.logging.ContainerLogs;
import
org.apache.shardingsphere.test.integration.junit.runner.TestCaseBeanContext;
import
org.apache.shardingsphere.test.integration.junit.runner.TestCaseDescription;
import org.junit.runners.model.FrameworkField;
+import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.TestClass;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.Network;
@@ -46,7 +46,8 @@ import org.testcontainers.lifecycle.Startable;
import java.io.Closeable;
import java.lang.reflect.Field;
import java.util.Arrays;
-import java.util.List;
+import java.util.Collection;
+import java.util.LinkedList;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
@@ -89,24 +90,24 @@ public final class ContainerCompose implements Closeable {
private ShardingSphereContainer createContainer(final FrameworkField
field) {
OnContainer metadata = field.getAnnotation(OnContainer.class);
try {
- ShardingSphereContainer container = createContainer(metadata);
- if (Objects.isNull(container)) {
+ ShardingSphereContainer result = createContainer(metadata);
+ if (Objects.isNull(result)) {
log.warn("container {} is not activated.", metadata.name());
return null;
}
- container.setDockerName(metadata.name());
+ result.setDockerName(metadata.name());
String hostName = metadata.hostName();
if (Strings.isNullOrEmpty(hostName)) {
hostName = metadata.name();
}
- container.withNetworkAliases(hostName);
- container.setNetwork(network);
- container.withLogConsumer(ContainerLogs.newConsumer(clusterName +
"_" + metadata.name()));
+ result.withNetworkAliases(hostName);
+ result.setNetwork(network);
+ result.withLogConsumer(ContainerLogs.newConsumer(clusterName + "_"
+ metadata.name()));
field.getField().setAccessible(true);
- field.getField().set(instance, container);
- beanContext.registerBeanByName(metadata.name(), container);
+ field.getField().set(instance, result);
+ beanContext.registerBeanByName(metadata.name(), result);
log.info("container {} is activated.", metadata.name());
- return container;
+ return result;
// CHECKSTYLE:OFF
} catch (final Exception ex) {
// CHECKSTYLE:ON
@@ -152,25 +153,25 @@ public final class ContainerCompose implements Closeable {
}
private void inject(final ShardingSphereContainer container) {
- List<Field> fields = Lists.newArrayList();
+ Collection<Field> fields = new LinkedList<>();
for (Class<?> klass = container.getClass(); Objects.nonNull(klass);
klass = klass.getSuperclass()) {
fields.addAll(Arrays.asList(klass.getDeclaredFields()));
}
- fields.stream()
- .filter(e ->
e.isAnnotationPresent(ShardingSphereITInject.class))
- .forEach(e -> {
- Class<?> type = e.getType();
- e.setAccessible(true);
- try {
- if (type.isPrimitive() || String.class == type) {
- e.set(container,
beanContext.getBeanByName(e.getName()));
- } else {
- e.set(container, beanContext.getBean(type));
- }
- } catch (final IllegalAccessException
illegalAccessException) {
- log.error("Failed to auto inject {}.{}.",
container.getContainerName(), e.getName());
- }
- });
+ fields.stream().filter(each ->
each.isAnnotationPresent(ShardingSphereITInject.class)).forEach(each ->
setFieldValue(each, container));
+ }
+
+ private void setFieldValue(final Field field, final
ShardingSphereContainer container) {
+ Class<?> type = field.getType();
+ field.setAccessible(true);
+ try {
+ if (type.isPrimitive() || String.class == type) {
+ field.set(container,
beanContext.getBeanByName(field.getName()));
+ } else {
+ field.set(container, beanContext.getBean(type));
+ }
+ } catch (final IllegalAccessException ex) {
+ log.error("Failed to auto inject {}.{}.",
container.getContainerName(), field.getName());
+ }
}
/**
@@ -178,28 +179,30 @@ public final class ContainerCompose implements Closeable {
*/
@SneakyThrows
public void createInitializerAndExecute() {
-
testClass.getAnnotatedMethods(ContainerInitializer.class).forEach(method -> {
- try {
- if (method.isStatic()) {
- method.getMethod().setAccessible(true);
- method.invokeExplosively(null);
- } else {
- method.getMethod().setAccessible(true);
- method.invokeExplosively(instance);
- }
- // CHECKSTYLE:OFF
- } catch (final Throwable throwable) {
- // CHECKSTYLE:ON
- throwable.printStackTrace();
+
testClass.getAnnotatedMethods(ContainerInitializer.class).forEach(this::invokeExplosively);
+ }
+
+ private void invokeExplosively(final FrameworkMethod frameworkMethod) {
+ try {
+ if (frameworkMethod.isStatic()) {
+ frameworkMethod.getMethod().setAccessible(true);
+ frameworkMethod.invokeExplosively(null);
+ } else {
+ frameworkMethod.getMethod().setAccessible(true);
+ frameworkMethod.invokeExplosively(instance);
}
- });
+ // CHECKSTYLE:OFF
+ } catch (final Throwable ex) {
+ // CHECKSTYLE:ON
+ throw new RuntimeException(ex);
+ }
}
/**
* Startup.
*/
public void start() {
- containers.stream().filter(c ->
!c.isCreated()).forEach(GenericContainer::start);
+ containers.stream().filter(each ->
!each.isCreated()).forEach(GenericContainer::start);
}
/**
@@ -207,21 +210,20 @@ public final class ContainerCompose implements Closeable {
*/
public void waitUntilReady() {
containers.stream()
- .filter(c -> {
+ .filter(each -> {
try {
- return !c.isHealthy();
+ return !each.isHealthy();
// CHECKSTYLE:OFF
- } catch (final Exception ex) {
+ } catch (final RuntimeException ex) {
// CHECKSTYLE:ON
return false;
}
})
- .forEach(c -> {
- while (!(c.isRunning() && c.isHealthy())) {
+ .forEach(each -> {
+ while (!(each.isRunning() && each.isHealthy())) {
try {
TimeUnit.MILLISECONDS.sleep(200L);
} catch (final InterruptedException ignored) {
-
}
}
});
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/param/TestCaseParameters.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/param/TestCaseParameters.java
index 5f1ee83..8395a17 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/param/TestCaseParameters.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/param/TestCaseParameters.java
@@ -36,7 +36,7 @@ public final class TestCaseParameters {
private final String parentPath;
- private final String statement;
+ private final String sql;
private final SQLExecuteType executeType;
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/ShardingSphereCISubRunner.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/ShardingSphereCISubRunner.java
index 88a72e1..aae2f65 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/ShardingSphereCISubRunner.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/ShardingSphereCISubRunner.java
@@ -114,7 +114,7 @@ public final class ShardingSphereCISubRunner extends
BlockJUnit4ClassRunner {
description.getScenario(),
description.getDatabase(),
context.getBean(SQLExecuteType.class),
- context.getBeanByName("statement")
+ context.getBeanByName("sql")
);
}
}
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/ShardingSphereITSubRunner.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/ShardingSphereITSubRunner.java
index 9b225bc..b6cec9a 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/ShardingSphereITSubRunner.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/ShardingSphereITSubRunner.java
@@ -111,7 +111,7 @@ public final class ShardingSphereITSubRunner extends
BlockJUnit4ClassRunner {
description.getScenario(),
description.getDatabase(),
context.getBean(SQLExecuteType.class),
- context.getBeanByName("statement")
+ context.getBeanByName("sql")
);
}
}
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/ShardingSphereRunner.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/ShardingSphereRunner.java
index 5c39ce9..b14f673 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/ShardingSphereRunner.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/runner/ShardingSphereRunner.java
@@ -144,7 +144,7 @@ public final class ShardingSphereRunner extends Suite {
private void register(final TestCaseParameters parameters, final
TestCaseBeanContext context) {
context.registerBean(TestCaseParameters.class, parameters);
- context.registerBeanByName("statement", parameters.getStatement());
+ context.registerBeanByName("sql", parameters.getSql());
context.registerBeanByName("parentPath", parameters.getParentPath());
context.registerBean(SQLExecuteType.class,
parameters.getExecuteType());
context.registerBean(IntegrationTestCase.class,
parameters.getTestCase());
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/BaseITCase.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/BaseITCase.java
index ca13841..df39560 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/BaseITCase.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/BaseITCase.java
@@ -29,8 +29,8 @@ import
org.apache.shardingsphere.test.integration.env.database.DatabaseEnvironme
import
org.apache.shardingsphere.test.integration.env.dataset.DataSetEnvironmentManager;
import
org.apache.shardingsphere.test.integration.junit.annotation.ContainerInitializer;
import
org.apache.shardingsphere.test.integration.junit.annotation.ContainerType;
-import
org.apache.shardingsphere.test.integration.junit.annotation.ShardingSphereITInject;
import org.apache.shardingsphere.test.integration.junit.annotation.OnContainer;
+import
org.apache.shardingsphere.test.integration.junit.annotation.ShardingSphereITInject;
import
org.apache.shardingsphere.test.integration.junit.container.ShardingSphereAdapterContainer;
import
org.apache.shardingsphere.test.integration.junit.container.ShardingSphereStorageContainer;
import
org.apache.shardingsphere.test.integration.junit.runner.ShardingSphereRunner;
@@ -70,7 +70,7 @@ public abstract class BaseITCase {
private DataSetEnvironmentManager dataSetEnvironmentManager;
@ShardingSphereITInject
- private String statement;
+ private String sql;
@ShardingSphereITInject
private TestCaseDescription description;
@@ -88,33 +88,33 @@ public abstract class BaseITCase {
}
@ContainerInitializer
- protected void initialize() {
+ protected final void initialize() {
if (Objects.nonNull(proxy) && Objects.nonNull(storage)) {
proxy.dependsOn(storage);
}
}
+ @BeforeClass
+ public static void executeInitSQLs() throws IOException, JAXBException,
SQLException {
+ if (EnvironmentType.DOCKER !=
IntegrationTestEnvironment.getInstance().getEnvType()) {
+ DatabaseEnvironmentManager.executeInitSQLs();
+ }
+ }
+
@Before
- public void createDataSource() {
+ public final void createDataSource() {
targetDataSource = proxy.getDataSource();
}
- protected String getStatement() throws ParseException {
- return sqlExecuteType == SQLExecuteType.Literal ?
getLiteralSQL(statement) : statement;
+ protected final String getSQL() throws ParseException {
+ return sqlExecuteType == SQLExecuteType.Literal ? getLiteralSQL(sql) :
sql;
}
- protected String getLiteralSQL(final String sql) throws ParseException {
+ protected final String getLiteralSQL(final String sql) throws
ParseException {
List<Object> parameters = null == assertion ? Collections.emptyList()
:
assertion.getSQLValues().stream().map(SQLValue::toString).collect(Collectors.toList());
return parameters.isEmpty() ? sql : String.format(sql.replace("%",
"$").replace("?", "%s"), parameters.toArray()).replace("$", "%").replace("%%",
"%").replace("'%'", "'%%'");
}
- @BeforeClass
- public static void executeInitSQLs() throws IOException, JAXBException,
SQLException {
- if (EnvironmentType.DOCKER !=
IntegrationTestEnvironment.getInstance().getEnvType()) {
- DatabaseEnvironmentManager.executeInitSQLs();
- }
- }
-
@After
public final void tearDown() {
if (targetDataSource instanceof ShardingSphereDataSource) {
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dal/GeneralDALIT.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dal/GeneralDALIT.java
index ed9b35a..9e47274 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dal/GeneralDALIT.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dal/GeneralDALIT.java
@@ -51,7 +51,7 @@ public final class GeneralDALIT extends BaseDALIT {
private void assertExecuteForStatement(final Connection connection) throws
SQLException, ParseException {
try (Statement statement = connection.createStatement()) {
- boolean isQuery = statement.execute(getStatement());
+ boolean isQuery = statement.execute(getSQL());
if (isQuery) {
try (ResultSet resultSet = statement.getResultSet()) {
assertResultSet(resultSet);
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dcl/GeneralDCLIT.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dcl/GeneralDCLIT.java
index 7627ae9..951bb1d 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dcl/GeneralDCLIT.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dcl/GeneralDCLIT.java
@@ -36,9 +36,9 @@ public final class GeneralDCLIT extends BaseDCLIT {
public void assertExecuteUpdate() throws SQLException, ParseException {
try (Connection connection = getTargetDataSource().getConnection()) {
if (SQLExecuteType.Literal == getSqlExecuteType()) {
- connection.createStatement().executeUpdate(getStatement());
+ connection.createStatement().executeUpdate(getSQL());
} else {
- connection.prepareStatement(getStatement()).executeUpdate();
+ connection.prepareStatement(getSQL()).executeUpdate();
}
}
}
@@ -47,9 +47,9 @@ public final class GeneralDCLIT extends BaseDCLIT {
public void assertExecute() throws SQLException, ParseException {
try (Connection connection = getTargetDataSource().getConnection()) {
if (SQLExecuteType.Literal == getSqlExecuteType()) {
- connection.createStatement().execute(getStatement());
+ connection.createStatement().execute(getSQL());
} else {
- connection.prepareStatement(getStatement()).execute();
+ connection.prepareStatement(getSQL()).execute();
}
}
}
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/ddl/GeneralDDLIT.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/ddl/GeneralDDLIT.java
index 1dc5a69..c227729 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/ddl/GeneralDDLIT.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/ddl/GeneralDDLIT.java
@@ -36,9 +36,9 @@ public final class GeneralDDLIT extends BaseDDLIT {
public void assertExecuteUpdate() throws SQLException, ParseException {
try (Connection connection = getTargetDataSource().getConnection()) {
if (SQLExecuteType.Literal == getSqlExecuteType()) {
- connection.createStatement().executeUpdate(getStatement());
+ connection.createStatement().executeUpdate(getSQL());
} else {
- connection.prepareStatement(getStatement()).executeUpdate();
+ connection.prepareStatement(getSQL()).executeUpdate();
}
assertTableMetaData();
}
@@ -48,9 +48,9 @@ public final class GeneralDDLIT extends BaseDDLIT {
public void assertExecute() throws SQLException, ParseException {
try (Connection connection = getTargetDataSource().getConnection()) {
if (SQLExecuteType.Literal == getSqlExecuteType()) {
- connection.createStatement().execute(getStatement());
+ connection.createStatement().execute(getSQL());
} else {
- connection.prepareStatement(getStatement()).execute();
+ connection.prepareStatement(getSQL()).execute();
}
assertTableMetaData();
}
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dml/AdditionalDMLIT.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dml/AdditionalDMLIT.java
index 1dce947..37aea00 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dml/AdditionalDMLIT.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dml/AdditionalDMLIT.java
@@ -54,12 +54,12 @@ public final class AdditionalDMLIT extends BaseDMLIT {
private int executeUpdateForStatementWithAutoGeneratedKeys(final
Connection connection) throws SQLException, ParseException {
try (Statement statement = connection.createStatement()) {
- return statement.executeUpdate(String.format(getStatement(),
getAssertion().getSQLValues().toArray()), Statement.NO_GENERATED_KEYS);
+ return statement.executeUpdate(String.format(getSQL(),
getAssertion().getSQLValues().toArray()), Statement.NO_GENERATED_KEYS);
}
}
private int executeUpdateForPreparedStatementWithAutoGeneratedKeys(final
Connection connection) throws SQLException, ParseException {
- try (PreparedStatement preparedStatement =
connection.prepareStatement(getStatement(), Statement.NO_GENERATED_KEYS)) {
+ try (PreparedStatement preparedStatement =
connection.prepareStatement(getSQL(), Statement.NO_GENERATED_KEYS)) {
for (SQLValue each : getAssertion().getSQLValues()) {
preparedStatement.setObject(each.getIndex(), each.getValue());
}
@@ -82,12 +82,12 @@ public final class AdditionalDMLIT extends BaseDMLIT {
private int executeUpdateForStatementWithColumnIndexes(final Connection
connection) throws SQLException, ParseException {
try (Statement statement = connection.createStatement()) {
- return statement.executeUpdate(String.format(getStatement(),
getAssertion().getSQLValues().toArray()), new int[]{1});
+ return statement.executeUpdate(String.format(getSQL(),
getAssertion().getSQLValues().toArray()), new int[]{1});
}
}
private int executeUpdateForPreparedStatementWithColumnIndexes(final
Connection connection) throws SQLException, ParseException {
- try (PreparedStatement preparedStatement =
connection.prepareStatement(getStatement(), new int[]{1})) {
+ try (PreparedStatement preparedStatement =
connection.prepareStatement(getSQL(), new int[]{1})) {
for (SQLValue each : getAssertion().getSQLValues()) {
preparedStatement.setObject(each.getIndex(), each.getValue());
}
@@ -110,12 +110,12 @@ public final class AdditionalDMLIT extends BaseDMLIT {
private int executeUpdateForStatementWithColumnNames(final Connection
connection) throws SQLException, ParseException {
try (Statement statement = connection.createStatement()) {
- return statement.executeUpdate(String.format(getStatement(),
getAssertion().getSQLValues().toArray()));
+ return statement.executeUpdate(String.format(getSQL(),
getAssertion().getSQLValues().toArray()));
}
}
private int executeUpdateForPreparedStatementWithColumnNames(final
Connection connection) throws SQLException, ParseException {
- try (PreparedStatement preparedStatement =
connection.prepareStatement(getStatement(), new String[]{"TODO"})) {
+ try (PreparedStatement preparedStatement =
connection.prepareStatement(getSQL(), new String[]{"TODO"})) {
for (SQLValue each : getAssertion().getSQLValues()) {
preparedStatement.setObject(each.getIndex(), each.getValue());
}
@@ -139,13 +139,13 @@ public final class AdditionalDMLIT extends BaseDMLIT {
private int executeForStatementWithoutAutoGeneratedKeys(final Connection
connection) throws SQLException, ParseException {
try (Statement statement = connection.createStatement()) {
- assertFalse("Not a DML statement.",
statement.execute(String.format(getStatement(),
getAssertion().getSQLValues().toArray()), Statement.NO_GENERATED_KEYS));
+ assertFalse("Not a DML statement.",
statement.execute(String.format(getSQL(),
getAssertion().getSQLValues().toArray()), Statement.NO_GENERATED_KEYS));
return statement.getUpdateCount();
}
}
private int executeForPreparedStatementWithoutAutoGeneratedKeys(final
Connection connection) throws SQLException, ParseException {
- try (PreparedStatement preparedStatement =
connection.prepareStatement(getStatement(), Statement.NO_GENERATED_KEYS)) {
+ try (PreparedStatement preparedStatement =
connection.prepareStatement(getSQL(), Statement.NO_GENERATED_KEYS)) {
for (SQLValue each : getAssertion().getSQLValues()) {
preparedStatement.setObject(each.getIndex(), each.getValue());
}
@@ -169,14 +169,14 @@ public final class AdditionalDMLIT extends BaseDMLIT {
private int executeForStatementWithAutoGeneratedKeys(final Connection
connection) throws SQLException, ParseException {
try (Statement statement = connection.createStatement()) {
- assertFalse("Not a DML statement.",
statement.execute(String.format(getStatement(),
getAssertion().getSQLValues().toArray()), Statement.RETURN_GENERATED_KEYS));
+ assertFalse("Not a DML statement.",
statement.execute(String.format(getSQL(),
getAssertion().getSQLValues().toArray()), Statement.RETURN_GENERATED_KEYS));
return statement.getUpdateCount();
// TODO assert statement.getGeneratedKeys();
}
}
private int executeForPreparedStatementWithAutoGeneratedKeys(final
Connection connection) throws SQLException, ParseException {
- try (PreparedStatement preparedStatement =
connection.prepareStatement(getStatement(), Statement.RETURN_GENERATED_KEYS)) {
+ try (PreparedStatement preparedStatement =
connection.prepareStatement(getSQL(), Statement.RETURN_GENERATED_KEYS)) {
for (SQLValue each : getAssertion().getSQLValues()) {
preparedStatement.setObject(each.getIndex(), each.getValue());
}
@@ -201,13 +201,13 @@ public final class AdditionalDMLIT extends BaseDMLIT {
private int executeForStatementWithColumnIndexes(final Connection
connection) throws SQLException, ParseException {
try (Statement statement = connection.createStatement()) {
- assertFalse("Not a DML statement.",
statement.execute(String.format(getStatement(),
getAssertion().getSQLValues().toArray()), new int[]{1}));
+ assertFalse("Not a DML statement.",
statement.execute(String.format(getSQL(),
getAssertion().getSQLValues().toArray()), new int[]{1}));
return statement.getUpdateCount();
}
}
private int executeForPreparedStatementWithColumnIndexes(final Connection
connection) throws SQLException, ParseException {
- try (PreparedStatement preparedStatement =
connection.prepareStatement(getStatement(), new int[]{1})) {
+ try (PreparedStatement preparedStatement =
connection.prepareStatement(getSQL(), new int[]{1})) {
for (SQLValue each : getAssertion().getSQLValues()) {
preparedStatement.setObject(each.getIndex(), each.getValue());
}
@@ -231,13 +231,13 @@ public final class AdditionalDMLIT extends BaseDMLIT {
private int executeForStatementWithColumnNames(final Connection
connection) throws SQLException, ParseException {
try (Statement statement = connection.createStatement()) {
- assertFalse("Not a DML statement.",
statement.execute(String.format(getStatement(),
getAssertion().getSQLValues().toArray()), new String[]{"TODO"}));
+ assertFalse("Not a DML statement.",
statement.execute(String.format(getSQL(),
getAssertion().getSQLValues().toArray()), new String[]{"TODO"}));
return statement.getUpdateCount();
}
}
private int executeForPreparedStatementWithColumnNames(final Connection
connection) throws SQLException, ParseException {
- try (PreparedStatement preparedStatement =
connection.prepareStatement(getStatement(), new String[]{"TODO"})) {
+ try (PreparedStatement preparedStatement =
connection.prepareStatement(getSQL(), new String[]{"TODO"})) {
for (SQLValue each : getAssertion().getSQLValues()) {
preparedStatement.setObject(each.getIndex(), each.getValue());
}
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dml/BatchDMLIT.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dml/BatchDMLIT.java
index 709c959..727e6ce 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dml/BatchDMLIT.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dml/BatchDMLIT.java
@@ -56,7 +56,7 @@ public final class BatchDMLIT extends BatchITCase {
}
private int[] executeBatchForPreparedStatement(final Connection
connection) throws SQLException, ParseException {
- try (PreparedStatement preparedStatement =
connection.prepareStatement(getStatement())) {
+ try (PreparedStatement preparedStatement =
connection.prepareStatement(getSQL())) {
for (IntegrationTestCaseAssertion each :
getTestCase().getAssertions()) {
addBatch(preparedStatement, each);
}
@@ -82,7 +82,7 @@ public final class BatchDMLIT extends BatchITCase {
default:
}
try (Connection connection = getTargetDataSource().getConnection()) {
- try (PreparedStatement preparedStatement =
connection.prepareStatement(getStatement())) {
+ try (PreparedStatement preparedStatement =
connection.prepareStatement(getSQL())) {
for (IntegrationTestCaseAssertion each :
getTestCase().getAssertions()) {
addBatch(preparedStatement, each);
}
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dml/GeneralDMLIT.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dml/GeneralDMLIT.java
index be83a45..09344c1 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dml/GeneralDMLIT.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dml/GeneralDMLIT.java
@@ -55,12 +55,12 @@ public final class GeneralDMLIT extends BaseDMLIT {
private int executeUpdateForStatement(final Connection connection) throws
SQLException, ParseException {
try (Statement statement = connection.createStatement()) {
- return statement.executeUpdate(getStatement());
+ return statement.executeUpdate(getSQL());
}
}
private int executeUpdateForPreparedStatement(final Connection connection)
throws SQLException, ParseException {
- try (PreparedStatement preparedStatement =
connection.prepareStatement(getStatement())) {
+ try (PreparedStatement preparedStatement =
connection.prepareStatement(getSQL())) {
for (SQLValue each : getAssertion().getSQLValues()) {
preparedStatement.setObject(each.getIndex(), each.getValue());
}
@@ -86,13 +86,13 @@ public final class GeneralDMLIT extends BaseDMLIT {
private int executeForStatement(final Connection connection) throws
SQLException, ParseException {
try (Statement statement = connection.createStatement()) {
- assertFalse("Not a DML statement.",
statement.execute(getStatement()));
+ assertFalse("Not a DML statement.", statement.execute(getSQL()));
return statement.getUpdateCount();
}
}
private int executeForPreparedStatement(final Connection connection)
throws SQLException, ParseException {
- try (PreparedStatement preparedStatement =
connection.prepareStatement(getStatement())) {
+ try (PreparedStatement preparedStatement =
connection.prepareStatement(getSQL())) {
for (SQLValue each : getAssertion().getSQLValues()) {
preparedStatement.setObject(each.getIndex(), each.getValue());
}
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dql/AdditionalDQLIT.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dql/AdditionalDQLIT.java
index f26ccf7..70bec28 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dql/AdditionalDQLIT.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dql/AdditionalDQLIT.java
@@ -53,13 +53,13 @@ public final class AdditionalDQLIT extends BaseDQLIT {
private void
assertExecuteQueryForStatementWithResultSetTypeAndResultSetConcurrency(final
Connection connection) throws SQLException, ParseException {
try (
Statement statement =
connection.createStatement(ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY);
- ResultSet resultSet =
statement.executeQuery(String.format(getStatement(),
getAssertion().getSQLValues().toArray()))) {
+ ResultSet resultSet =
statement.executeQuery(String.format(getSQL(),
getAssertion().getSQLValues().toArray()))) {
assertResultSet(resultSet);
}
}
private void
assertExecuteQueryForPreparedStatementWithResultSetTypeAndResultSetConcurrency(final
Connection connection) throws SQLException, ParseException {
- try (PreparedStatement preparedStatement =
connection.prepareStatement(getStatement(), ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY)) {
+ try (PreparedStatement preparedStatement =
connection.prepareStatement(getSQL(), ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY)) {
for (SQLValue each : getAssertion().getSQLValues()) {
preparedStatement.setObject(each.getIndex(), each.getValue());
}
@@ -84,14 +84,14 @@ public final class AdditionalDQLIT extends BaseDQLIT {
throws SQLException, ParseException {
try (
Statement statement =
connection.createStatement(ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
- ResultSet resultSet =
statement.executeQuery(String.format(getStatement(),
getAssertion().getSQLValues().toArray()))) {
+ ResultSet resultSet =
statement.executeQuery(String.format(getSQL(),
getAssertion().getSQLValues().toArray()))) {
assertResultSet(resultSet);
}
}
private void
assertExecuteQueryForPreparedStatementWithResultSetTypeAndResultSetConcurrencyAndResultSetHoldability(final
Connection connection)
throws SQLException, ParseException {
- try (PreparedStatement preparedStatement =
connection.prepareStatement(getStatement(), ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT)) {
+ try (PreparedStatement preparedStatement =
connection.prepareStatement(getSQL(), ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT)) {
for (SQLValue each : getAssertion().getSQLValues()) {
preparedStatement.setObject(each.getIndex(), each.getValue());
}
@@ -114,7 +114,7 @@ public final class AdditionalDQLIT extends BaseDQLIT {
private void
assertExecuteForStatementWithResultSetTypeAndResultSetConcurrency(final
Connection connection) throws SQLException, ParseException {
try (Statement statement =
connection.createStatement(ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY)) {
- assertTrue("Not a query statement.",
statement.execute(String.format(getStatement(),
getAssertion().getSQLValues().toArray())));
+ assertTrue("Not a query statement.",
statement.execute(String.format(getSQL(),
getAssertion().getSQLValues().toArray())));
try (ResultSet resultSet = statement.getResultSet()) {
assertResultSet(resultSet);
}
@@ -122,7 +122,7 @@ public final class AdditionalDQLIT extends BaseDQLIT {
}
private void
assertExecuteForPreparedStatementWithResultSetTypeAndResultSetConcurrency(final
Connection connection) throws SQLException, ParseException {
- try (PreparedStatement preparedStatement =
connection.prepareStatement(getStatement(), ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY)) {
+ try (PreparedStatement preparedStatement =
connection.prepareStatement(getSQL(), ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY)) {
for (SQLValue each : getAssertion().getSQLValues()) {
preparedStatement.setObject(each.getIndex(), each.getValue());
}
@@ -146,7 +146,7 @@ public final class AdditionalDQLIT extends BaseDQLIT {
private void
assertExecuteForStatementWithResultSetTypeAndResultSetConcurrencyAndResultSetHoldability(final
Connection connection) throws SQLException, ParseException {
try (Statement statement =
connection.createStatement(ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT)) {
- assertTrue("Not a query statement.",
statement.execute(String.format(getStatement(),
getAssertion().getSQLValues().toArray())));
+ assertTrue("Not a query statement.",
statement.execute(String.format(getSQL(),
getAssertion().getSQLValues().toArray())));
try (ResultSet resultSet = statement.getResultSet()) {
assertResultSet(resultSet);
}
@@ -154,7 +154,7 @@ public final class AdditionalDQLIT extends BaseDQLIT {
}
private void
assertExecuteForPreparedStatementWithResultSetTypeAndResultSetConcurrencyAndResultSetHoldability(final
Connection connection) throws SQLException, ParseException {
- try (PreparedStatement preparedStatement =
connection.prepareStatement(getStatement(), ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT)) {
+ try (PreparedStatement preparedStatement =
connection.prepareStatement(getSQL(), ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT)) {
for (SQLValue each : getAssertion().getSQLValues()) {
preparedStatement.setObject(each.getIndex(), each.getValue());
}
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dql/GeneralDQLIT.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dql/GeneralDQLIT.java
index edb0eda..80a57a2 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dql/GeneralDQLIT.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/dql/GeneralDQLIT.java
@@ -52,13 +52,13 @@ public final class GeneralDQLIT extends BaseDQLIT {
private void assertExecuteQueryForStatement(final Connection connection)
throws SQLException, ParseException {
try (
Statement statement = connection.createStatement();
- ResultSet resultSet = statement.executeQuery(getStatement())) {
+ ResultSet resultSet = statement.executeQuery(getSQL())) {
assertResultSet(resultSet);
}
}
private void assertExecuteQueryForPreparedStatement(final Connection
connection) throws SQLException, ParseException {
- try (PreparedStatement preparedStatement =
connection.prepareStatement(getStatement())) {
+ try (PreparedStatement preparedStatement =
connection.prepareStatement(getSQL())) {
for (SQLValue each : getAssertion().getSQLValues()) {
preparedStatement.setObject(each.getIndex(), each.getValue());
}
@@ -81,7 +81,7 @@ public final class GeneralDQLIT extends BaseDQLIT {
private void assertExecuteForStatement(final Connection connection) throws
SQLException, ParseException {
try (Statement statement = connection.createStatement()) {
- assertTrue("Not a query statement.",
statement.execute(getStatement()));
+ assertTrue("Not a query statement.", statement.execute(getSQL()));
try (ResultSet resultSet = statement.getResultSet()) {
assertResultSet(resultSet);
}
@@ -89,7 +89,7 @@ public final class GeneralDQLIT extends BaseDQLIT {
}
private void assertExecuteForPreparedStatement(final Connection
connection) throws SQLException, ParseException {
- try (PreparedStatement preparedStatement =
connection.prepareStatement(getStatement())) {
+ try (PreparedStatement preparedStatement =
connection.prepareStatement(getSQL())) {
for (SQLValue each : getAssertion().getSQLValues()) {
preparedStatement.setObject(each.getIndex(), each.getValue());
}