embulk 0.8.18-java → 0.8.19-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +10 -0
  3. data/build.gradle +10 -3
  4. data/embulk-cli/build.gradle +2 -0
  5. data/embulk-cli/src/main/bat/selfrun.bat +98 -0
  6. data/embulk-cli/src/main/java/org/embulk/cli/EmbulkExample.java +82 -0
  7. data/embulk-cli/src/main/java/org/embulk/cli/EmbulkMigrate.java +458 -0
  8. data/embulk-cli/src/main/java/org/embulk/cli/EmbulkNew.java +419 -0
  9. data/embulk-cli/src/main/java/org/embulk/cli/EmbulkSelfUpdate.java +248 -0
  10. data/embulk-cli/src/main/sh/selfrun.sh +0 -103
  11. data/embulk-cli/src/test/java/org/embulk/cli/SelfrunTest.java +158 -143
  12. data/embulk-core/build.gradle +2 -2
  13. data/embulk-core/src/main/java/org/embulk/EmbulkVersion.java +109 -0
  14. data/embulk-core/src/main/java/org/embulk/exec/GuessExecutor.java +11 -0
  15. data/embulk-core/src/main/java/org/embulk/exec/PreviewExecutor.java +29 -3
  16. data/embulk-core/src/main/java/org/embulk/exec/SamplingParserPlugin.java +47 -13
  17. data/embulk-core/src/main/java/org/embulk/spi/FileInputRunner.java +6 -3
  18. data/embulk-core/src/main/java/org/embulk/spi/PageBuilder.java +385 -64
  19. data/embulk-core/src/main/java/org/embulk/spi/TempFileSpace.java +2 -1
  20. data/embulk-core/src/test/java/org/embulk/spi/TestPageBuilderReader.java +62 -0
  21. data/embulk-docs/src/built-in.rst +59 -21
  22. data/embulk-docs/src/customization.rst +8 -8
  23. data/embulk-docs/src/developers/index.rst +45 -0
  24. data/embulk-docs/src/index.rst +11 -7
  25. data/embulk-docs/src/recipe.rst +1 -1
  26. data/embulk-docs/src/recipe/{scheduled-csv-load-to-elasticsearch-kibana4.rst → scheduled-csv-load-to-elasticsearch-kibana5.rst} +26 -24
  27. data/embulk-docs/src/release.rst +1 -0
  28. data/embulk-docs/src/release/release-0.4.0.rst +1 -1
  29. data/embulk-docs/src/release/release-0.5.0.rst +1 -1
  30. data/embulk-docs/src/release/release-0.6.0.rst +1 -1
  31. data/embulk-docs/src/release/release-0.6.20.rst +1 -1
  32. data/embulk-docs/src/release/release-0.8.19.rst +43 -0
  33. data/embulk-standards/src/main/java/org/embulk/standards/CsvParserPlugin.java +2 -2
  34. data/embulk-standards/src/main/java/org/embulk/standards/LocalFileInputPlugin.java +30 -1
  35. data/embulk-standards/src/test/java/org/embulk/standards/guess/TestCsvGuessPlugin.java +10 -0
  36. data/embulk-standards/src/test/java/org/embulk/standards/preview/TestFilePreview.java +73 -0
  37. data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_skip_suggest_if_empty_sample_records.csv +5 -0
  38. data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_skip_suggest_if_empty_sample_records_guessed.yml +2 -0
  39. data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_skip_suggest_if_empty_sample_records_seed.yml +1 -0
  40. data/embulk-standards/src/test/resources/org/embulk/standards/preview/file/test/test_sample_buffer_bytes.csv +5 -0
  41. data/embulk-standards/src/test/resources/org/embulk/standards/preview/file/test/test_sample_buffer_bytes_exec.yml +1 -0
  42. data/embulk-standards/src/test/resources/org/embulk/standards/preview/file/test/test_sample_buffer_bytes_load.yml +19 -0
  43. data/embulk-standards/src/test/resources/org/embulk/standards/preview/file/test/test_sample_buffer_bytes_previewed.csv +1 -0
  44. data/embulk-standards/src/test/resources/org/embulk/standards/preview/file/test/test_simple.csv +5 -0
  45. data/embulk-standards/src/test/resources/org/embulk/standards/preview/file/test/test_simple_load.yml +19 -0
  46. data/embulk-standards/src/test/resources/org/embulk/standards/preview/file/test/test_simple_previewed.csv +4 -0
  47. data/embulk-test/src/main/java/org/embulk/test/PreviewResultInputPlugin.java +65 -0
  48. data/embulk-test/src/main/java/org/embulk/test/TestingBulkLoader.java +5 -0
  49. data/embulk-test/src/main/java/org/embulk/test/TestingEmbulk.java +59 -2
  50. data/embulk.gemspec +2 -1
  51. data/lib/embulk/command/embulk_run.rb +11 -49
  52. data/lib/embulk/data/new/README.md.vm +106 -0
  53. data/lib/embulk/data/new/{gitignore.erb → gitignore.vm} +3 -3
  54. data/lib/embulk/data/new/java/{build.gradle.erb → build.gradle.vm} +8 -8
  55. data/lib/embulk/data/new/java/{decoder.java.erb → decoder.java.vm} +6 -4
  56. data/lib/embulk/data/new/java/{encoder.java.erb → encoder.java.vm} +7 -5
  57. data/lib/embulk/data/new/java/{file_input.java.erb → file_input.java.vm} +9 -7
  58. data/lib/embulk/data/new/java/{file_output.java.erb → file_output.java.vm} +7 -5
  59. data/lib/embulk/data/new/java/{filter.java.erb → filter.java.vm} +4 -3
  60. data/lib/embulk/data/new/java/{formatter.java.erb → formatter.java.vm} +5 -4
  61. data/lib/embulk/data/new/java/{input.java.erb → input.java.vm} +6 -4
  62. data/lib/embulk/data/new/java/{output.java.erb → output.java.vm} +7 -5
  63. data/lib/embulk/data/new/java/{parser.java.erb → parser.java.vm} +5 -4
  64. data/lib/embulk/data/new/java/plugin_loader.rb.vm +3 -0
  65. data/lib/embulk/data/new/java/test.java.vm +5 -0
  66. data/lib/embulk/data/new/ruby/decoder_guess.rb.vm +25 -0
  67. data/lib/embulk/data/new/ruby/{filter.rb.erb → filter.rb.vm} +2 -2
  68. data/lib/embulk/data/new/ruby/{formatter.rb.erb → formatter.rb.vm} +2 -2
  69. data/lib/embulk/data/new/ruby/gemspec.vm +20 -0
  70. data/lib/embulk/data/new/ruby/{input.rb.erb → input.rb.vm} +10 -10
  71. data/lib/embulk/data/new/ruby/{output.rb.erb → output.rb.vm} +7 -7
  72. data/lib/embulk/data/new/ruby/{parser.rb.erb → parser.rb.vm} +2 -2
  73. data/lib/embulk/data/new/ruby/parser_guess.rb.vm +65 -0
  74. data/lib/embulk/guess/csv.rb +5 -0
  75. data/lib/embulk/version.rb +22 -1
  76. metadata +55 -35
  77. data/lib/embulk/command/embulk_example.rb +0 -33
  78. data/lib/embulk/command/embulk_generate_bin.rb +0 -62
  79. data/lib/embulk/command/embulk_migrate_plugin.rb +0 -244
  80. data/lib/embulk/command/embulk_new_plugin.rb +0 -126
  81. data/lib/embulk/command/embulk_selfupdate.rb +0 -121
  82. data/lib/embulk/data/new/README.md.erb +0 -111
  83. data/lib/embulk/data/new/java/plugin_loader.rb.erb +0 -3
  84. data/lib/embulk/data/new/java/test.java.erb +0 -5
  85. data/lib/embulk/data/new/ruby/decoder_guess.rb.erb +0 -25
  86. data/lib/embulk/data/new/ruby/gemspec.erb +0 -20
  87. data/lib/embulk/data/new/ruby/parser_guess.rb.erb +0 -65
@@ -1,106 +1,3 @@
1
-
2
- : <<BAT
3
- @echo off
4
-
5
- setlocal
6
-
7
- set this=%~f0
8
- set java_args=
9
- set jruby_args=
10
- set default_optimize=
11
- set overwrite_optimize=
12
- set status=
13
- set error=
14
- set args=
15
-
16
- rem In jar file, cannot goto ahread for some reason.
17
-
18
- for %%a in ( %* ) do (
19
- call :check_arg %%a
20
- )
21
-
22
- if "%error%" == "true" exit /b 1
23
-
24
- set optimize=false
25
- if "%overwrite_optimize%" == "true" (
26
- set optimize=true
27
- ) else (
28
- if "%default_optimize%" == "true" (
29
- if not "%overwrite_optimize%" == "false" (
30
- set optimize=true
31
- )
32
- )
33
- )
34
-
35
- if "%optimize%" == "true" (
36
- set java_args=-XX:+AggressiveOpts -XX:+UseConcMarkSweepGC %java_args%
37
- ) else (
38
- set java_args=-XX:+AggressiveOpts -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Xverify:none %java_args%
39
- )
40
-
41
- java %java_args% -jar %this% %jruby_args% %args%
42
-
43
- endlocal
44
-
45
- exit /b %ERRORLEVEL%
46
-
47
- :check_arg
48
- set arg=%*
49
-
50
- rem Remove double quotations
51
- set p1=%arg:~0,1%
52
- set p1=%p1:"=%
53
- set p2=%arg:~-1,1%
54
- set p2=%p2:"=%
55
- set arg=%p1%%arg:~1,-1%%p2%
56
-
57
- if "%status%" == "rest" (
58
- set args=%args% %arg%
59
-
60
- ) else if "%status%" == "read" (
61
- call :read_file %arg%
62
-
63
- ) else if "%arg%" == "-J+O" (
64
- set overwrite_optimize=true
65
- set status=rest
66
-
67
- ) else if "%arg%" == "-J-O" (
68
- set overwrite_optimize=false
69
- set status=rest
70
-
71
- ) else if "%arg:~0,2%" == "-J" (
72
- if not "%arg:~2%" == "" (
73
- set java_args=%java_args% %arg:~2%
74
- ) else (
75
- set status=read
76
- )
77
-
78
- ) else if "%arg:~0,2%" == "-R" (
79
- set jruby_args=%jruby_args% %arg%
80
-
81
- ) else if "%arg%" == "run" (
82
- set default_optimize=true
83
- set args=%args% %arg%
84
- set status=rest
85
-
86
- ) else (
87
- set args=%args% %arg%
88
- set status=rest
89
- )
90
- exit /b
91
-
92
- :read_file
93
- if not exist "%~1" (
94
- echo "failed to load java argument file."
95
- set error=true
96
- ) else (
97
- for /f "delims=" %%i in (%~1) do set java_args=%java_args% %%i
98
- )
99
- set status=
100
- exit /b
101
-
102
- BAT
103
-
104
1
  java_args=""
105
2
  jruby_args=""
106
3
  default_optimize=""
@@ -6,13 +6,13 @@ import java.io.BufferedReader;
6
6
  import java.io.BufferedWriter;
7
7
  import java.io.File;
8
8
  import java.io.FileOutputStream;
9
- import java.io.IOException;
10
9
  import java.io.InputStreamReader;
10
+ import java.io.IOException;
11
11
  import java.io.OutputStreamWriter;
12
12
  import java.nio.charset.Charset;
13
+ import java.nio.file.Files;
13
14
  import java.nio.file.FileSystem;
14
15
  import java.nio.file.FileSystems;
15
- import java.nio.file.Files;
16
16
  import java.nio.file.StandardOpenOption;
17
17
  import java.util.Arrays;
18
18
  import java.util.List;
@@ -20,237 +20,247 @@ import java.util.List;
20
20
  import org.junit.BeforeClass;
21
21
  import org.junit.Test;
22
22
 
23
-
24
23
  public class SelfrunTest {
25
-
26
- private static File testSelfrun;
24
+ private static File testSelfrunFile;
27
25
 
28
26
  @BeforeClass
29
27
  public static void prepare() throws Exception {
30
- File selfrun = findSelfrun();
31
- FileSystem fs = FileSystems.getDefault();
32
- String line = new String(Files.readAllBytes(fs.getPath(selfrun.getAbsolutePath())), Charset.defaultCharset());
28
+ final File originalSelfrunFile = findSelfrun();
29
+ final FileSystem fileSystem = FileSystems.getDefault();
33
30
 
34
- File thisFolder = new File(SelfrunTest.class.getResource("/org/embulk/cli/SelfrunTest.class").toURI()).getParentFile();
35
- testSelfrun = new File(thisFolder, System.getProperty("file.separator").equals("\\") ? "selfrun.bat" : "selfrun.sh");
31
+ final File thisFolder = new File(
32
+ SelfrunTest.class.getResource("/org/embulk/cli/SelfrunTest.class").toURI()).getParentFile();
33
+ testSelfrunFile = new File(
34
+ thisFolder, System.getProperty("file.separator").equals("\\") ? "selfrun.bat" : "selfrun.sh");
36
35
 
37
- File classpath = thisFolder.getParentFile().getParentFile().getParentFile();
38
- line = line.replaceAll("java ", "java -classpath " + classpath.getAbsolutePath().replaceAll("\\\\", "\\\\\\\\") + " org.embulk.cli.DummyMain ");
36
+ final File classpath = thisFolder.getParentFile().getParentFile().getParentFile();
37
+ final String line =
38
+ new String(Files.readAllBytes(fileSystem.getPath(originalSelfrunFile.getAbsolutePath())),
39
+ Charset.defaultCharset())
40
+ .replaceAll("java ",
41
+ "java -classpath "
42
+ + classpath.getAbsolutePath().replaceAll("\\\\", "\\\\\\\\")
43
+ + " org.embulk.cli.DummyMain ");
39
44
 
40
45
  // Modify selfrun so that arguments are written in 'args.txt' .
41
- Files.write(fs.getPath(testSelfrun.getAbsolutePath()), line.getBytes(Charset.defaultCharset()), StandardOpenOption.CREATE);
42
- if (!testSelfrun.setExecutable(true)) {
43
- throw new Exception("Cannot se executable.");
46
+ Files.write(fileSystem.getPath(testSelfrunFile.getAbsolutePath()),
47
+ line.getBytes(Charset.defaultCharset()),
48
+ StandardOpenOption.CREATE);
49
+
50
+ if (!testSelfrunFile.setExecutable(true)) {
51
+ throw new Exception("Cannot set the copied selfrun file executable..");
44
52
  }
45
53
  }
46
54
 
47
-
48
55
  @Test
49
56
  public void testNoArgument() throws Exception {
50
57
  List<String> args = execute();
51
58
  assertEquals(Arrays.asList(
52
- "-XX:+AggressiveOpts",
53
- "-XX:+TieredCompilation",
54
- "-XX:TieredStopAtLevel=1",
55
- "-Xverify:none",
56
- "-jar",
57
- testSelfrun.getAbsolutePath()),
58
- args);
59
+ "-XX:+AggressiveOpts",
60
+ "-XX:+TieredCompilation",
61
+ "-XX:TieredStopAtLevel=1",
62
+ "-Xverify:none",
63
+ "-jar",
64
+ testSelfrunFile.getAbsolutePath()),
65
+ args);
59
66
  }
60
67
 
61
68
  @Test
62
69
  public void testArguments() throws Exception {
63
70
  List<String> args = execute("a1", "a2", "\"a3=v3\"");
64
71
  assertEquals(Arrays.asList(
65
- "-XX:+AggressiveOpts",
66
- "-XX:+TieredCompilation",
67
- "-XX:TieredStopAtLevel=1",
68
- "-Xverify:none",
69
- "-jar",
70
- testSelfrun.getAbsolutePath(),
71
- "a1",
72
- "a2",
73
- "a3=v3"),
74
- args);
72
+ "-XX:+AggressiveOpts",
73
+ "-XX:+TieredCompilation",
74
+ "-XX:TieredStopAtLevel=1",
75
+ "-Xverify:none",
76
+ "-jar",
77
+ testSelfrunFile.getAbsolutePath(),
78
+ "a1",
79
+ "a2",
80
+ "a3=v3"),
81
+ args);
75
82
  }
76
83
 
77
84
  @Test
78
85
  public void testRun() throws Exception {
79
86
  List<String> args = execute("run", "a1");
80
87
  assertEquals(Arrays.asList(
81
- "-XX:+AggressiveOpts",
82
- "-XX:+UseConcMarkSweepGC",
83
- "-jar",
84
- testSelfrun.getAbsolutePath(),
85
- "run",
86
- "a1"),
87
- args);
88
+ "-XX:+AggressiveOpts",
89
+ "-XX:+UseConcMarkSweepGC",
90
+ "-jar",
91
+ testSelfrunFile.getAbsolutePath(),
92
+ "run",
93
+ "a1"),
94
+ args);
88
95
  }
89
96
 
90
97
  @Test
91
98
  public void testJpO() throws Exception {
92
99
  List<String> args = execute("-J+O", "a1", "a2");
93
100
  assertEquals(Arrays.asList(
94
- "-XX:+AggressiveOpts",
95
- "-XX:+UseConcMarkSweepGC",
96
- "-jar",
97
- testSelfrun.getAbsolutePath(),
98
- "a1",
99
- "a2"),
100
- args);
101
+ "-XX:+AggressiveOpts",
102
+ "-XX:+UseConcMarkSweepGC",
103
+ "-jar",
104
+ testSelfrunFile.getAbsolutePath(),
105
+ "a1",
106
+ "a2"),
107
+ args);
101
108
  }
102
109
 
103
110
  @Test
104
111
  public void testJmO() throws Exception {
105
112
  List<String> args = execute("-J-O", "a1", "a2");
106
113
  assertEquals(Arrays.asList(
107
- "-XX:+AggressiveOpts",
108
- "-XX:+TieredCompilation",
109
- "-XX:TieredStopAtLevel=1",
110
- "-Xverify:none",
111
- "-jar",
112
- testSelfrun.getAbsolutePath(),
113
- "a1",
114
- "a2"),
115
- args);
114
+ "-XX:+AggressiveOpts",
115
+ "-XX:+TieredCompilation",
116
+ "-XX:TieredStopAtLevel=1",
117
+ "-Xverify:none",
118
+ "-jar",
119
+ testSelfrunFile.getAbsolutePath(),
120
+ "a1",
121
+ "a2"),
122
+ args);
116
123
  }
117
124
 
118
125
  @Test
119
126
  public void testR1() throws Exception {
120
127
  List<String> args = execute("-Rr1", "a1", "a2");
121
128
  assertEquals(Arrays.asList(
122
- "-XX:+AggressiveOpts",
123
- "-XX:+TieredCompilation",
124
- "-XX:TieredStopAtLevel=1",
125
- "-Xverify:none",
126
- "-jar",
127
- testSelfrun.getAbsolutePath(),
128
- "-Rr1",
129
- "a1",
130
- "a2"),
131
- args);
129
+ "-XX:+AggressiveOpts",
130
+ "-XX:+TieredCompilation",
131
+ "-XX:TieredStopAtLevel=1",
132
+ "-Xverify:none",
133
+ "-jar",
134
+ testSelfrunFile.getAbsolutePath(),
135
+ "-Rr1",
136
+ "a1",
137
+ "a2"),
138
+ args);
132
139
  }
133
140
 
134
141
  @Test
135
142
  public void testR2() throws Exception {
136
143
  List<String> args = execute("\"-Rr1=v1\"", "\"-Rr2=v2\"", "a1", "a2");
137
144
  assertEquals(Arrays.asList(
138
- "-XX:+AggressiveOpts",
139
- "-XX:+TieredCompilation",
140
- "-XX:TieredStopAtLevel=1",
141
- "-Xverify:none",
142
- "-jar",
143
- testSelfrun.getAbsolutePath(),
144
- "-Rr1=v1",
145
- "-Rr2=v2",
146
- "a1",
147
- "a2"),
148
- args);
145
+ "-XX:+AggressiveOpts",
146
+ "-XX:+TieredCompilation",
147
+ "-XX:TieredStopAtLevel=1",
148
+ "-Xverify:none",
149
+ "-jar",
150
+ testSelfrunFile.getAbsolutePath(),
151
+ "-Rr1=v1",
152
+ "-Rr2=v2",
153
+ "a1",
154
+ "a2"),
155
+ args);
149
156
  }
150
157
 
151
158
  @Test
152
159
  public void testRRun() throws Exception {
153
160
  List<String> args = execute("-Rr1", "run", "a1");
154
161
  assertEquals(Arrays.asList(
155
- "-XX:+AggressiveOpts",
156
- "-XX:+UseConcMarkSweepGC",
157
- "-jar",
158
- testSelfrun.getAbsolutePath(),
159
- "-Rr1",
160
- "run",
161
- "a1"),
162
- args);
162
+ "-XX:+AggressiveOpts",
163
+ "-XX:+UseConcMarkSweepGC",
164
+ "-jar",
165
+ testSelfrunFile.getAbsolutePath(),
166
+ "-Rr1",
167
+ "run",
168
+ "a1"),
169
+ args);
163
170
  }
164
171
 
165
172
  @Test
166
173
  public void testJ1() throws Exception {
167
174
  List<String> args = execute("-J-Dj1", "a1", "a2");
168
175
  assertEquals(Arrays.asList(
169
- "-XX:+AggressiveOpts",
170
- "-XX:+TieredCompilation",
171
- "-XX:TieredStopAtLevel=1",
172
- "-Xverify:none",
173
- "-Dj1",
174
- "-jar",
175
- testSelfrun.getAbsolutePath(),
176
- "a1",
177
- "a2"),
178
- args);
176
+ "-XX:+AggressiveOpts",
177
+ "-XX:+TieredCompilation",
178
+ "-XX:TieredStopAtLevel=1",
179
+ "-Xverify:none",
180
+ "-Dj1",
181
+ "-jar",
182
+ testSelfrunFile.getAbsolutePath(),
183
+ "a1",
184
+ "a2"),
185
+ args);
179
186
  }
180
187
 
181
188
  @Test
182
189
  public void testJ2() throws Exception {
183
190
  List<String> args = execute("\"-J-Dj1=v1\"", "\"-J-Dj2=v2\"", "a1", "a2");
184
191
  assertEquals(Arrays.asList(
185
- "-XX:+AggressiveOpts",
186
- "-XX:+TieredCompilation",
187
- "-XX:TieredStopAtLevel=1",
188
- "-Xverify:none",
189
- "-Dj1=v1",
190
- "-Dj2=v2",
191
- "-jar",
192
- testSelfrun.getAbsolutePath(),
193
- "a1",
194
- "a2"),
195
- args);
192
+ "-XX:+AggressiveOpts",
193
+ "-XX:+TieredCompilation",
194
+ "-XX:TieredStopAtLevel=1",
195
+ "-Xverify:none",
196
+ "-Dj1=v1",
197
+ "-Dj2=v2",
198
+ "-jar",
199
+ testSelfrunFile.getAbsolutePath(),
200
+ "a1",
201
+ "a2"),
202
+ args);
196
203
  }
197
204
 
198
205
  @Test
199
206
  public void testJR() throws Exception {
200
207
  List<String> args = execute("-Jj1", "-Rr1", "a1", "a2");
201
208
  assertEquals(Arrays.asList(
202
- "-XX:+AggressiveOpts",
203
- "-XX:+TieredCompilation",
204
- "-XX:TieredStopAtLevel=1",
205
- "-Xverify:none",
206
- "j1",
207
- "-jar",
208
- testSelfrun.getAbsolutePath(),
209
- "-Rr1",
210
- "a1",
211
- "a2"),
212
- args);
209
+ "-XX:+AggressiveOpts",
210
+ "-XX:+TieredCompilation",
211
+ "-XX:TieredStopAtLevel=1",
212
+ "-Xverify:none",
213
+ "j1",
214
+ "-jar",
215
+ testSelfrunFile.getAbsolutePath(),
216
+ "-Rr1",
217
+ "a1",
218
+ "a2"),
219
+ args);
213
220
  }
214
221
 
215
222
  @Test
216
223
  public void testJFile() throws Exception {
217
- File javaArgsFile = new File(testSelfrun.getParentFile(), "java_args.txt");
218
- FileSystem fs = FileSystems.getDefault();
219
- Files.write(fs.getPath(javaArgsFile.getAbsolutePath()), "j1 j2 j3".getBytes(Charset.defaultCharset()), StandardOpenOption.CREATE);
224
+ File javaArgsFile = new File(testSelfrunFile.getParentFile(), "java_args.txt");
225
+ FileSystem fileSystem = FileSystems.getDefault();
226
+ Files.write(fileSystem.getPath(javaArgsFile.getAbsolutePath()),
227
+ "j1 j2 j3".getBytes(Charset.defaultCharset()),
228
+ StandardOpenOption.CREATE);
220
229
 
221
230
  List<String> args = execute("-J", javaArgsFile.getAbsolutePath(), "a1", "a2");
222
231
  assertEquals(Arrays.asList(
223
- "-XX:+AggressiveOpts",
224
- "-XX:+TieredCompilation",
225
- "-XX:TieredStopAtLevel=1",
226
- "-Xverify:none",
227
- "j1",
228
- "j2",
229
- "j3",
230
- "-jar",
231
- testSelfrun.getAbsolutePath(),
232
- "a1",
233
- "a2"),
234
- args);
232
+ "-XX:+AggressiveOpts",
233
+ "-XX:+TieredCompilation",
234
+ "-XX:TieredStopAtLevel=1",
235
+ "-Xverify:none",
236
+ "j1",
237
+ "j2",
238
+ "j3",
239
+ "-jar",
240
+ testSelfrunFile.getAbsolutePath(),
241
+ "a1",
242
+ "a2"),
243
+ args);
235
244
  }
236
245
 
237
246
  private List<String> execute(String... arguments) throws Exception {
238
- File temp = new File(testSelfrun.getParentFile(), "call-" + testSelfrun.getName());
239
- try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(temp), Charset.defaultCharset()))) {
240
- writer.write(testSelfrun.getAbsolutePath());
247
+ File temp = new File(testSelfrunFile.getParentFile(), "call-" + testSelfrunFile.getName());
248
+ try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(temp),
249
+ Charset.defaultCharset()))) {
250
+ writer.write(testSelfrunFile.getAbsolutePath());
241
251
  for (String argument : arguments) {
242
252
  writer.write(" ");
243
253
  writer.write(argument);
244
254
  }
245
255
  }
246
256
  if (!temp.setExecutable(true)) {
247
- throw new Exception("Cannot se executable.");
257
+ throw new Exception("Cannot set the copied selfrun file executable..");
248
258
  }
249
259
 
250
- File argsFile = new File(testSelfrun.getParentFile(), "args.txt");
260
+ File argsFile = new File(testSelfrunFile.getParentFile(), "args.txt");
251
261
  if (argsFile.exists()) {
252
262
  if (!argsFile.delete()) {
253
- throw new IOException("Cannot delete " + argsFile);
263
+ throw new IOException("Cannot delete " + argsFile);
254
264
  }
255
265
  }
256
266
 
@@ -258,15 +268,17 @@ public class SelfrunTest {
258
268
  int exitCode = process.waitFor();
259
269
  if (exitCode != 0 || !argsFile.exists()) {
260
270
  StringBuilder builder = new StringBuilder();
261
- try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getErrorStream(), Charset.defaultCharset()))) {
271
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getErrorStream(),
272
+ Charset.defaultCharset()))) {
262
273
  builder.append(reader.readLine());
263
274
  builder.append(System.getProperty("line.separator"));
264
275
  }
265
276
  throw new Exception(builder.toString());
266
277
  }
267
278
 
268
- FileSystem fs = FileSystems.getDefault();
269
- List<String> args = Files.readAllLines(fs.getPath(argsFile.getAbsolutePath()), Charset.defaultCharset());
279
+ FileSystem fileSystem = FileSystems.getDefault();
280
+ List<String> args = Files.readAllLines(fileSystem.getPath(argsFile.getAbsolutePath()),
281
+ Charset.defaultCharset());
270
282
  return args;
271
283
  }
272
284
 
@@ -275,7 +287,10 @@ public class SelfrunTest {
275
287
  if (new File(folder, "embulk-cli").exists()) {
276
288
  folder = new File(folder, "embulk-cli");
277
289
  }
278
- return new File(new File(new File(new File(folder, "src"), "main"), "sh"), "selfrun.sh");
290
+ if (System.getProperty("file.separator").equals("\\")) {
291
+ return new File(new File(new File(new File(folder, "src"), "main"), "bat"), "selfrun.bat");
292
+ } else {
293
+ return new File(new File(new File(new File(folder, "src"), "main"), "sh"), "selfrun.sh");
294
+ }
279
295
  }
280
-
281
296
  }