mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-09 01:05:38 +02:00
[tests] Add testGetRootProperties to FileServiceTest and make it run on local, ssh, ftpWindows, ftpLinux, dstoreLinux, dstoreWindows
This commit is contained in:
parent
1f425a6662
commit
f02280993f
1 changed files with 122 additions and 55 deletions
|
@ -11,61 +11,101 @@
|
||||||
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
|
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
|
||||||
* Martin Oberhuber (Wind River) - [186640] Add IRSESystemType.testProperty()
|
* Martin Oberhuber (Wind River) - [186640] Add IRSESystemType.testProperty()
|
||||||
* Martin Oberhuber (Wind River) - organize, enable and tag test cases
|
* Martin Oberhuber (Wind River) - organize, enable and tag test cases
|
||||||
|
* Martin Oberhuber (Wind River) - [235360][ftp][ssh] Return proper "Root" IHostFile
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.rse.tests.subsystems.files;
|
package org.eclipse.rse.tests.subsystems.files;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
|
import junit.framework.Test;
|
||||||
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
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.IHost;
|
||||||
import org.eclipse.rse.core.model.ISystemRegistry;
|
|
||||||
import org.eclipse.rse.core.subsystems.ISubSystem;
|
|
||||||
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
|
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
|
||||||
import org.eclipse.rse.services.files.IFileService;
|
import org.eclipse.rse.services.files.IFileService;
|
||||||
import org.eclipse.rse.services.files.IHostFile;
|
import org.eclipse.rse.services.files.IHostFile;
|
||||||
|
import org.eclipse.rse.subsystems.files.core.model.RemoteFileUtility;
|
||||||
import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
|
import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
|
||||||
|
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||||
import org.eclipse.rse.tests.RSETestsPlugin;
|
import org.eclipse.rse.tests.RSETestsPlugin;
|
||||||
import org.eclipse.rse.tests.core.connection.RSEBaseConnectionTestCase;
|
import org.eclipse.rse.tests.core.connection.RSEBaseConnectionTestCase;
|
||||||
|
|
||||||
public class FileServiceTest extends RSEBaseConnectionTestCase {
|
public class FileServiceTest extends RSEBaseConnectionTestCase {
|
||||||
|
|
||||||
|
private String fPropertiesFileName;
|
||||||
|
// For testing the test: verify methods on Local
|
||||||
|
public static String fDefaultPropertiesFile = "local.properties";
|
||||||
|
|
||||||
private IFileServiceSubSystem fss;
|
private IFileServiceSubSystem fss;
|
||||||
private IFileService fs;
|
private IFileService fs;
|
||||||
private File tempDir;
|
private IRemoteFile fHomeDirectory;
|
||||||
|
private IRemoteFile remoteTempDir;
|
||||||
private String tempDirPath;
|
private String tempDirPath;
|
||||||
private IProgressMonitor mon = new NullProgressMonitor();
|
private IProgressMonitor mon = new NullProgressMonitor();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor with specific test name.
|
||||||
|
*
|
||||||
|
* @param name test to execute
|
||||||
|
*/
|
||||||
|
public FileServiceTest(String name) {
|
||||||
|
this(name, fDefaultPropertiesFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor with connection type and specific test name.
|
||||||
|
*
|
||||||
|
* @param name test to execute
|
||||||
|
* @param propertiesFileName file with connection properties to use
|
||||||
|
*/
|
||||||
|
public FileServiceTest(String name, String propertiesFileName) {
|
||||||
|
super(name);
|
||||||
|
fPropertiesFileName = propertiesFileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Test suite() {
|
||||||
|
String baseName = FileServiceTest.class.getName();
|
||||||
|
TestSuite suite = new TestSuite(baseName);
|
||||||
|
|
||||||
|
// // Add a test suite for each connection type
|
||||||
|
String[] connTypes = { "local", "ssh", "ftpWindows", "ftp", "linux", "windows" };
|
||||||
|
//String[] connTypes = { "local" };
|
||||||
|
// String[] connTypes = { "ssh" };
|
||||||
|
|
||||||
|
for (int i = 0; i < connTypes.length; i++) {
|
||||||
|
String suiteName = connTypes[i] == null ? "EFS" : connTypes[i];
|
||||||
|
String propFileName = connTypes[i] == null ? null : connTypes[i] + "Connection.properties";
|
||||||
|
TestSuite subSuite = new TestSuite(baseName + "." + suiteName);
|
||||||
|
Method[] m = FileServiceTest.class.getMethods();
|
||||||
|
for (int j = 0; j < m.length; j++) {
|
||||||
|
String testName = m[j].getName();
|
||||||
|
if (testName.startsWith("test")) {
|
||||||
|
subSuite.addTest(new FileServiceTest(testName, propFileName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
suite.addTest(subSuite);
|
||||||
|
}
|
||||||
|
return suite;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
IHost localHost = getLocalSystemConnection();
|
IHost host = getHost(fPropertiesFileName);
|
||||||
ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
|
fss = (IFileServiceSubSystem) RemoteFileUtility.getFileSubSystem(host);
|
||||||
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();
|
fs = fss.getFileService();
|
||||||
}
|
fss.checkIsConnected(getDefaultProgressMonitor());
|
||||||
}
|
fHomeDirectory = fss.getRemoteFileObject(".", getDefaultProgressMonitor());
|
||||||
try {
|
remoteTempDir = fss.getRemoteFileObject(fHomeDirectory, "rsetest" + System.currentTimeMillis(), getDefaultProgressMonitor());
|
||||||
tempDir = File.createTempFile("rsetest","dir"); //$NON-NLS-1$ //$NON-NLS-2$
|
fss.createFolder(remoteTempDir, getDefaultProgressMonitor());
|
||||||
assertTrue(tempDir.delete());
|
tempDirPath = remoteTempDir.getAbsolutePath();
|
||||||
assertTrue(tempDir.mkdir());
|
|
||||||
tempDirPath = tempDir.getAbsolutePath();
|
|
||||||
} catch(IOException ioe) {
|
|
||||||
assertTrue("Exception creating temp dir", false); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
try {
|
fss.delete(remoteTempDir, getDefaultProgressMonitor());
|
||||||
fs.delete(tempDir.getParent(), tempDir.getName(), mon);
|
|
||||||
} catch(SystemMessageException msg) {
|
|
||||||
//ensure that super.tearDown() can run
|
|
||||||
System.err.println("Exception on tearDown: "+msg.getLocalizedMessage()); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +120,33 @@ public class FileServiceTest extends RSEBaseConnectionTestCase {
|
||||||
return "a !@#${a}\"\' fi\tle\b\\%^&*()?_ =[]~+-'`;:,.|<>"; //$NON-NLS-1$
|
return "a !@#${a}\"\' fi\tle\b\\%^&*()?_ =[]~+-'`;:,.|<>"; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
//Fallback: Windows TODO: test unicode
|
//Fallback: Windows TODO: test unicode
|
||||||
return "a !@#${a}'` file%^&()_ =[]~+-;,."; //$NON-NLS-1$
|
//Note: The trailing dot ('.') is really unfair on Windows because the file
|
||||||
|
//system doesn't seem to ever store trailing dots
|
||||||
|
//return "a !@#${a}'` file%^&()_ =[]~+-;,."; //$NON-NLS-1$
|
||||||
|
return "a !@#${a}'` file%^&()_ =[]~+-;.,"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testGetRootProperties() throws Exception {
|
||||||
|
//-test-author-:MartinOberhuber
|
||||||
|
IHostFile[] roots = fs.getRoots(new NullProgressMonitor());
|
||||||
|
assertNotNull(roots);
|
||||||
|
assertTrue(roots.length > 0);
|
||||||
|
for (int i = 0; i < roots.length; i++) {
|
||||||
|
assertTrue(roots[i].isRoot());
|
||||||
|
assertTrue(roots[i].exists());
|
||||||
|
assertNull(roots[i].getParentPath());
|
||||||
|
String rootName = roots[i].getName();
|
||||||
|
assertNotNull(rootName);
|
||||||
|
System.out.println(rootName);
|
||||||
|
IHostFile newHf = fs.getFile(null, rootName, new NullProgressMonitor());
|
||||||
|
assertTrue(newHf.isRoot());
|
||||||
|
assertTrue(newHf.exists());
|
||||||
|
assertEquals(newHf.getName(), rootName);
|
||||||
|
newHf = fs.getFile("", rootName, new NullProgressMonitor());
|
||||||
|
assertTrue(newHf.isRoot());
|
||||||
|
assertTrue(newHf.exists());
|
||||||
|
assertEquals(newHf.getName(), rootName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCaseSensitive() {
|
public void testCaseSensitive() {
|
||||||
|
@ -88,13 +154,13 @@ public class FileServiceTest extends RSEBaseConnectionTestCase {
|
||||||
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCaseSensitive")) return; //$NON-NLS-1$
|
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCaseSensitive")) return; //$NON-NLS-1$
|
||||||
|
|
||||||
if (isWindows()) {
|
if (isWindows()) {
|
||||||
assertFalse(fss.getSubSystemConfiguration().isCaseSensitive());
|
assertFalse(fs.isCaseSensitive());
|
||||||
assertFalse(fss.isCaseSensitive());
|
assertFalse(fss.isCaseSensitive());
|
||||||
assertFalse(fs.isCaseSensitive()); //FAIL due to bug 168586
|
assertFalse(fss.getSubSystemConfiguration().isCaseSensitive());
|
||||||
} else {
|
} else {
|
||||||
assertTrue(fss.getSubSystemConfiguration().isCaseSensitive());
|
|
||||||
assertTrue(fss.isCaseSensitive()); //FAIL due to bug 168596
|
|
||||||
assertTrue(fs.isCaseSensitive());
|
assertTrue(fs.isCaseSensitive());
|
||||||
|
assertTrue(fss.isCaseSensitive());
|
||||||
|
assertTrue(fss.getSubSystemConfiguration().isCaseSensitive());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,11 +178,12 @@ public class FileServiceTest extends RSEBaseConnectionTestCase {
|
||||||
assertEquals(hf.getSize(), 0);
|
assertEquals(hf.getSize(), 0);
|
||||||
long modDate = hf.getModifiedDate();
|
long modDate = hf.getModifiedDate();
|
||||||
assertTrue(modDate > 0);
|
assertTrue(modDate > 0);
|
||||||
|
if (fss.getHost().getSystemType().isLocal()) {
|
||||||
File theFile = new File(tempDir, testName);
|
File theFile = new File(remoteTempDir.getAbsolutePath(), testName);
|
||||||
assertTrue(theFile.exists());
|
assertTrue(theFile.exists());
|
||||||
assertTrue(modDate == theFile.lastModified());
|
assertTrue(modDate == theFile.lastModified());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void testCreateCaseSensitive() throws SystemMessageException {
|
public void testCreateCaseSensitive() throws SystemMessageException {
|
||||||
//-test-author-:MartinOberhuber
|
//-test-author-:MartinOberhuber
|
||||||
|
|
Loading…
Add table
Reference in a new issue