Merge pull request #35 from dbuchko/master

# By Daniel L. Buchko
* pull35:
  Prevent test failures under Windows
  Fixed handling of spaces in file paths
This commit is contained in:
Phillip Webb
2013-08-24 18:52:34 -07:00
2 changed files with 7 additions and 7 deletions
@@ -18,6 +18,7 @@ package org.springframework.boot.loader;
import java.io.File;
import java.lang.reflect.Constructor;
import java.net.URI;
import java.net.URL;
import java.security.CodeSource;
import java.security.ProtectionDomain;
@@ -67,13 +68,12 @@ public abstract class Launcher {
protected void launch(String[] args, ProtectionDomain protectionDomain)
throws Exception {
CodeSource codeSource = protectionDomain.getCodeSource();
URL codeSourceLocation = (codeSource == null ? null : codeSource.getLocation());
String codeSourcePath = (codeSourceLocation == null ? null : codeSourceLocation
.getPath());
if (codeSourcePath == null) {
URI location = (codeSource == null ? null : codeSource.getLocation().toURI());
String path = (location == null ? null : location.getPath());
if (path == null) {
throw new IllegalStateException("Unable to determine code source archive");
}
File root = new File(codeSourcePath);
File root = new File(path);
if (!root.exists()) {
throw new IllegalStateException(
"Unable to determine code source archive from " + root);
@@ -109,7 +109,7 @@ public class ExplodedArchiveTests {
Entry entry = getEntriesMap(this.archive).get("nested.jar");
Archive nested = this.archive.getNestedArchive(entry);
assertThat(nested.getUrl().toString(),
equalTo("jar:file:" + this.rootFolder.getPath() + "/nested.jar!/"));
equalTo("jar:file:" + this.rootFolder.getPath() + File.separator + "nested.jar!/"));
}
@Test
@@ -119,7 +119,7 @@ public class ExplodedArchiveTests {
Map<String, Entry> nestedEntries = getEntriesMap(nested);
assertThat(nestedEntries.size(), equalTo(1));
assertThat(nested.getUrl().toString(),
equalTo("file:" + this.rootFolder.getPath() + "/d/"));
equalTo("file:" + this.rootFolder.getPath() + File.separator + "d/"));
}
@Test