sijie commented on a change in pull request #2440: Issue 2313: create a JDBC 
sink connector
URL: https://github.com/apache/incubator-pulsar/pull/2440#discussion_r212717520
 
 

 ##########
 File path: 
tests/integration/src/test/java/org/apache/pulsar/tests/integration/io/JdbcSinkTester.java
 ##########
 @@ -0,0 +1,134 @@
+/**
+ * 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.pulsar.tests.integration.io;
+
+import static com.google.common.base.Preconditions.checkState;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.fail;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.util.Map;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.pulsar.client.impl.schema.AvroSchema;
+import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.containers.MySQLContainer;
+
+/**
+ * A tester for testing jdbc sink.
+ * This will use MySql as DB server
+ */
+@Slf4j
+public class JdbcSinkTester extends SinkTester {
+
+    /**
+     * A Simple class to test jdbc class,
+     *
+     */
+    @Data
+    @ToString
+    @EqualsAndHashCode
+    public static class Foo {
+        private final String field1;
+        private final String field2;
+        private final int field3;
+    }
+
+    private static final String NAME = "jdbc";
+
+    private MySQLContainer mySQLContainer;
+    private AvroSchema<Foo> schema = AvroSchema.of(Foo.class);
+    private String tableName = "test";
+    private Connection connection;
+
+    public JdbcSinkTester() {
+        super(NAME);
+
+        // container default value is test
+        sinkConfig.put("userName", "test");
+        sinkConfig.put("password", "test");
+        sinkConfig.put("tableName", tableName);
+
+        // prepare schema
+        sinkConfig.put("schema",  new 
String(schema.getSchemaInfo().getSchema()));
+        log.info("schema: {}", new String(schema.getSchemaInfo().getSchema()));
+        sinkConfig.put("batchSize", 1);
+    }
+
+    @Override
+    public void findSinkServiceContainer(Map<String, GenericContainer<?>> 
containers) {
+        GenericContainer<?> container = containers.get(NAME);
+        checkState(container instanceof MySQLContainer,
+            "No kafka service found in the cluster");
 
 Review comment:
   No Mysql Service found

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to