1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-06 07:45:50 +02:00

[166117] incorporating patch from Uwe Stieber - this removes the tests from the test view, but allows them to run from PDE/JUnit.

This commit is contained in:
David Dykstal 2006-12-05 20:20:48 +00:00
parent e75eb83b3f
commit 4a01aad91a
24 changed files with 1236 additions and 680 deletions

View file

@ -1,8 +1,8 @@
#Tue Nov 28 18:18:22 CET 2006
#Tue Dec 05 13:08:02 CST 2006
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4
org.eclipse.jdt.core.compiler.compliance=1.4
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
org.eclipse.jdt.core.compiler.source=1.3
org.eclipse.jdt.core.compiler.source=1.4

View file

@ -0,0 +1,3 @@
#Tue Dec 05 13:08:02 CST 2006
eclipse.preferences.version=1
internal.default.compliance=user

View file

@ -1,18 +1,18 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: RSE Core Tests
Bundle-SymbolicName: org.eclipse.rse.tests.core;singleton:=true
Bundle-SymbolicName: org.eclipse.rse.tests;singleton:=true
Bundle-Version: 1.0.1.qualifier
Bundle-Activator: org.eclipse.rse.tests.systems.core.SystemTestPlugin
Bundle-Activator: org.eclipse.rse.tests.RSETestsPlugin
Bundle-Vendor: Eclipse.org
Bundle-Localization: plugin
Require-Bundle: org.junit,
org.eclipse.core.runtime,
org.eclipse.core.resources,
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
org.eclipse.rse.subsystems.shells.core
Eclipse-LazyStart: true
Bundle-RequiredExecutionEnvironment: J2SE-1.4

View file

@ -0,0 +1,16 @@
###############################################################################
# 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
###############################################################################
#
# Externalized MANIFEST.MF and plugin.xml strings
#
plugin.vendor=Eclipse.org
plugin.name=RSE Core Tests

View file

@ -1,19 +1,4 @@
<?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,56 @@
/* *******************************************************************************
* 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:
* Uwe Stieber (Wind River) - initial contribution.
* *******************************************************************************/
package org.eclipse.rse.tests;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.eclipse.rse.tests.core.connection.RSEConnectionTestSuite;
import org.eclipse.rse.tests.internal.RSEInternalFrameworkTestSuite;
import org.eclipse.rse.tests.persistence.RSEPersistenceTestSuite;
/**
* Main class bundling all single specialized test suites into a
* overall complete one.
*/
public class RSECombinedTestSuite {
/**
* Standard Java application main method. Allows to launch the test
* suite from outside as part of nightly runs, headless runs or other.
* <p><b>Note:</b> Use only <code>junit.textui.TestRunner</code> here as
* it is explicitly supposed to output the test output to the shell the
* test suite has been launched from.
* <p>
* @param args The standard Java application command line parameters passed in.
*/
public static void main(String[] args) {
junit.textui.TestRunner.run(suite());
}
/**
* Combine all test into a suite and returns the test suite instance.
* <p>
* <b>Note: This method must be always called <i><code>suite</code></i> ! Otherwise
* the JUnit plug-in test launcher will fail to detect this class!</b>
* <p>
* @return The test suite instance.
*/
public static Test suite() {
TestSuite suite = new TestSuite("RSE Combined Test Suite"); //$NON-NLS-1$
// add the single test suites to the overall one here.
suite.addTest(RSEInternalFrameworkTestSuite.suite());
suite.addTest(RSEConnectionTestSuite.suite());
suite.addTest(RSEPersistenceTestSuite.suite());
return suite;
}
}

View file

@ -0,0 +1,150 @@
/* *******************************************************************************
* 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.
* Uwe Stieber (Wind River) - restructuring and cleanup
* *******************************************************************************/
package org.eclipse.rse.tests;
import java.text.MessageFormat;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import org.eclipse.ui.plugin.AbstractUIPlugin;
/**
* Main plugin class for the RSE JUnit tests framework. This
* class provides basic infra structure for accessing externalized
* string data.
*/
public class RSETestsPlugin extends AbstractUIPlugin {
// The shared plugin instance.
private static RSETestsPlugin plugin;
// The resource bundle associated with this plugin.
private ResourceBundle resourceBundle;
/**
* Constructor.
*/
public RSETestsPlugin() {
super();
plugin = this;
}
/**
* Returns the shared plugin instance.
*
* @return The plugin instance or <code>null</code> if not yet constructed.
*/
public static RSETestsPlugin getDefault() {
return plugin;
}
/**
* Returns the associated resource bundle. If necessary, the resource
* bundle will be initialized.
*
* @return The resource bundle instance.
*/
public ResourceBundle getResourceBundle() {
// If the resource bundle got created already, return the
// existing instance.
if (resourceBundle != null) return resourceBundle;
// The resource bundle had not been created yet -> create it.
resourceBundle = ResourceBundle.getBundle("org.eclipse.rse.tests.RSETestsResources"); //$NON-NLS-1$
return resourceBundle;
}
/**
* Queries the externalized string for the specified resource key from
* the plugins associated resource bundle.
*
* @param key The resource key. Must be not <code>null</code>!
* @return The externalized string or the resource key enclosed in exlamation marks.
*/
public static String getResourceString(String key) {
assert key != null;
// Query the resource bundle from the plugin instance.
ResourceBundle bundle = RSETestsPlugin.getDefault().getResourceBundle();
if (bundle != null) {
try {
// Lookup the key and return the corresponding string if found.
return bundle.getString(key);
} catch (MissingResourceException e) {
// return the key as is enclosed in exlamation marks.
}
}
// If we could not found the key or the bundle is invalid,
// return the key as is enclosed in exlamation marks.
return '!' + key + '!';
}
/**
* Queries the externalized string for the specified resource key from
* the plugins associated resource bundle. If a externalized resource
* for the specified key exist, a possible argument placeholder will be
* replaced by the specified value.
*
* @param key The resource key. Must be not <code>null</code>!
* @param argument The content for a possible placeholder. Must be not <code>null</code>.
* @return The externalized string or the resource key enclosed in exlamation marks.
*/
public static String getResourceString(String key, Object argument) {
assert argument != null;
return getResourceString(key, new Object[] { argument });
}
/**
* Queries the externalized string for the specified resource key from
* the plugins associated resource bundle. If a externalized resource
* for the specified key exist, possible argument placeholder will be
* replaced by their specified values.
*
* @param key The resource key. Must be not <code>null</code>!
* @param arguments The content for the possible arguments. Must be not <code>null</code>.
* @return The externalized string or the resource key enclosed in exlamation marks.
*/
public static String getResourceString(String key, Object[] arguments) {
assert arguments != null;
String resourceString = getResourceString(key);
if (!resourceString.startsWith("!")) { //$NON-NLS-1$
MessageFormat.format(resourceString, arguments);
}
return resourceString;
}
/**
* Checks if the test case given through the specified key is enabled for
* execution. A test case is considered enabled if either<br>
* <ul>
* <li>-D&lt;testId&gt; is true or</li>
* <li>getResourceString(&lt;testId&gt;) is true or</li>
* <li>neither the explicit -D option is specified nor the key exist in the associated
* resource bundle.</li>
* </ul>
*
* @param testId The unique string id of the test case to execute. Must be not <code>null</code>!
* @return <code>true</code> if the test case is enabled for execution, <code>false</code> otherwise.
*/
public static boolean isTestCaseEnabled(String testId) {
assert testId != null;
// Test first for the system property (explicit -D option).
String value = System.getProperty(testId);
// if (value != null) return Boolean.parseBoolean(value);
if (value != null) return value.equals("true"); //$NON-NLS-1$
// If the system property is not set, check for the key in the resource bundle
value = getResourceString(testId);
// if (value != null && !value.startsWith("!")) return Boolean.parseBoolean(value); //$NON-NLS-1$
if (value != null && !value.startsWith("!")) return value.equals("true"); //$NON-NLS-1$ //$NON-NLS-2$
return false;
}
}

View file

@ -0,0 +1,24 @@
###############################################################################
# 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
###############################################################################
#
# The following section controls the execution of the single test cases.
# Each test case can be disabled individually here.
#
RSEConnectionTestCase.testConnect=true
RSEConnectionTestCase.testResolveFilterString=true
RSEPersistenceTest.testHostCreation=true
RSEPersistenceTest.testHostDeletion=true
RSEConnectionTestCase.testConnect=true
RSEConnectionTestCase.testResolveFilterString=true

View file

@ -0,0 +1,43 @@
/* *******************************************************************************
* 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:
* Uwe Stieber (Wind River) - initial contribution.
* *******************************************************************************/
package org.eclipse.rse.tests.core;
/**
* Interface declaring public known and usable core test case properties.
*/
public interface IRSECoreTestCaseProperties {
static final String PROP_BASE_KEY = "org.eclipse.rse.tests.core"; //$NON-NLS-1$
/**
* Boolean property controling if or if not the Remote Systems View will be
* expanded before the test case is starting. The original view maximized
* state will be restored after the test case finished.
* <p>
* Default value is <b><code>true</code></b>.
*/
public static final String PROP_MAXIMIZE_REMOTE_SYSTEMS_VIEW = PROP_BASE_KEY + ".maximizeRemoteSystemsView"; //$NON-NLS-1$
/**
* String property specifying the perspective id to switch to before the
* test case is starting. The original perspective will be restored after
* the test case finished.
* <p>
* Default value is <b><code>org.eclipse.rse.ui.view.SystemPerspective</code></b>.
*/
public static final String PROP_SWITCH_TO_PERSPECTIVE = PROP_BASE_KEY + ".switchToPerspective"; //$NON-NLS-1$
/**
* Boolean property controling if the test execution should be forced into a non
* display thread (if not already running in a non display thread anyway).
* <p>
* Default value is <b><code>false</code></b>.
*/
public static final String PROP_FORCE_BACKGROUND_EXECUTION = PROP_BASE_KEY + ".forceBackgroundExecution"; //$NON-NLS-1$
}

View file

@ -0,0 +1,199 @@
/* *******************************************************************************
* 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:
* Uwe Stieber (Wind River) - initial contribution.
* *******************************************************************************/
package org.eclipse.rse.tests.core;
import java.util.Properties;
import junit.framework.TestCase;
import junit.framework.TestResult;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.rse.tests.RSETestsPlugin;
import org.eclipse.swt.widgets.Display;
/**
* Core RSE test case infra structure implementation.
*/
public class RSECoreTestCase extends TestCase {
private final Properties properties = new Properties();
/**
* Constructor.
*/
public RSECoreTestCase() {
this(null);
}
/**
* Constructor.
*
* @param name The test name.
*/
public RSECoreTestCase(String name) {
super(name);
// clear out all properties on construction.
properties.clear();
// initialize the core test properties
initializeProperties();
}
// ***** Test properties management and support methods *****
/**
* Initialize the core test properties. Override to modify core
* test properties or to add additional ones.
*/
protected void initializeProperties() {
setProperty(IRSECoreTestCaseProperties.PROP_MAXIMIZE_REMOTE_SYSTEMS_VIEW, true);
setProperty(IRSECoreTestCaseProperties.PROP_SWITCH_TO_PERSPECTIVE, "org.eclipse.rse.ui.view.SystemPerspective"); //$NON-NLS-1$
setProperty(IRSECoreTestCaseProperties.PROP_FORCE_BACKGROUND_EXECUTION, false);
}
/**
* Enables or disables the specified property.
*
* @param key The key of the property to enable or disable. Must be not <code>null</code>!
* @param enable Specify <code>true</code> to enable the property, <code>false</code> to disable the property.
*/
protected final void setProperty(String key, boolean enable) {
setProperty(key, enable ? Boolean.TRUE.toString() : Boolean.FALSE.toString());
}
/**
* Test if the specified property is equal to the specified value.
*
* @param key The key of the property to test. Must be not <code>null</code>!
* @param value The value to compare the property with.
* @return <code>true</code> if the property is equal to the specified value, <code>false</code> otherwise.
*/
protected final boolean isProperty(String key, boolean value) {
assert key != null;
return (value ? Boolean.TRUE : Boolean.FALSE).equals(Boolean.valueOf(properties.getProperty(key, "false"))); //$NON-NLS-1$
}
/**
* Sets the specified string value for the specified property. If the specified
* value is <code>null</code>, the specified property will be removed.
*
* @param key The key of the property to set. Must be not <code>null</code>!
* @param value The string value to set or <code>null</code>.
*/
protected final void setProperty(String key, String value) {
assert key != null;
if (value != null) {
properties.setProperty(key, value);
} else {
properties.remove(key);
}
}
/**
* Test if the specified property is equal to the specified value. If the specified
* value is <code>null</code>, this method returns <code>true</code> if the specified
* property key does not exist. The comparisation is case insensitive.
*
* @param key The key of the property to test. Must be not <code>null</code>!
* @param value The value to compare the property with or <code>null</code>
* @return <code>true</code> if the property is equal to the specified value
* or the specified value is <code>null</code> and the property does not exist,
* <code>false</code> otherwise.
*/
protected final boolean isProperty(String key, String value) {
assert key != null;
if (value != null) {
return value.equalsIgnoreCase(properties.getProperty(key));
} else {
return !properties.containsKey(key);
}
}
// ***** Test case life cycle management and support methods *****
private final static QualifiedName BACKGROUND_TEST_EXECUTION_FINISHED = new QualifiedName(RSETestsPlugin.getDefault().getBundle().getSymbolicName(), "background_test_execution_finished"); //$NON-NLS-1$
private final class RSEBackgroundTestExecutionJob extends Job {
private final TestResult result;
/**
* Constructor.
*/
public RSEBackgroundTestExecutionJob(TestResult result) {
super("RSE JUnit Test Case Execution Job"); //$NON-NLS-1$
setUser(false);
setPriority(Job.INTERACTIVE);
setRule(ResourcesPlugin.getWorkspace().getRoot());
assert result != null;
this.result = result;
}
/* (non-Javadoc)
* @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
*/
protected IStatus run(IProgressMonitor monitor) {
monitor.beginTask("Running test " + RSECoreTestCase.this.getName() + " ...", IProgressMonitor.UNKNOWN); //$NON-NLS-1$ //$NON-NLS-2$
// Execute the test now.
RSECoreTestCase.super.run(result);
monitor.done();
setProperty(BACKGROUND_TEST_EXECUTION_FINISHED, Boolean.TRUE);
// The job never fails. The test result is the real result.
return Status.OK_STATUS;
}
}
/* (non-Javadoc)
* @see junit.framework.TestCase#run(junit.framework.TestResult)
*/
public final void run(TestResult result) {
if (isProperty(IRSECoreTestCaseProperties.PROP_FORCE_BACKGROUND_EXECUTION, false)) {
// do not force test execution into background, just call super.run(result)
// from with the current thread.
super.run(result);
} else {
// Create the background job
final Job job = new RSEBackgroundTestExecutionJob(result);
// Initialize the BACKGROUND_EXECUTION_TEST_RESULT property
job.setProperty(BACKGROUND_TEST_EXECUTION_FINISHED, Boolean.FALSE);
// schedule the job to run immediatelly
job.schedule();
// wait till the job finished executing
Boolean isFinished = (Boolean)job.getProperty(BACKGROUND_TEST_EXECUTION_FINISHED);
Display display = Display.findDisplay(Thread.currentThread());
if (display != null) {
// The current thread is a display thread. The display event queue
// must be not blocked as otherwise asynchronous events are blocked too!!!!!
while (!Boolean.TRUE.equals(isFinished)) {
if (!display.readAndDispatch()) display.sleep();
isFinished = (Boolean)job.getProperty(BACKGROUND_TEST_EXECUTION_FINISHED);
}
} else {
// The current thread is not a display thread. The thread can be put asleep
// for while till the test result is retried to poll.
while (!Boolean.TRUE.equals(isFinished)) {
try { Thread.sleep(500); } catch (InterruptedException e) { /* ignored on purpose */ }
isFinished = (Boolean)job.getProperty(BACKGROUND_TEST_EXECUTION_FINISHED);
}
}
}
}
}

View file

@ -8,7 +8,7 @@
* Don Yantzi (IBM) - initial contribution.
* David Dykstal (IBM) - initial contribution.
* *******************************************************************************/
package org.eclipse.rse.tests.systems.connection;
package org.eclipse.rse.tests.core.connection;
import java.text.MessageFormat;
import java.util.Properties;
@ -23,9 +23,8 @@ 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.tests.RSETestsPlugin;
import org.eclipse.rse.tests.core.RSECoreTestCase;
import org.eclipse.rse.ui.RSEUIPlugin;
/**
@ -35,24 +34,32 @@ import org.eclipse.rse.ui.RSEUIPlugin;
*
* @author yantzi
*/
public class BaseConnectionTest extends AnnotatingTestCase {
public class RSEBaseConnectionTestCase extends RSECoreTestCase {
// Constants used to index into the SystemConnectionTests.properties file
private static final String DEFAULT_IP_NAME = "default_ip_name"; //$NON-NLS-1$
private static final String DEFAULT_SYSTEM_TYPE= "default_system_type"; //$NON-NLS-1$
private static final String DEFAULT_PROFILE_NAME = "default_profile_name"; //$NON-NLS-1$
private static final String DEFAULT_HOST_NAME = "default_host_name"; //$NON-NLS-1$
private static final String DEFAULT_USERID = "default_userid"; //$NON-NLS-1$
private static final String DEFAULT_PASSWORD = "default_password"; //$NON-NLS-1$
private IHost host = null;
private Properties properties = null;
/**
* Constructor for ConnectionTest.
* Constructor.
*
* @param name
* Name of current test being run.
* @param name The test name.
*/
public BaseConnectionTest(String name) {
public RSEBaseConnectionTestCase(String name) {
super(name);
}
protected void setUp() throws Exception {
super.setUp();
properties = SystemTestUtil.loadProperties(SystemTestPlugin.getDefault().getBundle(), "SystemConnectionInfo.properties");
properties = RSEConnectionTestUtil.loadProperties(RSETestsPlugin.getDefault().getBundle(), "SystemConnectionInfo.properties"); //$NON-NLS-1$
host = getHost();
}
@ -82,31 +89,31 @@ public class BaseConnectionTest extends AnnotatingTestCase {
* @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()
* @see RSEBaseConnectionTestCase#getHostName()
* @see RSEBaseConnectionTestCase#getHostAddress()
* @see RSEBaseConnectionTestCase#getSystemType()
* @see RSEBaseConnectionTestCase#getUserID()
* @see RSEBaseConnectionTestCase#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);
assertNotSame("need to change the profile name in SystemConnectionInfo.properties", "unknown", profileName); //$NON-NLS-1$ //$NON-NLS-2$
ISystemProfile profile = RSEConnectionTestUtil.findProfile(profileName);
if (profile == null) {
profile = SystemTestUtil.createProfile(profileName);
profile = RSEConnectionTestUtil.createProfile(profileName);
}
String hostName = getHostName();
assertNotSame("need to change the host name in SystemConnectionInfo.properties", "unknown", hostName);
host = SystemTestUtil.findHost(profileName, hostName);
assertNotSame("need to change the host name in SystemConnectionInfo.properties", "unknown", hostName); //$NON-NLS-1$ //$NON-NLS-2$
host = RSEConnectionTestUtil.findHost(profileName, hostName);
if (host == null) {
String userID = getUserID();
assertNotSame("need to change the user id in SystemConnectionInfo.properties", "unknown", userID);
assertNotSame("need to change the user id in SystemConnectionInfo.properties", "unknown", userID); //$NON-NLS-1$ //$NON-NLS-2$
String password = getPassword();
assertNotSame("need to change the password in SystemConnectionInfo.properties", "unknown", password);
assertNotSame("need to change the password in SystemConnectionInfo.properties", "unknown", password); //$NON-NLS-1$ //$NON-NLS-2$
String hostAddress = getHostAddress();
assertNotSame("need to change the host address in SystemConnectionInfo.properties", "unknown", hostAddress);
host = SystemTestUtil.createHost(profileName, hostName, hostAddress, getSystemType(), userID, password);
assertNotSame("need to change the host address in SystemConnectionInfo.properties", "unknown", hostAddress); //$NON-NLS-1$ //$NON-NLS-2$
host = RSEConnectionTestUtil.createHost(profileName, hostName, hostAddress, getSystemType(), userID, password);
}
}
return host;
@ -125,7 +132,7 @@ public class BaseConnectionTest extends AnnotatingTestCase {
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}));
throw new RuntimeException(MessageFormat.format("The subsystem is connected as {0}. Disconnect before changing.", new Object[] {activeId})); //$NON-NLS-1$
} else {
ISystemRegistry registry = RSECorePlugin.getDefault().getSystemRegistry();
ISubSystemConfiguration desiredConfiguration = registry.getSubSystemConfiguration(desiredConfigurationId);
@ -164,7 +171,7 @@ public class BaseConnectionTest extends AnnotatingTestCase {
* @return the name of the profile
*/
protected String getProfileName() {
return getString(ConnectionConstants.DEFAULT_PROFILE_NAME);
return getString(DEFAULT_PROFILE_NAME);
}
/**
@ -175,7 +182,7 @@ public class BaseConnectionTest extends AnnotatingTestCase {
* @return the name of the host
*/
protected String getHostName() {
return getString(ConnectionConstants.DEFAULT_HOST_NAME);
return getString(DEFAULT_HOST_NAME);
}
/**
@ -185,7 +192,7 @@ public class BaseConnectionTest extends AnnotatingTestCase {
* @return the host address information
*/
protected String getHostAddress() {
return getString(ConnectionConstants.DEFAULT_IP_NAME);
return getString(DEFAULT_IP_NAME);
}
/**
@ -196,7 +203,7 @@ public class BaseConnectionTest extends AnnotatingTestCase {
* @return the system type
*/
protected String getSystemType() {
return getString(ConnectionConstants.DEFAULT_SYSTEM_TYPE);
return getString(DEFAULT_SYSTEM_TYPE);
}
/**
@ -207,7 +214,7 @@ public class BaseConnectionTest extends AnnotatingTestCase {
* @return the user id the connection will use
*/
protected String getUserID() {
return getString(ConnectionConstants.DEFAULT_USERID);
return getString(DEFAULT_USERID);
}
/**
@ -218,7 +225,7 @@ public class BaseConnectionTest extends AnnotatingTestCase {
* @return the password used to establish the connection
*/
protected String getPassword() {
return getString(ConnectionConstants.DEFAULT_PASSWORD);
return getString(DEFAULT_PASSWORD);
}
}

View file

@ -8,18 +8,19 @@
* Don Yantzi (IBM) - initial contribution.
* David Dykstal (IBM) - initial contribution.
* *******************************************************************************/
package org.eclipse.rse.tests.systems.connection;
package org.eclipse.rse.tests.core.connection;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.tests.RSETestsPlugin;
import org.eclipse.rse.ui.ISystemPreferencesConstants;
import org.eclipse.rse.ui.RSEUIPlugin;
/**
* Basic connection tests.
*/
public class ConnectionTest extends BaseConnectionTest {
public class RSEConnectionTestCase extends RSEBaseConnectionTestCase {
public ConnectionTest(String name) {
public RSEConnectionTestCase(String name) {
super(name);
}
@ -28,15 +29,18 @@ public class ConnectionTest extends BaseConnectionTest {
* @throws Exception if there is a problem
*/
public void testConnect() throws Exception {
ISubSystem subsystem = getFileSubSystem("dstore.files");
assertNotNull("No dstore.files subystem", subsystem);
if (!RSETestsPlugin.isTestCaseEnabled("RSEConnectionTestCase.testConnect")) return; //$NON-NLS-1$
ISubSystem subsystem = getFileSubSystem("dstore.files"); //$NON-NLS-1$
assertNotNull("No dstore.files subystem", subsystem); //$NON-NLS-1$
// 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());
assertTrue("Subsystem not connected", subsystem.isConnected()); //$NON-NLS-1$
subsystem.disconnect();
Thread.sleep(5000); // disconnect runs as a separate job, give it some time to disconnect
assertFalse(subsystem.isConnected());
}
@ -45,14 +49,16 @@ public class ConnectionTest extends BaseConnectionTest {
* @throws Exception if there is a problem
*/
public void testResolveFilterString() throws Exception {
ISubSystem subsystem = getFileSubSystem("dstore.files");
assertNotNull("No dstore.files subystem", subsystem);
if (!RSETestsPlugin.isTestCaseEnabled("RSEConnectionTestCase.testResolveFilterString")) return; //$NON-NLS-1$
ISubSystem subsystem = getFileSubSystem("dstore.files"); //$NON-NLS-1$
assertNotNull("No dstore.files subystem", subsystem); //$NON-NLS-1$
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);
assertTrue("subsystem not connected", subsystem.isConnected()); //$NON-NLS-1$
Object[] objects = subsystem.resolveFilterString(null, "/bin/*"); //$NON-NLS-1$
assertNotNull("A null result was returned from resolveFilterString.", objects); //$NON-NLS-1$
assertTrue("No entries found in home directory.", objects.length > 0); //$NON-NLS-1$
} finally {
if (subsystem.isConnected()) {
subsystem.disconnect();

View file

@ -0,0 +1,48 @@
/* *******************************************************************************
* 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.core.connection;
import junit.framework.Test;
import junit.framework.TestSuite;
/**
* Main class bundling all RSE connection test cases.
*/
public class RSEConnectionTestSuite {
/**
* Standard Java application main method. Allows to launch the test
* suite from outside as part of nightly runs, headless runs or other.
* <p><b>Note:</b> Use only <code>junit.textui.TestRunner</code> here as
* it is explicitly supposed to output the test output to the shell the
* test suite has been launched from.
* <p>
* @param args The standard Java application command line parameters passed in.
*/
public static void main(String[] args) {
junit.textui.TestRunner.run(suite());
}
/**
* Combine all test into a suite and returns the test suite instance.
* <p>
* <b>Note: This method must be always called <i><code>suite</code></i> ! Otherwise
* the JUnit plug-in test launcher will fail to detect this class!</b>
* <p>
* @return The test suite instance.
*/
public static Test suite() {
TestSuite suite = new TestSuite("RSE Connection Test Suite"); //$NON-NLS-1$
// add the single test suites to the overall one here.
suite.addTestSuite(RSEConnectionTestCase.class);
return suite;
}
}

View file

@ -8,7 +8,7 @@
* Don Yantzi (IBM) - initial contribution.
* David Dykstal (IBM) - initial contribution.
* *******************************************************************************/
package org.eclipse.rse.tests.systems.core;
package org.eclipse.rse.tests.core.connection;
import java.io.IOException;
import java.io.InputStream;
@ -32,7 +32,7 @@ import org.eclipse.swt.widgets.Shell;
import org.osgi.framework.Bundle;
/**
* SystemTestUtil is a collection of static utility methods for creating
* RSEConnectionTestUtil 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>
@ -45,7 +45,7 @@ import org.osgi.framework.Bundle;
*
* @author yantzi
*/
public class SystemTestUtil {
public class RSEConnectionTestUtil {
/**
* Load a properties file and return the Properties object.
@ -140,7 +140,7 @@ public class SystemTestUtil {
ISystemRegistryUI registry = RSEUIPlugin.getTheSystemRegistry();
ISystemProfile profile = findProfile(profileName);
if (profile != null) {
throw new RuntimeException(MessageFormat.format("Profile {0} already exists.", new Object[] { profileName }));
throw new RuntimeException(MessageFormat.format("Profile {0} already exists.", new Object[] { profileName })); //$NON-NLS-1$
}
try {
profile = registry.createSystemProfile(profileName, true);
@ -177,7 +177,7 @@ public class SystemTestUtil {
public static ISystemProfile getDefaultProfile(String profileName) throws Exception {
ISystemRegistry sr = RSEUIPlugin.getTheSystemRegistry();
ISystemProfile defaultProfile = sr.getSystemProfileManager().getDefaultPrivateSystemProfile();
if (defaultProfile != null && defaultProfile.getName().equals("Private")) {
if (defaultProfile != null && defaultProfile.getName().equals("Private")) { //$NON-NLS-1$
sr.renameSystemProfile(defaultProfile, profileName);
}
return defaultProfile;

View file

@ -0,0 +1,49 @@
/* *******************************************************************************
* 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:
* Uwe Stieber (Wind River) - initial contribution.
* *******************************************************************************/
package org.eclipse.rse.tests.internal;
import junit.framework.Test;
import junit.framework.TestSuite;
/**
* Main class bundling all internal test case asuring the consistent
* functionality of the test framework itself.
*/
public class RSEInternalFrameworkTestSuite {
/**
* Standard Java application main method. Allows to launch the test
* suite from outside as part of nightly runs, headless runs or other.
* <p><b>Note:</b> Use only <code>junit.textui.TestRunner</code> here as
* it is explicitly supposed to output the test output to the shell the
* test suite has been launched from.
* <p>
* @param args The standard Java application command line parameters passed in.
*/
public static void main(String[] args) {
junit.textui.TestRunner.run(suite());
}
/**
* Combine all test into a suite and returns the test suite instance.
* <p>
* <b>Note: This method must be always called <i><code>suite</code></i> ! Otherwise
* the JUnit plug-in test launcher will fail to detect this class!</b>
* <p>
* @return The test suite instance.
*/
public static Test suite() {
TestSuite suite = new TestSuite("RSE Internal Framework Test Suite"); //$NON-NLS-1$
// add the single test suites to the overall one here.
suite.addTestSuite(RSETestsPluginTestCase.class);
return suite;
}
}

View file

@ -0,0 +1,32 @@
/* *******************************************************************************
* 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:
* Uwe Stieber (Wind River) - initial contribution.
* *******************************************************************************/
package org.eclipse.rse.tests.internal;
import java.util.ResourceBundle;
import org.eclipse.rse.tests.RSETestsPlugin;
import org.eclipse.rse.tests.core.RSECoreTestCase;
/**
* Test cases testing the functionality of the <code>RSETestsPlugin</code> class.
*/
public class RSETestsPluginTestCase extends RSECoreTestCase {
/**
* Test the association of the resource bundle to the plugin and related
* resource bundle functionality.
*/
public void testPluginResourceBundle() {
if (!RSETestsPlugin.isTestCaseEnabled("RSETestsPluginTestCase.testPluginResourceBundle")) return; //$NON-NLS-1$
ResourceBundle bundle = RSETestsPlugin.getDefault().getResourceBundle();
assertNotNull("No resource bundle associated with RSETestsPlugin!", bundle); //$NON-NLS-1$
}
}

View file

@ -0,0 +1,40 @@
package org.eclipse.rse.tests.persistence;
import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.tests.RSETestsPlugin;
import org.eclipse.rse.tests.core.RSECoreTestCase;
import org.eclipse.rse.tests.core.connection.RSEConnectionTestUtil;
public class RSEPersistenceTest extends RSECoreTestCase {
public RSEPersistenceTest(String name) {
super(name);
}
public void testHostCreation() throws Exception {
if (!RSETestsPlugin.isTestCaseEnabled("RSEPersistenceTest.testHostCreation")) return; //$NON-NLS-1$
ISystemProfile profile = RSEConnectionTestUtil.findProfile("TestProfile"); //$NON-NLS-1$
if (profile == null) {
RSEConnectionTestUtil.createProfile("TestProfile"); //$NON-NLS-1$
}
RSEConnectionTestUtil.createHost("TestProfile", "TestHost1", "localhost", "Unix", "userid", "password"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
RSEConnectionTestUtil.createHost("TestProfile", "TestHost2", "localhost", "Unix", "userid", "password"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
RSEConnectionTestUtil.createHost("TestProfile", "TestHost3", "localhost", "Unix", "userid", "password"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
RSEConnectionTestUtil.createHost("TestProfile", "TestHost4", "localhost", "Unix", "userid", "password"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
RSEConnectionTestUtil.createHost("TestProfile", "TestHost5", "localhost", "Unix", "userid", "password"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
RSEConnectionTestUtil.createHost("TestProfile", "TestHost6", "localhost", "Unix", "userid", "password"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
}
public void testHostDeletion() throws Exception {
if (!RSETestsPlugin.isTestCaseEnabled("RSEPersistenceTest.testHostDeletion")) return; //$NON-NLS-1$
RSEConnectionTestUtil.deleteHost("TestProfile", "TestHost1"); //$NON-NLS-1$ //$NON-NLS-2$
RSEConnectionTestUtil.deleteHost("TestProfile", "TestHost2"); //$NON-NLS-1$ //$NON-NLS-2$
RSEConnectionTestUtil.deleteHost("TestProfile", "TestHost3"); //$NON-NLS-1$ //$NON-NLS-2$
RSEConnectionTestUtil.deleteHost("TestProfile", "TestHost4"); //$NON-NLS-1$ //$NON-NLS-2$
RSEConnectionTestUtil.deleteHost("TestProfile", "TestHost5"); //$NON-NLS-1$ //$NON-NLS-2$
RSEConnectionTestUtil.deleteHost("TestProfile", "TestHost6"); //$NON-NLS-1$ //$NON-NLS-2$
}
}

View file

@ -0,0 +1,39 @@
package org.eclipse.rse.tests.persistence;
import junit.framework.Test;
import junit.framework.TestSuite;
/**
* Main class bundling all RSE connection test cases.
*/
public class RSEPersistenceTestSuite {
/**
* Standard Java application main method. Allows to launch the test
* suite from outside as part of nightly runs, headless runs or other.
* <p><b>Note:</b> Use only <code>junit.textui.TestRunner</code> here as
* it is explicitly supposed to output the test output to the shell the
* test suite has been launched from.
* <p>
* @param args The standard Java application command line parameters passed in.
*/
public static void main(String[] args) {
junit.textui.TestRunner.run(suite());
}
/**
* Combine all test into a suite and returns the test suite instance.
* <p>
* <b>Note: This method must be always called <i><code>suite</code></i> ! Otherwise
* the JUnit plug-in test launcher will fail to detect this class!</b>
* <p>
* @return The test suite instance.
*/
public static Test suite() {
TestSuite suite = new TestSuite("RSE Persistence Test Suite"); //$NON-NLS-1$
// add the single test suites to the overall one here.
suite.addTestSuite(RSEPersistenceTest.class);
return suite;
}
}

View file

@ -1,27 +0,0 @@
/* *******************************************************************************
* 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

@ -1,25 +0,0 @@
/* *******************************************************************************
* 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

@ -1,36 +0,0 @@
/* *******************************************************************************
* 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

@ -1,35 +0,0 @@
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

@ -1,20 +0,0 @@
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

@ -1,14 +1,19 @@
<?xml version="1.0"?>
<!--
Run post build tests.
Not yet complete.
Needs to be updated and tested for org.eclipse.rse
-->
<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"/>
<property name="plugin-name" value="org.eclipse.rse.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 -->
@ -16,21 +21,18 @@
<target name="init">
<tstamp/>
<delete>
<fileset dir="${eclipse-home}" includes="com.ibm.etools.iseries.*.xml"/>
<fileset dir="${eclipse-home}" includes="org.eclipse.rse.tests.*.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"/>
<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"/>
<property name="classname" value="org.eclipse.rse.tests.SampleTestSuite"/>
</ant>
<!-- Commented out until source of problem found (not reusing same workspace dir)