embulk-input-oracle 0.7.4 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 38c75d9629dab90ac79caf0fdf0b76f4a467e4e6
4
- data.tar.gz: e5e32b42aa9707f50621d30be000ec0a3c98e048
3
+ metadata.gz: ab1f91c076cf91ec74900b6a463ad07abd8647b2
4
+ data.tar.gz: 2dc1d750ad0cd880de15893f3bf1222b4859521a
5
5
  SHA512:
6
- metadata.gz: df3d2c1b5baa64c0c98f67cead38534ff6a16295bc7f7223db778679795d15bcd4844c27310cfb5e66d7c9a1e99c5b3ee93da4c6ef3cc7f747ffbabb29b364d4
7
- data.tar.gz: 1b6d72f668bd00025f7bf92b5248296c3238594f1758642926e5aad0a2e281615c54e654dc5291524c1dc32a3ecaf3dd568f25976a5d942b5ef0784d28ea3d9c
6
+ metadata.gz: 7f65aff4ca8d4f34bbfac2b33a81dd315f68f4db9f01bb00147abad57df7f373d7c3807cb05391be979095356f82fef89710eaf087a1539553ea73ac2ea96404
7
+ data.tar.gz: 59e3ab2f6ee38e5eb7b72c96bb73b056246bcdcfc628e52031de3fb213cdcb7e8626edd01d867aa6ce10b7a4cabd826c014d257a0cb5793312fbf89855c68a6f
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # Oracle input plugins for Embulk
1
+ # Oracle input plugin for Embulk
2
2
 
3
- Oracle input plugins for Embulk loads records from Oracle.
3
+ Oracle input plugin for Embulk loads records from Oracle.
4
4
 
5
5
  ## Overview
6
6
 
@@ -1,36 +1,25 @@
1
1
  package org.embulk.input.oracle;
2
2
 
3
+ import static java.util.Locale.ENGLISH;
3
4
  import static org.junit.Assert.assertEquals;
4
5
 
5
- import java.io.File;
6
- import java.io.IOException;
7
- import java.net.URISyntaxException;
8
- import java.nio.charset.Charset;
9
- import java.nio.file.FileSystem;
10
- import java.nio.file.FileSystems;
11
- import java.nio.file.Files;
12
6
  import java.sql.Connection;
13
7
  import java.sql.DriverManager;
14
8
  import java.sql.SQLException;
15
- import java.sql.Statement;
16
9
  import java.util.Arrays;
17
- import java.util.List;
18
10
 
19
- import org.embulk.input.EmbulkPluginTester;
11
+ import org.embulk.input.AbstractJdbcInputPluginTest;
20
12
  import org.embulk.input.OracleInputPlugin;
21
13
  import org.embulk.spi.InputPlugin;
22
- import org.junit.AfterClass;
23
- import org.junit.BeforeClass;
24
14
  import org.junit.Test;
25
15
 
26
- public class OracleInputPluginTest
16
+ public class OracleInputPluginTest extends AbstractJdbcInputPluginTest
27
17
  {
28
- private static boolean prepared = false;
29
- private static EmbulkPluginTester tester = new EmbulkPluginTester(InputPlugin.class, "oracle", OracleInputPlugin.class);
30
-
31
- @BeforeClass
32
- public static void prepare() throws SQLException
18
+ @Override
19
+ protected void prepare() throws SQLException
33
20
  {
21
+ tester.addPlugin(InputPlugin.class, "oracle", OracleInputPlugin.class);
22
+
34
23
  try {
35
24
  Class.forName("oracle.jdbc.OracleDriver");
36
25
  } catch (ClassNotFoundException e) {
@@ -38,75 +27,66 @@ public class OracleInputPluginTest
38
27
  return;
39
28
  }
40
29
 
41
- Connection connection;
42
30
  try {
43
- connection = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521/TESTDB", "TEST_USER", "test_pw");
31
+ connect();
44
32
  } catch (SQLException e) {
45
33
  System.err.println(e);
46
- System.err.println("Warning: prepare a schema on Oracle (database = 'TESTDB', user = 'TEST_USER', password = 'test_pw').");
34
+ System.err.println(String.format(ENGLISH, "Warning: prepare a schema on Oracle 12c (server = %s, port = %d, database = %s, user = %s, password = %s, charset = UTF-8).",
35
+ getHost(), getPort(), getDatabase(), getUser(), getPassword()));
36
+ // for example
37
+ // CREATE USER TEST_USER IDENTIFIED BY "test_pw";
38
+ // GRANT DBA TO TEST_USER;
47
39
  return;
48
40
  }
49
41
 
50
- try {
51
- try (Statement statement = connection.createStatement()) {
52
- String drop1 = "DROP TABLE TEST1";
53
- try {
54
- statement.execute(drop1);
55
- } catch (SQLException e) {
56
- System.out.println(e);
57
- }
58
-
59
- String create1 =
60
- "CREATE TABLE TEST1 ("
61
- + "C1 DECIMAL(12,2),"
62
- + "C2 CHAR(8),"
63
- + "C3 VARCHAR2(8),"
64
- + "C4 NVARCHAR2(8),"
65
- + "C5 DATE,"
66
- + "C6 TIMESTAMP,"
67
- + "C7 TIMESTAMP(3))";
68
- statement.execute(create1);
69
-
70
- String insert1 =
71
- "INSERT INTO TEST1 VALUES("
72
- + "NULL,"
73
- + "NULL,"
74
- + "NULL,"
75
- + "NULL,"
76
- + "NULL,"
77
- + "NULL,"
78
- + "NULL)";
79
- statement.executeUpdate(insert1);
80
-
81
- String insert2 =
82
- "INSERT INTO TEST1 VALUES("
83
- + "-1234567890.12,"
84
- + "'ABCDEF',"
85
- + "'XYZ',"
86
- + "'ABCDEFGH',"
87
- + "'2015-06-04',"
88
- + "'2015-06-05 23:45:06',"
89
- + "'2015-06-06 23:45:06.789')";
90
- statement.executeUpdate(insert2);
91
- }
92
-
93
- } finally {
94
- connection.close();
95
- prepared = true;
96
- }
97
- }
98
-
99
- @AfterClass
100
- public static void dispose()
101
- {
102
- tester.destroy();
42
+ enabled = true;
43
+
44
+ String drop1 = "DROP TABLE TEST1";
45
+ executeSQL(drop1, true);
46
+
47
+ String create1 =
48
+ "CREATE TABLE TEST1 ("
49
+ + "ID CHAR(2),"
50
+ + "C1 DECIMAL(12,2),"
51
+ + "C2 CHAR(8),"
52
+ + "C3 VARCHAR2(8),"
53
+ + "C4 NVARCHAR2(8),"
54
+ + "C5 DATE,"
55
+ + "C6 TIMESTAMP,"
56
+ + "C7 TIMESTAMP(3),"
57
+ + "PRIMARY KEY(ID))";
58
+ executeSQL(create1);
59
+
60
+ String insert1 =
61
+ "INSERT INTO TEST1 VALUES("
62
+ + "'10',"
63
+ + "NULL,"
64
+ + "NULL,"
65
+ + "NULL,"
66
+ + "NULL,"
67
+ + "NULL,"
68
+ + "NULL,"
69
+ + "NULL)";
70
+ executeSQL(insert1);
71
+
72
+ String insert2 =
73
+ "INSERT INTO TEST1 VALUES("
74
+ + "'11',"
75
+ + "-1234567890.12,"
76
+ + "'ABCDEF',"
77
+ + "'XYZ',"
78
+ + "'ABCDEFGH',"
79
+ + "'2015-06-04',"
80
+ + "'2015-06-05 23:45:06',"
81
+ + "'2015-06-06 23:45:06.789')";
82
+ executeSQL(insert2);
103
83
  }
104
84
 
105
85
  @Test
106
86
  public void test() throws Exception
107
87
  {
108
- if (prepared) {
109
- tester.run(convertPath("/oracle/yml/input.yml"));
88
+ if (enabled) {
89
+ test("/oracle/yml/input.yml");
110
90
  assertEquals(Arrays.asList(
111
91
  "C1,C2,C3,C4,C5,C6,C7",
112
92
  "-1.23456789012E9,ABCDEF ,XYZ,ABCDEFGH,2015-06-04,2015-06-05 23:45:06,2015-06-06 23:45:06.789",
@@ -118,8 +98,8 @@ public class OracleInputPluginTest
118
98
  @Test
119
99
  public void testLower() throws Exception
120
100
  {
121
- if (prepared) {
122
- tester.run(convertPath("/oracle/yml/input-lower.yml"));
101
+ if (enabled) {
102
+ test("/oracle/yml/input-lower.yml");
123
103
  assertEquals(Arrays.asList(
124
104
  "C1,C2,C3,C4,C5,C6,C7",
125
105
  "-1.23456789012E9,ABCDEF ,XYZ,ABCDEFGH,2015-06-04,2015-06-05 23:45:06,2015-06-06 23:45:06.789",
@@ -131,12 +111,12 @@ public class OracleInputPluginTest
131
111
  @Test
132
112
  public void testQuery() throws Exception
133
113
  {
134
- if (prepared) {
135
- tester.run(convertPath("/oracle/yml/input-query.yml"));
114
+ if (enabled) {
115
+ test("/oracle/yml/input-query.yml");
136
116
  assertEquals(Arrays.asList(
137
117
  "C1,C2,C3,C4,C5,C6,C7",
138
- ",,,,,,",
139
- "-1.23456789012E9,ABCDEF ,XYZ,ABCDEFGH,2015-06-04,2015-06-05 23:45:06,2015-06-06 23:45:06.789"),
118
+ "-1.23456789012E9,ABCDEF ,XYZ,ABCDEFGH,2015-06-04,2015-06-05 23:45:06,2015-06-06 23:45:06.789",
119
+ ",,,,,,"),
140
120
  read("oracle-input000.00.csv"));
141
121
  }
142
122
  }
@@ -144,12 +124,12 @@ public class OracleInputPluginTest
144
124
  @Test
145
125
  public void testQueryLower() throws Exception
146
126
  {
147
- if (prepared) {
148
- tester.run(convertPath("/oracle/yml/input-query-lower.yml"));
127
+ if (enabled) {
128
+ test("/oracle/yml/input-query-lower.yml");
149
129
  assertEquals(Arrays.asList(
150
130
  "C1,C2,C3,C4,C5,C6,C7",
151
- ",,,,,,",
152
- "-1.23456789012E9,ABCDEF ,XYZ,ABCDEFGH,2015-06-04,2015-06-05 23:45:06,2015-06-06 23:45:06.789"),
131
+ "-1.23456789012E9,ABCDEF ,XYZ,ABCDEFGH,2015-06-04,2015-06-05 23:45:06,2015-06-06 23:45:06.789",
132
+ ",,,,,,"),
153
133
  read("oracle-input000.00.csv"));
154
134
  }
155
135
  }
@@ -157,12 +137,12 @@ public class OracleInputPluginTest
157
137
  @Test
158
138
  public void testColumnOptions() throws Exception
159
139
  {
160
- if (prepared) {
161
- tester.run(convertPath("/oracle/yml/input-column-options.yml"));
140
+ if (enabled) {
141
+ test("/oracle/yml/input-column-options.yml");
162
142
  assertEquals(Arrays.asList(
163
- "C1,C2,C3,C4,C5,C6,C7",
164
- ",,,,,,",
165
- "-1.23456789012E9,ABCDEF ,XYZ,ABCDEFGH,2015/06/04,2015/06/05 23:45:06,2015/06/06 23:45:06.789"),
143
+ "ID,C1,C2,C3,C4,C5,C6,C7",
144
+ "10,,,,,,,",
145
+ "11,-1.23456789012E9,ABCDEF ,XYZ,ABCDEFGH,2015/06/04,2015/06/05 23:45:06,2015/06/06 23:45:06.789"),
166
146
  read("oracle-input000.00.csv"));
167
147
  }
168
148
  }
@@ -170,27 +150,20 @@ public class OracleInputPluginTest
170
150
  @Test
171
151
  public void testColumnOptionsLower() throws Exception
172
152
  {
173
- if (prepared) {
174
- tester.run(convertPath("/oracle/yml/input-column-options-lower.yml"));
153
+ if (enabled) {
154
+ test("/oracle/yml/input-column-options-lower.yml");
175
155
  assertEquals(Arrays.asList(
176
- "C1,C2,C3,C4,C5,C6,C7",
177
- ",,,,,,",
178
- "-1.23456789012E9,ABCDEF ,XYZ,ABCDEFGH,2015/06/04,2015/06/05 23:45:06,2015/06/06 23:45:06.789"),
156
+ "ID,C1,C2,C3,C4,C5,C6,C7",
157
+ "10,,,,,,,",
158
+ "11,-1.23456789012E9,ABCDEF ,XYZ,ABCDEFGH,2015/06/04,2015/06/05 23:45:06,2015/06/06 23:45:06.789"),
179
159
  read("oracle-input000.00.csv"));
180
160
  }
181
161
  }
182
162
 
183
- private List<String> read(String path) throws IOException
163
+ @Override
164
+ protected Connection connect() throws SQLException
184
165
  {
185
- FileSystem fs = FileSystems.getDefault();
186
- return Files.readAllLines(fs.getPath(path), Charset.forName("UTF8"));
187
- }
188
-
189
- private String convertPath(String name) throws URISyntaxException
190
- {
191
- if (getClass().getResource(name) == null) {
192
- return name;
193
- }
194
- return new File(getClass().getResource(name).toURI()).getAbsolutePath();
166
+ return DriverManager.getConnection(String.format(ENGLISH, "jdbc:oracle:thin:@%s:%d:%s", getHost(), getPort(), getDatabase()),
167
+ getUser(), getPassword());
195
168
  }
196
169
  }
@@ -1,11 +1,12 @@
1
1
  in:
2
2
  type: oracle
3
- host: localhost
4
- database: TESTDB
5
- user: TEST_USER
6
- password: test_pw
3
+ host: #host#
4
+ database: #database#
5
+ user: #user#
6
+ password: #password#
7
7
  table: TEST1
8
8
  select: "*"
9
+ order_by: "ID"
9
10
  column_options:
10
11
  c5: {type: string, timestamp_format: '%Y/%m/%d', timezone: "+0900"}
11
12
  c6: {type: string, timestamp_format: '%Y/%m/%d %H:%M:%S', timezone: "+0900"}
@@ -1,11 +1,12 @@
1
1
  in:
2
2
  type: oracle
3
- host: localhost
4
- database: TESTDB
5
- user: TEST_USER
6
- password: test_pw
3
+ host: #host#
4
+ database: #database#
5
+ user: #user#
6
+ password: #password#
7
7
  table: TEST1
8
8
  select: "*"
9
+ order_by: "ID"
9
10
  column_options:
10
11
  C5: {type: string, timestamp_format: '%Y/%m/%d', timezone: "+0900"}
11
12
  C6: {type: string, timestamp_format: '%Y/%m/%d %H:%M:%S', timezone: "+0900"}
@@ -1,9 +1,9 @@
1
1
  in:
2
2
  type: oracle
3
- host: localhost
4
- database: TESTDB
5
- user: TEST_USER
6
- password: test_pw
3
+ host: #host#
4
+ database: #database#
5
+ user: #user#
6
+ password: #password#
7
7
  table: test1
8
8
  select: "c1, c2, c3, c4, c5, c6, c7"
9
9
  order_by: c1
@@ -1,10 +1,10 @@
1
1
  in:
2
2
  type: oracle
3
- host: localhost
4
- database: TESTDB
5
- user: TEST_USER
6
- password: test_pw
7
- query: "select c1, c2, c3, c4, c5, c6, c7 from test1"
3
+ host: #host#
4
+ database: #database#
5
+ user: #user#
6
+ password: #password#
7
+ query: "select c1, c2, c3, c4, c5, c6, c7 from test1 order by c1"
8
8
 
9
9
  out:
10
10
  type: file
@@ -1,10 +1,10 @@
1
1
  in:
2
2
  type: oracle
3
- host: localhost
4
- database: TESTDB
5
- user: TEST_USER
6
- password: test_pw
7
- query: "SELECT C1, C2, C3, C4, C5, C6, C7 FROM TEST1"
3
+ host: #host#
4
+ database: #database#
5
+ user: #user#
6
+ password: #password#
7
+ query: "SELECT C1, C2, C3, C4, C5, C6, C7 FROM TEST1 ORDER BY C1"
8
8
 
9
9
  out:
10
10
  type: file
@@ -1,9 +1,9 @@
1
1
  in:
2
2
  type: oracle
3
- host: localhost
4
- database: TESTDB
5
- user: TEST_USER
6
- password: test_pw
3
+ host: #host#
4
+ database: #database#
5
+ user: #user#
6
+ password: #password#
7
7
  table: TEST1
8
8
  select: "C1, C2, C3, C4, C5, C6, C7"
9
9
  order_by: C1
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-input-oracle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.4
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sadayuki Furuhashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-28 00:00:00.000000000 Z
11
+ date: 2016-10-13 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Selects records from 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-input-jdbc-0.7.4.jar
23
- - classpath/embulk-input-oracle-0.7.4.jar
22
+ - classpath/embulk-input-jdbc-0.8.0.jar
23
+ - classpath/embulk-input-oracle-0.8.0.jar
24
24
  - lib/embulk/input/oracle.rb
25
25
  - src/main/java/org/embulk/input/OracleInputPlugin.java
26
26
  - src/main/java/org/embulk/input/oracle/OracleInputConnection.java