Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 92312 Details for
Bug 195402
[api] RSE should support gzipped tar archives (*.tgz, *.tar.gz)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Updated patch with minor stylistic changes
bug195402_3.diff.txt (text/plain), 123.67 KB, created by
Martin Oberhuber
on 2008-03-12 09:53:51 EDT
(
hide
)
Description:
Updated patch with minor stylistic changes
Filename:
MIME Type:
Creator:
Martin Oberhuber
Created:
2008-03-12 09:53:51 EDT
Size:
123.67 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.rse.tests >Index: src/org/eclipse/rse/tests/subsystems/files/RSEFileSubsystemTestSuite.java >=================================================================== >RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/RSEFileSubsystemTestSuite.java,v >retrieving revision 1.7 >diff -u -r1.7 RSEFileSubsystemTestSuite.java >--- src/org/eclipse/rse/tests/subsystems/files/RSEFileSubsystemTestSuite.java 15 Feb 2008 16:08:21 -0000 1.7 >+++ src/org/eclipse/rse/tests/subsystems/files/RSEFileSubsystemTestSuite.java 12 Mar 2008 13:50:17 -0000 >@@ -8,6 +8,7 @@ > * Contributors: > * Martin Oberhuber (Wind River) - initial API and implementation > * Martin Oberhuber (Wind River) - organize, enable and tag test cases >+ * Johnson Ma (Wind River) - [195402] Add tar.gz archive support > *******************************************************************************/ > package org.eclipse.rse.tests.subsystems.files; > >@@ -54,6 +55,7 @@ > // we run in problems with that. The test needs to be executed manually with > // the ftp server to use possibly changed to whatever host will do. > suite.addTestSuite(FTPFileSubsystemTestCase.class); >+ suite.addTestSuite(FileServiceTgzArchiveTest.class); > > return suite; > } >Index: src/org/eclipse/rse/tests/subsystems/files/CreateFileTestCase.java >=================================================================== >RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/CreateFileTestCase.java,v >retrieving revision 1.5 >diff -u -r1.5 CreateFileTestCase.java >--- src/org/eclipse/rse/tests/subsystems/files/CreateFileTestCase.java 6 Mar 2008 22:40:01 -0000 1.5 >+++ src/org/eclipse/rse/tests/subsystems/files/CreateFileTestCase.java 12 Mar 2008 13:50:16 -0000 >@@ -11,6 +11,7 @@ > * Contributors: > * Martin Oberhuber (Wind River) - [cleanup] Avoid using SystemStartHere in production code > * Martin Oberhuber (Wind River) - organize, enable and tag test cases >+ * Martin Oberhuber (Wind River) - [195402] Add constructor with test name > ********************************************************************************/ > > package org.eclipse.rse.tests.subsystems.files; >@@ -34,7 +35,15 @@ > // File Dialog. This string can be so using this for base test. > private String fileName = "a !@#${a}'%^&()_ =[]~+-'`;,.txt"; //$NON-NLS-1$ > private IRemoteFile tempDirectory = null; >- >+ >+ /** >+ * Constructor with specific test name. >+ * @param name test to execute >+ */ >+ public CreateFileTestCase(String name) { >+ super(name); >+ } >+ > private IRemoteFileSubSystem getRemoteFileSubSystem(IHost host) { > IRemoteFileSubSystem fss = null; > ISystemRegistry sr = SystemStartHere.getSystemRegistry(); >Index: src/org/eclipse/rse/tests/subsystems/files/FileServiceBaseTest.java >=================================================================== >RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileServiceBaseTest.java,v >retrieving revision 1.7 >diff -u -r1.7 FileServiceBaseTest.java >--- src/org/eclipse/rse/tests/subsystems/files/FileServiceBaseTest.java 29 Nov 2007 16:13:07 -0000 1.7 >+++ src/org/eclipse/rse/tests/subsystems/files/FileServiceBaseTest.java 12 Mar 2008 13:50:17 -0000 >@@ -1,16 +1,17 @@ > /******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >+ * Copyright (c) 2007, 2008 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) - initial API and implementation >+ * Xuan Chen (IBM) - initial API and implementation > * - <copied code from org.eclipse.core.tests.internal.localstore/LocalStoreTest (Copyright IBM)> > * - <copied code from org.eclipse.core.tests.harness/CoreTest (Copyright IBM)> > * - <copied code from org.eclipse.core.tests.resources/ResourceTest (Copyright IBM)> > * - <copied code from org.eclipse.core.tests.harness/CoreTest (Copyright IBM)> >+ * Martin Oberhuber (Wind River) - [195402] Add constructor with test name > *******************************************************************************/ > package org.eclipse.rse.tests.subsystems.files; > >@@ -54,6 +55,14 @@ > > public static int TYPE_FILE = 0; > public static int TYPE_FOLDER = 1; >+ >+ /** >+ * Constructor with specific test name. >+ * @param name test to execute >+ */ >+ public FileServiceBaseTest(String name) { >+ super(name); >+ } > > public void setUp() throws Exception { > super.setUp(); >@@ -261,7 +270,7 @@ > * > * @param target the file to create > * @param content content of the new file >- * @throws CoreException >+ * @throws CoreException in case of failure > */ > protected void createFile(IFileStore target, String content) throws CoreException { > target.delete(EFS.NONE, null); >Index: src/org/eclipse/rse/tests/subsystems/files/FileOutputStreamTestCase.java >=================================================================== >RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileOutputStreamTestCase.java,v >retrieving revision 1.5 >diff -u -r1.5 FileOutputStreamTestCase.java >--- src/org/eclipse/rse/tests/subsystems/files/FileOutputStreamTestCase.java 6 Mar 2008 22:40:01 -0000 1.5 >+++ src/org/eclipse/rse/tests/subsystems/files/FileOutputStreamTestCase.java 12 Mar 2008 13:50:16 -0000 >@@ -11,6 +11,7 @@ > * Contributors: > * Martin Oberhuber (Wind River) - [cleanup] Avoid using SystemStartHere in production code > * Martin Oberhuber (Wind River) - organize, enable and tag test cases >+ * Martin Oberhuber (Wind River) - [195402] Add constructor with test name > ********************************************************************************/ > > package org.eclipse.rse.tests.subsystems.files; >@@ -37,7 +38,15 @@ > > private IHost host = null; > private IRemoteFile tempDirectory; >- >+ >+ /** >+ * Constructor with specific test name. >+ * @param name test to execute >+ */ >+ public FileOutputStreamTestCase(String name) { >+ super(name); >+ } >+ > private IRemoteFileSubSystem getRemoteFileSubSystem(IHost host) { > IRemoteFileSubSystem fss = null; > ISystemRegistry sr = SystemStartHere.getSystemRegistry(); >Index: src/org/eclipse/rse/tests/subsystems/files/FileServiceArchiveTestDStoreWindows.java >=================================================================== >RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileServiceArchiveTestDStoreWindows.java,v >retrieving revision 1.9 >diff -u -r1.9 FileServiceArchiveTestDStoreWindows.java >--- src/org/eclipse/rse/tests/subsystems/files/FileServiceArchiveTestDStoreWindows.java 6 Mar 2008 22:40:01 -0000 1.9 >+++ src/org/eclipse/rse/tests/subsystems/files/FileServiceArchiveTestDStoreWindows.java 12 Mar 2008 13:50:17 -0000 >@@ -6,8 +6,9 @@ > * http://www.eclipse.org/legal/epl-v10.html > * > * Contributors: >- * Xuan Chen (IBM) - initial API and implementation >+ * Xuan Chen (IBM) - initial API and implementation > * Martin Oberhuber (Wind River) - Fix Javadoc warnings >+ * Martin Oberhuber (Wind River) - [195402] Add constructor with test name > *******************************************************************************/ > package org.eclipse.rse.tests.subsystems.files; > >@@ -29,6 +30,14 @@ > private boolean fPreference_ALERT_SSL; > private boolean fPreference_ALERT_NONSSL; > >+ /** >+ * Constructor with specific test name. >+ * @param name test to execute >+ */ >+ public FileServiceArchiveTestDStoreWindows(String name) { >+ super(name); >+ } >+ > public static junit.framework.Test suite() { > > TestSuite suite = new TestSuite("FileServiceArchiveTestDStoreWindows"); >Index: src/org/eclipse/rse/tests/subsystems/files/FileServiceArchiveTest.java >=================================================================== >RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileServiceArchiveTest.java,v >retrieving revision 1.10 >diff -u -r1.10 FileServiceArchiveTest.java >--- src/org/eclipse/rse/tests/subsystems/files/FileServiceArchiveTest.java 13 Feb 2008 20:10:29 -0000 1.10 >+++ src/org/eclipse/rse/tests/subsystems/files/FileServiceArchiveTest.java 12 Mar 2008 13:50:16 -0000 >@@ -6,16 +6,15 @@ > * http://www.eclipse.org/legal/epl-v10.html > * > * Contributors: >- * Xuan Chen (IBM) - initial API and implementation >+ * Xuan Chen (IBM) - initial API and implementation > * Martin Oberhuber (Wind River) - Fix Javadoc warnings > * Martin Oberhuber (Wind River) - organize, enable and tag test cases >+ * Johnson Ma (Wind River) - [195402] Add tar.gz archive support > *******************************************************************************/ > package org.eclipse.rse.tests.subsystems.files; > > 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.ISystemResourceSet; >@@ -27,26 +26,12 @@ > import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; > import org.eclipse.rse.tests.RSETestsPlugin; > >-public class FileServiceArchiveTest extends FileServiceBaseTest { >+public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { > >- protected String folderToCopyName1 = "RemoteSystemsConnections"; >- protected String folderToCopyName2 = "6YLT5Xa"; >- protected String folderToCopyName3 = "folderToCopy"; > > protected String zipSourceFileName1 = "closedBefore.zip"; > protected String zipSourceFileName2 = "mynewzip.zip"; > >- protected String tarSourceFileName1 = "source.tar"; >- protected String tarSourceFileName2 = "mynewtar.tar"; >- >- protected String tarSourceFolderName1 = "META-INF"; >- protected String tarSourceFolderName2 = "org"; >- >- protected String tarSourceForOpenTest = "tarSourceForOpen.tar"; >- protected String tarSourceForOpenFolderName1 = "META-INF"; >- protected String tarSourceForOpenFolderName2 = "org"; >- >- protected String fileContentString1 = "this is just some dummy content \n to a remote file \n to test an open operation"; > protected String ZIP_SOURCE_DIR = ""; > protected String TEST_DIR = ""; > protected String SYSTEM_TYPE_ID = IRSESystemType.SYSTEMTYPE_LOCAL_ID; >@@ -54,70 +39,17 @@ > protected String SYSTEM_NAME = ""; > protected String USER_ID = ""; > protected String PASSWORD = ""; >- >- public static IWorkspace getWorkspace() { >- return ResourcesPlugin.getWorkspace(); >- } >- >- public void createSourceFolders() throws Exception >- { >- 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.uploadResourcesFromWorkspace((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); >+ >+ /** >+ * Constructor with specific test name. >+ * @param name test to execute >+ */ >+ public FileServiceArchiveTest(String name) { >+ super(name); >+ tarSourceFileName1 = "source.tar"; >+ tarSourceFileName2 = "mynewtar.tar"; >+ tarSourceForOpenTest = "tarSourceForOpen.tar"; >+ testName = "dummy.tar"; > } > > public void createSourceZipFiles() throws Exception >@@ -370,221 +302,6 @@ > return targetDir; > } > >- protected void createSuperTransferFolder(IFileStore temp) throws Exception >- { >- >- 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); >- >- return; >- >- } >- >- public void createTarSourceForOpen() throws Exception >- { >- String tempPath = getWorkspace().getRoot().getLocation().append("temp").toString(); >- IFileStore temp = createDir(tempPath, true); >- String content = getRandomString(); >- >- //Now, we need to construct a "source.tar" archive file >- //We will construct the content of the tar file in folders "META-INF" and "org" >- //Then we copy this folder into a tar file by RSE API. >- IFileStore META_INF = temp.getChild(tarSourceForOpenFolderName1); >- createDir(META_INF, true); >- //Now, populate the contents in the folder. >- IFileStore MANIFEST_MF = META_INF.getChild("MANIFEST.MF"); >- content = fileContentString1; >- createFile(MANIFEST_MF, content); >- >- //create folder "org" >- IFileStore org = temp.getChild("org"); >- createDir(org, true); >- IFileStore eclipse = org.getChild("eclipse"); >- createDir(eclipse, true); >- //create "dstore" folder inside "org" >- IFileStore dstore = eclipse.getChild("dstore"); >- createDir(dstore, true); >- //Now, create a few folders inside the dstore folder. >- IFileStore core = dstore.getChild("core"); >- createDir(core, true); >- IFileStore internal = dstore.getChild("internal"); >- createDir(internal, true); >- >- //now create directory inside "core": >- IFileStore client = core.getChild("client"); >- createDir(client, true); >- IFileStore java = core.getChild("java"); >- createDir(java, true); >- IFileStore miners = core.getChild("miners"); >- createDir(miners, true); >- IFileStore model = core.getChild("model"); >- createDir(model, true); >- IFileStore server = core.getChild("server"); >- createDir(server, true); >- IFileStore util = core.getChild("util"); >- createDir(util, true); >- IFileStore Activator_java = core.getChild("Activator.java"); >- content = fileContentString1; >- createFile(Activator_java, content); >- >- //now, some contents on client folder >- IFileStore ClientConnection_java = client.getChild("ClientConnection.java"); >- content = getRandomString(); >- createFile(ClientConnection_java, content); >- IFileStore ConnectionStatus_java = client.getChild("ConnectionStatus.java"); >- content = fileContentString1; >- createFile(ConnectionStatus_java, content); >- >- //now, some contents in java folder >- IFileStore ClassByteStreamHandler$ReceiveClassInstanceThread_java = java.getChild("ClassByteStreamHandler$ReceiveClassInstanceThread.java"); >- content = getRandomString(); >- createFile(ClassByteStreamHandler$ReceiveClassInstanceThread_java, content); >- >- //now, some contents in miners folder >- IFileStore Miner_java = miners.getChild("Miner.java"); >- content = getRandomString(); >- createFile(Miner_java, content); >- IFileStore MinerThread_java = miners.getChild("MinerThread.java"); >- content = getRandomString(); >- createFile(MinerThread_java, content); >- >- //now, some contents in model folder >- IFileStore ByteStreamHandler_java = model.getChild("ByteStreamHandler.java"); >- content = getRandomString(); >- createFile(ByteStreamHandler_java, content); >- IFileStore DE_java = model.getChild("DE.java"); >- content = getRandomString(); >- createFile(DE_java, content); >- IFileStore Handler_java = model.getChild("Handler.java"); >- content = getRandomString(); >- createFile(Handler_java, content); >- >- //now, some contents in server folder >- IFileStore Server_java = server.getChild("Server.java"); >- content = getRandomString(); >- createFile(Server_java, content); >- >- //now, some contents in util folder >- IFileStore StringCompare_java = util.getChild("StringCompare.java"); >- content = fileContentString1; >- createFile(StringCompare_java, content); >- >- //now, create the contents in "internal" folder >- IFileStore core1 = internal.getChild("core"); >- createDir(core1, true); >- >- //then create some folder in this "core" folder >- IFileStore client1 = core1.getChild("client"); >- createDir(client1, true); >- IFileStore model1 = core1.getChild("model"); >- createDir(model1, true); >- IFileStore server1 = core1.getChild("server"); >- createDir(server1, true); >- IFileStore util1 = core1.getChild("util"); >- createDir(util1, true); >- >- //now, some contents on client folder >- IFileStore ClientConnection_java1 = client1.getChild("ClientConnection.java"); >- content = getRandomString(); >- createFile(ClientConnection_java1, content); >- IFileStore ConnectionStatus_java1 = client1.getChild("ConnectionStatus.java"); >- content = getRandomString(); >- createFile(ConnectionStatus_java1, content); >- >- >- //now, some contents in model folder >- IFileStore ByteStreamHandler_java1 = model1.getChild("ByteStreamHandler.java"); >- content = getRandomString(); >- createFile(ByteStreamHandler_java1, content); >- IFileStore DE_java1 = model1.getChild("DE.java"); >- content = getRandomString(); >- createFile(DE_java1, content); >- IFileStore Handler_java1 = model1.getChild("Handler.java"); >- content = getRandomString(); >- createFile(Handler_java1, content); >- >- //now, some contents in server folder >- IFileStore Server_java1 = server1.getChild("Server.java"); >- content = getRandomString(); >- createFile(Server_java1, content); >- >- //now, some contents in util folder >- IFileStore StringCompare_java1 = util1.getChild("StringCompare.java"); >- content = getRandomString(); >- createFile(StringCompare_java1, content); >- >- //now, copy META_INF into the folder in the remote system >- IRemoteFile META_INF_folder = localFss.getRemoteFileObject(tempPath + '\\' + tarSourceForOpenFolderName1, mon); >- assertNotNull(META_INF_folder); >- ISystemDragDropAdapter srcAdapter1 = (ISystemDragDropAdapter) ((IAdaptable) META_INF_folder).getAdapter(ISystemDragDropAdapter.class); >- SystemRemoteResourceSet fromSet = new SystemRemoteResourceSet(localFss, srcAdapter1); >- fromSet.addResource(META_INF_folder); >- ISystemResourceSet tempObjects1 = srcAdapter1.doDrag(fromSet, mon); >- UniversalFileTransferUtility.uploadResourcesFromWorkspace((SystemWorkspaceResourceSet)tempObjects1, tempDir, mon, true); >- >- //now, copy org into the folder in the remote system >- IRemoteFile org_folder = localFss.getRemoteFileObject(tempPath + '\\' + tarSourceForOpenFolderName2, mon); >- assertNotNull(org_folder); >- ISystemDragDropAdapter srcAdapter2 = (ISystemDragDropAdapter) ((IAdaptable) org_folder).getAdapter(ISystemDragDropAdapter.class); >- SystemRemoteResourceSet fromSet2 = new SystemRemoteResourceSet(localFss, srcAdapter2); >- fromSet2.addResource(org_folder); >- ISystemResourceSet tempObjects2 = srcAdapter2.doDrag(fromSet2, mon); >- UniversalFileTransferUtility.uploadResourcesFromWorkspace((SystemWorkspaceResourceSet)tempObjects2, tempDir, mon, true); >- >- //now, create tar file in the host >- IRemoteFile tarSource = createFileOrFolder(tempDir.getAbsolutePath(), tarSourceForOpenTest, false); >- assertNotNull(tarSource); >- IRemoteFile tarSourceFolder1 = (IRemoteFile)getChildFromFolder(tempDir, tarSourceForOpenFolderName1); >- assertNotNull(tarSourceFolder1); >- IRemoteFile tarSourceFolder2 = (IRemoteFile)getChildFromFolder(tempDir, tarSourceForOpenFolderName2); >- fss.copy(tarSourceFolder1, tarSource, tarSourceForOpenFolderName1, mon); >- fss.copy(tarSourceFolder2, tarSource, tarSourceForOpenFolderName2, 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); >- } > > > public void testCreateZipFile() throws Exception { >@@ -1406,249 +1123,8 @@ > checkFolderContents((IRemoteFile)theCopiedChild, childrenToCheck, typesToCheck); > } > >- public void createSourceTarFiles() throws Exception >- { >- String tempPath = getWorkspace().getRoot().getLocation().append("temp").toString(); >- IFileStore temp = createDir(tempPath, true); >- String content = getRandomString(); >- >- //Now, we need to construct a "source.tar" archive file >- //We will construct the content of the tar file in folders "META-INF" and "org" >- //Then we copy this folder into a tar file by RSE API. >- IFileStore META_INF = temp.getChild(tarSourceFolderName1); >- createDir(META_INF, true); >- //Now, populate the contents in the folder. >- IFileStore MANIFEST_MF = META_INF.getChild("MANIFEST.MF"); >- content = getRandomString(); >- createFile(MANIFEST_MF, content); >- //create folder "org" >- IFileStore org = temp.getChild(tarSourceFolderName2); >- createDir(org, true); >- IFileStore eclipse = org.getChild("eclipse"); >- createDir(eclipse, true); >- //create "dstore" folder inside "org" >- IFileStore dstore = eclipse.getChild("dstore"); >- createDir(dstore, true); >- //Now, create a few folders inside the dstore folder. >- IFileStore core = dstore.getChild("core"); >- createDir(core, true); >- IFileStore internal = dstore.getChild("internal"); >- createDir(internal, true); >- >- //now create directory inside "core": >- IFileStore client = core.getChild("client"); >- createDir(client, true); >- IFileStore java = core.getChild("java"); >- createDir(java, true); >- IFileStore miners = core.getChild("miners"); >- createDir(miners, true); >- IFileStore model = core.getChild("model"); >- createDir(model, true); >- IFileStore server = core.getChild("server"); >- createDir(server, true); >- IFileStore util = core.getChild("util"); >- createDir(util, true); >- IFileStore Activator_java = core.getChild("Activator.java"); >- content = getRandomString(); >- createFile(Activator_java, content); >- >- //now, some contents on client folder >- IFileStore ClientConnection_java = client.getChild("ClientConnection.java"); >- content = getRandomString(); >- createFile(ClientConnection_java, content); >- IFileStore ConnectionStatus_java = client.getChild("ConnectionStatus.java"); >- content = getRandomString(); >- createFile(ConnectionStatus_java, content); >- >- //now, some contents in java folder >- IFileStore ClassByteStreamHandler$ReceiveClassInstanceThread_java = java.getChild("ClassByteStreamHandler$ReceiveClassInstanceThread.java"); >- content = getRandomString(); >- createFile(ClassByteStreamHandler$ReceiveClassInstanceThread_java, content); >- >- //now, some contents in miners folder >- IFileStore Miner_java = miners.getChild("Miner.java"); >- content = getRandomString(); >- createFile(Miner_java, content); >- IFileStore MinerThread_java = miners.getChild("MinerThread.java"); >- content = getRandomString(); >- createFile(MinerThread_java, content); >- >- //now, some contents in model folder >- IFileStore ByteStreamHandler_java = model.getChild("ByteStreamHandler.java"); >- content = getRandomString(); >- createFile(ByteStreamHandler_java, content); >- IFileStore DE_java = model.getChild("DE.java"); >- content = getRandomString(); >- createFile(DE_java, content); >- IFileStore Handler_java = model.getChild("Handler.java"); >- content = getRandomString(); >- createFile(Handler_java, content); >- >- //now, some contents in server folder >- IFileStore Server_java = server.getChild("Server.java"); >- content = getRandomString(); >- createFile(Server_java, content); >- >- //now, some contents in util folder >- IFileStore StringCompare_java = util.getChild("StringCompare.java"); >- content = getRandomString(); >- createFile(StringCompare_java, content); >- >- //now, create the contents in "internal" folder >- IFileStore core1 = internal.getChild("core"); >- createDir(core1, true); >- >- //then create some folder in this "core" folder >- IFileStore client1 = core1.getChild("client"); >- createDir(client1, true); >- IFileStore model1 = core1.getChild("model"); >- createDir(model1, true); >- IFileStore server1 = core1.getChild("server"); >- createDir(server1, true); >- IFileStore util1 = core1.getChild("util"); >- createDir(util1, true); >- >- //now, some contents on client folder >- IFileStore ClientConnection_java1 = client1.getChild("ClientConnection.java"); >- content = getRandomString(); >- createFile(ClientConnection_java1, content); >- IFileStore ConnectionStatus_java1 = client1.getChild("ConnectionStatus.java"); >- content = getRandomString(); >- createFile(ConnectionStatus_java1, content); >- >- >- //now, some contents in model folder >- IFileStore ByteStreamHandler_java1 = model1.getChild("ByteStreamHandler.java"); >- content = getRandomString(); >- createFile(ByteStreamHandler_java1, content); >- IFileStore DE_java1 = model1.getChild("DE.java"); >- content = getRandomString(); >- createFile(DE_java1, content); >- IFileStore Handler_java1 = model1.getChild("Handler.java"); >- content = getRandomString(); >- createFile(Handler_java1, content); >- >- //now, some contents in server folder >- IFileStore Server_java1 = server1.getChild("Server.java"); >- content = getRandomString(); >- createFile(Server_java1, content); >- >- //now, some contents in util folder >- IFileStore StringCompare_java1 = util1.getChild("StringCompare.java"); >- content = getRandomString(); >- createFile(StringCompare_java1, content); >- >- //now, copy META_INF into the folder in the remote system >- IRemoteFile META_INF_folder = localFss.getRemoteFileObject(tempPath + '\\' + tarSourceFolderName1, mon); >- assertNotNull(META_INF_folder); >- ISystemDragDropAdapter srcAdapter1 = (ISystemDragDropAdapter) ((IAdaptable) META_INF_folder).getAdapter(ISystemDragDropAdapter.class); >- SystemRemoteResourceSet fromSet = new SystemRemoteResourceSet(localFss, srcAdapter1); >- fromSet.addResource(META_INF_folder); >- ISystemResourceSet tempObjects1 = srcAdapter1.doDrag(fromSet, mon); >- UniversalFileTransferUtility.uploadResourcesFromWorkspace((SystemWorkspaceResourceSet)tempObjects1, tempDir, mon, true); >- >- //now, copy org into the folder in the remote system >- IRemoteFile org_folder = localFss.getRemoteFileObject(tempPath + '\\' + tarSourceFolderName2, mon); >- assertNotNull(org_folder); >- ISystemDragDropAdapter srcAdapter2 = (ISystemDragDropAdapter) ((IAdaptable) org_folder).getAdapter(ISystemDragDropAdapter.class); >- SystemRemoteResourceSet fromSet2 = new SystemRemoteResourceSet(localFss, srcAdapter2); >- fromSet2.addResource(org_folder); >- ISystemResourceSet tempObjects2 = srcAdapter2.doDrag(fromSet2, mon); >- UniversalFileTransferUtility.uploadResourcesFromWorkspace((SystemWorkspaceResourceSet)tempObjects2, tempDir, mon, true); >- >- //now, create tar file in the host >- IRemoteFile tarSource = createFileOrFolder(tempDir.getAbsolutePath(), tarSourceFileName1, false); >- assertNotNull(tarSource); >- IRemoteFile tarSourceFolder1 = (IRemoteFile)getChildFromFolder(tempDir, tarSourceFolderName1); >- assertNotNull(tarSourceFolder1); >- IRemoteFile tarSourceFolder2 = (IRemoteFile)getChildFromFolder(tempDir, tarSourceFolderName2); >- fss.copy(tarSourceFolder1, tarSource, tarSourceFolderName1, mon); >- fss.copy(tarSourceFolder2, tarSource, tarSourceFolderName2, mon); >- } > >- public void testCreateTarFile() throws Exception { >- //-test-author-:XuanChen >- if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ >- >- //Create the zip file first. >- String testName = "dummy.tar"; >- IRemoteFile newArchiveFile = createFileOrFolder(tempDirPath, testName, false); >- assertNotNull(newArchiveFile); >- assertTrue(newArchiveFile.exists()); >- assertTrue(newArchiveFile.canRead()); >- assertTrue(newArchiveFile.canWrite()); >- assertEquals(newArchiveFile.getName(), testName); >- assertEquals(newArchiveFile.getParentPath(), tempDirPath); >- >- //fss.resolveFilterString(filterString, monitor) >- >- //Now, we want to create a text file inside. >- String childName = "aaa.txt"; >- IRemoteFile file1 = createFileOrFolder(newArchiveFile.getAbsolutePath(), childName, false); >- assertNotNull(file1); >- >- childName = "bbb.txt"; >- IRemoteFile file2 = createFileOrFolder(newArchiveFile.getAbsolutePath(), childName, false); >- assertNotNull(file2); >- >- //Create a folder >- childName = "folder1"; >- IRemoteFile folder1 = createFileOrFolder(newArchiveFile.getAbsolutePath(), childName, true); >- assertNotNull(folder1); >- >- //Now, check the contents >- String[] namesToCheck = {"aaa.txt", "bbb.txt", "folder1"}; >- int[] typesToCheck = {TYPE_FILE, TYPE_FILE, TYPE_FOLDER}; >- checkFolderContents(newArchiveFile, namesToCheck, typesToCheck); >- >- //Now, create some files inside the folder. >- String secondLevelChildName = "ccc.exe"; >- IRemoteFile levelTwoChild1 = createFileOrFolder(folder1.getAbsolutePath(), secondLevelChildName, false); >- assertNotNull(levelTwoChild1); >- >- secondLevelChildName = "ddd.bat"; >- IRemoteFile levelTwoChild2 = createFileOrFolder(folder1.getAbsolutePath(), secondLevelChildName, false); >- assertNotNull(levelTwoChild2); >- >- secondLevelChildName = "another Folder"; //folder with space >- IRemoteFile levelTwoChild3 = createFileOrFolder(folder1.getAbsolutePath(), secondLevelChildName, true); >- assertNotNull(levelTwoChild3); >- >- //Now, check the contents >- String[] namesToCheck1 = {"ccc.exe", "ddd.bat", "another Folder"}; >- int[] typesToCheck1 = {TYPE_FILE, TYPE_FILE, TYPE_FOLDER}; >- checkFolderContents(folder1, namesToCheck1, typesToCheck1); >- } > >- public void testCopyToTarArchiveFile() throws Exception { >- //-test-author-:XuanChen >- if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ >- >- //create the source for testing first >- createSourceTarFiles(); >- createSourceFolders(); >- >- String tarTargetFileName = tarSourceFileName1; >- IRemoteFile targetTarFile = (IRemoteFile)getChildFromFolder(tempDir, tarTargetFileName); >- assertNotNull(targetTarFile); >- >- String sourceFolderName = folderToCopyName3; >- IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir, sourceFolderName); >- assertNotNull(sourceFolder); >- >- //Now, copy one of the folder from the sourceFolder into copiedTargetZipFile >- fss.copy(sourceFolder, targetTarFile, sourceFolder.getName(), mon); >- >- Object theCopiedChild = getChildFromFolder(targetTarFile, sourceFolderName); >- >- assertNotNull(theCopiedChild); >- >- //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); >- } > > public void testCopyToTarVirtualFileLevelOne() throws Exception { > //-test-author-:XuanChen >@@ -1721,35 +1197,6 @@ > checkFolderContents((IRemoteFile)theCopiedChild, childrenToCheck, typesToCheck); > } > >- public void testCopyTarVirtualFile() throws Exception { >- //-test-author-:XuanChen >- if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ >- >- //create the source for testing first >- createSourceTarFiles(); >- >- String sourceFileName = tarSourceFileName1; >- IRemoteFile sourceTarFile = (IRemoteFile)getChildFromFolder(tempDir, sourceFileName); >- assertNotNull(sourceTarFile); >- >- //then, create a folder inside the tempDir >- String folderName = "folder1"; >- IRemoteFile folder1 = createFileOrFolder(tempDirPath, folderName, true); >- assertNotNull(folder1); >- >- //Get one of its fourth level children, and copy the folder to there. >- IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(sourceTarFile, tarSourceFolderName1); >- assertNotNull(firstLevelChild); >- >- fss.copy(firstLevelChild, folder1, tarSourceFolderName1, mon); >- >- Object copiedVirtualFolder = getChildFromFolder(folder1, tarSourceFolderName1); >- assertNotNull(copiedVirtualFolder); >- >- String[] contents = {"MANIFEST.MF"}; >- int[] typesToCheck = {TYPE_FILE}; >- checkFolderContents((IRemoteFile)copiedVirtualFolder, contents, typesToCheck); >- } > > public void testCopyTarVirtualFileLevelFour() throws Exception { > //-test-author-:XuanChen >@@ -1799,38 +1246,6 @@ > checkFolderContents((IRemoteFile)copiedVirtualFolder, contents, typesToCheck); > } > >- public void testMoveToTarArchiveFile() throws Exception { >- //-test-author-:XuanChen >- if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ >- >- //create the source for testing first >- createSourceTarFiles(); >- createSourceFolders(); >- >- String tarTargetFileName = tarSourceFileName1; >- IRemoteFile targetTarFile = (IRemoteFile)getChildFromFolder(tempDir, tarTargetFileName); >- assertNotNull(targetTarFile); >- >- String sourceFolderName = folderToCopyName3; >- IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir, sourceFolderName); >- assertNotNull(sourceFolder); >- >- fss.move(sourceFolder, targetTarFile, sourceFolder.getName(), mon); >- >- Object theMovedChild = getChildFromFolder(targetTarFile, sourceFolderName); >- >- assertNotNull(theMovedChild); >- >- //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)theMovedChild, childrenToCheck, typesToCheck); >- >- //make sure the original folder is gone. >- Object originalSource = getChildFromFolder(tempDir, sourceFolderName); >- assertNull(originalSource); >- } > > public void testMoveToTarVirtualFileLevelOne() throws Exception { > //-test-author-:XuanChen >@@ -1912,41 +1327,6 @@ > assertNull(originalSource); > } > >- public void testMoveTarVirtualFile() throws Exception { >- //-test-author-:XuanChen >- if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ >- >- //create the source for testing first >- createSourceTarFiles(); >- >- String sourceFileName = tarSourceFileName1; >- IRemoteFile sourceTarFile = (IRemoteFile)getChildFromFolder(tempDir, sourceFileName); >- assertNotNull(sourceTarFile); >- >- //then, create a folder inside the tempDir >- //then, create a folder inside the tempDir >- String folderName = "folder1"; >- IRemoteFile folder1 = createFileOrFolder(tempDirPath, folderName, true); >- assertNotNull(folder1); >- >- //Now, copy one of the folder from the zip file into folder1 >- String movedFolderName = tarSourceFolderName1; >- IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(sourceTarFile, tarSourceFolderName1); >- assertNotNull(firstLevelChild); >- fss.move(firstLevelChild, folder1, movedFolderName, mon); >- >- Object movedVirtualFolder = getChildFromFolder(folder1, movedFolderName); >- >- assertNotNull(movedVirtualFolder); >- >- String[] contents = {"MANIFEST.MF"}; >- int[] typesToCheck = {TYPE_FILE}; >- checkFolderContents((IRemoteFile)movedVirtualFolder, contents, typesToCheck); >- >- //Now, make sure the moved virtual folder is gone from its original zip file >- IRemoteFile tmp = (IRemoteFile)getChildFromFolder(sourceTarFile, tarSourceFolderName1); >- assertNull(tmp); >- } > > public void testMoveTarVirtualFileLevelFour() throws Exception { > //-test-author-:XuanChen >@@ -1992,201 +1372,6 @@ > assertNull(result); //we should not be able to find it. > } > >- public void testRenameTarVirtualFile() throws Exception { >- //-test-author-:XuanChen >- if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ >- >- //Create the zip file first. >- String testName = "source.tar"; >- IRemoteFile newArchiveFile = createFileOrFolder(tempDirPath, testName, false); >- >- //Now, we want to create a text file inside. >- String childName = "aaa.txt"; >- IRemoteFile file1 = createFileOrFolder(newArchiveFile.getAbsolutePath(), childName, false); >- assertNotNull(file1); >- >- childName = "bbb.txt"; >- IRemoteFile file2 = createFileOrFolder(newArchiveFile.getAbsolutePath(), childName, false); >- assertNotNull(file2); >- >- //Create a folder >- childName = "folder1"; >- IRemoteFile folder1 = createFileOrFolder(newArchiveFile.getAbsolutePath(), childName, true); >- assertNotNull(folder1); >- >- //Now, check the contents >- String[] levelOneNamesToCheck = {"aaa.txt", "bbb.txt", "folder1"}; >- int[] levalOneTypesToCheck = {TYPE_FILE, TYPE_FILE, TYPE_FOLDER}; >- checkFolderContents(newArchiveFile, levelOneNamesToCheck, levalOneTypesToCheck); >- >- //Now, create some files inside the folder. >- String secondLevelChildName = "ccc.exe"; >- IRemoteFile levelTwoChild1 = createFileOrFolder(folder1.getAbsolutePath(), secondLevelChildName, false); >- assertNotNull(levelTwoChild1); >- >- secondLevelChildName = "ddd.bat"; >- IRemoteFile levelTwoChild2 = createFileOrFolder(folder1.getAbsolutePath(), secondLevelChildName, false); >- assertNotNull(levelTwoChild2); >- >- secondLevelChildName = "another Folder"; //folder with space >- IRemoteFile levelTwoChild3 = createFileOrFolder(folder1.getAbsolutePath(), secondLevelChildName, true); >- assertNotNull(levelTwoChild3); >- >- //Now, check the contents >- String[] levelTwoNamesToCheck = {"ccc.exe", "ddd.bat", "another Folder"}; >- int[] levalTwoTypesToCheck = {TYPE_FILE, TYPE_FILE, TYPE_FOLDER}; >- checkFolderContents(folder1, levelTwoNamesToCheck, levalTwoTypesToCheck); >- >- //Now rename one of the text file in the first level: >- IRemoteFile childToRename = (IRemoteFile)getChildFromFolder(newArchiveFile, "aaa.txt"); >- fss.rename(childToRename, "aaa1.txt", mon); >- //Now rename one of the folder in the first level >- childToRename = (IRemoteFile)getChildFromFolder(newArchiveFile, "folder1"); >- fss.rename(childToRename, "folder2", mon); >- >- //Check the result of rename >- String[] newLevelOneNamesToCheck = {"aaa1.txt", "bbb.txt", "folder2"}; >- checkFolderContents(newArchiveFile, newLevelOneNamesToCheck, levalOneTypesToCheck); >- >- //Now rename one of the text file in the second level: >- IRemoteFile thisFolder = (IRemoteFile)getChildFromFolder(newArchiveFile, "folder2"); >- childToRename = (IRemoteFile)getChildFromFolder(thisFolder, "ddd.bat"); >- fss.rename(childToRename, "ddd1.bat", mon); >- //Now rename one of the folder in the second level >- childToRename = (IRemoteFile)getChildFromFolder(thisFolder, "another Folder"); >- fss.rename(childToRename, "some folder$", mon); >- >- //Check the result of rename >- String[] newLevelTwoNamesToCheck = {"ccc.exe", "ddd1.bat", "some folder$"}; >- checkFolderContents(thisFolder, newLevelTwoNamesToCheck, levalTwoTypesToCheck); >- } >- >- public void testDeleteTarVirtualFile() throws Exception { >- //-test-author-:XuanChen >- if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ >- >- //create the source for testing first >- createSourceTarFiles(); >- >- String sourceFileName = tarSourceFileName1; >- IRemoteFile sourceTarFile = (IRemoteFile)getChildFromFolder(tempDir, sourceFileName); >- assertNotNull(sourceTarFile); >- >- //delete a file from level 2 >- String parentForFileToDeleteName ="META-INF"; >- IRemoteFile parentForFileToDelete = (IRemoteFile)getChildFromFolder(sourceTarFile, parentForFileToDeleteName); >- assertNotNull(parentForFileToDelete); >- String deleteFileName = "MANIFEST.MF"; >- IRemoteFile fileToToDelete = (IRemoteFile)getChildFromFolder(parentForFileToDelete, deleteFileName); >- assertNotNull(fileToToDelete); >- //Now, delete this file >- fss.delete(fileToToDelete, mon); >- fileToToDelete = (IRemoteFile)getChildFromFolder(parentForFileToDelete, deleteFileName); >- assertNull(fileToToDelete); >- >- //then, get directory "java" under org/eclipse/dstore/core >- String parentForDirectoryToDeleteName ="org"; >- IRemoteFile parentForDirectoryToDelete = (IRemoteFile)getChildFromFolder(sourceTarFile, parentForDirectoryToDeleteName); >- assertNotNull(parentForDirectoryToDelete); >- >- parentForDirectoryToDeleteName ="eclipse"; >- parentForDirectoryToDelete = (IRemoteFile)getChildFromFolder(parentForDirectoryToDelete, parentForDirectoryToDeleteName); >- assertNotNull(parentForDirectoryToDelete); >- >- parentForDirectoryToDeleteName ="dstore"; >- parentForDirectoryToDelete = (IRemoteFile)getChildFromFolder(parentForDirectoryToDelete, parentForDirectoryToDeleteName); >- assertNotNull(parentForDirectoryToDelete); >- >- parentForDirectoryToDeleteName ="core"; >- parentForDirectoryToDelete = (IRemoteFile)getChildFromFolder(parentForDirectoryToDelete, parentForDirectoryToDeleteName); >- assertNotNull(parentForDirectoryToDelete); >- >- String directoryToDeleteName = "java"; >- IRemoteFile directoryToDelete = (IRemoteFile)getChildFromFolder(parentForDirectoryToDelete, directoryToDeleteName); >- //Now, delete this directory >- fss.delete(directoryToDelete, mon); >- directoryToDelete = (IRemoteFile)getChildFromFolder(parentForDirectoryToDelete, directoryToDeleteName); >- >- //check result of this operation >- String[] contents = {"client", "miners", "model", "server", "util", "Activator.java"}; >- int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FOLDER, TYPE_FOLDER, TYPE_FOLDER, TYPE_FILE}; >- checkFolderContents(parentForDirectoryToDelete, contents, typesToCheck); >- >- //And check this directory is not there any more. >- directoryToDelete = (IRemoteFile)getChildFromFolder(parentForDirectoryToDelete, directoryToDeleteName); >- assertNull(directoryToDelete); >- >- //Now, delete some files and folder inside the a virtual folder. >- parentForFileToDelete = (IRemoteFile)getChildFromFolder(parentForDirectoryToDelete, "model"); >- deleteFileName = "DE.java"; >- fileToToDelete = (IRemoteFile)getChildFromFolder(parentForFileToDelete, deleteFileName); >- assertNotNull(fileToToDelete); >- >- fss.delete(fileToToDelete, mon); >- >- //check the result >- fileToToDelete = (IRemoteFile)getChildFromFolder(parentForFileToDelete, deleteFileName); >- >- assertNull(fileToToDelete); >- } >- >- >- >- public void testCopyBatchToTarArchiveFile() throws Exception { >- //-test-author-:XuanChen >- if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ >- >- createSourceTarFiles(); >- createSourceFolders(); >- >- String tarTargetFileName = tarSourceFileName1; >- IRemoteFile targetTarFile = (IRemoteFile)getChildFromFolder(tempDir, tarTargetFileName); >- assertNotNull(targetTarFile); >- >- //Now, copy the source folder. >- String sourceFolderName = folderToCopyName3; >- IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir,sourceFolderName); >- assertNotNull(sourceFolder); >- >- //Now, copy one of the folder from the sourceFolder into copiedTargetZipFile >- 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, targetTarFile, mon); >- >- //Checking the first copied folder >- Object theCopiedChild = getChildFromFolder(targetTarFile, childToCopyName1); >- >- assertNotNull(theCopiedChild); >- >- //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(targetTarFile, childToCopyName2); >- >- assertNotNull(theCopiedChild); >- >- //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(targetTarFile, childToCopyName3); >- assertNotNull(theCopiedChild); >- assertTrue(((IRemoteFile)theCopiedChild).isDirectory() != true); >- } >- > > > public void testCopyBatchToTarVirtualFileLevelFour() throws Exception { >@@ -2311,70 +1496,5 @@ > Object copiedVirtualFolder3 = getChildFromFolder(folder1, thirdToCopyName); > assertNotNull(copiedVirtualFolder3); > } >- >- >- >- >- >- >- public void testOpenFileFromTarArchive() throws Exception { >- if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ >- >- //create the source for testing first >- createTarSourceForOpen(); >- >- String tarTargetFileName = tarSourceForOpenTest; >- IRemoteFile targetTarFile = (IRemoteFile)getChildFromFolder(tempDir, tarTargetFileName); >- assertNotNull(targetTarFile); >- >- //Now get the contents of the virtual file we want to download: >- String fileContentToVerifyName1 = "MANIFEST.MF"; >- >- //Get its parent first. >- IRemoteFile itsParentFolder = (IRemoteFile)getChildFromFolder(tempDir,tarSourceForOpenFolderName1); >- assertNotNull(itsParentFolder); >- >- //Then get this file: >- IRemoteFile thisVirtualFile = (IRemoteFile)getChildFromFolder(itsParentFolder, fileContentToVerifyName1); >- assertNotNull(thisVirtualFile); >- >- //Now, we want to download the content of this file >- //We could just construct a dummy localpath for it. >- String tempPath = getWorkspace().getRoot().getLocation().append("temp").toString(); >- IFileStore temp = createDir(tempPath, true); >- String localPath = tempPath + "\\" + fileContentToVerifyName1; >- fss.download(thisVirtualFile, localPath, thisVirtualFile.getEncoding(), mon); >- >- //now, verify the content of the local file >- IFileStore localFile = temp.getChild(fileContentToVerifyName1); >- //Check the content of the download file: >- boolean sameContent = compareContent(getContents(fileContentString1), localFile.openInputStream(EFS.NONE, null)); >- assertTrue(sameContent); >- >- >- //now, we got the contents of another virtual file we want to download: >- String fileContentToVerifyName2 = "Activator.java"; >- itsParentFolder = (IRemoteFile)getChildFromFolder(tempDir,tarSourceForOpenFolderName2); >- assertNotNull(itsParentFolder); >- itsParentFolder = (IRemoteFile)getChildFromFolder(itsParentFolder,"eclipse"); >- assertNotNull(itsParentFolder); >- itsParentFolder = (IRemoteFile)getChildFromFolder(itsParentFolder,"dstore"); >- assertNotNull(itsParentFolder); >- itsParentFolder = (IRemoteFile)getChildFromFolder(itsParentFolder,"core"); >- assertNotNull(itsParentFolder); >- thisVirtualFile = (IRemoteFile)getChildFromFolder(itsParentFolder, fileContentToVerifyName2); >- assertNotNull(thisVirtualFile); >- localPath = tempPath + "\\" + fileContentToVerifyName2; >- fss.download(thisVirtualFile, localPath, thisVirtualFile.getEncoding(), mon); >- >- //now, verify the content of the local file >- localFile = temp.getChild(fileContentToVerifyName2); >- //Check the content of the download file: >- sameContent = compareContent(getContents(fileContentString1), localFile.openInputStream(EFS.NONE, null)); >- assertTrue(sameContent); >- } >- >- >- > > } >Index: src/org/eclipse/rse/tests/subsystems/files/FileServiceArchiveTestDStore.java >=================================================================== >RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileServiceArchiveTestDStore.java,v >retrieving revision 1.12 >diff -u -r1.12 FileServiceArchiveTestDStore.java >--- src/org/eclipse/rse/tests/subsystems/files/FileServiceArchiveTestDStore.java 6 Mar 2008 22:40:01 -0000 1.12 >+++ src/org/eclipse/rse/tests/subsystems/files/FileServiceArchiveTestDStore.java 12 Mar 2008 13:50:17 -0000 >@@ -9,6 +9,7 @@ > * Xuan Chen (IBM) - initial API and implementation > * Martin Oberhuber (Wind River) - Fix Javadoc warnings > * Martin Oberhuber (Wind River) - organize, enable and tag test cases >+ * Martin Oberhuber (Wind River) - [195402] Add constructor with test name > *******************************************************************************/ > package org.eclipse.rse.tests.subsystems.files; > >@@ -41,7 +42,15 @@ > > private boolean fPreference_ALERT_SSL; > private boolean fPreference_ALERT_NONSSL; >- >+ >+ /** >+ * Constructor with specific test name. >+ * @param name test to execute >+ */ >+ public FileServiceArchiveTestDStore(String name) { >+ super(name); >+ } >+ > public static junit.framework.Test suite() { > TestSuite suite = new TestSuite("FileServiceArchiveTestDStore"); > >Index: src/org/eclipse/rse/tests/subsystems/files/FileServiceArchiveBaseTest.java >=================================================================== >RCS file: src/org/eclipse/rse/tests/subsystems/files/FileServiceArchiveBaseTest.java >diff -N src/org/eclipse/rse/tests/subsystems/files/FileServiceArchiveBaseTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/rse/tests/subsystems/files/FileServiceArchiveBaseTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,945 @@ >+/******************************************************************************* >+ * Copyright (c) 2007, 2008 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: >+ * Johnson Ma (Wind River) - [195402] Extracted from FileServiceArchiveTest >+ *******************************************************************************/ >+package org.eclipse.rse.tests.subsystems.files; >+ >+import java.io.File; >+ >+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.model.ISystemResourceSet; >+import org.eclipse.rse.core.model.SystemRemoteResourceSet; >+import org.eclipse.rse.core.model.SystemWorkspaceResourceSet; >+import org.eclipse.rse.core.subsystems.ISystemDragDropAdapter; >+import org.eclipse.rse.files.ui.resources.UniversalFileTransferUtility; >+import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; >+import org.eclipse.rse.tests.RSETestsPlugin; >+ >+public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { >+ >+ protected String folderToCopyName1 = "RemoteSystemsConnections"; >+ protected String folderToCopyName2 = "6YLT5Xa"; >+ protected String folderToCopyName3 = "folderToCopy"; >+ >+ protected String tarSourceFileName1; >+ protected String tarSourceFileName2; >+ >+ protected String tarSourceFolderName1 = "META-INF"; >+ protected String tarSourceFolderName2 = "org"; >+ >+ protected String tarSourceForOpenTest; >+ protected String tarSourceForOpenFolderName1 = "META-INF"; >+ protected String tarSourceForOpenFolderName2 = "org"; >+ >+ protected String testName; >+ >+ protected String fileContentString1 = "this is just some dummy content \n to a remote file \n to test an open operation"; >+ >+ /** >+ * Constructor with specific test name. >+ * @param name test to execute >+ */ >+ public FileServiceArchiveBaseTest(String name) { >+ super(name); >+ } >+ >+ public static IWorkspace getWorkspace() { >+ return ResourcesPlugin.getWorkspace(); >+ } >+ >+ public void createSourceFolders() throws Exception >+ { >+ 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.uploadResourcesFromWorkspace((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); >+ } >+ >+ >+ protected void createSuperTransferFolder(IFileStore temp) throws Exception >+ { >+ >+ 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); >+ >+ return; >+ >+ } >+ >+ public void createTarSourceForOpen() throws Exception >+ { >+ String tempPath = getWorkspace().getRoot().getLocation().append("temp").toString(); >+ IFileStore temp = createDir(tempPath, true); >+ String content = getRandomString(); >+ >+ //Now, we need to construct a "source.tar" archive file >+ //We will construct the content of the tar file in folders "META-INF" and "org" >+ //Then we copy this folder into a tar file by RSE API. >+ IFileStore META_INF = temp.getChild(tarSourceForOpenFolderName1); >+ createDir(META_INF, true); >+ //Now, populate the contents in the folder. >+ IFileStore MANIFEST_MF = META_INF.getChild("MANIFEST.MF"); >+ content = fileContentString1; >+ createFile(MANIFEST_MF, content); >+ >+ //create folder "org" >+ IFileStore org = temp.getChild("org"); >+ createDir(org, true); >+ IFileStore eclipse = org.getChild("eclipse"); >+ createDir(eclipse, true); >+ //create "dstore" folder inside "org" >+ IFileStore dstore = eclipse.getChild("dstore"); >+ createDir(dstore, true); >+ //Now, create a few folders inside the dstore folder. >+ IFileStore core = dstore.getChild("core"); >+ createDir(core, true); >+ IFileStore internal = dstore.getChild("internal"); >+ createDir(internal, true); >+ >+ //now create directory inside "core": >+ IFileStore client = core.getChild("client"); >+ createDir(client, true); >+ IFileStore java = core.getChild("java"); >+ createDir(java, true); >+ IFileStore miners = core.getChild("miners"); >+ createDir(miners, true); >+ IFileStore model = core.getChild("model"); >+ createDir(model, true); >+ IFileStore server = core.getChild("server"); >+ createDir(server, true); >+ IFileStore util = core.getChild("util"); >+ createDir(util, true); >+ IFileStore Activator_java = core.getChild("Activator.java"); >+ content = fileContentString1; >+ createFile(Activator_java, content); >+ >+ //now, some contents on client folder >+ IFileStore ClientConnection_java = client.getChild("ClientConnection.java"); >+ content = getRandomString(); >+ createFile(ClientConnection_java, content); >+ IFileStore ConnectionStatus_java = client.getChild("ConnectionStatus.java"); >+ content = fileContentString1; >+ createFile(ConnectionStatus_java, content); >+ >+ //now, some contents in java folder >+ IFileStore ClassByteStreamHandler$ReceiveClassInstanceThread_java = java.getChild("ClassByteStreamHandler$ReceiveClassInstanceThread.java"); >+ content = getRandomString(); >+ createFile(ClassByteStreamHandler$ReceiveClassInstanceThread_java, content); >+ >+ //now, some contents in miners folder >+ IFileStore Miner_java = miners.getChild("Miner.java"); >+ content = getRandomString(); >+ createFile(Miner_java, content); >+ IFileStore MinerThread_java = miners.getChild("MinerThread.java"); >+ content = getRandomString(); >+ createFile(MinerThread_java, content); >+ >+ //now, some contents in model folder >+ IFileStore ByteStreamHandler_java = model.getChild("ByteStreamHandler.java"); >+ content = getRandomString(); >+ createFile(ByteStreamHandler_java, content); >+ IFileStore DE_java = model.getChild("DE.java"); >+ content = getRandomString(); >+ createFile(DE_java, content); >+ IFileStore Handler_java = model.getChild("Handler.java"); >+ content = getRandomString(); >+ createFile(Handler_java, content); >+ >+ //now, some contents in server folder >+ IFileStore Server_java = server.getChild("Server.java"); >+ content = getRandomString(); >+ createFile(Server_java, content); >+ >+ //now, some contents in util folder >+ IFileStore StringCompare_java = util.getChild("StringCompare.java"); >+ content = fileContentString1; >+ createFile(StringCompare_java, content); >+ >+ //now, create the contents in "internal" folder >+ IFileStore core1 = internal.getChild("core"); >+ createDir(core1, true); >+ >+ //then create some folder in this "core" folder >+ IFileStore client1 = core1.getChild("client"); >+ createDir(client1, true); >+ IFileStore model1 = core1.getChild("model"); >+ createDir(model1, true); >+ IFileStore server1 = core1.getChild("server"); >+ createDir(server1, true); >+ IFileStore util1 = core1.getChild("util"); >+ createDir(util1, true); >+ >+ //now, some contents on client folder >+ IFileStore ClientConnection_java1 = client1.getChild("ClientConnection.java"); >+ content = getRandomString(); >+ createFile(ClientConnection_java1, content); >+ IFileStore ConnectionStatus_java1 = client1.getChild("ConnectionStatus.java"); >+ content = getRandomString(); >+ createFile(ConnectionStatus_java1, content); >+ >+ >+ //now, some contents in model folder >+ IFileStore ByteStreamHandler_java1 = model1.getChild("ByteStreamHandler.java"); >+ content = getRandomString(); >+ createFile(ByteStreamHandler_java1, content); >+ IFileStore DE_java1 = model1.getChild("DE.java"); >+ content = getRandomString(); >+ createFile(DE_java1, content); >+ IFileStore Handler_java1 = model1.getChild("Handler.java"); >+ content = getRandomString(); >+ createFile(Handler_java1, content); >+ >+ //now, some contents in server folder >+ IFileStore Server_java1 = server1.getChild("Server.java"); >+ content = getRandomString(); >+ createFile(Server_java1, content); >+ >+ //now, some contents in util folder >+ IFileStore StringCompare_java1 = util1.getChild("StringCompare.java"); >+ content = getRandomString(); >+ createFile(StringCompare_java1, content); >+ >+ //now, copy META_INF into the folder in the remote system >+ IRemoteFile META_INF_folder = localFss.getRemoteFileObject(tempPath + '\\' + tarSourceForOpenFolderName1, mon); >+ assertNotNull(META_INF_folder); >+ ISystemDragDropAdapter srcAdapter1 = (ISystemDragDropAdapter) ((IAdaptable) META_INF_folder).getAdapter(ISystemDragDropAdapter.class); >+ SystemRemoteResourceSet fromSet = new SystemRemoteResourceSet(localFss, srcAdapter1); >+ fromSet.addResource(META_INF_folder); >+ ISystemResourceSet tempObjects1 = srcAdapter1.doDrag(fromSet, mon); >+ UniversalFileTransferUtility.uploadResourcesFromWorkspace((SystemWorkspaceResourceSet)tempObjects1, tempDir, mon, true); >+ >+ //now, copy org into the folder in the remote system >+ IRemoteFile org_folder = localFss.getRemoteFileObject(tempPath + '\\' + tarSourceForOpenFolderName2, mon); >+ assertNotNull(org_folder); >+ ISystemDragDropAdapter srcAdapter2 = (ISystemDragDropAdapter) ((IAdaptable) org_folder).getAdapter(ISystemDragDropAdapter.class); >+ SystemRemoteResourceSet fromSet2 = new SystemRemoteResourceSet(localFss, srcAdapter2); >+ fromSet2.addResource(org_folder); >+ ISystemResourceSet tempObjects2 = srcAdapter2.doDrag(fromSet2, mon); >+ UniversalFileTransferUtility.uploadResourcesFromWorkspace((SystemWorkspaceResourceSet)tempObjects2, tempDir, mon, true); >+ >+ //now, create tar file in the host >+ IRemoteFile tarSource = createFileOrFolder(tempDir.getAbsolutePath(), tarSourceForOpenTest, false); >+ assertNotNull(tarSource); >+ IRemoteFile tarSourceFolder1 = (IRemoteFile)getChildFromFolder(tempDir, tarSourceForOpenFolderName1); >+ assertNotNull(tarSourceFolder1); >+ IRemoteFile tarSourceFolder2 = (IRemoteFile)getChildFromFolder(tempDir, tarSourceForOpenFolderName2); >+ fss.copy(tarSourceFolder1, tarSource, tarSourceForOpenFolderName1, mon); >+ fss.copy(tarSourceFolder2, tarSource, tarSourceForOpenFolderName2, 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); >+ } >+ >+ >+ >+ public void createSourceTarFiles() throws Exception >+ { >+ String tempPath = getWorkspace().getRoot().getLocation().append("temp").toString(); >+ IFileStore temp = createDir(tempPath, true); >+ String content = getRandomString(); >+ >+ //Now, we need to construct a "source.tar" archive file >+ //We will construct the content of the tar file in folders "META-INF" and "org" >+ //Then we copy this folder into a tar file by RSE API. >+ IFileStore META_INF = temp.getChild(tarSourceFolderName1); >+ createDir(META_INF, true); >+ //Now, populate the contents in the folder. >+ IFileStore MANIFEST_MF = META_INF.getChild("MANIFEST.MF"); >+ content = getRandomString(); >+ createFile(MANIFEST_MF, content); >+ //create folder "org" >+ IFileStore org = temp.getChild(tarSourceFolderName2); >+ createDir(org, true); >+ IFileStore eclipse = org.getChild("eclipse"); >+ createDir(eclipse, true); >+ //create "dstore" folder inside "org" >+ IFileStore dstore = eclipse.getChild("dstore"); >+ createDir(dstore, true); >+ //Now, create a few folders inside the dstore folder. >+ IFileStore core = dstore.getChild("core"); >+ createDir(core, true); >+ IFileStore internal = dstore.getChild("internal"); >+ createDir(internal, true); >+ >+ //now create directory inside "core": >+ IFileStore client = core.getChild("client"); >+ createDir(client, true); >+ IFileStore java = core.getChild("java"); >+ createDir(java, true); >+ IFileStore miners = core.getChild("miners"); >+ createDir(miners, true); >+ IFileStore model = core.getChild("model"); >+ createDir(model, true); >+ IFileStore server = core.getChild("server"); >+ createDir(server, true); >+ IFileStore util = core.getChild("util"); >+ createDir(util, true); >+ IFileStore Activator_java = core.getChild("Activator.java"); >+ content = getRandomString(); >+ createFile(Activator_java, content); >+ >+ //now, some contents on client folder >+ IFileStore ClientConnection_java = client.getChild("ClientConnection.java"); >+ content = getRandomString(); >+ createFile(ClientConnection_java, content); >+ IFileStore ConnectionStatus_java = client.getChild("ConnectionStatus.java"); >+ content = getRandomString(); >+ createFile(ConnectionStatus_java, content); >+ >+ //now, some contents in java folder >+ IFileStore ClassByteStreamHandler$ReceiveClassInstanceThread_java = java.getChild("ClassByteStreamHandler$ReceiveClassInstanceThread.java"); >+ content = getRandomString(); >+ createFile(ClassByteStreamHandler$ReceiveClassInstanceThread_java, content); >+ >+ //now, some contents in miners folder >+ IFileStore Miner_java = miners.getChild("Miner.java"); >+ content = getRandomString(); >+ createFile(Miner_java, content); >+ IFileStore MinerThread_java = miners.getChild("MinerThread.java"); >+ content = getRandomString(); >+ createFile(MinerThread_java, content); >+ >+ //now, some contents in model folder >+ IFileStore ByteStreamHandler_java = model.getChild("ByteStreamHandler.java"); >+ content = getRandomString(); >+ createFile(ByteStreamHandler_java, content); >+ IFileStore DE_java = model.getChild("DE.java"); >+ content = getRandomString(); >+ createFile(DE_java, content); >+ IFileStore Handler_java = model.getChild("Handler.java"); >+ content = getRandomString(); >+ createFile(Handler_java, content); >+ >+ //now, some contents in server folder >+ IFileStore Server_java = server.getChild("Server.java"); >+ content = getRandomString(); >+ createFile(Server_java, content); >+ >+ //now, some contents in util folder >+ IFileStore StringCompare_java = util.getChild("StringCompare.java"); >+ content = getRandomString(); >+ createFile(StringCompare_java, content); >+ >+ //now, create the contents in "internal" folder >+ IFileStore core1 = internal.getChild("core"); >+ createDir(core1, true); >+ >+ //then create some folder in this "core" folder >+ IFileStore client1 = core1.getChild("client"); >+ createDir(client1, true); >+ IFileStore model1 = core1.getChild("model"); >+ createDir(model1, true); >+ IFileStore server1 = core1.getChild("server"); >+ createDir(server1, true); >+ IFileStore util1 = core1.getChild("util"); >+ createDir(util1, true); >+ >+ //now, some contents on client folder >+ IFileStore ClientConnection_java1 = client1.getChild("ClientConnection.java"); >+ content = getRandomString(); >+ createFile(ClientConnection_java1, content); >+ IFileStore ConnectionStatus_java1 = client1.getChild("ConnectionStatus.java"); >+ content = getRandomString(); >+ createFile(ConnectionStatus_java1, content); >+ >+ >+ //now, some contents in model folder >+ IFileStore ByteStreamHandler_java1 = model1.getChild("ByteStreamHandler.java"); >+ content = getRandomString(); >+ createFile(ByteStreamHandler_java1, content); >+ IFileStore DE_java1 = model1.getChild("DE.java"); >+ content = getRandomString(); >+ createFile(DE_java1, content); >+ IFileStore Handler_java1 = model1.getChild("Handler.java"); >+ content = getRandomString(); >+ createFile(Handler_java1, content); >+ >+ //now, some contents in server folder >+ IFileStore Server_java1 = server1.getChild("Server.java"); >+ content = getRandomString(); >+ createFile(Server_java1, content); >+ >+ //now, some contents in util folder >+ IFileStore StringCompare_java1 = util1.getChild("StringCompare.java"); >+ content = getRandomString(); >+ createFile(StringCompare_java1, content); >+ >+ //now, copy META_INF into the folder in the remote system >+ IRemoteFile META_INF_folder = localFss.getRemoteFileObject(tempPath + '\\' + tarSourceFolderName1, mon); >+ assertNotNull(META_INF_folder); >+ ISystemDragDropAdapter srcAdapter1 = (ISystemDragDropAdapter) ((IAdaptable) META_INF_folder).getAdapter(ISystemDragDropAdapter.class); >+ SystemRemoteResourceSet fromSet = new SystemRemoteResourceSet(localFss, srcAdapter1); >+ fromSet.addResource(META_INF_folder); >+ ISystemResourceSet tempObjects1 = srcAdapter1.doDrag(fromSet, mon); >+ UniversalFileTransferUtility.uploadResourcesFromWorkspace((SystemWorkspaceResourceSet)tempObjects1, tempDir, mon, true); >+ >+ //now, copy org into the folder in the remote system >+ IRemoteFile org_folder = localFss.getRemoteFileObject(tempPath + '\\' + tarSourceFolderName2, mon); >+ assertNotNull(org_folder); >+ ISystemDragDropAdapter srcAdapter2 = (ISystemDragDropAdapter) ((IAdaptable) org_folder).getAdapter(ISystemDragDropAdapter.class); >+ SystemRemoteResourceSet fromSet2 = new SystemRemoteResourceSet(localFss, srcAdapter2); >+ fromSet2.addResource(org_folder); >+ ISystemResourceSet tempObjects2 = srcAdapter2.doDrag(fromSet2, mon); >+ UniversalFileTransferUtility.uploadResourcesFromWorkspace((SystemWorkspaceResourceSet)tempObjects2, tempDir, mon, true); >+ >+ //now, create tar file in the host >+ IRemoteFile tarSource = createFileOrFolder(tempDir.getAbsolutePath(), tarSourceFileName1, false); >+ assertNotNull(tarSource); >+ IRemoteFile tarSourceFolder1 = (IRemoteFile)getChildFromFolder(tempDir, tarSourceFolderName1); >+ assertNotNull(tarSourceFolder1); >+ IRemoteFile tarSourceFolder2 = (IRemoteFile)getChildFromFolder(tempDir, tarSourceFolderName2); >+ fss.copy(tarSourceFolder1, tarSource, tarSourceFolderName1, mon); >+ fss.copy(tarSourceFolder2, tarSource, tarSourceFolderName2, mon); >+ } >+ >+ public void testCreateTarFile() throws Exception { >+ //-test-author-:XuanChen >+ if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ >+ >+ //Create the zip file first. >+ IRemoteFile newArchiveFile = createFileOrFolder(tempDirPath, testName, false); >+ assertNotNull(newArchiveFile); >+ assertTrue(newArchiveFile.exists()); >+ assertTrue(newArchiveFile.canRead()); >+ assertTrue(newArchiveFile.canWrite()); >+ assertEquals(newArchiveFile.getName(), testName); >+ assertEquals(newArchiveFile.getParentPath(), tempDirPath); >+ >+ //fss.resolveFilterString(filterString, monitor) >+ >+ //Now, we want to create a text file inside. >+ String childName = "aaa.txt"; >+ IRemoteFile file1 = createFileOrFolder(newArchiveFile.getAbsolutePath(), childName, false); >+ assertNotNull(file1); >+ >+ childName = "bbb.txt"; >+ IRemoteFile file2 = createFileOrFolder(newArchiveFile.getAbsolutePath(), childName, false); >+ assertNotNull(file2); >+ >+ //Create a folder >+ childName = "folder1"; >+ IRemoteFile folder1 = createFileOrFolder(newArchiveFile.getAbsolutePath(), childName, true); >+ assertNotNull(folder1); >+ >+ //Now, check the contents >+ String[] namesToCheck = {"aaa.txt", "bbb.txt", "folder1"}; >+ int[] typesToCheck = {TYPE_FILE, TYPE_FILE, TYPE_FOLDER}; >+ checkFolderContents(newArchiveFile, namesToCheck, typesToCheck); >+ >+ //Now, create some files inside the folder. >+ String secondLevelChildName = "ccc.exe"; >+ IRemoteFile levelTwoChild1 = createFileOrFolder(folder1.getAbsolutePath(), secondLevelChildName, false); >+ assertNotNull(levelTwoChild1); >+ >+ secondLevelChildName = "ddd.bat"; >+ IRemoteFile levelTwoChild2 = createFileOrFolder(folder1.getAbsolutePath(), secondLevelChildName, false); >+ assertNotNull(levelTwoChild2); >+ >+ secondLevelChildName = "another Folder"; //folder with space >+ IRemoteFile levelTwoChild3 = createFileOrFolder(folder1.getAbsolutePath(), secondLevelChildName, true); >+ assertNotNull(levelTwoChild3); >+ >+ //Now, check the contents >+ String[] namesToCheck1 = {"ccc.exe", "ddd.bat", "another Folder"}; >+ int[] typesToCheck1 = {TYPE_FILE, TYPE_FILE, TYPE_FOLDER}; >+ checkFolderContents(folder1, namesToCheck1, typesToCheck1); >+ } >+ >+ public void testCopyToTarArchiveFile() throws Exception { >+ //-test-author-:XuanChen >+ if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ >+ >+ //create the source for testing first >+ createSourceTarFiles(); >+ createSourceFolders(); >+ >+ String tarTargetFileName = tarSourceFileName1; >+ IRemoteFile targetTarFile = (IRemoteFile)getChildFromFolder(tempDir, tarTargetFileName); >+ assertNotNull(targetTarFile); >+ >+ String sourceFolderName = folderToCopyName3; >+ IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir, sourceFolderName); >+ assertNotNull(sourceFolder); >+ >+ //Now, copy one of the folder from the sourceFolder into copiedTargetZipFile >+ fss.copy(sourceFolder, targetTarFile, sourceFolder.getName(), mon); >+ >+ Object theCopiedChild = getChildFromFolder(targetTarFile, sourceFolderName); >+ >+ assertNotNull(theCopiedChild); >+ >+ //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); >+ } >+ >+ >+ >+ public void testCopyTarVirtualFile() throws Exception { >+ //-test-author-:XuanChen >+ if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ >+ >+ //create the source for testing first >+ createSourceTarFiles(); >+ >+ String sourceFileName = tarSourceFileName1; >+ IRemoteFile sourceTarFile = (IRemoteFile)getChildFromFolder(tempDir, sourceFileName); >+ assertNotNull(sourceTarFile); >+ >+ //then, create a folder inside the tempDir >+ String folderName = "folder1"; >+ IRemoteFile folder1 = createFileOrFolder(tempDirPath, folderName, true); >+ assertNotNull(folder1); >+ >+ //Get one of its fourth level children, and copy the folder to there. >+ IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(sourceTarFile, tarSourceFolderName1); >+ assertNotNull(firstLevelChild); >+ >+ fss.copy(firstLevelChild, folder1, tarSourceFolderName1, mon); >+ >+ Object copiedVirtualFolder = getChildFromFolder(folder1, tarSourceFolderName1); >+ assertNotNull(copiedVirtualFolder); >+ >+ String[] contents = {"MANIFEST.MF"}; >+ int[] typesToCheck = {TYPE_FILE}; >+ checkFolderContents((IRemoteFile)copiedVirtualFolder, contents, typesToCheck); >+ } >+ >+ >+ public void testMoveToTarArchiveFile() throws Exception { >+ //-test-author-:XuanChen >+ if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ >+ >+ //create the source for testing first >+ createSourceTarFiles(); >+ createSourceFolders(); >+ >+ String tarTargetFileName = tarSourceFileName1; >+ IRemoteFile targetTarFile = (IRemoteFile)getChildFromFolder(tempDir, tarTargetFileName); >+ assertNotNull(targetTarFile); >+ >+ String sourceFolderName = folderToCopyName3; >+ IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir, sourceFolderName); >+ assertNotNull(sourceFolder); >+ >+ fss.move(sourceFolder, targetTarFile, sourceFolder.getName(), mon); >+ >+ Object theMovedChild = getChildFromFolder(targetTarFile, sourceFolderName); >+ >+ assertNotNull(theMovedChild); >+ >+ //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)theMovedChild, childrenToCheck, typesToCheck); >+ >+ //make sure the original folder is gone. >+ Object originalSource = getChildFromFolder(tempDir, sourceFolderName); >+ assertNull(originalSource); >+ } >+ >+ >+ >+ public void testMoveTarVirtualFile() throws Exception { >+ //-test-author-:XuanChen >+ if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ >+ >+ //create the source for testing first >+ createSourceTarFiles(); >+ >+ String sourceFileName = tarSourceFileName1; >+ IRemoteFile sourceTarFile = (IRemoteFile)getChildFromFolder(tempDir, sourceFileName); >+ assertNotNull(sourceTarFile); >+ >+ //then, create a folder inside the tempDir >+ //then, create a folder inside the tempDir >+ String folderName = "folder1"; >+ IRemoteFile folder1 = createFileOrFolder(tempDirPath, folderName, true); >+ assertNotNull(folder1); >+ >+ //Now, copy one of the folder from the zip file into folder1 >+ String movedFolderName = tarSourceFolderName1; >+ IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(sourceTarFile, tarSourceFolderName1); >+ assertNotNull(firstLevelChild); >+ fss.move(firstLevelChild, folder1, movedFolderName, mon); >+ >+ Object movedVirtualFolder = getChildFromFolder(folder1, movedFolderName); >+ >+ assertNotNull(movedVirtualFolder); >+ >+ String[] contents = {"MANIFEST.MF"}; >+ int[] typesToCheck = {TYPE_FILE}; >+ checkFolderContents((IRemoteFile)movedVirtualFolder, contents, typesToCheck); >+ >+ //Now, make sure the moved virtual folder is gone from its original zip file >+ IRemoteFile tmp = (IRemoteFile)getChildFromFolder(sourceTarFile, tarSourceFolderName1); >+ assertNull(tmp); >+ } >+ >+ >+ public void testRenameTarVirtualFile() throws Exception { >+ //-test-author-:XuanChen >+ if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ >+ >+ //Create the zip file first. >+ IRemoteFile newArchiveFile = createFileOrFolder(tempDirPath, testName, false); >+ >+ //Now, we want to create a text file inside. >+ String childName = "aaa.txt"; >+ IRemoteFile file1 = createFileOrFolder(newArchiveFile.getAbsolutePath(), childName, false); >+ assertNotNull(file1); >+ >+ childName = "bbb.txt"; >+ IRemoteFile file2 = createFileOrFolder(newArchiveFile.getAbsolutePath(), childName, false); >+ assertNotNull(file2); >+ >+ //Create a folder >+ childName = "folder1"; >+ IRemoteFile folder1 = createFileOrFolder(newArchiveFile.getAbsolutePath(), childName, true); >+ assertNotNull(folder1); >+ >+ //Now, check the contents >+ String[] levelOneNamesToCheck = {"aaa.txt", "bbb.txt", "folder1"}; >+ int[] levalOneTypesToCheck = {TYPE_FILE, TYPE_FILE, TYPE_FOLDER}; >+ checkFolderContents(newArchiveFile, levelOneNamesToCheck, levalOneTypesToCheck); >+ >+ //Now, create some files inside the folder. >+ String secondLevelChildName = "ccc.exe"; >+ IRemoteFile levelTwoChild1 = createFileOrFolder(folder1.getAbsolutePath(), secondLevelChildName, false); >+ assertNotNull(levelTwoChild1); >+ >+ secondLevelChildName = "ddd.bat"; >+ IRemoteFile levelTwoChild2 = createFileOrFolder(folder1.getAbsolutePath(), secondLevelChildName, false); >+ assertNotNull(levelTwoChild2); >+ >+ secondLevelChildName = "another Folder"; //folder with space >+ IRemoteFile levelTwoChild3 = createFileOrFolder(folder1.getAbsolutePath(), secondLevelChildName, true); >+ assertNotNull(levelTwoChild3); >+ >+ //Now, check the contents >+ String[] levelTwoNamesToCheck = {"ccc.exe", "ddd.bat", "another Folder"}; >+ int[] levalTwoTypesToCheck = {TYPE_FILE, TYPE_FILE, TYPE_FOLDER}; >+ checkFolderContents(folder1, levelTwoNamesToCheck, levalTwoTypesToCheck); >+ >+ //Now rename one of the text file in the first level: >+ IRemoteFile childToRename = (IRemoteFile)getChildFromFolder(newArchiveFile, "aaa.txt"); >+ fss.rename(childToRename, "aaa1.txt", mon); >+ //Now rename one of the folder in the first level >+ childToRename = (IRemoteFile)getChildFromFolder(newArchiveFile, "folder1"); >+ fss.rename(childToRename, "folder2", mon); >+ >+ //Check the result of rename >+ String[] newLevelOneNamesToCheck = {"aaa1.txt", "bbb.txt", "folder2"}; >+ checkFolderContents(newArchiveFile, newLevelOneNamesToCheck, levalOneTypesToCheck); >+ >+ //Now rename one of the text file in the second level: >+ IRemoteFile thisFolder = (IRemoteFile)getChildFromFolder(newArchiveFile, "folder2"); >+ childToRename = (IRemoteFile)getChildFromFolder(thisFolder, "ddd.bat"); >+ fss.rename(childToRename, "ddd1.bat", mon); >+ //Now rename one of the folder in the second level >+ childToRename = (IRemoteFile)getChildFromFolder(thisFolder, "another Folder"); >+ fss.rename(childToRename, "some folder$", mon); >+ >+ //Check the result of rename >+ String[] newLevelTwoNamesToCheck = {"ccc.exe", "ddd1.bat", "some folder$"}; >+ checkFolderContents(thisFolder, newLevelTwoNamesToCheck, levalTwoTypesToCheck); >+ } >+ >+ public void testDeleteTarVirtualFile() throws Exception { >+ //-test-author-:XuanChen >+ if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ >+ >+ //create the source for testing first >+ createSourceTarFiles(); >+ >+ String sourceFileName = tarSourceFileName1; >+ IRemoteFile sourceTarFile = (IRemoteFile)getChildFromFolder(tempDir, sourceFileName); >+ assertNotNull(sourceTarFile); >+ >+ //delete a file from level 2 >+ String parentForFileToDeleteName ="META-INF"; >+ IRemoteFile parentForFileToDelete = (IRemoteFile)getChildFromFolder(sourceTarFile, parentForFileToDeleteName); >+ assertNotNull(parentForFileToDelete); >+ String deleteFileName = "MANIFEST.MF"; >+ IRemoteFile fileToToDelete = (IRemoteFile)getChildFromFolder(parentForFileToDelete, deleteFileName); >+ assertNotNull(fileToToDelete); >+ //Now, delete this file >+ fss.delete(fileToToDelete, mon); >+ fileToToDelete = (IRemoteFile)getChildFromFolder(parentForFileToDelete, deleteFileName); >+ assertNull(fileToToDelete); >+ >+ //then, get directory "java" under org/eclipse/dstore/core >+ String parentForDirectoryToDeleteName ="org"; >+ IRemoteFile parentForDirectoryToDelete = (IRemoteFile)getChildFromFolder(sourceTarFile, parentForDirectoryToDeleteName); >+ assertNotNull(parentForDirectoryToDelete); >+ >+ parentForDirectoryToDeleteName ="eclipse"; >+ parentForDirectoryToDelete = (IRemoteFile)getChildFromFolder(parentForDirectoryToDelete, parentForDirectoryToDeleteName); >+ assertNotNull(parentForDirectoryToDelete); >+ >+ parentForDirectoryToDeleteName ="dstore"; >+ parentForDirectoryToDelete = (IRemoteFile)getChildFromFolder(parentForDirectoryToDelete, parentForDirectoryToDeleteName); >+ assertNotNull(parentForDirectoryToDelete); >+ >+ parentForDirectoryToDeleteName ="core"; >+ parentForDirectoryToDelete = (IRemoteFile)getChildFromFolder(parentForDirectoryToDelete, parentForDirectoryToDeleteName); >+ assertNotNull(parentForDirectoryToDelete); >+ >+ String directoryToDeleteName = "java"; >+ IRemoteFile directoryToDelete = (IRemoteFile)getChildFromFolder(parentForDirectoryToDelete, directoryToDeleteName); >+ //Now, delete this directory >+ fss.delete(directoryToDelete, mon); >+ directoryToDelete = (IRemoteFile)getChildFromFolder(parentForDirectoryToDelete, directoryToDeleteName); >+ >+ //check result of this operation >+ String[] contents = {"client", "miners", "model", "server", "util", "Activator.java"}; >+ int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FOLDER, TYPE_FOLDER, TYPE_FOLDER, TYPE_FILE}; >+ checkFolderContents(parentForDirectoryToDelete, contents, typesToCheck); >+ >+ //And check this directory is not there any more. >+ directoryToDelete = (IRemoteFile)getChildFromFolder(parentForDirectoryToDelete, directoryToDeleteName); >+ assertNull(directoryToDelete); >+ >+ //Now, delete some files and folder inside the a virtual folder. >+ parentForFileToDelete = (IRemoteFile)getChildFromFolder(parentForDirectoryToDelete, "model"); >+ deleteFileName = "DE.java"; >+ fileToToDelete = (IRemoteFile)getChildFromFolder(parentForFileToDelete, deleteFileName); >+ assertNotNull(fileToToDelete); >+ >+ fss.delete(fileToToDelete, mon); >+ >+ //check the result >+ fileToToDelete = (IRemoteFile)getChildFromFolder(parentForFileToDelete, deleteFileName); >+ >+ assertNull(fileToToDelete); >+ } >+ >+ >+ >+ public void testCopyBatchToTarArchiveFile() throws Exception { >+ //-test-author-:XuanChen >+ if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ >+ >+ createSourceTarFiles(); >+ createSourceFolders(); >+ >+ String tarTargetFileName = tarSourceFileName1; >+ IRemoteFile targetTarFile = (IRemoteFile)getChildFromFolder(tempDir, tarTargetFileName); >+ assertNotNull(targetTarFile); >+ >+ //Now, copy the source folder. >+ String sourceFolderName = folderToCopyName3; >+ IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir,sourceFolderName); >+ assertNotNull(sourceFolder); >+ >+ //Now, copy one of the folder from the sourceFolder into copiedTargetZipFile >+ 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, targetTarFile, mon); >+ >+ //Checking the first copied folder >+ Object theCopiedChild = getChildFromFolder(targetTarFile, childToCopyName1); >+ >+ assertNotNull(theCopiedChild); >+ >+ //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(targetTarFile, childToCopyName2); >+ >+ assertNotNull(theCopiedChild); >+ >+ //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(targetTarFile, childToCopyName3); >+ assertNotNull(theCopiedChild); >+ assertTrue(((IRemoteFile)theCopiedChild).isDirectory() != true); >+ } >+ >+ >+ >+ >+ public void testOpenFileFromTarArchive() throws Exception { >+ if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ >+ >+ //create the source for testing first >+ createTarSourceForOpen(); >+ >+ String tarTargetFileName = tarSourceForOpenTest; >+ IRemoteFile targetTarFile = (IRemoteFile)getChildFromFolder(tempDir, tarTargetFileName); >+ assertNotNull(targetTarFile); >+ >+ //Now get the contents of the virtual file we want to download: >+ String fileContentToVerifyName1 = "MANIFEST.MF"; >+ >+ //Get its parent first. >+ IRemoteFile itsParentFolder = (IRemoteFile)getChildFromFolder(tempDir,tarSourceForOpenFolderName1); >+ assertNotNull(itsParentFolder); >+ >+ //Then get this file: >+ IRemoteFile thisVirtualFile = (IRemoteFile)getChildFromFolder(itsParentFolder, fileContentToVerifyName1); >+ assertNotNull(thisVirtualFile); >+ >+ //Now, we want to download the content of this file >+ //We could just construct a dummy localpath for it. >+ String tempPath = getWorkspace().getRoot().getLocation().append("temp").toString(); >+ IFileStore temp = createDir(tempPath, true); >+ String localPath = tempPath + File.separator + fileContentToVerifyName1; >+ fss.download(thisVirtualFile, localPath, thisVirtualFile.getEncoding(), mon); >+ >+ //now, verify the content of the local file >+ IFileStore localFile = temp.getChild(fileContentToVerifyName1); >+ //Check the content of the download file: >+ boolean sameContent = compareContent(getContents(fileContentString1), localFile.openInputStream(EFS.NONE, null)); >+ assertTrue(sameContent); >+ >+ >+ //now, we got the contents of another virtual file we want to download: >+ String fileContentToVerifyName2 = "Activator.java"; >+ itsParentFolder = (IRemoteFile)getChildFromFolder(tempDir,tarSourceForOpenFolderName2); >+ assertNotNull(itsParentFolder); >+ itsParentFolder = (IRemoteFile)getChildFromFolder(itsParentFolder,"eclipse"); >+ assertNotNull(itsParentFolder); >+ itsParentFolder = (IRemoteFile)getChildFromFolder(itsParentFolder,"dstore"); >+ assertNotNull(itsParentFolder); >+ itsParentFolder = (IRemoteFile)getChildFromFolder(itsParentFolder,"core"); >+ assertNotNull(itsParentFolder); >+ thisVirtualFile = (IRemoteFile)getChildFromFolder(itsParentFolder, fileContentToVerifyName2); >+ assertNotNull(thisVirtualFile); >+ localPath = tempPath + File.separator + fileContentToVerifyName2; >+ fss.download(thisVirtualFile, localPath, thisVirtualFile.getEncoding(), mon); >+ >+ //now, verify the content of the local file >+ localFile = temp.getChild(fileContentToVerifyName2); >+ //Check the content of the download file: >+ sameContent = compareContent(getContents(fileContentString1), localFile.openInputStream(EFS.NONE, null)); >+ assertTrue(sameContent); >+ } >+ >+ >+ >+ >+} >Index: src/org/eclipse/rse/tests/subsystems/files/FileServiceTgzArchiveTest.java >=================================================================== >RCS file: src/org/eclipse/rse/tests/subsystems/files/FileServiceTgzArchiveTest.java >diff -N src/org/eclipse/rse/tests/subsystems/files/FileServiceTgzArchiveTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/rse/tests/subsystems/files/FileServiceTgzArchiveTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,26 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Wind River Systems, Inc. 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: >+ * Johnson Ma (Wind River) - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.rse.tests.subsystems.files; >+ >+/** >+ * this class is used to test tgz and .tar.gz archive function >+ */ >+public class FileServiceTgzArchiveTest extends FileServiceArchiveBaseTest { >+ >+ public FileServiceTgzArchiveTest(String name) { >+ super(name); >+ tarSourceFileName1 = "source.tar.gz"; >+ tarSourceFileName2 = "mynewtar.tgz"; >+ tarSourceForOpenTest = "tarSourceForOpen.TAR.gz"; >+ testName = "dummy.tGz"; >+ } >+ >+} >#P org.eclipse.rse.services.dstore >Index: miners/org/eclipse/rse/dstore/universal/miners/UniversalFileSystemMiner.java >=================================================================== >RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/dstore/universal/miners/UniversalFileSystemMiner.java,v >retrieving revision 1.35 >diff -u -r1.35 UniversalFileSystemMiner.java >--- miners/org/eclipse/rse/dstore/universal/miners/UniversalFileSystemMiner.java 21 Feb 2008 17:58:55 -0000 1.35 >+++ miners/org/eclipse/rse/dstore/universal/miners/UniversalFileSystemMiner.java 12 Mar 2008 13:50:19 -0000 >@@ -15,20 +15,21 @@ > * Martin Oberhuber (Wind River) - Fix 154874 - handle files with space or $ in the name > * Xuan Chen (IBM) - Fix 160768 - [refresh][dstore] Refresh on renamed node within a zip does not work; > * Xuan Chen (IBM) - Fix 189487 - copy and paste a folder did not work - workbench hang >- * Xuan Chen (IBM) - [189681] [dstore][linux] Refresh Folder in My Home messes up Refresh in Root >- * Xuan Chen (IBM) - [191280] [dstore] Expand fails for folder "/folk" with 3361 children >+ * Xuan Chen (IBM) - [189681] [dstore][linux] Refresh Folder in My Home messes up Refresh in Root >+ * Xuan Chen (IBM) - [191280] [dstore] Expand fails for folder "/folk" with 3361 children > * Kevin Doyle (IBM) - [195709] Windows Copying doesn't work when path contains space > * Kevin Doyle (IBM) - [196211] DStore Move tries rename if that fails copy/delete >- * Xuan Chen (IBM) - [198046] [dstore] Cannot copy a folder into an archive file >- * Xuan Chen (IBM) - [191367] with supertransfer on, Drag & Drop Folder from DStore to DStore doesn't work >+ * Xuan Chen (IBM) - [198046] [dstore] Cannot copy a folder into an archive file >+ * Xuan Chen (IBM) - [191367] with supertransfer on, Drag & Drop Folder from DStore to DStore doesn't work > * Martin Oberhuber (Wind River) - [199548] Avoid touching files on setReadOnly() if unnecessary > * Kevin Doyle (IBM) - [191548] Deleting Read-Only directory removes it from view and displays no error >- * Xuan Chen (IBM) - [202949] [archives] copy a folder from one connection to an archive file in a different connection does not work >+ * Xuan Chen (IBM) - [202949] [archives] copy a folder from one connection to an archive file in a different connection does not work > * Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI thread >- * David McKnight (IBM) - [196624] dstore miner IDs should be String constants rather than dynamic lookup >+ * David McKnight (IBM) - [196624] dstore miner IDs should be String constants rather than dynamic lookup > * Xuan Chen (IBM) - [209827] Update DStore command implementation to enable cancelation of archive operations > * Xuan Chen (IBM) - [194481] [dstore][Archive] Save Conflict After Renaming a File that is Open >- * David McKnight (IBM) - [209593] [api] add support for "file permissions" and "owner" properties for unix files >+ * David McKnight (IBM) - [209593] [api] add support for "file permissions" and "owner" properties for unix files >+ * Johnson Ma (Wind River) - [195402] Add tar.gz archive support > *******************************************************************************/ > > package org.eclipse.rse.dstore.universal.miners; >@@ -69,6 +70,7 @@ > import org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler; > import org.eclipse.rse.services.clientserver.archiveutils.SystemJarHandler; > import org.eclipse.rse.services.clientserver.archiveutils.SystemTarHandler; >+import org.eclipse.rse.services.clientserver.archiveutils.SystemTgzHandler; > import org.eclipse.rse.services.clientserver.archiveutils.SystemZipHandler; > import org.eclipse.rse.services.clientserver.archiveutils.VirtualChild; > import org.eclipse.rse.services.clientserver.java.ClassFileUtil; >@@ -98,6 +100,8 @@ > _archiveHandlerManager = ArchiveHandlerManager.getInstance(); > _archiveHandlerManager.setRegisteredHandler("zip", SystemZipHandler.class); //$NON-NLS-1$ > _archiveHandlerManager.setRegisteredHandler("jar", SystemJarHandler.class); //$NON-NLS-1$ >+ _archiveHandlerManager.setRegisteredHandler("tar.gz", SystemTgzHandler.class); //$NON-NLS-1$ >+ _archiveHandlerManager.setRegisteredHandler("tgz", SystemTgzHandler.class); //$NON-NLS-1$ > _archiveHandlerManager.setRegisteredHandler("tar", SystemTarHandler.class); //$NON-NLS-1$ > } > >#P org.eclipse.rse.files.ui >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.files.ui/plugin.xml,v >retrieving revision 1.22 >diff -u -r1.22 plugin.xml >--- plugin.xml 16 Jan 2008 18:28:19 -0000 1.22 >+++ plugin.xml 12 Mar 2008 13:50:20 -0000 >@@ -1,6 +1,6 @@ > <?xml version="1.0" encoding="UTF-8"?> > <!-- >-Copyright (c) 2006, 2007 IBM Corporation and others. All rights reserved. >+Copyright (c) 2006, 2008 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 >@@ -15,9 +15,9 @@ > Martin Oberhuber (Wind River) - [180519] declaratively register adapter factories > Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core > Martin Oberhuber (Wind River) - [186748] Move ISubSystemConfigurationAdapter from UI/rse.core.subsystems.util >-David McKnight (IBM) - [187711] Link with Editor action for System View >-David McKnight (IBM) - [209593] [api] add support for "file permissions" and "owner" properties for unix files >- >+David McKnight (IBM) - [187711] Link with Editor action for System View >+David McKnight (IBM) - [209593] [api] add support for "file permissions" and "owner" properties for unix files >+Johnson Ma (Wind River) - [195402] Add tar.gz archive support > --> > <?eclipse version="3.0"?> > <plugin> >@@ -309,6 +309,18 @@ > id="org.eclipse.rse.services.clientserver.archiveutils.systemjarhandler"> > </archivehandler> > <archivehandler >+ fileNameExtension="tar.gz" >+ name="SystemTargzHandler" >+ class="org.eclipse.rse.services.clientserver.archiveutils.SystemTgzHandler" >+ id="org.eclipse.rse.services.clientserver.archiveutils.systemtargzhandler"> >+ </archivehandler> >+ <archivehandler >+ fileNameExtension="tgz" >+ name="SystemTgzHandler" >+ class="org.eclipse.rse.services.clientserver.archiveutils.SystemTgzHandler" >+ id="org.eclipse.rse.services.clientserver.archiveutils.systemtgzhandler"> >+ </archivehandler> >+ <archivehandler > fileNameExtension="tar" > name="SystemTarHandler" > class="org.eclipse.rse.services.clientserver.archiveutils.SystemTarHandler" >#P org.eclipse.rse.services >Index: clientserver/org/eclipse/rse/services/clientserver/archiveutils/ArchiveHandlerManager.java >=================================================================== >RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/archiveutils/ArchiveHandlerManager.java,v >retrieving revision 1.11 >diff -u -r1.11 ArchiveHandlerManager.java >--- clientserver/org/eclipse/rse/services/clientserver/archiveutils/ArchiveHandlerManager.java 15 Feb 2008 05:39:26 -0000 1.11 >+++ clientserver/org/eclipse/rse/services/clientserver/archiveutils/ArchiveHandlerManager.java 12 Mar 2008 13:50:21 -0000 >@@ -12,11 +12,11 @@ > * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. > * > * Contributors: >- * {Name} (company) - description of contribution. >- * Xuan Chen (IBM) - [194293] [Local][Archives] Saving file second time in an Archive Errors >- * Xuan Chen (IBM) - [202949] [archives] copy a folder from one connection to an archive file in a different connection does not work >- * Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI thread >- * Xuan Chen (IBM) - [218491] ArchiveHandlerManager#cleanUpVirtualPath is messing up the file separators (with updated fix) >+ * Xuan Chen (IBM) - [194293] [Local][Archives] Saving file second time in an Archive Errors >+ * Xuan Chen (IBM) - [202949] [archives] copy a folder from one connection to an archive file in a different connection does not work >+ * Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI thread >+ * Xuan Chen (IBM) - [218491] ArchiveHandlerManager#cleanUpVirtualPath is messing up the file separators (with updated fix) >+ * Johnson Ma (Wind River) - [195402] [api] add tar.gz archive support > *******************************************************************************/ > > package org.eclipse.rse.services.clientserver.archiveutils; >@@ -25,6 +25,7 @@ > import java.lang.reflect.Constructor; > import java.lang.reflect.InvocationTargetException; > import java.util.HashMap; >+import java.util.Iterator; > > /** > * This class manages all the Archive Handlers that correspond to the archive file that the system >@@ -40,6 +41,7 @@ > public static final String VIRTUAL_SEPARATOR = "#virtual#/"; //$NON-NLS-1$ > public static final String VIRTUAL_CANONICAL_SEPARATOR = "#virtual#"; //$NON-NLS-1$ > public static final String VIRTUAL_FOLDER_SEPARATOR = "/"; //$NON-NLS-1$ >+ public static final String EXTENSION_SEPARATOR = "."; //$NON-NLS-1$ > > // the singleton instance > protected static ArchiveHandlerManager _instance = new ArchiveHandlerManager(); >@@ -116,7 +118,7 @@ > } > else > { >- if (_handlerTypes.containsKey(getExtension(file))) >+ if (getRegisteredExtension(file)!=null) > { > return true; > } >@@ -136,20 +138,50 @@ > */ > public boolean isRegisteredArchive(String filename) > { >- if (_handlerTypes.containsKey(getExtension(filename))) >- { >- return true; >- } >- else >+ return getRegisteredExtension(filename) == null?false:true; >+ } >+ >+ /** >+ * check if the file extension is registered archive type. >+ * notice here, the getExtension method does't work for name like fool.tar.gz >+ * @param file the file to check >+ * @return registered extension or null >+ * @since 3.0 >+ */ >+ protected String getRegisteredExtension(File file) >+ { >+ String fileName = file.getName(); >+ return getRegisteredExtension(fileName); >+ } >+ >+ /** >+ * check if the file extension is registered archive type. >+ * @param fileName the file name to check >+ * @return registered extension or null >+ * @since 3.0 >+ */ >+ protected String getRegisteredExtension(String fileName) >+ { >+ fileName = fileName.toLowerCase(); >+ Iterator itor = _handlerTypes.keySet().iterator(); >+ while(itor.hasNext()) > { >- return false; >+ String ext = ((String)itor.next()).toLowerCase(); >+ if (fileName.endsWith(EXTENSION_SEPARATOR + ext)) >+ { >+ return ext; >+ } >+ > } >- } >+ return null; >+ } >+ > /** > * @param file the file whose extension we are computing. > * @return the extension of <code>file</code>. "Extension" is > * defined as any letters in the filename after the last ".". > * Returns "" if there is no extension. >+ * @deprecated Use {@link #getRegisteredExtension(File)} instead > */ > protected String getExtension(File file) > { >@@ -159,11 +191,13 @@ > return filename.substring(i+1).toLowerCase(); > } > >+ > /** > * @param filename the name of the file whose extension we are computing. > * @return the extension of <code>filename</code>. "Extension" is > * defined as any letters in the filename after the last ".". > * Returns "" if there is no extension. >+ * * @deprecated Use {@link #getRegisteredExtension(String)} instead > */ > protected String getExtension(String filename) > { >@@ -212,10 +246,9 @@ > } > else { > // find registered handler based on file's extension >- String ext = getExtension(file); >- if (!_handlerTypes.containsKey(ext)) >+ String ext = getRegisteredExtension(file); >+ if (ext == null) > { >- //System.out.println("Unknown archive file type: " + ext); > return null; > } > else >@@ -375,7 +408,7 @@ > //need to process it. > //But virtual path should neither start with "\", nor contains > //":". So for those two cases, we could just return the fullVirtualName >- if (fullVirtualName.indexOf(":") != -1 || fullVirtualName.trim().startsWith("\\")) >+ if (fullVirtualName.indexOf(":") != -1 || fullVirtualName.trim().startsWith("\\")) //$NON-NLS-1$ //$NON-NLS-2$ > { > return fullVirtualName; > } >Index: clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemTarHandler.java >=================================================================== >RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemTarHandler.java,v >retrieving revision 1.16 >diff -u -r1.16 SystemTarHandler.java >--- clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemTarHandler.java 29 Feb 2008 21:25:42 -0000 1.16 >+++ clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemTarHandler.java 12 Mar 2008 13:50:21 -0000 >@@ -12,16 +12,17 @@ > * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. > * > * Contributors: >- * Xuan Chen (IBM) - [194293] [Local][Archives] Saving file second time in an Archive Errors >- * Xuan Chen (IBM) - [199132] [Archives-TAR][Local-Windows] Can't open files in tar archives >- * Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI thread >- * Xuan Chen (IBM) - [209828] Need to move the Create operation to a job. >- * Xuan Chen (IBM) - [209825] Update SystemTarHandler so that archive operations could be cancelable. >- * Xuan Chen (IBM) - [211551] NPE when moving multiple folders from one tar file to another tar file >- * Xuan Chen (IBM) - [211653] Copy virtual directory with nested directory of tar file did not work >- * Xuan Chen (IBM) - [214251] [archive] "Last Modified Time" changed for all virtual files/folders if rename/paste/delete of one virtual file. >- * Xuan Chen (IBM) - [191370] [dstore] Supertransfer zip not deleted when cancelling copy >- * Xuan Chen (IBM) - [api] SystemTarHandler has inconsistent API >+ * Xuan Chen (IBM) - [194293] [Local][Archives] Saving file second time in an Archive Errors >+ * Xuan Chen (IBM) - [199132] [Archives-TAR][Local-Windows] Can't open files in tar archives >+ * Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI thread >+ * Xuan Chen (IBM) - [209828] Need to move the Create operation to a job. >+ * Xuan Chen (IBM) - [209825] Update SystemTarHandler so that archive operations could be cancelable. >+ * Xuan Chen (IBM) - [211551] NPE when moving multiple folders from one tar file to another tar file >+ * Xuan Chen (IBM) - [211653] Copy virtual directory with nested directory of tar file did not work >+ * Xuan Chen (IBM) - [214251] [archive] "Last Modified Time" changed for all virtual files/folders if rename/paste/delete of one virtual file. >+ * Xuan Chen (IBM) - [191370] [dstore] Supertransfer zip not deleted when cancelling copy >+ * Xuan Chen (IBM) - [api] SystemTarHandler has inconsistent API >+ * Johnson Ma (Wind River) - [195402][api] Add tar.gz archive support > *******************************************************************************/ > > package org.eclipse.rse.services.clientserver.archiveutils; >@@ -30,6 +31,7 @@ > import java.io.BufferedReader; > import java.io.File; > import java.io.FileInputStream; >+import java.io.FileNotFoundException; > import java.io.FileOutputStream; > import java.io.FilePermission; > import java.io.IOException; >@@ -1228,7 +1230,7 @@ > > // open a new temp file which will be our destination for the new tar file > outputTempFile = new File(file.getAbsolutePath() + "temp"); //$NON-NLS-1$ >- outStream = new TarOutputStream(new FileOutputStream(outputTempFile)); >+ outStream = getTarOutputStream(outputTempFile); > > // get all the entries in the current tar > VirtualChild[] children = getVirtualChildrenList(archiveOperationMonitor); >@@ -1669,7 +1671,7 @@ > // open a new temp file which will be our destination for the new tar file > File outputTempFile = new File(getArchive().getAbsolutePath() + "temp"); //$NON-NLS-1$ > >- TarOutputStream outStream = new TarOutputStream(new FileOutputStream(outputTempFile)); >+ TarOutputStream outStream = getTarOutputStream(outputTempFile); > > // get all the entries > VirtualChild[] children = getVirtualChildrenList(archiveOperationMonitor); >@@ -1778,7 +1780,7 @@ > > // open a new temp file which will be our destination for the new tar file > outputTempFile = new File(file.getAbsolutePath() + "temp"); //$NON-NLS-1$ >- TarOutputStream outStream = new TarOutputStream(new FileOutputStream(outputTempFile)); >+ TarOutputStream outStream = getTarOutputStream(outputTempFile); > > // get all the entries in the current tar > VirtualChild[] children = getVirtualChildrenList(archiveOperationMonitor); >@@ -1905,7 +1907,7 @@ > > // open a new temp file which will be our destination for the new tar file > outputTempFile = new File(file.getAbsolutePath() + "temp"); //$NON-NLS-1$ >- TarOutputStream outStream = new TarOutputStream(new FileOutputStream(outputTempFile)); >+ TarOutputStream outStream = getTarOutputStream(outputTempFile); > > // get all the entries > VirtualChild[] children = getVirtualChildrenList(archiveOperationMonitor); >@@ -2192,7 +2194,7 @@ > > // open a new temp file which will be our destination for the new tar file > outputTempFile = new File(file.getAbsolutePath() + "temp"); //$NON-NLS-1$ >- outStream = new TarOutputStream(new FileOutputStream(outputTempFile)); >+ outStream = getTarOutputStream(outputTempFile); > > // get all the entries > VirtualChild[] children = getVirtualChildrenList(archiveOperationMonitor); >@@ -2343,7 +2345,7 @@ > try { > > // create output stream >- TarOutputStream outStream = new TarOutputStream(new FileOutputStream(file)); >+ TarOutputStream outStream = getTarOutputStream(file); > > // close output stream, so we have an empty tar file > outStream.close(); >@@ -2609,4 +2611,17 @@ > archiveOperationMonitor.setDone(true); > } > } >+ >+ /** >+ * Get the tar output stream for a given file. >+ * This method can be overridden by subclass to return compressed output steam if needed. >+ * @param outputFile the output file to create stream >+ * @return OutputStream the output stream to write >+ * @throws FileNotFoundException when the output file doesn't exists >+ * @since 3.0 >+ */ >+ protected TarOutputStream getTarOutputStream(File outputFile) throws FileNotFoundException { >+ TarOutputStream outStream = new TarOutputStream(new FileOutputStream(outputFile)); >+ return outStream; >+ } > } >Index: clientserver/org/eclipse/rse/services/clientserver/archiveutils/TarFile.java >=================================================================== >RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/archiveutils/TarFile.java,v >retrieving revision 1.1 >diff -u -r1.1 TarFile.java >--- clientserver/org/eclipse/rse/services/clientserver/archiveutils/TarFile.java 29 Feb 2008 21:25:42 -0000 1.1 >+++ clientserver/org/eclipse/rse/services/clientserver/archiveutils/TarFile.java 12 Mar 2008 13:50:21 -0000 >@@ -12,8 +12,8 @@ > * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. > * > * Contributors: >- * {Name} (company) - description of contribution. > * Xuan Chen (IBM) - [api] SystemTarHandler has inconsistent API >+ * Johnson Ma (Wind River) - [195402] Add tar.gz archive support > *******************************************************************************/ > > package org.eclipse.rse.services.clientserver.archiveutils; >@@ -197,8 +197,9 @@ > * Gets the input stream for the tar file. > * @return the input stream for the tar file. > * @throws FileNotFoundException if the file does not exist. >+ * @since 3.0 > */ >- private InputStream getInputStream() throws FileNotFoundException { >+ protected InputStream getInputStream() throws FileNotFoundException { > FileInputStream stream = new FileInputStream(file); > return stream; > } >Index: clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemZipHandler.java >=================================================================== >RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemZipHandler.java,v >retrieving revision 1.18 >diff -u -r1.18 SystemZipHandler.java >--- clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemZipHandler.java 23 Jan 2008 03:57:16 -0000 1.18 >+++ clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemZipHandler.java 12 Mar 2008 13:50:21 -0000 >@@ -1389,8 +1389,8 @@ > * @param dest The ZipOutputStream representing the zip file where the > * children are to be recreated > * @param omitChildren The set of names of children to omit when creating >- * the zipfile. Null or empty set if there are no ommisions. >- * @throws IOException >+ * the zipfile. Null or empty set if there are no omissions. >+ * @throws IOException in case of a file I/O error > */ > protected boolean recreateZipDeleteEntries(VirtualChild[] vcList, ZipOutputStream dest, HashSet omitChildren, ISystemOperationMonitor archiveOperationMonitor) throws IOException > { >@@ -2563,8 +2563,9 @@ > return ""; //$NON-NLS-1$ > } > >- /** >- * @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#isExecutable(java.lang.String) >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#getClassification(java.lang.String) > */ > public String getClassification(String fullVirtualName) { > return getClassification(fullVirtualName, true); >@@ -2573,7 +2574,7 @@ > /** > * Same as getClassification(String), but you can choose whether to leave the zip file > * open after the method is closed. >- * @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#isExecutable(java.lang.String) >+ * @see org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler#getClassification(java.lang.String) > */ > public String getClassification(String fullVirtualName, boolean closeZipFile) { > >Index: clientserver/org/eclipse/rse/internal/services/clientserver/archiveutils/TgzFile.java >=================================================================== >RCS file: clientserver/org/eclipse/rse/internal/services/clientserver/archiveutils/TgzFile.java >diff -N clientserver/org/eclipse/rse/internal/services/clientserver/archiveutils/TgzFile.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ clientserver/org/eclipse/rse/internal/services/clientserver/archiveutils/TgzFile.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,65 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Wind River Systems, Inc. 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: >+ * Johnson Ma (Wind River) - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.rse.internal.services.clientserver.archiveutils; >+ >+import java.io.File; >+import java.io.FileNotFoundException; >+import java.io.IOException; >+import java.io.InputStream; >+import java.util.zip.GZIPInputStream; >+ >+import org.eclipse.rse.services.clientserver.archiveutils.TarFile; >+ >+/** >+ * This class is used to read entries from tar.gz file >+ * It read compressed data from GZIPInputStream >+ */ >+public class TgzFile extends TarFile { >+ >+ /** >+ * Opens a tar.gz file for reading given the specified File object. >+ * @param file the tar.gz file to be opened for reading. >+ * @throws FileNotFoundException if the file does not exist. >+ * @throws IOException if an I/O error occurs. >+ */ >+ public TgzFile(File file) throws FileNotFoundException, IOException { >+ super(file); >+ } >+ >+ /** >+ * Opens a tar.gz file for reading given the file name. >+ * @param name the name of the tar file to be opened for reading. >+ * @throws FileNotFoundException if the file with the given name does not exist. >+ * @throws IOException if an I/O error occurs. >+ */ >+ public TgzFile(String name) throws FileNotFoundException, IOException { >+ super(name); >+ } >+ >+ /** >+ * Gets the input stream for the tar.gz file. >+ * Get file input steam from superclass, wrap it using GZipInputSteam >+ * @return the input stream for the tar file. >+ * @throws FileNotFoundException if the file does not exist. >+ */ >+ protected InputStream getInputStream() throws FileNotFoundException { >+ InputStream fileInputStream = super.getInputStream(); >+ GZIPInputStream zipInputStream = null; >+ try{ >+ zipInputStream = new GZIPInputStream(fileInputStream); >+ } catch (IOException ioe) { >+ //in that case, the file doesn't exists yet. return the file input stream from base class >+ return fileInputStream; >+ } >+ return zipInputStream; >+ } >+ >+} >Index: clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemTgzHandler.java >=================================================================== >RCS file: clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemTgzHandler.java >diff -N clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemTgzHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemTgzHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,63 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Wind River Systems, Inc. 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: >+ * Johnson Ma (Wind River) - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.rse.services.clientserver.archiveutils; >+ >+import java.io.File; >+import java.io.FileNotFoundException; >+import java.io.FileOutputStream; >+import java.io.IOException; >+import java.util.zip.GZIPOutputStream; >+ >+import org.eclipse.rse.internal.services.clientserver.archiveutils.TarOutputStream; >+import org.eclipse.rse.internal.services.clientserver.archiveutils.TgzFile; >+ >+/** >+ * handler class for .tar.gz and .tgz files >+ */ >+public class SystemTgzHandler extends SystemTarHandler { >+ >+ /** >+ * constructor for the tgz handler >+ * @param file the .tar.gz or .tgz file >+ */ >+ public SystemTgzHandler(File file) throws IOException { >+ super(file); >+ } >+ >+ /** >+ * Gets a tar.gz file from the underlying file. >+ * @return the tar file, or <code>null</code> if the tar file does not exist. >+ */ >+ protected TarFile getTarFile() { >+ >+ TarFile tarFile = null; >+ >+ try { >+ tarFile = new TgzFile(file); >+ } >+ catch (IOException e) { >+ // TODO: log error >+ } >+ >+ return tarFile; >+ } >+ >+ protected TarOutputStream getTarOutputStream(File outputFile) throws FileNotFoundException { >+ GZIPOutputStream zipOutputStream = null; >+ try{ >+ zipOutputStream = new GZIPOutputStream(new FileOutputStream(outputFile)); >+ } catch (IOException ioe) { >+ throw new FileNotFoundException(ioe.getMessage()); >+ } >+ TarOutputStream outStream = new TarOutputStream(zipOutputStream); >+ return outStream; >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 195402
:
89809
|
91652
| 92312