diff --git a/rse/tests/org.eclipse.rse.tests/META-INF/MANIFEST.MF b/rse/tests/org.eclipse.rse.tests/META-INF/MANIFEST.MF
index 941233a7a0f..a6cae468d44 100644
--- a/rse/tests/org.eclipse.rse.tests/META-INF/MANIFEST.MF
+++ b/rse/tests/org.eclipse.rse.tests/META-INF/MANIFEST.MF
@@ -18,7 +18,9 @@ Require-Bundle: org.junit,
org.eclipse.ui.views,
org.eclipse.rse.services;bundle-version="[2.0.0,3.0.0)",
org.eclipse.rse.services.files.ftp;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.rse.subsystems.files.ftp;bundle-version="[2.0.0,3.0.0)"
+ org.eclipse.rse.subsystems.files.ftp;bundle-version="[2.0.0,3.0.0)",
+ org.eclipse.core.filesystem,
+ org.eclipse.rse.files.ui
Eclipse-LazyStart: true
Bundle-RequiredExecutionEnvironment: J2SE-1.4
Export-Package: org.eclipse.rse.tests,
diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/connection/RSEBaseConnectionTestCase.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/connection/RSEBaseConnectionTestCase.java
index db3bb8adbb8..32156a6ffa3 100644
--- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/connection/RSEBaseConnectionTestCase.java
+++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/connection/RSEBaseConnectionTestCase.java
@@ -9,6 +9,7 @@
* David Dykstal (IBM) - initial contribution.
* Uwe Stieber (Wind River) - refactoring and cleanup.
* Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType
+ * Xuan Chen (IBM) - [198859] Update the API doc for getRemoteSystemConnection.
********************************************************************************/
package org.eclipse.rse.tests.core.connection;
@@ -86,10 +87,14 @@ public class RSEBaseConnectionTestCase extends RSECoreTestCase {
}
/**
- * Lookup and return the local system type connection. This connection
- * should be usually available on all systems.
+ * Lookup/create and return the remote system connection according to the list of system parameters.
+ * @param systemTypeID The type id string of the remote system.
+ * @param systemAddress The address of the remote system.
+ * @param systemName The connection name.
+ * @param userID The user id used to logon to the remote system.
+ * @param password The password of the user id to logon to the remote system.
*
- * @return The local system type connection or null
if the lookup fails.
+ * @return The remote system connection or null
if the lookup/creation fails.
*/
protected IHost getRemoteSystemConnection(String systemTypeID, String systemAddress, String systemName, String userID, String password) {
diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileServiceArchiveTest.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileServiceArchiveTest.java
index 8e86589db9e..2218f7782ad 100644
--- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileServiceArchiveTest.java
+++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileServiceArchiveTest.java
@@ -10,42 +10,358 @@
*******************************************************************************/
package org.eclipse.rse.tests.subsystems.files;
-import java.io.File;
-
-import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.rse.core.IRSESystemType;
import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.core.model.ISystemRegistry;
+import org.eclipse.rse.core.model.ISystemResourceSet;
+import org.eclipse.rse.core.model.SystemRemoteResourceSet;
import org.eclipse.rse.core.model.SystemStartHere;
+import org.eclipse.rse.core.model.SystemWorkspaceResourceSet;
import org.eclipse.rse.core.subsystems.ISubSystem;
+import org.eclipse.rse.core.subsystems.ISystemDragDropAdapter;
+import org.eclipse.rse.files.ui.resources.UniversalFileTransferUtility;
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
import org.eclipse.rse.services.files.IFileService;
import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
import org.eclipse.rse.tests.RSETestsPlugin;
-import org.eclipse.rse.ui.ISystemPreferencesConstants;
-import org.eclipse.rse.ui.RSEUIPlugin;
public class FileServiceArchiveTest extends FileServiceBaseTest {
+ protected String folderToCopyName1 = "RemoteSystemsConnections";
+ protected String folderToCopyName2 = "6YLT5Xa";
+ protected String folderToCopyName3 = "folderToCopy";
+
+ protected String zipSourceFileName1 = "closedBefore.zip";
+ protected String zipSourceFileName2 = "mynewzip.zip";
protected String ZIP_SOURCE_DIR = "";
- protected String TMP_DIR_PARENT = "";
+ protected String TEST_DIR = "";
protected String SYSTEM_TYPE_ID = IRSESystemType.SYSTEMTYPE_LOCAL_ID;
protected String SYSTEM_ADDRESS = "";
protected String SYSTEM_NAME = "";
protected String USER_ID = "";
protected String PASSWORD = "";
+ public static IWorkspace getWorkspace() {
+ return ResourcesPlugin.getWorkspace();
+ }
+
+
+ public void createSourceFolders()
+ {
+ try
+ {
+ String tempPath = getWorkspace().getRoot().getLocation().append("temp").toString();
+ IFileStore temp = createDir(tempPath, true);
+ String content = getRandomString();
+
+
+ // create the source folder used for copy or move
+ IFileStore folderToCopy = temp.getChild(folderToCopyName3);
+ createDir(folderToCopy, true);
+ //Now, populate the contents in the folderToCopy.
+ IFileStore aaaaaaaa = folderToCopy.getChild("aaaaaaaa");
+ createDir(aaaaaaaa, true);
+ //create file inside the aaaaaaaa folder.
+ IFileStore adsf = aaaaaaaa.getChild("adsf");
+ content = getRandomString();
+ createFile(adsf, content);
+ IFileStore eclipse_SDK_3_3M6_win32_zip = aaaaaaaa.getChild("eclipse-SDK-3.3M6-win32.zip");
+ createFile(eclipse_SDK_3_3M6_win32_zip, "");
+ IFileStore epdcdump01_hex12 = aaaaaaaa.getChild("epdcdump01.hex12");
+ content = getRandomString();
+ createFile(epdcdump01_hex12, content);
+ IFileStore epdcdump01_hex12aaaa = aaaaaaaa.getChild("epdcdump01.hex12aaaa");
+ content = getRandomString();
+ createFile(epdcdump01_hex12aaaa, content);
+
+ IFileStore aaaab = folderToCopy.getChild("aaaab");
+ createDir(aaaab, true);
+ IFileStore features = aaaab.getChild("features");
+ createDir(features, true);
+ IFileStore dummyFile = features.getChild("dummy.txt");
+ content = getRandomString();
+ createFile(dummyFile, content);
+ //create file inside the aaaab folder.
+ content = "this is just a simple content \n to a simple file \n to test a 'simple' copy";
+ IFileStore epdcdump01_hex12a = aaaab.getChild("epdcdump01.hex12a");
+ content = getRandomString();
+ createFile(epdcdump01_hex12a, content);
+
+ IFileStore epdcdump01_hex12a1 = folderToCopy.getChild("epdcdump01.hex12a");
+ content = getRandomString();
+ createFile(epdcdump01_hex12a1, content);
+
+ IFileStore RSE_SDK_2_0RC1_zip = folderToCopy.getChild("RSE-SDK-2.0RC1.zip");
+ content = getRandomString();
+ createFile(RSE_SDK_2_0RC1_zip, content);
+
+ //now, copy folderToCopy into the folder in the remote system
+ IRemoteFile sourceFolderToCopy3 = localFss.getRemoteFileObject(tempPath + '\\' + folderToCopyName3, mon);
+ ISystemDragDropAdapter srcAdapter3 = (ISystemDragDropAdapter) ((IAdaptable) sourceFolderToCopy3).getAdapter(ISystemDragDropAdapter.class);
+ SystemRemoteResourceSet fromSet3 = new SystemRemoteResourceSet(localFss, srcAdapter3);
+ fromSet3.addResource(sourceFolderToCopy3);
+ ISystemResourceSet tempObjects3 = srcAdapter3.doDrag(fromSet3, mon);
+ UniversalFileTransferUtility.copyWorkspaceResourcesToRemote((SystemWorkspaceResourceSet)tempObjects3, tempDir, mon, true);
+
+ //Then, we need to retrieve children of the tempDir to cache their information.
+ fss.resolveFilterString(tempDir, null, mon);
+
+ //Then, delete the temp folder in the junit workspace.
+ temp.delete(EFS.NONE, mon);
+
+ return;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+
+ }
+
+ public void createSourceZipFiles()
+ {
+ try
+ {
+ /* build scenario */
+ String tempPath = getWorkspace().getRoot().getLocation().append("temp").toString();
+ IFileStore temp = createDir(tempPath, true);
+ String content = getRandomString();
+
+ //Now, we need to construct a "closeBefore.zip" archive file
+ //We will construct the content of the zip file in folder "RemoteSystemsConnections"
+ //Then we copy this folder into a zip file by RSE API.
+ IFileStore RemoteSystemsConnections = temp.getChild(folderToCopyName1);
+ createDir(RemoteSystemsConnections, true);
+ //Now, populate the contents in the folderToCopy.
+ IFileStore Team = RemoteSystemsConnections.getChild("Team");
+ createDir(Team, true);
+ //create folder inside the Team folder.
+ IFileStore Connections = Team.getChild("Connections");
+ createDir(Connections, true);
+ IFileStore dummyFile = Connections.getChild("dummy.txt");
+ content = getRandomString();
+ createFile(dummyFile, content);
+ IFileStore Filters = Team.getChild("Filters");
+ createDir(Filters, true);
+ //Now, create a few folders inside the Filters folder.
+ IFileStore ibm_cmds = Filters.getChild("ibm.cmds");
+ createDir(ibm_cmds, true);
+ IFileStore ibm_cmds400 = Filters.getChild("ibm.cmds400");
+ createDir(ibm_cmds400, true);
+ //create another directory inside this one
+ IFileStore filter_pool1 = ibm_cmds400.getChild("FilterPool_Team Filter Pool");
+ createDir(filter_pool1, true);
+ //create a file inside this folder
+ IFileStore filter_pool1_xml = filter_pool1.getChild("filterPool_Team Filter Pool.xmi");
+ content = getRandomString();
+ createFile(filter_pool1_xml, content);
+
+ IFileStore ibm_cmdsIFS = Filters.getChild("ibm.cmdsIFS");
+ createDir(ibm_cmdsIFS, true);
+ IFileStore ibm_cmdsLocal = Filters.getChild("ibm.cmdsLocal");
+ createDir(ibm_cmdsLocal, true);
+
+ IFileStore ibm_files = Filters.getChild("ibm.files");
+ createDir(ibm_files, true);
+ //create another directory inside this one
+ IFileStore filter_pool2 = ibm_files.getChild("FilterPool_Team Filter Pool");
+ createDir(filter_pool2, true);
+ //create a file inside this folder
+ IFileStore filter_pool2_xml = filter_pool2.getChild("filterPool_Team Filter Pool.xmi");
+ content = getRandomString();
+ createFile(filter_pool2_xml, content);
+
+ IFileStore ibm_files_aix = Filters.getChild("ibm.files.aix");
+ createDir(ibm_files_aix, true);
+ //create another directory inside this one
+ IFileStore filter_pool3 = ibm_files_aix.getChild("FilterPool_Team Filter Pool");
+ createDir(filter_pool3, true);
+ //create a file inside this folder
+ IFileStore filter_pool3_xml = filter_pool3.getChild("filterPool_Team Filter Pool.xmi");
+ content = getRandomString();
+ createFile(filter_pool3_xml, content);
+
+ IFileStore ibm_iles_powerlinux = Filters.getChild("ibm.files.powerlinux");
+ createDir(ibm_iles_powerlinux, true);
+ //create another directory inside this one
+ IFileStore filter_pool4 = ibm_iles_powerlinux.getChild("FilterPool_Team Filter Pool");
+ createDir(filter_pool4, true);
+ //create a file inside this folder
+ IFileStore filter_pool4_xml = filter_pool4.getChild("filterPool_Team Filter Pool.xmi");
+ content = getRandomString();
+ createFile(filter_pool4_xml, content);
+
+ IFileStore ibm_files400 = Filters.getChild("ibm.files400");
+ createDir(ibm_files400, true);
+ //create another directory inside this one
+ IFileStore filter_pool5 = ibm_files400.getChild("FilterPool_Team Filter Pool");
+ createDir(filter_pool5, true);
+ //create a file inside this folder
+ IFileStore filter_pool5_xml = filter_pool5.getChild("filterPool_Team Filter Pool.xmi");
+ content = getRandomString();
+ createFile(filter_pool5_xml, content);
+
+ IFileStore ibm_filesLocal = Filters.getChild("ibm.filesLocal");
+ createDir(ibm_filesLocal, true);
+ //create another directory inside this one
+ IFileStore filter_pool6 = ibm_filesLocal.getChild("FilterPool_Team Filter Pool");
+ createDir(filter_pool6, true);
+ //create a file inside this folder
+ IFileStore filter_pool6_xml = filter_pool6.getChild("filterPool_Team Filter Pool.xmi");
+ content = getRandomString();
+ createFile(filter_pool6_xml, content);
+
+ IFileStore ibm_filesIFS = Filters.getChild("ibm.filesIFS");
+ createDir(ibm_filesIFS, true);
+ //create another directory inside this one
+ IFileStore filter_pool7 = ibm_filesIFS.getChild("FilterPool_Team Filter Pool");
+ createDir(filter_pool7, true);
+ //create a file inside this folder
+ IFileStore filter_pool7_xml = filter_pool7.getChild("filterPool_Team Filter Pool.xmi");
+ content = getRandomString();
+ createFile(filter_pool7_xml, content);
+
+ IFileStore ibm_filesWindows = Filters.getChild("ibm.filesWindows");
+ createDir(ibm_filesWindows, true);
+ //create another directory inside this one
+ IFileStore filter_pool8 = ibm_filesWindows.getChild("FilterPool_Team Filter Pool");
+ createDir(filter_pool8, true);
+ //create a file inside this folder
+ IFileStore filter_pool8_xml = filter_pool8.getChild("filterPool_Team Filter Pool.xmi");
+ content = getRandomString();
+ createFile(filter_pool8_xml, content);
+
+ IFileStore ibm_jobs400 = Filters.getChild("ibm.jobs400");
+ createDir(ibm_jobs400, true);
+ //create another directory inside this one
+ IFileStore filter_pool9 = ibm_jobs400.getChild("FilterPool_Team Filter Pool");
+ createDir(filter_pool9, true);
+ //create a file inside this folder
+ IFileStore filter_pool9_xml = filter_pool9.getChild("filterPool_Team Filter Pool.xmi");
+ content = getRandomString();
+ createFile(filter_pool9_xml, content);
+
+ //create file inside the Team folder.
+ IFileStore profile_xml = Team.getChild("profile.xmi");
+ content = getRandomString();
+ createFile(profile_xml, content);
+
+ //Now create another folder TypeFilters in the RemoteSystemsConnections folder
+ IFileStore TypeFilters = RemoteSystemsConnections.getChild("TypeFilters");
+ createDir(TypeFilters, true);
+ dummyFile = TypeFilters.getChild("dummy.txt");
+ content = getRandomString();
+ createFile(dummyFile, content);
+ //Now create another folder xuanchentp in the RemoteSystemsConnections folder
+ IFileStore xuanchentp = RemoteSystemsConnections.getChild("xuanchentp");
+ createDir(xuanchentp, true);
+ //Create some files and folder inside the xuanchentp folder
+ IFileStore Connections1 = xuanchentp.getChild("Connections");
+ createDir(Connections1, true);
+ dummyFile = Connections1.getChild("dummy.txt");
+ content = getRandomString();
+ createFile(dummyFile, content);
+ IFileStore Filters1 = xuanchentp.getChild("Filters");
+ createDir(Filters1, true);
+ dummyFile = Filters1.getChild("dummy.txt");
+ content = getRandomString();
+ createFile(dummyFile, content);
+ IFileStore profile_xml1 = xuanchentp.getChild("profile.xmi");
+ content = getRandomString();
+ createFile(profile_xml1, content);
+ //now create two other files inside folder RemoteSystemConnections
+ IFileStore compatibility = RemoteSystemsConnections.getChild(".compatibility");
+ content = getRandomString();
+ createFile(compatibility, content);
+ IFileStore project = RemoteSystemsConnections.getChild(".project");
+ createFile(project, content);
+
+ //Now, we need to create the content of mynewzip.zip file
+ IFileStore folder_6YLT5Xa = temp.getChild(folderToCopyName2);
+ createDir(folder_6YLT5Xa, true);
+ IFileStore folder_20070315a = folder_6YLT5Xa.getChild("20070315a");
+ createDir(folder_20070315a, true);
+ IFileStore QB5ROUTaadd = folder_20070315a.getChild("QB5ROUTaadd");
+ content = getRandomString();
+ createFile(QB5ROUTaadd, content);
+ IFileStore folder_20070319 = folder_6YLT5Xa.getChild("20070319");
+ createDir(folder_20070319, true);
+ content = getRandomString();
+ IFileStore QB5ROUTERa = folder_20070319.getChild("QB5ROUTERa");
+ content = getRandomString();
+ createFile(QB5ROUTERa, content);
+ IFileStore folder_20070320a = folder_6YLT5Xa.getChild("20070320a");
+ createDir(folder_20070320a, true);
+ IFileStore QB5ROupdfasd = folder_20070320a.getChild("QB5ROupdfasd");
+ content = getRandomString();
+ createFile(QB5ROupdfasd, content);
+ IFileStore folder_20070404a = folder_6YLT5Xa.getChild("20070404a");
+ createDir(folder_20070404a, true);
+ IFileStore qb5routeraad = folder_20070404a.getChild("qb5routeraad");
+ content = getRandomString();
+ createFile(qb5routeraad, content);
+ IFileStore dummyFolder = folder_6YLT5Xa.getChild("dummyFolder");
+ createDir(dummyFolder, true);
+ IFileStore folder_20070404a1 = dummyFolder.getChild("20070404a");
+ createDir(folder_20070404a1, true);
+ IFileStore qb5routeraa = folder_20070404a1.getChild("qb5routeraa");
+ content = getRandomString();
+ createFile(qb5routeraa, content);
+ IFileStore epdcdump01_hex12ab = dummyFolder.getChild("epdcdump01.hex12ab");
+ content = getRandomString();
+ createFile(epdcdump01_hex12ab, content);
+
+
+
+
+ //now, copy folderToCopy into the folder in the remote system
+ IRemoteFile sourceFolderToCopy1 = localFss.getRemoteFileObject(tempPath + '\\' + folderToCopyName1, mon);
+ ISystemDragDropAdapter srcAdapter1 = (ISystemDragDropAdapter) ((IAdaptable) sourceFolderToCopy1).getAdapter(ISystemDragDropAdapter.class);
+ SystemRemoteResourceSet fromSet = new SystemRemoteResourceSet(localFss, srcAdapter1);
+ fromSet.addResource(sourceFolderToCopy1);
+ ISystemResourceSet tempObjects1 = srcAdapter1.doDrag(fromSet, mon);
+ UniversalFileTransferUtility.copyWorkspaceResourcesToRemote((SystemWorkspaceResourceSet)tempObjects1, tempDir, mon, true);
+
+ IRemoteFile sourceFolderToCopy2 = localFss.getRemoteFileObject(tempPath + '\\' + folderToCopyName2, mon);
+ ISystemDragDropAdapter srcAdapter2 = (ISystemDragDropAdapter) ((IAdaptable) sourceFolderToCopy2).getAdapter(ISystemDragDropAdapter.class);
+ SystemRemoteResourceSet fromSet2 = new SystemRemoteResourceSet(localFss, srcAdapter2);
+ fromSet2.addResource(sourceFolderToCopy2);
+ ISystemResourceSet tempObjects2 = srcAdapter2.doDrag(fromSet2, mon);
+ UniversalFileTransferUtility.copyWorkspaceResourcesToRemote((SystemWorkspaceResourceSet)tempObjects2, tempDir, mon, true);
+
+ IRemoteFile zipSource1 = createFileOrFolder(tempDir.getAbsolutePath(), zipSourceFileName1, false);
+ assertTrue(zipSource1 != null);
+ IRemoteFile zipSourceFolder = (IRemoteFile)getChildFromFolder(tempDir, folderToCopyName1);
+ fss.copy(zipSourceFolder, zipSource1, folderToCopyName1, mon);
+
+ IRemoteFile zipSource2 = createFileOrFolder(tempDir.getAbsolutePath(), zipSourceFileName2, false);
+ assertTrue(zipSource2 != null);
+ IRemoteFile zipSourceFolder2 = (IRemoteFile)getChildFromFolder(tempDir, folderToCopyName2);
+ fss.copy(zipSourceFolder2, zipSource2, folderToCopyName2, mon);
+
+ //Then, we need to retrieve children of the tempDir to cache their information.
+ fss.resolveFilterString(tempDir, null, mon);
+
+ //Then, delete the temp folder in the junit workspace.
+ temp.delete(EFS.NONE, mon);
+
+ return;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+
+ }
public void setUp() {
if (!classBeenRunBefore)
{
- IPreferenceStore store = RSEUIPlugin.getDefault().getPreferenceStore();
-
- //We need to setDefault first in order to set the value of a preference.
- store.setDefault(ISystemPreferencesConstants.ALERT_SSL, ISystemPreferencesConstants.DEFAULT_ALERT_SSL);
- store.setDefault(ISystemPreferencesConstants.ALERT_NONSSL, ISystemPreferencesConstants.DEFAULT_ALERT_NON_SSL);
- store.setValue(ISystemPreferencesConstants.ALERT_SSL, false);
- store.setValue(ISystemPreferencesConstants.ALERT_NONSSL, false);
try
{
System.out.println("need to sleep");
@@ -66,17 +382,22 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
fs = fss.getFileService();
}
}
- try {
- File tempDirFile = File.createTempFile("rsetest","dir"); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue(tempDirFile.delete());
- assertTrue(tempDirFile.mkdir());
- tempDirPath = tempDirFile.getAbsolutePath();
- tempDir = fss.getRemoteFileObject(tempDirPath, mon);
- } catch(Exception e) {
- assertTrue("Exception creating temp dir", false); //$NON-NLS-1$
- }
- ZIP_SOURCE_DIR = "d:\\tmp\\junit_source\\";
+ localFss = fss; //Used for creating test source data.
+ //Create a temparory directory in My Home
+ try
+ {
+ IRemoteFile homeDirectory = fss.getRemoteFileObject(".", mon);
+ String baseFolderName = "rsetest";
+ String homeFolderName = homeDirectory.getAbsolutePath();
+ String testFolderName = FileServiceHelper.getRandomLocation(fss, homeFolderName, baseFolderName, mon);
+ tempDir = createFileOrFolder(homeFolderName, testFolderName, true);
+ tempDirPath = tempDir.getAbsolutePath();
+ }
+ catch (Exception e)
+ {
+ fail("Problem encountered: " + e.getStackTrace().toString());
+ }
}
public void tearDown() {
@@ -98,7 +419,6 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
assertTrue(newArchiveFile.canRead());
assertTrue(newArchiveFile.canWrite());
assertEquals(newArchiveFile.getName(), testName);
- assertEquals(newArchiveFile.getParentPath(), tempDirPath);
//fss.resolveFilterString(filterString, monitor)
@@ -214,91 +534,20 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
}
- public void testRenameVirtualFileBigZip() throws SystemMessageException {
- if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
-
- //copy the zip file first.
- String sourceFileName = "eclipse-SDK-3.3M6-win32.zip";
- IRemoteFile sourceZipFile = copySourceFileOrFolder(ZIP_SOURCE_DIR + sourceFileName, sourceFileName, tempDirPath);
- assertTrue(sourceZipFile != null);
-
- //Get the "features" directory under "eclipse"
- String directoryName ="eclipse";
- IRemoteFile parentDirectory = (IRemoteFile)getChildFromFolder(sourceZipFile, directoryName);
- assertTrue(parentDirectory != null);
- directoryName = "features";
- parentDirectory = (IRemoteFile)getChildFromFolder(parentDirectory, directoryName);
- //Now, we want to rename a folder (with really long name) inside this "feature" directory.
- directoryName = "org.eclipse.cvs.source_1.0.0.v20070202-7B79_71CI99g_LDV2411";
- IRemoteFile directoryToRename = (IRemoteFile)getChildFromFolder(parentDirectory, directoryName);
- assertTrue(directoryToRename != null);
- //Now, rename this directory
- String newDirectoryName = "org.eclipse.cvs.source_1.0.0.v20070202-7B79_71CI99g_LDV2411 aaa#@";
- fss.rename(directoryToRename, newDirectoryName, mon);
-
- //check result of this operation
- String[] namesToCheck = {"org.eclipse.cvs.source_1.0.0.v20070202-7B79_71CI99g_LDV2411 aaa#@",
- "org.eclipse.cvs_1.0.0.v20070202-7B79_71CI99g_LDV2411",
- "org.eclipse.jdt.source_3.3.0.v20070319-1800-7n7dEAWEgDfeRYHuyAaFTR",
- "org.eclipse.jdt_3.3.0.v20070319-1800-7n7dEAWEgDfeRYHuyAaFTR",
- "org.eclipse.pde.source_3.3.0.v20061114-0800-7M7M-6NUEF6EbRV6EWGC",
- "org.eclipse.pde_3.3.0.v20061114-0800-7M7M-6NUEF6EbRV6EWGC",
- "org.eclipse.platform.source_3.3.0.v20070316b-_-9MEhFxiXZ2gosKM6M-3_Hu9MqL",
- "org.eclipse.platform_3.3.0.v20070316b-_-9MEhFxiXZ2gosKM6M-3_Hu9MqL",
- "org.eclipse.rcp.source_3.3.0.v20070316b-8l8VCEYXUPdNkSgt8LpKG",
- "org.eclipse.rcp_3.3.0.v20070316b-8l8VCEYXUPdNkSgt8LpKG",
- "org.eclipse.sdk_3.3.0.v20070319-7L7J-4DjllPLcCcxrZDgaddnelet"};
- int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER,TYPE_FOLDER,TYPE_FOLDER,TYPE_FOLDER,
- TYPE_FOLDER, TYPE_FOLDER,TYPE_FOLDER,TYPE_FOLDER,TYPE_FOLDER, TYPE_FOLDER};
- checkFolderContents(parentDirectory, namesToCheck, typesToCheck);
-
- //Now, rename some files and folder inside the renamed folder.
- directoryToRename = (IRemoteFile)getChildFromFolder(parentDirectory, newDirectoryName);
- assertTrue(directoryToRename != null);
-
- String fileToRenameName = "eclipse_update_120.jpg";
- IRemoteFile levelThreeFileToRename = (IRemoteFile)getChildFromFolder(directoryToRename, fileToRenameName);
- assertTrue(levelThreeFileToRename != null);
-
- directoryName = "META-INF";
- IRemoteFile levelThreeDirectoryToRename = (IRemoteFile)getChildFromFolder(directoryToRename, directoryName);
- assertTrue(levelThreeDirectoryToRename != null);
-
- //Rename file first
- String newFileName = "eclipse_update_120aaa.jpg";
- fss.rename(levelThreeFileToRename, newFileName, mon);
-
- newDirectoryName = "META!@#$%^&*INF";
- fss.rename(levelThreeDirectoryToRename, newDirectoryName, mon);
-
- //check the result
- String[] level3NamesToCheck = {"META!@#$%^&*INF",
- "eclipse_update_120aaa.jpg",
- "epl-v10.html",
- "feature.properties",
- "feature.xml",
- "license.html"};
- int[] level3TypesToCheck = {TYPE_FOLDER, TYPE_FILE, TYPE_FILE, TYPE_FILE, TYPE_FILE, TYPE_FILE};
- checkFolderContents(directoryToRename, level3NamesToCheck, level3TypesToCheck);
-
- return;
-
- }
-
public void testMoveVirtualFile() throws SystemMessageException {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
- //copy the zip file first.
- String sourceFileName = "closedBefore.zip";
- IRemoteFile sourceZipFile = copySourceFileOrFolder(ZIP_SOURCE_DIR + sourceFileName, sourceFileName, tempDirPath);
- assertTrue(sourceZipFile != null);
+ //Create the source data needed for testing
+ createSourceZipFiles();
- //then, create a folder inside the tempDir
//then, create a folder inside the tempDir
String folderName = "folder1";
IRemoteFile folder1 = createFileOrFolder(tempDirPath, folderName, true);
assertTrue(folder1 != null);
+ String sourceZipFileName = zipSourceFileName1;
+ IRemoteFile sourceZipFile = (IRemoteFile)getChildFromFolder(tempDir, sourceZipFileName);
+
//Now, copy one of the folder from the zip file into folder1
try
{
@@ -332,28 +581,27 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
public void testMoveVirtualFileLevelTwo() throws SystemMessageException {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
- //copy the zip file first.
- String sourceFileName = "closedBefore.zip";
- IRemoteFile sourceZipFile = copySourceFileOrFolder(ZIP_SOURCE_DIR + sourceFileName, sourceFileName, tempDirPath);
- assertTrue(sourceZipFile != null);
+ createSourceZipFiles();
- //then, create a folder inside the tempDir
//then, create a folder inside the tempDir
String folderName = "folder1";
IRemoteFile folder1 = createFileOrFolder(tempDirPath, folderName, true);
assertTrue(folder1 != null);
+ String sourceZipFileName = zipSourceFileName1;
+ IRemoteFile sourceZipFile = (IRemoteFile)getChildFromFolder(tempDir, sourceZipFileName);
+ assertTrue(sourceZipFile != null);
+
//Now, move one of the level two folder from the zip file into folder1
try
{
//Now, copy one of the level two folder from the zip file into folder1
- Object[] children = fss.resolveFilterString(sourceZipFile, null, mon); //level one chidren
- Object[] levelTwoChildren = fss.resolveFilterString(children[0], null, mon);
- IRemoteFile originalVirtualFolder = (IRemoteFile)levelTwoChildren[0];
- String movedFolderName = originalVirtualFolder.getName();
+ IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(sourceZipFile, folderToCopyName1);
+ IRemoteFile secondLevelChild = (IRemoteFile)getChildFromFolder(firstLevelChild, "Team");
+ String movedFolderName = secondLevelChild.getName();
//copy this level two childer into folder1
- fss.move(originalVirtualFolder, folder1, originalVirtualFolder.getName(), mon);
+ fss.move(secondLevelChild, folder1, movedFolderName, mon);
Object movedVirtualFolder = getChildFromFolder(folder1, movedFolderName);
@@ -364,9 +612,9 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
checkFolderContents((IRemoteFile)movedVirtualFolder, contents, typesToCheck);
//Now, make sure the moved virtual folder is gone from its original zip file
- children = fss.resolveFilterString(sourceZipFile, null, mon);
- Object result = getChildFromFolder((IRemoteFile)children[0], movedFolderName);
- assertTrue(result == null); //we should not be able to find it.
+ Object originalVirtualFolder = getChildFromFolder(firstLevelChild, movedFolderName);
+
+ assertTrue(originalVirtualFolder == null); //we should not be able to find it.
}
catch (Exception e)
{
@@ -380,26 +628,23 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
public void testMoveToArchiveFile() throws SystemMessageException {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
- //copy the zip file first.
- String zipTargetFileName = "closedBefore.zip";
+ createSourceZipFiles();
+ createSourceFolders();
- IRemoteFile targetZipFile = copySourceFileOrFolder(ZIP_SOURCE_DIR + zipTargetFileName, zipTargetFileName, tempDirPath);
+ String targetZipFileName = zipSourceFileName1;
+ IRemoteFile targetZipFile = (IRemoteFile)getChildFromFolder(tempDir, targetZipFileName);
assertTrue(targetZipFile != null);
- //Now, copy the source folder.
- String sourceFolderName = "folderToCopy";
- IRemoteFile sourceFolder = copySourceFileOrFolder(ZIP_SOURCE_DIR + sourceFolderName, sourceFolderName, tempDirPath);
+ String sourceFolderName = folderToCopyName3;
+ IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir, sourceFolderName);
assertTrue(sourceFolder != null);
//Now, copy one of the folder from the sourceFolder into copiedTargetZipFile
try
{
- //Object[] children = fss.resolveFilterString(sourceZipFile, null, mon);
fss.move(sourceFolder, targetZipFile, sourceFolder.getName(), mon);
- //IRemoteFile copiedVirtualFolder = fss.getRemoteFileObject(folderAbsName+"\\" + ((IRemoteFile)children[0]).getName(), mon);
Object theMovedChild = getChildFromFolder(targetZipFile, sourceFolderName);
-
assertTrue(theMovedChild != null);
//Also make sure the copied child has the right contents.
@@ -425,28 +670,27 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
public void testMoveToVirtualFileLevelOne() throws SystemMessageException {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
- //copy the zip file first.
- String zipTargetFileName = "closedBefore.zip";
+ createSourceZipFiles();
+ createSourceFolders();
- IRemoteFile targetZipFile = copySourceFileOrFolder(ZIP_SOURCE_DIR + zipTargetFileName, zipTargetFileName, tempDirPath);
+ String targetZipFileName = zipSourceFileName1;
+ IRemoteFile targetZipFile = (IRemoteFile)getChildFromFolder(tempDir, targetZipFileName);
assertTrue(targetZipFile != null);
- //Now, copy the source folder.
- String sourceFolderName = "folderToCopy";
- IRemoteFile sourceFolder = copySourceFileOrFolder(ZIP_SOURCE_DIR + sourceFolderName, sourceFolderName, tempDirPath);
+ String sourceFolderName = folderToCopyName3;
+ IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir, sourceFolderName);
assertTrue(sourceFolder != null);
try
{
- //Now, copy one of the folder from the sourceFolder into a first level virtual file in targetZipFile
- //Get one of its first level children, and copy the folder to there.
- Object[] childrenOfTargetZipFile = fss.resolveFilterString(targetZipFile, null, mon);
+ //Now, move one of the folder from the sourceFolder into a first level virtual file in targetZipFile
+ //Get one of its first level children, and move the folder to there.
+ IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(targetZipFile, folderToCopyName1);
- //Object[] children = fss.resolveFilterString(sourceZipFile, null, mon);
- fss.move(sourceFolder, ((IRemoteFile)childrenOfTargetZipFile[0]), sourceFolderName, mon);
+ fss.move(sourceFolder, firstLevelChild, sourceFolderName, mon);
- Object theMovedChild = getChildFromFolder(((IRemoteFile)childrenOfTargetZipFile[0]), sourceFolderName);
+ Object theMovedChild = getChildFromFolder(firstLevelChild, sourceFolderName);
assertTrue(theMovedChild != null);
@@ -471,28 +715,27 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
public void testMoveToVirtualFileLevelTwo() throws SystemMessageException {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
- //copy the zip file first.
- String zipTargetFileName = "closedBefore.zip";
+ createSourceZipFiles();
+ createSourceFolders();
- IRemoteFile targetZipFile = copySourceFileOrFolder(ZIP_SOURCE_DIR + zipTargetFileName, zipTargetFileName, tempDirPath);
+ String targetZipFileName = zipSourceFileName1;
+ IRemoteFile targetZipFile = (IRemoteFile)getChildFromFolder(tempDir, targetZipFileName);
assertTrue(targetZipFile != null);
- //Now, copy the source folder.
- String sourceFolderName = "folderToCopy";
- IRemoteFile sourceFolder = copySourceFileOrFolder(ZIP_SOURCE_DIR + sourceFolderName, sourceFolderName, tempDirPath);
+ String sourceFolderName = folderToCopyName3;
+ IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir, sourceFolderName);
assertTrue(sourceFolder != null);
try
{
- //Get one of its second level children, and copy the folder to there.
- Object[] childrenOfTargetZipFile = fss.resolveFilterString(targetZipFile, null, mon);
- Object[] childrenOfTargetZipFileFirstLevel = fss.resolveFilterString(childrenOfTargetZipFile[0], null, mon);
+ //Get one of its second level children, and move the folder to there.
+ IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(targetZipFile, folderToCopyName1);
+ IRemoteFile secondLevelChild = (IRemoteFile)getChildFromFolder(firstLevelChild, "Team");
- //Object[] children = fss.resolveFilterString(sourceZipFile, null, mon);
- fss.move(sourceFolder, ((IRemoteFile)childrenOfTargetZipFileFirstLevel[1]), sourceFolder.getName(), mon);
+ fss.move(sourceFolder, secondLevelChild, sourceFolder.getName(), mon);
- Object theMovedChild = getChildFromFolder((IRemoteFile)childrenOfTargetZipFileFirstLevel[1], sourceFolderName);
+ Object theMovedChild = getChildFromFolder(secondLevelChild, sourceFolderName);
assertTrue(theMovedChild != null);
@@ -520,12 +763,12 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
public void testCopyVirtualFile() throws SystemMessageException {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
- //copy the zip file first.
- String sourceFileName = "closedBefore.zip";
- IRemoteFile sourceZipFile = copySourceFileOrFolder(ZIP_SOURCE_DIR + sourceFileName, sourceFileName, tempDirPath);
+ createSourceZipFiles();
+
+ String sourceZipFileName = zipSourceFileName1;
+ IRemoteFile sourceZipFile = (IRemoteFile)getChildFromFolder(tempDir, sourceZipFileName);
assertTrue(sourceZipFile != null);
- //then, create a folder inside the tempDir
//then, create a folder inside the tempDir
String folderName = "folder1";
IRemoteFile folder1 = createFileOrFolder(tempDirPath, folderName, true);
@@ -534,10 +777,10 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
//Now, copy one of the folder from the zip file into folder1
try
{
- Object[] children = fss.resolveFilterString(sourceZipFile, null, mon);
- fss.copy(((IRemoteFile)children[0]), folder1, ((IRemoteFile)children[0]).getName(), mon);
+ IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(sourceZipFile, folderToCopyName1);
+ fss.copy(firstLevelChild, folder1, folderToCopyName1, mon);
- Object copiedVirtualFolder = getChildFromFolder(folder1, (((IRemoteFile)children[0]).getName()));
+ Object copiedVirtualFolder = getChildFromFolder(folder1, folderToCopyName1);
assertTrue(copiedVirtualFolder != null);
@@ -556,9 +799,11 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
public void testCopyVirtualFileLevelTwo() throws SystemMessageException {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
+ createSourceZipFiles();
+
//copy the zip file first.
- String sourceFileName = "closedBefore.zip";
- IRemoteFile sourceZipFile = copySourceFileOrFolder(ZIP_SOURCE_DIR + sourceFileName, sourceFileName, tempDirPath);
+ String sourceZipFileName = zipSourceFileName1;
+ IRemoteFile sourceZipFile = (IRemoteFile)getChildFromFolder(tempDir, sourceZipFileName);
assertTrue(sourceZipFile != null);
//then, create a folder inside the tempDir
@@ -569,12 +814,12 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
try
{
//Now, copy one of the level two folder from the zip file into folder1
- Object[] children = fss.resolveFilterString(sourceZipFile, null, mon); //level one chidren
- Object[] levelTwoChildren = fss.resolveFilterString(children[0], null, mon);
- //copy this level two childer into folder1
- fss.copy(((IRemoteFile)levelTwoChildren[0]), folder1, ((IRemoteFile)levelTwoChildren[0]).getName(), mon);
+ IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(sourceZipFile, folderToCopyName1);
+ IRemoteFile secondLevelChild = (IRemoteFile)getChildFromFolder(firstLevelChild, "Team");
+ //copy this level two children into folder1
+ fss.copy(secondLevelChild, folder1, secondLevelChild.getName(), mon);
- Object copiedVirtualFolder = getChildFromFolder(folder1, (((IRemoteFile)levelTwoChildren[0]).getName()));
+ Object copiedVirtualFolder = getChildFromFolder(folder1, secondLevelChild.getName());
assertTrue(copiedVirtualFolder != null);
@@ -595,23 +840,21 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
public void testCopyToArchiveFile() throws SystemMessageException {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
- //copy the zip file first.
- String zipTargetFileName = "closedBefore.zip";
+ createSourceZipFiles();
+ createSourceFolders();
- IRemoteFile targetZipFile = copySourceFileOrFolder(ZIP_SOURCE_DIR + zipTargetFileName, zipTargetFileName, tempDirPath);
+ String targetZipFileName = zipSourceFileName1;
+ IRemoteFile targetZipFile = (IRemoteFile)getChildFromFolder(tempDir, targetZipFileName);
assertTrue(targetZipFile != null);
- //Now, copy the source folder.
- String sourceFolderName = "folderToCopy";
- IRemoteFile sourceFolder = copySourceFileOrFolder(ZIP_SOURCE_DIR + sourceFolderName, sourceFolderName, tempDirPath);
+ String sourceFolderName = folderToCopyName3;
+ IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir, sourceFolderName);
assertTrue(sourceFolder != null);
//Now, copy one of the folder from the sourceFolder into copiedTargetZipFile
try
{
- //Object[] children = fss.resolveFilterString(sourceZipFile, null, mon);
fss.copy(sourceFolder, targetZipFile, sourceFolder.getName(), mon);
- //IRemoteFile copiedVirtualFolder = fss.getRemoteFileObject(folderAbsName+"\\" + ((IRemoteFile)children[0]).getName(), mon);
Object theCopiedChild = getChildFromFolder(targetZipFile, sourceFolderName);
@@ -636,15 +879,15 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
public void testCopyToVirtualFileLevelOne() throws SystemMessageException {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
- //copy the zip file first.
- String zipTargetFileName = "closedBefore.zip";
+ createSourceZipFiles();
+ createSourceFolders();
- IRemoteFile targetZipFile = copySourceFileOrFolder(ZIP_SOURCE_DIR + zipTargetFileName, zipTargetFileName, tempDirPath);
+ String targetZipFileName = zipSourceFileName1;
+ IRemoteFile targetZipFile = (IRemoteFile)getChildFromFolder(tempDir, targetZipFileName);
assertTrue(targetZipFile != null);
- //Now, copy the source folder.
- String sourceFolderName = "folderToCopy";
- IRemoteFile sourceFolder = copySourceFileOrFolder(ZIP_SOURCE_DIR + sourceFolderName, sourceFolderName, tempDirPath);
+ String sourceFolderName = folderToCopyName3;
+ IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir, sourceFolderName);
assertTrue(sourceFolder != null);
@@ -652,12 +895,12 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
{
//Now, copy one of the folder from the sourceFolder into a first level virtual file in targetZipFile
//Get one of its first level children, and copy the folder to there.
- Object[] childrenOfTargetZipFile = fss.resolveFilterString(targetZipFile, null, mon);
+ //Now, copy one of the level two folder from the zip file into folder1
+ IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(targetZipFile, folderToCopyName1);
- //Object[] children = fss.resolveFilterString(sourceZipFile, null, mon);
- fss.copy(sourceFolder, ((IRemoteFile)childrenOfTargetZipFile[0]), sourceFolder.getName(), mon);
+ fss.copy(sourceFolder, firstLevelChild, sourceFolder.getName(), mon);
- Object theCopiedChild = getChildFromFolder(((IRemoteFile)childrenOfTargetZipFile[0]), sourceFolderName);
+ Object theCopiedChild = getChildFromFolder(firstLevelChild, sourceFolderName);
assertTrue(theCopiedChild != null);
@@ -678,28 +921,28 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
public void testCopyToVirtualFileLevelTwo() throws SystemMessageException {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
- //copy the zip file first.
- String zipTargetFileName = "closedBefore.zip";
+ createSourceZipFiles();
+ createSourceFolders();
- IRemoteFile targetZipFile = copySourceFileOrFolder(ZIP_SOURCE_DIR + zipTargetFileName, zipTargetFileName, tempDirPath);
+ String zipTargetFileName = zipSourceFileName1;
+ IRemoteFile targetZipFile = (IRemoteFile)getChildFromFolder(tempDir, zipTargetFileName);
assertTrue(targetZipFile != null);
- //Now, copy the source folder.
- String sourceFolderName = "folderToCopy";
- IRemoteFile sourceFolder = copySourceFileOrFolder(ZIP_SOURCE_DIR + sourceFolderName, sourceFolderName, tempDirPath);
+ String sourceFolderName = folderToCopyName3;
+ IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir, folderToCopyName3);
assertTrue(sourceFolder != null);
try
{
//Get one of its second level children, and copy the folder to there.
- Object[] childrenOfTargetZipFile = fss.resolveFilterString(targetZipFile, null, mon);
- Object[] childrenOfTargetZipFileFirstLevel = fss.resolveFilterString(childrenOfTargetZipFile[0], null, mon);
+ //Now, copy one of the level two folder from the zip file into folder1
+ IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(targetZipFile, folderToCopyName1);
+ IRemoteFile secondLevelChild = (IRemoteFile)getChildFromFolder(firstLevelChild, "TypeFilters");
- //Object[] children = fss.resolveFilterString(sourceZipFile, null, mon);
- fss.copy(sourceFolder, ((IRemoteFile)childrenOfTargetZipFileFirstLevel[1]), sourceFolder.getName(), mon);
+ fss.copy(sourceFolder, secondLevelChild, sourceFolder.getName(), mon);
- Object theCopiedChild = getChildFromFolder((IRemoteFile)childrenOfTargetZipFileFirstLevel[1], sourceFolderName);
+ Object theCopiedChild = getChildFromFolder(secondLevelChild, sourceFolderName);
assertTrue(theCopiedChild != null);
@@ -716,71 +959,430 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
return;
}
- public void testDeleteVirtualFileBigZip() throws SystemMessageException {
+ public void testCopyBatchToArchiveFile() throws SystemMessageException {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
- //copy the zip file first.
- String sourceFileName = "eclipse-SDK-3.3M6-win32.zip";
- IRemoteFile sourceZipFile = copySourceFileOrFolder(ZIP_SOURCE_DIR + sourceFileName, sourceFileName, tempDirPath);
+ createSourceZipFiles();
+ createSourceFolders();
+
+ String zipTargetFileName = zipSourceFileName1;
+ IRemoteFile targetZipFile = (IRemoteFile)getChildFromFolder(tempDir,zipTargetFileName);
+ assertTrue(targetZipFile != null);
+
+ //Now, copy the source folder.
+ String sourceFolderName = folderToCopyName3;
+ IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir,sourceFolderName);
+ assertTrue(sourceFolder != null);
+
+ //Now, copy one of the folder from the sourceFolder into copiedTargetZipFile
+ try
+ {
+ IRemoteFile[] sourceFiles = new IRemoteFile[3];
+ //Also add some of its children into the batch.
+ String childToCopyName1 = "aaaaaaaa";
+ sourceFiles[0] = (IRemoteFile)getChildFromFolder(sourceFolder, childToCopyName1);
+ String childToCopyName2 = "aaaab";
+ sourceFiles[1] = (IRemoteFile)getChildFromFolder(sourceFolder, childToCopyName2);
+ String childToCopyName3 = "epdcdump01.hex12a";
+ sourceFiles[2] = (IRemoteFile)getChildFromFolder(sourceFolder, childToCopyName3);
+ fss.copyBatch(sourceFiles, targetZipFile, mon);
+
+ //Checking the first copied folder
+ Object theCopiedChild = getChildFromFolder(targetZipFile, childToCopyName1);
+
+ assertTrue(theCopiedChild != null);
+
+ //Also make sure the copied child has the right contents.
+ String[] childrenToCheck1 = {"adsf", "eclipse-SDK-3.3M6-win32.zip", "epdcdump01.hex12", "epdcdump01.hex12aaaa"};
+
+ int[] typesToCheck1 = {TYPE_FILE, TYPE_FILE, TYPE_FILE, TYPE_FILE};
+ checkFolderContents((IRemoteFile)theCopiedChild, childrenToCheck1, typesToCheck1);
+
+ //Checking the second copied folder
+ theCopiedChild = getChildFromFolder(targetZipFile, childToCopyName2);
+
+ assertTrue(theCopiedChild != null);
+
+ //Also make sure the copied child has the right contents.
+ String[] childrenToCheck2 = {"features"};
+
+ int[] typesToCheck2 = {TYPE_FOLDER};
+ checkFolderContents((IRemoteFile)theCopiedChild, childrenToCheck2, typesToCheck2);
+
+ //Checking the third copied file
+ theCopiedChild = getChildFromFolder(targetZipFile, childToCopyName3);
+ assertTrue(theCopiedChild != null);
+ assertTrue(((IRemoteFile)theCopiedChild).isDirectory() != true);
+
+ }
+ catch (Exception e)
+ {
+ fail("Problem encountered: " + e.getStackTrace().toString());
+ }
+
+ return;
+ }
+
+ public void testCopyBatchToVirtualFileLevelOne() throws SystemMessageException {
+ if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
+
+ createSourceZipFiles();
+ createSourceFolders();
+
+ String zipTargetFileName = zipSourceFileName1;
+ IRemoteFile targetZipFile = (IRemoteFile)getChildFromFolder(tempDir, zipTargetFileName);
+ assertTrue(targetZipFile != null);
+
+ String sourceFolderName = folderToCopyName3;
+ IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir, sourceFolderName);
+ assertTrue(sourceFolder != null);
+
+
+ try
+ {
+ //Now, copy one of the folder from the sourceFolder into a first level virtual file in targetZipFile
+ //Get one of its first level children, and copy the folder to there.
+ Object[] childrenOfTargetZipFile = fss.resolveFilterString(targetZipFile, null, mon);
+
+ IRemoteFile[] sourceFiles = new IRemoteFile[1];
+ sourceFiles[0] = sourceFolder;
+ fss.copyBatch(sourceFiles, ((IRemoteFile)childrenOfTargetZipFile[0]), mon);
+
+ Object theCopiedChild = getChildFromFolder(((IRemoteFile)childrenOfTargetZipFile[0]), sourceFolderName);
+
+ assertTrue(theCopiedChild != null);
+
+ //Also make sure the copied child has the right contents.
+ String[] childrenToCheck = {"aaaaaaaa", "aaaab", "epdcdump01.hex12a", "RSE-SDK-2.0RC1.zip"};
+ int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FILE, TYPE_FILE};
+ checkFolderContents((IRemoteFile)theCopiedChild, childrenToCheck, typesToCheck);
+ }
+ catch (Exception e)
+ {
+ fail("Problem encountered: " + e.getStackTrace().toString());
+ }
+
+ return;
+ }
+
+ public void testCopyBatchToVirtualFileLevelTwo() throws SystemMessageException {
+ if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
+
+ createSourceZipFiles();
+ createSourceFolders();
+
+ String zipTargetFileName = zipSourceFileName1;
+ IRemoteFile targetZipFile = (IRemoteFile)getChildFromFolder(tempDir, zipTargetFileName);
+ assertTrue(targetZipFile != null);
+
+ //Now, copy the source folder.
+ String sourceFolderName = folderToCopyName3;
+ IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir, sourceFolderName);
+ assertTrue(sourceFolder != null);
+
+ try
+ {
+ //Get one of its second level children, and copy the folder to there.
+ //Now, copy one of the level two folder from the zip file into folder1
+ IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(targetZipFile, folderToCopyName1);
+ IRemoteFile secondLevelChild = (IRemoteFile)getChildFromFolder(firstLevelChild, "TypeFilters");
+
+ IRemoteFile[] sourceFiles = new IRemoteFile[3];
+ //Also add some of its children into the batch.
+ String childToCopyName1 = "aaaaaaaa";
+ sourceFiles[0] = (IRemoteFile)getChildFromFolder(sourceFolder, childToCopyName1);
+ String childToCopyName2 = "aaaab";
+ sourceFiles[1] = (IRemoteFile)getChildFromFolder(sourceFolder, childToCopyName2);
+ String childToCopyName3 = "epdcdump01.hex12a";
+ sourceFiles[2] = (IRemoteFile)getChildFromFolder(sourceFolder, childToCopyName3);
+ fss.copyBatch(sourceFiles, secondLevelChild, mon);
+
+
+ //Checking the first copied folder
+ Object theCopiedChild = getChildFromFolder(secondLevelChild, childToCopyName1);
+
+ assertTrue(theCopiedChild != null);
+
+ //Also make sure the copied child has the right contents.
+ String[] childrenToCheck1 = {"adsf", "eclipse-SDK-3.3M6-win32.zip", "epdcdump01.hex12", "epdcdump01.hex12aaaa"};
+
+ int[] typesToCheck1 = {TYPE_FILE, TYPE_FILE, TYPE_FILE, TYPE_FILE};
+ checkFolderContents((IRemoteFile)theCopiedChild, childrenToCheck1, typesToCheck1);
+
+ //Checking the second copied folder
+ theCopiedChild = getChildFromFolder(secondLevelChild, childToCopyName2);
+
+ assertTrue(theCopiedChild != null);
+
+ //Also make sure the copied child has the right contents.
+ String[] childrenToCheck2 = {"features"};
+
+ int[] typesToCheck2 = {TYPE_FOLDER};
+ checkFolderContents((IRemoteFile)theCopiedChild, childrenToCheck2, typesToCheck2);
+
+ //Checking the third copied file
+ theCopiedChild = getChildFromFolder(secondLevelChild, childToCopyName3);
+ assertTrue(theCopiedChild != null);
+ assertTrue(((IRemoteFile)theCopiedChild).isDirectory() != true);
+
+ }
+ catch (Exception e)
+ {
+ fail("Problem encountered: " + e.getStackTrace().toString());
+ }
+
+ return;
+ }
+
+ public void testCopyBatchVirtualFile() throws SystemMessageException {
+ if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
+
+ createSourceZipFiles();
+
+ String sourceFileName = zipSourceFileName1;
+ IRemoteFile sourceZipFile = (IRemoteFile)getChildFromFolder(tempDir,sourceFileName);
assertTrue(sourceZipFile != null);
- //Get the "features" directory under "eclipse"
- String directoryName ="eclipse";
- IRemoteFile parentDirectory = (IRemoteFile)getChildFromFolder(sourceZipFile, directoryName);
- assertTrue(parentDirectory != null);
- directoryName = "features";
- parentDirectory = (IRemoteFile)getChildFromFolder(parentDirectory, directoryName);
- //Now, we want to delete a folder (with really long name) inside this "feature" directory.
- directoryName = "org.eclipse.platform.source_3.3.0.v20070316b-_-9MEhFxiXZ2gosKM6M-3_Hu9MqL";
- IRemoteFile directoryToDelete = (IRemoteFile)getChildFromFolder(parentDirectory, directoryName);
- assertTrue(directoryToDelete != null);
- //Now, delete this directory
- fss.delete(directoryToDelete, mon);
- directoryToDelete = (IRemoteFile)getChildFromFolder(parentDirectory, directoryName);
- assertTrue(directoryToDelete == null);
+ //then, create a folder inside the tempDir
+ String folderName = "folder1";
+ IRemoteFile folder1 = createFileOrFolder(tempDirPath, folderName, true);
+ assertTrue(folder1 != null);
- //check result of this operation
- String[] namesToCheck = {"org.eclipse.cvs.source_1.0.0.v20070202-7B79_71CI99g_LDV2411",
- "org.eclipse.cvs_1.0.0.v20070202-7B79_71CI99g_LDV2411",
- "org.eclipse.jdt.source_3.3.0.v20070319-1800-7n7dEAWEgDfeRYHuyAaFTR",
- "org.eclipse.jdt_3.3.0.v20070319-1800-7n7dEAWEgDfeRYHuyAaFTR",
- "org.eclipse.pde.source_3.3.0.v20061114-0800-7M7M-6NUEF6EbRV6EWGC",
- "org.eclipse.pde_3.3.0.v20061114-0800-7M7M-6NUEF6EbRV6EWGC",
- "org.eclipse.platform_3.3.0.v20070316b-_-9MEhFxiXZ2gosKM6M-3_Hu9MqL",
- "org.eclipse.rcp.source_3.3.0.v20070316b-8l8VCEYXUPdNkSgt8LpKG",
- "org.eclipse.rcp_3.3.0.v20070316b-8l8VCEYXUPdNkSgt8LpKG",
- "org.eclipse.sdk_3.3.0.v20070319-7L7J-4DjllPLcCcxrZDgaddnelet"};
- int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER,TYPE_FOLDER,TYPE_FOLDER,TYPE_FOLDER,
- TYPE_FOLDER, TYPE_FOLDER,TYPE_FOLDER,TYPE_FOLDER,TYPE_FOLDER};
- checkFolderContents(parentDirectory, namesToCheck, typesToCheck);
+ //Now, copy one of the folder from the zip file into folder1
+ try
+ {
+ Object[] children = fss.resolveFilterString(sourceZipFile, null, mon);
+ IRemoteFile[] sourceFiles = new IRemoteFile[3];
+ String childToCopyName1 = "Team";
+ sourceFiles[0] = (IRemoteFile)getChildFromFolder((IRemoteFile)children[0], childToCopyName1);
+ assertTrue(sourceFiles[0] != null);
+ String childToCopyName2 = "xuanchentp";
+ sourceFiles[1] = (IRemoteFile)getChildFromFolder((IRemoteFile)children[0], childToCopyName2);
+ assertTrue(sourceFiles[1] != null);
+ String childToCopyName3 = ".compatibility";
+ sourceFiles[2] = (IRemoteFile)getChildFromFolder((IRemoteFile)children[0], childToCopyName3);
+ assertTrue(sourceFiles[2] != null);
+ fss.copyBatch(sourceFiles, folder1, mon);
+
+ Object copiedVirtualFolder = getChildFromFolder(folder1, childToCopyName1);
+ assertTrue(copiedVirtualFolder != null);
+ String[] contents1 = {"Connections", "Filters", "profile.xmi"};
+ int[] typesToCheck1 = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FILE};
+ checkFolderContents((IRemoteFile)copiedVirtualFolder, contents1, typesToCheck1);
+
+ copiedVirtualFolder = getChildFromFolder(folder1, childToCopyName2);
+ assertTrue(copiedVirtualFolder != null);
+ String[] contents2 = {"Connections", "Filters", "profile.xmi"};
+ int[] typesToCheck2 = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FILE};
+ checkFolderContents((IRemoteFile)copiedVirtualFolder, contents2, typesToCheck2);
+
+ Object copiedVirtualFile = getChildFromFolder(folder1, childToCopyName3);
+ assertTrue(copiedVirtualFile != null);
+ assertTrue(((IRemoteFile)copiedVirtualFile).isDirectory() != true);
+
+ }
+ catch (Exception e)
+ {
+ fail("Problem encountered: " + e.getStackTrace().toString());
+ }
- //Now, delete some files and folder inside the a virtual folder.
- parentDirectory = (IRemoteFile)getChildFromFolder(parentDirectory, "org.eclipse.rcp_3.3.0.v20070316b-8l8VCEYXUPdNkSgt8LpKG");
- assertTrue(parentDirectory != null);
+ return;
+ }
+
+ public void testCopyBatchVirtualFileLevelTwo() throws SystemMessageException {
+ if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
- String fileToDelete = "eclipse_update_120.jpg";
- IRemoteFile levelThreeFileToDelete = (IRemoteFile)getChildFromFolder(parentDirectory, fileToDelete);
- assertTrue(levelThreeFileToDelete != null);
+ createSourceZipFiles();
- String directoryNameToDelete = "META-INF";
- IRemoteFile levelThreeDirectoryToDelete = (IRemoteFile)getChildFromFolder(parentDirectory, directoryNameToDelete);
- assertTrue(levelThreeDirectoryToDelete != null);
+ String sourceFileName = zipSourceFileName1;
+ IRemoteFile sourceZipFile = (IRemoteFile)getChildFromFolder(tempDir, sourceFileName);
+ assertTrue(sourceZipFile != null);
- //delete file first
- fss.delete(levelThreeFileToDelete, mon);
+ //then, create a folder inside the tempDir
+ String folderName = "folder1";
+ IRemoteFile folder1 = createFileOrFolder(tempDirPath, folderName, true);
+ assertTrue(folder1 != null);
- fss.delete(levelThreeDirectoryToDelete, mon);
-
- //check the result
- String[] level3NamesToCheck = {"epl-v10.html",
- "feature.properties",
- "feature.xml",
- "license.html"};
- int[] level3TypesToCheck = {TYPE_FILE, TYPE_FILE, TYPE_FILE, TYPE_FILE};
- checkFolderContents(parentDirectory, level3NamesToCheck, level3TypesToCheck);
+ try
+ {
+ //Now, copy one of the level two folder from the zip file into folder1
+ IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(sourceZipFile, folderToCopyName1);
+ IRemoteFile secondLevelChild = (IRemoteFile)getChildFromFolder(firstLevelChild, "Team");
+
+ IRemoteFile[] sourceFiles = new IRemoteFile[1];
+ sourceFiles[0] = secondLevelChild;
+ //copy this level two childer into folder1
+ fss.copyBatch(sourceFiles, folder1, mon);
+
+ Object copiedVirtualFolder = getChildFromFolder(folder1, secondLevelChild.getName());
+
+ assertTrue(copiedVirtualFolder != null);
+
+ String[] contents = {"Connections", "Filters", "profile.xmi"};
+ int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FILE};
+ checkFolderContents((IRemoteFile)copiedVirtualFolder, contents, typesToCheck);
+ }
+ catch (Exception e)
+ {
+ fail("Problem encountered: " + e.getStackTrace().toString());
+ }
return;
}
+ public void testCopyVirtualBatchToArchiveFile() throws SystemMessageException {
+ if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
+
+ createSourceZipFiles();
+
+ String zipTargetFileName = zipSourceFileName1;
+ IRemoteFile targetZipFile = (IRemoteFile)getChildFromFolder(tempDir, zipTargetFileName);
+ assertTrue(targetZipFile != null);
+
+ String sourcefileName = zipSourceFileName2;
+ IRemoteFile sourceFile = (IRemoteFile)getChildFromFolder(tempDir, sourcefileName);
+ assertTrue(sourceFile != null);
+
+ //Now, copy one of the folder from the sourceFile into copiedTargetZipFile
+ try
+ {
+ IRemoteFile[] sourceFiles = new IRemoteFile[1];
+ String virutalFolderToCopyName = "6YLT5Xa";
+ IRemoteFile virtualFolderToCopy = (IRemoteFile)getChildFromFolder(sourceFile, virutalFolderToCopyName);
+ sourceFiles[0] = virtualFolderToCopy;
+ fss.copyBatch(sourceFiles, targetZipFile, mon);
+
+ Object theCopiedChild = getChildFromFolder(targetZipFile, virutalFolderToCopyName);
+
+ assertTrue(theCopiedChild != null);
+
+ //Also make sure the copied child has the right contents.
+ String[] childrenToCheck = {"20070315a", "20070319", "20070320a", "20070404a", "dummyFolder"};
+
+ int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FOLDER, TYPE_FOLDER, TYPE_FOLDER};
+ checkFolderContents((IRemoteFile)theCopiedChild, childrenToCheck, typesToCheck);
+ }
+ catch (Exception e)
+ {
+ fail("Problem encountered: " + e.getStackTrace().toString());
+ }
+
+ return;
+ }
+
+ public void testCopyVirtualBatchToVirtualFileLevelOne() throws SystemMessageException {
+ if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
+
+ createSourceZipFiles();
+
+ String zipTargetFileName = zipSourceFileName1;
+ IRemoteFile targetZipFile = (IRemoteFile)getChildFromFolder(tempDir, zipTargetFileName);
+ assertTrue(targetZipFile != null);
+
+ String sourcefileName = zipSourceFileName2;
+ IRemoteFile sourceFile = (IRemoteFile)getChildFromFolder(tempDir, sourcefileName);
+ assertTrue(sourceFile != null);
+
+ try
+ {
+ //Now, copy one of the folder from the sourceFolder into a first level virtual file in targetZipFile
+ //Get one of its first level children, and copy the folder to there.
+ Object[] childrenOfTargetZipFile = fss.resolveFilterString(targetZipFile, null, mon);
+
+ IRemoteFile[] sourceFiles = new IRemoteFile[3];
+
+ String parentOfVirutalFolderToCopyName = "6YLT5Xa";
+ IRemoteFile parentOfVirtualFolderToCopy = (IRemoteFile)getChildFromFolder(sourceFile, parentOfVirutalFolderToCopyName);
+ String virtualChildToCopyName1 = "20070315a";
+ String virtualChildToCopyName2 = "20070319";
+ String virtualChildToCopyName3 = "dummyFolder";
+
+ sourceFiles[0] = (IRemoteFile)getChildFromFolder(parentOfVirtualFolderToCopy, virtualChildToCopyName1);
+ assertTrue(sourceFiles[0] != null);
+ sourceFiles[1] = (IRemoteFile)getChildFromFolder(parentOfVirtualFolderToCopy, virtualChildToCopyName2);
+ assertTrue(sourceFiles[1] != null);
+ sourceFiles[2] = (IRemoteFile)getChildFromFolder(parentOfVirtualFolderToCopy, virtualChildToCopyName3);
+ assertTrue(sourceFiles[2] != null);
+ fss.copyBatch(sourceFiles, ((IRemoteFile)childrenOfTargetZipFile[0]), mon);
+
+
+ Object theCopiedChild = getChildFromFolder(((IRemoteFile)childrenOfTargetZipFile[0]), virtualChildToCopyName1);
+ assertTrue(theCopiedChild != null);
+ //Also make sure the copied child has the right contents.
+ String[] childrenToCheck1 = {"QB5ROUTaadd"};
+ int[] typesToCheck1 = {TYPE_FILE};
+ checkFolderContents((IRemoteFile)theCopiedChild, childrenToCheck1, typesToCheck1);
+
+ theCopiedChild = getChildFromFolder(((IRemoteFile)childrenOfTargetZipFile[0]), virtualChildToCopyName2);
+ assertTrue(theCopiedChild != null);
+ //Also make sure the copied child has the right contents.
+ String[] childrenToCheck2 = {"QB5ROUTERa"};
+ int[] typesToCheck2 = {TYPE_FILE};
+ checkFolderContents((IRemoteFile)theCopiedChild, childrenToCheck2, typesToCheck2);
+
+ theCopiedChild = getChildFromFolder(((IRemoteFile)childrenOfTargetZipFile[0]), virtualChildToCopyName3);
+ assertTrue(theCopiedChild != null);
+ //Also make sure the copied child has the right contents.
+ String[] childrenToCheck3 = {"20070404a", "epdcdump01.hex12ab"};
+ int[] typesToCheck3 = {TYPE_FOLDER, TYPE_FILE};
+ checkFolderContents((IRemoteFile)theCopiedChild, childrenToCheck3, typesToCheck3);
+
+ }
+ catch (Exception e)
+ {
+ fail("Problem encountered: " + e.getStackTrace().toString());
+ }
+
+ return;
+ }
+
+ public void testCopyVirtualBatchToVirtualFileLevelTwo() throws SystemMessageException {
+ if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
+
+ createSourceZipFiles();
+
+ String zipTargetFileName = zipSourceFileName1;
+ IRemoteFile targetZipFile = (IRemoteFile)getChildFromFolder(tempDir, zipTargetFileName);
+ assertTrue(targetZipFile != null);
+
+ String sourcefileName = zipSourceFileName2;
+ IRemoteFile sourceFile = (IRemoteFile)getChildFromFolder(tempDir, sourcefileName);
+ assertTrue(sourceFile != null);
+
+ try
+ {
+ //Get one of its second level children, and copy the folder to there.
+ //Now, copy one of the level two folder from the zip file into folder1
+ IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(targetZipFile, folderToCopyName1);
+ IRemoteFile secondLevelChild = (IRemoteFile)getChildFromFolder(firstLevelChild, "TypeFilters");
+
+ IRemoteFile[] sourceFiles = new IRemoteFile[1];
+
+ String parentOfVirutalFolderToCopyName = "6YLT5Xa";
+ IRemoteFile parentOfVirtualFolderToCopy = (IRemoteFile)getChildFromFolder(sourceFile, parentOfVirutalFolderToCopyName);
+ String virtualFolderToCopyName = "dummyFolder";
+ IRemoteFile virtualFolderToCopy = (IRemoteFile)getChildFromFolder(parentOfVirtualFolderToCopy, virtualFolderToCopyName);
+
+ sourceFiles[0] = virtualFolderToCopy;
+
+ fss.copyBatch(sourceFiles, secondLevelChild, mon);
+
+ Object theCopiedChild = getChildFromFolder(parentOfVirtualFolderToCopy, virtualFolderToCopyName);
+
+ assertTrue(theCopiedChild != null);
+
+ //Also make sure the copied child has the right contents.
+ String[] childrenToCheck = {"20070404a", "epdcdump01.hex12ab"};
+ int[] typesToCheck = {TYPE_FOLDER, TYPE_FILE};
+ checkFolderContents((IRemoteFile)theCopiedChild, childrenToCheck, typesToCheck);
+ }
+ catch (Exception e)
+ {
+ fail("Problem encountered: " + e.getStackTrace().toString());
+ }
+
+ return;
+ }
+
}
diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileServiceArchiveTestDStore.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileServiceArchiveTestDStore.java
index 854df5cb9ea..0916eab397f 100644
--- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileServiceArchiveTestDStore.java
+++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileServiceArchiveTestDStore.java
@@ -10,13 +10,24 @@
*******************************************************************************/
package org.eclipse.rse.tests.subsystems.files;
+import junit.framework.TestSuite;
+
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.rse.core.IRSESystemType;
import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.core.model.ISystemRegistry;
+import org.eclipse.rse.core.model.ISystemResourceSet;
+import org.eclipse.rse.core.model.SystemRemoteResourceSet;
import org.eclipse.rse.core.model.SystemStartHere;
+import org.eclipse.rse.core.model.SystemWorkspaceResourceSet;
import org.eclipse.rse.core.subsystems.IConnectorService;
+import org.eclipse.rse.core.subsystems.IRemoteServerLauncher;
+import org.eclipse.rse.core.subsystems.IServerLauncherProperties;
import org.eclipse.rse.core.subsystems.ISubSystem;
+import org.eclipse.rse.core.subsystems.ISystemDragDropAdapter;
+import org.eclipse.rse.files.ui.resources.UniversalFileTransferUtility;
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
import org.eclipse.rse.services.files.IFileService;
import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
@@ -27,19 +38,65 @@ import org.eclipse.rse.ui.RSEUIPlugin;
public class FileServiceArchiveTestDStore extends FileServiceArchiveTest {
- /*
+ protected String tarSourceFileName1 = "source.tar";
+ protected String tarSourceFileName2 = "mynewtar.tar";
+
+ protected String tarSourceFolderName1 = "META-INF";
+ protected String tarSourceFolderName2 = "org";
+
public static junit.framework.Test suite() {
TestSuite suite = new TestSuite("FileServiceArchiveTestDStore");
- suite.addTest(new FileServiceArchiveTestDStore("testMoveToVirtualFileLevelOne"));
+
+ //zip file testing
+ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testCopyBatchToArchiveFile")); //$NON-NLS-1$
+ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testCopyBatchToVirtualFileLevelOne")); //$NON-NLS-1$
+ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testCopyBatchToVirtualFileLevelTwo")); //$NON-NLS-1$
+ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testCopyBatchVirtualFile")); //$NON-NLS-1$
+ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testCopyBatchVirtualFileLevelTwo")); //$NON-NLS-1$
+ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testCopyToArchiveFile")); //$NON-NLS-1$
+ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testCopyToVirtualFileLevelOne")); //$NON-NLS-1$
+ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testCopyToVirtualFileLevelTwo")); //$NON-NLS-1$
+ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testCopyVirtualBatchToArchiveFile")); //$NON-NLS-1$
+ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testCopyVirtualBatchToVirtualFileLevelOne")); //$NON-NLS-1$
+ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testCopyVirtualBatchToVirtualFileLevelTwo")); //$NON-NLS-1$
+ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testCopyVirtualFile")); //$NON-NLS-1$
+ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testCopyVirtualFileLevelTwo")); //$NON-NLS-1$
+ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testCreateZipFile")); //$NON-NLS-1$
+ //suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testDeleteVirtualFileBigZip")); //$NON-NLS-1$
+ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testMoveToArchiveFile")); //$NON-NLS-1$
+ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testMoveToVirtualFileLevelOne")); //$NON-NLS-1$
+ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testMoveToVirtualFileLevelTwo")); //$NON-NLS-1$
+ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testMoveVirtualFile")); //$NON-NLS-1$
+ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testMoveVirtualFileLevelTwo")); //$NON-NLS-1$
+ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testRenameVirtualFile")); //$NON-NLS-1$
+ //suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testRenameVirtualFileBigZip")); //$NON-NLS-1$
+
+ //tar file testing
+ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testCreateTarFile")); //$NON-NLS-1$
+ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testCopyTarVirtualFile")); //$NON-NLS-1$
+ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testCopyTarVirtualFileLevelFour")); //$NON-NLS-1$
+ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testCopyToTarArchiveFile")); //$NON-NLS-1$
+ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testCopyToTarVirtualFileLevelOne")); //$NON-NLS-1$
+ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testCopyToTarVirtualFileLevelFour")); //$NON-NLS-1$
+ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testDeleteTarVirtualFile")); //$NON-NLS-1$
+ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testMoveTarVirtualFile")); //$NON-NLS-1$
+ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testMoveTarVirtualFileLevelFour")); //$NON-NLS-1$
+ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testMoveToTarArchiveFile")); //$NON-NLS-1$
+ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testMoveToTarVirtualFileLevelOne")); //$NON-NLS-1$
+ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testMoveToVirtualFileLevelFour")); //$NON-NLS-1$
+ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testRenameTarVirtualFile")); //$NON-NLS-1$
+ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testCopyBatchTarVirtualFileLevelFive"));
+ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testCopyBatchToTarArchiveFile"));
+ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testCopyBatchToTarVirtualFileLevelFour"));
+
return suite;
}
- */
+
+
public void setUp() {
//We need to delay if it is first case run after a workspace startup
SYSTEM_TYPE_ID = IRSESystemType.SYSTEMTYPE_LINUX_ID;
- TMP_DIR_PARENT = "/home2/xuanchen/test/";
- ZIP_SOURCE_DIR = "/home2/xuanchen/test/junit_source/";
SYSTEM_ADDRESS = "SLES8RM";
SYSTEM_NAME = "sles8rm_ds";
USER_ID = "xuanchen";
@@ -76,20 +133,30 @@ public class FileServiceArchiveTestDStore extends FileServiceArchiveTest {
fs = fss.getFileService();
}
}
+
+ IHost localHost = getLocalSystemConnection();
+ sr = SystemStartHere.getSystemRegistry();
+ ss = sr.getServiceSubSystems(localHost, IFileService.class);
+ for (int i=0; i
+ * -
*******************************************************************************/
package org.eclipse.rse.tests.subsystems.files;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
import java.util.HashMap;
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileInfo;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager;
import org.eclipse.rse.services.files.IFileService;
import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
@@ -24,6 +35,7 @@ import org.eclipse.rse.tests.core.connection.RSEBaseConnectionTestCase;
public class FileServiceBaseTest extends RSEBaseConnectionTestCase {
protected IFileServiceSubSystem fss;
+ protected IFileServiceSubSystem localFss;
protected IFileService fs;
protected IRemoteFile tempDir;
protected String tempDirPath;
@@ -48,6 +60,7 @@ public class FileServiceBaseTest extends RSEBaseConnectionTestCase {
return "a !@#${a}'` file%^&()_ =[]~+-;,."; //$NON-NLS-1$
}
+
public IRemoteFile copySourceFileOrFolder(String sourceFullName, String sourceName, String targetFolderFullName)
{
boolean ok = false;
@@ -65,7 +78,7 @@ public class FileServiceBaseTest extends RSEBaseConnectionTestCase {
//Need to call resolveFilterString of the parent to make sure the newly copied child
//is added to the DStore map. Otherwise, next time when query it, it will just created a
//default filter string. And the dstore server cannot handler it correctly.
- Object[] children = fss.resolveFilterString(targetFolder, null, mon);
+ fss.resolveFilterString(targetFolder, null, mon);
}
catch(Exception e)
{
@@ -99,7 +112,7 @@ public class FileServiceBaseTest extends RSEBaseConnectionTestCase {
//Need to call resolveFilterString of the parent to make sure the newly created child
//is added to the DStore map. Otherwise, next time when query it, it will just created a
//default filter string. And the dstore server cannot handler it correctly.
- Object[] children = fss.resolveFilterString(targetFolder, null, mon);
+ fss.resolveFilterString(targetFolder, null, mon);
}
catch (Exception e)
{
@@ -141,6 +154,7 @@ public class FileServiceBaseTest extends RSEBaseConnectionTestCase {
//We need to call getRemoteFileObject to get its attribute updated.
//Otherwise, will get error "directory not readable"
folderToCheck = fss.getRemoteFileObject(folderToCheck.getAbsolutePath(), mon);
+ System.out.println("verifying the contents for folder: " + folderToCheck.getAbsolutePath());
Object[] children = fss.resolveFilterString(folderToCheck, null, mon);
//Make sure the children array includes the copied folder.
HashMap childrenMap = new HashMap();
@@ -154,7 +168,7 @@ public class FileServiceBaseTest extends RSEBaseConnectionTestCase {
for (int i=0; i
+ //----------------------------------------------------------------------
+ protected IFileStore createDir(IFileStore store, boolean clear) throws CoreException {
+ if (clear && store.fetchInfo().exists())
+ store.delete(EFS.NONE, null);
+ store.mkdir(EFS.NONE, null);
+ IFileInfo info = store.fetchInfo();
+ assertTrue("createDir.1", info.exists());
+ assertTrue("createDir.1", info.isDirectory());
+ return store;
+ }
+
+ //----------------------------------------------------------------------
+ //
+ //----------------------------------------------------------------------
+ protected IFileStore createDir(String string, boolean clear) throws CoreException {
+ return createDir(EFS.getFileSystem(EFS.SCHEME_FILE).getStore(new Path(string)), clear);
+ }
+
+ /**
+ * Create a file with random content. If a resource exists in the same path,
+ * the resource is deleted.
+ *
+ *
+ * @param target the file to create
+ * @param content content of the new file
+ * @throws CoreException
+ */
+ protected void createFile(IFileStore target, String content) throws CoreException {
+ target.delete(EFS.NONE, null);
+ InputStream input = new ByteArrayInputStream(content.getBytes());
+ transferData(input, target.openOutputStream(EFS.NONE, null));
+ IFileInfo info = target.fetchInfo();
+ assertTrue(info.exists() && !info.isDirectory());
+ }
+
+ /**
+ * Copy the data from the input stream to the output stream.
+ * Close both streams when finished.
+ *
+ *
+ * @param input input stream
+ * @param output output stream
+ */
+ protected void transferData(InputStream input, OutputStream output) {
+ try {
+ try {
+ int c = 0;
+ while ((c = input.read()) != -1)
+ output.write(c);
+ } finally {
+ input.close();
+ output.close();
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ assertTrue(e.toString(), false);
+ }
+ }
+
+ /**
+ * Return String with some random text to use
+ * as contents for a file resource.
+ *
+ *
+ * @return the result random string
+ */
+ protected String getRandomString() {
+ switch ((int) Math.round(Math.random() * 10)) {
+ case 0 :
+ return "este e' o meu conteudo (portuguese)";
+ case 1 :
+ return "ho ho ho";
+ case 2 :
+ return "I'll be back";
+ case 3 :
+ return "don't worry, be happy";
+ case 4 :
+ return "there is no imagination for more sentences";
+ case 5 :
+ return "customize yours";
+ case 6 :
+ return "foo";
+ case 7 :
+ return "bar";
+ case 8 :
+ return "foobar";
+ case 9 :
+ return "case 9";
+ default :
+ return "these are my contents";
+ }
+ }
}
diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileServiceHelper.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileServiceHelper.java
new file mode 100644
index 00000000000..c630e6ffb71
--- /dev/null
+++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileServiceHelper.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Xuan Chen (IBM) - copied and adapted from org.eclipse.core.tests.harness/FileSystemHelper
+ *******************************************************************************/
+package org.eclipse.rse.tests.subsystems.files;
+
+import java.io.IOException;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
+import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
+
+/**
+ * Home for file system-related utility methods.
+ */
+public class FileServiceHelper {
+ /** counter for generating unique random file system locations */
+ protected static int nextLocationCounter = 0;
+ private static final long MASK = 0x00000000FFFFFFFFL;
+
+ /*
+ * Return the root directory for the temp dir.
+ */
+ public static IPath getTempDir() {
+ String tempPath = System.getProperty("java.io.tmpdir");
+ try {
+ tempPath = new java.io.File(tempPath).getCanonicalPath();
+ } catch (IOException e) {
+ //ignore and use non-canonical path
+ }
+ return new Path(tempPath);
+ }
+
+ /**
+ * Returns a unique location on the remote file system. It is guaranteed that no file currently
+ * exists at that location. The returned location will be unique with respect
+ * to all other locations generated by this method in the current session.
+ * If the caller creates a folder or file at this location, they are responsible for
+ * deleting it when finished.
+ * @param fss The FileServiceSubSystem where we want to get this location
+ * @param parentPath The path of the parent folder
+ * @param baseName the name where the calculated extension will be appended to
+ * @param mon Progress Monitor needed for necessary remote query
+ * @return the generated name of this location
+ */
+ public static String getRandomLocation(IFileServiceSubSystem fss, String parentPath, String baseName, IProgressMonitor mon) {
+ String resultName = computeRandomLocation(fss, baseName);
+ try
+ {
+ IRemoteFile remoteFile = fss.getRemoteFileObject(parentPath + fss.getSeparator() + resultName, mon);
+ boolean fileExist = (remoteFile != null) && remoteFile.exists();
+ while (fileExist)
+ {
+ try
+ {
+ Thread.sleep(10);
+ } catch (InterruptedException e) {
+ // ignore
+ }
+ resultName = computeRandomLocation(fss, baseName);
+ remoteFile = fss.getRemoteFileObject(parentPath + fss.getSeparator() + resultName, mon);
+ fileExist = (remoteFile != null) && remoteFile.exists();
+ }
+ }
+ catch (Exception e)
+ {
+ return null;
+ }
+ return resultName;
+
+ }
+
+ public static String computeRandomLocation(IFileServiceSubSystem fss, String path) {
+ long segment = (((long) ++nextLocationCounter) << 32) | (System.currentTimeMillis() & MASK);
+ return path +(Long.toString(segment));
+ }
+
+}