191 *
192 * @param DockerRunOptions options for running docker
193 *
194 * @return command
195 * @throws Exception
196 */
197 public static List<String> buildJavaCommand(DockerRunOptions opts) throws Exception {
198 List<String> cmd = new ArrayList<>();
199
200 cmd.add(Container.ENGINE_COMMAND);
201 cmd.add("run");
202 if (opts.tty)
203 cmd.add("--tty=true");
204 if (opts.removeContainerAfterUse)
205 cmd.add("--rm");
206
207 cmd.addAll(opts.dockerOpts);
208 cmd.add(opts.imageNameAndTag);
209 cmd.add(opts.command);
210
211 cmd.addAll(opts.javaOpts);
212 if (opts.appendTestJavaOptions) {
213 Collections.addAll(cmd, Utils.getTestJavaOpts());
214 }
215
216 cmd.add(opts.classToRun);
217 cmd.addAll(opts.classParams);
218
219 return cmd;
220 }
221
222 /**
223 * Run Java inside the docker image with specified parameters and options.
224 *
225 * @param DockerRunOptions options for running docker
226 *
227 * @return output of the run command
228 * @throws Exception
229 */
230 public static OutputAnalyzer dockerRunJava(DockerRunOptions opts) throws Exception {
231 return execute(buildJavaCommand(opts));
232 }
233
234
|
191 *
192 * @param DockerRunOptions options for running docker
193 *
194 * @return command
195 * @throws Exception
196 */
197 public static List<String> buildJavaCommand(DockerRunOptions opts) throws Exception {
198 List<String> cmd = new ArrayList<>();
199
200 cmd.add(Container.ENGINE_COMMAND);
201 cmd.add("run");
202 if (opts.tty)
203 cmd.add("--tty=true");
204 if (opts.removeContainerAfterUse)
205 cmd.add("--rm");
206
207 cmd.addAll(opts.dockerOpts);
208 cmd.add(opts.imageNameAndTag);
209 cmd.add(opts.command);
210
211 // move after test java options
212 //cmd.addAll(opts.javaOpts);
213 if (opts.appendTestJavaOptions) {
214 Collections.addAll(cmd, Utils.getTestJavaOpts());
215 }
216 cmd.addAll(opts.javaOpts);
217
218 cmd.add(opts.classToRun);
219 cmd.addAll(opts.classParams);
220
221 return cmd;
222 }
223
224 /**
225 * Run Java inside the docker image with specified parameters and options.
226 *
227 * @param DockerRunOptions options for running docker
228 *
229 * @return output of the run command
230 * @throws Exception
231 */
232 public static OutputAnalyzer dockerRunJava(DockerRunOptions opts) throws Exception {
233 return execute(buildJavaCommand(opts));
234 }
235
236
|