Browse Source

Merge branch '2.3.x'

Closes gh-24017
pull/24020/head
Andy Wilkinson 5 years ago
parent
commit
bbad377ecc
  1. 6
      spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFileWrapper.java
  2. 17
      spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarFileWrapperTests.java
  3. 11
      spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarURLConnectionTests.java

6
spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFileWrapper.java

@ -24,6 +24,7 @@ import java.security.Permission; @@ -24,6 +24,7 @@ import java.security.Permission;
import java.util.Enumeration;
import java.util.jar.JarEntry;
import java.util.jar.Manifest;
import java.util.stream.Stream;
import java.util.zip.ZipEntry;
/**
@ -67,6 +68,11 @@ class JarFileWrapper extends AbstractJarFile { @@ -67,6 +68,11 @@ class JarFileWrapper extends AbstractJarFile {
return this.parent.entries();
}
@Override
public Stream<JarEntry> stream() {
return this.parent.stream();
}
@Override
public JarEntry getJarEntry(String name) {
return this.parent.getJarEntry(name);

17
spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarFileWrapperTests.java

@ -28,6 +28,7 @@ import java.util.Enumeration; @@ -28,6 +28,7 @@ import java.util.Enumeration;
import java.util.Set;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
import java.util.stream.Stream;
import java.util.zip.ZipEntry;
import org.junit.jupiter.api.AfterEach;
@ -150,6 +151,12 @@ class JarFileWrapperTests { @@ -150,6 +151,12 @@ class JarFileWrapperTests {
.isThrownBy(() -> JarFileWrapper.class.getDeclaredMethod("close"));
}
@Test
void streamDelegatestoParent() {
this.wrapper.stream();
this.parent.verify(Call.STREAM);
}
/**
* {@link JarFile} that we can spy (even on Java 11+)
*/
@ -179,6 +186,12 @@ class JarFileWrapperTests { @@ -179,6 +186,12 @@ class JarFileWrapperTests {
return super.entries();
}
@Override
public Stream<java.util.jar.JarEntry> stream() {
mark(Call.STREAM);
return super.stream();
}
@Override
public JarEntry getJarEntry(String name) {
mark(Call.GET_JAR_ENTRY);
@ -257,7 +270,9 @@ class JarFileWrapperTests { @@ -257,7 +270,9 @@ class JarFileWrapperTests {
GET_COMMENT,
SIZE
SIZE,
STREAM
}

11
spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarURLConnectionTests.java

@ -20,6 +20,9 @@ import java.io.File; @@ -20,6 +20,9 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.net.URL;
import java.util.List;
import java.util.jar.JarEntry;
import java.util.stream.Collectors;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
@ -200,6 +203,14 @@ class JarURLConnectionTests { @@ -200,6 +203,14 @@ class JarURLConnectionTests {
assertThat(connection.getLastModified()).isEqualTo(connection.getJarEntry().getTime());
}
@Test
void entriesCanBeStreamedFromJarFileOfConnection() throws Exception {
URL url = new URL("jar:" + this.rootJarFile.toURI().toURL() + "!/");
JarURLConnection connection = JarURLConnection.get(url, this.jarFile);
List<String> entryNames = connection.getJarFile().stream().map(JarEntry::getName).collect(Collectors.toList());
assertThat(entryNames).hasSize(12);
}
@Test
void jarEntryBasicName() {
assertThat(new JarEntryName(new StringSequence("a/b/C.class")).toString()).isEqualTo("a/b/C.class");

Loading…
Cancel
Save