diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/connection/IRSEConnectionProperties.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/connection/IRSEConnectionProperties.java index e86ca7cd295..d72d6bdb094 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/connection/IRSEConnectionProperties.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/connection/IRSEConnectionProperties.java @@ -23,7 +23,8 @@ public interface IRSEConnectionProperties { public final String ATTR_ADDRESS = "address"; //$NON-NLS-1$ public final String ATTR_USERID = "userid"; //$NON-NLS-1$ public final String ATTR_PASSWORD = "password"; //$NON-NLS-1$ - + public final String ATTR_DAEMON_PORT = "daemon_port"; //$NON-NLS-1$ + /** * Returns the associated property stored under the specified key. * diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/RSEConnectionManager.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/RSEConnectionManager.java index dae487148cf..5f8d9fd97c9 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/RSEConnectionManager.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/RSEConnectionManager.java @@ -31,6 +31,7 @@ import junit.framework.Assert; import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; +import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.rse.core.IRSESystemType; import org.eclipse.rse.core.IRSEUserIdConstants; import org.eclipse.rse.core.PasswordPersistenceManager; @@ -41,6 +42,8 @@ import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.rse.core.model.ISystemRegistry; import org.eclipse.rse.core.model.SystemSignonInformation; +import org.eclipse.rse.core.subsystems.IRemoteServerLauncher; +import org.eclipse.rse.core.subsystems.IServerLauncherProperties; import org.eclipse.rse.core.subsystems.ISubSystem; import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; import org.eclipse.rse.subsystems.files.core.model.RemoteFileUtility; @@ -50,6 +53,8 @@ import org.eclipse.rse.tests.RSETestsPlugin; import org.eclipse.rse.tests.core.connection.IRSEConnectionManager; import org.eclipse.rse.tests.core.connection.IRSEConnectionProperties; import org.eclipse.rse.tests.testsubsystem.interfaces.ITestSubSystem; +import org.eclipse.rse.ui.ISystemPreferencesConstants; +import org.eclipse.rse.ui.RSEUIPlugin; import org.eclipse.swt.widgets.Display; import org.osgi.framework.Bundle; @@ -216,18 +221,20 @@ public class RSEConnectionManager implements IRSEConnectionManager { Assert.assertNotNull("FAILED(findOrCreateConnection): Failed to find and/or create system profile '" + profileName + "'!", profile); //$NON-NLS-1$ //$NON-NLS-2$ String name = properties.getProperty(IRSEConnectionProperties.ATTR_NAME); - Assert.assertNotSame("FAILED(findOrCreateConnection): Invalid host name!", "unknown", name); //$NON-NLS-1$ //$NON-NLS-2$ + Assert.assertFalse("FAILED(findOrCreateConnection): Invalid host name!", "unknown".equals(name)); //$NON-NLS-1$ //$NON-NLS-2$ connection = systemRegistry.getHost(profile, name); if (connection == null) { String userId = properties.getProperty(IRSEConnectionProperties.ATTR_USERID); - Assert.assertNotSame("FAILED(findOrCreateConnection): Invalid user id name!", "unknown", userId); //$NON-NLS-1$ //$NON-NLS-2$ + Assert.assertFalse("FAILED(findOrCreateConnection): Invalid user id name!", "unknown".equals(userId)); //$NON-NLS-1$ //$NON-NLS-2$ String password = properties.getProperty(IRSEConnectionProperties.ATTR_PASSWORD); - Assert.assertNotSame("FAILED(findOrCreateConnection): Invalid user password name!", "unknown", password); //$NON-NLS-1$ //$NON-NLS-2$ + Assert.assertFalse("FAILED(findOrCreateConnection): Invalid user password name!", "unknown".equals(password)); //$NON-NLS-1$ //$NON-NLS-2$ String address = properties.getProperty(IRSEConnectionProperties.ATTR_ADDRESS); - Assert.assertNotSame("FAILED(findOrCreateConnection): Invalid remote system ip address or dns name!", "unknown", address); //$NON-NLS-1$ //$NON-NLS-2$ + Assert.assertFalse("FAILED(findOrCreateConnection): Invalid remote system ip address or dns name!", "unknown".equals(address)); //$NON-NLS-1$ //$NON-NLS-2$ String systemTypeId = properties.getProperty(IRSEConnectionProperties.ATTR_SYSTEM_TYPE_ID); - Assert.assertNotSame("FAILED(findOrCreateConnection): Invalid system type!", "unknown", systemTypeId); //$NON-NLS-1$ //$NON-NLS-2$ + Assert.assertFalse("FAILED(findOrCreateConnection): Invalid system type!", "unknown".equals(systemTypeId)); //$NON-NLS-1$ //$NON-NLS-2$ IRSESystemType systemType = RSECorePlugin.getTheCoreRegistry().getSystemTypeById(systemTypeId); + String daemonPort = properties.getProperty(IRSEConnectionProperties.ATTR_DAEMON_PORT); + Assert.assertFalse("FAILED(findOrCreateConnection): Invalid port!", "unknown".equals(daemonPort)); //$NON-NLS-1$ //$NON-NLS-2$ exception = null; cause = null; @@ -244,6 +251,15 @@ public class RSEConnectionManager implements IRSEConnectionManager { SystemSignonInformation info = new SystemSignonInformation(address, userId, password, systemType); PasswordPersistenceManager.getInstance().add(info, true, true); } + + if (daemonPort != null) { + int daemonPortNum = Integer.parseInt(daemonPort); + IServerLauncherProperties connProperties = connection.getConnectorServices()[0].getRemoteServerLauncherProperties(); + if (connProperties instanceof IRemoteServerLauncher) { + IRemoteServerLauncher launcher = (IRemoteServerLauncher) connProperties; + launcher.setDaemonPort(daemonPortNum); + } + } } Assert.assertNotNull("FAILED(findOrCreateConnection): Failed to find and/or create connection IHost object!", connection); //$NON-NLS-1$ final Display display = Display.getCurrent(); diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/CreateFileTestCase.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/CreateFileTestCase.java index d1d166bf98e..1bc43575ae7 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/CreateFileTestCase.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/CreateFileTestCase.java @@ -15,27 +15,24 @@ package org.eclipse.rse.tests.subsystems.files; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.rse.core.IRSESystemType; import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.core.model.ISystemRegistry; import org.eclipse.rse.core.model.SystemStartHere; import org.eclipse.rse.core.subsystems.ISubSystem; -import org.eclipse.rse.internal.core.model.SystemRegistry; import org.eclipse.rse.services.files.IFileService; import org.eclipse.rse.services.files.IHostFile; import org.eclipse.rse.subsystems.files.core.servicesubsystem.FileServiceSubSystem; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem; +import org.eclipse.rse.tests.core.connection.IRSEConnectionProperties; import org.eclipse.rse.ui.ISystemPreferencesConstants; import org.eclipse.rse.ui.RSEUIPlugin; public class CreateFileTestCase extends FileServiceBaseTest { - private String SYSTEM_ADDRESS = "sles8rm";//"SLES8RM"; - private String USER_ID = "xxxxxx"; - private String PASSWORD = "xxxxxx"; //"xxxxxx"; private IHost host; //TODO: See if additional characters in the name should work. // Also make sure if there are that they can be entered in the New @@ -56,37 +53,31 @@ public class CreateFileTestCase extends FileServiceBaseTest { return null; } - protected IHost getSSHHost() - { - IHost sshHost = null; - - String SYSTEM_TYPE_ID = IRSESystemType.SYSTEMTYPE_SSH_ONLY_ID; - String SYSTEM_NAME = SYSTEM_ADDRESS + "_ssh"; - - sshHost = getRemoteSystemConnection(SYSTEM_TYPE_ID, SYSTEM_ADDRESS, SYSTEM_NAME, USER_ID, PASSWORD); - assertNotNull(sshHost); - return sshHost; + public void testCreateFileFTP() throws Exception { + //-test-author-:KevinDoyle + + // Calculate the location of the test connection properties + IPath location = getTestDataLocation("", false); //$NON-NLS-1$ + assertNotNull("Cannot locate test data! Missing test data location?", location); //$NON-NLS-1$ + location = location.append("ftpConnection.properties"); //$NON-NLS-1$ + assertNotNull("Failed to construct location to 'connection.properties' test data file!", location); //$NON-NLS-1$ + assertTrue("Required test data file seems to be not a file!", location.toFile().isFile()); //$NON-NLS-1$ + assertTrue("Required test data file is not readable!", location.toFile().canRead()); //$NON-NLS-1$ + + // Load the properties from the calculated location without backing up defaults + IRSEConnectionProperties properties = getConnectionManager().loadConnectionProperties(location, false); + assertNotNull("Failed to load test connection properties from location " + location.toOSString(), properties); //$NON-NLS-1$ + + // Lookup and create the connection now if necessary + host = getConnectionManager().findOrCreateConnection(properties); + assertNotNull("Failed to create connection " + properties.getProperty(IRSEConnectionProperties.ATTR_NAME), host); //$NON-NLS-1$ + + createFileAndAssertProperties(); } - - protected IHost getFTPHost() - { - IHost ftpHost = null; - - String SYSTEM_TYPE_ID = IRSESystemType.SYSTEMTYPE_FTP_ONLY_ID; - String SYSTEM_NAME = SYSTEM_ADDRESS + "_ftp"; - - ftpHost = getRemoteSystemConnection(SYSTEM_TYPE_ID, SYSTEM_ADDRESS, SYSTEM_NAME, USER_ID, PASSWORD); - assertNotNull(ftpHost); - return ftpHost; - } - - protected IHost getDStoreHost() - { - IHost dstoreHost = null; - - String SYSTEM_TYPE_ID = IRSESystemType.SYSTEMTYPE_LINUX_ID; - String SYSTEM_NAME = SYSTEM_ADDRESS + "_dstore"; - + + public void testCreateFileDStore() throws Exception { + //-test-author-:KevinDoyle + //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(); @@ -95,28 +86,45 @@ public class CreateFileTestCase extends FileServiceBaseTest { store.setValue(ISystemPreferencesConstants.ALERT_SSL, false); store.setValue(ISystemPreferencesConstants.ALERT_NONSSL, false); - - dstoreHost = getRemoteSystemConnection(SYSTEM_TYPE_ID, SYSTEM_ADDRESS, SYSTEM_NAME, USER_ID, PASSWORD); - assertNotNull(dstoreHost); - return dstoreHost; - } - - public void testCreateFileFTP() throws Exception { - //-test-author-:KevinDoyle - host = getFTPHost(); - createFileAndAssertProperties(); - } + // Calculate the location of the test connection properties + IPath location = getTestDataLocation("", false); //$NON-NLS-1$ + assertNotNull("Cannot locate test data! Missing test data location?", location); //$NON-NLS-1$ + location = location.append("linuxConnection.properties"); //$NON-NLS-1$ + assertNotNull("Failed to construct location to 'connection.properties' test data file!", location); //$NON-NLS-1$ + assertTrue("Required test data file seems to be not a file!", location.toFile().isFile()); //$NON-NLS-1$ + assertTrue("Required test data file is not readable!", location.toFile().canRead()); //$NON-NLS-1$ + + // Load the properties from the calculated location without backing up defaults + IRSEConnectionProperties properties = getConnectionManager().loadConnectionProperties(location, false); + assertNotNull("Failed to load test connection properties from location " + location.toOSString(), properties); //$NON-NLS-1$ + + // Lookup and create the connection now if necessary + host = getConnectionManager().findOrCreateConnection(properties); + assertNotNull("Failed to create connection " + properties.getProperty(IRSEConnectionProperties.ATTR_NAME), host); //$NON-NLS-1$ - public void testCreateFileDStore() throws Exception { - //-test-author-:KevinDoyle - host = getDStoreHost(); createFileAndAssertProperties(); } public void testCreateFileSSH() throws Exception { //-test-author-:KevinDoyle - host = getSSHHost(); + + // Calculate the location of the test connection properties + IPath location = getTestDataLocation("", false); //$NON-NLS-1$ + assertNotNull("Cannot locate test data! Missing test data location?", location); //$NON-NLS-1$ + location = location.append("sshConnection.properties"); //$NON-NLS-1$ + assertNotNull("Failed to construct location to 'connection.properties' test data file!", location); //$NON-NLS-1$ + assertTrue("Required test data file seems to be not a file!", location.toFile().isFile()); //$NON-NLS-1$ + assertTrue("Required test data file is not readable!", location.toFile().canRead()); //$NON-NLS-1$ + + // Load the properties from the calculated location without backing up defaults + IRSEConnectionProperties properties = getConnectionManager().loadConnectionProperties(location, false); + assertNotNull("Failed to load test connection properties from location " + location.toOSString(), properties); //$NON-NLS-1$ + + // Lookup and create the connection now if necessary + host = getConnectionManager().findOrCreateConnection(properties); + assertNotNull("Failed to create connection " + properties.getProperty(IRSEConnectionProperties.ATTR_NAME), host); //$NON-NLS-1$ + createFileAndAssertProperties(); } @@ -157,7 +165,7 @@ public class CreateFileTestCase extends FileServiceBaseTest { fss.disconnect(); tempDirectory = null; } - SystemRegistry.getInstance().deleteHost(host); + getConnectionManager().removeConnection(host.getSystemProfile().getName(), host.getName()); host = null; } } diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileOutputStreamTestCase.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileOutputStreamTestCase.java index 6eb311c6d06..666d62f57cb 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileOutputStreamTestCase.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileOutputStreamTestCase.java @@ -21,28 +21,25 @@ import java.net.URI; import org.eclipse.core.filesystem.EFS; import org.eclipse.core.filesystem.IFileStore; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.rse.core.IRSESystemType; import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.core.model.ISystemRegistry; import org.eclipse.rse.core.model.SystemStartHere; import org.eclipse.rse.core.subsystems.ISubSystem; -import org.eclipse.rse.internal.core.model.SystemRegistry; import org.eclipse.rse.internal.efs.RSEFileStore; import org.eclipse.rse.services.clientserver.PathUtility; import org.eclipse.rse.services.files.IFileService; import org.eclipse.rse.subsystems.files.core.servicesubsystem.FileServiceSubSystem; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem; +import org.eclipse.rse.tests.core.connection.IRSEConnectionProperties; import org.eclipse.rse.ui.ISystemPreferencesConstants; import org.eclipse.rse.ui.RSEUIPlugin; public class FileOutputStreamTestCase extends FileServiceBaseTest { - private String SYSTEM_ADDRESS = "sles8rm";//"SLES8RM"; - private String USER_ID = "xxxxxx"; - private String PASSWORD = "xxxxxx"; //"xxxxxx"; private IHost host = null; private IRemoteFile tempDirectory; @@ -61,46 +58,68 @@ public class FileOutputStreamTestCase extends FileServiceBaseTest { protected IHost getSSHHost() { - IHost sshHost = null; - - String SYSTEM_TYPE_ID = IRSESystemType.SYSTEMTYPE_SSH_ONLY_ID; - String SYSTEM_NAME = SYSTEM_ADDRESS + "_ssh"; - - sshHost = getRemoteSystemConnection(SYSTEM_TYPE_ID, SYSTEM_ADDRESS, SYSTEM_NAME, USER_ID, PASSWORD); - assertNotNull(sshHost); - return sshHost; + // Calculate the location of the test connection properties + IPath location = getTestDataLocation("", false); //$NON-NLS-1$ + assertNotNull("Cannot locate test data! Missing test data location?", location); //$NON-NLS-1$ + location = location.append("sshConnection.properties"); //$NON-NLS-1$ + assertNotNull("Failed to construct location to 'connection.properties' test data file!", location); //$NON-NLS-1$ + assertTrue("Required test data file seems to be not a file!", location.toFile().isFile()); //$NON-NLS-1$ + assertTrue("Required test data file is not readable!", location.toFile().canRead()); //$NON-NLS-1$ + + // Load the properties from the calculated location without backing up defaults + IRSEConnectionProperties properties = getConnectionManager().loadConnectionProperties(location, false); + assertNotNull("Failed to load test connection properties from location " + location.toOSString(), properties); //$NON-NLS-1$ + + // Lookup and create the connection now if necessary + host = getConnectionManager().findOrCreateConnection(properties); + assertNotNull("Failed to create connection " + properties.getProperty(IRSEConnectionProperties.ATTR_NAME), host); //$NON-NLS-1$ + + return host; } protected IHost getFTPHost() { - IHost ftpHost = null; - - String SYSTEM_TYPE_ID = IRSESystemType.SYSTEMTYPE_FTP_ONLY_ID; - String SYSTEM_NAME = SYSTEM_ADDRESS + "_ftp"; - - ftpHost = getRemoteSystemConnection(SYSTEM_TYPE_ID, SYSTEM_ADDRESS, SYSTEM_NAME, USER_ID, PASSWORD); - assertNotNull(ftpHost); - return ftpHost; + // Calculate the location of the test connection properties + IPath location = getTestDataLocation("", false); //$NON-NLS-1$ + assertNotNull("Cannot locate test data! Missing test data location?", location); //$NON-NLS-1$ + location = location.append("ftpConnection.properties"); //$NON-NLS-1$ + assertNotNull("Failed to construct location to 'connection.properties' test data file!", location); //$NON-NLS-1$ + assertTrue("Required test data file seems to be not a file!", location.toFile().isFile()); //$NON-NLS-1$ + assertTrue("Required test data file is not readable!", location.toFile().canRead()); //$NON-NLS-1$ + + // Load the properties from the calculated location without backing up defaults + IRSEConnectionProperties properties = getConnectionManager().loadConnectionProperties(location, false); + assertNotNull("Failed to load test connection properties from location " + location.toOSString(), properties); //$NON-NLS-1$ + + // Lookup and create the connection now if necessary + host = getConnectionManager().findOrCreateConnection(properties); + assertNotNull("Failed to create connection " + properties.getProperty(IRSEConnectionProperties.ATTR_NAME), host); //$NON-NLS-1$ + + return host; } protected IHost getLocalHost() { - IHost localHost = null; - - String SYSTEM_TYPE_ID = IRSESystemType.SYSTEMTYPE_LOCAL_ID; - String SYSTEM_NAME = SYSTEM_ADDRESS + "_local"; - - localHost = getRemoteSystemConnection(SYSTEM_TYPE_ID, "localhost", SYSTEM_NAME, "", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - assertNotNull(localHost); - return localHost; + // Calculate the location of the test connection properties + IPath location = getTestDataLocation("", false); //$NON-NLS-1$ + assertNotNull("Cannot locate test data! Missing test data location?", location); //$NON-NLS-1$ + location = location.append("localConnection.properties"); //$NON-NLS-1$ + assertNotNull("Failed to construct location to 'connection.properties' test data file!", location); //$NON-NLS-1$ + assertTrue("Required test data file seems to be not a file!", location.toFile().isFile()); //$NON-NLS-1$ + assertTrue("Required test data file is not readable!", location.toFile().canRead()); //$NON-NLS-1$ + + // Load the properties from the calculated location without backing up defaults + IRSEConnectionProperties properties = getConnectionManager().loadConnectionProperties(location, false); + assertNotNull("Failed to load test connection properties from location " + location.toOSString(), properties); //$NON-NLS-1$ + + // Lookup and create the connection now if necessary + host = getConnectionManager().findOrCreateConnection(properties); + assertNotNull("Failed to create connection " + properties.getProperty(IRSEConnectionProperties.ATTR_NAME), host); //$NON-NLS-1$ + + return host; } protected IHost getDStoreHost() { - IHost dstoreHost = null; - - String SYSTEM_TYPE_ID = IRSESystemType.SYSTEMTYPE_LINUX_ID; - String SYSTEM_NAME = SYSTEM_ADDRESS + "_dstore"; - //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(); @@ -109,11 +128,24 @@ public class FileOutputStreamTestCase extends FileServiceBaseTest { store.setValue(ISystemPreferencesConstants.ALERT_SSL, false); store.setValue(ISystemPreferencesConstants.ALERT_NONSSL, false); - - dstoreHost = getRemoteSystemConnection(SYSTEM_TYPE_ID, SYSTEM_ADDRESS, SYSTEM_NAME, USER_ID, PASSWORD); - assertNotNull(dstoreHost); - return dstoreHost; + // Calculate the location of the test connection properties + IPath location = getTestDataLocation("", false); //$NON-NLS-1$ + assertNotNull("Cannot locate test data! Missing test data location?", location); //$NON-NLS-1$ + location = location.append("linuxConnection.properties"); //$NON-NLS-1$ + assertNotNull("Failed to construct location to 'connection.properties' test data file!", location); //$NON-NLS-1$ + assertTrue("Required test data file seems to be not a file!", location.toFile().isFile()); //$NON-NLS-1$ + assertTrue("Required test data file is not readable!", location.toFile().canRead()); //$NON-NLS-1$ + + // Load the properties from the calculated location without backing up defaults + IRSEConnectionProperties properties = getConnectionManager().loadConnectionProperties(location, false); + assertNotNull("Failed to load test connection properties from location " + location.toOSString(), properties); //$NON-NLS-1$ + + // Lookup and create the connection now if necessary + host = getConnectionManager().findOrCreateConnection(properties); + assertNotNull("Failed to create connection " + properties.getProperty(IRSEConnectionProperties.ATTR_NAME), host); //$NON-NLS-1$ + + return host; } public void testRSEFileStoreAppendOutputStreamLocal() throws Exception { @@ -265,7 +297,7 @@ public class FileOutputStreamTestCase extends FileServiceBaseTest { fss.disconnect(); tempDirectory = null; } - SystemRegistry.getInstance().deleteHost(host); + getConnectionManager().removeConnection(host.getSystemProfile().getName(), host.getName()); host = null; } } diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileSubsystemConsistencyTestCase.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileSubsystemConsistencyTestCase.java index ec700b48b00..dd0e8a31f14 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileSubsystemConsistencyTestCase.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileSubsystemConsistencyTestCase.java @@ -17,10 +17,10 @@ import java.io.File; import java.util.ArrayList; import java.util.List; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.rse.core.IRSESystemType; import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.core.model.ISystemRegistry; import org.eclipse.rse.core.model.SystemStartHere; @@ -29,6 +29,7 @@ import org.eclipse.rse.services.files.IFileService; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem; import org.eclipse.rse.tests.RSETestsPlugin; +import org.eclipse.rse.tests.core.connection.IRSEConnectionProperties; import org.eclipse.rse.tests.core.connection.RSEBaseConnectionTestCase; import org.eclipse.rse.ui.ISystemPreferencesConstants; import org.eclipse.rse.ui.RSEUIPlugin; @@ -42,19 +43,8 @@ public class FileSubsystemConsistencyTestCase extends RSEBaseConnectionTestCase private List _connections; private List _samplePaths; - private String SYSTEM_ADDRESS = "dmcknigh3";//"SLES8RM"; - private String USER_ID = "dmcknigh"; - private String PASSWORD = null;//"xxxxxx"; - private String LOCALTEMPDIR = "C:\\temp"; - /* - private SYSTEM_ADDRESS = "dmcknigh3"; - private USER_ID = "tester"; - private PASSWORD = null;"xxxxxx"; - */ - - /* (non-Javadoc) * @see org.eclipse.rse.tests.core.RSECoreTestCase#tearDown() */ @@ -134,11 +124,22 @@ public class FileSubsystemConsistencyTestCase extends RSEBaseConnectionTestCase { IHost sshHost = null; - String SYSTEM_TYPE_ID = IRSESystemType.SYSTEMTYPE_SSH_ONLY_ID; - String SYSTEM_NAME = SYSTEM_ADDRESS + "_ssh"; + // Calculate the location of the test connection properties + IPath location = getTestDataLocation("", false); //$NON-NLS-1$ + assertNotNull("Cannot locate test data! Missing test data location?", location); //$NON-NLS-1$ + location = location.append("sshConnection.properties"); //$NON-NLS-1$ + assertNotNull("Failed to construct location to 'connection.properties' test data file!", location); //$NON-NLS-1$ + assertTrue("Required test data file seems to be not a file!", location.toFile().isFile()); //$NON-NLS-1$ + assertTrue("Required test data file is not readable!", location.toFile().canRead()); //$NON-NLS-1$ + + // Load the properties from the calculated location without backing up defaults + IRSEConnectionProperties properties = getConnectionManager().loadConnectionProperties(location, false); + assertNotNull("Failed to load test connection properties from location " + location.toOSString(), properties); //$NON-NLS-1$ + + // Lookup and create the connection now if necessary + sshHost = getConnectionManager().findOrCreateConnection(properties); + assertNotNull("Failed to create connection " + properties.getProperty(IRSEConnectionProperties.ATTR_NAME), sshHost); //$NON-NLS-1$ - sshHost = getRemoteSystemConnection(SYSTEM_TYPE_ID, SYSTEM_ADDRESS, SYSTEM_NAME, USER_ID, PASSWORD); - assertNotNull(sshHost); return sshHost; } @@ -146,21 +147,29 @@ public class FileSubsystemConsistencyTestCase extends RSEBaseConnectionTestCase { IHost ftpHost = null; - String SYSTEM_TYPE_ID = IRSESystemType.SYSTEMTYPE_FTP_ONLY_ID; - String SYSTEM_NAME = SYSTEM_ADDRESS + "_ftp"; - - ftpHost = getRemoteSystemConnection(SYSTEM_TYPE_ID, SYSTEM_ADDRESS, SYSTEM_NAME, USER_ID, PASSWORD); - assertNotNull(ftpHost); + // Calculate the location of the test connection properties + IPath location = getTestDataLocation("", false); //$NON-NLS-1$ + assertNotNull("Cannot locate test data! Missing test data location?", location); //$NON-NLS-1$ + location = location.append("ftpConnection.properties"); //$NON-NLS-1$ + assertNotNull("Failed to construct location to 'connection.properties' test data file!", location); //$NON-NLS-1$ + assertTrue("Required test data file seems to be not a file!", location.toFile().isFile()); //$NON-NLS-1$ + assertTrue("Required test data file is not readable!", location.toFile().canRead()); //$NON-NLS-1$ + + // Load the properties from the calculated location without backing up defaults + IRSEConnectionProperties properties = getConnectionManager().loadConnectionProperties(location, false); + assertNotNull("Failed to load test connection properties from location " + location.toOSString(), properties); //$NON-NLS-1$ + + // Lookup and create the connection now if necessary + ftpHost = getConnectionManager().findOrCreateConnection(properties); + assertNotNull("Failed to create connection " + properties.getProperty(IRSEConnectionProperties.ATTR_NAME), ftpHost); //$NON-NLS-1$ + return ftpHost; } protected IHost getDStoreHost() { IHost dstoreHost = null; - - String SYSTEM_TYPE_ID = IRSESystemType.SYSTEMTYPE_LINUX_ID; - String SYSTEM_NAME = SYSTEM_ADDRESS + "_dstore"; - + //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(); @@ -170,8 +179,21 @@ public class FileSubsystemConsistencyTestCase extends RSEBaseConnectionTestCase store.setValue(ISystemPreferencesConstants.ALERT_SSL, false); store.setValue(ISystemPreferencesConstants.ALERT_NONSSL, false); - dstoreHost = getRemoteSystemConnection(SYSTEM_TYPE_ID, SYSTEM_ADDRESS, SYSTEM_NAME, USER_ID, PASSWORD); - assertNotNull(dstoreHost); + // Calculate the location of the test connection properties + IPath location = getTestDataLocation("", false); //$NON-NLS-1$ + assertNotNull("Cannot locate test data! Missing test data location?", location); //$NON-NLS-1$ + location = location.append("linuxConnection.properties"); //$NON-NLS-1$ + assertNotNull("Failed to construct location to 'connection.properties' test data file!", location); //$NON-NLS-1$ + assertTrue("Required test data file seems to be not a file!", location.toFile().isFile()); //$NON-NLS-1$ + assertTrue("Required test data file is not readable!", location.toFile().canRead()); //$NON-NLS-1$ + + // Load the properties from the calculated location without backing up defaults + IRSEConnectionProperties properties = getConnectionManager().loadConnectionProperties(location, false); + assertNotNull("Failed to load test connection properties from location " + location.toOSString(), properties); //$NON-NLS-1$ + + // Lookup and create the connection now if necessary + dstoreHost = getConnectionManager().findOrCreateConnection(properties); + assertNotNull("Failed to create connection " + properties.getProperty(IRSEConnectionProperties.ATTR_NAME), dstoreHost); //$NON-NLS-1$ return dstoreHost; } diff --git a/rse/tests/org.eclipse.rse.tests/test.data/ftpConnection.properties b/rse/tests/org.eclipse.rse.tests/test.data/ftpConnection.properties new file mode 100644 index 00000000000..23cb2e2000e --- /dev/null +++ b/rse/tests/org.eclipse.rse.tests/test.data/ftpConnection.properties @@ -0,0 +1,28 @@ +############################################################################### +# Copyright (c) 2008 IBM Corporation and others. All rights reserved. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# IBM Corporation - initial API and implementation +############################################################################### + +# name/label for this ftp connection +name = test_ftp_only + +# profile name this connection should be created for +profile_name = junit_test_profile + +# FTP system ID +system_type_id = org.eclipse.rse.systemtype.ftp + +# Address of ftp connection +address = unknown + +# userid to connect to ftp connection +#userid = + +# password to connect to ftp connection +#password = \ No newline at end of file diff --git a/rse/tests/org.eclipse.rse.tests/test.data/linuxConnection.properties b/rse/tests/org.eclipse.rse.tests/test.data/linuxConnection.properties new file mode 100644 index 00000000000..90eee48b494 --- /dev/null +++ b/rse/tests/org.eclipse.rse.tests/test.data/linuxConnection.properties @@ -0,0 +1,31 @@ +############################################################################### +# Copyright (c) 2008 IBM Corporation and others. All rights reserved. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# IBM Corporation - initial API and implementation +############################################################################### + +# name/label for this linux connection +name = test_linux + +# profile name this connection should be created for +profile_name = junit_test_profile + +# Linux System ID +system_type_id = org.eclipse.rse.systemtype.linux + +# Address of windows connection +address = unknown + +# userid to connect to linux connection +#userid = + +# password to connect to linux connection +#password = + +# daemon port used for connecting to this linux connection +#daemon_port = \ No newline at end of file diff --git a/rse/tests/org.eclipse.rse.tests/test.data/localConnection.properties b/rse/tests/org.eclipse.rse.tests/test.data/localConnection.properties new file mode 100644 index 00000000000..6bcd75c4fd7 --- /dev/null +++ b/rse/tests/org.eclipse.rse.tests/test.data/localConnection.properties @@ -0,0 +1,22 @@ +############################################################################### +# Copyright (c) 2008 IBM Corporation and others. All rights reserved. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# IBM Corporation - initial API and implementation +############################################################################### + +# name/label for this local connection +name = test_local + +# profile name this connection should be created for +profile_name = junit_test_profile + +# Local System ID +system_type_id = org.eclipse.rse.systemtype.local + +# Address of local system +address = localhost \ No newline at end of file diff --git a/rse/tests/org.eclipse.rse.tests/test.data/sshConnection.properties b/rse/tests/org.eclipse.rse.tests/test.data/sshConnection.properties new file mode 100644 index 00000000000..89b9f113d9e --- /dev/null +++ b/rse/tests/org.eclipse.rse.tests/test.data/sshConnection.properties @@ -0,0 +1,28 @@ +############################################################################### +# Copyright (c) 2008 IBM Corporation and others. All rights reserved. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# IBM Corporation - initial API and implementation +############################################################################### + +# name/label for this windows connection +name = test_ssh_only + +# profile name this connection should be created for +profile_name = junit_test_profile + +# SSH system ID +system_type_id = org.eclipse.rse.systemtype.ssh + +# Address of ssh connection +address = unknown + +# userid to connect to ssh connection +#userid = + +# password to connect to ssh connection +#password = \ No newline at end of file diff --git a/rse/tests/org.eclipse.rse.tests/test.data/windowsConnection.properties b/rse/tests/org.eclipse.rse.tests/test.data/windowsConnection.properties new file mode 100644 index 00000000000..57cab23f0c5 --- /dev/null +++ b/rse/tests/org.eclipse.rse.tests/test.data/windowsConnection.properties @@ -0,0 +1,31 @@ +############################################################################### +# Copyright (c) 2008 IBM Corporation and others. All rights reserved. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# IBM Corporation - initial API and implementation +############################################################################### + +# name/label for this windows connection +name = test_windows + +# profile name this connection should be created for +profile_name = junit_test_profile + +# Windows system ID +system_type_id = org.eclipse.rse.systemtype.windows + +# Address of windows connection +address = unknown + +# userid to connect to windows connection +#userid = + +# password to connect to windows connection +#password = + +# daemon port used for connecting to this windows connection +#daemon_port = \ No newline at end of file