1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-04 15:45:25 +02:00

initial population of automated JUnit tests

This commit is contained in:
David Dykstal 2006-11-21 22:24:55 +00:00
parent 8142289743
commit 482f5bb864
15 changed files with 850 additions and 0 deletions

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.rse.tests</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<plugin>
<extension
point="org.eclipse.rse.tests.framework.suites">
<suite type="generated" name="Connection Test Suite">
<arg name="class" value="org.eclipse.rse.tests.systems.connection.ConnectionTestSuite"/>
</suite>
<suite type="generated" name="Persistence Test Suite (Creation)">
<arg name="class" value="org.eclipse.rse.tests.systems.persistence.PersistenceTestSuite"/>
<arg name="argument" value="create"/>
</suite>
<suite type="generated" name="Persistence Test Suite (Deletion)">
<arg name="class" value="org.eclipse.rse.tests.systems.persistence.PersistenceTestSuite"/>
<arg name="argument" value="delete"/>
</suite>
</extension>
</plugin>

View file

@ -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);
}
}

View file

@ -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";
}

View file

@ -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();
}
}
}
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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.
* <p>
* 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.
* <p>
* 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();
}
}

View file

@ -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");
}
}

View file

@ -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;
}
}

View file

@ -0,0 +1,84 @@
<?xml version="1.0"?>
<project name="testsuite" default="run" basedir=".">
<!-- The property ${eclipse-home} should be passed into this script -->
<!-- Set a meaningful default value for when it is not. -->
<property name="eclipse-home" value="${basedir}\..\.."/>
<!-- sets the properties eclipse-home, and library-file -->
<property name="plugin-name" value="com.ibm.etools.iseries.tests"/>
<property name="library-file"
value="${eclipse-home}/plugins/org.eclipse.test/library.xml"/>
<!-- This target holds all initialization code that needs to be done for -->
<!-- all tests that are to be run. Initialization for individual tests -->
<!-- should be done within the body of the suite target. -->
<target name="init">
<tstamp/>
<delete>
<fileset dir="${eclipse-home}" includes="com.ibm.etools.iseries.*.xml"/>
</delete>
</target>
<!-- This target defines the tests that need to be run. -->
<target name="suite">
<property name="test-folder"
value="${eclipse-home}/ui_iseriestests_folder"/>
<delete dir="${test-folder}" quiet="true"/>
<ant target="ui-test" antfile="${library-file}" dir="${eclipse-home}">
<property name="data-dir" value="${test-folder}"/>
<property name="plugin-name" value="${plugin-name}"/>
<property name="classname"
value="com.ibm.etools.iseries.tests.SampleTestSuite"/>
</ant>
<!-- Commented out until source of problem found (not reusing same workspace dir)
<ant target="ui-test" antfile="${library-file}" dir="${eclipse-home}">
<property name="data-dir" value="${session-folder}"/>
<property name="plugin-name" value="${plugin-name}"/>
<property name="classname"
value="org.eclipse.ui.tests.api.SessionRestoreTest"/>
</ant>
-->
<!--
<property name="sniff-folder"
value="${eclipse-home}/ui_sniff_folder"/>
<delete dir="${sniff-folder}" quiet="true"/>
<ant target="ui-test" antfile="${library-file}" dir="${eclipse-home}">
<property name="data-dir" value="${sniff-folder}"/>
<property name="plugin-name" value="${plugin-name}"/>
<property name="classname"
value="org.eclipse.ui.tests.UiTestSuite"/>
</ant>
<property name="jface-sniff-folder"
value="${eclipse-home}/jface_sniff_folder"/>
<delete dir="${jface-sniff-folder}" quiet="true"/>
<ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
<property name="data-dir" value="${jface-sniff-folder}"/>
<property name="plugin-name" value="${plugin-name}"/>
<property name="classname"
value="org.eclipse.jface.tests.viewers.AllTests"/>
</ant>
-->
</target>
<!-- This target holds code to cleanup the testing environment after -->
<!-- after all of the tests have been run. You can use this target to -->
<!-- delete temporary files that have been created. -->
<target name="cleanup">
</target>
<!-- This target runs the test suite. Any actions that need to happen -->
<!-- after all the tests have been run should go here. -->
<target name="run" depends="init,suite,cleanup">
<ant target="collect" antfile="${library-file}" dir="${eclipse-home}">
<property name="includes" value="com.ibm.etools.iseries.*.xml"/>
<property name="output-file" value="${plugin-name}.xml"/>
</ant>
</target>
</project>