From d22f94c00bc23c54e1608cdfb8433c6c5a3ffc74 Mon Sep 17 00:00:00 2001 From: Michael Bangas Date: Tue, 18 Jun 2024 17:14:47 +0200 Subject: [PATCH] New test for copy bug --- .../core/tests/filesystem/zip/CloseTest.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/zip/CloseTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/zip/CloseTest.java index 663e2bbec5d..31a6bab30d7 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/zip/CloseTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/zip/CloseTest.java @@ -48,4 +48,31 @@ public void testCloseZipFile() throws Exception { ensureExists(zipFile); } + /* + * Test for a bug that breaks the opened zip file underneath the zip file that + * is closing. The zip file underneath converts to a linked file but the local + * file in the project is deleted so the linked file has no target. + */ + @Test + public void testCloseZipFileWithZipFileUnderneath() throws Exception { + IFolder firstOpenedZipFile = ZipFileSystemTestSetup.firstProject + .getFolder(ZipFileSystemTestSetup.ZIP_FILE_VIRTUAL_FOLDER_NAME); + ensureExists(firstOpenedZipFile); + String secondZipFileName = ZipFileSystemTestSetup.ZIP_FILE_VIRTUAL_FOLDER_NAME.replace(".", "New."); + ZipFileSystemTestSetup.copyZipFileIntoProject(ZipFileSystemTestSetup.firstProject, secondZipFileName); + IFile secondZipFile = ZipFileSystemTestSetup.firstProject.getFile(secondZipFileName); + ZipFileSystemTestUtil.openZipFile(secondZipFile); + IFolder secondOpenedZipFile = ZipFileSystemTestSetup.firstProject.getFolder(secondZipFileName); + ensureExists(secondOpenedZipFile); + + ZipFileSystemTestUtil.closeZipFile(firstOpenedZipFile); + IFile zipFile = ZipFileSystemTestSetup.firstProject + .getFile(ZipFileSystemTestSetup.ZIP_FILE_VIRTUAL_FOLDER_NAME); + // Don't use Utility method ensureDoesNotExist because the fileStore is still + // available after closing. The fileStore is the File itself in the local file + // system that still exists after closing. + assertTrue("folder was not properly deleted: " + firstOpenedZipFile, !firstOpenedZipFile.exists()); + ensureExists(zipFile); + ensureExists(secondOpenedZipFile); + } }