Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test case for windows service where JAVA_HOME path contains spaces #53028

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.Matchers.isEmptyString;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.Assume.assumeThat;
import static org.junit.Assume.assumeTrue;

Expand Down Expand Up @@ -99,12 +100,32 @@ public void test31BadJavaHome() throws Exception {
sh.getEnv().put("JAVA_HOME", "doesnotexist");

// ask for elasticsearch version to quickly exit if java is actually found (ie test failure)
final Result runResult = sh.runIgnoreExitCode(bin.elasticsearch.toString() + " -v");
final Result runResult = sh.runIgnoreExitCode(bin.elasticsearch.toString() + " -V");
assertThat(runResult.exitCode, is(1));
assertThat(runResult.stderr, containsString("could not find java in JAVA_HOME"));

}

public void test32SpecialCharactersInJdkPath() throws Exception {
final Installation.Executables bin = installation.executables();

final Path relocatedJdk = installation.bundledJdk.getParent().resolve("a (special) path");
sh.getEnv().put("JAVA_HOME", relocatedJdk.toString());

try {
if (distribution().hasJdk) {
mv(installation.bundledJdk, relocatedJdk);
}
// ask for elasticsearch version to avoid starting the app
final Result runResult = sh.run(bin.elasticsearch.toString() + " -V");
assertThat(runResult.stdout, startsWith("Version: "));
} finally {
if (distribution().hasJdk) {
mv(relocatedJdk, installation.bundledJdk);
}
}
}

public void test50StartAndStop() throws Exception {
// cleanup from previous test
rm(installation.config("elasticsearch.keystore"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,20 @@ public void test15RemoveNotInstalled() {
assertThat(result.stdout, containsString("Failed removing '" + DEFAULT_ID + "' service"));
}

public void test16InstallSpecialCharactersInJdkPath() throws IOException {
final Path relocatedJdk = installation.bundledJdk.getParent().resolve("a (special) jdk");
sh.getEnv().put("JAVA_HOME", relocatedJdk.toString());

try {
mv(installation.bundledJdk, relocatedJdk);
Result result = sh.run(serviceScript + " install");
assertThat(result.stdout, containsString("The service 'elasticsearch-service-x64' has been installed."));
} finally {
sh.runIgnoreExitCode(serviceScript + " remove");
mv(relocatedJdk, installation.bundledJdk);
}
}

public void test20CustomizeServiceId() {
String serviceId = "my-es-service";
String displayName = DEFAULT_DISPLAY_NAME.replace(DEFAULT_ID, serviceId);
Expand Down