embulk-input-sqlserver 0.9.0 → 0.9.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aeb5fdb1e2052094319ffd9523d1a2af66cf4b91
4
- data.tar.gz: b3d7243830262fbae4c265cb8e248e3a81cea6fb
3
+ metadata.gz: 2a28bc0a24889fb4b87c8ce28838c6ed3a85bad7
4
+ data.tar.gz: 25afe54eb3dab0944c644fbc53fdf4325ee1a28d
5
5
  SHA512:
6
- metadata.gz: 5be091106d42670ae06d736fd0f2b7d585f067ca18e266bfa19477c61f1fa07750b45fcf4c593e764ca6f2b35151c9da0a4e7d3eb68121c9570e4380852d1871
7
- data.tar.gz: 93696785f29ea5e78530f53bb7c7edcd72bc3ca1f20889a6689bfffd0d912a4a7dfb0d57143eb509220e0a42e3720f8ec04d88e86f7692d5a8c0439d861971bb
6
+ metadata.gz: 4550243e5b325368420f04798f53281f18facf4f083088e14e8b5ac7c8fe502593ef2ff5cfc75e973e9f29dfd0817a2f2685d3a6c289070afb19e3afc0b511ba
7
+ data.tar.gz: a00150591fd92378df2ef32900f5b6fda039c46ec60793158dd2d2e62232c540f21f1e89cdb731d301ec34ca3a8adbaf1aacf59dd4de2f7ebada70f94571dfa8
data/build.gradle CHANGED
@@ -2,5 +2,5 @@ dependencies {
2
2
  compile project(':embulk-input-jdbc')
3
3
  compile 'net.sourceforge.jtds:jtds:1.3.1'
4
4
 
5
- testCompile project(':embulk-input-jdbc').sourceSets.test.output
5
+ testCompile 'org.embulk:embulk-standards:0.8.15'
6
6
  }
@@ -0,0 +1,56 @@
1
+ package org.embulk.input.sqlserver;
2
+
3
+ import static org.embulk.input.sqlserver.SQLServerTests.execute;
4
+ import static org.embulk.test.EmbulkTests.readSortedFile;
5
+ import static org.hamcrest.Matchers.is;
6
+ import static org.junit.Assert.assertThat;
7
+
8
+ import java.nio.file.Path;
9
+
10
+ import org.embulk.config.ConfigDiff;
11
+ import org.embulk.config.ConfigSource;
12
+ import org.embulk.input.SQLServerInputPlugin;
13
+ import org.embulk.spi.InputPlugin;
14
+ import org.embulk.test.EmbulkTests;
15
+ import org.embulk.test.TestingEmbulk;
16
+ import org.junit.Before;
17
+ import org.junit.Rule;
18
+ import org.junit.Test;
19
+
20
+ public class BasicTest
21
+ {
22
+ private static final String BASIC_RESOURCE_PATH = "org/embulk/input/sqlserver/test/expect/basic/";
23
+
24
+ private static ConfigSource loadYamlResource(TestingEmbulk embulk, String fileName)
25
+ {
26
+ return embulk.loadYamlResource(BASIC_RESOURCE_PATH + fileName);
27
+ }
28
+
29
+ private static String readResource(String fileName)
30
+ {
31
+ return EmbulkTests.readResource(BASIC_RESOURCE_PATH + fileName);
32
+ }
33
+
34
+ @Rule
35
+ public TestingEmbulk embulk = TestingEmbulk.builder()
36
+ .registerPlugin(InputPlugin.class, "sqlserver", SQLServerInputPlugin.class)
37
+ .build();
38
+
39
+ private ConfigSource baseConfig;
40
+
41
+ @Before
42
+ public void setup()
43
+ {
44
+ baseConfig = SQLServerTests.baseConfig();
45
+ execute(readResource("setup.sql")); // setup rows
46
+ }
47
+
48
+ @Test
49
+ public void test() throws Exception
50
+ {
51
+ Path out1 = embulk.createTempFile("csv");
52
+ TestingEmbulk.RunResult result1 = embulk.runInput(baseConfig.merge(loadYamlResource(embulk, "test_config.yml")), out1);
53
+ assertThat(readSortedFile(out1), is(readResource("test_expected.csv")));
54
+ assertThat(result1.getConfigDiff(), is((ConfigDiff) loadYamlResource(embulk, "test_expected.diff")));
55
+ }
56
+ }
@@ -0,0 +1,80 @@
1
+ package org.embulk.input.sqlserver;
2
+
3
+ import static java.util.Locale.ENGLISH;
4
+
5
+ import java.io.IOException;
6
+ import java.nio.charset.Charset;
7
+ import java.nio.file.Files;
8
+ import java.nio.file.Path;
9
+ import java.util.Collections;
10
+ import java.util.List;
11
+
12
+ import org.embulk.config.ConfigSource;
13
+ import org.embulk.test.EmbulkTests;
14
+ import org.embulk.test.TestingEmbulk;
15
+
16
+ import com.google.common.base.Throwables;
17
+ import com.google.common.collect.ImmutableList;
18
+ import com.google.common.io.ByteStreams;
19
+
20
+ public class SQLServerTests
21
+ {
22
+ public static ConfigSource baseConfig()
23
+ {
24
+ return EmbulkTests.config("EMBULK_INPUT_SQLSERVER_TEST_CONFIG");
25
+ }
26
+
27
+ public static void execute(String sql, String... options)
28
+ {
29
+ ConfigSource config = baseConfig();
30
+
31
+ ImmutableList.Builder<String> args = ImmutableList.builder();
32
+ args.add("sqlcmd")
33
+ .add("-U")
34
+ .add(config.get(String.class, "user"))
35
+ .add("-P")
36
+ .add(config.get(String.class, "password"))
37
+ .add("-H")
38
+ .add(config.get(String.class, "host"))
39
+ .add("-d")
40
+ .add(config.get(String.class, "database"))
41
+ .add("-Q")
42
+ .add(sql);
43
+ for (String option : options) {
44
+ args.add(option);
45
+ }
46
+
47
+ ProcessBuilder pb = new ProcessBuilder(args.build());
48
+ pb.redirectErrorStream(true);
49
+ int code;
50
+ try {
51
+ Process process = pb.start();
52
+ ByteStreams.copy(process.getInputStream(), System.out);
53
+ code = process.waitFor();
54
+ } catch (IOException | InterruptedException ex) {
55
+ throw Throwables.propagate(ex);
56
+ }
57
+ if (code != 0) {
58
+ throw new RuntimeException(String.format(ENGLISH,
59
+ "Command finished with non-zero exit code. Exit code is %d.", code));
60
+ }
61
+ }
62
+
63
+ public static String selectRecords(TestingEmbulk embulk, String tableName) throws IOException
64
+ {
65
+ Path temp = embulk.createTempFile("txt");
66
+ Files.delete(temp);
67
+
68
+ // should not use UTF8 because of BOM
69
+ execute("SET NOCOUNT ON; SELECT * FROM " + tableName, "-h", "-1", "-s", ",", "-W", "-f", "932", "-o", temp.toString());
70
+
71
+ List<String> lines = Files.readAllLines(temp, Charset.forName("MS932"));
72
+ Collections.sort(lines);
73
+ StringBuilder sb = new StringBuilder();
74
+ for (String line : lines) {
75
+ sb.append(line);
76
+ sb.append("\n");
77
+ }
78
+ return sb.toString();
79
+ }
80
+ }
@@ -0,0 +1,58 @@
1
+ DROP TABLE TEST1
2
+ CREATE TABLE TEST1 (
3
+ ID CHAR(4),
4
+ TINYINT_ITEM TINYINT,
5
+ SMALLINT_ITEM SMALLINT,
6
+ INT_ITEM INT,
7
+ BIGINT_ITEM BIGINT,
8
+ BIT_ITEM BIT,
9
+ DECIMAL_ITEM DECIMAL(12,2),
10
+ NUMERIC_ITEM NUMERIC(5,3),
11
+ SMALLMONEY_ITEM SMALLMONEY,
12
+ MONEY_ITEM MONEY,
13
+ REAL_ITEM REAL,
14
+ FLOAT_ITEM FLOAT,
15
+ CHAR_ITEM CHAR(4),
16
+ VARCHAR_ITEM VARCHAR(8),
17
+ TEXT_ITEM TEXT,
18
+ NCHAR_ITEM NCHAR(4),
19
+ NVARCHAR_ITEM NVARCHAR(8),
20
+ NTEXT_ITEM NTEXT,
21
+ DATE_ITEM DATE,
22
+ DATETIME_ITEM DATETIME,
23
+ DATETIME2_ITEM DATETIME2,
24
+ DATETIME2_2_ITEM DATETIME2(2),
25
+ SMALLDATETIME_ITEM SMALLDATETIME,
26
+ TIME_ITEM TIME,
27
+ TIME_2_ITEM TIME(2),
28
+ PRIMARY KEY (ID)
29
+ );
30
+ INSERT INTO TEST1(ID) VALUES('1000');
31
+ INSERT INTO TEST1 VALUES(
32
+ '1001',
33
+ 12,
34
+ 1234,
35
+ 123456,
36
+ 12345678901234,
37
+ 1,
38
+ 1234567890.12,
39
+ 12.345,
40
+ 12.3456,
41
+ 1234.5678,
42
+ 1234567.8,
43
+ 123456789012.34,
44
+ 'a',
45
+ 'A',
46
+ 'abcdefg',
47
+ 'あ',
48
+ 'ア',
49
+ 'あいうえお',
50
+ '2018-01-02',
51
+ '2018-01-03 12:34:56.789',
52
+ '2018-01-04 12:34:56.1234567',
53
+ '2018-01-05 12:34:56.89',
54
+ '2018-01-06 12:34:56',
55
+ '17:34:56.1234567',
56
+ '18:34:56.12'
57
+ );
58
+
@@ -0,0 +1,2 @@
1
+ table: TEST1
2
+ order_by: 'ID'
@@ -0,0 +1,2 @@
1
+ 1000,,,,,,,,,,,,,,,,,,,,,,,,
2
+ 1001,12,1234,123456,12345678901234,true,1.23456789012E9,12.345,12.3456,1234.5678,1234567.75,1.2345678901234E11,a ,A,abcdefg,あ ,ア,あいうえお,2018-01-02,2018-01-03 10:34:56.790000 +0000,2018-01-04 12:34:56.1234567,2018-01-05 12:34:56.89,2018-01-06 10:35:00.000000 +0000,17:34:56.1234567,18:34:56.12
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-input-sqlserver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
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-12-27 00:00:00.000000000 Z
11
+ date: 2018-03-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Selects records from a table.
14
14
  email:
@@ -19,12 +19,18 @@ extra_rdoc_files: []
19
19
  files:
20
20
  - README.md
21
21
  - build.gradle
22
- - classpath/embulk-input-jdbc-0.9.0.jar
23
- - classpath/embulk-input-sqlserver-0.9.0.jar
22
+ - classpath/embulk-input-jdbc-0.9.1.jar
23
+ - classpath/embulk-input-sqlserver-0.9.1.jar
24
24
  - classpath/jtds-1.3.1.jar
25
25
  - lib/embulk/input/sqlserver.rb
26
26
  - src/main/java/org/embulk/input/SQLServerInputPlugin.java
27
27
  - src/main/java/org/embulk/input/sqlserver/SQLServerInputConnection.java
28
+ - src/test/java/org/embulk/input/sqlserver/BasicTest.java
29
+ - src/test/java/org/embulk/input/sqlserver/SQLServerTests.java
30
+ - src/test/resources/org/embulk/input/sqlserver/test/expect/basic/setup.sql
31
+ - src/test/resources/org/embulk/input/sqlserver/test/expect/basic/test_config.yml
32
+ - src/test/resources/org/embulk/input/sqlserver/test/expect/basic/test_expected.csv
33
+ - src/test/resources/org/embulk/input/sqlserver/test/expect/basic/test_expected.diff
28
34
  homepage: https://github.com/embulk/embulk-input-jdbc
29
35
  licenses:
30
36
  - Apache 2.0