|
22 | 22 | import com.carrotsearch.randomizedtesting.annotations.TestCaseOrdering;
|
23 | 23 | import org.apache.http.client.fluent.Request;
|
24 | 24 | import org.elasticsearch.packaging.util.Archives;
|
| 25 | +import org.elasticsearch.packaging.util.Distribution; |
| 26 | +import org.elasticsearch.packaging.util.Installation; |
25 | 27 | import org.elasticsearch.packaging.util.Platforms;
|
26 | 28 | import org.elasticsearch.packaging.util.ServerUtils;
|
27 | 29 | import org.elasticsearch.packaging.util.Shell;
|
28 | 30 | import org.elasticsearch.packaging.util.Shell.Result;
|
29 | 31 | import org.junit.Before;
|
30 | 32 | import org.junit.BeforeClass;
|
31 | 33 |
|
32 |
| -import org.elasticsearch.packaging.util.Distribution; |
33 |
| -import org.elasticsearch.packaging.util.Installation; |
34 |
| - |
35 | 34 | import java.io.IOException;
|
36 | 35 | import java.nio.file.Files;
|
37 | 36 | import java.nio.file.Path;
|
|
40 | 39 |
|
41 | 40 | import static java.util.stream.Collectors.joining;
|
42 | 41 | import static org.elasticsearch.packaging.util.Archives.ARCHIVE_OWNER;
|
43 |
| -import static org.elasticsearch.packaging.util.Cleanup.cleanEverything; |
44 | 42 | import static org.elasticsearch.packaging.util.Archives.installArchive;
|
45 | 43 | import static org.elasticsearch.packaging.util.Archives.verifyArchiveInstallation;
|
| 44 | +import static org.elasticsearch.packaging.util.Cleanup.cleanEverything; |
46 | 45 | import static org.elasticsearch.packaging.util.FileMatcher.Fileness.File;
|
47 | 46 | import static org.elasticsearch.packaging.util.FileMatcher.file;
|
48 | 47 | import static org.elasticsearch.packaging.util.FileMatcher.p660;
|
@@ -193,6 +192,39 @@ public void test50StartAndStop() throws IOException {
|
193 | 192 | Archives.stopElasticsearch(installation);
|
194 | 193 | }
|
195 | 194 |
|
| 195 | + public void test51JavaHomeContainParansAndSpace() throws IOException { |
| 196 | + assumeThat(installation, is(notNullValue())); |
| 197 | + |
| 198 | + Platforms.onWindows(() -> { |
| 199 | + final Shell sh = new Shell(); |
| 200 | + final String originalPath = sh.run("$Env:PATH").stdout.trim(); |
| 201 | + final String javaHome = sh.run("$Env:JAVA_HOME").stdout.trim(); |
| 202 | + |
| 203 | + try { |
| 204 | + final String newPath = Arrays.stream(originalPath.split(";")) |
| 205 | + .filter(path -> path.contains("Java") == false) |
| 206 | + .collect(joining(";")); |
| 207 | + |
| 208 | + sh.runIgnoreExitCode("cmd /c mklink /D 'C:\\Program Files (x86)\\java' $Env:JAVA_HOME"); |
| 209 | + |
| 210 | + sh.getEnv().put("PATH", newPath); |
| 211 | + sh.getEnv().put("JAVA_HOME", "C:\\Program Files (x86)\\java"); |
| 212 | + |
| 213 | + Archives.runElasticsearch(installation, sh); |
| 214 | + |
| 215 | + Archives.stopElasticsearch(installation); |
| 216 | + } catch (IOException e) { |
| 217 | + logger.error("Test failed with exception", e); |
| 218 | + }finally { |
| 219 | + //clean up sym link |
| 220 | + sh.runIgnoreExitCode("cmd /c del /F /Q 'C:\\Program Files (x86)\\java' "); |
| 221 | + sh.getEnv().put("PATH", originalPath); |
| 222 | + sh.getEnv().put("JAVA_HOME", javaHome); |
| 223 | + |
| 224 | + } |
| 225 | + }); |
| 226 | + } |
| 227 | + |
196 | 228 | public void test60AutoCreateKeystore() {
|
197 | 229 | assumeThat(installation, is(notNullValue()));
|
198 | 230 |
|
|
0 commit comments