embulk-output-oracle 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +160 -160
  3. data/build.gradle +6 -6
  4. data/classpath/{embulk-output-jdbc-0.4.0.jar → embulk-output-jdbc-0.4.1.jar} +0 -0
  5. data/classpath/{embulk-output-oracle-0.4.0.jar → embulk-output-oracle-0.4.1.jar} +0 -0
  6. data/lib/embulk/output/oracle.rb +3 -3
  7. data/src/main/cpp/common/dir-path-load.cpp +424 -424
  8. data/src/main/cpp/common/dir-path-load.h +36 -36
  9. data/src/main/cpp/common/embulk-output-oracle.cpp +196 -196
  10. data/src/main/cpp/common/org_embulk_output_oracle_oci_OCI.h +77 -77
  11. data/src/main/cpp/linux/build.sh +21 -21
  12. data/src/main/cpp/win/build.bat +31 -31
  13. data/src/main/cpp/win/dllmain.cpp +25 -25
  14. data/src/main/cpp/win/embulk-output-oracle.sln +39 -39
  15. data/src/main/cpp/win/embulk-output-oracle.vcxproj +175 -175
  16. data/src/main/java/org/embulk/output/OracleOutputPlugin.java +153 -153
  17. data/src/main/java/org/embulk/output/oracle/DirectBatchInsert.java +290 -290
  18. data/src/main/java/org/embulk/output/oracle/InsertMethod.java +8 -8
  19. data/src/main/java/org/embulk/output/oracle/OracleCharset.java +32 -32
  20. data/src/main/java/org/embulk/output/oracle/OracleOutputConnection.java +165 -165
  21. data/src/main/java/org/embulk/output/oracle/OracleOutputConnector.java +49 -49
  22. data/src/main/java/org/embulk/output/oracle/TimestampFormat.java +37 -37
  23. data/src/main/java/org/embulk/output/oracle/oci/ColumnDefinition.java +26 -26
  24. data/src/main/java/org/embulk/output/oracle/oci/OCI.java +139 -139
  25. data/src/main/java/org/embulk/output/oracle/oci/OCIManager.java +64 -64
  26. data/src/main/java/org/embulk/output/oracle/oci/OCIWrapper.java +96 -96
  27. data/src/main/java/org/embulk/output/oracle/oci/RowBuffer.java +105 -105
  28. data/src/main/java/org/embulk/output/oracle/oci/TableDefinition.java +24 -24
  29. data/src/test/cpp/common/embulk-output-oracle-test.cpp +69 -69
  30. data/src/test/cpp/linux/build.sh +19 -19
  31. data/src/test/cpp/win/build.bat +28 -28
  32. data/src/test/cpp/win/embulk-output-oracle-test.vcxproj +154 -154
  33. data/src/test/java/org/embulk/input/filesplit/LocalFileSplitInputPlugin.java +187 -187
  34. data/src/test/java/org/embulk/input/filesplit/PartialFile.java +49 -49
  35. data/src/test/java/org/embulk/input/filesplit/PartialFileInputStream.java +154 -154
  36. data/src/test/java/org/embulk/output/oracle/ChildFirstClassLoader.java +42 -42
  37. data/src/test/java/org/embulk/output/oracle/EmbulkPluginTester.java +124 -120
  38. data/src/test/java/org/embulk/output/oracle/EmptyConfigSource.java +105 -100
  39. data/src/test/java/org/embulk/output/oracle/OracleOutputPluginTest.java +38 -14
  40. data/src/test/java/org/embulk/output/oracle/OracleOutputPluginTestImpl.java +540 -484
  41. data/src/test/java/org/embulk/output/oracle/TimestampFormatTest.java +57 -57
  42. data/src/test/resources/data/test1/test1.csv +3 -3
  43. data/src/test/resources/yml/test-insert-direct-direct-method.yml +26 -0
  44. data/src/test/resources/yml/test-insert-direct-empty.yml +25 -0
  45. data/src/test/resources/yml/{test-insert-oci-split.yml → test-insert-direct-oci-method-split.yml} +28 -28
  46. data/src/test/resources/yml/{test-insert-oci.yml → test-insert-direct-oci-method.yml} +28 -28
  47. data/src/test/resources/yml/test-insert-direct.yml +25 -26
  48. data/src/test/resources/yml/test-insert-empty.yml +27 -0
  49. data/src/test/resources/yml/test-insert.yml +27 -25
  50. data/src/test/resources/yml/test-replace-empty.yml +31 -0
  51. data/src/test/resources/yml/test-replace-long-name-multibyte.yml +31 -31
  52. data/src/test/resources/yml/test-replace-long-name.yml +31 -31
  53. data/src/test/resources/yml/test-replace.yml +31 -31
  54. data/src/test/resources/yml/test-string-timestamp.yml +28 -28
  55. data/src/test/resources/yml/test-url.yml +24 -24
  56. metadata +10 -6
@@ -1,100 +1,105 @@
1
- package org.embulk.output.oracle;
2
-
3
- import java.util.Collections;
4
- import java.util.List;
5
- import java.util.Map.Entry;
6
-
7
- import org.embulk.config.ConfigSource;
8
- import org.embulk.config.DataSource;
9
-
10
- import com.fasterxml.jackson.databind.JsonNode;
11
- import com.fasterxml.jackson.databind.node.ObjectNode;
12
-
13
- public class EmptyConfigSource implements ConfigSource
14
- {
15
-
16
- @Override
17
- public <E> E get(Class<E> type, String attrName)
18
- {
19
- return null;
20
- }
21
-
22
- @Override
23
- public <E> E get(Class<E> type, String attrName, E defaultValue)
24
- {
25
- return defaultValue;
26
- }
27
-
28
- @Override
29
- public List<String> getAttributeNames()
30
- {
31
- return Collections.emptyList();
32
- }
33
-
34
- @Override
35
- public Iterable<Entry<String, JsonNode>> getAttributes()
36
- {
37
- return Collections.emptyList();
38
- }
39
-
40
- @Override
41
- public ObjectNode getObjectNode()
42
- {
43
- return null;
44
- }
45
-
46
- @Override
47
- public boolean isEmpty()
48
- {
49
- return true;
50
- }
51
-
52
- @Override
53
- public ConfigSource deepCopy()
54
- {
55
- return this;
56
- }
57
-
58
- @Override
59
- public ConfigSource getNested(String s)
60
- {
61
- return null;
62
- }
63
-
64
- @Override
65
- public ConfigSource getNestedOrSetEmpty(String s)
66
- {
67
- return null;
68
- }
69
-
70
- @Override
71
- public <T> T loadConfig(Class<T> class1)
72
- {
73
- return null;
74
- }
75
-
76
- @Override
77
- public ConfigSource merge(DataSource datasource)
78
- {
79
- return null;
80
- }
81
-
82
- @Override
83
- public ConfigSource set(String s, Object obj)
84
- {
85
- return null;
86
- }
87
-
88
- @Override
89
- public ConfigSource setAll(DataSource datasource)
90
- {
91
- return null;
92
- }
93
-
94
- @Override
95
- public ConfigSource setNested(String s, DataSource datasource)
96
- {
97
- return null;
98
- }
99
-
100
- }
1
+ package org.embulk.output.oracle;
2
+
3
+ import java.util.Collections;
4
+ import java.util.List;
5
+ import java.util.Map.Entry;
6
+
7
+ import org.embulk.config.ConfigSource;
8
+ import org.embulk.config.DataSource;
9
+
10
+ import com.fasterxml.jackson.databind.JsonNode;
11
+ import com.fasterxml.jackson.databind.node.ObjectNode;
12
+
13
+ public class EmptyConfigSource implements ConfigSource
14
+ {
15
+
16
+ @Override
17
+ public <E> E get(Class<E> type, String attrName)
18
+ {
19
+ return null;
20
+ }
21
+
22
+ @Override
23
+ public <E> E get(Class<E> type, String attrName, E defaultValue)
24
+ {
25
+ return defaultValue;
26
+ }
27
+
28
+ @Override
29
+ public List<String> getAttributeNames()
30
+ {
31
+ return Collections.emptyList();
32
+ }
33
+
34
+ @Override
35
+ public Iterable<Entry<String, JsonNode>> getAttributes()
36
+ {
37
+ return Collections.emptyList();
38
+ }
39
+
40
+ @Override
41
+ public ObjectNode getObjectNode()
42
+ {
43
+ return null;
44
+ }
45
+
46
+ @Override
47
+ public boolean isEmpty()
48
+ {
49
+ return true;
50
+ }
51
+
52
+ @Override
53
+ public ConfigSource deepCopy()
54
+ {
55
+ return this;
56
+ }
57
+
58
+ @Override
59
+ public ConfigSource getNested(String s)
60
+ {
61
+ return null;
62
+ }
63
+
64
+ @Override
65
+ public ConfigSource getNestedOrSetEmpty(String s)
66
+ {
67
+ return null;
68
+ }
69
+
70
+ @Override
71
+ public <T> T loadConfig(Class<T> class1)
72
+ {
73
+ return null;
74
+ }
75
+
76
+ @Override
77
+ public ConfigSource merge(DataSource datasource)
78
+ {
79
+ return null;
80
+ }
81
+
82
+ @Override
83
+ public ConfigSource set(String s, Object obj)
84
+ {
85
+ return null;
86
+ }
87
+
88
+ @Override
89
+ public ConfigSource setAll(DataSource datasource)
90
+ {
91
+ return null;
92
+ }
93
+
94
+ @Override
95
+ public ConfigSource setNested(String s, DataSource datasource)
96
+ {
97
+ return null;
98
+ }
99
+
100
+ @Override
101
+ public ConfigSource remove(String s) {
102
+ return null;
103
+ }
104
+
105
+ }
@@ -31,7 +31,7 @@ public class OracleOutputPluginTest
31
31
  public static void beforeClass() throws Exception
32
32
  {
33
33
  if (System.getProperty("path.separator").equals(";")) {
34
- // forw Windows
34
+ // for Windows
35
35
  System.setProperty("file.encoding", "MS932");
36
36
  }
37
37
 
@@ -102,36 +102,54 @@ public class OracleOutputPluginTest
102
102
  }
103
103
  return null;
104
104
  }
105
-
105
+ /*
106
106
  @Test
107
107
  public void testInsert() throws Exception
108
108
  {
109
109
  invoke("testInsert");
110
110
  }
111
-
111
+ */
112
112
  @Test
113
- public void testInsertCreate() throws Exception
113
+ public void testInsertEmpty() throws Exception
114
114
  {
115
- invoke("testInsertCreate");
115
+ invoke("testInsertEmpty");
116
116
  }
117
-
117
+ /*
118
118
  @Test
119
119
  public void testInsertDirect() throws Exception
120
+ {
121
+ invoke("testInsertDirect");
122
+ }
123
+ /*
124
+ @Test
125
+ public void testInsertDirectCreate() throws Exception
126
+ {
127
+ invoke("testInsertDirectCreate");
128
+ }
129
+ */
130
+ @Test
131
+ public void testInsertDirectEmpty() throws Exception
132
+ {
133
+ invoke("testInsertDirectEmpty");
134
+ }
135
+ /*
136
+ @Test
137
+ public void testInsertDirectDirectMethod() throws Exception
120
138
  {
121
139
  // ArrayIndexOutOfBoundsException thrown if using 12c driver.
122
- invoke(test11g, "testInsertDirect");
140
+ invoke(test11g, "testInsertDirectDirectMethod");
123
141
  }
124
-
142
+ *//*
125
143
  @Test
126
- public void testInsertOCI() throws Exception
144
+ public void testInsertDirectOCIMethod() throws Exception
127
145
  {
128
- invoke("testInsertOCI");
146
+ invoke("testInsertDirectOCIMethod");
129
147
  }
130
-
148
+ /*
131
149
  @Test
132
- public void testInsertOCISplit() throws Exception
150
+ public void testInsertDirectOCIMethodSplit() throws Exception
133
151
  {
134
- invoke("testInsertOCISplit");
152
+ invoke("testInsertDirectOCIMethodSplit");
135
153
  }
136
154
 
137
155
  @Test
@@ -146,6 +164,12 @@ public class OracleOutputPluginTest
146
164
  invoke("testReplace");
147
165
  }
148
166
 
167
+ @Test
168
+ public void testReplaceEmpty() throws Exception
169
+ {
170
+ invoke("testReplaceEmpty");
171
+ }
172
+
149
173
  @Test
150
174
  public void testReplaceLongName() throws Exception
151
175
  {
@@ -168,5 +192,5 @@ public class OracleOutputPluginTest
168
192
  public void testStringTimestamp() throws Exception
169
193
  {
170
194
  invoke("testStringTimestamp");
171
- }
195
+ }*/
172
196
  }
@@ -1,484 +1,540 @@
1
- package org.embulk.output.oracle;
2
-
3
- import static org.junit.Assert.assertEquals;
4
-
5
- import java.io.BufferedReader;
6
- import java.io.BufferedWriter;
7
- import java.io.File;
8
- import java.io.FileReader;
9
- import java.io.FileWriter;
10
- import java.io.IOException;
11
- import java.lang.reflect.Constructor;
12
- import java.math.BigDecimal;
13
- import java.net.URISyntaxException;
14
- import java.sql.Connection;
15
- import java.sql.DriverManager;
16
- import java.sql.ResultSet;
17
- import java.sql.SQLException;
18
- import java.sql.Statement;
19
- import java.sql.Timestamp;
20
- import java.text.DateFormat;
21
- import java.text.ParseException;
22
- import java.text.SimpleDateFormat;
23
- import java.util.ArrayList;
24
- import java.util.Collections;
25
- import java.util.Comparator;
26
- import java.util.Date;
27
- import java.util.Iterator;
28
- import java.util.List;
29
- import java.util.TimeZone;
30
- import java.util.regex.Matcher;
31
- import java.util.regex.Pattern;
32
-
33
- import org.embulk.input.filesplit.LocalFileSplitInputPlugin;
34
- import org.embulk.output.OracleOutputPlugin;
35
- import org.embulk.spi.InputPlugin;
36
- import org.embulk.spi.OutputPlugin;
37
-
38
-
39
- public class OracleOutputPluginTestImpl
40
- {
41
- private EmbulkPluginTester tester = new EmbulkPluginTester(OutputPlugin.class, "oracle", OracleOutputPlugin.class);
42
-
43
-
44
- public String beforeClass()
45
- {
46
- try {
47
- Class.forName("oracle.jdbc.OracleDriver");
48
-
49
- try (Connection connection = connect()) {
50
- String version = connection.getMetaData().getDriverVersion();
51
- System.out.println("Driver version = " + version);
52
- return version;
53
- }
54
-
55
- } catch (ClassNotFoundException | NoClassDefFoundError e) {
56
- //throw new RuntimeException("You should put Oracle JDBC driver on 'driver' directory.");
57
- System.err.println("Warning: put Oracle JDBC driver on 'driver' directory in order to test embulk-output-oracle plugin.");
58
-
59
- } catch (SQLException e) {
60
- System.err.println(e);
61
- //throw new RuntimeException("You should prepare a schema on Oracle (database = 'TESTDB', user = 'TEST_USER', password = 'test_pw').");
62
- System.err.println("Warning: prepare a schema on Oracle (database = 'TESTDB', user = 'TEST_USER', password = 'test_pw').");
63
- // for example
64
- // CREATE USER EMBULK_USER IDENTIFIED BY "embulk_pw";
65
- // GRANT DBA TO EMBULK_USER;
66
- }
67
-
68
- return null;
69
- }
70
-
71
-
72
- public void testInsert() throws Exception
73
- {
74
- String table = "TEST1";
75
-
76
- dropTable(table);
77
- createTable(table);
78
-
79
- run("/yml/test-insert.yml");
80
-
81
- assertTable(table);
82
- }
83
-
84
- public void testInsertCreate() throws Exception
85
- {
86
- String table = "TEST1";
87
-
88
- dropTable(table);
89
-
90
- run("/yml/test-insert.yml");
91
-
92
- assertGeneratedTable1(table);
93
- }
94
-
95
- public void testInsertDirect() throws Exception
96
- {
97
- String table = "TEST1";
98
-
99
- dropTable(table);
100
- createTable(table);
101
-
102
- run("/yml/test-insert-direct.yml");
103
-
104
- assertTable(table);
105
- }
106
-
107
- public void testInsertOCI() throws Exception
108
- {
109
- String table = "TEST1";
110
-
111
- dropTable(table);
112
- createTable(table);
113
-
114
- run("/yml/test-insert-oci.yml");
115
-
116
- assertTable(table);
117
- }
118
-
119
- public void testInsertOCISplit() throws Exception
120
- {
121
- tester.addPlugin(InputPlugin.class, "filesplit", LocalFileSplitInputPlugin.class);
122
-
123
- String table = "TEST1";
124
-
125
- dropTable(table);
126
- createTable(table);
127
-
128
- run("/yml/test-insert-oci-split.yml");
129
-
130
- assertTable(table);
131
- }
132
-
133
- public void testUrl() throws Exception
134
- {
135
- String table = "TEST1";
136
-
137
- dropTable(table);
138
- createTable(table);
139
-
140
- run("/yml/test-url.yml");
141
-
142
- assertTable(table);
143
- }
144
-
145
- public void testReplace() throws Exception
146
- {
147
- String table = "TEST1";
148
-
149
- dropTable(table);
150
- createTable(table);
151
-
152
- run("/yml/test-replace.yml");
153
-
154
- assertGeneratedTable2(table);
155
- }
156
-
157
- public void testReplaceCreate() throws Exception
158
- {
159
- String table = "TEST1";
160
-
161
- dropTable(table);
162
-
163
- run("/yml/test-replace.yml");
164
-
165
- assertGeneratedTable2(table);
166
- }
167
-
168
-
169
- public void testReplaceLongName() throws Exception
170
- {
171
- String table = "TEST12345678901234567890123456";
172
-
173
- dropTable(table);
174
- createTable(table);
175
-
176
- run("/yml/test-replace-long-name.yml");
177
-
178
- assertGeneratedTable2(table);
179
- }
180
-
181
- public void testReplaceLongNameMultibyte() throws Exception
182
- {
183
- String table = "TEST12345678901234567890";
184
-
185
- run("/yml/test-replace-long-name-multibyte.yml");
186
-
187
- assertGeneratedTable2(table);
188
- }
189
-
190
- public void testStringTimestamp() throws Exception
191
- {
192
- String table = "TEST1";
193
-
194
- dropTable(table);
195
- createTable(table);
196
-
197
- run("/yml/test-string-timestamp.yml");
198
-
199
- assertTable(table);
200
- }
201
-
202
- private void dropTable(String table) throws SQLException
203
- {
204
- String sql = String.format("DROP TABLE %s", table);
205
- executeSQL(sql, true);
206
- }
207
-
208
- private void createTable(String table) throws SQLException
209
- {
210
- String sql = String.format("CREATE TABLE %s ("
211
- + "ID CHAR(4),"
212
- + "VARCHAR2_ITEM VARCHAR2(40),"
213
- + "INTEGER_ITEM NUMBER(4,0),"
214
- + "NUMBER_ITEM NUMBER(10,2),"
215
- + "DATE_ITEM DATE,"
216
- + "TIMESTAMP_ITEM TIMESTAMP,"
217
- + "PRIMARY KEY (ID))", table);
218
- executeSQL(sql);
219
- }
220
-
221
- private void assertTable(String table) throws Exception
222
- {
223
- // datetime of UTC will be inserted by embulk.
224
- // datetime of default timezone will be selected by JDBC.
225
- TimeZone timeZone = TimeZone.getDefault();
226
- List<List<Object>> rows = select(table);
227
-
228
- /*
229
- A001,ABCDE,0,123.45,2015/03/05,2015/03/05 12:34:56
230
- A002,あいうえお,-9999,-99999999.99,2015/03/06,2015/03/06 23:59:59
231
- A003,,,,,
232
- */
233
-
234
- assertEquals(3, rows.size());
235
- Iterator<List<Object>> i1 = rows.iterator();
236
- {
237
- Iterator<Object> i2 = i1.next().iterator();
238
- assertEquals("A001", i2.next());
239
- assertEquals("ABCDE", i2.next());
240
- assertEquals(new BigDecimal("0"), i2.next());
241
- assertEquals(new BigDecimal("123.45"), i2.next());
242
- assertEquals(toTimestamp("2015/03/05 00:00:00", timeZone), i2.next());
243
- assertEquals(toOracleTimestamp("2015/03/05 12:34:56", timeZone), i2.next());
244
- }
245
- {
246
- Iterator<Object> i2 = i1.next().iterator();
247
- assertEquals("A002", i2.next());
248
- assertEquals("あいうえお", i2.next());
249
- assertEquals(new BigDecimal("-9999"), i2.next());
250
- assertEquals(new BigDecimal("-99999999.99"), i2.next());
251
- assertEquals(toTimestamp("2015/03/06 00:00:00", timeZone), i2.next());
252
- assertEquals(toOracleTimestamp("2015/03/06 23:59:59", timeZone), i2.next());
253
- }
254
- {
255
- Iterator<Object> i2 = i1.next().iterator();
256
- assertEquals("A003", i2.next());
257
- assertEquals(null, i2.next());
258
- assertEquals(null, i2.next());
259
- assertEquals(null, i2.next());
260
- assertEquals(null, i2.next());
261
- assertEquals(null, i2.next());
262
- }
263
- }
264
-
265
- private void assertGeneratedTable1(String table) throws Exception
266
- {
267
- // datetime of UTC will be inserted by embulk.
268
- // datetime of default timezone will be selected by JDBC.
269
- TimeZone timeZone = TimeZone.getDefault();
270
- List<List<Object>> rows = select(table);
271
-
272
- /*
273
- A001,ABCDE,0,123.45,2015/03/05,2015/03/05 12:34:56
274
- A002,あいうえお,-9999,-99999999.99,2015/03/06,2015/03/06 23:59:59
275
- A003,,,,,
276
- */
277
-
278
- assertEquals(3, rows.size());
279
- Iterator<List<Object>> i1 = rows.iterator();
280
- {
281
- Iterator<Object> i2 = i1.next().iterator();
282
- assertEquals("A001", i2.next());
283
- assertEquals("ABCDE", i2.next());
284
- assertEquals(new BigDecimal("0"), i2.next());
285
- assertEquals("123.45", i2.next());
286
- assertEquals(toOracleTimestamp("2015/03/05 00:00:00", timeZone), i2.next());
287
- assertEquals(toOracleTimestamp("2015/03/05 12:34:56", timeZone), i2.next());
288
- }
289
- {
290
- Iterator<Object> i2 = i1.next().iterator();
291
- assertEquals("A002", i2.next());
292
- assertEquals("あいうえお", i2.next());
293
- assertEquals(new BigDecimal("-9999"), i2.next());
294
- assertEquals("-99999999.99", i2.next());
295
- assertEquals(toOracleTimestamp("2015/03/06 00:00:00", timeZone), i2.next());
296
- assertEquals(toOracleTimestamp("2015/03/06 23:59:59", timeZone), i2.next());
297
- }
298
- {
299
- Iterator<Object> i2 = i1.next().iterator();
300
- assertEquals("A003", i2.next());
301
- assertEquals(null, i2.next());
302
- assertEquals(null, i2.next());
303
- assertEquals(null, i2.next());
304
- assertEquals(null, i2.next());
305
- assertEquals(null, i2.next());
306
- }
307
- }
308
-
309
- private void assertGeneratedTable2(String table) throws Exception
310
- {
311
- // datetime of UTC will be inserted by embulk.
312
- // datetime of default timezone will be selected by JDBC.
313
- TimeZone timeZone = TimeZone.getDefault();
314
- List<List<Object>> rows = select(table);
315
-
316
- /*
317
- A001,ABCDE,0,123.45,2015/03/05,2015/03/05 12:34:56
318
- A002,あいうえお,-9999,-99999999.99,2015/03/06,2015/03/06 23:59:59
319
- A003,,,,,
320
- */
321
-
322
- assertEquals(3, rows.size());
323
- Iterator<List<Object>> i1 = rows.iterator();
324
- {
325
- Iterator<Object> i2 = i1.next().iterator();
326
- assertEquals("A001", i2.next());
327
- assertEquals("ABCDE", i2.next());
328
- assertEquals(new BigDecimal("0"), i2.next());
329
- assertEquals(new BigDecimal("123.45"), i2.next());
330
- assertEquals(toTimestamp("2015/03/05 00:00:00", timeZone), i2.next());
331
- assertEquals(toOracleTimestamp("2015/03/05 12:34:56", timeZone), i2.next());
332
- }
333
- {
334
- Iterator<Object> i2 = i1.next().iterator();
335
- assertEquals("A002", i2.next());
336
- assertEquals("あいうえお", i2.next());
337
- assertEquals(new BigDecimal("-9999"), i2.next());
338
- assertEquals(new BigDecimal("-99999999.99"), i2.next());
339
- assertEquals(toTimestamp("2015/03/06 00:00:00", timeZone), i2.next());
340
- assertEquals(toOracleTimestamp("2015/03/06 23:59:59", timeZone), i2.next());
341
- }
342
- {
343
- Iterator<Object> i2 = i1.next().iterator();
344
- assertEquals("A003", i2.next());
345
- assertEquals(null, i2.next());
346
- assertEquals(null, i2.next());
347
- assertEquals(null, i2.next());
348
- assertEquals(null, i2.next());
349
- assertEquals(null, i2.next());
350
- }
351
- }
352
-
353
-
354
- private Timestamp toTimestamp(String s, TimeZone timeZone)
355
- {
356
- for (String formatString : new String[]{"yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd"}) {
357
- DateFormat dateFormat = new SimpleDateFormat(formatString);
358
- dateFormat.setTimeZone(timeZone);
359
- try {
360
- Date date = dateFormat.parse(s);
361
- return new Timestamp(date.getTime());
362
- } catch (ParseException e) {
363
- // NOP
364
- }
365
- }
366
- throw new IllegalArgumentException(s);
367
- }
368
-
369
- private Object toOracleTimestamp(String s, TimeZone timeZone) throws Exception
370
- {
371
- Class<?> timestampClass = Class.forName("oracle.sql.TIMESTAMP");
372
- Constructor<?> constructor = timestampClass.getConstructor(Timestamp.class);
373
- return constructor.newInstance(toTimestamp(s, timeZone));
374
- }
375
-
376
-
377
- private List<List<Object>> select(String table) throws SQLException
378
- {
379
- try (Connection connection = connect()) {
380
- try (Statement statement = connection.createStatement()) {
381
- List<List<Object>> rows = new ArrayList<List<Object>>();
382
- String sql = "SELECT * FROM " + table;
383
- System.out.println(sql);
384
- try (ResultSet resultSet = statement.executeQuery(sql)) {
385
- while (resultSet.next()) {
386
- List<Object> row = new ArrayList<Object>();
387
- for (int i = 1; i <= resultSet.getMetaData().getColumnCount(); i++) {
388
- Object value = resultSet.getObject(i);
389
- if (value != null && value.getClass().getName().equals("oracle.sql.CLOB")) {
390
- value = resultSet.getString(i);
391
- }
392
- row.add(value);
393
- }
394
- rows.add(row);
395
- }
396
- }
397
- // cannot sort by CLOB, so sort by Java
398
- Collections.sort(rows, new Comparator<List<Object>>() {
399
- @Override
400
- public int compare(List<Object> o1, List<Object> o2) {
401
- return o1.toString().compareTo(o2.toString());
402
- }
403
- });
404
- return rows;
405
- }
406
- }
407
-
408
- }
409
-
410
-
411
- private void executeSQL(String sql) throws SQLException
412
- {
413
- executeSQL(sql, false);
414
- }
415
-
416
- private void executeSQL(String sql, boolean ignoreError) throws SQLException
417
- {
418
- try (Connection connection = connect()) {
419
- try {
420
- connection.setAutoCommit(true);
421
-
422
- try (Statement statement = connection.createStatement()) {
423
- System.out.println(String.format("Execute SQL : \"%s\".", sql));
424
- statement.execute(sql);
425
- }
426
-
427
- } catch (SQLException e) {
428
- if (!ignoreError) {
429
- throw e;
430
- }
431
- }
432
- }
433
- }
434
-
435
- private static Connection connect() throws SQLException
436
- {
437
- return DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:TESTDB", "TEST_USER", "test_pw");
438
- }
439
-
440
- private void run(String ymlName) throws Exception
441
- {
442
- tester.run(convertYml(ymlName));
443
- }
444
-
445
- private String convertYml(String ymlName)
446
- {
447
- try {
448
- File ymlPath = convertPath(ymlName);
449
- File tempYmlPath = new File(ymlPath.getParentFile(), "temp-" + ymlPath.getName());
450
- Pattern pathPrefixPattern = Pattern.compile("^ *path(_prefix)?: '(.*)'$");
451
- try (BufferedReader reader = new BufferedReader(new FileReader(ymlPath))) {
452
- try (BufferedWriter writer = new BufferedWriter(new FileWriter(tempYmlPath))) {
453
- String line;
454
- while ((line = reader.readLine()) != null) {
455
- Matcher matcher = pathPrefixPattern.matcher(line);
456
- if (matcher.matches()) {
457
- int group = 2;
458
- writer.write(line.substring(0, matcher.start(group)));
459
- writer.write(convertPath(matcher.group(group)).getAbsolutePath());
460
- writer.write(line.substring(matcher.end(group)));
461
- } else {
462
- writer.write(line);
463
- }
464
- writer.newLine();
465
- }
466
- }
467
- }
468
- return tempYmlPath.getAbsolutePath();
469
-
470
- } catch (IOException e) {
471
- throw new RuntimeException(e);
472
- } catch (URISyntaxException e) {
473
- throw new RuntimeException(e);
474
- }
475
- }
476
-
477
- private File convertPath(String name) throws URISyntaxException
478
- {
479
- if (getClass().getResource(name) == null)
480
- return new File(name);
481
- return new File(getClass().getResource(name).toURI());
482
- }
483
-
484
- }
1
+ package org.embulk.output.oracle;
2
+
3
+ import static org.junit.Assert.assertEquals;
4
+
5
+ import java.io.BufferedReader;
6
+ import java.io.BufferedWriter;
7
+ import java.io.File;
8
+ import java.io.FileReader;
9
+ import java.io.FileWriter;
10
+ import java.io.IOException;
11
+ import java.lang.reflect.Constructor;
12
+ import java.math.BigDecimal;
13
+ import java.net.URISyntaxException;
14
+ import java.sql.Connection;
15
+ import java.sql.DriverManager;
16
+ import java.sql.ResultSet;
17
+ import java.sql.SQLException;
18
+ import java.sql.Statement;
19
+ import java.sql.Timestamp;
20
+ import java.text.DateFormat;
21
+ import java.text.ParseException;
22
+ import java.text.SimpleDateFormat;
23
+ import java.util.ArrayList;
24
+ import java.util.Collections;
25
+ import java.util.Comparator;
26
+ import java.util.Date;
27
+ import java.util.Iterator;
28
+ import java.util.List;
29
+ import java.util.TimeZone;
30
+ import java.util.regex.Matcher;
31
+ import java.util.regex.Pattern;
32
+
33
+ import org.embulk.input.filesplit.LocalFileSplitInputPlugin;
34
+ import org.embulk.output.OracleOutputPlugin;
35
+ import org.embulk.spi.InputPlugin;
36
+ import org.embulk.spi.OutputPlugin;
37
+
38
+
39
+ public class OracleOutputPluginTestImpl
40
+ {
41
+ private EmbulkPluginTester tester = new EmbulkPluginTester(OutputPlugin.class, "oracle", OracleOutputPlugin.class);
42
+
43
+
44
+ public String beforeClass()
45
+ {
46
+ try {
47
+ Class.forName("oracle.jdbc.OracleDriver");
48
+
49
+ try (Connection connection = connect()) {
50
+ String version = connection.getMetaData().getDriverVersion();
51
+ System.out.println("Driver version = " + version);
52
+ return version;
53
+ }
54
+
55
+ } catch (ClassNotFoundException | NoClassDefFoundError e) {
56
+ //throw new RuntimeException("You should put Oracle JDBC driver on 'driver' directory.");
57
+ System.err.println("Warning: put Oracle JDBC driver on 'driver' directory in order to test embulk-output-oracle plugin.");
58
+
59
+ } catch (SQLException e) {
60
+ System.err.println(e);
61
+ //throw new RuntimeException("You should prepare a schema on Oracle (database = 'TESTDB', user = 'TEST_USER', password = 'test_pw').");
62
+ System.err.println("Warning: prepare a schema on Oracle (database = 'TESTDB', user = 'TEST_USER', password = 'test_pw').");
63
+ // for example
64
+ // CREATE USER EMBULK_USER IDENTIFIED BY "embulk_pw";
65
+ // GRANT DBA TO EMBULK_USER;
66
+ }
67
+
68
+ convertPath("/data/test2/").mkdirs();
69
+
70
+ return null;
71
+ }
72
+
73
+ public void testInsert() throws Exception
74
+ {
75
+ String table = "TEST1";
76
+
77
+ dropTable(table);
78
+ createTable(table);
79
+
80
+ run("/yml/test-insert.yml");
81
+
82
+ assertTable(table);
83
+ }
84
+
85
+ public void testInsertEmpty() throws Exception
86
+ {
87
+ String table = "TEST1";
88
+
89
+ dropTable(table);
90
+ createTable(table);
91
+
92
+ run("/yml/test-insert-empty.yml");
93
+
94
+ assertTableEmpty(table);
95
+ }
96
+
97
+ public void testInsertDirect() throws Exception
98
+ {
99
+ String table = "TEST1";
100
+
101
+ dropTable(table);
102
+ createTable(table);
103
+
104
+ run("/yml/test-insert-direct.yml");
105
+
106
+ assertTable(table);
107
+ }
108
+
109
+ public void testInsertDirectEmpty() throws Exception
110
+ {
111
+ String table = "TEST1";
112
+
113
+ dropTable(table);
114
+ createTable(table);
115
+
116
+ run("/yml/test-insert-direct-empty.yml");
117
+
118
+ assertTableEmpty(table);
119
+ }
120
+
121
+ public void testInsertDirectCreate() throws Exception
122
+ {
123
+ String table = "TEST1";
124
+
125
+ dropTable(table);
126
+
127
+ run("/yml/test-insert-direct.yml");
128
+
129
+ assertGeneratedTable1(table);
130
+ }
131
+
132
+ public void testInsertDirectDirectMethod() throws Exception
133
+ {
134
+ String table = "TEST1";
135
+
136
+ dropTable(table);
137
+ createTable(table);
138
+
139
+ run("/yml/test-insert-direct-direct-method.yml");
140
+
141
+ assertTable(table);
142
+ }
143
+
144
+ public void testInsertDirectOCIMethod() throws Exception
145
+ {
146
+ String table = "TEST1";
147
+
148
+ dropTable(table);
149
+ createTable(table);
150
+
151
+ run("/yml/test-insert-direct-oci-method.yml");
152
+
153
+ assertTable(table);
154
+ }
155
+
156
+ public void testInsertDirectOCIMethodSplit() throws Exception
157
+ {
158
+ tester.addPlugin(InputPlugin.class, "filesplit", LocalFileSplitInputPlugin.class);
159
+
160
+ String table = "TEST1";
161
+
162
+ dropTable(table);
163
+ createTable(table);
164
+
165
+ run("/yml/test-insert-direct-oci-method-split.yml");
166
+
167
+ assertTable(table);
168
+ }
169
+
170
+ public void testUrl() throws Exception
171
+ {
172
+ String table = "TEST1";
173
+
174
+ dropTable(table);
175
+ createTable(table);
176
+
177
+ run("/yml/test-url.yml");
178
+
179
+ assertTable(table);
180
+ }
181
+
182
+ public void testReplace() throws Exception
183
+ {
184
+ String table = "TEST1";
185
+
186
+ dropTable(table);
187
+ createTable(table);
188
+
189
+ run("/yml/test-replace.yml");
190
+
191
+ assertGeneratedTable2(table);
192
+ }
193
+
194
+ public void testReplaceEmpty() throws Exception
195
+ {
196
+ String table = "TEST1";
197
+
198
+ dropTable(table);
199
+ createTable(table);
200
+
201
+ run("/yml/test-replace-empty.yml");
202
+
203
+ assertTableEmpty(table);
204
+ }
205
+
206
+ public void testReplaceCreate() throws Exception
207
+ {
208
+ String table = "TEST1";
209
+
210
+ dropTable(table);
211
+
212
+ run("/yml/test-replace.yml");
213
+
214
+ assertGeneratedTable2(table);
215
+ }
216
+
217
+
218
+ public void testReplaceLongName() throws Exception
219
+ {
220
+ String table = "TEST12345678901234567890123456";
221
+
222
+ dropTable(table);
223
+ createTable(table);
224
+
225
+ run("/yml/test-replace-long-name.yml");
226
+
227
+ assertGeneratedTable2(table);
228
+ }
229
+
230
+ public void testReplaceLongNameMultibyte() throws Exception
231
+ {
232
+ String table = "TEST12345678901234567890";
233
+
234
+ run("/yml/test-replace-long-name-multibyte.yml");
235
+
236
+ assertGeneratedTable2(table);
237
+ }
238
+
239
+ public void testStringTimestamp() throws Exception
240
+ {
241
+ String table = "TEST1";
242
+
243
+ dropTable(table);
244
+ createTable(table);
245
+
246
+ run("/yml/test-string-timestamp.yml");
247
+
248
+ assertTable(table);
249
+ }
250
+
251
+ private void dropTable(String table) throws SQLException
252
+ {
253
+ String sql = String.format("DROP TABLE %s", table);
254
+ executeSQL(sql, true);
255
+ }
256
+
257
+ private void createTable(String table) throws SQLException
258
+ {
259
+ String sql = String.format("CREATE TABLE %s ("
260
+ + "ID CHAR(4),"
261
+ + "VARCHAR2_ITEM VARCHAR2(40),"
262
+ + "INTEGER_ITEM NUMBER(4,0),"
263
+ + "NUMBER_ITEM NUMBER(10,2),"
264
+ + "DATE_ITEM DATE,"
265
+ + "TIMESTAMP_ITEM TIMESTAMP,"
266
+ + "PRIMARY KEY (ID))", table);
267
+ executeSQL(sql);
268
+ }
269
+
270
+ private void assertTable(String table) throws Exception
271
+ {
272
+ // datetime of UTC will be inserted by embulk.
273
+ // datetime of default timezone will be selected by JDBC.
274
+ TimeZone timeZone = TimeZone.getDefault();
275
+ List<List<Object>> rows = select(table);
276
+
277
+ /*
278
+ A001,ABCDE,0,123.45,2015/03/05,2015/03/05 12:34:56
279
+ A002,あいうえお,-9999,-99999999.99,2015/03/06,2015/03/06 23:59:59
280
+ A003,,,,,
281
+ */
282
+
283
+ assertEquals(3, rows.size());
284
+ Iterator<List<Object>> i1 = rows.iterator();
285
+ {
286
+ Iterator<Object> i2 = i1.next().iterator();
287
+ assertEquals("A001", i2.next());
288
+ assertEquals("ABCDE", i2.next());
289
+ assertEquals(new BigDecimal("0"), i2.next());
290
+ assertEquals(new BigDecimal("123.45"), i2.next());
291
+ assertEquals(toTimestamp("2015/03/05 00:00:00", timeZone), i2.next());
292
+ assertEquals(toOracleTimestamp("2015/03/05 12:34:56", timeZone), i2.next());
293
+ }
294
+ {
295
+ Iterator<Object> i2 = i1.next().iterator();
296
+ assertEquals("A002", i2.next());
297
+ assertEquals("あいうえお", i2.next());
298
+ assertEquals(new BigDecimal("-9999"), i2.next());
299
+ assertEquals(new BigDecimal("-99999999.99"), i2.next());
300
+ assertEquals(toTimestamp("2015/03/06 00:00:00", timeZone), i2.next());
301
+ assertEquals(toOracleTimestamp("2015/03/06 23:59:59", timeZone), i2.next());
302
+ }
303
+ {
304
+ Iterator<Object> i2 = i1.next().iterator();
305
+ assertEquals("A003", i2.next());
306
+ assertEquals(null, i2.next());
307
+ assertEquals(null, i2.next());
308
+ assertEquals(null, i2.next());
309
+ assertEquals(null, i2.next());
310
+ assertEquals(null, i2.next());
311
+ }
312
+ }
313
+
314
+ private void assertTableEmpty(String table) throws Exception
315
+ {
316
+ List<List<Object>> rows = select(table);
317
+ assertEquals(0, rows.size());
318
+ }
319
+
320
+ private void assertGeneratedTable1(String table) throws Exception
321
+ {
322
+ // datetime of UTC will be inserted by embulk.
323
+ // datetime of default timezone will be selected by JDBC.
324
+ TimeZone timeZone = TimeZone.getDefault();
325
+ List<List<Object>> rows = select(table);
326
+
327
+ /*
328
+ A001,ABCDE,0,123.45,2015/03/05,2015/03/05 12:34:56
329
+ A002,あいうえお,-9999,-99999999.99,2015/03/06,2015/03/06 23:59:59
330
+ A003,,,,,
331
+ */
332
+
333
+ assertEquals(3, rows.size());
334
+ Iterator<List<Object>> i1 = rows.iterator();
335
+ {
336
+ Iterator<Object> i2 = i1.next().iterator();
337
+ assertEquals("A001", i2.next());
338
+ assertEquals("ABCDE", i2.next());
339
+ assertEquals(new BigDecimal("0"), i2.next());
340
+ assertEquals("123.45", i2.next());
341
+ assertEquals(toOracleTimestamp("2015/03/05 00:00:00", timeZone), i2.next());
342
+ assertEquals(toOracleTimestamp("2015/03/05 12:34:56", timeZone), i2.next());
343
+ }
344
+ {
345
+ Iterator<Object> i2 = i1.next().iterator();
346
+ assertEquals("A002", i2.next());
347
+ assertEquals("あいうえお", i2.next());
348
+ assertEquals(new BigDecimal("-9999"), i2.next());
349
+ assertEquals("-99999999.99", i2.next());
350
+ assertEquals(toOracleTimestamp("2015/03/06 00:00:00", timeZone), i2.next());
351
+ assertEquals(toOracleTimestamp("2015/03/06 23:59:59", timeZone), i2.next());
352
+ }
353
+ {
354
+ Iterator<Object> i2 = i1.next().iterator();
355
+ assertEquals("A003", i2.next());
356
+ assertEquals(null, i2.next());
357
+ assertEquals(null, i2.next());
358
+ assertEquals(null, i2.next());
359
+ assertEquals(null, i2.next());
360
+ assertEquals(null, i2.next());
361
+ }
362
+ }
363
+
364
+ private void assertGeneratedTable2(String table) throws Exception
365
+ {
366
+ // datetime of UTC will be inserted by embulk.
367
+ // datetime of default timezone will be selected by JDBC.
368
+ TimeZone timeZone = TimeZone.getDefault();
369
+ List<List<Object>> rows = select(table);
370
+
371
+ /*
372
+ A001,ABCDE,0,123.45,2015/03/05,2015/03/05 12:34:56
373
+ A002,あいうえお,-9999,-99999999.99,2015/03/06,2015/03/06 23:59:59
374
+ A003,,,,,
375
+ */
376
+
377
+ assertEquals(3, rows.size());
378
+ Iterator<List<Object>> i1 = rows.iterator();
379
+ {
380
+ Iterator<Object> i2 = i1.next().iterator();
381
+ assertEquals("A001", i2.next());
382
+ assertEquals("ABCDE", i2.next());
383
+ assertEquals(new BigDecimal("0"), i2.next());
384
+ assertEquals(new BigDecimal("123.45"), i2.next());
385
+ assertEquals(toTimestamp("2015/03/05 00:00:00", timeZone), i2.next());
386
+ assertEquals(toOracleTimestamp("2015/03/05 12:34:56", timeZone), i2.next());
387
+ }
388
+ {
389
+ Iterator<Object> i2 = i1.next().iterator();
390
+ assertEquals("A002", i2.next());
391
+ assertEquals("あいうえお", i2.next());
392
+ assertEquals(new BigDecimal("-9999"), i2.next());
393
+ assertEquals(new BigDecimal("-99999999.99"), i2.next());
394
+ assertEquals(toTimestamp("2015/03/06 00:00:00", timeZone), i2.next());
395
+ assertEquals(toOracleTimestamp("2015/03/06 23:59:59", timeZone), i2.next());
396
+ }
397
+ {
398
+ Iterator<Object> i2 = i1.next().iterator();
399
+ assertEquals("A003", i2.next());
400
+ assertEquals(null, i2.next());
401
+ assertEquals(null, i2.next());
402
+ assertEquals(null, i2.next());
403
+ assertEquals(null, i2.next());
404
+ assertEquals(null, i2.next());
405
+ }
406
+ }
407
+
408
+
409
+ private Timestamp toTimestamp(String s, TimeZone timeZone)
410
+ {
411
+ for (String formatString : new String[]{"yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd"}) {
412
+ DateFormat dateFormat = new SimpleDateFormat(formatString);
413
+ dateFormat.setTimeZone(timeZone);
414
+ try {
415
+ Date date = dateFormat.parse(s);
416
+ return new Timestamp(date.getTime());
417
+ } catch (ParseException e) {
418
+ // NOP
419
+ }
420
+ }
421
+ throw new IllegalArgumentException(s);
422
+ }
423
+
424
+ private Object toOracleTimestamp(String s, TimeZone timeZone) throws Exception
425
+ {
426
+ Class<?> timestampClass = Class.forName("oracle.sql.TIMESTAMP");
427
+ Constructor<?> constructor = timestampClass.getConstructor(Timestamp.class);
428
+ return constructor.newInstance(toTimestamp(s, timeZone));
429
+ }
430
+
431
+
432
+ private List<List<Object>> select(String table) throws SQLException
433
+ {
434
+ try (Connection connection = connect()) {
435
+ try (Statement statement = connection.createStatement()) {
436
+ List<List<Object>> rows = new ArrayList<List<Object>>();
437
+ String sql = "SELECT * FROM " + table;
438
+ System.out.println(sql);
439
+ try (ResultSet resultSet = statement.executeQuery(sql)) {
440
+ while (resultSet.next()) {
441
+ List<Object> row = new ArrayList<Object>();
442
+ for (int i = 1; i <= resultSet.getMetaData().getColumnCount(); i++) {
443
+ Object value = resultSet.getObject(i);
444
+ if (value != null && value.getClass().getName().equals("oracle.sql.CLOB")) {
445
+ value = resultSet.getString(i);
446
+ }
447
+ row.add(value);
448
+ }
449
+ rows.add(row);
450
+ }
451
+ }
452
+ // cannot sort by CLOB, so sort by Java
453
+ Collections.sort(rows, new Comparator<List<Object>>() {
454
+ @Override
455
+ public int compare(List<Object> o1, List<Object> o2) {
456
+ return o1.toString().compareTo(o2.toString());
457
+ }
458
+ });
459
+ return rows;
460
+ }
461
+ }
462
+
463
+ }
464
+
465
+
466
+ private void executeSQL(String sql) throws SQLException
467
+ {
468
+ executeSQL(sql, false);
469
+ }
470
+
471
+ private void executeSQL(String sql, boolean ignoreError) throws SQLException
472
+ {
473
+ try (Connection connection = connect()) {
474
+ try {
475
+ connection.setAutoCommit(true);
476
+
477
+ try (Statement statement = connection.createStatement()) {
478
+ System.out.println(String.format("Execute SQL : \"%s\".", sql));
479
+ statement.execute(sql);
480
+ }
481
+
482
+ } catch (SQLException e) {
483
+ if (!ignoreError) {
484
+ throw e;
485
+ }
486
+ }
487
+ }
488
+ }
489
+
490
+ private static Connection connect() throws SQLException
491
+ {
492
+ return DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:TESTDB", "TEST_USER", "test_pw");
493
+ }
494
+
495
+ private void run(String ymlName) throws Exception
496
+ {
497
+ tester.run(convertYml(ymlName));
498
+ }
499
+
500
+ private String convertYml(String ymlName)
501
+ {
502
+ try {
503
+ File ymlPath = convertPath(ymlName);
504
+ File tempYmlPath = new File(ymlPath.getParentFile(), "temp-" + ymlPath.getName());
505
+ Pattern pathPrefixPattern = Pattern.compile("^ *path(_prefix)?: '(.*)'$");
506
+ try (BufferedReader reader = new BufferedReader(new FileReader(ymlPath))) {
507
+ try (BufferedWriter writer = new BufferedWriter(new FileWriter(tempYmlPath))) {
508
+ String line;
509
+ while ((line = reader.readLine()) != null) {
510
+ Matcher matcher = pathPrefixPattern.matcher(line);
511
+ if (matcher.matches()) {
512
+ int group = 2;
513
+ writer.write(line.substring(0, matcher.start(group)));
514
+ writer.write(convertPath(matcher.group(group)).getAbsolutePath());
515
+ writer.write(line.substring(matcher.end(group)));
516
+ } else {
517
+ writer.write(line);
518
+ }
519
+ writer.newLine();
520
+ }
521
+ }
522
+ }
523
+ return tempYmlPath.getAbsolutePath();
524
+
525
+ } catch (IOException e) {
526
+ throw new RuntimeException(e);
527
+ }
528
+ }
529
+
530
+ private File convertPath(String name)
531
+ {
532
+ try {
533
+ File root = new File(getClass().getResource("/dummy.txt").toURI()).getParentFile();
534
+ return new File(root, name);
535
+ } catch (URISyntaxException e) {
536
+ throw new RuntimeException(e);
537
+ }
538
+ }
539
+
540
+ }