diff --git a/rse/tests/org.eclipse.rse.tests/.classpath b/rse/tests/org.eclipse.rse.tests/.classpath
new file mode 100644
index 00000000000..751c8f2e504
--- /dev/null
+++ b/rse/tests/org.eclipse.rse.tests/.classpath
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/rse/tests/org.eclipse.rse.tests/.project b/rse/tests/org.eclipse.rse.tests/.project
new file mode 100644
index 00000000000..0b0e2b5a011
--- /dev/null
+++ b/rse/tests/org.eclipse.rse.tests/.project
@@ -0,0 +1,28 @@
+
+
+ org.eclipse.rse.tests
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.pde.ManifestBuilder
+
+
+
+
+ org.eclipse.pde.SchemaBuilder
+
+
+
+
+
+ org.eclipse.pde.PluginNature
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/rse/tests/org.eclipse.rse.tests/META-INF/MANIFEST.MF b/rse/tests/org.eclipse.rse.tests/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..b2d90d2d652
--- /dev/null
+++ b/rse/tests/org.eclipse.rse.tests/META-INF/MANIFEST.MF
@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: RSE Core Tests
+Bundle-SymbolicName: org.eclipse.rse.tests.core;singleton:=true
+Bundle-Version: 1.0.0
+Bundle-Activator: org.eclipse.rse.tests.systems.core.SystemTestPlugin
+Bundle-Vendor: Eclipse.org
+Bundle-Localization: plugin
+Require-Bundle: org.junit,
+ org.eclipse.core.runtime,
+ org.eclipse.ui,
+ org.eclipse.rse.core,
+ org.eclipse.rse.ui,
+ org.eclipse.rse.subsystems.files.core,
+ org.eclipse.rse.subsystems.shells.core,
+ org.eclipse.rse.tests.framework
+Eclipse-LazyStart: true
diff --git a/rse/tests/org.eclipse.rse.tests/SystemConnectionInfo.properties b/rse/tests/org.eclipse.rse.tests/SystemConnectionInfo.properties
new file mode 100644
index 00000000000..2a794efe937
--- /dev/null
+++ b/rse/tests/org.eclipse.rse.tests/SystemConnectionInfo.properties
@@ -0,0 +1,33 @@
+###############################################################################
+# Copyright (c) 2001, 2004 IBM Corporation and others.
+# 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
+###############################################################################
+#############################################################################
+# This file connection information that is used as default values in the
+# AbstractSystemConnectionTest and SystemTestUtil.
+# Using this interface allows you to easily change which system
+# way we can quickly change which system the testcases are run against.
+#############################################################################
+
+## Linux Systems ##
+default_ip_name = myhost.mycompany.com
+
+
+## System Types ##
+#default_system_type = Linux
+#default_system_type = Local
+default_system_type = Unix
+#default_system_type = Windows
+
+## Default values for creating connections ##
+default_profile_name = test_profile
+default_host_name = test_host_name
+
+default_userid = myname
+default_password = mypassword
diff --git a/rse/tests/org.eclipse.rse.tests/build.properties b/rse/tests/org.eclipse.rse.tests/build.properties
new file mode 100644
index 00000000000..533fd267c96
--- /dev/null
+++ b/rse/tests/org.eclipse.rse.tests/build.properties
@@ -0,0 +1,17 @@
+###############################################################################
+# Copyright (c) 2001, 2004 IBM Corporation and others.
+# 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
+###############################################################################
+source.. = src/
+output.. = bin/
+bin.includes = .,\
+ plugin.xml,\
+ META-INF/,\
+ SystemConnectionInfo.properties,\
+ test.xml
diff --git a/rse/tests/org.eclipse.rse.tests/plugin.xml b/rse/tests/org.eclipse.rse.tests/plugin.xml
new file mode 100644
index 00000000000..b622091eb2a
--- /dev/null
+++ b/rse/tests/org.eclipse.rse.tests/plugin.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/systems/connection/BaseConnectionTest.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/systems/connection/BaseConnectionTest.java
new file mode 100644
index 00000000000..2f6cda1c73d
--- /dev/null
+++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/systems/connection/BaseConnectionTest.java
@@ -0,0 +1,224 @@
+/* *******************************************************************************
+ * Copyright (c) 2006 IBM Corporation. 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:
+ * Don Yantzi (IBM) - initial contribution.
+ * David Dykstal (IBM) - initial contribution.
+ * *******************************************************************************/
+package org.eclipse.rse.tests.systems.connection;
+
+import java.text.MessageFormat;
+import java.util.Properties;
+
+import org.eclipse.rse.core.RSECorePlugin;
+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.subsystems.IServiceSubSystemConfiguration;
+import org.eclipse.rse.core.subsystems.ISubSystem;
+import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
+import org.eclipse.rse.subsystems.files.core.model.RemoteFileUtility;
+import org.eclipse.rse.subsystems.files.core.servicesubsystem.FileServiceSubSystem;
+import org.eclipse.rse.subsystems.shells.core.subsystems.servicesubsystem.IShellServiceSubSystem;
+import org.eclipse.rse.tests.framework.AnnotatingTestCase;
+import org.eclipse.rse.tests.systems.core.SystemTestPlugin;
+import org.eclipse.rse.tests.systems.core.SystemTestUtil;
+import org.eclipse.rse.ui.RSEUIPlugin;
+
+/**
+ * Abstract superclass for JUnit PDE test cases that require an IHost.
+ * This superclass creates a single RSE IHost that can
+ * be reused by multiple testcases run during the same PDE invocation.
+ *
+ * @author yantzi
+ */
+public class BaseConnectionTest extends AnnotatingTestCase {
+
+ private IHost host = null;
+ private Properties properties = null;
+
+ /**
+ * Constructor for ConnectionTest.
+ *
+ * @param name
+ * Name of current test being run.
+ */
+ public BaseConnectionTest(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ properties = SystemTestUtil.loadProperties(SystemTestPlugin.getDefault().getBundle(), "SystemConnectionInfo.properties");
+ host = getHost();
+ }
+
+ protected void tearDown() throws Exception {
+ host = null;
+ properties = null;
+ super.tearDown();
+ }
+
+ /**
+ * Load strings from the SystemConnectionTests.properties file. Can be used to retrieve
+ * properties that influence the running of the testcase.
+ * @param key the key of the string in the properties file.
+ * @return the value of the property
+ */
+ public String getString(String key) {
+ return properties.getProperty(key);
+ }
+
+ /**
+ * Find the host used by all subclasses for this
+ * invocation of the runtime workbench. If not found, then
+ * create it using the associated getters to
+ * change the default connection name, hostname, user ID or password (as
+ * specified in SystemConnectionTests.properties).
+ *
+ * @return the new connection (host)
+ * @throws Exception if there is a problem
+ *
+ * @see BaseConnectionTest#getHostName()
+ * @see BaseConnectionTest#getHostAddress()
+ * @see BaseConnectionTest#getSystemType()
+ * @see BaseConnectionTest#getUserID()
+ * @see BaseConnectionTest#getPassword()
+ */
+ protected IHost getHost() throws Exception {
+ if (host == null) {
+ String profileName = getProfileName();
+ assertNotSame("need to change the profile name in SystemConnectionInfo.properties", "unknown", profileName);
+ ISystemProfile profile = SystemTestUtil.findProfile(profileName);
+ if (profile == null) {
+ profile = SystemTestUtil.createProfile(profileName);
+ }
+ String hostName = getHostName();
+ assertNotSame("need to change the host name in SystemConnectionInfo.properties", "unknown", hostName);
+ host = SystemTestUtil.findHost(profileName, hostName);
+ if (host == null) {
+ String userID = getUserID();
+ assertNotSame("need to change the user id in SystemConnectionInfo.properties", "unknown", userID);
+ String password = getPassword();
+ assertNotSame("need to change the password in SystemConnectionInfo.properties", "unknown", password);
+ String hostAddress = getHostAddress();
+ assertNotSame("need to change the host address in SystemConnectionInfo.properties", "unknown", hostAddress);
+ host = SystemTestUtil.createHost(profileName, hostName, hostAddress, getSystemType(), userID, password);
+ }
+ }
+ return host;
+ }
+
+ /**
+ * Get the file subsystem for default connection.
+ * Returns null if there is no subsystem with the given configuration id in this connection.
+ * @param desiredConfigurationId the subsystem configuration id of the desired subsystem.
+ * @return the file subsystem
+ * @throws Exception if there is a problem
+ */
+ protected ISubSystem getFileSubSystem(String desiredConfigurationId) throws Exception {
+ FileServiceSubSystem subsystem = (FileServiceSubSystem) RemoteFileUtility.getFileSubSystem(getHost());
+ ISubSystemConfiguration config = subsystem.getSubSystemConfiguration();
+ String activeId = config.getId();
+ if (!activeId.equals(desiredConfigurationId)) {
+ if (subsystem.isConnected()) {
+ throw new RuntimeException(MessageFormat.format("The subsystem is connected as {}. Disconnect before changing.", new Object[] {activeId}));
+ } else {
+ ISystemRegistry registry = RSECorePlugin.getDefault().getSystemRegistry();
+ ISubSystemConfiguration desiredConfiguration = registry.getSubSystemConfiguration(desiredConfigurationId);
+ if (desiredConfiguration instanceof IServiceSubSystemConfiguration) {
+ IServiceSubSystemConfiguration t = (IServiceSubSystemConfiguration) desiredConfiguration;
+ subsystem.switchServiceFactory(t);
+ }
+ }
+ }
+ return subsystem;
+ }
+
+ /**
+ * Get the shell subsystem for default connection
+ * @return the shell subsystem
+ * @throws Exception if there is a problem
+ */
+ protected ISubSystem getShellSubSystem() throws Exception {
+ ISystemRegistry registry = RSEUIPlugin.getTheSystemRegistry();
+ ISubSystem[] subSystems = registry.getSubSystems(getHost());
+ for (int i = 0; i < subSystems.length; i++) {
+ ISubSystem subSystem = subSystems[i];
+ if (subSystem instanceof IShellServiceSubSystem) {
+ IShellServiceSubSystem shellSubSystem = (IShellServiceSubSystem) subSystem;
+ return shellSubSystem;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Retrieve the name for the default RSE profile used by subclasses.
+ * Subclasses should override this method to override the profile name,
+ * otherwise the default system type from SystemConnectionTests.properties
+ * is used.
+ * @return the name of the profile
+ */
+ protected String getProfileName() {
+ return getString(ConnectionConstants.DEFAULT_PROFILE_NAME);
+ }
+
+ /**
+ * Retrieve the name for the default RSE connection used by subclasses.
+ * Subclasses should override this method to override the connection name,
+ * otherwise the default system type from SystemConnectionTests.properties
+ * is used.
+ * @return the name of the host
+ */
+ protected String getHostName() {
+ return getString(ConnectionConstants.DEFAULT_HOST_NAME);
+ }
+
+ /**
+ * Retrieve the hostname for the default RSE connection used by subclasses.
+ * Subclasses should override this method to override the hostname,
+ * otherwise the default hostname is used.
+ * @return the host address information
+ */
+ protected String getHostAddress() {
+ return getString(ConnectionConstants.DEFAULT_IP_NAME);
+ }
+
+ /**
+ * Retrieve the system type for the default RSE connection used by
+ * subclasses. Subclasses should override this method to override the system
+ * type, otherwise the default system type from
+ * SystemConnectionTests.properties is used.
+ * @return the system type
+ */
+ protected String getSystemType() {
+ return getString(ConnectionConstants.DEFAULT_SYSTEM_TYPE);
+ }
+
+ /**
+ * Retrieve the user ID for the default RSE connection used by subclasses.
+ * Subclasses should override this method to override the user ID used for
+ * the connection, otherwise the default system type from
+ * SystemConnectionTests.properties is used.
+ * @return the user id the connection will use
+ */
+ protected String getUserID() {
+ return getString(ConnectionConstants.DEFAULT_USERID);
+ }
+
+ /**
+ * Retrieve the password for the default RSE connection used by subclasses.
+ * Subclasses should override this method to override the password used for
+ * the associated hostname and user ID, otherwise the default system type
+ * from SystemConnectionTests.properties is used.
+ * @return the password used to establish the connection
+ */
+ protected String getPassword() {
+ return getString(ConnectionConstants.DEFAULT_PASSWORD);
+ }
+
+}
\ No newline at end of file
diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/systems/connection/ConnectionConstants.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/systems/connection/ConnectionConstants.java
new file mode 100644
index 00000000000..040bada68a7
--- /dev/null
+++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/systems/connection/ConnectionConstants.java
@@ -0,0 +1,27 @@
+/* *******************************************************************************
+ * Copyright (c) 2006 IBM Corporation. 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:
+ * Don Yantzi (IBM) - initial contribution.
+ * David Dykstal (IBM) - initial contribution.
+ * *******************************************************************************/
+package org.eclipse.rse.tests.systems.connection;
+
+/**
+ * Constants used to index into the SystemConnectionTests.properties file
+ */
+public interface ConnectionConstants {
+
+ public static final String DEFAULT_IP_NAME = "default_ip_name";
+ public static final String DEFAULT_SYSTEM_TYPE= "default_system_type";
+
+ public static final String DEFAULT_PROFILE_NAME = "default_profile_name";
+ public static final String DEFAULT_HOST_NAME = "default_host_name";
+
+ public static final String DEFAULT_USERID = "default_userid";
+ public static final String DEFAULT_PASSWORD = "default_password";
+
+}
diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/systems/connection/ConnectionTest.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/systems/connection/ConnectionTest.java
new file mode 100644
index 00000000000..cf6f304ad99
--- /dev/null
+++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/systems/connection/ConnectionTest.java
@@ -0,0 +1,63 @@
+/* *******************************************************************************
+ * Copyright (c) 2006 IBM Corporation. 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:
+ * Don Yantzi (IBM) - initial contribution.
+ * David Dykstal (IBM) - initial contribution.
+ * *******************************************************************************/
+package org.eclipse.rse.tests.systems.connection;
+
+import org.eclipse.rse.core.subsystems.ISubSystem;
+import org.eclipse.rse.ui.ISystemPreferencesConstants;
+import org.eclipse.rse.ui.RSEUIPlugin;
+
+/**
+ * Basic connection tests.
+ */
+public class ConnectionTest extends BaseConnectionTest {
+
+ public ConnectionTest(String name) {
+ super(name);
+ }
+
+ /**
+ * Test the connect and disconnect methods
+ * @throws Exception if there is a problem
+ */
+ public void testConnect() throws Exception {
+ ISubSystem subsystem = getFileSubSystem("dstore.files");
+ assertNotNull("No dstore.files subystem", subsystem);
+// subsystem.getConnectorService().setPort(4036);
+// ((RemoteServerLauncher)subsystem.getConnectorService().getRemoteServerLauncherProperties()).setDaemonPort(4036);
+ RSEUIPlugin.getDefault().getPreferenceStore().setValue(ISystemPreferencesConstants.ALERT_SSL, false);
+ RSEUIPlugin.getDefault().getPreferenceStore().setValue(ISystemPreferencesConstants.ALERT_NONSSL, false);
+ subsystem.connect();
+ assertTrue("Subsystem not connected", subsystem.isConnected());
+ subsystem.disconnect();
+ assertFalse(subsystem.isConnected());
+ }
+
+ /**
+ * Test resolving a filter string.
+ * @throws Exception if there is a problem
+ */
+ public void testResolveFilterString() throws Exception {
+ ISubSystem subsystem = getFileSubSystem("dstore.files");
+ assertNotNull("No dstore.files subystem", subsystem);
+ try {
+ subsystem.connect();
+ assertTrue("subsystem not connected", subsystem.isConnected());
+ Object[] objects = subsystem.resolveFilterString(null, "/bin/*");
+ assertNotNull("A null result was returned from resolveFilterString.", objects);
+ assertTrue("No entries found in home directory.", objects.length > 0);
+ } finally {
+ if (subsystem.isConnected()) {
+ subsystem.disconnect();
+ }
+ }
+ }
+
+}
diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/systems/connection/ConnectionTestSuite.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/systems/connection/ConnectionTestSuite.java
new file mode 100644
index 00000000000..6b05c7dd8fc
--- /dev/null
+++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/systems/connection/ConnectionTestSuite.java
@@ -0,0 +1,25 @@
+/* *******************************************************************************
+ * Copyright (c) 2006 IBM Corporation. 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:
+ * David Dykstal (IBM) - initial contribution.
+ * *******************************************************************************/
+package org.eclipse.rse.tests.systems.connection;
+
+import junit.framework.TestSuite;
+
+import org.eclipse.rse.tests.framework.ITestSuiteProvider;
+
+public class ConnectionTestSuite implements ITestSuiteProvider {
+
+ public TestSuite getSuite(String arg) {
+ TestSuite suite = new TestSuite("Connection Test");
+ suite.addTest(new ConnectionTest("testConnect"));
+ suite.addTest(new ConnectionTest("testResolveFilterString"));
+ return suite;
+ }
+
+}
diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/systems/core/SystemTestPlugin.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/systems/core/SystemTestPlugin.java
new file mode 100644
index 00000000000..ec64a630251
--- /dev/null
+++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/systems/core/SystemTestPlugin.java
@@ -0,0 +1,36 @@
+/* *******************************************************************************
+ * Copyright (c) 2006 IBM Corporation. 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:
+ * Don Yantzi (IBM) - initial contribution.
+ * David Dykstal (IBM) - initial contribution.
+ * *******************************************************************************/
+package org.eclipse.rse.tests.systems.core;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+public class SystemTestPlugin extends AbstractUIPlugin {
+
+ private static SystemTestPlugin singleton = null;
+
+ /**
+ * Constructs a new plugin.
+ * The plugin should be constructed by the workbench exactly once,
+ * so it is saved as a singleton.
+ */
+ public SystemTestPlugin() {
+ super();
+ singleton = this;
+ }
+
+ /**
+ * @return the singleton plugin.
+ */
+ public static SystemTestPlugin getDefault() {
+ return singleton;
+ }
+
+}
diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/systems/core/SystemTestUtil.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/systems/core/SystemTestUtil.java
new file mode 100644
index 00000000000..bceefa5b78b
--- /dev/null
+++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/systems/core/SystemTestUtil.java
@@ -0,0 +1,215 @@
+/* *******************************************************************************
+ * Copyright (c) 2006 IBM Corporation. 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:
+ * Don Yantzi (IBM) - initial contribution.
+ * David Dykstal (IBM) - initial contribution.
+ * *******************************************************************************/
+package org.eclipse.rse.tests.systems.core;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.text.MessageFormat;
+import java.util.Properties;
+
+import org.eclipse.rse.core.ISystemUserIdConstants;
+import org.eclipse.rse.core.PasswordPersistenceManager;
+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.model.ISystemRegistryUI;
+import org.eclipse.rse.model.ISystemResourceChangeEvents;
+import org.eclipse.rse.model.SystemRegistry;
+import org.eclipse.rse.model.SystemResourceChangeEvent;
+import org.eclipse.rse.ui.RSEUIPlugin;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Shell;
+import org.osgi.framework.Bundle;
+
+/**
+ * SystemTestUtil is a collection of static utility methods for creating
+ * RSE system connections and associated RSE artifacts (filter pools, filters, etc...) to assist
+ * you in writing your JUnit plug-in testcases.
+ *
+ * Since most JUnit PDE testcases create a brand new workspace when they start you will likely need
+ * to create a new RSE connection to start your testing. The "createSystemConnection(...) methods
+ * are therefore your most likely starting point.
+ *
+ * Note: If your testcases subclasses AbstractSystemConnectionTest then you can use the getConnection()
+ * method instead.
+ *
+ * @author yantzi
+ */
+public class SystemTestUtil {
+
+ /**
+ * Load a properties file and return the Properties object.
+ * @param bundle The bundle containing the properties.
+ * @param propertiesFileName the properties file name relative to the bundle.
+ * @return the Properties object, may be empty if no such file is found or an error occurs.
+ */
+ public static Properties loadProperties(Bundle bundle, String propertiesFileName) {
+ URL url = bundle.getEntry(propertiesFileName);
+ Properties result = new Properties();
+ try {
+ InputStream in = url.openStream();
+ result.load(in);
+ in.close();
+ } catch (IOException e) {
+ }
+ return result;
+ }
+
+ /**
+ * @param profileName The profile in which to look for the host.
+ * @param hostName The host to look for.
+ * @return The requested host (connection) or null if none was found.
+ */
+ public static IHost findHost(String profileName, String hostName) {
+ IHost host = null;
+ ISystemRegistryUI registry = RSEUIPlugin.getTheSystemRegistry();
+ ISystemProfile profile = registry.getSystemProfile(profileName);
+ if (profile != null) {
+ host = registry.getHost(profile, hostName);
+ }
+ return host;
+ }
+
+ /**
+ * Create a new system connection.
+ * If a user ID and password are not provided then the testcase will pause while the user
+ * is prompted to signon.
+ *
+ * @param profileName The name of an existing RSE profile under which this connection should be created.
+ * @param hostName The name for the new RSE connection.
+ * @param hostAddress The IP address or name for the new RSE connection.
+ * @param systemType the system type of the new connection.
+ * @param userid The user ID for the new RSE connection. May be null.
+ * @param password The password to be used in conjunction with the user ID for
+ * connecting to the remote system. May be null.
+ * @return A new RSE IHost for the specified host information
+ * @throws Exception
+ */
+ public static IHost createHost(String profileName, String hostName, String hostAddress, String systemType, String userid, String password) throws Exception {
+ ISystemRegistryUI registry = RSEUIPlugin.getTheSystemRegistry();
+ IHost connection = registry.createHost(profileName, systemType, hostName, hostAddress, null, userid, ISystemUserIdConstants.USERID_LOCATION_CONNECTION, null);
+ if (userid != null && password != null) {
+ savePassword(hostAddress, userid, password, systemType); // register password for this hostname
+ }
+ return connection;
+ }
+
+ /**
+ * Delete a host given its name and the name of its profile. If the host is not found then
+ * do nothing.
+ * @param profileName the name of the profile containing the host
+ * @param hostName the name of the host to delete
+ */
+ public static void deleteHost(String profileName, String hostName) {
+ IHost host = findHost(profileName, hostName);
+ if (host != null) {
+ SystemRegistry registry = RSEUIPlugin.getTheSystemRegistry();
+ registry.deleteHost(host);
+ registry.fireEvent(new SystemResourceChangeEvent(host, ISystemResourceChangeEvents.EVENT_DELETE, registry));
+ }
+ }
+
+ /**
+ * Find a profile given its name.
+ * @param profileName the name of the profile to find
+ * @return the ISystemProfile that was found.
+ */
+ public static ISystemProfile findProfile(String profileName) {
+ ISystemRegistryUI registry = RSEUIPlugin.getTheSystemRegistry();
+ ISystemProfile profile = registry.getSystemProfile(profileName);
+ return profile;
+ }
+
+ /**
+ * Creates a new profile. If the profile already exists, it throws an exception.
+ * @param profileName The name of the profile to create.
+ * @return The profile that was created.
+ * @throws RuntimeException if the profile exists or it cannot be created.
+ */
+ public static ISystemProfile createProfile(String profileName) {
+ ISystemRegistryUI registry = RSEUIPlugin.getTheSystemRegistry();
+ ISystemProfile profile = findProfile(profileName);
+ if (profile != null) {
+ throw new RuntimeException(MessageFormat.format("Profile {0} already exists.", new Object[] { profileName }));
+ }
+ try {
+ profile = registry.createSystemProfile(profileName, true);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ return profile;
+ }
+
+ /**
+ * Save the password assocaited with the specified hostname and userid. This method overwrites any previously
+ * saved password for the specified hostname and user ID.
+ *
+ * @param hostname The hostname to save the password for.
+ * @param userid The user ID to save the password for.
+ * @param password The password to be saved.
+ * @param systemtype the system type of the new connection
+ *
+ * @return true if the password was saved okay or false if it was not able to be saved
+ */
+ public static boolean savePassword(String hostname, String userid, String password, String systemtype) {
+ SystemSignonInformation info = new SystemSignonInformation(hostname, userid, password, systemtype);
+ return (PasswordPersistenceManager.getInstance().add(info, true) == PasswordPersistenceManager.RC_OK);
+ }
+
+ /**
+ * Retrieve the default RSE system profile. If the default profile has not been renamed from the default
+ * name ("Private") then the profile is renamed to the DEFAULT_PROFILE_NAME specified in
+ * SystemConnectionTests.properties.
+ * @param profileName the name the default profile will become.
+ * @return The default RSE system profile.
+ * @throws Exception of the profile cannot be found
+ */
+ public static ISystemProfile getDefaultProfile(String profileName) throws Exception {
+ ISystemRegistry sr = RSEUIPlugin.getTheSystemRegistry();
+ ISystemProfile defaultProfile = sr.getSystemProfileManager().getDefaultPrivateSystemProfile();
+ if (defaultProfile != null && defaultProfile.getName().equals("Private")) {
+ sr.renameSystemProfile(defaultProfile, profileName);
+ }
+ return defaultProfile;
+ }
+
+ /**
+ * Rename the default RSE system profile.
+ *
+ * @param name The new name for the default RSE system profile.
+ *
+ * @return The default RSE system profile
+ * @throws Exception if the profile cannot be renamed
+ */
+ public static ISystemProfile renameDefaultProfile(String name) throws Exception {
+ ISystemRegistry sr = RSEUIPlugin.getTheSystemRegistry();
+ ISystemProfile defaultProfile = sr.getSystemProfileManager().getDefaultPrivateSystemProfile();
+ if (defaultProfile != null) {
+ sr.renameSystemProfile(defaultProfile, name);
+ }
+ return defaultProfile;
+ }
+
+ /**
+ * Display a simple String message to the user. This can be used to provide testing instructions to the user
+ * to guide them through semi-automated test cases.
+ * @param shell the shell on which to show the message
+ * @param message the message to show
+ */
+ public static void displayMessage(Shell shell, String message) {
+ MessageBox msgBox = new MessageBox(shell);
+ msgBox.setMessage(message);
+ msgBox.open();
+ }
+
+}
diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/systems/persistence/PersistenceTest.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/systems/persistence/PersistenceTest.java
new file mode 100644
index 00000000000..f9f5dd619f4
--- /dev/null
+++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/systems/persistence/PersistenceTest.java
@@ -0,0 +1,35 @@
+package org.eclipse.rse.tests.systems.persistence;
+
+import org.eclipse.rse.core.model.ISystemProfile;
+import org.eclipse.rse.tests.framework.AnnotatingTestCase;
+import org.eclipse.rse.tests.systems.core.SystemTestUtil;
+
+public class PersistenceTest extends AnnotatingTestCase {
+
+ public PersistenceTest(String name) {
+ super(name);
+ }
+
+ public void testHostCreation() throws Exception {
+ ISystemProfile profile = SystemTestUtil.findProfile("TestProfile");
+ if (profile == null) {
+ SystemTestUtil.createProfile("TestProfile");
+ }
+ SystemTestUtil.createHost("TestProfile", "TestHost1", "localhost", "Unix", "userid", "password");
+ SystemTestUtil.createHost("TestProfile", "TestHost2", "localhost", "Unix", "userid", "password");
+ SystemTestUtil.createHost("TestProfile", "TestHost3", "localhost", "Unix", "userid", "password");
+ SystemTestUtil.createHost("TestProfile", "TestHost4", "localhost", "Unix", "userid", "password");
+ SystemTestUtil.createHost("TestProfile", "TestHost5", "localhost", "Unix", "userid", "password");
+ SystemTestUtil.createHost("TestProfile", "TestHost6", "localhost", "Unix", "userid", "password");
+ }
+
+ public void testHostDeletion() throws Exception {
+ SystemTestUtil.deleteHost("TestProfile", "TestHost1");
+ SystemTestUtil.deleteHost("TestProfile", "TestHost2");
+ SystemTestUtil.deleteHost("TestProfile", "TestHost3");
+ SystemTestUtil.deleteHost("TestProfile", "TestHost4");
+ SystemTestUtil.deleteHost("TestProfile", "TestHost5");
+ SystemTestUtil.deleteHost("TestProfile", "TestHost6");
+ }
+
+}
diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/systems/persistence/PersistenceTestSuite.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/systems/persistence/PersistenceTestSuite.java
new file mode 100644
index 00000000000..820c04b9861
--- /dev/null
+++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/systems/persistence/PersistenceTestSuite.java
@@ -0,0 +1,20 @@
+package org.eclipse.rse.tests.systems.persistence;
+
+import junit.framework.TestSuite;
+
+import org.eclipse.rse.tests.framework.ITestSuiteProvider;
+
+public class PersistenceTestSuite implements ITestSuiteProvider {
+
+ public TestSuite getSuite(String argument) {
+ TestSuite suite = new TestSuite("Persistence Test Suite");
+ if (argument == null || argument.equals("create")) {
+ suite.addTest(new PersistenceTest("testHostCreation"));
+ }
+ if (argument == null || argument.equals("delete")) {
+ suite.addTest(new PersistenceTest("testHostDeletion"));
+ }
+ return suite;
+ }
+
+}
diff --git a/rse/tests/org.eclipse.rse.tests/test.xml b/rse/tests/org.eclipse.rse.tests/test.xml
new file mode 100644
index 00000000000..7462c094272
--- /dev/null
+++ b/rse/tests/org.eclipse.rse.tests/test.xml
@@ -0,0 +1,84 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+