35
35
36
36
import org .apache .commons .io .FileUtils ;
37
37
import org .apache .tika .TikaTest ;
38
+ import org .apache .tika .utils .ProcessUtils ;
38
39
import org .junit .AfterClass ;
39
40
import org .junit .BeforeClass ;
40
41
import org .junit .Ignore ;
@@ -123,9 +124,14 @@ private static void compare() throws IOException {
123
124
List <String > args = new ArrayList <>();
124
125
args .add ("Compare" );
125
126
args .add ("-extractsA" );
126
- args .add (extractsDir .resolve ("extractsA" ).toAbsolutePath ().toString ());
127
+ args .add (
128
+ ProcessUtils .escapeCommandLine (
129
+ extractsDir .resolve ("extractsA" )
130
+ .toAbsolutePath ().toString ()));
127
131
args .add ("-extractsB" );
128
- args .add (extractsDir .resolve ("extractsB" ).toAbsolutePath ().toString ());
132
+ args .add (ProcessUtils .escapeCommandLine (
133
+ extractsDir .resolve ("extractsB" )
134
+ .toAbsolutePath ().toString ()));
129
135
//add these just to confirm this info doesn't cause problems w cli
130
136
args .add ("-maxTokens" );
131
137
args .add ("10000000" );
@@ -135,7 +141,10 @@ private static void compare() throws IOException {
135
141
args .add ("100000" );
136
142
137
143
args .add ("-db" );
138
- args .add (compareDBDir .toAbsolutePath ().toString ()+"/" +dbName );
144
+ args .add (
145
+ ProcessUtils .escapeCommandLine (
146
+ compareDBDir
147
+ .toAbsolutePath ().toString ()+"/" +dbName ));
139
148
140
149
execute (args , 60000 );
141
150
@@ -145,7 +154,9 @@ private static void profile() throws IOException {
145
154
List <String > args = new ArrayList <>();
146
155
args .add ("Profile" );
147
156
args .add ("-extracts" );
148
- args .add (extractsDir .resolve ("extractsA" ).toAbsolutePath ().toString ());
157
+ args .add (ProcessUtils .escapeCommandLine (
158
+ extractsDir .resolve ("extractsA" )
159
+ .toAbsolutePath ().toString ()));
149
160
//add these just to confirm this info doesn't cause problems w cli
150
161
args .add ("-maxTokens" );
151
162
args .add ("10000000" );
@@ -155,27 +166,39 @@ private static void profile() throws IOException {
155
166
args .add ("100000" );
156
167
157
168
args .add ("-db" );
158
- args .add (profileDBDir .toAbsolutePath ().toString ()+"/" +dbName );
169
+ args .add (
170
+ ProcessUtils .escapeCommandLine (
171
+ profileDBDir
172
+ .toAbsolutePath ().toString ()+"/" +dbName ));
159
173
execute (args , 60000 );
160
174
}
161
175
162
176
private static void reportProfile () throws IOException {
163
177
List <String > args = new ArrayList <>();
164
178
args .add ("Report" );
165
179
args .add ("-db" );
166
- args .add (profileDBDir .toAbsolutePath ().toString ()+"/" +dbName );
180
+ args .add (
181
+ ProcessUtils .escapeCommandLine (
182
+ profileDBDir .toAbsolutePath ()
183
+ .toString ()+"/" +dbName ));
167
184
args .add ("-rd" );
168
- args .add (profileReportsDir .toAbsolutePath ().toString ());
185
+ args .add (
186
+ ProcessUtils .escapeCommandLine (
187
+ profileReportsDir .toAbsolutePath ().toString ()));
169
188
execute (args , 60000 );
170
189
}
171
190
172
191
private static void reportCompare () throws IOException {
173
192
List <String > args = new ArrayList <>();
174
193
args .add ("Report" );
175
194
args .add ("-db" );
176
- args .add (compareDBDir .toAbsolutePath ().toString ()+"/" +dbName );
195
+ args .add (
196
+ ProcessUtils .escapeCommandLine (
197
+ compareDBDir .toAbsolutePath ().toString ()+"/" +dbName ));
177
198
args .add ("-rd" );
178
- args .add (compareReportsDir .toAbsolutePath ().toString ());
199
+ args .add (
200
+ ProcessUtils .escapeCommandLine (
201
+ compareReportsDir .toAbsolutePath ().toString ()));
179
202
execute (args , 60000 );
180
203
}
181
204
@@ -186,11 +209,20 @@ public void testOneOff() throws Exception {
186
209
List <String > args = new ArrayList <>();
187
210
args .add ("Compare" );
188
211
args .add ("-extractsA" );
189
- args .add (extractsDir .resolve ("extractsA" ).toAbsolutePath ().toString ());
212
+ args .add (
213
+ ProcessUtils .escapeCommandLine (
214
+ extractsDir .resolve ("extractsA" )
215
+ .toAbsolutePath ().toString ()));
190
216
args .add ("-extractsB" );
191
- args .add (extractsDir .resolve ("extractsB" ).toAbsolutePath ().toString ());
217
+ args .add (
218
+ ProcessUtils .escapeCommandLine (
219
+ extractsDir .resolve ("extractsB" )
220
+ .toAbsolutePath ().toString ()));
192
221
args .add ("-db" );
193
- args .add (compareDBDir .toAbsolutePath ().toString ()+"/" +dbName );
222
+ args .add (
223
+ ProcessUtils .escapeCommandLine (
224
+ compareDBDir .toAbsolutePath ()
225
+ .toString ()+"/" +dbName ));
194
226
195
227
execute (args , 60000 );
196
228
// args.add("-drop");
@@ -202,6 +234,7 @@ private static void execute(List<String> incomingArgs, long maxMillis) throws IO
202
234
List <String > args = new ArrayList <>();
203
235
String cp = System .getProperty ("java.class.path" );
204
236
args .add ("java" );
237
+ args .add ("-Djava.awt.headless=true" );
205
238
args .add ("-cp" );
206
239
args .add (cp );
207
240
args .add ("org.apache.tika.eval.TikaEvalCLI" );
0 commit comments