1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-20 06:35:50 +02:00

[198956][tests] Fix initialization of RSE Unit tests by waiting for InitRSEJob

This commit is contained in:
Martin Oberhuber 2007-08-06 17:02:44 +00:00
parent 47f4d7d7a8
commit 42cc075be4
7 changed files with 1372 additions and 1728 deletions

View file

@ -43,6 +43,8 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.persistence.IRSEPersistenceManager;
import org.eclipse.rse.tests.RSETestsPlugin;
import org.eclipse.rse.tests.core.RSEWaitAndDispatchUtil.IInterruptCondition;
import org.eclipse.rse.ui.SystemBasePlugin;
@ -346,16 +348,66 @@ public class RSECoreTestCase extends TestCase {
}
}
/**
* Wait until the SystemProfileManager has finished loading all "autoload" profiles,
* and the RSEUIPlugin InitRSEJob has finished filling it with the default connections.
* @throws InterruptedException
*/
protected void waitForRSEWorkspaceInit() throws InterruptedException {
//RSEUIPlugin is loaded automatically because RSETestsPlugins extends SystemBasePlugin,
//which is defined in org.eclipse.rse.ui, so we KNOW org.eclipse.rse.ui is started.
//TODO: At one point we want the tests to run headless, so then RSETestsPlugins should
//not extend SystemBasePlugin any more.
Job[] jobs = Job.getJobManager().find(null);
for(int i=0; i<jobs.length; i++) {
if ("Initialize RSE".equals(jobs[i].getName())) { //$NON-NLS-1$
System.out.println("Waiting for InitRSEJob"); //$NON-NLS-1$
jobs[i].join();
break;
}
}
//The code below would never be necessary during normal initialization,
//Since the InitRSEJob takes care of loading the profiles already.
//We still wait here, in order to ensure that unit tests are really
//separate from each other.
final IRSEPersistenceManager pm = RSECorePlugin.getThePersistenceManager();
while (!pm.isRestoreComplete() || pm.isBusy()) {
System.err.println("Waiting for Persistence Manager"); //$NON-NLS-1$
Thread.sleep(100);
}
}
/* (non-Javadoc)
* @see junit.framework.TestCase#setUp()
*/
protected void setUp() throws Exception {
super.setUp();
waitForRSEWorkspaceInit();
switchMaximizeSystemsView();
}
/* (non-Javadoc)
* @see junit.framework.TestCase#tearDown()
*/
protected void tearDown() throws Exception {
restoreMaximizeSystemsView();
super.tearDown();
}
// ***** View and perspective management and support methods *****
/**
* Bring the RSE SystemsView to front, and toggle its "maximized" state based on what
* the {@link IRSECoreTestCaseProperties#PROP_MAXIMIZE_REMOTE_SYSTEMS_VIEW} property
* requires for the given test case.
* In case a Workbench Intro View is hiding every else because this is the first
* product launch, it is hidden.
*/
protected void switchMaximizeSystemsView() {
final String perspectiveId = getProperty(IRSECoreTestCaseProperties.PROP_SWITCH_TO_PERSPECTIVE);
assertNotNull("Invalid null-value for test case perspective id!", perspectiveId); //$NON-NLS-1$
// all view managment must happen in the UI thread!
// all view management must happen in the UI thread!
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
public void run() {
// in case the test case is launched within a new workspace, the eclipse intro
@ -382,19 +434,23 @@ public class RSECoreTestCase extends TestCase {
});
// Give the UI a chance to repaint if the view zoom state changed
if (isProperty(PROP_RSE_SYSTEMS_VIEW_ZOOM_STATE_CHANGED, true)) RSEWaitAndDispatchUtil.waitAndDispatch(1000);
if (isProperty(PROP_RSE_SYSTEMS_VIEW_ZOOM_STATE_CHANGED, true)) {
System.err.println("Waiting for UI to repaint"); //$NON-NLS-1$
RSEWaitAndDispatchUtil.waitAndDispatch(1000);
}
}
/* (non-Javadoc)
* @see junit.framework.TestCase#tearDown()
/**
* Restore the RSE SystemsView to its previous state, in case the view state
* has been changed by {@link #switchMaximizeSystemsView()}.
*/
protected void tearDown() throws Exception {
protected void restoreMaximizeSystemsView() {
// restore the original view zoom state
if (isProperty(PROP_RSE_SYSTEMS_VIEW_ZOOM_STATE_CHANGED, true)) {
final String perspectiveId = getProperty(IRSECoreTestCaseProperties.PROP_SWITCH_TO_PERSPECTIVE);
assertNotNull("Invalid null-value for test case perspective id!", perspectiveId); //$NON-NLS-1$
// all view managment must happen in the UI thread!
// all view management must happen in the UI thread!
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
public void run() {
IViewReference reference = findView(IRSEViews.RSE_REMOTE_SYSTEMS_VIEW_ID, perspectiveId);
@ -410,12 +466,8 @@ public class RSECoreTestCase extends TestCase {
}
});
}
super.tearDown();
}
// ***** View and perspective management and support methods *****
/**
* Finds the view reference for the view identified by the specified id.
*

View file

@ -16,18 +16,11 @@ import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.rse.core.IRSESystemType;
import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.core.model.ISystemResourceSet;
import org.eclipse.rse.core.model.SystemRemoteResourceSet;
import org.eclipse.rse.core.model.SystemStartHere;
import org.eclipse.rse.core.model.SystemWorkspaceResourceSet;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.core.subsystems.ISystemDragDropAdapter;
import org.eclipse.rse.files.ui.resources.UniversalFileTransferUtility;
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
import org.eclipse.rse.services.files.IFileService;
import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
import org.eclipse.rse.tests.RSETestsPlugin;
@ -51,16 +44,12 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
return ResourcesPlugin.getWorkspace();
}
public void createSourceFolders()
{
try
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);
@ -114,19 +103,9 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
//Then, delete the temp folder in the junit workspace.
temp.delete(EFS.NONE, mon);
return;
}
catch (Exception e)
{
e.printStackTrace();
}
}
public void createSourceZipFiles()
{
try
public void createSourceZipFiles() throws Exception
{
/* build scenario */
String tempPath = getWorkspace().getRoot().getLocation().append("temp").toString();
@ -317,9 +296,6 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
content = getRandomString();
createFile(epdcdump01_hex12ab, content);
//now, copy folderToCopy into the folder in the remote system
IRemoteFile sourceFolderToCopy1 = localFss.getRemoteFileObject(tempPath + '\\' + folderToCopyName1, mon);
ISystemDragDropAdapter srcAdapter1 = (ISystemDragDropAdapter) ((IAdaptable) sourceFolderToCopy1).getAdapter(ISystemDragDropAdapter.class);
@ -350,71 +326,15 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
//Then, delete the temp folder in the junit workspace.
temp.delete(EFS.NONE, mon);
return;
}
catch (Exception e)
{
e.printStackTrace();
}
}
public void setUp() {
if (!classBeenRunBefore)
{
try
{
System.out.println("need to sleep");
Thread.sleep(500);
}
catch (Exception e)
{
e.printStackTrace();
}
classBeenRunBefore = true;
}
IHost localHost = getLocalSystemConnection();
ISystemRegistry sr = SystemStartHere.getSystemRegistry();
ISubSystem[] ss = sr.getServiceSubSystems(localHost, IFileService.class);
for (int i=0; i<ss.length; i++) {
if (ss[i] instanceof IFileServiceSubSystem) {
fss = (IFileServiceSubSystem)ss[i];
fs = fss.getFileService();
}
}
localFss = fss; //Used for creating test source data.
//Create a temparory directory in My Home
try
{
IRemoteFile homeDirectory = fss.getRemoteFileObject(".", mon);
String baseFolderName = "rsetest";
String homeFolderName = homeDirectory.getAbsolutePath();
String testFolderName = FileServiceHelper.getRandomLocation(fss, homeFolderName, baseFolderName, mon);
tempDir = createFileOrFolder(homeFolderName, testFolderName, true);
tempDirPath = tempDir.getAbsolutePath();
}
catch (Exception e)
{
fail("Problem encountered: " + e.getStackTrace().toString());
}
}
public void tearDown() {
try {
fss.delete(tempDir, mon);
} catch(SystemMessageException msg) {
assertFalse("Exception: "+msg.getLocalizedMessage(), true); //$NON-NLS-1$
}
}
public void testCreateZipFile() throws SystemMessageException {
public void testCreateZipFile() throws Exception {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
//Create the zip file first.
String testName = "dummy.zip";
IRemoteFile newArchiveFile = createFileOrFolder(tempDirPath, testName, false);
assertTrue(newArchiveFile != null);
assertNotNull(newArchiveFile);
assertTrue(newArchiveFile.exists());
assertTrue(newArchiveFile.canRead());
assertTrue(newArchiveFile.canWrite());
@ -425,16 +345,16 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
//Now, we want to create a text file inside.
String childName = "aaa.txt";
IRemoteFile file1 = createFileOrFolder(newArchiveFile.getAbsolutePath(), childName, false);
assertTrue(file1 != null);
assertNotNull(file1);
childName = "bbb.txt";
IRemoteFile file2 = createFileOrFolder(newArchiveFile.getAbsolutePath(), childName, false);
assertTrue(file2 != null);
assertNotNull(file2);
//Create a folder
childName = "folder1";
IRemoteFile folder1 = createFileOrFolder(newArchiveFile.getAbsolutePath(), childName, true);
assertTrue(folder1 != null);
assertNotNull(folder1);
//Now, check the contents
String[] namesToCheck = {"aaa.txt", "bbb.txt", "folder1"};
@ -463,7 +383,7 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
}
public void testRenameVirtualFile() throws SystemMessageException {
public void testRenameVirtualFile() throws Exception {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
//Create the zip file first.
@ -534,7 +454,7 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
}
public void testMoveVirtualFile() throws SystemMessageException {
public void testMoveVirtualFile() throws Exception {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
//Create the source data needed for testing
@ -549,8 +469,6 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
IRemoteFile sourceZipFile = (IRemoteFile)getChildFromFolder(tempDir, sourceZipFileName);
//Now, copy one of the folder from the zip file into folder1
try
{
Object[] children = fss.resolveFilterString(sourceZipFile, null, mon);
IRemoteFile originalVirtualFolder = (IRemoteFile)children[0];
String movedFolderName = originalVirtualFolder.getName();
@ -569,16 +487,8 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
children = fss.resolveFilterString(sourceZipFile, null, mon);
assertTrue(children.length == 0);
}
catch (Exception e)
{
fail("Problem encountered: " + e.getStackTrace().toString());
}
return;
}
public void testMoveVirtualFileLevelTwo() throws SystemMessageException {
public void testMoveVirtualFileLevelTwo() throws Exception {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
createSourceZipFiles();
@ -593,9 +503,6 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
assertTrue(sourceZipFile != null);
//Now, move one of the level two folder from the zip file into folder1
try
{
//Now, copy one of the level two folder from the zip file into folder1
IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(sourceZipFile, folderToCopyName1);
IRemoteFile secondLevelChild = (IRemoteFile)getChildFromFolder(firstLevelChild, "Team");
String movedFolderName = secondLevelChild.getName();
@ -616,16 +523,8 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
assertTrue(originalVirtualFolder == null); //we should not be able to find it.
}
catch (Exception e)
{
fail("Problem encountered: " + e.getStackTrace().toString());
}
return;
}
public void testMoveToArchiveFile() throws SystemMessageException {
public void testMoveToArchiveFile() throws Exception {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
createSourceZipFiles();
@ -639,9 +538,7 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir, sourceFolderName);
assertTrue(sourceFolder != null);
//Now, copy one of the folder from the sourceFolder into copiedTargetZipFile
try
{
//Now, move one of the folder from the sourceFolder into copiedTargetZipFile
fss.move(sourceFolder, targetZipFile, sourceFolder.getName(), mon);
Object theMovedChild = getChildFromFolder(targetZipFile, sourceFolderName);
@ -659,15 +556,8 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
Object originalSource = getChildFromFolder(tempDirRemoteFile, sourceFolderName);
assertFalse(originalSource != null);
}
catch (Exception e)
{
fail("Problem encountered: " + e.getStackTrace().toString());
}
return;
}
public void testMoveToVirtualFileLevelOne() throws SystemMessageException {
public void testMoveToVirtualFileLevelOne() throws Exception {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
createSourceZipFiles();
@ -681,9 +571,6 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir, sourceFolderName);
assertTrue(sourceFolder != null);
try
{
//Now, move one of the folder from the sourceFolder into a first level virtual file in targetZipFile
//Get one of its first level children, and move the folder to there.
IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(targetZipFile, folderToCopyName1);
@ -704,15 +591,8 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
Object originalSource = getChildFromFolder(tempDirRemoteFile, sourceFolderName);
assertFalse(originalSource != null);
}
catch (Exception e)
{
fail("Problem encountered: " + e.getStackTrace().toString());
}
return;
}
public void testMoveToVirtualFileLevelTwo() throws SystemMessageException {
public void testMoveToVirtualFileLevelTwo() throws Exception {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
createSourceZipFiles();
@ -726,9 +606,6 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir, sourceFolderName);
assertTrue(sourceFolder != null);
try
{
//Get one of its second level children, and move the folder to there.
IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(targetZipFile, folderToCopyName1);
IRemoteFile secondLevelChild = (IRemoteFile)getChildFromFolder(firstLevelChild, "Team");
@ -748,19 +625,10 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
IRemoteFile tempDirRemoteFile = fss.getRemoteFileObject(tempDirPath, mon);
Object originalSource = getChildFromFolder(tempDirRemoteFile, sourceFolderName);
assertFalse(originalSource != null);
}
catch (Exception e)
{
fail("Problem encountered: " + e.getStackTrace().toString());
}
return;
}
public void testCopyVirtualFile() throws SystemMessageException {
public void testCopyVirtualFile() throws Exception {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
createSourceZipFiles();
@ -775,8 +643,6 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
assertTrue(folder1 != null);
//Now, copy one of the folder from the zip file into folder1
try
{
IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(sourceZipFile, folderToCopyName1);
fss.copy(firstLevelChild, folder1, folderToCopyName1, mon);
@ -788,15 +654,8 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FOLDER, TYPE_FILE, TYPE_FILE};
checkFolderContents((IRemoteFile)copiedVirtualFolder, contents, typesToCheck);
}
catch (Exception e)
{
fail("Problem encountered: " + e.getStackTrace().toString());
}
return;
}
public void testCopyVirtualFileLevelTwo() throws SystemMessageException {
public void testCopyVirtualFileLevelTwo() throws Exception {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
createSourceZipFiles();
@ -811,8 +670,6 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
IRemoteFile folder1 = createFileOrFolder(tempDirPath, folderName, true);
assertTrue(folder1 != null);
try
{
//Now, copy one of the level two folder from the zip file into folder1
IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(sourceZipFile, folderToCopyName1);
IRemoteFile secondLevelChild = (IRemoteFile)getChildFromFolder(firstLevelChild, "Team");
@ -827,17 +684,9 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FILE};
checkFolderContents((IRemoteFile)copiedVirtualFolder, contents, typesToCheck);
}
catch (Exception e)
{
fail("Problem encountered: " + e.getStackTrace().toString());
}
return;
}
public void testCopyToArchiveFile() throws SystemMessageException {
public void testCopyToArchiveFile() throws Exception {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
createSourceZipFiles();
@ -852,8 +701,6 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
assertTrue(sourceFolder != null);
//Now, copy one of the folder from the sourceFolder into copiedTargetZipFile
try
{
fss.copy(sourceFolder, targetZipFile, sourceFolder.getName(), mon);
Object theCopiedChild = getChildFromFolder(targetZipFile, sourceFolderName);
@ -866,17 +713,10 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FILE, TYPE_FILE};
checkFolderContents((IRemoteFile)theCopiedChild, childrenToCheck, typesToCheck);
}
catch (Exception e)
{
fail("Problem encountered: " + e.getStackTrace().toString());
}
return;
}
public void testCopyToVirtualFileLevelOne() throws SystemMessageException {
public void testCopyToVirtualFileLevelOne() throws Exception {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
createSourceZipFiles();
@ -890,9 +730,6 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir, sourceFolderName);
assertTrue(sourceFolder != null);
try
{
//Now, copy one of the folder from the sourceFolder into a first level virtual file in targetZipFile
//Get one of its first level children, and copy the folder to there.
//Now, copy one of the level two folder from the zip file into folder1
@ -909,16 +746,9 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FILE, TYPE_FILE};
checkFolderContents((IRemoteFile)theCopiedChild, childrenToCheck, typesToCheck);
}
catch (Exception e)
{
fail("Problem encountered: " + e.getStackTrace().toString());
}
return;
}
public void testCopyToVirtualFileLevelTwo() throws SystemMessageException {
public void testCopyToVirtualFileLevelTwo() throws Exception {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
createSourceZipFiles();
@ -932,9 +762,6 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir, folderToCopyName3);
assertTrue(sourceFolder != null);
try
{
//Get one of its second level children, and copy the folder to there.
//Now, copy one of the level two folder from the zip file into folder1
IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(targetZipFile, folderToCopyName1);
@ -951,15 +778,8 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FILE, TYPE_FILE};
checkFolderContents((IRemoteFile)theCopiedChild, childrenToCheck, typesToCheck);
}
catch (Exception e)
{
fail("Problem encountered: " + e.getStackTrace().toString());
}
return;
}
public void testCopyBatchToArchiveFile() throws SystemMessageException {
public void testCopyBatchToArchiveFile() throws Exception {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
createSourceZipFiles();
@ -975,8 +795,6 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
assertTrue(sourceFolder != null);
//Now, copy one of the folder from the sourceFolder into copiedTargetZipFile
try
{
IRemoteFile[] sourceFiles = new IRemoteFile[3];
//Also add some of its children into the batch.
String childToCopyName1 = "aaaaaaaa";
@ -1013,17 +831,9 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
theCopiedChild = getChildFromFolder(targetZipFile, childToCopyName3);
assertTrue(theCopiedChild != null);
assertTrue(((IRemoteFile)theCopiedChild).isDirectory() != true);
}
catch (Exception e)
{
fail("Problem encountered: " + e.getStackTrace().toString());
}
return;
}
public void testCopyBatchToVirtualFileLevelOne() throws SystemMessageException {
public void testCopyBatchToVirtualFileLevelOne() throws Exception {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
createSourceZipFiles();
@ -1037,9 +847,6 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir, sourceFolderName);
assertTrue(sourceFolder != null);
try
{
//Now, copy one of the folder from the sourceFolder into a first level virtual file in targetZipFile
//Get one of its first level children, and copy the folder to there.
Object[] childrenOfTargetZipFile = fss.resolveFilterString(targetZipFile, null, mon);
@ -1057,15 +864,8 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FILE, TYPE_FILE};
checkFolderContents((IRemoteFile)theCopiedChild, childrenToCheck, typesToCheck);
}
catch (Exception e)
{
fail("Problem encountered: " + e.getStackTrace().toString());
}
return;
}
public void testCopyBatchToVirtualFileLevelTwo() throws SystemMessageException {
public void testCopyBatchToVirtualFileLevelTwo() throws Exception {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
createSourceZipFiles();
@ -1080,8 +880,6 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir, sourceFolderName);
assertTrue(sourceFolder != null);
try
{
//Get one of its second level children, and copy the folder to there.
//Now, copy one of the level two folder from the zip file into folder1
IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(targetZipFile, folderToCopyName1);
@ -1124,17 +922,9 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
theCopiedChild = getChildFromFolder(secondLevelChild, childToCopyName3);
assertTrue(theCopiedChild != null);
assertTrue(((IRemoteFile)theCopiedChild).isDirectory() != true);
}
catch (Exception e)
{
fail("Problem encountered: " + e.getStackTrace().toString());
}
return;
}
public void testCopyBatchVirtualFile() throws SystemMessageException {
public void testCopyBatchVirtualFile() throws Exception {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
createSourceZipFiles();
@ -1149,8 +939,6 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
assertTrue(folder1 != null);
//Now, copy one of the folder from the zip file into folder1
try
{
Object[] children = fss.resolveFilterString(sourceZipFile, null, mon);
IRemoteFile[] sourceFiles = new IRemoteFile[3];
String childToCopyName1 = "Team";
@ -1179,17 +967,9 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
Object copiedVirtualFile = getChildFromFolder(folder1, childToCopyName3);
assertTrue(copiedVirtualFile != null);
assertTrue(((IRemoteFile)copiedVirtualFile).isDirectory() != true);
}
catch (Exception e)
{
fail("Problem encountered: " + e.getStackTrace().toString());
}
return;
}
public void testCopyBatchVirtualFileLevelTwo() throws SystemMessageException {
public void testCopyBatchVirtualFileLevelTwo() throws Exception {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
createSourceZipFiles();
@ -1203,8 +983,6 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
IRemoteFile folder1 = createFileOrFolder(tempDirPath, folderName, true);
assertTrue(folder1 != null);
try
{
//Now, copy one of the level two folder from the zip file into folder1
IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(sourceZipFile, folderToCopyName1);
IRemoteFile secondLevelChild = (IRemoteFile)getChildFromFolder(firstLevelChild, "Team");
@ -1222,16 +1000,8 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FILE};
checkFolderContents((IRemoteFile)copiedVirtualFolder, contents, typesToCheck);
}
catch (Exception e)
{
fail("Problem encountered: " + e.getStackTrace().toString());
}
return;
}
public void testCopyVirtualBatchToArchiveFile() throws SystemMessageException {
public void testCopyVirtualBatchToArchiveFile() throws Exception {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
createSourceZipFiles();
@ -1245,8 +1015,6 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
assertTrue(sourceFile != null);
//Now, copy one of the folder from the sourceFile into copiedTargetZipFile
try
{
IRemoteFile[] sourceFiles = new IRemoteFile[1];
String virutalFolderToCopyName = "6YLT5Xa";
IRemoteFile virtualFolderToCopy = (IRemoteFile)getChildFromFolder(sourceFile, virutalFolderToCopyName);
@ -1263,15 +1031,8 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FOLDER, TYPE_FOLDER, TYPE_FOLDER};
checkFolderContents((IRemoteFile)theCopiedChild, childrenToCheck, typesToCheck);
}
catch (Exception e)
{
fail("Problem encountered: " + e.getStackTrace().toString());
}
return;
}
public void testCopyVirtualBatchToVirtualFileLevelOne() throws SystemMessageException {
public void testCopyVirtualBatchToVirtualFileLevelOne() throws Exception {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
createSourceZipFiles();
@ -1284,8 +1045,6 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
IRemoteFile sourceFile = (IRemoteFile)getChildFromFolder(tempDir, sourcefileName);
assertTrue(sourceFile != null);
try
{
//Now, copy one of the folder from the sourceFolder into a first level virtual file in targetZipFile
//Get one of its first level children, and copy the folder to there.
Object[] childrenOfTargetZipFile = fss.resolveFilterString(targetZipFile, null, mon);
@ -1327,17 +1086,9 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
String[] childrenToCheck3 = {"20070404a", "epdcdump01.hex12ab"};
int[] typesToCheck3 = {TYPE_FOLDER, TYPE_FILE};
checkFolderContents((IRemoteFile)theCopiedChild, childrenToCheck3, typesToCheck3);
}
catch (Exception e)
{
fail("Problem encountered: " + e.getStackTrace().toString());
}
return;
}
public void testCopyVirtualBatchToVirtualFileLevelTwo() throws SystemMessageException {
public void testCopyVirtualBatchToVirtualFileLevelTwo() throws Exception {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
createSourceZipFiles();
@ -1350,8 +1101,6 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
IRemoteFile sourceFile = (IRemoteFile)getChildFromFolder(tempDir, sourcefileName);
assertTrue(sourceFile != null);
try
{
//Get one of its second level children, and copy the folder to there.
//Now, copy one of the level two folder from the zip file into folder1
IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(targetZipFile, folderToCopyName1);
@ -1377,12 +1126,5 @@ public class FileServiceArchiveTest extends FileServiceBaseTest {
int[] typesToCheck = {TYPE_FOLDER, TYPE_FILE};
checkFolderContents((IRemoteFile)theCopiedChild, childrenToCheck, typesToCheck);
}
catch (Exception e)
{
fail("Problem encountered: " + e.getStackTrace().toString());
}
return;
}
}

View file

@ -28,7 +28,6 @@ import org.eclipse.rse.core.subsystems.IServerLauncherProperties;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.core.subsystems.ISystemDragDropAdapter;
import org.eclipse.rse.files.ui.resources.UniversalFileTransferUtility;
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
import org.eclipse.rse.services.files.IFileService;
import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
@ -44,6 +43,9 @@ public class FileServiceArchiveTestDStore extends FileServiceArchiveTest {
protected String tarSourceFolderName1 = "META-INF";
protected String tarSourceFolderName2 = "org";
private boolean fPreference_ALERT_SSL;
private boolean fPreference_ALERT_NONSSL;
public static junit.framework.Test suite() {
TestSuite suite = new TestSuite("FileServiceArchiveTestDStore");
@ -94,7 +96,9 @@ public class FileServiceArchiveTestDStore extends FileServiceArchiveTest {
public void setUp() {
public void setUp() throws Exception {
super.setUp();
//We need to delay if it is first case run after a workspace startup
SYSTEM_TYPE_ID = IRSESystemType.SYSTEMTYPE_LINUX_ID;
SYSTEM_ADDRESS = "SLES8RM";
@ -102,27 +106,16 @@ public class FileServiceArchiveTestDStore extends FileServiceArchiveTest {
USER_ID = "xuanchen";
PASSWORD = "xxxxxx";
if (!classBeenRunBefore)
{
IPreferenceStore store = RSEUIPlugin.getDefault().getPreferenceStore();
//Ensure that the SSL acknowledge dialog does not show up.
//We need to setDefault first in order to set the value of a preference.
IPreferenceStore store = RSEUIPlugin.getDefault().getPreferenceStore();
store.setDefault(ISystemPreferencesConstants.ALERT_SSL, ISystemPreferencesConstants.DEFAULT_ALERT_SSL);
store.setDefault(ISystemPreferencesConstants.ALERT_NONSSL, ISystemPreferencesConstants.DEFAULT_ALERT_NON_SSL);
fPreference_ALERT_SSL = store.getBoolean(ISystemPreferencesConstants.ALERT_SSL);
fPreference_ALERT_NONSSL = store.getBoolean(ISystemPreferencesConstants.ALERT_NONSSL);
store.setValue(ISystemPreferencesConstants.ALERT_SSL, false);
store.setValue(ISystemPreferencesConstants.ALERT_NONSSL, false);
try
{
System.out.println("need to sleep");
Thread.sleep(500);
}
catch (Exception e)
{
e.printStackTrace();
}
classBeenRunBefore = true;
}
IHost dstoreHost = getRemoteSystemConnection(SYSTEM_TYPE_ID, SYSTEM_ADDRESS, SYSTEM_NAME, USER_ID, PASSWORD);
assertTrue(dstoreHost != null);
ISystemRegistry sr = SystemStartHere.getSystemRegistry();
@ -192,17 +185,14 @@ public class FileServiceArchiveTestDStore extends FileServiceArchiveTest {
}
}
public void tearDown() {
try {
fss.delete(tempDir, mon);
} catch(SystemMessageException msg) {
assertFalse("Exception: "+msg.getLocalizedMessage(), true); //$NON-NLS-1$
}
public void tearDown() throws Exception {
IPreferenceStore store = RSEUIPlugin.getDefault().getPreferenceStore();
store.setValue(ISystemPreferencesConstants.ALERT_SSL, fPreference_ALERT_SSL);
store.setValue(ISystemPreferencesConstants.ALERT_NONSSL, fPreference_ALERT_NONSSL);
super.tearDown();
}
public void createSourceTarFiles()
{
try
public void createSourceTarFiles() throws Exception
{
String tempPath = getWorkspace().getRoot().getLocation().append("temp").toString();
IFileStore temp = createDir(tempPath, true);
@ -360,15 +350,9 @@ public class FileServiceArchiveTestDStore extends FileServiceArchiveTest {
IRemoteFile tarSourceFolder2 = (IRemoteFile)getChildFromFolder(tempDir, tarSourceFolderName2);
fss.copy(tarSourceFolder1, tarSource, tarSourceFolderName1, mon);
fss.copy(tarSourceFolder2, tarSource, tarSourceFolderName2, mon);
return;
}
catch (Exception e)
{
e.printStackTrace();
}
}
public void testCreateTarFile() throws SystemMessageException {
public void testCreateTarFile() throws Exception {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
//Create the zip file first.
@ -419,12 +403,9 @@ public class FileServiceArchiveTestDStore extends FileServiceArchiveTest {
String[] namesToCheck1 = {"ccc.exe", "ddd.bat", "another Folder"};
int[] typesToCheck1 = {TYPE_FILE, TYPE_FILE, TYPE_FOLDER};
checkFolderContents(folder1, namesToCheck1, typesToCheck1);
return;
}
public void testCopyToTarArchiveFile() throws SystemMessageException {
public void testCopyToTarArchiveFile() throws Exception {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
//create the source for testing first
@ -440,8 +421,6 @@ public class FileServiceArchiveTestDStore extends FileServiceArchiveTest {
assertTrue(sourceFolder != null);
//Now, copy one of the folder from the sourceFolder into copiedTargetZipFile
try
{
fss.copy(sourceFolder, targetTarFile, sourceFolder.getName(), mon);
Object theCopiedChild = getChildFromFolder(targetTarFile, sourceFolderName);
@ -454,15 +433,8 @@ public class FileServiceArchiveTestDStore extends FileServiceArchiveTest {
int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FILE, TYPE_FILE};
checkFolderContents((IRemoteFile)theCopiedChild, childrenToCheck, typesToCheck);
}
catch (Exception e)
{
fail("Problem encountered: " + e.getStackTrace().toString());
}
return;
}
public void testCopyToTarVirtualFileLevelOne() throws SystemMessageException {
public void testCopyToTarVirtualFileLevelOne() throws Exception {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
//create the source for testing first
@ -477,9 +449,6 @@ public class FileServiceArchiveTestDStore extends FileServiceArchiveTest {
IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir, sourceFolderName);
assertTrue(sourceFolder != null);
try
{
//Now, copy one of the folder from the sourceFolder into a first level virtual file in targetZipFile
//Get one of its first level children, and copy the folder to there.
IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(targetTarFile, "org");
@ -496,15 +465,8 @@ public class FileServiceArchiveTestDStore extends FileServiceArchiveTest {
int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FILE, TYPE_FILE};
checkFolderContents((IRemoteFile)theCopiedChild, childrenToCheck, typesToCheck);
}
catch (Exception e)
{
fail("Problem encountered: " + e.getStackTrace().toString());
}
return;
}
public void testCopyToTarVirtualFileLevelFour() throws SystemMessageException {
public void testCopyToTarVirtualFileLevelFour() throws Exception {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
//create the source for testing first
@ -519,9 +481,6 @@ public class FileServiceArchiveTestDStore extends FileServiceArchiveTest {
IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir, sourceFolderName);
assertTrue(sourceFolder != null);
try
{
//Get one of its fourth level children, and copy the folder to there.
IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(targetTarFile, "org");
assertTrue(firstLevelChild != null);
@ -543,15 +502,8 @@ public class FileServiceArchiveTestDStore extends FileServiceArchiveTest {
int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FILE, TYPE_FILE};
checkFolderContents((IRemoteFile)theCopiedChild, childrenToCheck, typesToCheck);
}
catch (Exception e)
{
fail("Problem encountered: " + e.getStackTrace().toString());
}
return;
}
public void testCopyTarVirtualFile() throws SystemMessageException {
public void testCopyTarVirtualFile() throws Exception {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
//create the source for testing first
@ -566,9 +518,6 @@ public class FileServiceArchiveTestDStore extends FileServiceArchiveTest {
IRemoteFile folder1 = createFileOrFolder(tempDirPath, folderName, true);
assertTrue(folder1 != null);
//Now, copy one of the folders from the tar file into folder1
try
{
//Get one of its fourth level children, and copy the folder to there.
IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(sourceTarFile, tarSourceFolderName1);
assertTrue(firstLevelChild != null);
@ -582,15 +531,8 @@ public class FileServiceArchiveTestDStore extends FileServiceArchiveTest {
int[] typesToCheck = {TYPE_FILE};
checkFolderContents((IRemoteFile)copiedVirtualFolder, contents, typesToCheck);
}
catch (Exception e)
{
fail("Problem encountered: " + e.getStackTrace().toString());
}
return;
}
public void testCopyTarVirtualFileLevelFour() throws SystemMessageException {
public void testCopyTarVirtualFileLevelFour() throws Exception {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
//create the source for testing first
@ -605,8 +547,6 @@ public class FileServiceArchiveTestDStore extends FileServiceArchiveTest {
IRemoteFile folder1 = createFileOrFolder(tempDirPath, folderName, true);
assertTrue(folder1 != null);
try
{
//Now, copy one of the level four folder from the zip file into folder1
//The folder is org/eclipse/dstore/core
//then, get directory "java" under org/eclipse/dstore/core
@ -638,16 +578,8 @@ public class FileServiceArchiveTestDStore extends FileServiceArchiveTest {
int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FOLDER, TYPE_FOLDER, TYPE_FOLDER, TYPE_FOLDER, TYPE_FILE};
checkFolderContents((IRemoteFile)copiedVirtualFolder, contents, typesToCheck);
}
catch (Exception e)
{
fail("Problem encountered: " + e.getStackTrace().toString());
}
return;
}
public void testMoveToTarArchiveFile() throws SystemMessageException {
public void testMoveToTarArchiveFile() throws Exception {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
//create the source for testing first
@ -656,21 +588,17 @@ public class FileServiceArchiveTestDStore extends FileServiceArchiveTest {
String tarTargetFileName = tarSourceFileName1;
IRemoteFile targetTarFile = (IRemoteFile)getChildFromFolder(tempDir, tarTargetFileName);
assertTrue(targetTarFile != null);
assertNotNull(targetTarFile);
String sourceFolderName = folderToCopyName3;
IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir, sourceFolderName);
assertTrue(sourceFolder != null);
assertNotNull(sourceFolder);
//Now, move sourceFolder into targetTarFile
try
{
fss.move(sourceFolder, targetTarFile, sourceFolder.getName(), mon);
Object theMovedChild = getChildFromFolder(targetTarFile, sourceFolderName);
assertTrue(theMovedChild != null);
assertNotNull(theMovedChild);
//Also make sure the copied child has the right contents.
String[] childrenToCheck = {"aaaaaaaa", "aaaab", "epdcdump01.hex12a", "RSE-SDK-2.0RC1.zip"};
@ -680,17 +608,10 @@ public class FileServiceArchiveTestDStore extends FileServiceArchiveTest {
//make sure the original folder is gone.
Object originalSource = getChildFromFolder(tempDir, sourceFolderName);
assertFalse(originalSource != null);
}
catch (Exception e)
{
fail("Problem encountered: " + e.getStackTrace().toString());
assertNull(originalSource);
}
return;
}
public void testMoveToTarVirtualFileLevelOne() throws SystemMessageException {
public void testMoveToTarVirtualFileLevelOne() throws Exception {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
//create the source for testing first
@ -705,9 +626,6 @@ public class FileServiceArchiveTestDStore extends FileServiceArchiveTest {
IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir, sourceFolderName);
assertTrue(sourceFolder != null);
try
{
//Now, copy one of the folder from the sourceFolder into a first level virtual file in targetZipFile
//Get one of its first level children, and copy the folder to there.
Object[] childrenOfTargetZipFile = fss.resolveFilterString(targetTarFile, null, mon);
@ -728,15 +646,8 @@ public class FileServiceArchiveTestDStore extends FileServiceArchiveTest {
Object originalSource = getChildFromFolder(tempDir, sourceFolderName);
assertFalse(originalSource != null);
}
catch (Exception e)
{
fail("Problem encountered: " + e.getStackTrace().toString());
}
return;
}
public void testMoveToVirtualFileLevelFour() throws SystemMessageException {
public void testMoveToVirtualFileLevelFour() throws Exception {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
//create the source for testing first
@ -751,9 +662,6 @@ public class FileServiceArchiveTestDStore extends FileServiceArchiveTest {
IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir, sourceFolderName);
assertTrue(sourceFolder != null);
try
{
//Get one of its fourth level children, and copy the folder to there.
IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(targetTarFile, "org");
assertTrue(firstLevelChild != null);
@ -780,15 +688,8 @@ public class FileServiceArchiveTestDStore extends FileServiceArchiveTest {
Object originalSource = getChildFromFolder(tempDir, sourceFolderName);
assertFalse(originalSource != null);
}
catch (Exception e)
{
fail("Problem encountered: " + e.getStackTrace().toString());
}
return;
}
public void testMoveTarVirtualFile() throws SystemMessageException {
public void testMoveTarVirtualFile() throws Exception {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
//create the source for testing first
@ -805,8 +706,6 @@ public class FileServiceArchiveTestDStore extends FileServiceArchiveTest {
assertTrue(folder1 != null);
//Now, copy one of the folder from the zip file into folder1
try
{
String movedFolderName = tarSourceFolderName1;
IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(sourceTarFile, tarSourceFolderName1);
assertTrue(firstLevelChild != null);
@ -824,16 +723,8 @@ public class FileServiceArchiveTestDStore extends FileServiceArchiveTest {
IRemoteFile tmp = (IRemoteFile)getChildFromFolder(sourceTarFile, tarSourceFolderName1);
assertTrue(tmp == null);
}
catch (Exception e)
{
fail("Problem encountered: " + e.getStackTrace().toString());
}
return;
}
public void testMoveTarVirtualFileLevelFour() throws SystemMessageException {
public void testMoveTarVirtualFileLevelFour() throws Exception {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
//create the source for testing first
@ -848,8 +739,6 @@ public class FileServiceArchiveTestDStore extends FileServiceArchiveTest {
IRemoteFile folder1 = createFileOrFolder(tempDirPath, folderName, true);
assertTrue(folder1 != null);
try
{
//Get one of its fourth level children, and move it to the folder
IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(sourceTarFile, "org");
assertTrue(firstLevelChild != null);
@ -877,16 +766,8 @@ public class FileServiceArchiveTestDStore extends FileServiceArchiveTest {
Object result = getChildFromFolder(thirdLevelChild, movedFolderName);
assertTrue(result == null); //we should not be able to find it.
}
catch (Exception e)
{
fail("Problem encountered: " + e.getStackTrace().toString());
}
return;
}
public void testRenameTarVirtualFile() throws SystemMessageException {
public void testRenameTarVirtualFile() throws Exception {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
//Create the zip file first.
@ -952,12 +833,9 @@ public class FileServiceArchiveTestDStore extends FileServiceArchiveTest {
//Check the result of rename
String[] newLevelTwoNamesToCheck = {"ccc.exe", "ddd1.bat", "some folder$"};
checkFolderContents(thisFolder, newLevelTwoNamesToCheck, levalTwoTypesToCheck);
return;
}
public void testDeleteTarVirtualFile() throws SystemMessageException {
public void testDeleteTarVirtualFile() throws Exception {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
//create the source for testing first
@ -1022,15 +900,12 @@ public class FileServiceArchiveTestDStore extends FileServiceArchiveTest {
//check the result
fileToToDelete = (IRemoteFile)getChildFromFolder(parentForFileToDelete, deleteFileName);
assertTrue(fileToToDelete == null);
return;
assertNull(fileToToDelete);
}
public void testCopyBatchToTarArchiveFile() throws SystemMessageException {
public void testCopyBatchToTarArchiveFile() throws Exception {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
createSourceTarFiles();
@ -1046,8 +921,6 @@ public class FileServiceArchiveTestDStore extends FileServiceArchiveTest {
assertTrue(sourceFolder != null);
//Now, copy one of the folder from the sourceFolder into copiedTargetZipFile
try
{
IRemoteFile[] sourceFiles = new IRemoteFile[3];
//Also add some of its children into the batch.
String childToCopyName1 = "aaaaaaaa";
@ -1084,19 +957,11 @@ public class FileServiceArchiveTestDStore extends FileServiceArchiveTest {
theCopiedChild = getChildFromFolder(targetTarFile, childToCopyName3);
assertTrue(theCopiedChild != null);
assertTrue(((IRemoteFile)theCopiedChild).isDirectory() != true);
}
catch (Exception e)
{
fail("Problem encountered: " + e.getStackTrace().toString());
}
return;
}
public void testCopyBatchToTarVirtualFileLevelFour() throws SystemMessageException {
public void testCopyBatchToTarVirtualFileLevelFour() throws Exception {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
createSourceTarFiles();
@ -1111,8 +976,6 @@ public class FileServiceArchiveTestDStore extends FileServiceArchiveTest {
IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir, sourceFolderName);
assertTrue(sourceFolder != null);
try
{
//Get one of its fourth level children, and copy the folder to there.
IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(targetTarFile, "org");
assertTrue(firstLevelChild != null);
@ -1160,19 +1023,11 @@ public class FileServiceArchiveTestDStore extends FileServiceArchiveTest {
theCopiedChild = getChildFromFolder(fourthLevelChild, childToCopyName3);
assertTrue(theCopiedChild != null);
assertTrue(((IRemoteFile)theCopiedChild).isDirectory() != true);
}
catch (Exception e)
{
fail("Problem encountered: " + e.getStackTrace().toString());
}
return;
}
public void testCopyBatchTarVirtualFileLevelFive() throws SystemMessageException {
public void testCopyBatchTarVirtualFileLevelFive() throws Exception {
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
createSourceTarFiles();
@ -1186,8 +1041,6 @@ public class FileServiceArchiveTestDStore extends FileServiceArchiveTest {
IRemoteFile folder1 = createFileOrFolder(tempDirPath, folderName, true);
assertTrue(folder1 != null);
try
{
//Get several of its fifth level children, and them into the folder.
IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(sourceTarFile, "org");
assertTrue(firstLevelChild != null);
@ -1228,13 +1081,5 @@ public class FileServiceArchiveTestDStore extends FileServiceArchiveTest {
Object copiedVirtualFolder3 = getChildFromFolder(folder1, thirdToCopyName);
assertTrue(copiedVirtualFolder3 != null);
}
catch (Exception e)
{
fail("Problem encountered: " + e.getStackTrace().toString());
}
return;
}
}

View file

@ -28,6 +28,9 @@ import org.eclipse.rse.ui.RSEUIPlugin;
public class FileServiceArchiveTestDStoreWindows extends FileServiceArchiveTest {
private boolean fPreference_ALERT_SSL;
private boolean fPreference_ALERT_NONSSL;
public static junit.framework.Test suite() {
TestSuite suite = new TestSuite("FileServiceArchiveTestDStoreWindows");
suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStoreWindows.class, "testCopyBatchToArchiveFile")); //$NON-NLS-1$
@ -55,34 +58,24 @@ public class FileServiceArchiveTestDStoreWindows extends FileServiceArchiveTest
return suite;
}
public void setUp() {
public void setUp() throws Exception {
super.setUp();
//We need to delay if it is first case run after a workspace startup
SYSTEM_TYPE_ID = IRSESystemType.SYSTEMTYPE_WINDOWS_ID;
SYSTEM_ADDRESS = "LOCALHOST";
SYSTEM_NAME = "LOCALHOST_ds";
//We need to delay if it is first case run after a workspace startup
if (!classBeenRunBefore)
{
IPreferenceStore store = RSEUIPlugin.getDefault().getPreferenceStore();
//Ensure that the SSL acknowledge dialog does not show up.
//We need to setDefault first in order to set the value of a preference.
IPreferenceStore store = RSEUIPlugin.getDefault().getPreferenceStore();
store.setDefault(ISystemPreferencesConstants.ALERT_SSL, ISystemPreferencesConstants.DEFAULT_ALERT_SSL);
store.setDefault(ISystemPreferencesConstants.ALERT_NONSSL, ISystemPreferencesConstants.DEFAULT_ALERT_NON_SSL);
fPreference_ALERT_SSL = store.getBoolean(ISystemPreferencesConstants.ALERT_SSL);
fPreference_ALERT_NONSSL = store.getBoolean(ISystemPreferencesConstants.ALERT_NONSSL);
store.setValue(ISystemPreferencesConstants.ALERT_SSL, false);
store.setValue(ISystemPreferencesConstants.ALERT_NONSSL, false);
try
{
System.out.println("need to sleep");
Thread.sleep(500);
}
catch (Exception e)
{
e.printStackTrace();
}
classBeenRunBefore = true;
}
IHost dstoreHost = getRemoteSystemConnection(SYSTEM_TYPE_ID, SYSTEM_ADDRESS, SYSTEM_NAME, "", "");
assertTrue(dstoreHost != null);
ISystemRegistry sr = SystemStartHere.getSystemRegistry();
@ -153,12 +146,11 @@ public class FileServiceArchiveTestDStoreWindows extends FileServiceArchiveTest
}
}
public void tearDown() {
try {
fss.delete(tempDir, mon);
} catch(SystemMessageException msg) {
assertFalse("Exception: "+msg.getLocalizedMessage(), true); //$NON-NLS-1$
}
public void tearDown() throws Exception {
IPreferenceStore store = RSEUIPlugin.getDefault().getPreferenceStore();
store.setValue(ISystemPreferencesConstants.ALERT_SSL, fPreference_ALERT_SSL);
store.setValue(ISystemPreferencesConstants.ALERT_NONSSL, fPreference_ALERT_NONSSL);
super.tearDown();
}
}

View file

@ -25,13 +25,22 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager;
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
import org.eclipse.rse.services.files.IFileService;
import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
import org.eclipse.rse.subsystems.files.core.subsystems.IVirtualRemoteFile;
import org.eclipse.rse.tests.core.connection.RSEBaseConnectionTestCase;
/**
* Base class for file subsystem / file service unit tests.
* Contains helper methods for test environment setup.
*/
public class FileServiceBaseTest extends RSEBaseConnectionTestCase {
protected IFileServiceSubSystem fss;
@ -40,11 +49,43 @@ public class FileServiceBaseTest extends RSEBaseConnectionTestCase {
protected IRemoteFile tempDir;
protected String tempDirPath;
protected IProgressMonitor mon = new NullProgressMonitor();
protected static boolean classBeenRunBefore = false;
public static int TYPE_FILE = 0;
public static int TYPE_FOLDER = 1;
public void setUp() throws Exception {
super.setUp();
IHost localHost = getLocalSystemConnection();
ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
ISubSystem[] ss = sr.getServiceSubSystems(localHost, IFileService.class);
for (int i=0; i<ss.length; i++) {
if (ss[i] instanceof IFileServiceSubSystem) {
fss = (IFileServiceSubSystem)ss[i];
fs = fss.getFileService();
}
}
localFss = fss; //Used for creating test source data.
assertNotNull(localFss);
//Create a temporary directory in My Home
IRemoteFile homeDirectory = fss.getRemoteFileObject(".", mon);
String baseFolderName = "rsetest";
String homeFolderName = homeDirectory.getAbsolutePath();
String testFolderName = FileServiceHelper.getRandomLocation(fss, homeFolderName, baseFolderName, mon);
tempDir = createFileOrFolder(homeFolderName, testFolderName, true);
tempDirPath = tempDir.getAbsolutePath();
}
public void tearDown() throws Exception {
try {
fss.delete(tempDir, mon);
} catch(SystemMessageException msg) {
//ensure that super.tearDown() can run
System.err.println("Exception on tearDown: "+msg.getLocalizedMessage()); //$NON-NLS-1$
}
super.tearDown();
}
public boolean isWindows() {
return fss.getHost().getSystemType().isWindows();
@ -61,12 +102,10 @@ public class FileServiceBaseTest extends RSEBaseConnectionTestCase {
}
public IRemoteFile copySourceFileOrFolder(String sourceFullName, String sourceName, String targetFolderFullName)
public IRemoteFile copySourceFileOrFolder(String sourceFullName, String sourceName, String targetFolderFullName) throws Exception
{
boolean ok = false;
IRemoteFile result = null;
try
{
IRemoteFile originalTargetArchiveFile = fss.getRemoteFileObject(sourceFullName, mon);
IRemoteFile targetFolder = fss.getRemoteFileObject(targetFolderFullName, mon);
ok = fss.copy(originalTargetArchiveFile, targetFolder, sourceName, mon);
@ -79,24 +118,13 @@ public class FileServiceBaseTest extends RSEBaseConnectionTestCase {
//is added to the DStore map. Otherwise, next time when query it, it will just created a
//default filter string. And the dstore server cannot handler it correctly.
fss.resolveFilterString(targetFolder, null, mon);
}
catch(Exception e)
{
return null;
}
return result;
}
public IRemoteFile createFileOrFolder(String targetFolderName, String fileOrFolderName, boolean isFolder)
public IRemoteFile createFileOrFolder(String targetFolderName, String fileOrFolderName, boolean isFolder) throws Exception
{
IRemoteFile result = null;
try
{
System.out.println("targetFolderName is " + targetFolderName);
if (fss == null)
{
System.out.println("fss is null ");
}
System.out.println("createFileOrFolder: targetFolderName is " + targetFolderName);
IRemoteFile targetFolder = fss.getRemoteFileObject(targetFolderName, mon);
//fss.resolveFilterString(targetFolder, null, mon);
String fileOrFolderAbsName = getNewAbsoluteName(targetFolder, fileOrFolderName);
@ -113,22 +141,14 @@ public class FileServiceBaseTest extends RSEBaseConnectionTestCase {
//is added to the DStore map. Otherwise, next time when query it, it will just created a
//default filter string. And the dstore server cannot handler it correctly.
fss.resolveFilterString(targetFolder, null, mon);
}
catch (Exception e)
{
e.printStackTrace();
return null;
}
return result;
}
public Object getChildFromFolder(IRemoteFile folderToCheck, String childName)
public Object getChildFromFolder(IRemoteFile folderToCheck, String childName) throws Exception
{
//then check the result of copy
Object[] children = null;
Object foundChild = null;
try
{
children = fss.resolveFilterString(folderToCheck, null, mon);
for (int i=0; i<children.length; i++)
{
@ -138,17 +158,10 @@ public class FileServiceBaseTest extends RSEBaseConnectionTestCase {
foundChild = children[i];
}
}
}
catch (Exception e)
{
foundChild = null;
}
return foundChild;
}
public void checkFolderContents(IRemoteFile folderToCheck, String[] names, int[] types)
{
try
public void checkFolderContents(IRemoteFile folderToCheck, String[] names, int[] types) throws Exception
{
//the folder returned by the create API did not get the right attributes.
//We need to call getRemoteFileObject to get its attribute updated.
@ -184,11 +197,6 @@ public class FileServiceBaseTest extends RSEBaseConnectionTestCase {
}
}
}
catch (Exception e)
{
fail("Problem encountered: " + e.getStackTrace().toString());
}
}
protected static String getNewAbsoluteName(IRemoteFile parentFolder, String newName)
{

View file

@ -18,9 +18,9 @@ import java.io.IOException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.core.model.SystemStartHere;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
import org.eclipse.rse.services.files.IFileService;
@ -37,9 +37,10 @@ public class FileServiceTest extends RSEBaseConnectionTestCase {
private String tempDirPath;
private IProgressMonitor mon = new NullProgressMonitor();
public void setUp() {
public void setUp() throws Exception {
super.setUp();
IHost localHost = getLocalSystemConnection();
ISystemRegistry sr = SystemStartHere.getSystemRegistry();
ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
ISubSystem[] ss = sr.getServiceSubSystems(localHost, IFileService.class);
for (int i=0; i<ss.length; i++) {
if (ss[i] instanceof IFileServiceSubSystem) {
@ -57,12 +58,14 @@ public class FileServiceTest extends RSEBaseConnectionTestCase {
}
}
public void tearDown() {
public void tearDown() throws Exception {
try {
fs.delete(tempDir.getParent(), tempDir.getName(), mon);
} catch(SystemMessageException msg) {
assertFalse("Exception: "+msg.getLocalizedMessage(), true); //$NON-NLS-1$
//ensure that super.tearDown() can run
System.err.println("Exception on tearDown: "+msg.getLocalizedMessage()); //$NON-NLS-1$
}
super.tearDown();
}
public boolean isWindows() {

View file

@ -1,36 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.pde.ui.JunitLaunchConfig">
<stringAttribute key="product" value="org.eclipse.sdk.ide"/>
<stringAttribute key="bootstrap" value=""/>
<booleanAttribute key="useProduct" value="true"/>
<booleanAttribute key="tracing" value="false"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
<booleanAttribute key="automaticValidate" value="false"/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<booleanAttribute key="automaticAdd" value="true"/>
<stringAttribute key="checked" value="[NONE]"/>
<stringAttribute key="location" value="${workspace_loc}/../junit-test-workspace"/>
<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/>
<booleanAttribute key="clearws" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.rse.tests.RSECombinedTestSuite"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-debug -clean"/>
<stringAttribute key="pde.version" value="3.3"/>
<stringAttribute key="templateConfig" value="${target_home}\configuration\config.ini"/>
<booleanAttribute key="default" value="true"/>
<booleanAttribute key="clearConfig" value="true"/>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
<booleanAttribute key="useDefaultConfigArea" value="false"/>
<booleanAttribute key="useDefaultConfig" value="true"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.rse.tests"/>
<booleanAttribute key="askclear" value="false"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/org.eclipse.rse.tests"/>
</listAttribute>
<booleanAttribute key="automaticAdd" value="true"/>
<booleanAttribute key="automaticValidate" value="false"/>
<stringAttribute key="bootstrap" value=""/>
<stringAttribute key="checked" value="[NONE]"/>
<booleanAttribute key="clearConfig" value="true"/>
<booleanAttribute key="clearws" value="true"/>
<booleanAttribute key="clearwslog" value="false"/>
<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/>
<booleanAttribute key="default" value="true"/>
<booleanAttribute key="includeOptional" value="true"/>
<stringAttribute key="location" value="${workspace_loc}/../junit-test-workspace"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/org.eclipse.rse.tests/src/org/eclipse/rse/tests/RSECombinedTestSuite.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.rse.tests.RSECombinedTestSuite"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -debug -clean"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.rse.tests"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-ea -esa -Dcom.sun.management.jmxremote"/>
<stringAttribute key="pde.version" value="3.3"/>
<stringAttribute key="product" value="org.eclipse.sdk.ide"/>
<stringAttribute key="templateConfig" value="${target_home}\configuration\config.ini"/>
<booleanAttribute key="tracing" value="false"/>
<booleanAttribute key="useDefaultConfig" value="true"/>
<booleanAttribute key="useDefaultConfigArea" value="false"/>
<booleanAttribute key="useProduct" value="true"/>
</launchConfiguration>