diff options
author | Anna Koskinen <Ansku@users.noreply.github.com> | 2021-07-22 13:01:10 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-22 13:01:10 +0300 |
commit | df8bd7e0f6d2ee4dd102e02b480d82385961a130 (patch) | |
tree | 0ed636c45e95c3334f7fd984b4e34ec26eb1d78d /server/src/test | |
parent | 40e35575c8268868b38f725e3da43017e8992e87 (diff) | |
download | vaadin-framework-df8bd7e0f6d2ee4dd102e02b480d82385961a130.tar.gz vaadin-framework-df8bd7e0f6d2ee4dd102e02b480d82385961a130.zip |
fix: Reuse existing filesystem (#12346)
Modified cherry-pick of https://github.com/vaadin/flow/pull/11428
Diffstat (limited to 'server/src/test')
-rw-r--r-- | server/src/test/java/com/vaadin/server/VaadinServletTest.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/server/src/test/java/com/vaadin/server/VaadinServletTest.java b/server/src/test/java/com/vaadin/server/VaadinServletTest.java index 2c318e0897..4eb97d4453 100644 --- a/server/src/test/java/com/vaadin/server/VaadinServletTest.java +++ b/server/src/test/java/com/vaadin/server/VaadinServletTest.java @@ -10,11 +10,13 @@ import java.io.File; import java.io.IOException; import java.net.URISyntaxException; import java.net.URL; +import java.nio.file.FileSystem; import java.nio.file.FileSystemNotFoundException; import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; @@ -322,6 +324,42 @@ public class VaadinServletTest { } @Test + public void openFileServerExistsForZip_openingNewDoesNotFail() + throws IOException, URISyntaxException { + assertTrue("Can not run concurrently with other test", + VaadinServlet.OPEN_FILE_SYSTEMS.isEmpty()); + + VaadinServlet servlet = new VaadinServlet(); + + final TemporaryFolder folder = TemporaryFolder.builder().build(); + folder.create(); + + try { + Path tempArchive = createJAR(folder).toPath(); + + final FileSystem fileSystem = FileSystems + .newFileSystem( + new URL("jar:file:///" + tempArchive.toString() + .replaceAll("\\\\", "/") + "!/").toURI(), + Collections.emptyMap()); + + final URL folderResourceURL = new URL("jar:file:///" + + tempArchive.toString().replaceAll("\\\\", "/") + + "!/VAADIN"); + + try { + servlet.getFileSystem(folderResourceURL.toURI()); + } finally { + servlet.closeFileSystem(folderResourceURL.toURI()); + fileSystem.close(); + } + } finally { + folder.delete(); + } + + } + + @Test public void openingJarFileSystemForDifferentFilesInSameJar_existingFileSystemIsUsed() throws IOException, URISyntaxException, ServletException { assertTrue("Can not run concurrently with other test", |