Merge branch '1.3.x'

pull/6081/merge
Andy Wilkinson 9 years ago
commit af20dc6cc4

@ -84,7 +84,7 @@ public class ExplodedArchive implements Archive {
@Override @Override
public URL getUrl() throws MalformedURLException { public URL getUrl() throws MalformedURLException {
return new URL("file", "", -1, this.root.toURI().getPath()); return this.root.toURI().toURL();
} }
@Override @Override

@ -23,7 +23,6 @@ import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.net.URL; import java.net.URL;
import java.net.URLClassLoader; import java.net.URLClassLoader;
import java.net.URLDecoder;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -37,6 +36,7 @@ import org.junit.rules.TemporaryFolder;
import org.springframework.boot.loader.TestJarCreator; import org.springframework.boot.loader.TestJarCreator;
import org.springframework.boot.loader.archive.Archive.Entry; import org.springframework.boot.loader.archive.Archive.Entry;
import org.springframework.util.StringUtils;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -45,6 +45,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* *
* @author Phillip Webb * @author Phillip Webb
* @author Dave Syer * @author Dave Syer
* @author Andy Wilkinson
*/ */
public class ExplodedArchiveTests { public class ExplodedArchiveTests {
@ -57,10 +58,20 @@ public class ExplodedArchiveTests {
@Before @Before
public void setup() throws Exception { public void setup() throws Exception {
createArchive();
}
private void createArchive() throws Exception {
createArchive(null);
}
private void createArchive(String folderName) throws Exception {
File file = this.temporaryFolder.newFile(); File file = this.temporaryFolder.newFile();
TestJarCreator.createTestJar(file); TestJarCreator.createTestJar(file);
this.rootFolder = this.temporaryFolder.newFolder(); this.rootFolder = StringUtils.hasText(folderName)
? this.temporaryFolder.newFolder(folderName)
: this.temporaryFolder.newFolder();
JarFile jarFile = new JarFile(file); JarFile jarFile = new JarFile(file);
Enumeration<JarEntry> entries = jarFile.entries(); Enumeration<JarEntry> entries = jarFile.entries();
while (entries.hasMoreElements()) { while (entries.hasMoreElements()) {
@ -102,9 +113,13 @@ public class ExplodedArchiveTests {
@Test @Test
public void getUrl() throws Exception { public void getUrl() throws Exception {
URL url = this.archive.getUrl(); assertThat(this.archive.getUrl()).isEqualTo(this.rootFolder.toURI().toURL());
assertThat(new File(URLDecoder.decode(url.getFile(), "UTF-8"))) }
.isEqualTo(this.rootFolder);
@Test
public void getUrlWithSpaceInPath() throws Exception {
createArchive("spaces in the name");
assertThat(this.archive.getUrl()).isEqualTo(this.rootFolder.toURI().toURL());
} }
@Test @Test

Loading…
Cancel
Save