|
18 | 18 | import static org.mockito.Mockito.mock; |
19 | 19 | import static org.mockito.Mockito.only; |
20 | 20 | import static org.mockito.Mockito.verify; |
| 21 | +import static org.mockito.Mockito.verifyNoMoreInteractions; |
21 | 22 | import static org.mockito.Mockito.when; |
22 | 23 |
|
23 | 24 | import java.net.URI; |
| 25 | +import java.nio.file.FileSystem; |
24 | 26 | import java.nio.file.FileSystemNotFoundException; |
25 | 27 | import java.nio.file.FileSystems; |
26 | 28 | import java.util.ArrayList; |
@@ -51,6 +53,37 @@ void closeAllPaths() { |
51 | 53 | closeAll(paths); |
52 | 54 | } |
53 | 55 |
|
| 56 | + @Test |
| 57 | + void parsesJarUri() throws Exception { |
| 58 | + FileSystemProvider fileSystemProvider = mock(); |
| 59 | + |
| 60 | + FileSystem fileSystem = mock(); |
| 61 | + when(fileSystemProvider.newFileSystem(any())).thenReturn(fileSystem); |
| 62 | + |
| 63 | + URI jarFileWithEntry = URI.create("jar:file:/example.jar!/com/example/Example.class"); |
| 64 | + CloseablePath.create(jarFileWithEntry, fileSystemProvider).close(); |
| 65 | + |
| 66 | + URI jarFileUri = URI.create("jar:file:/example.jar"); |
| 67 | + verify(fileSystemProvider).newFileSystem(jarFileUri); |
| 68 | + verifyNoMoreInteractions(fileSystemProvider); |
| 69 | + } |
| 70 | + |
| 71 | + @Test |
| 72 | + void parsesRecursiveJarUri() throws Exception { |
| 73 | + FileSystemProvider fileSystemProvider = mock(); |
| 74 | + |
| 75 | + FileSystem fileSystem = mock(); |
| 76 | + when(fileSystemProvider.newFileSystem(any())).thenReturn(fileSystem); |
| 77 | + |
| 78 | + URI jarNestedFileWithEntry = URI.create( |
| 79 | + "jar:nested:file:/example.jar!/BOOT-INF/classes!/com/example/Example.class"); |
| 80 | + CloseablePath.create(jarNestedFileWithEntry, fileSystemProvider).close(); |
| 81 | + |
| 82 | + URI jarNestedFile = URI.create("jar:nested:file:/example.jar!/BOOT-INF/classes"); |
| 83 | + verify(fileSystemProvider).newFileSystem(jarNestedFile); |
| 84 | + verifyNoMoreInteractions(fileSystemProvider); |
| 85 | + } |
| 86 | + |
54 | 87 | @Test |
55 | 88 | void createsAndClosesJarFileSystemOnceWhenCalledConcurrently() throws Exception { |
56 | 89 | var numThreads = 50; |
|
0 commit comments