Skip to content

Commit

Permalink
[Fix][Connector-V2] update test case
Browse files Browse the repository at this point in the history
  • Loading branch information
corgy-w committed Aug 26, 2024
1 parent ef96c1b commit a9e4d95
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
public class JdbcCatalogUtilsTest {

@Test
public void test() throws SQLException, ClassNotFoundException {
public void testCatalogUtils() throws SQLException, ClassNotFoundException {
List<JdbcSourceTableConfig> tablesConfig = new ArrayList<>();
// JdbcSourceTableConfig(tablePath=null, query=select age, name,gender from `dbs`.`user`,
// partitionColumn=null, partitionNumber=10, partitionStart=null, partitionEnd=null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
import org.apache.seatunnel.api.table.catalog.TablePath;
import org.apache.seatunnel.common.utils.JdbcUrlUtil;
import org.apache.seatunnel.connectors.seatunnel.jdbc.catalog.mysql.MySqlCatalog;
import org.apache.seatunnel.connectors.seatunnel.jdbc.config.JdbcConnectionConfig;
import org.apache.seatunnel.connectors.seatunnel.jdbc.config.JdbcSourceTableConfig;
import org.apache.seatunnel.connectors.seatunnel.jdbc.source.JdbcSourceTable;
import org.apache.seatunnel.connectors.seatunnel.jdbc.utils.JdbcCatalogUtils;
import org.apache.seatunnel.e2e.common.TestResource;
import org.apache.seatunnel.e2e.common.TestSuiteBase;
import org.apache.seatunnel.e2e.common.container.ContainerExtendedFactory;
Expand All @@ -39,12 +43,16 @@
import org.testcontainers.utility.DockerLoggerFactory;

import com.google.common.collect.Lists;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;

@Slf4j
Expand Down Expand Up @@ -189,6 +197,30 @@ public void testCatalog() {
mySqlCatalog.close();
}

@SneakyThrows
@Test
public void testCatalogWithCatalogUtils() {
List<JdbcSourceTableConfig> tablesConfig = new ArrayList<>();
JdbcSourceTableConfig tableConfig =
JdbcSourceTableConfig.builder()
.query("SELECT * FROM mysql_auto_create;")
.useSelectCount(false)
.build();
tablesConfig.add(tableConfig);
Map<TablePath, JdbcSourceTable> tables =
JdbcCatalogUtils.getTables(
JdbcConnectionConfig.builder()
.url(MysqlUrlInfo.getUrlWithDatabase().get())
.username(MYSQL_USERNAME)
.password(MYSQL_PASSWORD)
.build(),
tablesConfig);
Assertions.assertTrue(
tables.containsKey(
TablePath.of(
MysqlUrlInfo.getDefaultDatabase().get(), "mysql_auto_create")));
}

@Override
public void tearDown() throws Exception {
if (mysql_container != null) {
Expand Down

0 comments on commit a9e4d95

Please sign in to comment.