34
34
import java .util .Map ;
35
35
import java .util .concurrent .ThreadLocalRandom ;
36
36
37
+ import io .confluent .connect .jdbc .sink .dialect .DbDialect ;
38
+ import io .confluent .connect .jdbc .sink .dialect .SqliteDialect ;
37
39
import io .confluent .connect .jdbc .sink .metadata .DbTable ;
38
40
39
41
import static junit .framework .TestCase .assertTrue ;
@@ -53,6 +55,13 @@ public void tearDown() throws IOException, SQLException {
53
55
sqliteHelper .tearDown ();
54
56
}
55
57
58
+ private JdbcDbWriter newWriter (Map <String , String > props ) {
59
+ final JdbcSinkConfig config = new JdbcSinkConfig (props );
60
+ final DbDialect dbDialect = new SqliteDialect ();
61
+ final DbStructure dbStructure = new DbStructure (dbDialect );
62
+ return new JdbcDbWriter (config , dbDialect , dbStructure );
63
+ }
64
+
56
65
@ Test
57
66
public void autoCreateWithAutoEvolve () throws SQLException {
58
67
String topic = "books" ;
@@ -64,7 +73,7 @@ public void autoCreateWithAutoEvolve() throws SQLException {
64
73
props .put ("pk.mode" , "record_key" );
65
74
props .put ("pk.fields" , "id" ); // assigned name for the primitive key
66
75
67
- JdbcDbWriter writer = new JdbcDbWriter ( new JdbcSinkConfig ( props ) );
76
+ JdbcDbWriter writer = newWriter ( props );
68
77
69
78
Schema keySchema = Schema .INT64_SCHEMA ;
70
79
@@ -151,7 +160,7 @@ private void writeSameRecordTwiceExpectingSingleUpdate(
151
160
props .put ("pk.fields" , pkFields );
152
161
props .put ("insert.mode" , insertMode .toString ());
153
162
154
- JdbcDbWriter writer = new JdbcDbWriter ( new JdbcSinkConfig ( props ) );
163
+ JdbcDbWriter writer = newWriter ( props );
155
164
156
165
Schema keySchema = SchemaBuilder .struct ()
157
166
.field ("id" , SchemaBuilder .INT64_SCHEMA );
@@ -231,7 +240,8 @@ public void sameRecordNTimes() throws SQLException {
231
240
props .put ("table.name.format" , tableName );
232
241
props .put ("batch.size" , String .valueOf (ThreadLocalRandom .current ().nextInt (20 , 100 )));
233
242
234
- JdbcDbWriter writer = new JdbcDbWriter (new JdbcSinkConfig (props ));
243
+ JdbcDbWriter writer = newWriter (props );
244
+
235
245
writer .write (Collections .nCopies (
236
246
numRecords ,
237
247
new SinkRecord ("topic" , 0 , null , null , schema , struct , 0 )
0 commit comments