You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by GitBox <gi...@apache.org> on 2022/10/13 09:49:44 UTC

[GitHub] [incubator-seatunnel] liugddx commented on a diff in pull request #3089: [Feature][Connector-V2][JDBC] support sqlite

liugddx commented on code in PR #3089:
URL: https://github.com/apache/incubator-seatunnel/pull/3089#discussion_r994420396


##########
seatunnel-e2e/seatunnel-flink-connector-v2-e2e/connector-jdbc-flink-e2e/src/test/java/org/apache/seatunnel/e2e/flink/v2/jdbc/JdbcSqliteIT.java:
##########
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.seatunnel.e2e.flink.v2.jdbc;
+
+import org.apache.seatunnel.e2e.flink.FlinkContainer;
+
+import lombok.extern.slf4j.Slf4j;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.testcontainers.containers.Container;
+import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.images.builder.Transferable;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+@Slf4j
+public class JdbcSqliteIT extends FlinkContainer {
+
+    private static final String SQLITE_USER = "";
+    private static final String SQLITE_PASSWORD = "";
+    private static final String SQLITE_DRIVER = "org.sqlite.JDBC";
+    private String tmpdir;
+    private static final List<List<Object>> TEST_DATASET = generateTestDataset();
+    private static final String THIRD_PARTY_PLUGINS_URL = "https://repo1.maven.org/maven2/org/xerial/sqlite-jdbc/3.39.3.0/sqlite-jdbc-3.39.3.0.jar";
+
+    private Connection jdbcConnection;
+
+    private void initTestDb() throws ClassNotFoundException, SQLException {
+        tmpdir = System.getProperty("java.io.tmpdir");
+        Class.forName(SQLITE_DRIVER);
+        jdbcConnection = DriverManager.getConnection("jdbc:sqlite:" + tmpdir + "test.db", SQLITE_USER, SQLITE_PASSWORD);
+        initializeJdbcTable();
+        batchInsertData();
+    }
+
+    private void initializeJdbcTable() throws SQLException {
+        try (Statement statement = jdbcConnection.createStatement()) {
+            statement.execute("DROP TABLE IF EXISTS source");
+            statement.execute("DROP TABLE IF EXISTS sink");
+            String createSource = "CREATE TABLE source (\n" +
+                    "age INT NOT NULL,\n" +
+                    "name VARCHAR(255) NOT NULL\n" +
+                    ")";
+            String createSink = "CREATE TABLE sink (\n" +
+                    "age INT NOT NULL,\n" +
+                    "name VARCHAR(255) NOT NULL\n" +
+                    ")";

Review Comment:
   Please test all field types



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org