embulk-output-mysql 0.7.10 → 0.7.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -0
- data/build.gradle +1 -2
- data/classpath/{embulk-output-jdbc-0.7.10.jar → embulk-output-jdbc-0.7.11.jar} +0 -0
- data/classpath/{embulk-output-mysql-0.7.10.jar → embulk-output-mysql-0.7.11.jar} +0 -0
- data/src/test/java/org/embulk/output/mysql/AfterLoadTest.java +136 -0
- data/src/test/java/org/embulk/output/mysql/BeforeLoadTest.java +124 -0
- data/src/test/java/org/embulk/output/mysql/MySQLTests.java +69 -0
- data/src/test/resources/org/embulk/output/mysql/test/expect/after_load/setup.sql +8 -0
- data/src/test/resources/org/embulk/output/mysql/test/expect/after_load/test1.csv +4 -0
- data/src/test/resources/org/embulk/output/mysql/test/expect/after_load/test_expected.diff +2 -0
- data/src/test/resources/org/embulk/output/mysql/test/expect/after_load/test_insert_after_load.yml +3 -0
- data/src/test/resources/org/embulk/output/mysql/test/expect/after_load/test_insert_after_load_expected.csv +5 -0
- data/src/test/resources/org/embulk/output/mysql/test/expect/after_load/test_insert_direct_after_load.yml +3 -0
- data/src/test/resources/org/embulk/output/mysql/test/expect/after_load/test_merge_after_load.yml +3 -0
- data/src/test/resources/org/embulk/output/mysql/test/expect/after_load/test_merge_after_load_expected.csv +5 -0
- data/src/test/resources/org/embulk/output/mysql/test/expect/after_load/test_merge_direct_after_load.yml +3 -0
- data/src/test/resources/org/embulk/output/mysql/test/expect/after_load/test_replace_after_load.yml +3 -0
- data/src/test/resources/org/embulk/output/mysql/test/expect/after_load/test_replace_after_load_expected.csv +3 -0
- data/src/test/resources/org/embulk/output/mysql/test/expect/after_load/test_truncate_insert_after_load.yml +3 -0
- data/src/test/resources/org/embulk/output/mysql/test/expect/after_load/test_truncate_insert_after_load_expected.csv +3 -0
- data/src/test/resources/org/embulk/output/mysql/test/expect/before_load/setup.sql +8 -0
- data/src/test/resources/org/embulk/output/mysql/test/expect/before_load/test1.csv +4 -0
- data/src/test/resources/org/embulk/output/mysql/test/expect/before_load/test_expected.diff +2 -0
- data/src/test/resources/org/embulk/output/mysql/test/expect/before_load/test_insert_before_load.yml +3 -0
- data/src/test/resources/{mysql/data/test1.csv → org/embulk/output/mysql/test/expect/before_load/test_insert_before_load_expected.csv} +1 -0
- data/src/test/resources/org/embulk/output/mysql/test/expect/before_load/test_insert_direct_before_load.yml +3 -0
- data/src/test/resources/org/embulk/output/mysql/test/expect/before_load/test_merge_before_load.yml +3 -0
- data/src/test/resources/org/embulk/output/mysql/test/expect/before_load/test_merge_before_load_expected.csv +4 -0
- data/src/test/resources/org/embulk/output/mysql/test/expect/before_load/test_merge_direct_before_load.yml +3 -0
- data/src/test/resources/org/embulk/output/mysql/test/expect/before_load/test_truncate_insert_before_load.yml +3 -0
- data/src/test/resources/org/embulk/output/mysql/test/expect/before_load/test_truncate_insert_before_load_expected.csv +4 -0
- metadata +31 -17
- data/src/test/java/org/embulk/output/mysql/MySQLOutputPluginTest.java +0 -569
- data/src/test/resources/mysql/yml/test-insert-after-load.yml +0 -22
- data/src/test/resources/mysql/yml/test-insert-before-load.yml +0 -22
- data/src/test/resources/mysql/yml/test-insert-direct-after-load.yml +0 -22
- data/src/test/resources/mysql/yml/test-insert-direct-before-load.yml +0 -22
- data/src/test/resources/mysql/yml/test-merge-after-load.yml +0 -22
- data/src/test/resources/mysql/yml/test-merge-before-load.yml +0 -22
- data/src/test/resources/mysql/yml/test-merge-direct-after-load.yml +0 -22
- data/src/test/resources/mysql/yml/test-merge-direct-before-load.yml +0 -22
- data/src/test/resources/mysql/yml/test-replace-after-load.yml +0 -22
- data/src/test/resources/mysql/yml/test-truncate-insert-after-load.yml +0 -22
- data/src/test/resources/mysql/yml/test-truncate-insert-before-load.yml +0 -22
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-output-mysql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sadayuki Furuhashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Inserts or updates records to a table.
|
14
14
|
email:
|
@@ -19,8 +19,8 @@ extra_rdoc_files: []
|
|
19
19
|
files:
|
20
20
|
- README.md
|
21
21
|
- build.gradle
|
22
|
-
- classpath/embulk-output-jdbc-0.7.
|
23
|
-
- classpath/embulk-output-mysql-0.7.
|
22
|
+
- classpath/embulk-output-jdbc-0.7.11.jar
|
23
|
+
- classpath/embulk-output-mysql-0.7.11.jar
|
24
24
|
- classpath/mysql-connector-java-5.1.34.jar
|
25
25
|
- lib/embulk/output/mysql.rb
|
26
26
|
- src/main/java/org/embulk/output/MySQLOutputPlugin.java
|
@@ -28,19 +28,33 @@ files:
|
|
28
28
|
- src/main/java/org/embulk/output/mysql/MySQLBatchInsert.java
|
29
29
|
- src/main/java/org/embulk/output/mysql/MySQLOutputConnection.java
|
30
30
|
- src/main/java/org/embulk/output/mysql/MySQLOutputConnector.java
|
31
|
-
- src/test/java/org/embulk/output/mysql/
|
32
|
-
- src/test/
|
33
|
-
- src/test/
|
34
|
-
- src/test/resources/mysql/
|
35
|
-
- src/test/resources/mysql/
|
36
|
-
- src/test/resources/mysql/
|
37
|
-
- src/test/resources/mysql/
|
38
|
-
- src/test/resources/mysql/
|
39
|
-
- src/test/resources/mysql/
|
40
|
-
- src/test/resources/mysql/
|
41
|
-
- src/test/resources/mysql/
|
42
|
-
- src/test/resources/mysql/
|
43
|
-
- src/test/resources/mysql/
|
31
|
+
- src/test/java/org/embulk/output/mysql/AfterLoadTest.java
|
32
|
+
- src/test/java/org/embulk/output/mysql/BeforeLoadTest.java
|
33
|
+
- src/test/java/org/embulk/output/mysql/MySQLTests.java
|
34
|
+
- src/test/resources/org/embulk/output/mysql/test/expect/after_load/setup.sql
|
35
|
+
- src/test/resources/org/embulk/output/mysql/test/expect/after_load/test1.csv
|
36
|
+
- src/test/resources/org/embulk/output/mysql/test/expect/after_load/test_expected.diff
|
37
|
+
- src/test/resources/org/embulk/output/mysql/test/expect/after_load/test_insert_after_load.yml
|
38
|
+
- src/test/resources/org/embulk/output/mysql/test/expect/after_load/test_insert_after_load_expected.csv
|
39
|
+
- src/test/resources/org/embulk/output/mysql/test/expect/after_load/test_insert_direct_after_load.yml
|
40
|
+
- src/test/resources/org/embulk/output/mysql/test/expect/after_load/test_merge_after_load.yml
|
41
|
+
- src/test/resources/org/embulk/output/mysql/test/expect/after_load/test_merge_after_load_expected.csv
|
42
|
+
- src/test/resources/org/embulk/output/mysql/test/expect/after_load/test_merge_direct_after_load.yml
|
43
|
+
- src/test/resources/org/embulk/output/mysql/test/expect/after_load/test_replace_after_load.yml
|
44
|
+
- src/test/resources/org/embulk/output/mysql/test/expect/after_load/test_replace_after_load_expected.csv
|
45
|
+
- src/test/resources/org/embulk/output/mysql/test/expect/after_load/test_truncate_insert_after_load.yml
|
46
|
+
- src/test/resources/org/embulk/output/mysql/test/expect/after_load/test_truncate_insert_after_load_expected.csv
|
47
|
+
- src/test/resources/org/embulk/output/mysql/test/expect/before_load/setup.sql
|
48
|
+
- src/test/resources/org/embulk/output/mysql/test/expect/before_load/test1.csv
|
49
|
+
- src/test/resources/org/embulk/output/mysql/test/expect/before_load/test_expected.diff
|
50
|
+
- src/test/resources/org/embulk/output/mysql/test/expect/before_load/test_insert_before_load.yml
|
51
|
+
- src/test/resources/org/embulk/output/mysql/test/expect/before_load/test_insert_before_load_expected.csv
|
52
|
+
- src/test/resources/org/embulk/output/mysql/test/expect/before_load/test_insert_direct_before_load.yml
|
53
|
+
- src/test/resources/org/embulk/output/mysql/test/expect/before_load/test_merge_before_load.yml
|
54
|
+
- src/test/resources/org/embulk/output/mysql/test/expect/before_load/test_merge_before_load_expected.csv
|
55
|
+
- src/test/resources/org/embulk/output/mysql/test/expect/before_load/test_merge_direct_before_load.yml
|
56
|
+
- src/test/resources/org/embulk/output/mysql/test/expect/before_load/test_truncate_insert_before_load.yml
|
57
|
+
- src/test/resources/org/embulk/output/mysql/test/expect/before_load/test_truncate_insert_before_load_expected.csv
|
44
58
|
homepage: https://github.com/embulk/embulk-output-jdbc
|
45
59
|
licenses:
|
46
60
|
- Apache 2.0
|
@@ -1,569 +0,0 @@
|
|
1
|
-
package org.embulk.output.mysql;
|
2
|
-
|
3
|
-
import static java.util.Locale.ENGLISH;
|
4
|
-
import static org.junit.Assert.assertEquals;
|
5
|
-
|
6
|
-
import java.sql.Connection;
|
7
|
-
import java.sql.DriverManager;
|
8
|
-
import java.sql.SQLException;
|
9
|
-
import java.util.Iterator;
|
10
|
-
import java.util.List;
|
11
|
-
|
12
|
-
import org.embulk.output.AbstractJdbcOutputPluginTest;
|
13
|
-
import org.embulk.output.MySQLOutputPlugin;
|
14
|
-
import org.embulk.spi.OutputPlugin;
|
15
|
-
import org.junit.Test;
|
16
|
-
|
17
|
-
|
18
|
-
public class MySQLOutputPluginTest extends AbstractJdbcOutputPluginTest
|
19
|
-
{
|
20
|
-
@Override
|
21
|
-
protected void prepare() throws SQLException
|
22
|
-
{
|
23
|
-
tester.addPlugin(OutputPlugin.class, "mysql", MySQLOutputPlugin.class);
|
24
|
-
|
25
|
-
try {
|
26
|
-
connect();
|
27
|
-
} catch (SQLException e) {
|
28
|
-
System.err.println(e);
|
29
|
-
System.err.println(String.format(ENGLISH, "Warning: prepare a schema on MySQL (server = %s, port = %d, database = %s, user = %s, password = %s).",
|
30
|
-
getHost(), getPort(), getDatabase(), getUser(), getPassword()));
|
31
|
-
return;
|
32
|
-
}
|
33
|
-
|
34
|
-
enabled = true;
|
35
|
-
}
|
36
|
-
|
37
|
-
@Test
|
38
|
-
public void testInsertDirectBeforeLoad() throws Exception
|
39
|
-
{
|
40
|
-
if (!enabled) {
|
41
|
-
return;
|
42
|
-
}
|
43
|
-
|
44
|
-
String table = "test1";
|
45
|
-
|
46
|
-
dropTable(table);
|
47
|
-
createTable(table);
|
48
|
-
executeSQL(String.format("INSERT INTO %s VALUES('B001', 0, 'z')", table));
|
49
|
-
executeSQL(String.format("INSERT INTO %s VALUES('B002', 9, 'z')", table));
|
50
|
-
|
51
|
-
test("/mysql/yml/test-insert-direct-before-load.yml");
|
52
|
-
|
53
|
-
List<List<Object>> rows = select(table);
|
54
|
-
assertEquals(4, rows.size());
|
55
|
-
Iterator<List<Object>> i1 = rows.iterator();
|
56
|
-
{
|
57
|
-
Iterator<Object> i2 = i1.next().iterator();
|
58
|
-
assertEquals("A001", i2.next());
|
59
|
-
assertEquals(9, i2.next());
|
60
|
-
assertEquals("a", i2.next());
|
61
|
-
}
|
62
|
-
{
|
63
|
-
Iterator<Object> i2 = i1.next().iterator();
|
64
|
-
assertEquals("A002", i2.next());
|
65
|
-
assertEquals(0, i2.next());
|
66
|
-
assertEquals("b", i2.next());
|
67
|
-
}
|
68
|
-
{
|
69
|
-
Iterator<Object> i2 = i1.next().iterator();
|
70
|
-
assertEquals("A003", i2.next());
|
71
|
-
assertEquals(9, i2.next());
|
72
|
-
assertEquals("c", i2.next());
|
73
|
-
}
|
74
|
-
{
|
75
|
-
Iterator<Object> i2 = i1.next().iterator();
|
76
|
-
assertEquals("B001", i2.next());
|
77
|
-
assertEquals(0, i2.next());
|
78
|
-
assertEquals("z", i2.next());
|
79
|
-
}
|
80
|
-
}
|
81
|
-
|
82
|
-
@Test
|
83
|
-
public void testInsertBeforeLoad() throws Exception
|
84
|
-
{
|
85
|
-
if (!enabled) {
|
86
|
-
return;
|
87
|
-
}
|
88
|
-
|
89
|
-
String table = "test1";
|
90
|
-
|
91
|
-
dropTable(table);
|
92
|
-
createTable(table);
|
93
|
-
executeSQL(String.format("INSERT INTO %s VALUES('B001', 0, 'z')", table));
|
94
|
-
executeSQL(String.format("INSERT INTO %s VALUES('B002', 9, 'z')", table));
|
95
|
-
|
96
|
-
test("/mysql/yml/test-insert-before-load.yml");
|
97
|
-
|
98
|
-
List<List<Object>> rows = select(table);
|
99
|
-
assertEquals(4, rows.size());
|
100
|
-
Iterator<List<Object>> i1 = rows.iterator();
|
101
|
-
{
|
102
|
-
Iterator<Object> i2 = i1.next().iterator();
|
103
|
-
assertEquals("A001", i2.next());
|
104
|
-
assertEquals(9, i2.next());
|
105
|
-
assertEquals("a", i2.next());
|
106
|
-
}
|
107
|
-
{
|
108
|
-
Iterator<Object> i2 = i1.next().iterator();
|
109
|
-
assertEquals("A002", i2.next());
|
110
|
-
assertEquals(0, i2.next());
|
111
|
-
assertEquals("b", i2.next());
|
112
|
-
}
|
113
|
-
{
|
114
|
-
Iterator<Object> i2 = i1.next().iterator();
|
115
|
-
assertEquals("A003", i2.next());
|
116
|
-
assertEquals(9, i2.next());
|
117
|
-
assertEquals("c", i2.next());
|
118
|
-
}
|
119
|
-
{
|
120
|
-
Iterator<Object> i2 = i1.next().iterator();
|
121
|
-
assertEquals("B001", i2.next());
|
122
|
-
assertEquals(0, i2.next());
|
123
|
-
assertEquals("z", i2.next());
|
124
|
-
}
|
125
|
-
}
|
126
|
-
|
127
|
-
@Test
|
128
|
-
public void testTruncateInsertBeforeLoad() throws Exception
|
129
|
-
{
|
130
|
-
if (!enabled) {
|
131
|
-
return;
|
132
|
-
}
|
133
|
-
|
134
|
-
String table = "test1";
|
135
|
-
|
136
|
-
dropTable(table);
|
137
|
-
createTable(table);
|
138
|
-
executeSQL(String.format("INSERT INTO %s VALUES('B001', 0, 'z')", table));
|
139
|
-
executeSQL(String.format("INSERT INTO %s VALUES('B002', 9, 'z')", table));
|
140
|
-
|
141
|
-
test("/mysql/yml/test-truncate-insert-before-load.yml");
|
142
|
-
|
143
|
-
List<List<Object>> rows = select(table);
|
144
|
-
assertEquals(4, rows.size());
|
145
|
-
Iterator<List<Object>> i1 = rows.iterator();
|
146
|
-
{
|
147
|
-
Iterator<Object> i2 = i1.next().iterator();
|
148
|
-
assertEquals("A001", i2.next());
|
149
|
-
assertEquals(9, i2.next());
|
150
|
-
assertEquals("a", i2.next());
|
151
|
-
}
|
152
|
-
{
|
153
|
-
Iterator<Object> i2 = i1.next().iterator();
|
154
|
-
assertEquals("A002", i2.next());
|
155
|
-
assertEquals(0, i2.next());
|
156
|
-
assertEquals("b", i2.next());
|
157
|
-
}
|
158
|
-
{
|
159
|
-
Iterator<Object> i2 = i1.next().iterator();
|
160
|
-
assertEquals("A003", i2.next());
|
161
|
-
assertEquals(9, i2.next());
|
162
|
-
assertEquals("c", i2.next());
|
163
|
-
}
|
164
|
-
{
|
165
|
-
Iterator<Object> i2 = i1.next().iterator();
|
166
|
-
assertEquals("C001", i2.next());
|
167
|
-
assertEquals(0, i2.next());
|
168
|
-
assertEquals("x", i2.next());
|
169
|
-
}
|
170
|
-
}
|
171
|
-
|
172
|
-
@Test
|
173
|
-
public void testMergeDirectBeforeLoad() throws Exception
|
174
|
-
{
|
175
|
-
if (!enabled) {
|
176
|
-
return;
|
177
|
-
}
|
178
|
-
|
179
|
-
String table = "test1";
|
180
|
-
|
181
|
-
dropTable(table);
|
182
|
-
createTable(table);
|
183
|
-
executeSQL(String.format("INSERT INTO %s VALUES('A002', 1, 'y')", table));
|
184
|
-
executeSQL(String.format("INSERT INTO %s VALUES('A003', 1, 'y')", table));
|
185
|
-
executeSQL(String.format("INSERT INTO %s VALUES('B001', 0, 'z')", table));
|
186
|
-
executeSQL(String.format("INSERT INTO %s VALUES('B002', 9, 'z')", table));
|
187
|
-
|
188
|
-
test("/mysql/yml/test-merge-direct-before-load.yml");
|
189
|
-
|
190
|
-
List<List<Object>> rows = select(table);
|
191
|
-
assertEquals(4, rows.size());
|
192
|
-
Iterator<List<Object>> i1 = rows.iterator();
|
193
|
-
{
|
194
|
-
Iterator<Object> i2 = i1.next().iterator();
|
195
|
-
assertEquals("A001", i2.next());
|
196
|
-
assertEquals(9, i2.next());
|
197
|
-
assertEquals("a", i2.next());
|
198
|
-
}
|
199
|
-
{
|
200
|
-
Iterator<Object> i2 = i1.next().iterator();
|
201
|
-
assertEquals("A002", i2.next());
|
202
|
-
assertEquals(0, i2.next());
|
203
|
-
assertEquals("b", i2.next());
|
204
|
-
}
|
205
|
-
{
|
206
|
-
Iterator<Object> i2 = i1.next().iterator();
|
207
|
-
assertEquals("A003", i2.next());
|
208
|
-
assertEquals(9, i2.next());
|
209
|
-
assertEquals("c", i2.next());
|
210
|
-
}
|
211
|
-
{
|
212
|
-
Iterator<Object> i2 = i1.next().iterator();
|
213
|
-
assertEquals("B001", i2.next());
|
214
|
-
assertEquals(0, i2.next());
|
215
|
-
assertEquals("z", i2.next());
|
216
|
-
}
|
217
|
-
}
|
218
|
-
|
219
|
-
@Test
|
220
|
-
public void testMergeBeforeLoad() throws Exception
|
221
|
-
{
|
222
|
-
if (!enabled) {
|
223
|
-
return;
|
224
|
-
}
|
225
|
-
|
226
|
-
String table = "test1";
|
227
|
-
|
228
|
-
dropTable(table);
|
229
|
-
createTable(table);
|
230
|
-
executeSQL(String.format("INSERT INTO %s VALUES('A002', 1, 'y')", table));
|
231
|
-
executeSQL(String.format("INSERT INTO %s VALUES('A003', 1, 'y')", table));
|
232
|
-
executeSQL(String.format("INSERT INTO %s VALUES('B001', 0, 'z')", table));
|
233
|
-
executeSQL(String.format("INSERT INTO %s VALUES('B002', 9, 'z')", table));
|
234
|
-
|
235
|
-
test("/mysql/yml/test-merge-before-load.yml");
|
236
|
-
|
237
|
-
List<List<Object>> rows = select(table);
|
238
|
-
assertEquals(4, rows.size());
|
239
|
-
Iterator<List<Object>> i1 = rows.iterator();
|
240
|
-
{
|
241
|
-
Iterator<Object> i2 = i1.next().iterator();
|
242
|
-
assertEquals("A001", i2.next());
|
243
|
-
assertEquals(9, i2.next());
|
244
|
-
assertEquals("a", i2.next());
|
245
|
-
}
|
246
|
-
{
|
247
|
-
Iterator<Object> i2 = i1.next().iterator();
|
248
|
-
assertEquals("A002", i2.next());
|
249
|
-
assertEquals(0, i2.next());
|
250
|
-
assertEquals("b", i2.next());
|
251
|
-
}
|
252
|
-
{
|
253
|
-
Iterator<Object> i2 = i1.next().iterator();
|
254
|
-
assertEquals("A003", i2.next());
|
255
|
-
assertEquals(9, i2.next());
|
256
|
-
assertEquals("c", i2.next());
|
257
|
-
}
|
258
|
-
{
|
259
|
-
Iterator<Object> i2 = i1.next().iterator();
|
260
|
-
assertEquals("B001", i2.next());
|
261
|
-
assertEquals(0, i2.next());
|
262
|
-
assertEquals("z", i2.next());
|
263
|
-
}
|
264
|
-
}
|
265
|
-
|
266
|
-
@Test
|
267
|
-
public void testInsertDirectAfterLoad() throws Exception
|
268
|
-
{
|
269
|
-
if (!enabled) {
|
270
|
-
return;
|
271
|
-
}
|
272
|
-
|
273
|
-
String table = "test1";
|
274
|
-
|
275
|
-
dropTable(table);
|
276
|
-
createTable(table);
|
277
|
-
executeSQL(String.format("INSERT INTO %s VALUES('B001', 0, 'z')", table));
|
278
|
-
executeSQL(String.format("INSERT INTO %s VALUES('B002', 9, 'z')", table));
|
279
|
-
|
280
|
-
test("/mysql/yml/test-insert-direct-after-load.yml");
|
281
|
-
|
282
|
-
List<List<Object>> rows = select(table);
|
283
|
-
assertEquals(5, rows.size());
|
284
|
-
Iterator<List<Object>> i1 = rows.iterator();
|
285
|
-
{
|
286
|
-
Iterator<Object> i2 = i1.next().iterator();
|
287
|
-
assertEquals("A001", i2.next());
|
288
|
-
assertEquals(9, i2.next());
|
289
|
-
assertEquals("x", i2.next());
|
290
|
-
}
|
291
|
-
{
|
292
|
-
Iterator<Object> i2 = i1.next().iterator();
|
293
|
-
assertEquals("A002", i2.next());
|
294
|
-
assertEquals(0, i2.next());
|
295
|
-
assertEquals("b", i2.next());
|
296
|
-
}
|
297
|
-
{
|
298
|
-
Iterator<Object> i2 = i1.next().iterator();
|
299
|
-
assertEquals("A003", i2.next());
|
300
|
-
assertEquals(9, i2.next());
|
301
|
-
assertEquals("x", i2.next());
|
302
|
-
}
|
303
|
-
{
|
304
|
-
Iterator<Object> i2 = i1.next().iterator();
|
305
|
-
assertEquals("B001", i2.next());
|
306
|
-
assertEquals(0, i2.next());
|
307
|
-
assertEquals("z", i2.next());
|
308
|
-
}
|
309
|
-
{
|
310
|
-
Iterator<Object> i2 = i1.next().iterator();
|
311
|
-
assertEquals("B002", i2.next());
|
312
|
-
assertEquals(9, i2.next());
|
313
|
-
assertEquals("x", i2.next());
|
314
|
-
}
|
315
|
-
}
|
316
|
-
|
317
|
-
@Test
|
318
|
-
public void testInsertAfterLoad() throws Exception
|
319
|
-
{
|
320
|
-
if (!enabled) {
|
321
|
-
return;
|
322
|
-
}
|
323
|
-
|
324
|
-
String table = "test1";
|
325
|
-
|
326
|
-
dropTable(table);
|
327
|
-
createTable(table);
|
328
|
-
executeSQL(String.format("INSERT INTO %s VALUES('B001', 0, 'z')", table));
|
329
|
-
executeSQL(String.format("INSERT INTO %s VALUES('B002', 9, 'z')", table));
|
330
|
-
|
331
|
-
test("/mysql/yml/test-insert-after-load.yml");
|
332
|
-
|
333
|
-
List<List<Object>> rows = select(table);
|
334
|
-
assertEquals(5, rows.size());
|
335
|
-
Iterator<List<Object>> i1 = rows.iterator();
|
336
|
-
{
|
337
|
-
Iterator<Object> i2 = i1.next().iterator();
|
338
|
-
assertEquals("A001", i2.next());
|
339
|
-
assertEquals(9, i2.next());
|
340
|
-
assertEquals("x", i2.next());
|
341
|
-
}
|
342
|
-
{
|
343
|
-
Iterator<Object> i2 = i1.next().iterator();
|
344
|
-
assertEquals("A002", i2.next());
|
345
|
-
assertEquals(0, i2.next());
|
346
|
-
assertEquals("b", i2.next());
|
347
|
-
}
|
348
|
-
{
|
349
|
-
Iterator<Object> i2 = i1.next().iterator();
|
350
|
-
assertEquals("A003", i2.next());
|
351
|
-
assertEquals(9, i2.next());
|
352
|
-
assertEquals("x", i2.next());
|
353
|
-
}
|
354
|
-
{
|
355
|
-
Iterator<Object> i2 = i1.next().iterator();
|
356
|
-
assertEquals("B001", i2.next());
|
357
|
-
assertEquals(0, i2.next());
|
358
|
-
assertEquals("z", i2.next());
|
359
|
-
}
|
360
|
-
{
|
361
|
-
Iterator<Object> i2 = i1.next().iterator();
|
362
|
-
assertEquals("B002", i2.next());
|
363
|
-
assertEquals(9, i2.next());
|
364
|
-
assertEquals("x", i2.next());
|
365
|
-
}
|
366
|
-
}
|
367
|
-
|
368
|
-
@Test
|
369
|
-
public void testTruncateInsertAfterLoad() throws Exception
|
370
|
-
{
|
371
|
-
if (!enabled) {
|
372
|
-
return;
|
373
|
-
}
|
374
|
-
|
375
|
-
String table = "test1";
|
376
|
-
|
377
|
-
dropTable(table);
|
378
|
-
createTable(table);
|
379
|
-
executeSQL(String.format("INSERT INTO %s VALUES('B001', 0, 'z')", table));
|
380
|
-
executeSQL(String.format("INSERT INTO %s VALUES('B002', 9, 'z')", table));
|
381
|
-
|
382
|
-
test("/mysql/yml/test-truncate-insert-after-load.yml");
|
383
|
-
|
384
|
-
List<List<Object>> rows = select(table);
|
385
|
-
assertEquals(3, rows.size());
|
386
|
-
Iterator<List<Object>> i1 = rows.iterator();
|
387
|
-
{
|
388
|
-
Iterator<Object> i2 = i1.next().iterator();
|
389
|
-
assertEquals("A001", i2.next());
|
390
|
-
assertEquals(9, i2.next());
|
391
|
-
assertEquals("x", i2.next());
|
392
|
-
}
|
393
|
-
{
|
394
|
-
Iterator<Object> i2 = i1.next().iterator();
|
395
|
-
assertEquals("A002", i2.next());
|
396
|
-
assertEquals(0, i2.next());
|
397
|
-
assertEquals("b", i2.next());
|
398
|
-
}
|
399
|
-
{
|
400
|
-
Iterator<Object> i2 = i1.next().iterator();
|
401
|
-
assertEquals("A003", i2.next());
|
402
|
-
assertEquals(9, i2.next());
|
403
|
-
assertEquals("x", i2.next());
|
404
|
-
}
|
405
|
-
}
|
406
|
-
|
407
|
-
@Test
|
408
|
-
public void testReplaceAfterLoad() throws Exception
|
409
|
-
{
|
410
|
-
if (!enabled) {
|
411
|
-
return;
|
412
|
-
}
|
413
|
-
|
414
|
-
String table = "test1";
|
415
|
-
|
416
|
-
dropTable(table);
|
417
|
-
createTable(table);
|
418
|
-
executeSQL(String.format("INSERT INTO %s VALUES('B001', 0, 'z')", table));
|
419
|
-
executeSQL(String.format("INSERT INTO %s VALUES('B002', 9, 'z')", table));
|
420
|
-
|
421
|
-
test("/mysql/yml/test-replace-after-load.yml");
|
422
|
-
|
423
|
-
List<List<Object>> rows = select(table);
|
424
|
-
assertEquals(3, rows.size());
|
425
|
-
Iterator<List<Object>> i1 = rows.iterator();
|
426
|
-
{
|
427
|
-
Iterator<Object> i2 = i1.next().iterator();
|
428
|
-
assertEquals("A001", i2.next());
|
429
|
-
assertEquals(9L, i2.next());
|
430
|
-
assertEquals("x", i2.next());
|
431
|
-
}
|
432
|
-
{
|
433
|
-
Iterator<Object> i2 = i1.next().iterator();
|
434
|
-
assertEquals("A002", i2.next());
|
435
|
-
assertEquals(0L, i2.next());
|
436
|
-
assertEquals("b", i2.next());
|
437
|
-
}
|
438
|
-
{
|
439
|
-
Iterator<Object> i2 = i1.next().iterator();
|
440
|
-
assertEquals("A003", i2.next());
|
441
|
-
assertEquals(9L, i2.next());
|
442
|
-
assertEquals("x", i2.next());
|
443
|
-
}
|
444
|
-
}
|
445
|
-
|
446
|
-
@Test
|
447
|
-
public void testMergeDirectAfterLoad() throws Exception
|
448
|
-
{
|
449
|
-
if (!enabled) {
|
450
|
-
return;
|
451
|
-
}
|
452
|
-
|
453
|
-
String table = "test1";
|
454
|
-
|
455
|
-
dropTable(table);
|
456
|
-
createTable(table);
|
457
|
-
executeSQL(String.format("INSERT INTO %s VALUES('A002', 1, 'y')", table));
|
458
|
-
executeSQL(String.format("INSERT INTO %s VALUES('A003', 1, 'y')", table));
|
459
|
-
executeSQL(String.format("INSERT INTO %s VALUES('B001', 0, 'z')", table));
|
460
|
-
executeSQL(String.format("INSERT INTO %s VALUES('B002', 9, 'z')", table));
|
461
|
-
|
462
|
-
test("/mysql/yml/test-merge-direct-after-load.yml");
|
463
|
-
|
464
|
-
List<List<Object>> rows = select(table);
|
465
|
-
assertEquals(5, rows.size());
|
466
|
-
Iterator<List<Object>> i1 = rows.iterator();
|
467
|
-
{
|
468
|
-
Iterator<Object> i2 = i1.next().iterator();
|
469
|
-
assertEquals("A001", i2.next());
|
470
|
-
assertEquals(9, i2.next());
|
471
|
-
assertEquals("x", i2.next());
|
472
|
-
}
|
473
|
-
{
|
474
|
-
Iterator<Object> i2 = i1.next().iterator();
|
475
|
-
assertEquals("A002", i2.next());
|
476
|
-
assertEquals(0, i2.next());
|
477
|
-
assertEquals("b", i2.next());
|
478
|
-
}
|
479
|
-
{
|
480
|
-
Iterator<Object> i2 = i1.next().iterator();
|
481
|
-
assertEquals("A003", i2.next());
|
482
|
-
assertEquals(9, i2.next());
|
483
|
-
assertEquals("x", i2.next());
|
484
|
-
}
|
485
|
-
{
|
486
|
-
Iterator<Object> i2 = i1.next().iterator();
|
487
|
-
assertEquals("B001", i2.next());
|
488
|
-
assertEquals(0, i2.next());
|
489
|
-
assertEquals("z", i2.next());
|
490
|
-
}
|
491
|
-
{
|
492
|
-
Iterator<Object> i2 = i1.next().iterator();
|
493
|
-
assertEquals("B002", i2.next());
|
494
|
-
assertEquals(9, i2.next());
|
495
|
-
assertEquals("x", i2.next());
|
496
|
-
}
|
497
|
-
}
|
498
|
-
|
499
|
-
@Test
|
500
|
-
public void testMergeAfterLoad() throws Exception
|
501
|
-
{
|
502
|
-
if (!enabled) {
|
503
|
-
return;
|
504
|
-
}
|
505
|
-
|
506
|
-
String table = "test1";
|
507
|
-
|
508
|
-
dropTable(table);
|
509
|
-
createTable(table);
|
510
|
-
executeSQL(String.format("INSERT INTO %s VALUES('A002', 1, 'y')", table));
|
511
|
-
executeSQL(String.format("INSERT INTO %s VALUES('A003', 1, 'y')", table));
|
512
|
-
executeSQL(String.format("INSERT INTO %s VALUES('B001', 0, 'z')", table));
|
513
|
-
executeSQL(String.format("INSERT INTO %s VALUES('B002', 9, 'z')", table));
|
514
|
-
|
515
|
-
test("/mysql/yml/test-merge-after-load.yml");
|
516
|
-
|
517
|
-
List<List<Object>> rows = select(table);
|
518
|
-
assertEquals(5, rows.size());
|
519
|
-
Iterator<List<Object>> i1 = rows.iterator();
|
520
|
-
{
|
521
|
-
Iterator<Object> i2 = i1.next().iterator();
|
522
|
-
assertEquals("A001", i2.next());
|
523
|
-
assertEquals(9, i2.next());
|
524
|
-
assertEquals("x", i2.next());
|
525
|
-
}
|
526
|
-
{
|
527
|
-
Iterator<Object> i2 = i1.next().iterator();
|
528
|
-
assertEquals("A002", i2.next());
|
529
|
-
assertEquals(0, i2.next());
|
530
|
-
assertEquals("b", i2.next());
|
531
|
-
}
|
532
|
-
{
|
533
|
-
Iterator<Object> i2 = i1.next().iterator();
|
534
|
-
assertEquals("A003", i2.next());
|
535
|
-
assertEquals(9, i2.next());
|
536
|
-
assertEquals("x", i2.next());
|
537
|
-
}
|
538
|
-
{
|
539
|
-
Iterator<Object> i2 = i1.next().iterator();
|
540
|
-
assertEquals("B001", i2.next());
|
541
|
-
assertEquals(0, i2.next());
|
542
|
-
assertEquals("z", i2.next());
|
543
|
-
}
|
544
|
-
{
|
545
|
-
Iterator<Object> i2 = i1.next().iterator();
|
546
|
-
assertEquals("B002", i2.next());
|
547
|
-
assertEquals(9, i2.next());
|
548
|
-
assertEquals("x", i2.next());
|
549
|
-
}
|
550
|
-
}
|
551
|
-
|
552
|
-
private void createTable(String table) throws SQLException
|
553
|
-
{
|
554
|
-
String sql = String.format("create table %s ("
|
555
|
-
+ "id char(4),"
|
556
|
-
+ "int_item int,"
|
557
|
-
+ "varchar_item varchar(8),"
|
558
|
-
+ "primary key (id))", table);
|
559
|
-
executeSQL(sql);
|
560
|
-
}
|
561
|
-
|
562
|
-
@Override
|
563
|
-
protected Connection connect() throws SQLException
|
564
|
-
{
|
565
|
-
return DriverManager.getConnection(String.format(ENGLISH, "jdbc:mysql://%s:%d/%s", getHost(), getPort(), getDatabase()),
|
566
|
-
getUser(), getPassword());
|
567
|
-
}
|
568
|
-
|
569
|
-
}
|