mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-14 12:35:22 +02:00
[199854] Fix regressions in unit tests
This commit is contained in:
parent
2ffdc02079
commit
2561ea2cfd
2 changed files with 51 additions and 47 deletions
|
@ -1538,19 +1538,20 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
||||||
if (isVirtual || isArchive)
|
if (isVirtual || isArchive)
|
||||||
{
|
{
|
||||||
moveByCopy(srcParent, srcName, tgtParent, tgtName, monitor);
|
moveByCopy(srcParent, srcName, tgtParent, tgtName, monitor);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
rename("", src, tgt, monitor); //$NON-NLS-1$
|
rename("", src, tgt, monitor); //$NON-NLS-1$
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
catch (SystemMessageException e)
|
catch (SystemMessageException e)
|
||||||
{
|
{
|
||||||
moveByCopy(srcParent, srcName, tgtParent, tgtName, monitor);
|
moveByCopy(srcParent, srcName, tgtParent, tgtName, monitor);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
// movedOk should never be false otherwise the last DataElement status was null
|
|
||||||
moveByCopy(srcParent, srcName, tgtParent, tgtName, monitor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2038,6 +2039,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
||||||
// first modify the source attribute to temporarily be the date field
|
// first modify the source attribute to temporarily be the date field
|
||||||
de.setAttribute(DE.A_SOURCE, timestamp + ""); //$NON-NLS-1$
|
de.setAttribute(DE.A_SOURCE, timestamp + ""); //$NON-NLS-1$
|
||||||
ds.command(setCmd, de, true);
|
ds.command(setCmd, de, true);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID,
|
throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID,
|
||||||
|
@ -2068,6 +2070,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
||||||
{
|
{
|
||||||
throw new RemoteFileIOException(e);
|
throw new RemoteFileIOException(e);
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID,
|
throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID,
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007, 2008 IBM Corporation and others.
|
* Copyright (c) 2007, 2008 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* 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.internal.localstore/LocalStoreTest (Copyright IBM)>
|
||||||
* - <copied code from org.eclipse.core.tests.harness/CoreTest (Copyright IBM)>
|
* - <copied code from org.eclipse.core.tests.harness/CoreTest (Copyright IBM)>
|
||||||
|
@ -52,7 +52,7 @@ public class FileServiceBaseTest extends RSEBaseConnectionTestCase {
|
||||||
protected IRemoteFile tempDir;
|
protected IRemoteFile tempDir;
|
||||||
protected String tempDirPath;
|
protected String tempDirPath;
|
||||||
protected IProgressMonitor mon = new NullProgressMonitor();
|
protected IProgressMonitor mon = new NullProgressMonitor();
|
||||||
|
|
||||||
public static int TYPE_FILE = 0;
|
public static int TYPE_FILE = 0;
|
||||||
public static int TYPE_FOLDER = 1;
|
public static int TYPE_FOLDER = 1;
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ public class FileServiceBaseTest extends RSEBaseConnectionTestCase {
|
||||||
public FileServiceBaseTest(String name) {
|
public FileServiceBaseTest(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
setupFileSubSystem();
|
setupFileSubSystem();
|
||||||
|
@ -82,7 +82,7 @@ public class FileServiceBaseTest extends RSEBaseConnectionTestCase {
|
||||||
fail("Problem encountered: " + e.getStackTrace().toString());
|
fail("Problem encountered: " + e.getStackTrace().toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
try {
|
try {
|
||||||
fss.delete(tempDir, mon);
|
fss.delete(tempDir, mon);
|
||||||
|
@ -92,11 +92,11 @@ public class FileServiceBaseTest extends RSEBaseConnectionTestCase {
|
||||||
}
|
}
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isWindows() {
|
public boolean isWindows() {
|
||||||
return fss.getHost().getSystemType().isWindows();
|
return fss.getHost().getSystemType().isWindows();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTestFileName() {
|
public String getTestFileName() {
|
||||||
//Return a filename for testing that exposes all characters valid on the file system
|
//Return a filename for testing that exposes all characters valid on the file system
|
||||||
if (!isWindows()) {
|
if (!isWindows()) {
|
||||||
|
@ -106,13 +106,13 @@ public class FileServiceBaseTest extends RSEBaseConnectionTestCase {
|
||||||
//Fallback: Windows TODO: test unicode
|
//Fallback: Windows TODO: test unicode
|
||||||
return "a !@#${a}'` file%^&()_ =[]~+-;,."; //$NON-NLS-1$
|
return "a !@#${a}'` file%^&()_ =[]~+-;,."; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public IRemoteFile copySourceFileOrFolder(String sourceFullName, String sourceName, String targetFolderFullName) throws Exception
|
public IRemoteFile copySourceFileOrFolder(String sourceFullName, String sourceName, String targetFolderFullName) throws Exception
|
||||||
{
|
{
|
||||||
boolean ok = false;
|
boolean ok = false;
|
||||||
IRemoteFile result = null;
|
IRemoteFile result = null;
|
||||||
IRemoteFile originalTargetArchiveFile = fss.getRemoteFileObject(sourceFullName, mon);
|
IRemoteFile originalTargetArchiveFile = fss.getRemoteFileObject(sourceFullName, mon);
|
||||||
IRemoteFile targetFolder = fss.getRemoteFileObject(targetFolderFullName, mon);
|
IRemoteFile targetFolder = fss.getRemoteFileObject(targetFolderFullName, mon);
|
||||||
ok = fss.copy(originalTargetArchiveFile, targetFolder, sourceName, mon);
|
ok = fss.copy(originalTargetArchiveFile, targetFolder, sourceName, mon);
|
||||||
if (ok)
|
if (ok)
|
||||||
|
@ -121,24 +121,24 @@ public class FileServiceBaseTest extends RSEBaseConnectionTestCase {
|
||||||
result = fss.getRemoteFileObject(getNewAbsoluteName(targetFolder, sourceName), mon);
|
result = fss.getRemoteFileObject(getNewAbsoluteName(targetFolder, sourceName), mon);
|
||||||
}
|
}
|
||||||
//Need to call resolveFilterString of the parent to make sure the newly copied child
|
//Need to call resolveFilterString of the parent to make sure the newly copied child
|
||||||
//is added to the DStore map. Otherwise, next time when query it, it will just created a
|
//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.
|
//default filter string. And the dstore server cannot handler it correctly.
|
||||||
fss.resolveFilterString(targetFolder, null, mon);
|
fss.resolveFilterString(targetFolder, null, mon);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IRemoteFile createFileOrFolder(String targetFolderName, String fileOrFolderName, boolean isFolder) throws Exception
|
public IRemoteFile createFileOrFolder(String targetFolderName, String fileOrFolderName, boolean isFolder) throws Exception
|
||||||
{
|
{
|
||||||
return createFileOrFolder(fss, targetFolderName, fileOrFolderName, isFolder);
|
return createFileOrFolder(fss, targetFolderName, fileOrFolderName, isFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IRemoteFile createFileOrFolder(IFileServiceSubSystem inputFss, String targetFolderName, String fileOrFolderName, boolean isFolder) throws Exception
|
public IRemoteFile createFileOrFolder(IFileServiceSubSystem inputFss, String targetFolderName, String fileOrFolderName, boolean isFolder) throws Exception
|
||||||
{
|
{
|
||||||
IRemoteFile result = null;
|
IRemoteFile result = null;
|
||||||
System.out.println("createFileOrFolder: targetFolderName is " + targetFolderName);
|
System.out.println("createFileOrFolder: targetFolderName is " + targetFolderName);
|
||||||
IRemoteFile targetFolder = inputFss.getRemoteFileObject(targetFolderName, mon);
|
IRemoteFile targetFolder = inputFss.getRemoteFileObject(targetFolderName, mon);
|
||||||
String fileOrFolderAbsName = getNewAbsoluteName(targetFolder, fileOrFolderName);
|
String fileOrFolderAbsName = getNewAbsoluteName(targetFolder, fileOrFolderName);
|
||||||
IRemoteFile newFileOrFolderPath = inputFss.getRemoteFileObject(fileOrFolderAbsName, mon);
|
IRemoteFile newFileOrFolderPath = inputFss.getRemoteFileObject(fileOrFolderAbsName, mon);
|
||||||
if (isFolder)
|
if (isFolder)
|
||||||
{
|
{
|
||||||
result = inputFss.createFolder(newFileOrFolderPath, mon);
|
result = inputFss.createFolder(newFileOrFolderPath, mon);
|
||||||
|
@ -148,17 +148,17 @@ public class FileServiceBaseTest extends RSEBaseConnectionTestCase {
|
||||||
result = inputFss.createFile(newFileOrFolderPath, mon);
|
result = inputFss.createFile(newFileOrFolderPath, mon);
|
||||||
}
|
}
|
||||||
//Need to call resolveFilterString of the parent to make sure the newly created child
|
//Need to call resolveFilterString of the parent to make sure the newly created child
|
||||||
//is added to the DStore map. Otherwise, next time when query it, it will just created a
|
//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.
|
//default filter string. And the dstore server cannot handler it correctly.
|
||||||
inputFss.resolveFilterString(targetFolder, null, mon);
|
inputFss.resolveFilterString(targetFolder, null, mon);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getChildFromFolder(IRemoteFile folderToCheck, String childName) throws Exception
|
public Object getChildFromFolder(IRemoteFile folderToCheck, String childName) throws Exception
|
||||||
{
|
{
|
||||||
return getChildFromFolder(fss, folderToCheck, childName);
|
return getChildFromFolder(fss, folderToCheck, childName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getChildFromFolder(IFileServiceSubSystem inputFss, IRemoteFile folderToCheck, String childName) throws Exception
|
public Object getChildFromFolder(IFileServiceSubSystem inputFss, IRemoteFile folderToCheck, String childName) throws Exception
|
||||||
{
|
{
|
||||||
//then check the result of copy
|
//then check the result of copy
|
||||||
|
@ -171,16 +171,17 @@ public class FileServiceBaseTest extends RSEBaseConnectionTestCase {
|
||||||
if (thisName.equals(childName))
|
if (thisName.equals(childName))
|
||||||
{
|
{
|
||||||
foundChild = children[i];
|
foundChild = children[i];
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return foundChild;
|
return foundChild;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkFolderContents(IRemoteFile folderToCheck, String[] names, int[] types) throws Exception
|
public void checkFolderContents(IRemoteFile folderToCheck, String[] names, int[] types) throws Exception
|
||||||
{
|
{
|
||||||
checkFolderContents(fss, folderToCheck, names, types);
|
checkFolderContents(fss, folderToCheck, names, types);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkFolderContents(IFileServiceSubSystem inputFss, IRemoteFile folderToCheck, String[] names, int[] types) throws Exception
|
public void checkFolderContents(IFileServiceSubSystem inputFss, IRemoteFile folderToCheck, String[] names, int[] types) throws Exception
|
||||||
{
|
{
|
||||||
//the folder returned by the create API did not get the right attributes.
|
//the folder returned by the create API did not get the right attributes.
|
||||||
|
@ -217,32 +218,32 @@ public class FileServiceBaseTest extends RSEBaseConnectionTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static String getNewAbsoluteName(IRemoteFile parentFolder, String newName)
|
protected static String getNewAbsoluteName(IRemoteFile parentFolder, String newName)
|
||||||
{
|
{
|
||||||
String newAbsName = null;
|
String newAbsName = null;
|
||||||
char sep = parentFolder.getSeparatorChar();
|
char sep = parentFolder.getSeparatorChar();
|
||||||
String parentFolderPath = parentFolder.getAbsolutePath();
|
String parentFolderPath = parentFolder.getAbsolutePath();
|
||||||
|
|
||||||
// hack by Mike to allow virtual files and folders.
|
// hack by Mike to allow virtual files and folders.
|
||||||
if (parentFolder instanceof IVirtualRemoteFile)
|
if (parentFolder instanceof IVirtualRemoteFile)
|
||||||
{
|
{
|
||||||
sep = '/';
|
sep = '/';
|
||||||
}
|
}
|
||||||
else if (parentFolder.isArchive())
|
else if (parentFolder.isArchive())
|
||||||
{
|
{
|
||||||
sep = '/';
|
sep = '/';
|
||||||
parentFolderPath = parentFolderPath + ArchiveHandlerManager.VIRTUAL_SEPARATOR;
|
parentFolderPath = parentFolderPath + ArchiveHandlerManager.VIRTUAL_SEPARATOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((parentFolderPath.length()==1) && (parentFolderPath.charAt(0)=='/') &&
|
if ((parentFolderPath.length()==1) && (parentFolderPath.charAt(0)=='/') &&
|
||||||
(parentFolderPath.charAt(0)==sep))
|
(parentFolderPath.charAt(0)==sep))
|
||||||
newAbsName = sep + newName;
|
newAbsName = sep + newName;
|
||||||
else
|
else
|
||||||
newAbsName = parentFolderPath + sep + newName;
|
newAbsName = parentFolderPath + sep + newName;
|
||||||
return newAbsName;
|
return newAbsName;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// <copied code from org.eclipse.core.tests.internal.localstore/LocalStoreTest (Copyright IBM)>
|
// <copied code from org.eclipse.core.tests.internal.localstore/LocalStoreTest (Copyright IBM)>
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -262,12 +263,12 @@ public class FileServiceBaseTest extends RSEBaseConnectionTestCase {
|
||||||
protected IFileStore createDir(String string, boolean clear) throws CoreException {
|
protected IFileStore createDir(String string, boolean clear) throws CoreException {
|
||||||
return createDir(EFS.getFileSystem(EFS.SCHEME_FILE).getStore(new Path(string)), clear);
|
return createDir(EFS.getFileSystem(EFS.SCHEME_FILE).getStore(new Path(string)), clear);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a file with random content. If a resource exists in the same path,
|
* Create a file with random content. If a resource exists in the same path,
|
||||||
* the resource is deleted.
|
* the resource is deleted.
|
||||||
* <copied code from org.eclipse.core.tests.internal.localstore/LocalStoreTest (Copyright IBM)>
|
* <copied code from org.eclipse.core.tests.internal.localstore/LocalStoreTest (Copyright IBM)>
|
||||||
*
|
*
|
||||||
* @param target the file to create
|
* @param target the file to create
|
||||||
* @param content content of the new file
|
* @param content content of the new file
|
||||||
* @throws CoreException in case of failure
|
* @throws CoreException in case of failure
|
||||||
|
@ -279,7 +280,7 @@ public class FileServiceBaseTest extends RSEBaseConnectionTestCase {
|
||||||
IFileInfo info = target.fetchInfo();
|
IFileInfo info = target.fetchInfo();
|
||||||
assertTrue(info.exists() && !info.isDirectory());
|
assertTrue(info.exists() && !info.isDirectory());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <copied code from org.eclipse.core.tests.harness/CoreTest (Copyright IBM)>
|
* <copied code from org.eclipse.core.tests.harness/CoreTest (Copyright IBM)>
|
||||||
* Asserts that a stream closes successfully. Null streams
|
* Asserts that a stream closes successfully. Null streams
|
||||||
|
@ -296,7 +297,7 @@ public class FileServiceBaseTest extends RSEBaseConnectionTestCase {
|
||||||
fail("Failed close in assertClose");
|
fail("Failed close in assertClose");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <copied code from org.eclipse.core.tests.harness/CoreTest (Copyright IBM)>
|
* <copied code from org.eclipse.core.tests.harness/CoreTest (Copyright IBM)>
|
||||||
* Return an input stream with some the specified text to use
|
* Return an input stream with some the specified text to use
|
||||||
|
@ -307,7 +308,7 @@ public class FileServiceBaseTest extends RSEBaseConnectionTestCase {
|
||||||
public InputStream getContents(String text) {
|
public InputStream getContents(String text) {
|
||||||
return new ByteArrayInputStream(text.getBytes());
|
return new ByteArrayInputStream(text.getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <copied code from org.eclipse.core.tests.resources/ResourceTest.java (Copyright IBM) >
|
* <copied code from org.eclipse.core.tests.resources/ResourceTest.java (Copyright IBM) >
|
||||||
*
|
*
|
||||||
|
@ -335,12 +336,12 @@ public class FileServiceBaseTest extends RSEBaseConnectionTestCase {
|
||||||
assertClose(b);
|
assertClose(b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy the data from the input stream to the output stream.
|
* Copy the data from the input stream to the output stream.
|
||||||
* Close both streams when finished.
|
* Close both streams when finished.
|
||||||
* <copied code from org.eclipse.core.tests.harness/CoreTest (Copyright IBM)>
|
* <copied code from org.eclipse.core.tests.harness/CoreTest (Copyright IBM)>
|
||||||
*
|
*
|
||||||
* @param input input stream
|
* @param input input stream
|
||||||
* @param output output stream
|
* @param output output stream
|
||||||
*/
|
*/
|
||||||
|
@ -359,12 +360,12 @@ public class FileServiceBaseTest extends RSEBaseConnectionTestCase {
|
||||||
assertTrue(e.toString(), false);
|
assertTrue(e.toString(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return String with some random text to use
|
* Return String with some random text to use
|
||||||
* as contents for a file resource.
|
* as contents for a file resource.
|
||||||
* <copied code from org.eclipse.core.tests.harness/CoreTest (Copyright IBM)>
|
* <copied code from org.eclipse.core.tests.harness/CoreTest (Copyright IBM)>
|
||||||
*
|
*
|
||||||
* @return the result random string
|
* @return the result random string
|
||||||
*/
|
*/
|
||||||
protected String getRandomString() {
|
protected String getRandomString() {
|
||||||
|
@ -393,14 +394,14 @@ public class FileServiceBaseTest extends RSEBaseConnectionTestCase {
|
||||||
return "these are my contents";
|
return "these are my contents";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup the file subsystem used for this testcase
|
* Setup the file subsystem used for this testcase
|
||||||
*/
|
*/
|
||||||
protected void setupFileSubSystem()
|
protected void setupFileSubSystem()
|
||||||
{
|
{
|
||||||
IHost localHost = getLocalSystemConnection();
|
IHost localHost = getLocalSystemConnection();
|
||||||
ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
|
ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
|
||||||
ISubSystem[] ss = sr.getServiceSubSystems(localHost, IFileService.class);
|
ISubSystem[] ss = sr.getServiceSubSystems(localHost, IFileService.class);
|
||||||
for (int i=0; i<ss.length; i++) {
|
for (int i=0; i<ss.length; i++) {
|
||||||
if (ss[i] instanceof IFileServiceSubSystem) {
|
if (ss[i] instanceof IFileServiceSubSystem) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue