From 78252cae08f334a0df36d506493ed8a57612c2c7 Mon Sep 17 00:00:00 2001 From: ZhangCheng Date: Thu, 9 Jan 2025 19:44:02 +0800 Subject: [PATCH] Add clob data type for E2E assertion --- .../shardingsphere/test/e2e/cases/value/SQLValue.java | 1 + .../test/e2e/engine/type/dml/BaseDMLE2EIT.java | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/cases/value/SQLValue.java b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/cases/value/SQLValue.java index 72b9f043139a4..c6c85015974c1 100644 --- a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/cases/value/SQLValue.java +++ b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/cases/value/SQLValue.java @@ -60,6 +60,7 @@ private Object getValue(final String value, final String type) { case "longtext": case "mediumtext": case "json": + case "clob": return value; case "tinyint": return Byte.parseByte(value); diff --git a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/dml/BaseDMLE2EIT.java b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/dml/BaseDMLE2EIT.java index 9e732ae1c2cec..fd118fab3cedf 100644 --- a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/dml/BaseDMLE2EIT.java +++ b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/dml/BaseDMLE2EIT.java @@ -20,6 +20,7 @@ import com.google.common.base.Splitter; import com.google.common.collect.Sets; import lombok.Getter; +import lombok.SneakyThrows; import org.apache.shardingsphere.infra.database.core.type.DatabaseType; import org.apache.shardingsphere.infra.datanode.DataNode; import org.apache.shardingsphere.infra.expr.core.InlineExpressionParserFactory; @@ -48,6 +49,7 @@ import javax.xml.bind.JAXBException; import java.io.IOException; import java.nio.charset.StandardCharsets; +import java.sql.Clob; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -284,6 +286,8 @@ private void assertValue(final ResultSet actual, final int columnIndex, final St assertThat(actual.getString(columnIndex), is(expected)); } else if (Types.BINARY == actual.getMetaData().getColumnType(columnIndex)) { assertThat(actual.getObject(columnIndex), is(expected.getBytes(StandardCharsets.UTF_8))); + } else if (Types.CLOB == actual.getMetaData().getColumnType(columnIndex)) { + assertThat(getClobValue((Clob) actual.getObject(columnIndex)), is(expected)); } else { assertThat(String.valueOf(actual.getObject(columnIndex)), is(expected)); } @@ -293,6 +297,11 @@ private boolean isPostgreSQLOrOpenGaussMoney(final String columnTypeName, final return "money".equalsIgnoreCase(columnTypeName) && ("PostgreSQL".equals(databaseType.getType()) || "openGauss".equals(databaseType.getType())); } + @SneakyThrows(SQLException.class) + private static String getClobValue(final Clob value) { + return value.getSubString(1, (int) value.length()); + } + protected void assertGeneratedKeys(final AssertionTestParameter testParam, final ResultSet generatedKeys, final DatabaseType databaseType) throws SQLException { DataSet generatedKeyDataSet = null == testParam.getAssertion() || null == testParam.getAssertion().getExpectedGeneratedKeyDataFile() ? null