diff --git a/resources/tests/org.eclipse.core.tests.resources/resources/ZipFileSystem/PasswordProtected.zip b/resources/tests/org.eclipse.core.tests.resources/resources/ZipFileSystem/PasswordProtected.zip new file mode 100644 index 00000000000..6030f241b4a Binary files /dev/null and b/resources/tests/org.eclipse.core.tests.resources/resources/ZipFileSystem/PasswordProtected.zip differ diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/zip/OpenTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/zip/OpenTest.java index dc0b0b04e61..043369647c9 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/zip/OpenTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/zip/OpenTest.java @@ -123,4 +123,23 @@ public void testOpenFakeZip() { fail("Expected a CoreException, but got a different type of exception."); } } + + @Test + public void testOpenPasswordProtectedZip() { + try { + ZipFileSystemTestSetup.copyZipFileIntoProject(ZipFileSystemTestSetup.firstProject, + ZipFileSystemTestSetup.PASSWORD_PROTECTED_ZIP_FILE_NAME); + IFile passwordProtectedZipFile = ZipFileSystemTestSetup.firstProject + .getFile(ZipFileSystemTestSetup.PASSWORD_PROTECTED_ZIP_FILE_NAME); + ensureExists(passwordProtectedZipFile); + + ZipFileSystemTestUtil.openZipFile(passwordProtectedZipFile); + fail("Expected an IOException due to password protection."); + } catch (CoreException e) { + String expectedMessage = "Zip File could not be opened"; + assertTrue("Expected different error message", e.getMessage().contains(expectedMessage)); + } catch (Exception e) { + fail("Expected a CoreException, but got a different type of exception."); + } + } } diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/zip/ZipFileSystemTestSetup.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/zip/ZipFileSystemTestSetup.java index baac1ca9e2d..20fdc41b1d9 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/zip/ZipFileSystemTestSetup.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/zip/ZipFileSystemTestSetup.java @@ -45,6 +45,7 @@ class ZipFileSystemTestSetup { static final String TEXT_FILE_NAME = "Text.txt"; static final String DEEP_NESTED_ZIP_FILE_NAME = "DeepNested.zip"; static final String FAKE_ZIP_FILE_NAME = "Fake.zip"; + static final String PASSWORD_PROTECTED_ZIP_FILE_NAME = "PasswordProtected.zip"; static IProject firstProject; static IProject secondProject; static IProgressMonitor progressMonitor = new NullProgressMonitor();