Skip to content

Commit

Permalink
Add parametrization to test .jar and .war files
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael5601 committed Jul 31, 2024
1 parent 586fa0f commit a8713ee
Show file tree
Hide file tree
Showing 13 changed files with 177 additions and 126 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
import org.eclipse.core.resources.IFolder;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

public class CloseTest {

Expand All @@ -33,14 +34,15 @@ public void teardown() throws Exception {
ZipFileSystemTestSetup.teardown();
}

@Test
public void testCloseZipFile() throws Exception {
@ParameterizedTest
@MethodSource("org.eclipse.core.tests.filesystem.zip.ZipFileSystemTestUtil#zipFileNames")
public void testCloseZipFile(String zipFileName) throws Exception {
IFolder openedZipFile = ZipFileSystemTestSetup.firstProject
.getFolder(ZipFileSystemTestSetup.ZIP_FILE_VIRTUAL_FOLDER_NAME);
.getFolder(zipFileName);
ensureExists(openedZipFile);
ZipFileSystemTestUtil.closeZipFile(openedZipFile);
IFile zipFile = ZipFileSystemTestSetup.firstProject
.getFile(ZipFileSystemTestSetup.ZIP_FILE_VIRTUAL_FOLDER_NAME);
.getFile(zipFileName);
// 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.
Expand All @@ -53,12 +55,13 @@ public void testCloseZipFile() throws Exception {
* 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 {
@ParameterizedTest
@MethodSource("org.eclipse.core.tests.filesystem.zip.ZipFileSystemTestUtil#zipFileNames")
public void testCloseZipFileWithZipFileUnderneath(String zipFileName) throws Exception {
IFolder firstOpenedZipFile = ZipFileSystemTestSetup.firstProject
.getFolder(ZipFileSystemTestSetup.ZIP_FILE_VIRTUAL_FOLDER_NAME);
.getFolder(zipFileName);
ensureExists(firstOpenedZipFile);
String secondZipFileName = ZipFileSystemTestSetup.ZIP_FILE_VIRTUAL_FOLDER_NAME.replace(".", "New.");
String secondZipFileName = zipFileName.replace(".", "New.");
ZipFileSystemTestSetup.copyZipFileIntoProject(ZipFileSystemTestSetup.firstProject, secondZipFileName);
IFile secondZipFile = ZipFileSystemTestSetup.firstProject.getFile(secondZipFileName);
ZipFileSystemTestUtil.openZipFile(secondZipFile);
Expand All @@ -67,7 +70,7 @@ public void testCloseZipFileWithZipFileUnderneath() throws Exception {

ZipFileSystemTestUtil.closeZipFile(firstOpenedZipFile);
IFile zipFile = ZipFileSystemTestSetup.firstProject
.getFile(ZipFileSystemTestSetup.ZIP_FILE_VIRTUAL_FOLDER_NAME);
.getFile(zipFileName);
// 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
import org.eclipse.core.resources.IFolder;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

/**
*
Expand All @@ -40,25 +41,27 @@ public void teardown() throws Exception {
ZipFileSystemTestSetup.teardown();
}

@Test
public void testCopyZipFile() throws Exception {
@ParameterizedTest
@MethodSource("org.eclipse.core.tests.filesystem.zip.ZipFileSystemTestUtil#zipFileNames")
public void testCopyZipFile(String zipFileName) throws Exception {
IFolder openedZipFile = ZipFileSystemTestSetup.firstProject
.getFolder(ZipFileSystemTestSetup.ZIP_FILE_VIRTUAL_FOLDER_NAME);
.getFolder(zipFileName);
ensureExists(openedZipFile);
IFolder destinationFolder = ZipFileSystemTestSetup.firstProject.getFolder("Folder");
destinationFolder.create(true, true, getMonitor());
ensureExists(destinationFolder);
IFolder copyDestination = ZipFileSystemTestSetup.firstProject
.getFolder("Folder" + "/" + ZipFileSystemTestSetup.ZIP_FILE_VIRTUAL_FOLDER_NAME);
.getFolder("Folder" + "/" + zipFileName);
openedZipFile.copy(copyDestination.getFullPath(), true, getMonitor());
ensureExists(copyDestination);
ensureExists(openedZipFile);
}

@Test
public void testCopyFileInsideOfZipFile() throws Exception {
@ParameterizedTest
@MethodSource("org.eclipse.core.tests.filesystem.zip.ZipFileSystemTestUtil#zipFileNames")
public void testCopyFileInsideOfZipFile(String zipFileName) throws Exception {
IFile textFile = ZipFileSystemTestSetup.firstProject.getFile(
ZipFileSystemTestSetup.ZIP_FILE_VIRTUAL_FOLDER_NAME + "/" + ZipFileSystemTestSetup.TEXT_FILE_NAME);
zipFileName + "/" + ZipFileSystemTestSetup.TEXT_FILE_NAME);
ensureExists(textFile);
IFolder destinationFolder = ZipFileSystemTestSetup.firstProject.getFolder("Folder");
destinationFolder.create(true, true, getMonitor());
Expand All @@ -70,10 +73,11 @@ public void testCopyFileInsideOfZipFile() throws Exception {
ensureExists(textFile);
}

@Test
public void testCopyFolderInsideOfZipFile() throws Exception {
@ParameterizedTest
@MethodSource("org.eclipse.core.tests.filesystem.zip.ZipFileSystemTestUtil#zipFileNames")
public void testCopyFolderInsideOfZipFile(String zipFileName) throws Exception {
IFolder openedZipFile = ZipFileSystemTestSetup.firstProject
.getFolder(ZipFileSystemTestSetup.ZIP_FILE_VIRTUAL_FOLDER_NAME);
.getFolder(zipFileName);
ensureExists(openedZipFile);
IFolder newFolder = ZipFileSystemTestSetup.firstProject.getFolder("NewFolder");
ensureDoesNotExist(newFolder);
Expand All @@ -94,8 +98,9 @@ public void testCopyFolderInsideOfZipFile() throws Exception {
assertTextFileContent(textFile, "Foo");
}

@Test
public void testCopyFileIntoZipFile() throws Exception {
@ParameterizedTest
@MethodSource("org.eclipse.core.tests.filesystem.zip.ZipFileSystemTestUtil#zipFileNames")
public void testCopyFileIntoZipFile(String zipFileName) throws Exception {
IFile textFile = ZipFileSystemTestSetup.firstProject.getFile("NewFile.txt");
ensureDoesNotExist(textFile);
String text = "Foo";
Expand All @@ -104,15 +109,16 @@ public void testCopyFileIntoZipFile() throws Exception {
stream.close();
ensureExists(textFile);
IFile copyDestination = ZipFileSystemTestSetup.firstProject
.getFile(ZipFileSystemTestSetup.ZIP_FILE_VIRTUAL_FOLDER_NAME + "/" + "NewFile.txt");
.getFile(zipFileName + "/" + "NewFile.txt");
textFile.copy(copyDestination.getFullPath(), true, getMonitor());
ensureExists(copyDestination);
ensureExists(textFile);
assertTextFileContent(textFile, "Foo");
}

@Test
public void testCopyFolderIntoZipFile() throws Exception {
@ParameterizedTest
@MethodSource("org.eclipse.core.tests.filesystem.zip.ZipFileSystemTestUtil#zipFileNames")
public void testCopyFolderIntoZipFile(String zipFileName) throws Exception {
IFile textFile = ZipFileSystemTestSetup.firstProject.getFile("NewFile.txt");
ensureDoesNotExist(textFile);
String text = "Foo";
Expand All @@ -121,17 +127,18 @@ public void testCopyFolderIntoZipFile() throws Exception {
stream.close();
ensureExists(textFile);
IFile copyDestination = ZipFileSystemTestSetup.firstProject
.getFile(ZipFileSystemTestSetup.ZIP_FILE_VIRTUAL_FOLDER_NAME + "/" + "NewFile.txt");
.getFile(zipFileName + "/" + "NewFile.txt");
textFile.copy(copyDestination.getFullPath(), true, getMonitor());
ensureExists(copyDestination);
ensureExists(textFile);
assertTextFileContent(textFile, "Foo");
}

@Test
public void testCopyFileFromOutsideOfZipFIleIntoFolderInZipFile() throws Exception {
@ParameterizedTest
@MethodSource("org.eclipse.core.tests.filesystem.zip.ZipFileSystemTestUtil#zipFileNames")
public void testCopyFileFromOutsideOfZipFIleIntoFolderInZipFile(String zipFileName) throws Exception {
IFolder openedZipFile = ZipFileSystemTestSetup.firstProject
.getFolder(ZipFileSystemTestSetup.ZIP_FILE_VIRTUAL_FOLDER_NAME);
.getFolder(zipFileName);
IFolder newFolder = openedZipFile.getFolder("NewFolder");
ensureDoesNotExist(newFolder);
newFolder.create(false, true, getMonitor());
Expand All @@ -151,10 +158,11 @@ public void testCopyFileFromOutsideOfZipFIleIntoFolderInZipFile() throws Excepti
assertTextFileContent(textFile, "Foo");
}

@Test
public void testCopyFolderIntoFolderInZipFile() throws Exception {
@ParameterizedTest
@MethodSource("org.eclipse.core.tests.filesystem.zip.ZipFileSystemTestUtil#zipFileNames")
public void testCopyFolderIntoFolderInZipFile(String zipFileName) throws Exception {
IFolder openedZipFile = ZipFileSystemTestSetup.firstProject
.getFolder(ZipFileSystemTestSetup.ZIP_FILE_VIRTUAL_FOLDER_NAME);
.getFolder(zipFileName);
IFolder firstNewFolder = openedZipFile.getFolder("FirstNewFolder");
ensureDoesNotExist(firstNewFolder);
firstNewFolder.create(false, true, getMonitor());
Expand All @@ -178,10 +186,11 @@ public void testCopyFolderIntoFolderInZipFile() throws Exception {
assertTextFileContent(textFile, "Foo");
}

@Test
public void testCopyFileFromOneFolderToOtherFolderInsideofZipFile() throws Exception {
@ParameterizedTest
@MethodSource("org.eclipse.core.tests.filesystem.zip.ZipFileSystemTestUtil#zipFileNames")
public void testCopyFileFromOneFolderToOtherFolderInsideofZipFile(String zipFileName) throws Exception {
IFolder openedZipFile = ZipFileSystemTestSetup.firstProject
.getFolder(ZipFileSystemTestSetup.ZIP_FILE_VIRTUAL_FOLDER_NAME);
.getFolder(zipFileName);
IFolder firstNewFolder = openedZipFile.getFolder("FirstNewFolder");
ensureDoesNotExist(firstNewFolder);
firstNewFolder.create(false, true, getMonitor());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
import org.eclipse.core.resources.IFolder;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

public class CreateTest {

Expand All @@ -37,10 +38,11 @@ public void teardown() throws Exception {
ZipFileSystemTestSetup.teardown();
}

@Test
public void testCreateFileInsideOfZipFile() throws Exception {
@ParameterizedTest
@MethodSource("org.eclipse.core.tests.filesystem.zip.ZipFileSystemTestUtil#zipFileNames")
public void testCreateFileInsideOfZipFile(String zipFileName) throws Exception {
IFolder openedZipFile = ZipFileSystemTestSetup.firstProject
.getFolder(ZipFileSystemTestSetup.ZIP_FILE_VIRTUAL_FOLDER_NAME);
.getFolder(zipFileName);
IFile textFile = openedZipFile.getFile("NewFile.txt");
ensureDoesNotExist(textFile);
String text = "Foo";
Expand All @@ -51,10 +53,11 @@ public void testCreateFileInsideOfZipFile() throws Exception {
assertTextFileContent(textFile, "Foo");
}

@Test
public void testCreateFolderInsideOfZipFile() throws Exception {
@ParameterizedTest
@MethodSource("org.eclipse.core.tests.filesystem.zip.ZipFileSystemTestUtil#zipFileNames")
public void testCreateFolderInsideOfZipFile(String zipFileName) throws Exception {
IFolder openedZipFile = ZipFileSystemTestSetup.firstProject
.getFolder(ZipFileSystemTestSetup.ZIP_FILE_VIRTUAL_FOLDER_NAME);
.getFolder(zipFileName);
IFolder newFolder = openedZipFile.getFolder("NewFolder");
ensureDoesNotExist(newFolder);
newFolder.create(false, true, getMonitor());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
import org.eclipse.core.runtime.CoreException;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

public class DeleteTest {

Expand All @@ -37,32 +38,35 @@ public void teardown() throws Exception {
ZipFileSystemTestSetup.teardown();
}

@Test
public void testDeleteZipFile() throws CoreException, IOException {
@ParameterizedTest
@MethodSource("org.eclipse.core.tests.filesystem.zip.ZipFileSystemTestUtil#zipFileNames")
public void testDeleteZipFile(String zipFileName) throws CoreException, IOException {
IFolder openedZipFile = ZipFileSystemTestSetup.firstProject
.getFolder(ZipFileSystemTestSetup.ZIP_FILE_VIRTUAL_FOLDER_NAME);
.getFolder(zipFileName);
ensureExists(openedZipFile);
openedZipFile.delete(false, false, getMonitor());
ensureDoesNotExist(openedZipFile);
IFile zipFile = ZipFileSystemTestSetup.firstProject
.getFile(ZipFileSystemTestSetup.ZIP_FILE_VIRTUAL_FOLDER_NAME);
.getFile(zipFileName);
ensureDoesNotExist(zipFile);
}

@Test
public void testDeleteFileInsideOfZipFile() throws CoreException, IOException {
@ParameterizedTest
@MethodSource("org.eclipse.core.tests.filesystem.zip.ZipFileSystemTestUtil#zipFileNames")
public void testDeleteFileInsideOfZipFile(String zipFileName) throws CoreException, IOException {
IFolder openedZipFile = ZipFileSystemTestSetup.firstProject
.getFolder(ZipFileSystemTestSetup.ZIP_FILE_VIRTUAL_FOLDER_NAME);
.getFolder(zipFileName);
IFile textFile = openedZipFile.getFile(ZipFileSystemTestSetup.TEXT_FILE_NAME);
ensureExists(textFile);
textFile.delete(true, getMonitor());
ensureDoesNotExist(textFile);
}

@Test
public void testDeleteEmptyFolder() throws CoreException, IOException {
@ParameterizedTest
@MethodSource("org.eclipse.core.tests.filesystem.zip.ZipFileSystemTestUtil#zipFileNames")
public void testDeleteEmptyFolder(String zipFileName) throws CoreException, IOException {
IFolder openedZipFile = ZipFileSystemTestSetup.firstProject
.getFolder(ZipFileSystemTestSetup.ZIP_FILE_VIRTUAL_FOLDER_NAME);
.getFolder(zipFileName);
IFolder folder = openedZipFile.getFolder("FolderToDelete");
ensureDoesNotExist(folder);
folder.create(true, true, getMonitor());
Expand All @@ -71,10 +75,11 @@ public void testDeleteEmptyFolder() throws CoreException, IOException {
ensureDoesNotExist(folder);
}

@Test
public void testDeleteFolderWithChildren() throws CoreException, IOException {
@ParameterizedTest
@MethodSource("org.eclipse.core.tests.filesystem.zip.ZipFileSystemTestUtil#zipFileNames")
public void testDeleteFolderWithChildren(String zipFileName) throws CoreException, IOException {
IFolder openedZipFile = ZipFileSystemTestSetup.firstProject
.getFolder(ZipFileSystemTestSetup.ZIP_FILE_VIRTUAL_FOLDER_NAME);
.getFolder(zipFileName);
IFolder folder = openedZipFile.getFolder("FolderToDelete");
ensureDoesNotExist(folder);
folder.create(true, true, getMonitor());
Expand Down
Loading

0 comments on commit a8713ee

Please sign in to comment.