|
|
|
|
@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
|
|
|
|
|
/* |
|
|
|
|
* Copyright 2012-2018 the original author or authors. |
|
|
|
|
* Copyright 2012-2019 the original author or authors. |
|
|
|
|
* |
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
|
@ -16,10 +16,16 @@
@@ -16,10 +16,16 @@
|
|
|
|
|
|
|
|
|
|
package org.springframework.boot.loader.jar; |
|
|
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
|
import java.net.MalformedURLException; |
|
|
|
|
import java.net.URL; |
|
|
|
|
import java.net.URLConnection; |
|
|
|
|
|
|
|
|
|
import org.junit.Rule; |
|
|
|
|
import org.junit.Test; |
|
|
|
|
import org.junit.rules.TemporaryFolder; |
|
|
|
|
|
|
|
|
|
import org.springframework.boot.loader.TestJarCreator; |
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat; |
|
|
|
|
|
|
|
|
|
@ -30,6 +36,9 @@ import static org.assertj.core.api.Assertions.assertThat;
@@ -30,6 +36,9 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
|
*/ |
|
|
|
|
public class HandlerTests { |
|
|
|
|
|
|
|
|
|
@Rule |
|
|
|
|
public TemporaryFolder temporaryFolder = new TemporaryFolder(); |
|
|
|
|
|
|
|
|
|
private final Handler handler = new Handler(); |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
@ -170,6 +179,20 @@ public class HandlerTests {
@@ -170,6 +179,20 @@ public class HandlerTests {
|
|
|
|
|
"!/foo.txt?alpha"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void fallbackToJdksJarUrlStreamHandler() throws Exception { |
|
|
|
|
File testJar = this.temporaryFolder.newFile("test.jar"); |
|
|
|
|
TestJarCreator.createTestJar(testJar); |
|
|
|
|
URLConnection connection = new URL(null, |
|
|
|
|
"jar:file:" + testJar.getAbsolutePath() + "!/nested.jar!/", this.handler) |
|
|
|
|
.openConnection(); |
|
|
|
|
assertThat(connection).isInstanceOf(JarURLConnection.class); |
|
|
|
|
URLConnection jdkConnection = new URL(null, |
|
|
|
|
"jar:file:file:" + testJar.getAbsolutePath() + "!/nested.jar!/", |
|
|
|
|
this.handler).openConnection(); |
|
|
|
|
assertThat(jdkConnection).isNotInstanceOf(JarURLConnection.class); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void assertStandardAndCustomHandlerUrlsAreEqual(String context, String spec) |
|
|
|
|
throws MalformedURLException { |
|
|
|
|
URL standardUrl = new URL(new URL("jar:" + context), spec); |
|
|
|
|
|