diff --git a/rse/tests/org.eclipse.rse.tests/.settings/org.eclipse.jdt.core.prefs b/rse/tests/org.eclipse.rse.tests/.settings/org.eclipse.jdt.core.prefs index 3606a63265d..97c0defc845 100644 --- a/rse/tests/org.eclipse.rse.tests/.settings/org.eclipse.jdt.core.prefs +++ b/rse/tests/org.eclipse.rse.tests/.settings/org.eclipse.jdt.core.prefs @@ -1,8 +1,70 @@ -#Tue Dec 05 13:08:02 CST 2006 +#Mon Dec 18 18:27:07 GMT+01:00 2006 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4 org.eclipse.jdt.core.compiler.compliance=1.4 +org.eclipse.jdt.core.compiler.doc.comment.support=enabled +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning +org.eclipse.jdt.core.compiler.problem.autoboxing=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=enabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=error +org.eclipse.jdt.core.compiler.problem.emptyStatement=warning +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning +org.eclipse.jdt.core.compiler.problem.fieldHiding=warning +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=error +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning +org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning +org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=protected +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=protected +org.eclipse.jdt.core.compiler.problem.missingJavadocTags=warning +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=protected +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning +org.eclipse.jdt.core.compiler.problem.nullReference=ignore +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=error +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.source=1.4 diff --git a/rse/tests/org.eclipse.rse.tests/.settings/org.eclipse.jdt.ui.prefs b/rse/tests/org.eclipse.rse.tests/.settings/org.eclipse.jdt.ui.prefs deleted file mode 100644 index 5f7e8abd767..00000000000 --- a/rse/tests/org.eclipse.rse.tests/.settings/org.eclipse.jdt.ui.prefs +++ /dev/null @@ -1,3 +0,0 @@ -#Tue Dec 05 13:08:02 CST 2006 -eclipse.preferences.version=1 -internal.default.compliance=user diff --git a/rse/tests/org.eclipse.rse.tests/SystemConnectionInfo.properties b/rse/tests/org.eclipse.rse.tests/SystemConnectionInfo.properties deleted file mode 100644 index 2a794efe937..00000000000 --- a/rse/tests/org.eclipse.rse.tests/SystemConnectionInfo.properties +++ /dev/null @@ -1,33 +0,0 @@ -############################################################################### -# 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 index a1d5efa6bee..add787540f9 100644 --- a/rse/tests/org.eclipse.rse.tests/build.properties +++ b/rse/tests/org.eclipse.rse.tests/build.properties @@ -14,7 +14,7 @@ output.. = bin/ bin.includes = .,\ plugin.xml,\ META-INF/,\ - SystemConnectionInfo.properties,\ + test.data/,\ test.xml,\ plugin.properties diff --git a/rse/tests/org.eclipse.rse.tests/plugin.xml b/rse/tests/org.eclipse.rse.tests/plugin.xml index 78a7bfcb361..618b9e81bef 100644 --- a/rse/tests/org.eclipse.rse.tests/plugin.xml +++ b/rse/tests/org.eclipse.rse.tests/plugin.xml @@ -10,8 +10,5 @@ - - - diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/RSECombinedTestSuite.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/RSECombinedTestSuite.java index d2e199487bf..b47b3e3cd98 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/RSECombinedTestSuite.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/RSECombinedTestSuite.java @@ -1,5 +1,5 @@ /* ******************************************************************************* - * Copyright (c) 2006 IBM Corporation. All rights reserved. + * Copyright (c) 2006 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 @@ -15,7 +15,6 @@ import junit.framework.TestSuite; import org.eclipse.rse.tests.core.connection.RSEConnectionTestSuite; import org.eclipse.rse.tests.framework.DelegatingTestSuiteHolder; import org.eclipse.rse.tests.internal.RSEInternalFrameworkTestSuite; -import org.eclipse.rse.tests.persistence.RSEPersistenceTestSuite; /** * Main class bundling all single specialized test suites into a @@ -50,7 +49,6 @@ public class RSECombinedTestSuite extends DelegatingTestSuiteHolder { // add the single test suites to the overall one here. suite.addTest(RSEInternalFrameworkTestSuite.suite()); suite.addTest(RSEConnectionTestSuite.suite()); - suite.addTest(RSEPersistenceTestSuite.suite()); return suite; } diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/RSETestsPlugin.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/RSETestsPlugin.java index fab0e12725c..32f56fa44df 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/RSETestsPlugin.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/RSETestsPlugin.java @@ -1,5 +1,5 @@ /* ******************************************************************************* - * Copyright (c) 2006 IBM Corporation. All rights reserved. + * Copyright (c) 2006 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 diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/RSETestsResources.properties b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/RSETestsResources.properties index 69e7d2876b4..cce8f115697 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/RSETestsResources.properties +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/RSETestsResources.properties @@ -19,13 +19,13 @@ RSETestsPluginTestCase.testPluginResourceBundle=true RSEInternalFrameworkTestCase.testCoreTestPropertiesHandling=true RSEInternalFrameworkTestCase.testWaitAndDispatch=true RSEInternalFrameworkTestCase.testTestDataLocationManagement=true +RSEInternalFrameworkTestCase.testConnectionManager=true +RSEConnectionTestCase.testConnectionCreation=true +RSEConnectionTestCase.testConnectionRemoval=true RSEConnectionTestCase.testConnect=true RSEConnectionTestCase.testResolveFilterString=true -RSEPersistenceTest.testHostCreation=true -RSEPersistenceTest.testHostDeletion=true - # # The following section contains externalized string for the single classes # diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/IRSECoreTestCaseProperties.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/IRSECoreTestCaseProperties.java index 4116eaa7007..0d1282411a1 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/IRSECoreTestCaseProperties.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/IRSECoreTestCaseProperties.java @@ -1,5 +1,5 @@ /* ******************************************************************************* - * Copyright (c) 2006 IBM Corporation. All rights reserved. + * Copyright (c) 2006 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 diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/IRSETestLogCollectorDelegate.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/IRSETestLogCollectorDelegate.java index def9993d6a2..75cd8a67a31 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/IRSETestLogCollectorDelegate.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/IRSETestLogCollectorDelegate.java @@ -1,5 +1,5 @@ /* ******************************************************************************* - * Copyright (c) 2006 IBM Corporation. All rights reserved. + * Copyright (c) 2006 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 diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/IRSEViews.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/IRSEViews.java index 9c39384d4be..601d0790131 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/IRSEViews.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/IRSEViews.java @@ -1,5 +1,5 @@ /* ******************************************************************************* - * Copyright (c) 2006 IBM Corporation. All rights reserved. + * Copyright (c) 2006 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 diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/RSECoreTestCase.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/RSECoreTestCase.java index f87bf787119..bab0aa0705d 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/RSECoreTestCase.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/RSECoreTestCase.java @@ -1,5 +1,5 @@ /* ******************************************************************************* - * Copyright (c) 2006 IBM Corporation. All rights reserved. + * Copyright (c) 2006 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 @@ -150,9 +150,8 @@ public class RSECoreTestCase extends TestCase { assert key != null; if (value != null) { return value.equalsIgnoreCase(properties.getProperty(key)); - } else { - return !properties.containsKey(key); } + return !properties.containsKey(key); } /** @@ -168,13 +167,15 @@ public class RSECoreTestCase extends TestCase { // ***** 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$ + 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. + * + * @param result The test result object the test is reporting failures to. Must be not null. */ public RSEBackgroundTestExecutionJob(TestResult result) { super("RSE JUnit Test Case Execution Job"); //$NON-NLS-1$ @@ -194,7 +195,7 @@ public class RSECoreTestCase extends TestCase { // Execute the test now. result.addListener(TEST_LISTENER); - RSECoreTestCase.super.run(result); + invokeTestCaseRunImpl(result); result.removeListener(TEST_LISTENER); monitor.done(); @@ -233,6 +234,16 @@ public class RSECoreTestCase extends TestCase { public void dispose() { /* nothing to dispose here */ } } + /** + * Internal accessor method to call the original junit. + * framework.TestCase.run(TestResult) implementation. + * + * @param result The test result object the test is reporting failures to. Must be not null. + */ + final void invokeTestCaseRunImpl(TestResult result) { + super.run(result); + } + /* (non-Javadoc) * @see junit.framework.TestCase#run(junit.framework.TestResult) */ @@ -520,19 +531,20 @@ public class RSECoreTestCase extends TestCase { // ***** Test failures log collector management and support methods ***** - private final TestListener TEST_LISTENER = new RSETestFailureListener(); + final TestListener TEST_LISTENER = new RSETestFailureListener(); /** * Listens to the test executions and collect the test log files * through the known list of test log collector delegates in a test * had an error or failed. */ - private class RSETestFailureListener implements TestListener { + class RSETestFailureListener implements TestListener { /* (non-Javadoc) * @see junit.framework.TestListener#startTest(junit.framework.Test) */ public void startTest(Test test) { + // nothing to do on start test } /* (non-Javadoc) @@ -577,6 +589,7 @@ public class RSECoreTestCase extends TestCase { * @see junit.framework.TestListener#endTest(junit.framework.Test) */ public void endTest(Test test) { + // nothing to do on end test } } diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/RSEWaitAndDispatchUtil.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/RSEWaitAndDispatchUtil.java index 4912a556b3c..30b8f3c2d03 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/RSEWaitAndDispatchUtil.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/RSEWaitAndDispatchUtil.java @@ -1,5 +1,5 @@ /* ******************************************************************************* - * Copyright (c) 2006 IBM Corporation. All rights reserved. + * Copyright (c) 2006 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 @@ -24,7 +24,9 @@ public final class RSEWaitAndDispatchUtil { /** * Private constructor. */ - private RSEWaitAndDispatchUtil() {} + private RSEWaitAndDispatchUtil() { + // nothing to do. The class cannot be instanciated. + } /** * Blocks the calling thread from execution till the specified @@ -87,6 +89,8 @@ public final class RSEWaitAndDispatchUtil { * * @param timeout The time to wait till the method return in milli seconds. Must be larger or equals than 0. * @param condition The interrupt condition to test. Must be not null. + * @return True if the method returned because of the timeout, false if the + * method returned because of the condition became true. */ public static boolean waitAndDispatch(long timeout, IInterruptCondition condition) { assert timeout >= 0 && condition != null; diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/connection/IRSEConnectionManager.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/connection/IRSEConnectionManager.java new file mode 100644 index 00000000000..6c1cec8b74d --- /dev/null +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/connection/IRSEConnectionManager.java @@ -0,0 +1,102 @@ +/* ******************************************************************************* + * Copyright (c) 2006 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: + * Uwe Stieber (Wind River) - initial contribution. + * *******************************************************************************/ +package org.eclipse.rse.tests.core.connection; + +import java.util.Properties; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.rse.core.model.IHost; +import org.eclipse.rse.core.subsystems.ISubSystem; + +/** + * Interfaces declares public access and factory methods to deal + * with RSE connections and artefacts. + */ +public interface IRSEConnectionManager { + + /** + * Loads the connection properties from the specified file. The + * file must exist and must be a valid formated properties file. + *

+ * Note: The loaded properties will be underlayed by a set of default + * properties. The default properties will be loaded from the + * file <bundle_location>/src/org/eclipse/rse/tests/internal/connectionDefault.properties. + *

+ * @param path The properties file location. Must be not null. + * @param allowDefaults Specify true to allow to underlay the connection properties with default, + * false otherwise. + * + * @return The corresponding IRSEConnectionProperties object or null + * if the loading of the properties fails. + * + * @see java.util.Properties + * @see org.eclipse.rse.tests.core.connection.IRSEConnectionProperties + */ + public IRSEConnectionProperties loadConnectionProperties(IPath path, boolean allowDefaults); + + /** + * Loads the connection properties using the given set of potential + * incomplete properties and the default properties. + * + * @param properties The connection properties. Must be not null + * @param allowDefaults Specify true to allow to underlay the connection properties with default, + * false otherwise. + * + * @return The corresponding IRSEConnectionProperties object or null + * if the loading of the properties fails. + * + * @see java.util.Properties + * @see org.eclipse.rse.tests.core.connection.IRSEConnectionProperties + */ + public IRSEConnectionProperties loadConnectionProperties(Properties properties, boolean allowDefaults); + + /** + * Removes the connection given by the specified name/label from the specified + * system profile. The method will do nothing if either the system profile or + * the connection does not exist. + * + * @param profileName The system profile to remove the connection from. Must be not null. + * @param name The name of the connection to remove. Must be not null. + */ + public void removeConnection(String profileName, String name); + + /** + * Lookup the connection described by the given connection properties. If + * the described connection does not exist, the connection (and all required + * RSE artefacts) will be created. + * + * @param properties The connection properties. Must be not null. + * @return The corresponding IHost connection object. + */ + public IHost findOrCreateConnection(IRSEConnectionProperties properties); + + /** + * Get the file subsystem, matching the specified configuration id, for the specified connection. + * + * @param connection The corresponding IHost connection object. Must be not null. + * @param desiredConfigurationId The subsystem configuration id of the desired subsystem. Must be not null. + * + * @return The file subsystem object if found or null. + * + * @throws Exception If the file subsystem lookup fails. + */ + public ISubSystem getFileSubSystem(IHost connection, String desiredConfigurationId) throws Exception; + + /** + * Get the shell subsystem for the specified connection. + * + * @param connection The corresponding IHost connection object. Must be not null. + * @return The shell subsystem object if found or null. + * + * @throws Exception If the shell subsystem lookup fails. + */ + public ISubSystem getShellSubSystem(IHost connection) throws Exception; + +} diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/connection/IRSEConnectionProperties.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/connection/IRSEConnectionProperties.java new file mode 100644 index 00000000000..d079fd2ad8c --- /dev/null +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/connection/IRSEConnectionProperties.java @@ -0,0 +1,42 @@ +/* ******************************************************************************* + * Copyright (c) 2006 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: + * Uwe Stieber (Wind River) - initial contribution. + * *******************************************************************************/ +package org.eclipse.rse.tests.core.connection; + +/** + * Interface declares public access and management methods to deal + * with the RSE connection specific properties. + */ +public interface IRSEConnectionProperties { + + public final String ATTR_NAME = "name"; //$NON-NLS-1$ + public final String ATTR_PROFILE_NAME = "profile_name"; //$NON-NLS-1$ + public final String ATTR_SYSTEM_TYPE = "system_type"; //$NON-NLS-1$ + public final String ATTR_ADDRESS = "address"; //$NON-NLS-1$ + public final String ATTR_USERID = "userid"; //$NON-NLS-1$ + public final String ATTR_PASSWORD = "password"; //$NON-NLS-1$ + + /** + * Returns the associated property stored under the specified key. + * + * @param key The property key. Must be not null. + * @return The properties value or null if not set. + */ + public String getProperty(String key); + + /** + * Set the property, given by the specified key, to the specified + * property value. If the specified value is null, the + * property will be removed. + * + * @param key The property key. Must be not null. + * @param value The property value or null + */ + public void setProperty(String key, String value); +} diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/connection/RSEBaseConnectionTestCase.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/connection/RSEBaseConnectionTestCase.java index 0b0b99d6382..904c93a320b 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/connection/RSEBaseConnectionTestCase.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/connection/RSEBaseConnectionTestCase.java @@ -1,5 +1,5 @@ /* ******************************************************************************* - * Copyright (c) 2006 IBM Corporation. All rights reserved. + * Copyright (c) 2006 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 @@ -7,46 +7,31 @@ * Contributors: * Don Yantzi (IBM) - initial contribution. * David Dykstal (IBM) - initial contribution. + * Uwe Stieber (Wind River) - refactoring and cleanup. * *******************************************************************************/ package org.eclipse.rse.tests.core.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.RSETestsPlugin; import org.eclipse.rse.tests.core.RSECoreTestCase; -import org.eclipse.rse.ui.RSEUIPlugin; +import org.eclipse.rse.tests.internal.RSEConnectionManager; /** * 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 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 final IRSEConnectionManager connectionManager = new RSEConnectionManager(); + private final IRSEConnectionProperties localSystemConnectionProperties; - 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. + */ + public RSEBaseConnectionTestCase() { + this(null); + } /** * Constructor. @@ -55,178 +40,46 @@ public class RSEBaseConnectionTestCase extends RSECoreTestCase { */ public RSEBaseConnectionTestCase(String name) { super(name); - } - - protected void setUp() throws Exception { - super.setUp(); - properties = RSEConnectionTestUtil.loadProperties(RSETestsPlugin.getDefault().getBundle(), "SystemConnectionInfo.properties"); //$NON-NLS-1$ - host = getHost(); - } - - protected void tearDown() throws Exception { - host = null; - properties = null; - super.tearDown(); + + // Pre-create the local system connection properties + Properties properties = new Properties(); + properties.setProperty(IRSEConnectionProperties.ATTR_SYSTEM_TYPE, "Local"); //$NON-NLS-1$ + properties.setProperty(IRSEConnectionProperties.ATTR_ADDRESS, "localhost"); //$NON-NLS-1$ + properties.setProperty(IRSEConnectionProperties.ATTR_NAME, "Local"); //$NON-NLS-1$ + localSystemConnectionProperties = getConnectionManager().loadConnectionProperties(properties, false); } /** - * 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). + * Returns the associated RSE connection manager instance. * - * @return the new connection (host) - * @throws Exception if there is a problem + * @return The connection manager instance. Should be never null. + */ + protected IRSEConnectionManager getConnectionManager() { + return connectionManager; + } + + /** + * Lookup and return the local system type connection. This connection + * should be usually available on all systems. * - * @see RSEBaseConnectionTestCase#getHostName() - * @see RSEBaseConnectionTestCase#getHostAddress() - * @see RSEBaseConnectionTestCase#getSystemType() - * @see RSEBaseConnectionTestCase#getUserID() - * @see RSEBaseConnectionTestCase#getPassword() + * @return The local system type connection or null if the lookup fails. */ - protected IHost getHost() throws Exception { - if (host == null) { - String profileName = getProfileName(); - 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 = RSEConnectionTestUtil.createProfile(profileName); - } - assertNotNull("Failed to find and create profile!", profile); //$NON-NLS-1$ - String hostName = getHostName(); - 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); //$NON-NLS-1$ //$NON-NLS-2$ - String password = getPassword(); - 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); //$NON-NLS-1$ //$NON-NLS-2$ - host = RSEConnectionTestUtil.createHost(profileName, hostName, hostAddress, getSystemType(), userID, password); - } + protected IHost getLocalSystemConnection() { + assertNotNull("Local system connection properties are not available!", localSystemConnectionProperties); //$NON-NLS-1$ + + Exception exception = null; + String cause = null; + + IHost connection = null; + try { + connection = getConnectionManager().findOrCreateConnection(localSystemConnectionProperties); + } catch (Exception e) { + exception = e; + cause = exception.getLocalizedMessage(); } - return host; + assertNull("Failed to find and create local system connection! Possible cause: " + cause, exception); //$NON-NLS-1$ + assertNotNull("Failed to find and create local system connection! Cause unknown!", connection); //$NON-NLS-1$ + + return connection; } - - /** - * 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 {0}. Disconnect before changing.", new Object[] {activeId})); //$NON-NLS-1$ - } 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(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(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(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(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(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(DEFAULT_PASSWORD); - } - } \ No newline at end of file diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/connection/RSEConnectionTestCase.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/connection/RSEConnectionTestCase.java index a4b6265d9f3..945d37b571a 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/connection/RSEConnectionTestCase.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/connection/RSEConnectionTestCase.java @@ -1,5 +1,5 @@ /* ******************************************************************************* - * Copyright (c) 2006 IBM Corporation. All rights reserved. + * Copyright (c) 2006 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 @@ -10,6 +10,9 @@ * *******************************************************************************/ package org.eclipse.rse.tests.core.connection; +import java.util.Properties; + +import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.core.subsystems.ISubSystem; import org.eclipse.rse.tests.RSETestsPlugin; import org.eclipse.rse.ui.ISystemPreferencesConstants; @@ -25,44 +28,154 @@ public class RSEConnectionTestCase extends RSEBaseConnectionTestCase { } /** - * Test the connect and disconnect methods - * @throws Exception if there is a problem + * Test creation of connections. */ - public void testConnect() throws Exception { + public void testConnectionCreation() { + if (!RSETestsPlugin.isTestCaseEnabled("RSEConnectionTestCase.testConnectionCreation")) return; //$NON-NLS-1$ + + Properties properties = new Properties(); + properties.setProperty(IRSEConnectionProperties.ATTR_PROFILE_NAME, "TestProfile"); //$NON-NLS-1$ + properties.setProperty(IRSEConnectionProperties.ATTR_NAME, "TestHost1"); //$NON-NLS-1$ + properties.setProperty(IRSEConnectionProperties.ATTR_ADDRESS, "localhost"); //$NON-NLS-1$ + properties.setProperty(IRSEConnectionProperties.ATTR_SYSTEM_TYPE, "Unix"); //$NON-NLS-1$ + properties.setProperty(IRSEConnectionProperties.ATTR_USERID, "userid"); //$NON-NLS-1$ + properties.setProperty(IRSEConnectionProperties.ATTR_PASSWORD, "password"); //$NON-NLS-1$ + + IRSEConnectionProperties props = getConnectionManager().loadConnectionProperties(properties, false); + IHost connection = getConnectionManager().findOrCreateConnection(props); + assertNotNull("Failed to create connection " + props.getProperty(IRSEConnectionProperties.ATTR_NAME), connection); //$NON-NLS-1$ + + props.setProperty(IRSEConnectionProperties.ATTR_NAME, "TestHost2"); //$NON-NLS-1$ + connection = getConnectionManager().findOrCreateConnection(props); + assertNotNull("Failed to create connection " + props.getProperty(IRSEConnectionProperties.ATTR_NAME), connection); //$NON-NLS-1$ + + props.setProperty(IRSEConnectionProperties.ATTR_NAME, "TestHost3"); //$NON-NLS-1$ + connection = getConnectionManager().findOrCreateConnection(props); + assertNotNull("Failed to create connection " + props.getProperty(IRSEConnectionProperties.ATTR_NAME), connection); //$NON-NLS-1$ + + props.setProperty(IRSEConnectionProperties.ATTR_NAME, "TestHost4"); //$NON-NLS-1$ + connection = getConnectionManager().findOrCreateConnection(props); + assertNotNull("Failed to create connection " + props.getProperty(IRSEConnectionProperties.ATTR_NAME), connection); //$NON-NLS-1$ + + props.setProperty(IRSEConnectionProperties.ATTR_NAME, "TestHost5"); //$NON-NLS-1$ + connection = getConnectionManager().findOrCreateConnection(props); + assertNotNull("Failed to create connection " + props.getProperty(IRSEConnectionProperties.ATTR_NAME), connection); //$NON-NLS-1$ + + props.setProperty(IRSEConnectionProperties.ATTR_NAME, "TestHost6"); //$NON-NLS-1$ + connection = getConnectionManager().findOrCreateConnection(props); + assertNotNull("Failed to create connection " + props.getProperty(IRSEConnectionProperties.ATTR_NAME), connection); //$NON-NLS-1$ + } + + /** + * Test removal of connections + */ + public void testConnectionRemoval() { + if (!RSETestsPlugin.isTestCaseEnabled("RSEConnectionTestCase.testConnectionRemoval")) return; //$NON-NLS-1$ + + String profileName = "TestProfile"; //$NON-NLS-1$ + + getConnectionManager().removeConnection(profileName, "TestHost1"); //$NON-NLS-1$ + getConnectionManager().removeConnection(profileName, "TestHost2"); //$NON-NLS-1$ + getConnectionManager().removeConnection(profileName, "TestHost3"); //$NON-NLS-1$ + getConnectionManager().removeConnection(profileName, "TestHost4"); //$NON-NLS-1$ + getConnectionManager().removeConnection(profileName, "TestHost5"); //$NON-NLS-1$ + getConnectionManager().removeConnection(profileName, "TestHost6"); //$NON-NLS-1$ + } + + /** + * Test the connect and disconnect methods + */ + public void testConnect() { 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); + Exception exception = null; + String cause = null; + + IHost connection = getLocalSystemConnection(); + ISubSystem subsystem = null; + try { + subsystem = getConnectionManager().getFileSubSystem(connection, "local.files"); //$NON-NLS-1$ + } catch(Exception e) { + exception = e; + cause = e.getLocalizedMessage(); + } + assertNull("Failed to get local.files subsystem! Possible cause: " + cause, exception); //$NON-NLS-1$ + assertNotNull("No local.files subystem", subsystem); //$NON-NLS-1$ + RSEUIPlugin.getDefault().getPreferenceStore().setValue(ISystemPreferencesConstants.ALERT_SSL, false); RSEUIPlugin.getDefault().getPreferenceStore().setValue(ISystemPreferencesConstants.ALERT_NONSSL, false); - subsystem.connect(); - assertTrue("Subsystem not connected", subsystem.isConnected()); //$NON-NLS-1$ - subsystem.disconnect(); - assertFalse(subsystem.isConnected()); + + exception = null; + cause = null; + + try { + subsystem.connect(); + } catch(Exception e) { + exception = e; + cause = e.getLocalizedMessage(); + } + assertNull("Failed to connect local.files subsystem! Possible cause: " + cause, exception); //$NON-NLS-1$ + assertTrue("local.files subsystem is not connected!", subsystem.isConnected()); //$NON-NLS-1$ + + exception = null; + cause = null; + + try { + subsystem.disconnect(); + } catch(Exception e) { + exception = e; + cause = e.getLocalizedMessage(); + } + assertNull("Failed to discconnect local.files subsystem! Possible cause: " + cause, exception); //$NON-NLS-1$ + // The local.files subsystem should be not disconnectable! + assertTrue("local.files subsystem is not connected but is expected to!", subsystem.isConnected()); //$NON-NLS-1$ } /** * Test resolving a filter string. - * @throws Exception if there is a problem */ - public void testResolveFilterString() throws Exception { + public void testResolveFilterString() { 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$ + Exception exception = null; + String cause = null; + + IHost connection = getLocalSystemConnection(); + ISubSystem subsystem = null; + try { + subsystem = getConnectionManager().getFileSubSystem(connection, "local.files"); //$NON-NLS-1$ + } catch(Exception e) { + exception = e; + cause = e.getLocalizedMessage(); + } + assertNull("Failed to get local.files subsystem! Possible cause: " + cause, exception); //$NON-NLS-1$ + assertNotNull("No local.files subystem", subsystem); //$NON-NLS-1$ + + exception = null; + cause = null; + try { subsystem.connect(); - 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(); - } + } catch(Exception e) { + exception = e; + cause = e.getLocalizedMessage(); } - } - + assertNull("Failed to connect local.files subsystem! Possible cause: " + cause, exception); //$NON-NLS-1$ + assertTrue("local.files subsystem is not connected!", subsystem.isConnected()); //$NON-NLS-1$ + + exception = null; + cause = null; + + Object[] objects = null; + try { + objects = subsystem.resolveFilterString(null, "/bin/*"); //$NON-NLS-1$ + } catch(Exception e) { + exception = e; + cause = e.getLocalizedMessage(); + } finally { + try { subsystem.disconnect(); } catch (Exception e) { /* ignored */ } + } + assertNull("Failed to resolve filter string for local.files subsystem! Possible cause: " + cause, exception); //$NON-NLS-1$ + assertNotNull("Unexpected return value null for resolveFilterString!", objects); //$NON-NLS-1$ + } } diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/connection/RSEConnectionTestSuite.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/connection/RSEConnectionTestSuite.java index 5cdda3ebd06..a34393f9ea6 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/connection/RSEConnectionTestSuite.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/connection/RSEConnectionTestSuite.java @@ -1,5 +1,5 @@ /* ******************************************************************************* - * Copyright (c) 2006 IBM Corporation. All rights reserved. + * Copyright (c) 2006 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 diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/connection/RSEConnectionTestUtil.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/connection/RSEConnectionTestUtil.java index 12b6cd000b4..d1becc174bf 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/connection/RSEConnectionTestUtil.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/connection/RSEConnectionTestUtil.java @@ -1,5 +1,5 @@ /* ******************************************************************************* - * Copyright (c) 2006 IBM Corporation. All rights reserved. + * Copyright (c) 2006 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 @@ -10,26 +10,9 @@ * *******************************************************************************/ package org.eclipse.rse.tests.core.connection; -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; /** * RSEConnectionTestUtil is a collection of static utility methods for creating @@ -47,124 +30,7 @@ import org.osgi.framework.Bundle; */ public class RSEConnectionTestUtil { - /** - * 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 })); //$NON-NLS-1$ - } - 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 @@ -183,33 +49,4 @@ public class RSEConnectionTestUtil { 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/internal/RSEConnectionManager.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/RSEConnectionManager.java new file mode 100644 index 00000000000..c6dc41be593 --- /dev/null +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/RSEConnectionManager.java @@ -0,0 +1,283 @@ +/* ******************************************************************************* + * Copyright (c) 2006 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: + * Don Yantzi (IBM) - initial contribution. + * David Dykstal (IBM) - initial contribution. + * Uwe Stieber (Wind River) - refactoring and cleanup. + * *******************************************************************************/ +package org.eclipse.rse.tests.internal; + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.text.MessageFormat; +import java.util.Enumeration; +import java.util.Properties; + +import junit.framework.Assert; + +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.rse.core.ISystemUserIdConstants; +import org.eclipse.rse.core.PasswordPersistenceManager; +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.model.SystemSignonInformation; +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.model.ISystemResourceChangeEvents; +import org.eclipse.rse.model.SystemRegistry; +import org.eclipse.rse.model.SystemResourceChangeEvent; +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.RSETestsPlugin; +import org.eclipse.rse.tests.core.connection.IRSEConnectionManager; +import org.eclipse.rse.tests.core.connection.IRSEConnectionProperties; +import org.eclipse.rse.ui.RSEUIPlugin; +import org.osgi.framework.Bundle; + +/** + * RSE connection factory implementation. + */ +public class RSEConnectionManager implements IRSEConnectionManager { + private IPath connectionDefaultsLocation = null; + + /** + * Constructor. + */ + public RSEConnectionManager() { + // locate the connectionDefault.properties file. + Bundle bundle = RSETestsPlugin.getDefault().getBundle(); + if (bundle != null) { + IPath relative = new Path ("src/org/eclipse/rse/tests/internal/connectionDefault.properties"); //$NON-NLS-1$ + URL url = FileLocator.find(bundle, relative, null); + if (url != null) { + try { + // Resolve the URL to an absolute path + connectionDefaultsLocation = new Path(FileLocator.resolve(url).getFile()); + } catch (IOException e) { /* ignored on purpose */ } + } + } + } + + /* (non-Javadoc) + * @see org.eclipse.rse.tests.core.connection.IRSEConnectionManager#loadConnectionProperties(org.eclipse.core.runtime.IPath, boolean) + */ + public IRSEConnectionProperties loadConnectionProperties(IPath path, boolean allowDefaults) { + assert path != null; + + Properties defaults = null; + if (allowDefaults && connectionDefaultsLocation != null + && connectionDefaultsLocation.toFile().isFile() + && connectionDefaultsLocation.toFile().canRead()) { + InputStream stream = null; + try { + defaults = new Properties(); + stream = new FileInputStream(connectionDefaultsLocation.toFile()); + defaults.load(stream); + } catch (IOException e) { + // There are no defaults if anything goes wrong reading them + defaults = null; + } finally { + try { if (stream != null) stream.close(); } catch (IOException e) { /* ignored */ } + } + } + + + Properties properties = null; + if (path.toFile().isFile() && path.toFile().canRead()) { + InputStream stream = null; + try { + stream = new FileInputStream(path.toFile()); + properties = defaults != null ? new Properties(defaults) : new Properties(); + properties.load(stream); + } catch (IOException e) { + // if anything goes wrong reading the properties + // we do not return any. + properties = null; + } finally { + try { if (stream != null) stream.close(); } catch (IOException e) { /* ignored */ } + } + } + + return properties != null ? new RSEConnectionProperties(properties) : (IRSEConnectionProperties)null; + } + + /* (non-Javadoc) + * @see org.eclipse.rse.tests.core.connection.IRSEConnectionManager#loadConnectionProperties(java.util.Properties, boolean) + */ + public IRSEConnectionProperties loadConnectionProperties(Properties properties, boolean allowDefaults) { + assert properties != null; + + Properties defaults = null; + if (allowDefaults && connectionDefaultsLocation != null + && connectionDefaultsLocation.toFile().isFile() + && connectionDefaultsLocation.toFile().canRead()) { + InputStream stream = null; + try { + defaults = new Properties(); + stream = new FileInputStream(connectionDefaultsLocation.toFile()); + defaults.load(stream); + } catch (IOException e) { + // There are no defaults if anything goes wrong reading them + defaults = null; + } finally { + try { if (stream != null) stream.close(); } catch (IOException e) { /* ignored */ } + } + } + + // Unfortunately, we cannot use the given properties directly (as + // we cannot associate the defaults). We must copy everything from + // the given properties object. + Properties resultProperties = null; + if (defaults != null) { + resultProperties = new Properties(defaults); + Enumeration names = properties.propertyNames(); + while (names.hasMoreElements()) { + String name = (String)names.nextElement(); + if (name != null && properties.getProperty(name) != null) { + resultProperties.setProperty(name, properties.getProperty(name)); + } + } + } else { + resultProperties = properties; + } + + return resultProperties != null ? new RSEConnectionProperties(resultProperties) : (IRSEConnectionProperties)null; + } + + /** + * 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 name the name of the host to delete + */ + public void removeConnection(String profileName, String name) { + assert profileName != null && name != null; + + SystemRegistry systemRegistry = RSEUIPlugin.getTheSystemRegistry(); + Assert.assertNotNull("FAILED(findOrCreateConnection): RSE system registry unavailable!", systemRegistry); //$NON-NLS-1$ + + ISystemProfile profile = systemRegistry.getSystemProfile(profileName); + if (profile != null) { + IHost connection = systemRegistry.getHost(profile, name); + if (connection != null) { + systemRegistry.deleteHost(connection); + systemRegistry.fireEvent(new SystemResourceChangeEvent(connection, ISystemResourceChangeEvents.EVENT_DELETE, systemRegistry)); + } + } + } + + /* (non-Javadoc) + * @see org.eclipse.rse.tests.core.connection.IRSEConnectionManager#findOrCreateConnection(org.eclipse.rse.tests.core.connection.IRSEConnectionProperties) + */ + public IHost findOrCreateConnection(IRSEConnectionProperties properties) { + assert properties != null; + + IHost connection = null; + + SystemRegistry systemRegistry = RSEUIPlugin.getTheSystemRegistry(); + Assert.assertNotNull("FAILED(findOrCreateConnection): RSE system registry unavailable!", systemRegistry); //$NON-NLS-1$ + + Exception exception = null; + String cause = null; + + // First lookup and create the profile + String profileName = properties.getProperty(IRSEConnectionProperties.ATTR_PROFILE_NAME); + Assert.assertNotSame("FAILED(findOrCreateConnection): Invalid system profile name!", "unknown", profileName); //$NON-NLS-1$ //$NON-NLS-2$ + ISystemProfile profile = profileName == null ? systemRegistry.getSystemProfileManager().getDefaultPrivateSystemProfile() : systemRegistry.getSystemProfile(profileName); + if (profile == null) { + try { + profile = systemRegistry.createSystemProfile(profileName, true); + } catch(Exception e) { + exception = e; + cause = e.getLocalizedMessage(); + } + Assert.assertNull("FAILED(findOrCreateConnection): Failed to create system profile '" + profileName + "'! Possible cause: " + cause, exception); //$NON-NLS-1$ //$NON-NLS-2$ + } + Assert.assertNotNull("FAILED(findOrCreateConnection): Failed to find and/or create system profile '" + profileName + "'!", profile); //$NON-NLS-1$ //$NON-NLS-2$ + + String name = properties.getProperty(IRSEConnectionProperties.ATTR_NAME); + Assert.assertNotSame("FAILED(findOrCreateConnection): Invalid host name!", "unknown", name); //$NON-NLS-1$ //$NON-NLS-2$ + connection = systemRegistry.getHost(profile, name); + if (connection == null) { + String userId = properties.getProperty(IRSEConnectionProperties.ATTR_USERID); + Assert.assertNotSame("FAILED(findOrCreateConnection): Invalid user id name!", "unknown", userId); //$NON-NLS-1$ //$NON-NLS-2$ + String password = properties.getProperty(IRSEConnectionProperties.ATTR_PASSWORD); + Assert.assertNotSame("FAILED(findOrCreateConnection): Invalid user password name!", "unknown", password); //$NON-NLS-1$ //$NON-NLS-2$ + String address = properties.getProperty(IRSEConnectionProperties.ATTR_ADDRESS); + Assert.assertNotSame("FAILED(findOrCreateConnection): Invalid remote system ip address or dns name!", "unknown", address); //$NON-NLS-1$ //$NON-NLS-2$ + String systemType = properties.getProperty(IRSEConnectionProperties.ATTR_SYSTEM_TYPE); + Assert.assertNotSame("FAILED(findOrCreateConnection): Invalid system type!", "unknown", address); //$NON-NLS-1$ //$NON-NLS-2$ + + exception = null; + cause = null; + + try { + connection = systemRegistry.createHost(profileName, systemType, name, address, null, userId, ISystemUserIdConstants.USERID_LOCATION_CONNECTION, null); + } catch(Exception e) { + exception = e; + cause = e.getLocalizedMessage(); + } + Assert.assertNull("FAILED(findOrCreateConnection): Failed to create connection IHost object! Possible cause: " + cause, exception); //$NON-NLS-1$ + + if (userId != null && password != null) { + SystemSignonInformation info = new SystemSignonInformation(address, userId, password, systemType); + PasswordPersistenceManager.getInstance().add(info, true); + } + } + Assert.assertNotNull("FAILED(findOrCreateConnection): Failed to find and/or create connection IHost object!", connection); //$NON-NLS-1$ + + return connection; + } + + /* (non-Javadoc) + * @see org.eclipse.rse.tests.core.connection.IRSEConnectionManager#getFileSubSystem(org.eclipse.rse.core.model.IHost, java.lang.String) + */ + public ISubSystem getFileSubSystem(IHost connection, String desiredConfigurationId) throws Exception { + assert connection != null && desiredConfigurationId != null; + FileServiceSubSystem subsystem = (FileServiceSubSystem)RemoteFileUtility.getFileSubSystem(connection); + 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 {0}. Disconnect before changing.", new Object[] { activeId })); //$NON-NLS-1$ + } + + ISystemRegistry registry = RSECorePlugin.getDefault().getSystemRegistry(); + ISubSystemConfiguration desiredConfiguration = registry.getSubSystemConfiguration(desiredConfigurationId); + if (desiredConfiguration instanceof IServiceSubSystemConfiguration) { + IServiceSubSystemConfiguration t = (IServiceSubSystemConfiguration)desiredConfiguration; + subsystem.switchServiceFactory(t); + } + } + return subsystem; + } + + /* (non-Javadoc) + * @see org.eclipse.rse.tests.core.connection.IRSEConnectionManager#getShellSubSystem(org.eclipse.rse.core.model.IHost) + */ + public ISubSystem getShellSubSystem(IHost connection) throws Exception { + assert connection != null; + ISystemRegistry registry = RSEUIPlugin.getTheSystemRegistry(); + ISubSystem[] subSystems = registry.getSubSystems(connection); + for (int i = 0; i < subSystems.length; i++) { + ISubSystem subSystem = subSystems[i]; + if (subSystem instanceof IShellServiceSubSystem) { + IShellServiceSubSystem shellSubSystem = (IShellServiceSubSystem)subSystem; + return shellSubSystem; + } + } + return null; + } +} diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/RSEConnectionProperties.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/RSEConnectionProperties.java new file mode 100644 index 00000000000..2837d7fb714 --- /dev/null +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/RSEConnectionProperties.java @@ -0,0 +1,54 @@ +/* ******************************************************************************* + * Copyright (c) 2006 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: + * Uwe Stieber (Wind River) - initial contribution. + * *******************************************************************************/ +package org.eclipse.rse.tests.internal; + +import java.util.Properties; + +import org.eclipse.rse.tests.core.connection.IRSEConnectionProperties; + +/** + * RSE connection properties implementation. + */ +public class RSEConnectionProperties implements IRSEConnectionProperties { + private final Properties properties; + + /** + * Constructor. + * + * @param properties The string based properties container. Must be not null. + */ + public RSEConnectionProperties(Properties properties) { + super(); + + assert properties != null; + this.properties = properties; + } + + /* (non-Javadoc) + * @see org.eclipse.rse.tests.core.connection.IRSEConnectionProperties#getProperty(java.lang.String) + */ + public String getProperty(String key) { + assert key != null; + String value = properties.getProperty(key, null); + return value != null ? value.trim() : null; + } + + /* (non-Javadoc) + * @see org.eclipse.rse.tests.core.connection.IRSEConnectionProperties#setProperty(java.lang.String, java.lang.String) + */ + public void setProperty(String key, String value) { + assert key != null; + if (value != null) { + properties.setProperty(key, value); + } else { + properties.remove(key); + } + } +} diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/RSEDefaultTestLogCollectorDelegate.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/RSEDefaultTestLogCollectorDelegate.java index 2adc009de59..00473f25cf4 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/RSEDefaultTestLogCollectorDelegate.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/RSEDefaultTestLogCollectorDelegate.java @@ -1,5 +1,5 @@ /* ******************************************************************************* - * Copyright (c) 2006 IBM Corporation. All rights reserved. + * Copyright (c) 2006 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 diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/RSEInternalFrameworkTestCase.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/RSEInternalFrameworkTestCase.java index 80c0b891c5e..1a169396967 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/RSEInternalFrameworkTestCase.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/RSEInternalFrameworkTestCase.java @@ -1,5 +1,5 @@ /* ******************************************************************************* - * Copyright (c) 2006 IBM Corporation. All rights reserved. + * Copyright (c) 2006 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 @@ -11,6 +11,7 @@ package org.eclipse.rse.tests.internal; import java.util.ArrayList; import java.util.List; +import java.util.Properties; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.IPath; @@ -21,15 +22,16 @@ import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.rse.tests.RSETestsPlugin; import org.eclipse.rse.tests.core.IRSECoreTestCaseProperties; -import org.eclipse.rse.tests.core.RSECoreTestCase; import org.eclipse.rse.tests.core.RSEWaitAndDispatchUtil; import org.eclipse.rse.tests.core.RSEWaitAndDispatchUtil.IInterruptCondition; +import org.eclipse.rse.tests.core.connection.IRSEConnectionProperties; +import org.eclipse.rse.tests.core.connection.RSEBaseConnectionTestCase; import org.eclipse.ui.PlatformUI; /** * Tests the very core RSE test framework functionality. */ -public class RSEInternalFrameworkTestCase extends RSECoreTestCase { +public class RSEInternalFrameworkTestCase extends RSEBaseConnectionTestCase { /** * Test the properties managment and support methods of the @@ -74,7 +76,7 @@ public class RSEInternalFrameworkTestCase extends RSECoreTestCase { } private static class TestJob extends Job { - private final List params; + final List params; public TestJob(List params) { super("Test Job"); //$NON-NLS-1$ assert params != null; @@ -157,4 +159,53 @@ public class RSEInternalFrameworkTestCase extends RSECoreTestCase { assertTrue("Failed to delete test data location " + path.toOSString() + "!", path.toFile().delete()); //$NON-NLS-1$ //$NON-NLS-2$ assertTrue("Failed to delete test data location " + root.append(relative).toOSString() + "!", root.append(relative).toFile().delete()); //$NON-NLS-1$ //$NON-NLS-2$ } + + /** + * Test RSE connection manager and related functionality. + */ + public void testConnectionManager() { + if (!RSETestsPlugin.isTestCaseEnabled("RSEInternalFrameworkTestCase.testConnectionManager")) return; //$NON-NLS-1$ + + // get the pure test data location root path. + IPath location = getTestDataLocation("testConnectionManager", false); //$NON-NLS-1$ + assertNotNull("Cannot locate test data! Missing test data location?", location); //$NON-NLS-1$ + location = location.append("connection.properties"); //$NON-NLS-1$ + assertNotNull("Failed to construct location to 'connection.properties' test data file!", location); //$NON-NLS-1$ + assertTrue("Required test data file seems to be not a file!", location.toFile().isFile()); //$NON-NLS-1$ + assertTrue("Required test data file is not readable!", location.toFile().canRead()); //$NON-NLS-1$ + + // load the test connection properties from the data file. + IRSEConnectionProperties properties = getConnectionManager().loadConnectionProperties(location, true); + assertNotNull("Failed to load test connection properties from location " + location.toOSString(), properties); //$NON-NLS-1$ + assertEquals("Property name does not match!", "test_windows", properties.getProperty(IRSEConnectionProperties.ATTR_NAME)); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("Property profile name does not match!", "junit_test_profile", properties.getProperty(IRSEConnectionProperties.ATTR_PROFILE_NAME)); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("Property system type does not match!", "Windows", properties.getProperty(IRSEConnectionProperties.ATTR_SYSTEM_TYPE)); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("Property remote system address does not match!", "128.0.0.1", properties.getProperty(IRSEConnectionProperties.ATTR_ADDRESS)); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("Property user id does not match!", "test_user", properties.getProperty(IRSEConnectionProperties.ATTR_USERID)); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("Property password does not match!", "test_passwd", properties.getProperty(IRSEConnectionProperties.ATTR_PASSWORD)); //$NON-NLS-1$ //$NON-NLS-2$ + + // test the loading with partial connection information (with defauls) + Properties props = new Properties(); + props.setProperty(IRSEConnectionProperties.ATTR_SYSTEM_TYPE, "SSH Only"); //$NON-NLS-1$ + props.setProperty(IRSEConnectionProperties.ATTR_USERID, "local_user"); //$NON-NLS-1$ + props.setProperty(IRSEConnectionProperties.ATTR_PASSWORD, "local_passwd"); //$NON-NLS-1$ + properties = getConnectionManager().loadConnectionProperties(props, true); + assertNotNull("Failed to load test connection properties from location " + location.toOSString(), properties); //$NON-NLS-1$ + assertEquals("Property name does not match!", "Local", properties.getProperty(IRSEConnectionProperties.ATTR_NAME)); //$NON-NLS-1$ //$NON-NLS-2$ + assertNull("Property profile name does not match!", properties.getProperty(IRSEConnectionProperties.ATTR_PROFILE_NAME)); //$NON-NLS-1$ + assertEquals("Property system type does not match!", "SSH Only", properties.getProperty(IRSEConnectionProperties.ATTR_SYSTEM_TYPE)); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("Property remote system address does not match!", "localhost", properties.getProperty(IRSEConnectionProperties.ATTR_ADDRESS)); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("Property user id does not match!", "local_user", properties.getProperty(IRSEConnectionProperties.ATTR_USERID)); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("Property password does not match!", "local_passwd", properties.getProperty(IRSEConnectionProperties.ATTR_PASSWORD)); //$NON-NLS-1$ //$NON-NLS-2$ + + // test the loading with partial connection information (without defauls) + properties = getConnectionManager().loadConnectionProperties(props, false); + assertNotNull("Failed to load test connection properties from location " + location.toOSString(), properties); //$NON-NLS-1$ + assertNull("Property name does not match!", properties.getProperty(IRSEConnectionProperties.ATTR_NAME)); //$NON-NLS-1$ + assertNull("Property profile name does not match!", properties.getProperty(IRSEConnectionProperties.ATTR_PROFILE_NAME)); //$NON-NLS-1$ + assertEquals("Property system type does not match!", "SSH Only", properties.getProperty(IRSEConnectionProperties.ATTR_SYSTEM_TYPE)); //$NON-NLS-1$ //$NON-NLS-2$ + assertNull("Property remote system address does not match!", properties.getProperty(IRSEConnectionProperties.ATTR_ADDRESS)); //$NON-NLS-1$ + assertEquals("Property user id does not match!", "local_user", properties.getProperty(IRSEConnectionProperties.ATTR_USERID)); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("Property password does not match!", "local_passwd", properties.getProperty(IRSEConnectionProperties.ATTR_PASSWORD)); //$NON-NLS-1$ //$NON-NLS-2$ + } } diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/RSEInternalFrameworkTestSuite.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/RSEInternalFrameworkTestSuite.java index b6d272a0986..2543d3a347f 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/RSEInternalFrameworkTestSuite.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/RSEInternalFrameworkTestSuite.java @@ -1,5 +1,5 @@ /* ******************************************************************************* - * Copyright (c) 2006 IBM Corporation. All rights reserved. + * Copyright (c) 2006 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 diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/RSETestsPluginTestCase.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/RSETestsPluginTestCase.java index 8491001ae8e..f73622dd93c 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/RSETestsPluginTestCase.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/RSETestsPluginTestCase.java @@ -1,5 +1,5 @@ /* ******************************************************************************* - * Copyright (c) 2006 IBM Corporation. All rights reserved. + * Copyright (c) 2006 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 diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/connectionDefault.properties b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/connectionDefault.properties new file mode 100644 index 00000000000..b7835953c22 --- /dev/null +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/connectionDefault.properties @@ -0,0 +1,33 @@ +# ******************************************************************************* +# Copyright (c) 2006 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 +# Uwe Stieber (Wind River) - refactoring and cleanup. +# *******************************************************************************/ + +# The default RSE host node label/name +name = Local + +# The default RSE profile name to store the connection to. If not set, +# the default system profile is used. +# Default: not set. Uncomment to set! +#profile_name = myprofilename + +# The default test connection system type if not explicitly +# specified different (possible values: Unix, Linux, Local, Windows, SSH Only, FTP Only) +system_type = Local + +# The default remote system ip address or dns name. +address = localhost + +# The default user id to use for connecting to the remote system +# Default: not set. Uncomment to set! +#userid = myuserid + +# The default users password to use for connecting to the remote system +# Default: not set. Uncomment to set! +#password = mypassword diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/persistence/RSEPersistenceTest.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/persistence/RSEPersistenceTest.java deleted file mode 100644 index f3b79c2cf58..00000000000 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/persistence/RSEPersistenceTest.java +++ /dev/null @@ -1,49 +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.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$ - } - -} diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/persistence/RSEPersistenceTestSuite.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/persistence/RSEPersistenceTestSuite.java deleted file mode 100644 index 6882eac309d..00000000000 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/persistence/RSEPersistenceTestSuite.java +++ /dev/null @@ -1,57 +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.persistence; - -import junit.framework.Test; -import junit.framework.TestSuite; - -import org.eclipse.rse.tests.framework.DelegatingTestSuiteHolder; - -/** - * Main class bundling all RSE connection test cases. - */ -public class RSEPersistenceTestSuite extends DelegatingTestSuiteHolder { - - /** - * Standard Java application main method. Allows to launch the test - * suite from outside as part of nightly runs, headless runs or other. - *

Note: Use only junit.textui.TestRunner here as - * it is explicitly supposed to output the test output to the shell the - * test suite has been launched from. - *

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

- * Note: This method must be always called suite ! Otherwise - * the JUnit plug-in test launcher will fail to detect this class! - *

- * @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; - } - - /* (non-Javadoc) - * @see org.eclipse.rse.tests.framework.AbstractTestSuiteHolder#getTestSuite() - */ - public TestSuite getTestSuite() { - return (TestSuite)RSEPersistenceTestSuite.suite(); - } -} diff --git a/rse/tests/org.eclipse.rse.tests/teamConfig/RSE Combined Test Suite.launch b/rse/tests/org.eclipse.rse.tests/teamConfig/RSE Combined Test Suite.launch index 9c73fdd44b8..3fb03cb09b7 100644 --- a/rse/tests/org.eclipse.rse.tests/teamConfig/RSE Combined Test Suite.launch +++ b/rse/tests/org.eclipse.rse.tests/teamConfig/RSE Combined Test Suite.launch @@ -16,14 +16,14 @@ - + - + diff --git a/rse/tests/org.eclipse.rse.tests/test.data/testConnectionManager/connection.properties b/rse/tests/org.eclipse.rse.tests/test.data/testConnectionManager/connection.properties new file mode 100644 index 00000000000..b6e6ad6cfd4 --- /dev/null +++ b/rse/tests/org.eclipse.rse.tests/test.data/testConnectionManager/connection.properties @@ -0,0 +1,18 @@ +# ******************************************************************************* +# Copyright (c) 2006 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: +# Uwe Stieber (Wind River) - initial contribution. +# *******************************************************************************/ + +# Do not change the properties within this file without changing +# the consuming unittest too! +name = test_windows +profile_name = junit_test_profile +system_type = Windows +address = 128.0.0.1 +userid = test_user +password = test_passwd