38 // more java options, but to be set AFTER the test Java options
39 public ArrayList<String> javaOptsAppended = new ArrayList<>();
40 public String classToRun; // class or "-version"
41 public ArrayList<String> classParams = new ArrayList<>();
42
43 public boolean tty = true;
44 public boolean removeContainerAfterUse = true;
45 public boolean appendTestJavaOptions = true;
46 public boolean retainChildStdout = false;
47
48 /**
49 * Convenience constructor for most common use cases in testing.
50 * @param imageNameAndTag a string representing name and tag for the
51 * docker image to run, as "name:tag"
52 * @param javaCmd a java command to run (e.g. /jdk/bin/java)
53 * @param classToRun a class to run, or "-version"
54 * @param javaOpts java options to use
55 *
56 * @return Default docker run options
57 */
58 public DockerRunOptions(String imageNameAndTag, String javaCmd,
59 String classToRun, String... javaOpts) {
60 this.imageNameAndTag = imageNameAndTag;
61 this.command = javaCmd;
62 this.classToRun = classToRun;
63 this.addJavaOpts(javaOpts);
64 // always print hserr to stderr in the docker tests to avoid
65 // trouble accessing it after a crash in the container
66 this.addJavaOpts("-XX:+ErrorFileToStderr");
67 }
68
69 public final DockerRunOptions addDockerOpts(String... opts) {
70 Collections.addAll(dockerOpts, opts);
71 return this;
72 }
73
74 public final DockerRunOptions addEngineOpts(String... opts) {
75 Collections.addAll(engineOpts, opts);
76 return this;
77 }
|
38 // more java options, but to be set AFTER the test Java options
39 public ArrayList<String> javaOptsAppended = new ArrayList<>();
40 public String classToRun; // class or "-version"
41 public ArrayList<String> classParams = new ArrayList<>();
42
43 public boolean tty = true;
44 public boolean removeContainerAfterUse = true;
45 public boolean appendTestJavaOptions = true;
46 public boolean retainChildStdout = false;
47
48 /**
49 * Convenience constructor for most common use cases in testing.
50 * @param imageNameAndTag a string representing name and tag for the
51 * docker image to run, as "name:tag"
52 * @param javaCmd a java command to run (e.g. /jdk/bin/java)
53 * @param classToRun a class to run, or "-version"
54 * @param javaOpts java options to use
55 *
56 * @return Default docker run options
57 */
58 @SuppressWarnings("initialization")
59 public DockerRunOptions(String imageNameAndTag, String javaCmd,
60 String classToRun, String... javaOpts) {
61 this.imageNameAndTag = imageNameAndTag;
62 this.command = javaCmd;
63 this.classToRun = classToRun;
64 this.addJavaOpts(javaOpts);
65 // always print hserr to stderr in the docker tests to avoid
66 // trouble accessing it after a crash in the container
67 this.addJavaOpts("-XX:+ErrorFileToStderr");
68 }
69
70 public final DockerRunOptions addDockerOpts(String... opts) {
71 Collections.addAll(dockerOpts, opts);
72 return this;
73 }
74
75 public final DockerRunOptions addEngineOpts(String... opts) {
76 Collections.addAll(engineOpts, opts);
77 return this;
78 }
|