1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-17 05:55:22 +02:00

[unittests] Simplify dstore connection creation

This commit is contained in:
Martin Oberhuber 2008-05-26 17:13:36 +00:00
parent 44f56ccd0f
commit 1a0505d699
3 changed files with 58 additions and 56 deletions

View file

@ -21,6 +21,7 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.rse.core.IRSESystemType; import org.eclipse.rse.core.IRSESystemType;
import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.tests.core.RSECoreTestCase; import org.eclipse.rse.tests.core.RSECoreTestCase;
import org.eclipse.rse.tests.internal.RSEConnectionManager; import org.eclipse.rse.tests.internal.RSEConnectionManager;
import org.eclipse.rse.ui.ISystemPreferencesConstants; import org.eclipse.rse.ui.ISystemPreferencesConstants;
@ -104,29 +105,11 @@ public class RSEBaseConnectionTestCase extends RSECoreTestCase {
protected IHost getLinuxHost() protected IHost getLinuxHost()
{ {
//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);
store.setValue(ISystemPreferencesConstants.ALERT_SSL, false);
store.setValue(ISystemPreferencesConstants.ALERT_NONSSL, false);
return getHost("linuxConnection.properties"); return getHost("linuxConnection.properties");
} }
protected IHost getWindowsHost() protected IHost getWindowsHost()
{ {
//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);
store.setValue(ISystemPreferencesConstants.ALERT_SSL, false);
store.setValue(ISystemPreferencesConstants.ALERT_NONSSL, false);
return getHost("windowsConnection.properties"); return getHost("windowsConnection.properties");
} }
@ -136,7 +119,7 @@ public class RSEBaseConnectionTestCase extends RSECoreTestCase {
// Calculate the location of the test connection properties // Calculate the location of the test connection properties
IPath location = getTestDataLocation("", false); //$NON-NLS-1$ IPath location = getTestDataLocation("", false); //$NON-NLS-1$
assertNotNull("Cannot locate test data! Missing test data location?", location); //$NON-NLS-1$ assertNotNull("Cannot locate test data! Missing test data location?", location); //$NON-NLS-1$
location = location.append(propertiesFileName); //$NON-NLS-1$ location = location.append(propertiesFileName);
assertNotNull("Failed to construct location to 'connection.properties' test data file!", location); //$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 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$ assertTrue("Required test data file is not readable!", location.toFile().canRead()); //$NON-NLS-1$
@ -149,6 +132,24 @@ public class RSEBaseConnectionTestCase extends RSECoreTestCase {
host = getConnectionManager().findOrCreateConnection(properties); host = getConnectionManager().findOrCreateConnection(properties);
assertNotNull("Failed to create connection " + properties.getProperty(IRSEConnectionProperties.ATTR_NAME), host); //$NON-NLS-1$ assertNotNull("Failed to create connection " + properties.getProperty(IRSEConnectionProperties.ATTR_NAME), host); //$NON-NLS-1$
// For connections with dstore, need to disable SSL alerts
// since the UI messagebox on connect would make the test hang
ISubSystem[] ss = host.getSubSystems();
for (int i = 0; i < ss.length; i++) {
String id = ss[i].getSubSystemConfiguration().getId();
if (id.indexOf("dstore.") >= 0) {
IPreferenceStore store = RSEUIPlugin.getDefault().getPreferenceStore();
////Ensure that the SSL acknowledge dialog does not show up.
////We no longer need to setDefault first in order to set the value of a preference.
////Since this is now in connectorservice.dstore/Activator, and it's sure to be active here
// store.setDefault(ISystemPreferencesConstants.ALERT_SSL,ISystemPreferencesConstants.DEFAULT_ALERT_SSL);
// store.setDefault(ISystemPreferencesConstants.ALERT_NONSSL, ISystemPreferencesConstants.DEFAULT_ALERT_NON_SSL);
store.setValue(ISystemPreferencesConstants.ALERT_SSL, false);
store.setValue(ISystemPreferencesConstants.ALERT_NONSSL, false);
break;
}
}
return host; return host;
} }
@ -169,11 +170,11 @@ public class RSEBaseConnectionTestCase extends RSECoreTestCase {
// Pre-create the local system connection properties // Pre-create the local system connection properties
Properties properties = new Properties(); Properties properties = new Properties();
properties.setProperty(IRSEConnectionProperties.ATTR_SYSTEM_TYPE_ID, systemTypeID); properties.setProperty(IRSEConnectionProperties.ATTR_SYSTEM_TYPE_ID, systemTypeID);
properties.setProperty(IRSEConnectionProperties.ATTR_ADDRESS, systemAddress); //$NON-NLS-1$ properties.setProperty(IRSEConnectionProperties.ATTR_ADDRESS, systemAddress);
properties.setProperty(IRSEConnectionProperties.ATTR_NAME, systemName); //$NON-NLS-1$ properties.setProperty(IRSEConnectionProperties.ATTR_NAME, systemName);
properties.setProperty(IRSEConnectionProperties.ATTR_USERID, userID); //$NON-NLS-1$ properties.setProperty(IRSEConnectionProperties.ATTR_USERID, userID);
if (password != null) if (password != null)
properties.setProperty(IRSEConnectionProperties.ATTR_PASSWORD, password); //$NON-NLS-1$ properties.setProperty(IRSEConnectionProperties.ATTR_PASSWORD, password);
IRSEConnectionProperties remoteSystemConnectionProperties; IRSEConnectionProperties remoteSystemConnectionProperties;
remoteSystemConnectionProperties = getConnectionManager().loadConnectionProperties(properties, false); remoteSystemConnectionProperties = getConnectionManager().loadConnectionProperties(properties, false);

View file

@ -131,7 +131,7 @@ public class FileServiceBaseTest extends RSEBaseConnectionTestCase {
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);

View file

@ -56,6 +56,7 @@ public class RSEFileSubsystemTestSuite extends DelegatingTestSuiteHolder {
// the ftp server to use possibly changed to whatever host will do. // the ftp server to use possibly changed to whatever host will do.
suite.addTestSuite(FTPFileSubsystemTestCase.class); suite.addTestSuite(FTPFileSubsystemTestCase.class);
suite.addTestSuite(FileServiceTgzArchiveTest.class); suite.addTestSuite(FileServiceTgzArchiveTest.class);
suite.addTest(RSEFileStoreTest.suite());
return suite; return suite;
} }