From 464ddfc9503caf1b8fb4cf9505a2f08b00ed3de7 Mon Sep 17 00:00:00 2001 From: Martin Oberhuber < martin.oberhuber@windriver.com> Date: Mon, 14 Jul 2008 21:48:51 +0000 Subject: [PATCH] [240729] More flexible disabling of testcases --- .../rse/tests/RSETestsResources.properties | 20 +- .../eclipse/rse/tests/core/HostMoveTest.java | 44 +- .../rse/tests/core/RSECoreTestCase.java | 275 ++++--- .../SubSystemConfigurationProxyTestCase.java | 30 +- .../registries/SubSystemInterfacesTest.java | 20 +- .../initialization/InitializationTest.java | 12 +- .../RSEInternalFrameworkTestCase.java | 67 +- .../internal/RSETestsPluginTestCase.java | 23 +- .../tests/persistence/ExportImportTest.java | 25 +- .../rse/tests/persistence/MigrationTest.java | 11 +- .../tests/persistence/PersistenceTest.java | 66 +- .../tests/preferences/PreferencesTest.java | 26 +- .../rse/tests/profiles/ProfileTest.java | 26 +- .../subsystems/files/CreateFileTestCase.java | 53 +- .../files/FTPFileSubsystemTestCase.java | 52 +- .../files/FileOutputStreamTestCase.java | 90 ++- .../files/FileServiceArchiveBaseTest.java | 356 ++++----- .../files/FileServiceArchiveTest.java | 721 +++++++++--------- .../files/FileServiceArchiveTestDStore.java | 449 +++++------ .../FileServiceArchiveTestDStoreWindows.java | 31 +- .../subsystems/files/FileServiceBaseTest.java | 17 +- .../subsystems/files/FileServiceTest.java | 14 +- .../subsystems/files/RSEFileStoreTest.java | 22 + .../rse/tests/ui/mnemonics/MnemonicsTest.java | 18 +- 24 files changed, 1383 insertions(+), 1085 deletions(-) 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 d42cdcc6721..e5d3667bd5d 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 @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2001, 2007 IBM Corporation and others. +# Copyright (c) 2001, 2008 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 @@ -8,6 +8,7 @@ # Contributors: # IBM Corporation - initial API and implementation # Uwe Stieber (Wind River) - Rework test data location & connection management +# Martin Oberhuber (Wind River) - [240729] More flexible disabling of testcases ############################################################################### # @@ -36,6 +37,23 @@ TestSubsystemTestCase.testAddAndDeleteDeepNodes=true TestSubsystemTestCase.testAddAndDeleteFlatNodes=true TestSubsystemTestCase.testBugzilla170728=true +# +# The following section controls enablement of test cases by target or client platform. +# Uncomment a line to disable running unit tests on the specified target connection. +# Target connections refer to connection properties files, e.g. ftp --> ftpConnection.properties +# For active target connections, the Properties file must contain valid connection properties. +# +*.ftp=true +*.ftpWindows=true +*.linux=true +*.local=true +*.ssh=true +*.windows=true + +Windows_XP.x86.*=true +Linux.x86.*=true +Linux.ppc.*=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/HostMoveTest.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/HostMoveTest.java index 88970fec23a..54a73570cbb 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/HostMoveTest.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/HostMoveTest.java @@ -1,7 +1,7 @@ /******************************************************************************** * Copyright (c) 2007, 2008 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 + * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: @@ -28,11 +28,11 @@ import org.eclipse.rse.tests.core.connection.RSEBaseConnectionTestCase; * Each testcase method should leave the host pool as it was prior to running the method. */ public class HostMoveTest extends RSEBaseConnectionTestCase { - + static final int NUMBER_OF_HOSTS = 6; // number of hosts private IHost hostArray[] = null; private ISystemRegistry registry = null; - + /* (non-Javadoc) * @see org.eclipse.rse.tests.core.RSECoreTestCase#setUp() */ @@ -41,7 +41,7 @@ public class HostMoveTest extends RSEBaseConnectionTestCase { registry = RSECorePlugin.getTheSystemRegistry(); createHosts(); } - + /* (non-Javadoc) * @see org.eclipse.rse.tests.core.RSECoreTestCase#tearDown() */ @@ -49,9 +49,11 @@ public class HostMoveTest extends RSEBaseConnectionTestCase { deleteHosts(); super.tearDown(); } - + public void testMoveOneUp() throws Exception { //-test-author-:DavidDykstal + if (isTestDisabled()) + return; checkPrecondition(); IHost host = hostArray[NUMBER_OF_HOSTS - 1]; IHost[] hosts = new IHost[] {host}; @@ -62,9 +64,11 @@ public class HostMoveTest extends RSEBaseConnectionTestCase { registry.moveHosts("TestProfile", hosts, 1); assertEquals(NUMBER_OF_HOSTS - 1, registry.getHostPosition(host)); } - + public void testMoveManyUp() throws Exception { //-test-author-:DavidDykstal + if (isTestDisabled()) + return; checkPrecondition(); IHost[] hosts = new IHost[] {hostArray[NUMBER_OF_HOSTS - 1], hostArray[NUMBER_OF_HOSTS - 2]}; registry.moveHosts("TestProfile", hosts, -2); @@ -80,6 +84,8 @@ public class HostMoveTest extends RSEBaseConnectionTestCase { public void testMoveFirstUp() throws Exception { //-test-author-:DavidDykstal + if (isTestDisabled()) + return; checkPrecondition(); IHost host = hostArray[0]; assertEquals(0, registry.getHostPosition(host)); @@ -90,6 +96,8 @@ public class HostMoveTest extends RSEBaseConnectionTestCase { public void testMoveOneDown() throws Exception { //-test-author-:DavidDykstal + if (isTestDisabled()) + return; checkPrecondition(); IHost host = hostArray[1]; // second in the list assertEquals(1, registry.getHostPosition(host)); @@ -99,9 +107,11 @@ public class HostMoveTest extends RSEBaseConnectionTestCase { registry.moveHosts("TestProfile", hosts, -1); assertEquals(1, registry.getHostPosition(host)); } - + public void testMoveManyDown() throws Exception { //-test-author-:DavidDykstal + if (isTestDisabled()) + return; checkPrecondition(); IHost[] hosts = new IHost[] {hostArray[0], hostArray[2], hostArray[4]}; assertEquals(0, registry.getHostPosition(hostArray[0])); @@ -119,8 +129,10 @@ public class HostMoveTest extends RSEBaseConnectionTestCase { public void testMoveLastDown() throws Exception { //-test-author-:DavidDykstal + if (isTestDisabled()) + return; checkPrecondition(); - IHost host = hostArray[NUMBER_OF_HOSTS - 1]; + IHost host = hostArray[NUMBER_OF_HOSTS - 1]; assertEquals(NUMBER_OF_HOSTS - 1, registry.getHostPosition(host)); IHost[] hosts = new IHost[] {host}; registry.moveHosts("TestProfile", hosts, 1); // should not actually move @@ -129,16 +141,18 @@ public class HostMoveTest extends RSEBaseConnectionTestCase { public void testNoHost() throws Exception { //-test-author-:DavidDykstal + if (isTestDisabled()) + return; checkPrecondition(); IHost[] hosts = new IHost[] {}; registry.moveHosts("TestProfile", hosts, -1); // should not fail } - + /** * Create the test hosts. */ private void createHosts() throws Exception { - + hostArray = new IHost[NUMBER_OF_HOSTS]; /* Common host properties */ @@ -149,28 +163,28 @@ public class HostMoveTest extends RSEBaseConnectionTestCase { properties.setProperty(IRSEConnectionProperties.ATTR_USERID, "userid"); //$NON-NLS-1$ properties.setProperty(IRSEConnectionProperties.ATTR_PASSWORD, "password"); //$NON-NLS-1$ IRSEConnectionProperties props = getConnectionManager().loadConnectionProperties(properties, false); - + for (int i = 0; i < hostArray.length; i++) { String hostName = getHostName(i); - properties.setProperty(IRSEConnectionProperties.ATTR_NAME, hostName); //$NON-NLS-1$ + properties.setProperty(IRSEConnectionProperties.ATTR_NAME, hostName); hostArray[i] = getConnectionManager().findOrCreateConnection(props); assertNotNull("Failed to create connection " + props.getProperty(IRSEConnectionProperties.ATTR_NAME), hostArray[i]); //$NON-NLS-1$ } } - + private void deleteHosts() { for (int i = 1; i < hostArray.length; i++) { registry.deleteHost(hostArray[i]); } } - + private void checkPrecondition() { for (int i = 0; i < hostArray.length; i++) { assertEquals("Precondition check failed", i, registry.getHostPosition(hostArray[i])); } } - + private String getHostName(int i) { String hostName = "TestHost" + Integer.toString(i); return hostName; 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 8fc6b49841a..c4edd437050 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,15 +1,16 @@ /******************************************************************************** * Copyright (c) 2006, 2008 Wind River Systems, Inc. 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 - * + * 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 API and implementation. * Martin Oberhuber (Wind River) - fix build against 3.2.1, fix javadoc errors * Martin Oberhuber (Wind River) - [168870] refactor org.eclipse.rse.core package of the UI plugin * Martin Oberhuber (Wind River) - [219086] flush event queue to shield tests from each other + * Martin Oberhuber (Wind River) - [240729] More flexible disabling of testcases ********************************************************************************/ package org.eclipse.rse.tests.core; @@ -66,10 +67,17 @@ import org.osgi.framework.Bundle; public class RSECoreTestCase extends TestCase { // Test properties storage. private final Properties properties = new Properties(); - + // Internal. Used to remember view zoom state changes. private final String PROP_RSE_SYSTEMS_VIEW_ZOOM_STATE_CHANGED = "rseSystemsViewZoomStateChanged"; //$NON-NLS-1$ - + + // Target name, if set. + private String targetName = null; + + // Client name, if set. + private static final String defaultClientName = (System.getProperty("os.name") + '.' + System.getProperty("os.arch")).replace(' ', '_'); + private String clientName = defaultClientName; + /** * Constructor. */ @@ -79,7 +87,7 @@ public class RSECoreTestCase extends TestCase { /** * Constructor. - * + * * @param name The test name. */ public RSECoreTestCase(String name) { @@ -90,8 +98,30 @@ public class RSECoreTestCase extends TestCase { initializeProperties(); } + /** + * Set the name of the target platform against which this test runs. Must be + * done from Constructor. Used to filter tests in {@link #isTestDisabled()}. + * + * @param targetName target platform name. + */ + public void setTargetName(String targetName) { + this.targetName = targetName; + } + + /** + * Set the name of the client platform on which this test runs. Usually not + * necessary, since the default is computed automatically. If set, this must + * be done from the Constructor. Used to filter tests in + * {@link #isTestDisabled()}. + * + * @param clientName client platform name. + */ + public void setClientName(String clientName) { + this.clientName = clientName; + } + // ***** Test properties management and support methods ***** - + /** * Initialize the core test properties. Override to modify core * test properties or to add additional ones. @@ -103,20 +133,20 @@ public class RSECoreTestCase extends TestCase { setProperty(IRSECoreTestCaseProperties.PROP_PERFORMANCE_TIMING_INCLUDE_SETUP_TEARDOWN, false); setProperty(PROP_RSE_SYSTEMS_VIEW_ZOOM_STATE_CHANGED, false); } - + /** * Enables or disables the specified property. - * + * * @param key The key of the property to enable or disable. Must be not null! * @param enable Specify true to enable the property, false 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 null! * @param value The value to compare the property with. * @return true if the property is equal to the specified value, false otherwise. @@ -125,11 +155,11 @@ public class RSECoreTestCase extends TestCase { 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 null, the specified property will be removed. - * + * * @param key The key of the property to set. Must be not null! * @param value The string value to set or null. */ @@ -143,15 +173,15 @@ public class RSECoreTestCase extends TestCase { } } } - + /** * Test if the specified property is equal to the specified value. If the specified * value is null, this method returns true 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 null! * @param value The value to compare the property with or null - * @return true if the property is equal to the specified value + * @return true if the property is equal to the specified value * or the specified value is null and the property does not exist, * false otherwise. */ @@ -165,7 +195,7 @@ public class RSECoreTestCase extends TestCase { /** * Returns the configured string value of the specified property. - * + * * @param key The property key. Must be not null. * @return The property value or null if the specified property does not exist. */ @@ -173,17 +203,92 @@ public class RSECoreTestCase extends TestCase { assert key != null; return properties.getProperty(key, null); } - + + /** + * Return the fully qualified name of the unit test currently running. Used + * for pattern matching against enablement rules. Qualification is + * "OS_Name"."OS_Arch"."Testclass"."methodname"."connectiontype" where the + * connectiontype may be empty if not specified. + * + * @return the fully qualified name of the unit test currently running. + */ + protected String getTestNameForCheck() { + String testName = getName(); + String testClass = getClass().getName(); + String testPackage = getClass().getPackage().getName(); + String testClassSimpleName = testClass.substring(testPackage.length() + 1); + String checkName = testClassSimpleName + '.' + testName; + if (targetName != null) { + checkName = checkName + '.' + targetName; + } + if (clientName != null) { + checkName = clientName + '.' + checkName; + } + return checkName; + } + + /** + * Check whether this test is currently disabled. Uses Introspection and + * JUnit Test Name to check against user-specified Properties file. Note + * that by default, all tests are enabled. + * + * @return true if this test should run, false otherwise. + */ + protected boolean isTestDisabled() { + String testName = getName(); + String testClass = getClass().getName(); + String testPackage = getClass().getPackage().getName(); + String testClassSimpleName = testClass.substring(testPackage.length() + 1); + String checkName = testClassSimpleName + '.' + testName; + String checkString = checkName; + if (!RSETestsPlugin.isTestCaseEnabled(checkString)) { + System.out.println("--> disabled due to rule: " + checkString); + return true; + } + if (targetName != null) { + checkString = "*." + targetName; + if (!RSETestsPlugin.isTestCaseEnabled(checkString)) { + System.out.println("--> disabled due to rule: " + checkString); + return true; + } + checkString = checkName + '.' + targetName; + if (!RSETestsPlugin.isTestCaseEnabled(checkString)) { + System.out.println("--> disabled due to rule: " + checkString); + return true; + } + if (clientName != null) { + checkString = getTestNameForCheck(); + if (!RSETestsPlugin.isTestCaseEnabled(checkString)) { + System.out.println("--> disabled due to rule: " + checkString); + return true; + } + } + } + if (clientName != null) { + checkString = clientName + ".*"; + if (!RSETestsPlugin.isTestCaseEnabled(checkString)) { + System.out.println("--> disabled due to rule: " + checkString); + return true; + } + checkString = clientName + '.' + checkName; + if (!RSETestsPlugin.isTestCaseEnabled(checkString)) { + System.out.println("--> disabled due to rule: " + checkString); + return true; + } + } + return false; + } + // ***** Test case life cycle management and support methods ***** 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) { @@ -191,11 +296,11 @@ public class RSECoreTestCase extends TestCase { 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) */ @@ -206,29 +311,29 @@ public class RSECoreTestCase extends TestCase { result.addListener(TEST_LISTENER); invokeTestCaseRunImpl(result); result.removeListener(TEST_LISTENER); - + monitor.done(); - + setProperty(BACKGROUND_TEST_EXECUTION_FINISHED, Boolean.TRUE); // The job never fails. The test result is the real result. return Status.OK_STATUS; - } + } } - + private final static class RSEBackgroundTestExecutionJobWaiter implements IInterruptCondition { private final Job job; - + /** * Constructor. - * + * * @param job The job to wait for the execution to finish. Must be not null. */ public RSEBackgroundTestExecutionJobWaiter(Job job) { assert job != null; this.job = job; } - + /* (non-Javadoc) * @see org.eclipse.rse.tests.core.RSEWaitAndDispatchUtil.IInterruptCondition#isTrue() */ @@ -236,23 +341,23 @@ public class RSECoreTestCase extends TestCase { // Interrupt the wait method if the job signaled that it has finished. return ((Boolean)job.getProperty(BACKGROUND_TEST_EXECUTION_FINISHED)).booleanValue(); } - + /* (non-Javadoc) * @see org.eclipse.rse.tests.core.RSEWaitAndDispatchUtil.IInterruptCondition#dispose() */ 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) */ @@ -271,7 +376,7 @@ public class RSECoreTestCase extends TestCase { job.setProperty(BACKGROUND_TEST_EXECUTION_FINISHED, Boolean.FALSE); // schedule the job to run immediatelly job.schedule(); - + // wait till the job finished executing RSEWaitAndDispatchUtil.waitAndDispatch(0, new RSEBackgroundTestExecutionJobWaiter(job)); } @@ -322,7 +427,7 @@ public class RSECoreTestCase extends TestCase { /** * Print the start date and time of the specified test to stdout. - * + * * @param name The name of the starting test. Must be not null! * @return The start time of the test in milliseconds. */ @@ -334,10 +439,10 @@ public class RSECoreTestCase extends TestCase { } return startTime; } - + /** * Print the end date and time as well as the delay of the specified test to stdout. - * + * * @param name The name of the finished test. Must be not null! * @param startTime The start time of the test in milliseconds. */ @@ -349,7 +454,7 @@ public class RSECoreTestCase extends TestCase { System.out.println("=== " + name + " finished at: " + DATE_FORMAT.format(new Date(endTime)) + " (duration: " + duration + " ms)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ } } - + /** * Wait until the SystemProfileManager has finished loading all "autoload" profiles, * and the RSEUIPlugin InitRSEJob has finished filling it with the default connections. @@ -387,14 +492,14 @@ public class RSECoreTestCase extends TestCase { waitForRSEWorkspaceInit(); switchMaximizeSystemsView(); } - + /** * Flush the event queue in order to ensure that no left-over events influence later test cases. *

* Unhandled exceptions in the event loop event are caught as follows: * In case multiple events from the event loop throw exceptions these are printed * to stdout. The first exception found in the event loop is thrown to the caller. - * + * * @throws Exception in case an unhandled event loop exception was found. */ protected void flushEventQueue() throws Exception { @@ -448,8 +553,8 @@ public class RSECoreTestCase extends TestCase { flushEventQueue(); super.tearDown(); } - - // ***** View and perspective management and support methods ***** + + // ***** View and perspective management and support methods ***** /** * Bring the RSE SystemsView to front, and toggle its "maximized" state based on what @@ -461,14 +566,14 @@ public class RSECoreTestCase extends TestCase { protected void switchMaximizeSystemsView() { final String perspectiveId = getProperty(IRSECoreTestCaseProperties.PROP_SWITCH_TO_PERSPECTIVE); assertNotNull("Invalid null-value for test case perspective id!", perspectiveId); //$NON-NLS-1$ - + // all view management must happen in the UI thread! PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { public void run() { // in case the test case is launched within a new workspace, the eclipse intro // view is hiding everything else. Find the intro page and hide it. hideView("org.eclipse.ui.internal.introview", perspectiveId); //$NON-NLS-1$ - + // toggle the Remote Systems View zoom state. setProperty(PROP_RSE_SYSTEMS_VIEW_ZOOM_STATE_CHANGED, false); IViewPart part = showView(IRSEViews.RSE_REMOTE_SYSTEMS_VIEW_ID, perspectiveId); @@ -487,17 +592,17 @@ public class RSECoreTestCase extends TestCase { } } }); - + // Give the UI a chance to repaint if the view zoom state changed if (isProperty(PROP_RSE_SYSTEMS_VIEW_ZOOM_STATE_CHANGED, true)) { System.err.println("Waiting for UI to repaint"); //$NON-NLS-1$ RSEWaitAndDispatchUtil.waitAndDispatch(1000); } } - + /** * Restore the RSE SystemsView to its previous state, in case the view state - * has been changed by {@link #switchMaximizeSystemsView()}. + * has been changed by {@link #switchMaximizeSystemsView()}. */ protected void restoreMaximizeSystemsView() { // restore the original view zoom state @@ -522,10 +627,10 @@ public class RSECoreTestCase extends TestCase { }); } } - + /** * Finds the view reference for the view identified by the specified id. - * + * * @param viewId The unique view id. Must be not null. * @param perspectiveId The unique perspective id within the view should be searched. Must be not null. * @return The view reference instance to the view or null if not available. @@ -533,32 +638,32 @@ public class RSECoreTestCase extends TestCase { public final IViewReference findView(String viewId, String perspectiveId) { assert viewId != null && perspectiveId != null; if (viewId == null || perspectiveId == null) return null; - + // First of all, we have to lookup the currently active workbench - // of the currently active workbench window. + // of the currently active workbench window. IWorkbench workbench = PlatformUI.getWorkbench(); assertNotNull("Failed to query current workbench instance!", workbench); //$NON-NLS-1$ // and the corresponding currently active workbench window. IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); assertNotNull("Failed to query currently active workbench window!", window); //$NON-NLS-1$ - + // Now we have to switch to the specified perspecitve try { workbench.showPerspective(perspectiveId, window); } catch (WorkbenchException e) { SystemBasePlugin.logError("Failed to switch to requested perspective (id = " + perspectiveId + ")!", e); //$NON-NLS-1$ //$NON-NLS-2$ } - + // From the active workbench window, we need the active workbench page IWorkbenchPage page = window.getActivePage(); assertNotNull("Failed to query currently active workbench page!", page); //$NON-NLS-1$ - + return page.findViewReference(viewId); } /** * Shows and activate the view identified by the specified id. - * + * * @param viewId The unique view id. Must be not null. * @param perspectiveId The unique perspective id within the view should be activated. Must be not null. * @return The view part instance to the view or null if it cannot be shown. @@ -566,46 +671,46 @@ public class RSECoreTestCase extends TestCase { public final IViewPart showView(String viewId, String perspectiveId) { assert viewId != null && perspectiveId != null; if (viewId == null || perspectiveId == null) return null; - + // First of all, we have to lookup the currently active workbench - // of the currently active workbench window. + // of the currently active workbench window. IWorkbench workbench = PlatformUI.getWorkbench(); assertNotNull("Failed to query current workbench instance!", workbench); //$NON-NLS-1$ // and the corresponding currently active workbench window. IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); assertNotNull("Failed to query currently active workbench window!", window); //$NON-NLS-1$ - + // Now we have to switch to the specified perspecitve try { workbench.showPerspective(perspectiveId, window); } catch (WorkbenchException e) { SystemBasePlugin.logError("Failed to switch to requested perspective (id = " + perspectiveId + ")!", e); //$NON-NLS-1$ //$NON-NLS-2$ } - + // From the active workbench window, we need the active workbench page IWorkbenchPage page = window.getActivePage(); assertNotNull("Failed to query currently active workbench page!", page); //$NON-NLS-1$ - + IViewPart part = null; try { part = page.showView(viewId); } catch (PartInitException e) { SystemBasePlugin.logError("Failed to show view (id = " + viewId + ")!", e); //$NON-NLS-1$ //$NON-NLS-2$ } - + return part; } /** * Hides the view identified by the specified id. - * + * * @param viewId The unique view id. Must be not null. * @param perspectiveId The unique perspective id the view should be hidden from. Must be not null. */ public final void hideView(String viewId, String perspectiveId) { assert viewId != null && perspectiveId != null; if (viewId == null || perspectiveId == null) return; - + IViewReference viewReference = findView(viewId, perspectiveId); if (viewReference != null) { // at this point we can safely asume that we can access the active page directly @@ -616,7 +721,7 @@ public class RSECoreTestCase extends TestCase { } // ***** Test data management and support methods ***** - + /** * Returns the absolute test data location path calculated out of the known * test data location root (org.eclipse.rse.tests plugin location + sub @@ -630,16 +735,16 @@ public class RSECoreTestCase extends TestCase { *
* If the calculated test data location does not pass these conditions, the * method will return null. - * + * * @param relativePath A path relative to the test data location root path. Must be not nullTrue if to append the current execution host operating system string, false otherwise. - * + * * @return The root path to the test data location or null if the test data location does cannot be read or is not a directory. */ protected final IPath getTestDataLocation(String relativePath, boolean appendHostOS) { assert relativePath != null; IPath root = null; - + if (relativePath != null) { Bundle bundle = RSETestsPlugin.getDefault().getBundle(); if (bundle != null) { @@ -660,14 +765,14 @@ public class RSECoreTestCase extends TestCase { } } } - + return root; } // ***** Test failures log collector management and support methods ***** - + 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 @@ -681,7 +786,7 @@ public class RSECoreTestCase extends TestCase { public void startTest(Test test) { // nothing to do on start test } - + /* (non-Javadoc) * @see junit.framework.TestListener#addError(junit.framework.Test, java.lang.Throwable) */ @@ -695,7 +800,7 @@ public class RSECoreTestCase extends TestCase { error ); RSETestsPlugin.getDefault().getLog().log(status); - + // Collect the log files if at least one test log collector is known collectTestLogs(test); } @@ -714,7 +819,7 @@ public class RSECoreTestCase extends TestCase { failure ); RSETestsPlugin.getDefault().getLog().log(status); - + // Collect the log files if at least one test log collector is known collectTestLogs(test); } @@ -727,10 +832,10 @@ public class RSECoreTestCase extends TestCase { // nothing to do on end test } } - + /** * Collect the test logs for the failed test. - * + * * @param test The failed test. Must be not null. */ protected final synchronized void collectTestLogs(Test test) { @@ -754,11 +859,11 @@ public class RSECoreTestCase extends TestCase { if (archivePath.toFile().createNewFile()) { stream = new ZipOutputStream(new FileOutputStream(archivePath.toFile())); stream.setLevel(9); - + // cache the names of the entries added to the ZIP stream. // They needs to be unique! Set nameCache = new HashSet(); - + // call each test log collector delegate for the absolute file names // and add each of the returned files to the ZIP archive. for (int i = 0; i < delegates.length; i++) { @@ -783,7 +888,7 @@ public class RSECoreTestCase extends TestCase { unifier = location.removeLastSegments(1); entryName = unifier.lastSegment() + "_" + entryName; //$NON-NLS-1$ } - + // if the name is still not unique, append a count to it long count = 0; // force to make a copy of the current name @@ -795,11 +900,11 @@ public class RSECoreTestCase extends TestCase { } else { nameCache.add(entryName); } - + ZipEntry zipEntry = new ZipEntry(entryName); zipEntry.setTime(file.lastModified()); stream.putNextEntry(zipEntry); - + // Read the file bytewise and write it bytewise to the ZIP BufferedInputStream fileStream = null; try { @@ -820,13 +925,13 @@ public class RSECoreTestCase extends TestCase { } } } - + // If done with the current test log collector delegate, signal the delegate to dispose himself. // This gives the delegate the chance to remove any possibly created temporary file. delegate.dispose(); } } - } catch(IOException e) { + } catch(IOException e) { /* ignored on purpose */ } finally { // always close the stream if open diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/registries/SubSystemConfigurationProxyTestCase.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/registries/SubSystemConfigurationProxyTestCase.java index 485f2545385..ff8bdc81850 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/registries/SubSystemConfigurationProxyTestCase.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/registries/SubSystemConfigurationProxyTestCase.java @@ -1,15 +1,15 @@ /******************************************************************************* * Copyright (c) 2007, 2008 Wind River Systems, Inc. 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: + * 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 API and implementation * Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType * Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods - * Martin Oberhuber (Wind River) - [186640] Add IRSESystemType.testProperty() + * Martin Oberhuber (Wind River) - [186640] Add IRSESystemType.testProperty() * Martin Oberhuber (Wind River) - organize, enable and tag test cases *******************************************************************************/ package org.eclipse.rse.tests.core.registries; @@ -23,16 +23,18 @@ import org.eclipse.rse.tests.core.RSECoreTestCase; /** * Tests the subsystem configuration proxy functionality. - * + * * @author uwe.stieber@windriver.com */ public class SubSystemConfigurationProxyTestCase extends RSECoreTestCase { - + public void testSubSystemConfigurationProxy() { //-test-author-:UweStieber + if (isTestDisabled()) + return; ISystemRegistry systemRegistry = RSECorePlugin.getTheSystemRegistry(); assertNotNull("Failed to fetch RSE system registry instance!", systemRegistry); //$NON-NLS-1$ - + // get all subsystem configuration proxies and pick out the ones from our // tests plugin. ISubSystemConfigurationProxy[] proxies = systemRegistry.getSubSystemConfigurationProxies(); @@ -44,7 +46,7 @@ public class SubSystemConfigurationProxyTestCase extends RSECoreTestCase { assertEquals("Proxy object changed hash code between two calls!", proxy.hashCode(), proxy.hashCode()); //$NON-NLS-1$ assertFalse("Unexpected return value true for proxy.equals(null)!", proxy.equals(null)); //$NON-NLS-1$ assertTrue("Unexpected return value false for proxy.equals(proxy)!", proxy.equals(proxy)); //$NON-NLS-1$ - + // a few specific value we test only for one well known test subsystem if ("org.eclipse.rse.tests.subsystems.TestSubSystem".equals(proxy.getId())) { //$NON-NLS-1$ assertEquals("Unexpected return value for proxy.getDescription()!", "Test Subsystem", proxy.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$ @@ -55,7 +57,7 @@ public class SubSystemConfigurationProxyTestCase extends RSECoreTestCase { assertEquals("Unexpected return value for proxy.getPriority()!", 50000, proxy.getPriority()); //$NON-NLS-1$ assertEquals("Unexpected return value for proxy.getCategory()!", "users", proxy.getCategory()); //$NON-NLS-1$ //$NON-NLS-2$ assertNotNull("Unexpected return value null for proxy.getSubSystemConfiguration()!", proxy.getSubSystemConfiguration()); //$NON-NLS-1$ - + // walk through all known system types. Only "Local" and "Windows" should match! IRSESystemType[] systemTypes = RSECorePlugin.getTheCoreRegistry().getSystemTypes(); assertNotNull("Failed to fetch list of registered system types!", systemTypes); //$NON-NLS-1$ @@ -79,7 +81,7 @@ public class SubSystemConfigurationProxyTestCase extends RSECoreTestCase { assertEquals("Unexpected return value for proxy.getPriority()!", 100000, proxy.getPriority()); //$NON-NLS-1$ assertEquals("Unexpected return value for proxy.getCategory()!", "users", proxy.getCategory()); //$NON-NLS-1$ //$NON-NLS-2$ assertNotNull("Unexpected return value null for proxy.getSubSystemConfiguration()!", proxy.getSubSystemConfiguration()); //$NON-NLS-1$ - + // walk through all known system types. All system types declared by the tests plugin are expected to match IRSESystemType[] systemTypes = RSECorePlugin.getTheCoreRegistry().getSystemTypes(); assertNotNull("Failed to fetch list of registered system types!", systemTypes); //$NON-NLS-1$ @@ -103,7 +105,7 @@ public class SubSystemConfigurationProxyTestCase extends RSECoreTestCase { assertEquals("Unexpected return value for proxy.getPriority()!", 2000, proxy.getPriority()); //$NON-NLS-1$ assertEquals("Unexpected return value for proxy.getCategory()!", "users", proxy.getCategory()); //$NON-NLS-1$ //$NON-NLS-2$ assertNotNull("Unexpected return value null for proxy.getSubSystemConfiguration()!", proxy.getSubSystemConfiguration()); //$NON-NLS-1$ - + // walk through all known system types. Only "Unix" and "Linux" should match! IRSESystemType[] systemTypes = RSECorePlugin.getTheCoreRegistry().getSystemTypes(); assertNotNull("Failed to fetch list of registered system types!", systemTypes); //$NON-NLS-1$ diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/registries/SubSystemInterfacesTest.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/registries/SubSystemInterfacesTest.java index fb5bdd349d6..19d258c5747 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/registries/SubSystemInterfacesTest.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/registries/SubSystemInterfacesTest.java @@ -1,11 +1,11 @@ /******************************************************************************* * Copyright (c) 2008 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: + * 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 implementation *******************************************************************************/ package org.eclipse.rse.tests.core.registries; @@ -23,14 +23,14 @@ import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCmdSubSystem; import org.eclipse.rse.tests.core.RSECoreTestCase; /** - * Tests the subsystem configuration proxy functionality. - * - * @author uwe.stieber@windriver.com + * Tests the subsystem interfaces. */ public class SubSystemInterfacesTest extends RSECoreTestCase { - + public void testSubSystemFinding() { //-test-author-:DavidDykstal + if (isTestDisabled()) + return; try { ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry(); assertNotNull("system registry not found", registry); //$NON-NLS-1$ diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/initialization/InitializationTest.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/initialization/InitializationTest.java index 4f453e6c18d..e3fe516e1fb 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/initialization/InitializationTest.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/initialization/InitializationTest.java @@ -18,16 +18,17 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.rse.core.IRSEInitListener; import org.eclipse.rse.core.RSECorePlugin; +import org.eclipse.rse.tests.RSETestsPlugin; /** * Should be run on a clean workspace. */ public class InitializationTest extends TestCase { - + public InitializationTest(String name) { super(name); } - + /* (non-Javadoc) * @see org.eclipse.rse.tests.core.RSECoreTestCase#setUp() */ @@ -39,16 +40,17 @@ public class InitializationTest extends TestCase { } }); } - + /* (non-Javadoc) * @see org.eclipse.rse.tests.core.RSECoreTestCase#tearDown() */ protected void tearDown() throws Exception { super.tearDown(); } - + public void testInitialization() { //-test-author-:DavidDykstal + if (!RSETestsPlugin.isTestCaseEnabled("InitializationTest.testInitialization"))return; //$NON-NLS-1$ try { IStatus status = null; status = RSECorePlugin.waitForInitCompletion(RSECorePlugin.INIT_MODEL); @@ -78,5 +80,5 @@ public class InitializationTest extends TestCase { assertFalse("listener saw phase INIT_MODEL", listener.sawPhase(RSECorePlugin.INIT_MODEL)); // shouldn't see this since it occurs before the listener is added assertTrue("listener missed phase INIT_ALL", listener.sawPhase(RSECorePlugin.INIT_ALL)); } - + } 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 377a2d9ff29..1e90715b331 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,11 +1,11 @@ /******************************************************************************* * Copyright (c) 2006, 2008 Wind River Systems, Inc. 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: + * 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 API and implementation * Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType * Martin Oberhuber (Wind River) - organize, enable and tag test cases @@ -24,7 +24,6 @@ import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.rse.core.IRSESystemType; -import org.eclipse.rse.tests.RSETestsPlugin; import org.eclipse.rse.tests.core.IRSECoreTestCaseProperties; import org.eclipse.rse.tests.core.RSEWaitAndDispatchUtil; import org.eclipse.rse.tests.core.RSEWaitAndDispatchUtil.IInterruptCondition; @@ -43,8 +42,9 @@ public class RSEInternalFrameworkTestCase extends RSEBaseConnectionTestCase { */ public void testCoreTestPropertiesHandling() { //-test-author-:UweStieber - if (!RSETestsPlugin.isTestCaseEnabled("RSEInternalFrameworkTestCase.testCoreTestPropertiesHandling")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + // test for our defaults assertTrue("Unexpected default for property PROP_MAXIMIZE_REMOTE_SYSTEMS_VIEW!", isProperty(IRSECoreTestCaseProperties.PROP_MAXIMIZE_REMOTE_SYSTEMS_VIEW, false)); //$NON-NLS-1$ assertEquals("Unexpected default for property PROP_SWITCH_TO_PERSPECTIVE!", "org.eclipse.rse.ui.view.SystemPerspective", getProperty(IRSECoreTestCaseProperties.PROP_SWITCH_TO_PERSPECTIVE)); //$NON-NLS-1$ //$NON-NLS-2$ @@ -79,7 +79,7 @@ public class RSEInternalFrameworkTestCase extends RSEBaseConnectionTestCase { public boolean isTrue() { return params.size() > 0; } public void dispose() { params.clear(); } } - + private static class TestJob extends Job { final List params; public TestJob(List params) { @@ -87,7 +87,7 @@ public class RSEInternalFrameworkTestCase extends RSEBaseConnectionTestCase { assert params != null; this.params = params; } - + protected IStatus run(IProgressMonitor monitor) { PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { public void run() { @@ -97,24 +97,25 @@ public class RSEInternalFrameworkTestCase extends RSEBaseConnectionTestCase { return Status.OK_STATUS; } } - + /** * Test the RSEWaitAndDispatchUtil wait methods. */ public void testWaitAndDispatch() { //-test-author-:UweStieber - if (!RSETestsPlugin.isTestCaseEnabled("RSEInternalFrameworkTestCase.testWaitAndDispatch")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + // the simple wait and dispatch is time out based long start = System.currentTimeMillis(); RSEWaitAndDispatchUtil.waitAndDispatch(2500); long end = System.currentTimeMillis(); assertTrue("Failed to wait a given timeout!", (end - start) >= 2500); //$NON-NLS-1$ - + // the more complex wait and dispatch method has to stop // on a given condition. final List params = new ArrayList(); - + // the trick here is to make the condition true only if a // runnable passed through the display thread. That should // give us the asurance that the display event dispatching @@ -125,55 +126,57 @@ public class RSEInternalFrameworkTestCase extends RSEBaseConnectionTestCase { job.setPriority(Job.SHORT); job.setRule(ResourcesPlugin.getWorkspace().getRoot()); job.schedule(3000); - + boolean timeout = RSEWaitAndDispatchUtil.waitAndDispatch(10000, new TestWaiter(params)); assertFalse("Interrupt condition failed to stop wait method!", timeout); //$NON-NLS-1$ assertEquals("Interrupt condition failed to dispose!", 0, params.size()); //$NON-NLS-1$ } - + /** * Test accessing the test data location. */ public void testTestDataLocationManagement() { //-test-author-:UweStieber - if (!RSETestsPlugin.isTestCaseEnabled("RSEInternalFrameworkTestCase.testTestDataLocationManagement")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + // get the pure test data location root path. IPath root = getTestDataLocation("", false); //$NON-NLS-1$ assertNotNull("Failed to query test data location root!", root); //$NON-NLS-1$ assertTrue("Test data root location " + root.toOSString() + " is not a directory!", root.toFile().isDirectory()); //$NON-NLS-1$ //$NON-NLS-2$ assertTrue("Test data root location " + root.toOSString() + " cannot be read!", root.toFile().canRead()); //$NON-NLS-1$ //$NON-NLS-2$ - + // get a test data location path under the root String relative = "unittest_" + System.currentTimeMillis(); //$NON-NLS-1$ // as the directories should not exist yet, a call to getTestDataLocation must return null IPath path = getTestDataLocation(relative, false); assertNull("Test data location exist but should not!", path); //$NON-NLS-1$ - + // go and create the path now (including the OS) String os = Platform.getOS(); assertNotNull("Failed to query current execution host operating system string!", os); //$NON-NLS-1$ path = root.append(relative + "/" + os); //$NON-NLS-1$ assertTrue("Failed to create test data location directories. Permission problem?", path.toFile().mkdirs()); //$NON-NLS-1$ - + // Now, the re-query must be successful. IPath path2 = getTestDataLocation(relative, false); assertNotNull("Test data location " + root.append(relative).toOSString() + " seems not to exist!", path2); //$NON-NLS-1$ //$NON-NLS-2$ path2 = getTestDataLocation(relative, true); assertNotNull("Test data location " + path.toOSString() + " seems not to exist!", path2); //$NON-NLS-1$ //$NON-NLS-2$ - + // Delete the created pathes again 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() { //-test-author-:UweStieber - if (!RSETestsPlugin.isTestCaseEnabled("RSEInternalFrameworkTestCase.testConnectionManager")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + // 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$ @@ -181,17 +184,17 @@ public class RSEInternalFrameworkTestCase extends RSEBaseConnectionTestCase { 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!", IRSESystemType.SYSTEMTYPE_WINDOWS_ID, properties.getProperty(IRSEConnectionProperties.ATTR_SYSTEM_TYPE_ID)); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("Property system type does not match!", IRSESystemType.SYSTEMTYPE_WINDOWS_ID, properties.getProperty(IRSEConnectionProperties.ATTR_SYSTEM_TYPE_ID)); //$NON-NLS-1$ 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_ID, IRSESystemType.SYSTEMTYPE_SSH_ONLY_ID); @@ -201,7 +204,7 @@ public class RSEInternalFrameworkTestCase extends RSEBaseConnectionTestCase { 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!", IRSESystemType.SYSTEMTYPE_SSH_ONLY_ID, properties.getProperty(IRSEConnectionProperties.ATTR_SYSTEM_TYPE_ID)); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("Property system type does not match!", IRSESystemType.SYSTEMTYPE_SSH_ONLY_ID, properties.getProperty(IRSEConnectionProperties.ATTR_SYSTEM_TYPE_ID)); //$NON-NLS-1$ 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$ @@ -211,7 +214,7 @@ public class RSEInternalFrameworkTestCase extends RSEBaseConnectionTestCase { 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!", IRSESystemType.SYSTEMTYPE_SSH_ONLY_ID, properties.getProperty(IRSEConnectionProperties.ATTR_SYSTEM_TYPE_ID)); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("Property system type does not match!", IRSESystemType.SYSTEMTYPE_SSH_ONLY_ID, properties.getProperty(IRSEConnectionProperties.ATTR_SYSTEM_TYPE_ID)); //$NON-NLS-1$ 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/RSETestsPluginTestCase.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/internal/RSETestsPluginTestCase.java index 4d3c0663c2f..b3c44217ff6 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,11 +1,11 @@ /******************************************************************************* * Copyright (c) 2006, 2008 Wind River Systems, Inc. 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: + * 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 API and implementation * Martin Oberhuber (Wind River) - organize, enable and tag test cases *******************************************************************************/ @@ -28,21 +28,22 @@ public class RSETestsPluginTestCase extends RSECoreTestCase { */ public void testPluginResourceBundle() { //-test-author-:UweStieber - if (!RSETestsPlugin.isTestCaseEnabled("RSETestsPluginTestCase.testPluginResourceBundle")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + ResourceBundle bundle = RSETestsPlugin.getDefault().getResourceBundle(); assertNotNull("No resource bundle associated with RSETestsPlugin!", bundle); //$NON-NLS-1$ - + // our own test id must be true here, otherwise we wouldn't had // reached this point anyway. assertTrue("Unexpected return value false!", RSETestsPlugin.isTestCaseEnabled("RSETestsPluginTestCase.testPluginResourceBundle")); //$NON-NLS-1$ //$NON-NLS-2$ // a test id not listed within the resources file must be always true assertTrue("Unexpected return value false!", RSETestsPlugin.isTestCaseEnabled("RSETestsPluginTestCase.testNeverAddThisToTheResourceBundle")); //$NON-NLS-1$ //$NON-NLS-2$ - + // this test id should be never enabled assertFalse("Unexpected return value true!", RSETestsPlugin.isTestCaseEnabled("RSETestsPluginTestCase.dontRemove.testNeverEnabledThis")); //$NON-NLS-1$ //$NON-NLS-2$ - + // Test the different getResourceString methods. String expected = "testResolveString"; //$NON-NLS-1$ assertEquals("Unexpected return value!", expected, RSETestsPlugin.getResourceString("RSETestsPluginTestCase.dontRemove.testResolveString")); //$NON-NLS-1$ //$NON-NLS-2$ diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/persistence/ExportImportTest.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/persistence/ExportImportTest.java index 0d0f0cc32b0..e76a56d7c61 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/persistence/ExportImportTest.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/persistence/ExportImportTest.java @@ -1,13 +1,14 @@ /********************************************************************************* - * Copyright (c) 2008 IBM Corporation. All rights reserved. + * Copyright (c) 2008 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 + * 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. * David Dykstal (IBM) - [189274] provide import and export operations for profiles * David Dykstal (IBM) - [232126] add test for filter type persistence + * Martin Oberhuber (Wind River) - [240729] More flexible disabling of testcases *********************************************************************************/ package org.eclipse.rse.tests.persistence; @@ -35,10 +36,10 @@ import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem; import org.eclipse.rse.tests.core.RSECoreTestCase; /** - * + * */ public class ExportImportTest extends RSECoreTestCase { - + ISystemProfile sourceProfile = null; ISystemRegistry registry = null; IRSEPersistenceManager manager = null; @@ -47,7 +48,7 @@ public class ExportImportTest extends RSECoreTestCase { public ExportImportTest(String name) { super(name); } - + /* (non-Javadoc) * @see org.eclipse.rse.tests.core.RSECoreTestCase#setUp() */ @@ -82,7 +83,7 @@ public class ExportImportTest extends RSECoreTestCase { ISystemFilter sharedFilter = sharedFilterPool.createSystemFilter("sharedFilter", filterStrings); sharedFilter.setType("sharedFilterType"); } - + /* (non-Javadoc) * @see org.eclipse.rse.tests.core.RSECoreTestCase#tearDown() */ @@ -95,6 +96,8 @@ public class ExportImportTest extends RSECoreTestCase { */ public void testFilterPool1() { //-test-author-:DavidDykstal + if (isTestDisabled()) + return; try { // find the provider IRSEPersistenceProvider persistenceProvider = manager.getPersistenceProvider("org.eclipse.rse.persistence.PropertyFileProvider"); @@ -105,7 +108,7 @@ public class ExportImportTest extends RSECoreTestCase { RSEEnvelope envelope = new RSEEnvelope(); envelope.add(fp); IProgressMonitor monitor = new NullProgressMonitor(); - ByteArrayOutputStream out = new ByteArrayOutputStream(); + ByteArrayOutputStream out = new ByteArrayOutputStream(); envelope.put(out, persistenceProvider, monitor); // create an empty profile ISystemProfile targetProfile = registry.createSystemProfile("profileFilterPool1", true); @@ -143,6 +146,8 @@ public class ExportImportTest extends RSECoreTestCase { */ public void testHost1() { //-test-author-:DavidDykstal + if (isTestDisabled()) + return; try { // find the provider IRSEPersistenceProvider persistenceProvider = manager.getPersistenceProvider("org.eclipse.rse.persistence.PropertyFileProvider"); @@ -153,7 +158,7 @@ public class ExportImportTest extends RSECoreTestCase { RSEEnvelope envelope = new RSEEnvelope(); envelope.add(host1); IProgressMonitor monitor = new NullProgressMonitor(); - ByteArrayOutputStream out = new ByteArrayOutputStream(); + ByteArrayOutputStream out = new ByteArrayOutputStream(); envelope.put(out, persistenceProvider, monitor); // import from the newly created stream ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); @@ -189,6 +194,8 @@ public class ExportImportTest extends RSECoreTestCase { public void testPropertySet() { //-test-author-:DavidDykstal + if (isTestDisabled()) + return; } } diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/persistence/MigrationTest.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/persistence/MigrationTest.java index 7b61e7c41b2..853f62af439 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/persistence/MigrationTest.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/persistence/MigrationTest.java @@ -1,11 +1,12 @@ /********************************************************************************* - * Copyright (c) 2008 IBM Corporation. All rights reserved. + * Copyright (c) 2008 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 + * 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. + * Martin Oberhuber (Wind River) - [240729] More flexible disabling of testcases *********************************************************************************/ package org.eclipse.rse.tests.persistence; @@ -13,7 +14,7 @@ package org.eclipse.rse.tests.persistence; import org.eclipse.rse.tests.core.RSECoreTestCase; /** - * + * */ public class MigrationTest extends RSECoreTestCase { @@ -23,6 +24,8 @@ public class MigrationTest extends RSECoreTestCase { public void testProfileMigration() { //-test-author-:DavidDykstal + if (isTestDisabled()) + return; // create a new profile // set its persistence manager to PM1 // populate the profile diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/persistence/PersistenceTest.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/persistence/PersistenceTest.java index 5749be3397f..6e69611f600 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/persistence/PersistenceTest.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/persistence/PersistenceTest.java @@ -35,32 +35,34 @@ import org.eclipse.rse.ui.SystemPreferencesManager; /** * Tests for {@link SystemPreferencesManager}. - * Since these are persistence tests they will play with the creation and deletion of + * Since these are persistence tests they will play with the creation and deletion of * profiles, hosts, filters, and other model objects. You should run this only in a * clean workspace. */ public class PersistenceTest extends RSECoreTestCase { - + public PersistenceTest(String name) { super(name); } - + /* (non-Javadoc) * @see org.eclipse.rse.tests.core.RSECoreTestCase#setUp() */ protected void setUp() throws Exception { super.setUp(); } - + /* (non-Javadoc) * @see org.eclipse.rse.tests.core.RSECoreTestCase#tearDown() */ protected void tearDown() throws Exception { super.tearDown(); } - + public void testPersistenceManagerStartup() { //-test-author-:DavidDykstal + if (isTestDisabled()) + return; IRSEPersistenceManager m = RSECorePlugin.getThePersistenceManager(); for (int i = 0; i < 5; i++) { if (m.isRestoreComplete()) break; @@ -72,15 +74,17 @@ public class PersistenceTest extends RSECoreTestCase { } assertTrue("Restore not complete", m.isRestoreComplete()); } - + public void testProfilePersistence() { //-test-author-:DavidDykstal + if (isTestDisabled()) + return; /* * Set up this particular test. */ ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry(); int n = registry.getSystemProfileManager().getSystemProfiles().length; - + /* * Create a new profile in this profile manager. This will be the second * profile created. Creating a profile causes a commit. @@ -94,15 +98,15 @@ public class PersistenceTest extends RSECoreTestCase { } catch (Exception e) { throw new RuntimeException(e); } - + // reload(); // reload not yet working - + /* * There should be one more profile */ ISystemProfile[] profiles = registry.getSystemProfileManager().getSystemProfiles(); assertEquals(n, profiles.length); - + /* * One should be default private profile */ @@ -112,7 +116,7 @@ public class PersistenceTest extends RSECoreTestCase { found = p.isDefaultPrivate(); } assertTrue("Default private profile not found", found); - + /* * One should be the test profile */ @@ -122,7 +126,7 @@ public class PersistenceTest extends RSECoreTestCase { found = p.getName().equals("bogus"); } assertTrue("bogus profile not found", found); - + /* * Get the test profile and check its properties. */ @@ -133,7 +137,7 @@ public class PersistenceTest extends RSECoreTestCase { IPropertySet[] pSets = bogus.getPropertySets(); assertNotNull(pSets); assertEquals(0, pSets.length); - + /* * Add a property set to the profile. */ @@ -141,20 +145,20 @@ public class PersistenceTest extends RSECoreTestCase { bogusProperties.addProperty("bp1", "1"); bogusProperties.addProperty("bp2", "2"); bogus.addPropertySet(bogusProperties); - + // nested property set IPropertySet bogusNestedProperties = new PropertySet("bogus_nested_properties"); bogusNestedProperties.addProperty("bnpa", "a"); bogusNestedProperties.addProperty("bnpb", "b"); bogusProperties.addPropertySet(bogusNestedProperties); - + bogus.commit(); - + /* * Refresh the profile manager. */ // reload(); // reload not yet working - + /* * Check to see if everything is still OK and that the properties are restored. */ @@ -169,29 +173,31 @@ public class PersistenceTest extends RSECoreTestCase { assertNotNull(bogusProperties); assertEquals("1", bogusProperties.getProperty("bp1").getValue()); assertEquals("2", bogusProperties.getProperty("bp2").getValue()); - + bogusNestedProperties = bogusProperties.getPropertySet("bogus_nested_properties"); assertNotNull(bogusNestedProperties); assertEquals("a", bogusNestedProperties.getProperty("bnpa").getValue()); - assertEquals("b", bogusNestedProperties.getProperty("bnpb").getValue()); - + assertEquals("b", bogusNestedProperties.getProperty("bnpb").getValue()); + try { registry.deleteSystemProfile(bogus); } catch (Exception e) { throw new RuntimeException(e); } - + // reload(); // reload not yet working - + } public void testHostPersistence() { //-test-author-:DavidDykstal + if (isTestDisabled()) + return; /* * Set up this particular test. */ ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry(); - + /* * Create a new profile in this profile manager. This will be the third * profile created. Creating a profile causes a commit. @@ -203,7 +209,7 @@ public class PersistenceTest extends RSECoreTestCase { } ISystemProfile profile = registry.getSystemProfile("bogus"); assertNotNull(profile); - + try { IRSESystemType linuxType = RSECorePlugin.getTheCoreRegistry().getSystemTypeById(IRSESystemType.SYSTEMTYPE_LINUX_ID); registry.createHost("bogus", linuxType, "myhost", "myhost.mynet.mycompany.net", null); @@ -218,9 +224,9 @@ public class PersistenceTest extends RSECoreTestCase { props.addProperty("bp2", "2"); host.addPropertySet(props); host.commit(); - + // reload(); // reload not yet working - + /* * Get the test profile and check its properties. */ @@ -232,12 +238,12 @@ public class PersistenceTest extends RSECoreTestCase { assertNotNull(props); assertEquals("1", props.getProperty("bp1").getValue()); assertEquals("2", props.getProperty("bp2").getValue()); - + } private void reload() { /* - * Set up this particular test. The persistence manager acts as the family for all + * Set up this particular test. The persistence manager acts as the family for all * Jobs that are created for reading and writing the persistent form of the model. */ IRSEPersistenceManager persistenceManager = RSECorePlugin.getThePersistenceManager(); @@ -253,12 +259,12 @@ public class PersistenceTest extends RSECoreTestCase { } catch (InterruptedException e) { throw new RuntimeException(e); } - + /* * restore the profile manager */ RSEUIPlugin.getDefault().restart(); } - + } diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/preferences/PreferencesTest.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/preferences/PreferencesTest.java index 612bb99f99d..fba94006742 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/preferences/PreferencesTest.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/preferences/PreferencesTest.java @@ -1,7 +1,7 @@ /******************************************************************************* * Copyright (c) 2006, 2008 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 + * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: @@ -28,23 +28,25 @@ import org.eclipse.rse.ui.SystemPreferencesManager; * Tests for {@link SystemPreferencesManager}. */ public class PreferencesTest extends RSECoreTestCase { - + /* (non-Javadoc) * @see org.eclipse.rse.tests.core.RSECoreTestCase#setUp() */ protected void setUp() throws Exception { super.setUp(); } - + /* (non-Javadoc) * @see org.eclipse.rse.tests.core.RSECoreTestCase#tearDown() */ protected void tearDown() throws Exception { super.tearDown(); } - + public void testActiveProfiles() { //-test-author-:DavidDykstal + if (isTestDisabled()) + return; RSEPreferencesManager.addActiveProfile("bogus01"); //$NON-NLS-1$ RSEPreferencesManager.addActiveProfile("bogus02"); //$NON-NLS-1$ String[] profiles = RSEPreferencesManager.getActiveProfiles(); @@ -60,17 +62,21 @@ public class PreferencesTest extends RSECoreTestCase { assertEquals(-1, RSEPreferencesManager.getActiveProfilePosition("bogus01")); //$NON-NLS-1$ assertEquals(-1, RSEPreferencesManager.getActiveProfilePosition("bogus99")); //$NON-NLS-1$ } - + public void testUserIds() { //-test-author-:DavidDykstal + if (isTestDisabled()) + return; RSEPreferencesManager.setUserId("a.b.c", "bogusUser"); //$NON-NLS-1$ //$NON-NLS-2$ assertEquals("bogusUser", RSEPreferencesManager.getUserId("a.b.c")); //$NON-NLS-1$ //$NON-NLS-2$ RSEPreferencesManager.clearUserId("a.b.c"); //$NON-NLS-1$ assertNull(RSEPreferencesManager.getUserId("a.b.c")); //$NON-NLS-1$ } - + public void testDefaultUserIds() { //-test-author-:DavidDykstal + if (isTestDisabled()) + return; IRSECoreRegistry registry = RSECorePlugin.getTheCoreRegistry(); //TODO should we test deprecated methods as well? Probably yes... IRSESystemType systemTypeDeprecated = registry.getSystemType("Local"); //$NON-NLS-1$ @@ -80,15 +86,17 @@ public class PreferencesTest extends RSECoreTestCase { RSEPreferencesManager.setDefaultUserId(systemType, "bogus1"); //$NON-NLS-1$ assertEquals("bogus1", RSEPreferencesManager.getDefaultUserId(systemType)); //$NON-NLS-1$ IRSESystemType localType = RSECorePlugin.getTheCoreRegistry().getSystemTypeById(IRSESystemType.SYSTEMTYPE_LOCAL_ID); - RSEPreferencesManager.setDefaultUserId(localType, "bogus2"); //$NON-NLS-1$ //$NON-NLS-2$ + RSEPreferencesManager.setDefaultUserId(localType, "bogus2"); //$NON-NLS-1$ assertEquals("bogus2", RSEPreferencesManager.getDefaultUserId(systemType)); //$NON-NLS-1$ RSEPreferencesManager.setDefaultUserId(systemType, oldValue); assertEquals(oldValue, RSEPreferencesManager.getDefaultUserId(systemType)); } - + public void testShowLocalConnection() { //-test-author-:DavidDykstal + if (isTestDisabled()) + return; assertTrue(SystemPreferencesManager.getShowLocalConnection()); } - + } diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/profiles/ProfileTest.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/profiles/ProfileTest.java index 653feefcf64..ab4c0c3758d 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/profiles/ProfileTest.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/profiles/ProfileTest.java @@ -23,36 +23,38 @@ import org.eclipse.rse.ui.SystemPreferencesManager; /** * Tests for {@link SystemPreferencesManager}. - * Since these are persistence tests they will play with the creation and deletion of + * Since these are persistence tests they will play with the creation and deletion of * profiles, hosts, filters, and other model objects. You should run this only in a * clean workspace. */ public class ProfileTest extends RSECoreTestCase { - + ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry(); ISystemProfileManager manager = registry.getSystemProfileManager(); ISystemProfile defaultProfile = manager.getDefaultPrivateSystemProfile(); - + public ProfileTest(String name) { super(name); } - + /* (non-Javadoc) * @see org.eclipse.rse.tests.core.RSECoreTestCase#setUp() */ protected void setUp() throws Exception { super.setUp(); } - + /* (non-Javadoc) * @see org.eclipse.rse.tests.core.RSECoreTestCase#tearDown() */ protected void tearDown() throws Exception { super.tearDown(); } - + public void testDefaultProfileMarking() { //-test-author-:DavidDykstal + if (isTestDisabled()) + return; assertNotNull("default profile is null", defaultProfile); assertTrue("default profile is not active - 1", defaultProfile.isActive()); assertTrue("default profile is not marked as default", defaultProfile.isDefaultPrivate()); @@ -60,6 +62,8 @@ public class ProfileTest extends RSECoreTestCase { public void testDefaultProfileActivation() { //-test-author-:DavidDykstal + if (isTestDisabled()) + return; registry.setSystemProfileActive(defaultProfile, true); assertTrue("default profile is not active - 2", defaultProfile.isActive()); registry.setSystemProfileActive(defaultProfile, false); // this should be ignored @@ -68,6 +72,8 @@ public class ProfileTest extends RSECoreTestCase { public void testDefaultProfileRename() { //-test-author-:DavidDykstal + if (isTestDisabled()) + return; try { ISystemProfile profile = registry.getSystemProfile("bogus"); assertNull(profile); @@ -89,6 +95,8 @@ public class ProfileTest extends RSECoreTestCase { public void testProfileActivation() { //-test-author-:DavidDykstal + if (isTestDisabled()) + return; try { ISystemProfile profile = registry.getSystemProfile("bogus"); assertNull(profile); @@ -107,6 +115,8 @@ public class ProfileTest extends RSECoreTestCase { public void testDefaultProfileDeletion() { //-test-author-:DavidDykstal + if (isTestDisabled()) + return; try { registry.deleteSystemProfile(defaultProfile); // this should be ignored List profiles = Arrays.asList(manager.getSystemProfiles()); @@ -116,9 +126,11 @@ public class ProfileTest extends RSECoreTestCase { throw new RuntimeException(e); } } - + public void testProfileDeletion() { //-test-author-:DavidDykstal + if (isTestDisabled()) + return; try { ISystemProfile profile = registry.getSystemProfile("bogus"); assertNull(profile); diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/CreateFileTestCase.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/CreateFileTestCase.java index fd29720b24f..4a35cf48e95 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/CreateFileTestCase.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/CreateFileTestCase.java @@ -1,13 +1,13 @@ /******************************************************************************** * Copyright (c) 2007, 2008 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 - * + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * * Initial Contributors: * The following IBM employees contributed to the Remote System Explorer * component that contains this file: Kevin Doyle. - * + * * Contributors: * Martin Oberhuber (Wind River) - [cleanup] Avoid using SystemStartHere in production code * Martin Oberhuber (Wind River) - organize, enable and tag test cases @@ -46,50 +46,53 @@ public class CreateFileTestCase extends FileServiceBaseTest { private IRemoteFileSubSystem getRemoteFileSubSystem(IHost host) { IRemoteFileSubSystem fss = null; - ISystemRegistry sr = SystemStartHere.getSystemRegistry(); + ISystemRegistry sr = SystemStartHere.getSystemRegistry(); ISubSystem[] ss = sr.getServiceSubSystems(host, IFileService.class); for (int i=0; i 0); - + // perform cleanup, so EFS uses the right file service next time cleanup(); } - + public void cleanup() throws Exception { if (host != null) { if (tempDirectory != null) { @@ -127,10 +130,10 @@ public class CreateFileTestCase extends FileServiceBaseTest { host = null; } } - + public void tearDown() throws Exception { cleanup(); super.tearDown(); } } - + diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FTPFileSubsystemTestCase.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FTPFileSubsystemTestCase.java index 26e4f0dce3c..4dcf1c80c97 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FTPFileSubsystemTestCase.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FTPFileSubsystemTestCase.java @@ -1,11 +1,11 @@ /******************************************************************************* * Copyright (c) 2006, 2008 Wind River Systems, Inc. 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: + * 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 API and implementation. * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry * David McKnight (IBM) - [186363] get rid of obsolete calls to SubSystem.connect() @@ -30,7 +30,6 @@ import org.eclipse.rse.internal.services.files.ftp.FTPService; import org.eclipse.rse.services.files.IFileService; import org.eclipse.rse.services.files.IHostFile; import org.eclipse.rse.subsystems.files.ftp.FTPFileSubSystemConfiguration; -import org.eclipse.rse.tests.RSETestsPlugin; import org.eclipse.rse.tests.core.RSEWaitAndDispatchUtil; import org.eclipse.rse.tests.core.connection.IRSEConnectionProperties; import org.eclipse.rse.tests.core.connection.RSEBaseConnectionTestCase; @@ -42,7 +41,7 @@ import org.eclipse.rse.ui.RSEUIPlugin; public class FTPFileSubsystemTestCase extends RSEBaseConnectionTestCase { private ISubSystem subSystem; private IHost connection; - + /* (non-Javadoc) * @see org.eclipse.rse.tests.core.RSECoreTestCase#tearDown() */ @@ -56,7 +55,7 @@ public class FTPFileSubsystemTestCase extends RSEBaseConnectionTestCase { subSystem = null; connection = null; - + super.tearDown(); } @@ -65,11 +64,12 @@ public class FTPFileSubsystemTestCase extends RSEBaseConnectionTestCase { */ public void testFTPReadAccessToRemoteHost() { //-test-author-:UweStieber - if (!RSETestsPlugin.isTestCaseEnabled("FTPFileSubsystemTestCase.testFTPReadAccessToRemoteHost")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + ISystemRegistry systemRegistry = RSECorePlugin.getTheSystemRegistry(); assertNotNull("Failed to get RSE system registry instance!", systemRegistry); //$NON-NLS-1$ - + // Calculate the location of the test connection properties IPath location = getTestDataLocation("testFTPReadAccessToRemoteHost", false); //$NON-NLS-1$ assertNotNull("Cannot locate test data! Missing test data location?", location); //$NON-NLS-1$ @@ -77,20 +77,20 @@ public class FTPFileSubsystemTestCase extends RSEBaseConnectionTestCase { 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 properties from the calculated location without backing up defaults IRSEConnectionProperties properties = getConnectionManager().loadConnectionProperties(location, false); assertNotNull("Failed to load test connection properties from location " + location.toOSString(), properties); //$NON-NLS-1$ - + // Lookup and create the connection now if necessary connection = getConnectionManager().findOrCreateConnection(properties); assertNotNull("Failed to create connection " + properties.getProperty(IRSEConnectionProperties.ATTR_NAME), connection); //$NON-NLS-1$ // expand the connection in the UI RSEUIPlugin.getTheSystemRegistryUI().expandHost(connection); - + Exception exception = null; String cause = null; - + subSystem = null; try { subSystem = getConnectionManager().getFileSubSystem(connection, "ftp.files"); //$NON-NLS-1$ @@ -103,12 +103,12 @@ public class FTPFileSubsystemTestCase extends RSEBaseConnectionTestCase { ISubSystemConfiguration configuration = subSystem.getSubSystemConfiguration(); assertNotNull("Failed to get ftp.files subsystem configuration instance!", configuration); //$NON-NLS-1$ - + // The ftp.files subsystem supports filtering, therefor ISubSystem.getChildren() is expected // to return a non null value. assertTrue("Unexpected return value false for ftp.files subsystem configuration supportFilters()!", configuration.supportsFilters()); //$NON-NLS-1$ assertNotNull("Unexpected return value null for ftp.files subsystem getChildren()!", subSystem.getChildren()); //$NON-NLS-1$ - + // get access to the services assertTrue("ftp.files subsystem configuration instance is not of expected type FileServiceSubSystemConfiguration!", configuration instanceof FTPFileSubSystemConfiguration); //$NON-NLS-1$ FTPFileSubSystemConfiguration ftpConfiguration = (FTPFileSubSystemConfiguration)configuration; @@ -116,12 +116,12 @@ public class FTPFileSubsystemTestCase extends RSEBaseConnectionTestCase { assertNotNull("Failed to get IFileService instance from ftp.files subsystem configuration!", service); //$NON-NLS-1$ assertTrue("IFileService instance is not of expected type FTPService!", service instanceof FTPService); //$NON-NLS-1$ final FTPService ftpService = (FTPService)service; - + // configure the service to use passive ftp IPropertySet set = new PropertySet("testFTPReadAccessToRemoteHost"); //$NON-NLS-1$ set.addProperty("passive", "true"); //$NON-NLS-1$ //$NON-NLS-2$ ftpService.setPropertySet(set); - + // we expect that the subsystem is not connected yet assertFalse("ftp.files subsystem is unexpectedly connected!", subSystem.isConnected()); //$NON-NLS-1$ try { @@ -138,20 +138,20 @@ public class FTPFileSubsystemTestCase extends RSEBaseConnectionTestCase { // if we could not connect in 10 sec. we give up here. The server might be not reachable // or exceeded the max number of connection or ... or ... or ... Just do not fail in this case. if (!subSystem.isConnected() || !ftpService.isConnected()) return; - + // expand the subsystem RSEUIPlugin.getTheSystemRegistryUI().expandSubSystem(subSystem); - + // now we have the service reference and can start reading things from the server IHostFile[] roots = ftpService.getRoots(new NullProgressMonitor()); assertNotNull("Failed to get root nodes from ftp.files service!", roots); //$NON-NLS-1$ - + FTPClient ftpClient = ftpService.getFTPClient(); assertNotNull("Failed to get FTPClient instance!", ftpClient); //$NON-NLS-1$ - + exception = null; cause = null; - + FTPFile[] files = null; try { files = ftpClient.listFiles(); @@ -161,7 +161,7 @@ public class FTPFileSubsystemTestCase extends RSEBaseConnectionTestCase { } assertNull("Failed to list the files from ftp server " + properties.getProperty(IRSEConnectionProperties.ATTR_NAME) + "! Possible cause: " + cause, exception); //$NON-NLS-1$ //$NON-NLS-2$ assertNotNull("Unexpected return value null for FTPClient.listFiles()!", files); //$NON-NLS-1$ - + if (ftpService.isConnected()) ftpService.disconnect(); } } diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileOutputStreamTestCase.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileOutputStreamTestCase.java index 72a1f0dffeb..68382a292d1 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileOutputStreamTestCase.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileOutputStreamTestCase.java @@ -1,13 +1,13 @@ /******************************************************************************** * Copyright (c) 2007, 2008 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 - * + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * * Initial Contributors: * The following IBM employees contributed to the Remote System Explorer * component that contains this file: Kevin Doyle - * + * * Contributors: * Martin Oberhuber (Wind River) - [cleanup] Avoid using SystemStartHere in production code * Martin Oberhuber (Wind River) - organize, enable and tag test cases @@ -49,82 +49,102 @@ public class FileOutputStreamTestCase extends FileServiceBaseTest { private IRemoteFileSubSystem getRemoteFileSubSystem(IHost host) { IRemoteFileSubSystem fss = null; - ISystemRegistry sr = SystemStartHere.getSystemRegistry(); + ISystemRegistry sr = SystemStartHere.getSystemRegistry(); ISubSystem[] ss = sr.getServiceSubSystems(host, IFileService.class); for (int i=0; i return pathBuf.toString(); } - + public void cleanup() throws Exception { if (host != null) { if (tempDirectory != null) { @@ -225,7 +245,7 @@ public class FileOutputStreamTestCase extends FileServiceBaseTest { host = null; } } - + public void tearDown() throws Exception { cleanup(); super.tearDown(); diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileServiceArchiveBaseTest.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileServiceArchiveBaseTest.java index f7a93336b2f..61577561c04 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileServiceArchiveBaseTest.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileServiceArchiveBaseTest.java @@ -4,8 +4,8 @@ * 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: + * + * Contributors: * Johnson Ma (Wind River) - [195402] Extracted from FileServiceArchiveTest *******************************************************************************/ package org.eclipse.rse.tests.subsystems.files; @@ -23,26 +23,25 @@ import org.eclipse.rse.core.model.SystemWorkspaceResourceSet; import org.eclipse.rse.core.subsystems.ISystemDragDropAdapter; import org.eclipse.rse.files.ui.resources.UniversalFileTransferUtility; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; -import org.eclipse.rse.tests.RSETestsPlugin; public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { protected String folderToCopyName1 = "RemoteSystemsConnections"; protected String folderToCopyName2 = "6YLT5Xa"; protected String folderToCopyName3 = "folderToCopy"; - + protected String tarSourceFileName1; protected String tarSourceFileName2; - + protected String tarSourceFolderName1 = "META-INF"; protected String tarSourceFolderName2 = "org"; - + protected String tarSourceForOpenTest; protected String tarSourceForOpenFolderName1 = "META-INF"; protected String tarSourceForOpenFolderName2 = "org"; - + protected String testName; - + protected String fileContentString1 = "this is just some dummy content \n to a remote file \n to test an open operation"; /** @@ -52,17 +51,17 @@ public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { public FileServiceArchiveBaseTest(String name) { super(name); } - + public static IWorkspace getWorkspace() { return ResourcesPlugin.getWorkspace(); } - + public void createSourceFolders() throws Exception { String tempPath = getWorkspace().getRoot().getLocation().append("temp").toString(); IFileStore temp = createDir(tempPath, true); String content = getRandomString(); - + // create the source folder used for copy or move IFileStore folderToCopy = temp.getChild(folderToCopyName3); createDir(folderToCopy, true); @@ -81,7 +80,7 @@ public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { IFileStore epdcdump01_hex12aaaa = aaaaaaaa.getChild("epdcdump01.hex12aaaa"); content = getRandomString(); createFile(epdcdump01_hex12aaaa, content); - + IFileStore aaaab = folderToCopy.getChild("aaaab"); createDir(aaaab, true); IFileStore features = aaaab.getChild("features"); @@ -94,15 +93,15 @@ public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { IFileStore epdcdump01_hex12a = aaaab.getChild("epdcdump01.hex12a"); content = getRandomString(); createFile(epdcdump01_hex12a, content); - + IFileStore epdcdump01_hex12a1 = folderToCopy.getChild("epdcdump01.hex12a"); content = getRandomString(); createFile(epdcdump01_hex12a1, content); - + IFileStore RSE_SDK_2_0RC1_zip = folderToCopy.getChild("RSE-SDK-2.0RC1.zip"); content = getRandomString(); createFile(RSE_SDK_2_0RC1_zip, content); - + //now, copy folderToCopy into the folder in the remote system IRemoteFile sourceFolderToCopy3 = localFss.getRemoteFileObject(tempPath + '\\' + folderToCopyName3, mon); ISystemDragDropAdapter srcAdapter3 = (ISystemDragDropAdapter) ((IAdaptable) sourceFolderToCopy3).getAdapter(ISystemDragDropAdapter.class); @@ -110,20 +109,20 @@ public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { fromSet3.addResource(sourceFolderToCopy3); ISystemResourceSet tempObjects3 = srcAdapter3.doDrag(fromSet3, mon); UniversalFileTransferUtility.uploadResourcesFromWorkspace((SystemWorkspaceResourceSet)tempObjects3, tempDir, mon, true); - + //Then, we need to retrieve children of the tempDir to cache their information. fss.resolveFilterString(tempDir, null, mon); - + //Then, delete the temp folder in the junit workspace. temp.delete(EFS.NONE, mon); } - - protected void createSuperTransferFolder(IFileStore temp) throws Exception + + protected void createSuperTransferFolder(IFileStore temp) throws Exception { - + String content = getRandomString(); - + // create the source folder used for copy or move IFileStore folderToCopy = temp.getChild(folderToCopyName3); createDir(folderToCopy, true); @@ -142,7 +141,7 @@ public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { IFileStore epdcdump01_hex12aaaa = aaaaaaaa.getChild("epdcdump01.hex12aaaa"); content = getRandomString(); createFile(epdcdump01_hex12aaaa, content); - + IFileStore aaaab = folderToCopy.getChild("aaaab"); createDir(aaaab, true); IFileStore features = aaaab.getChild("features"); @@ -155,25 +154,25 @@ public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { IFileStore epdcdump01_hex12a = aaaab.getChild("epdcdump01.hex12a"); content = getRandomString(); createFile(epdcdump01_hex12a, content); - + IFileStore epdcdump01_hex12a1 = folderToCopy.getChild("epdcdump01.hex12a"); content = getRandomString(); createFile(epdcdump01_hex12a1, content); - + IFileStore RSE_SDK_2_0RC1_zip = folderToCopy.getChild("RSE-SDK-2.0RC1.zip"); content = getRandomString(); createFile(RSE_SDK_2_0RC1_zip, content); - + return; } - + public void createTarSourceForOpen() throws Exception { String tempPath = getWorkspace().getRoot().getLocation().append("temp").toString(); IFileStore temp = createDir(tempPath, true); String content = getRandomString(); - + //Now, we need to construct a "source.tar" archive file //We will construct the content of the tar file in folders "META-INF" and "org" //Then we copy this folder into a tar file by RSE API. @@ -183,7 +182,7 @@ public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { IFileStore MANIFEST_MF = META_INF.getChild("MANIFEST.MF"); content = fileContentString1; createFile(MANIFEST_MF, content); - + //create folder "org" IFileStore org = temp.getChild("org"); createDir(org, true); @@ -197,7 +196,7 @@ public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { createDir(core, true); IFileStore internal = dstore.getChild("internal"); createDir(internal, true); - + //now create directory inside "core": IFileStore client = core.getChild("client"); createDir(client, true); @@ -214,7 +213,7 @@ public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { IFileStore Activator_java = core.getChild("Activator.java"); content = fileContentString1; createFile(Activator_java, content); - + //now, some contents on client folder IFileStore ClientConnection_java = client.getChild("ClientConnection.java"); content = getRandomString(); @@ -222,12 +221,12 @@ public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { IFileStore ConnectionStatus_java = client.getChild("ConnectionStatus.java"); content = fileContentString1; createFile(ConnectionStatus_java, content); - + //now, some contents in java folder IFileStore ClassByteStreamHandler$ReceiveClassInstanceThread_java = java.getChild("ClassByteStreamHandler$ReceiveClassInstanceThread.java"); content = getRandomString(); createFile(ClassByteStreamHandler$ReceiveClassInstanceThread_java, content); - + //now, some contents in miners folder IFileStore Miner_java = miners.getChild("Miner.java"); content = getRandomString(); @@ -235,7 +234,7 @@ public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { IFileStore MinerThread_java = miners.getChild("MinerThread.java"); content = getRandomString(); createFile(MinerThread_java, content); - + //now, some contents in model folder IFileStore ByteStreamHandler_java = model.getChild("ByteStreamHandler.java"); content = getRandomString(); @@ -246,21 +245,21 @@ public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { IFileStore Handler_java = model.getChild("Handler.java"); content = getRandomString(); createFile(Handler_java, content); - + //now, some contents in server folder IFileStore Server_java = server.getChild("Server.java"); content = getRandomString(); createFile(Server_java, content); - + //now, some contents in util folder IFileStore StringCompare_java = util.getChild("StringCompare.java"); content = fileContentString1; createFile(StringCompare_java, content); - + //now, create the contents in "internal" folder IFileStore core1 = internal.getChild("core"); createDir(core1, true); - + //then create some folder in this "core" folder IFileStore client1 = core1.getChild("client"); createDir(client1, true); @@ -270,7 +269,7 @@ public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { createDir(server1, true); IFileStore util1 = core1.getChild("util"); createDir(util1, true); - + //now, some contents on client folder IFileStore ClientConnection_java1 = client1.getChild("ClientConnection.java"); content = getRandomString(); @@ -278,8 +277,8 @@ public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { IFileStore ConnectionStatus_java1 = client1.getChild("ConnectionStatus.java"); content = getRandomString(); createFile(ConnectionStatus_java1, content); - - + + //now, some contents in model folder IFileStore ByteStreamHandler_java1 = model1.getChild("ByteStreamHandler.java"); content = getRandomString(); @@ -290,17 +289,17 @@ public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { IFileStore Handler_java1 = model1.getChild("Handler.java"); content = getRandomString(); createFile(Handler_java1, content); - + //now, some contents in server folder IFileStore Server_java1 = server1.getChild("Server.java"); content = getRandomString(); createFile(Server_java1, content); - + //now, some contents in util folder IFileStore StringCompare_java1 = util1.getChild("StringCompare.java"); content = getRandomString(); createFile(StringCompare_java1, content); - + //now, copy META_INF into the folder in the remote system IRemoteFile META_INF_folder = localFss.getRemoteFileObject(tempPath + '\\' + tarSourceForOpenFolderName1, mon); assertNotNull(META_INF_folder); @@ -309,7 +308,7 @@ public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { fromSet.addResource(META_INF_folder); ISystemResourceSet tempObjects1 = srcAdapter1.doDrag(fromSet, mon); UniversalFileTransferUtility.uploadResourcesFromWorkspace((SystemWorkspaceResourceSet)tempObjects1, tempDir, mon, true); - + //now, copy org into the folder in the remote system IRemoteFile org_folder = localFss.getRemoteFileObject(tempPath + '\\' + tarSourceForOpenFolderName2, mon); assertNotNull(org_folder); @@ -318,31 +317,31 @@ public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { fromSet2.addResource(org_folder); ISystemResourceSet tempObjects2 = srcAdapter2.doDrag(fromSet2, mon); UniversalFileTransferUtility.uploadResourcesFromWorkspace((SystemWorkspaceResourceSet)tempObjects2, tempDir, mon, true); - + //now, create tar file in the host IRemoteFile tarSource = createFileOrFolder(tempDir.getAbsolutePath(), tarSourceForOpenTest, false); assertNotNull(tarSource); - IRemoteFile tarSourceFolder1 = (IRemoteFile)getChildFromFolder(tempDir, tarSourceForOpenFolderName1); + IRemoteFile tarSourceFolder1 = (IRemoteFile)getChildFromFolder(tempDir, tarSourceForOpenFolderName1); assertNotNull(tarSourceFolder1); IRemoteFile tarSourceFolder2 = (IRemoteFile)getChildFromFolder(tempDir, tarSourceForOpenFolderName2); fss.copy(tarSourceFolder1, tarSource, tarSourceForOpenFolderName1, mon); fss.copy(tarSourceFolder2, tarSource, tarSourceForOpenFolderName2, mon); - + //Then, we need to retrieve children of the tempDir to cache their information. fss.resolveFilterString(tempDir, null, mon); - + //Then, delete the temp folder in the junit workspace. temp.delete(EFS.NONE, mon); } - - - + + + public void createSourceTarFiles() throws Exception { String tempPath = getWorkspace().getRoot().getLocation().append("temp").toString(); IFileStore temp = createDir(tempPath, true); String content = getRandomString(); - + //Now, we need to construct a "source.tar" archive file //We will construct the content of the tar file in folders "META-INF" and "org" //Then we copy this folder into a tar file by RSE API. @@ -365,7 +364,7 @@ public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { createDir(core, true); IFileStore internal = dstore.getChild("internal"); createDir(internal, true); - + //now create directory inside "core": IFileStore client = core.getChild("client"); createDir(client, true); @@ -382,7 +381,7 @@ public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { IFileStore Activator_java = core.getChild("Activator.java"); content = getRandomString(); createFile(Activator_java, content); - + //now, some contents on client folder IFileStore ClientConnection_java = client.getChild("ClientConnection.java"); content = getRandomString(); @@ -390,12 +389,12 @@ public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { IFileStore ConnectionStatus_java = client.getChild("ConnectionStatus.java"); content = getRandomString(); createFile(ConnectionStatus_java, content); - + //now, some contents in java folder IFileStore ClassByteStreamHandler$ReceiveClassInstanceThread_java = java.getChild("ClassByteStreamHandler$ReceiveClassInstanceThread.java"); content = getRandomString(); createFile(ClassByteStreamHandler$ReceiveClassInstanceThread_java, content); - + //now, some contents in miners folder IFileStore Miner_java = miners.getChild("Miner.java"); content = getRandomString(); @@ -403,7 +402,7 @@ public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { IFileStore MinerThread_java = miners.getChild("MinerThread.java"); content = getRandomString(); createFile(MinerThread_java, content); - + //now, some contents in model folder IFileStore ByteStreamHandler_java = model.getChild("ByteStreamHandler.java"); content = getRandomString(); @@ -414,21 +413,21 @@ public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { IFileStore Handler_java = model.getChild("Handler.java"); content = getRandomString(); createFile(Handler_java, content); - + //now, some contents in server folder IFileStore Server_java = server.getChild("Server.java"); content = getRandomString(); createFile(Server_java, content); - + //now, some contents in util folder IFileStore StringCompare_java = util.getChild("StringCompare.java"); content = getRandomString(); createFile(StringCompare_java, content); - + //now, create the contents in "internal" folder IFileStore core1 = internal.getChild("core"); createDir(core1, true); - + //then create some folder in this "core" folder IFileStore client1 = core1.getChild("client"); createDir(client1, true); @@ -438,7 +437,7 @@ public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { createDir(server1, true); IFileStore util1 = core1.getChild("util"); createDir(util1, true); - + //now, some contents on client folder IFileStore ClientConnection_java1 = client1.getChild("ClientConnection.java"); content = getRandomString(); @@ -446,8 +445,8 @@ public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { IFileStore ConnectionStatus_java1 = client1.getChild("ConnectionStatus.java"); content = getRandomString(); createFile(ConnectionStatus_java1, content); - - + + //now, some contents in model folder IFileStore ByteStreamHandler_java1 = model1.getChild("ByteStreamHandler.java"); content = getRandomString(); @@ -458,17 +457,17 @@ public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { IFileStore Handler_java1 = model1.getChild("Handler.java"); content = getRandomString(); createFile(Handler_java1, content); - + //now, some contents in server folder IFileStore Server_java1 = server1.getChild("Server.java"); content = getRandomString(); createFile(Server_java1, content); - + //now, some contents in util folder IFileStore StringCompare_java1 = util1.getChild("StringCompare.java"); content = getRandomString(); createFile(StringCompare_java1, content); - + //now, copy META_INF into the folder in the remote system IRemoteFile META_INF_folder = localFss.getRemoteFileObject(tempPath + '\\' + tarSourceFolderName1, mon); assertNotNull(META_INF_folder); @@ -477,7 +476,7 @@ public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { fromSet.addResource(META_INF_folder); ISystemResourceSet tempObjects1 = srcAdapter1.doDrag(fromSet, mon); UniversalFileTransferUtility.uploadResourcesFromWorkspace((SystemWorkspaceResourceSet)tempObjects1, tempDir, mon, true); - + //now, copy org into the folder in the remote system IRemoteFile org_folder = localFss.getRemoteFileObject(tempPath + '\\' + tarSourceFolderName2, mon); assertNotNull(org_folder); @@ -486,21 +485,22 @@ public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { fromSet2.addResource(org_folder); ISystemResourceSet tempObjects2 = srcAdapter2.doDrag(fromSet2, mon); UniversalFileTransferUtility.uploadResourcesFromWorkspace((SystemWorkspaceResourceSet)tempObjects2, tempDir, mon, true); - + //now, create tar file in the host IRemoteFile tarSource = createFileOrFolder(tempDir.getAbsolutePath(), tarSourceFileName1, false); assertNotNull(tarSource); - IRemoteFile tarSourceFolder1 = (IRemoteFile)getChildFromFolder(tempDir, tarSourceFolderName1); + IRemoteFile tarSourceFolder1 = (IRemoteFile)getChildFromFolder(tempDir, tarSourceFolderName1); assertNotNull(tarSourceFolder1); IRemoteFile tarSourceFolder2 = (IRemoteFile)getChildFromFolder(tempDir, tarSourceFolderName2); fss.copy(tarSourceFolder1, tarSource, tarSourceFolderName1, mon); fss.copy(tarSourceFolder2, tarSource, tarSourceFolderName2, mon); } - + public void testCreateTarFile() throws Exception { //-test-author-:XuanChen - if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + //Create the zip file first. IRemoteFile newArchiveFile = createFileOrFolder(tempDirPath, testName, false); assertNotNull(newArchiveFile); @@ -509,73 +509,74 @@ public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { assertTrue(newArchiveFile.canWrite()); assertEquals(newArchiveFile.getName(), testName); assertEquals(newArchiveFile.getParentPath(), tempDirPath); - + //fss.resolveFilterString(filterString, monitor) - + //Now, we want to create a text file inside. String childName = "aaa.txt"; IRemoteFile file1 = createFileOrFolder(newArchiveFile.getAbsolutePath(), childName, false); assertNotNull(file1); - + childName = "bbb.txt"; IRemoteFile file2 = createFileOrFolder(newArchiveFile.getAbsolutePath(), childName, false); assertNotNull(file2); - + //Create a folder childName = "folder1"; IRemoteFile folder1 = createFileOrFolder(newArchiveFile.getAbsolutePath(), childName, true); assertNotNull(folder1); - + //Now, check the contents String[] namesToCheck = {"aaa.txt", "bbb.txt", "folder1"}; int[] typesToCheck = {TYPE_FILE, TYPE_FILE, TYPE_FOLDER}; checkFolderContents(newArchiveFile, namesToCheck, typesToCheck); - + //Now, create some files inside the folder. String secondLevelChildName = "ccc.exe"; IRemoteFile levelTwoChild1 = createFileOrFolder(folder1.getAbsolutePath(), secondLevelChildName, false); assertNotNull(levelTwoChild1); - + secondLevelChildName = "ddd.bat"; IRemoteFile levelTwoChild2 = createFileOrFolder(folder1.getAbsolutePath(), secondLevelChildName, false); assertNotNull(levelTwoChild2); - + secondLevelChildName = "another Folder"; //folder with space IRemoteFile levelTwoChild3 = createFileOrFolder(folder1.getAbsolutePath(), secondLevelChildName, true); assertNotNull(levelTwoChild3); - + //Now, check the contents String[] namesToCheck1 = {"ccc.exe", "ddd.bat", "another Folder"}; int[] typesToCheck1 = {TYPE_FILE, TYPE_FILE, TYPE_FOLDER}; checkFolderContents(folder1, namesToCheck1, typesToCheck1); } - + public void testCopyToTarArchiveFile() throws Exception { //-test-author-:XuanChen - if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + //create the source for testing first createSourceTarFiles(); createSourceFolders(); - + String tarTargetFileName = tarSourceFileName1; IRemoteFile targetTarFile = (IRemoteFile)getChildFromFolder(tempDir, tarTargetFileName); assertNotNull(targetTarFile); - + String sourceFolderName = folderToCopyName3; IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir, sourceFolderName); assertNotNull(sourceFolder); - + //Now, copy one of the folder from the sourceFolder into copiedTargetZipFile fss.copy(sourceFolder, targetTarFile, sourceFolder.getName(), mon); - + Object theCopiedChild = getChildFromFolder(targetTarFile, sourceFolderName); - + assertNotNull(theCopiedChild); - + //Also make sure the copied child has the right contents. String[] childrenToCheck = {"aaaaaaaa", "aaaab", "epdcdump01.hex12a", "RSE-SDK-2.0RC1.zip"}; - + int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FILE, TYPE_FILE}; checkFolderContents((IRemoteFile)theCopiedChild, childrenToCheck, typesToCheck); } @@ -584,29 +585,30 @@ public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { public void testCopyTarVirtualFile() throws Exception { //-test-author-:XuanChen - if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + //create the source for testing first createSourceTarFiles(); - + String sourceFileName = tarSourceFileName1; IRemoteFile sourceTarFile = (IRemoteFile)getChildFromFolder(tempDir, sourceFileName); assertNotNull(sourceTarFile); - + //then, create a folder inside the tempDir String folderName = "folder1"; IRemoteFile folder1 = createFileOrFolder(tempDirPath, folderName, true); assertNotNull(folder1); - + //Get one of its fourth level children, and copy the folder to there. IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(sourceTarFile, tarSourceFolderName1); assertNotNull(firstLevelChild); - + fss.copy(firstLevelChild, folder1, tarSourceFolderName1, mon); - + Object copiedVirtualFolder = getChildFromFolder(folder1, tarSourceFolderName1); assertNotNull(copiedVirtualFolder); - + String[] contents = {"MANIFEST.MF"}; int[] typesToCheck = {TYPE_FILE}; checkFolderContents((IRemoteFile)copiedVirtualFolder, contents, typesToCheck); @@ -615,32 +617,33 @@ public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { public void testMoveToTarArchiveFile() throws Exception { //-test-author-:XuanChen - if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + //create the source for testing first createSourceTarFiles(); createSourceFolders(); - + String tarTargetFileName = tarSourceFileName1; IRemoteFile targetTarFile = (IRemoteFile)getChildFromFolder(tempDir, tarTargetFileName); assertNotNull(targetTarFile); - + String sourceFolderName = folderToCopyName3; IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir, sourceFolderName); assertNotNull(sourceFolder); - + fss.move(sourceFolder, targetTarFile, sourceFolder.getName(), mon); - + Object theMovedChild = getChildFromFolder(targetTarFile, sourceFolderName); - + assertNotNull(theMovedChild); - + //Also make sure the copied child has the right contents. String[] childrenToCheck = {"aaaaaaaa", "aaaab", "epdcdump01.hex12a", "RSE-SDK-2.0RC1.zip"}; - + int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FILE, TYPE_FILE}; checkFolderContents((IRemoteFile)theMovedChild, childrenToCheck, typesToCheck); - + //make sure the original folder is gone. Object originalSource = getChildFromFolder(tempDir, sourceFolderName); assertNull(originalSource); @@ -650,35 +653,36 @@ public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { public void testMoveTarVirtualFile() throws Exception { //-test-author-:XuanChen - if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + //create the source for testing first createSourceTarFiles(); - + String sourceFileName = tarSourceFileName1; IRemoteFile sourceTarFile = (IRemoteFile)getChildFromFolder(tempDir, sourceFileName); assertNotNull(sourceTarFile); - + //then, create a folder inside the tempDir //then, create a folder inside the tempDir String folderName = "folder1"; IRemoteFile folder1 = createFileOrFolder(tempDirPath, folderName, true); assertNotNull(folder1); - + //Now, copy one of the folder from the zip file into folder1 String movedFolderName = tarSourceFolderName1; IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(sourceTarFile, tarSourceFolderName1); assertNotNull(firstLevelChild); fss.move(firstLevelChild, folder1, movedFolderName, mon); - + Object movedVirtualFolder = getChildFromFolder(folder1, movedFolderName); - + assertNotNull(movedVirtualFolder); - + String[] contents = {"MANIFEST.MF"}; int[] typesToCheck = {TYPE_FILE}; checkFolderContents((IRemoteFile)movedVirtualFolder, contents, typesToCheck); - + //Now, make sure the moved virtual folder is gone from its original zip file IRemoteFile tmp = (IRemoteFile)getChildFromFolder(sourceTarFile, tarSourceFolderName1); assertNull(tmp); @@ -687,59 +691,60 @@ public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { public void testRenameTarVirtualFile() throws Exception { //-test-author-:XuanChen - if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + //Create the zip file first. IRemoteFile newArchiveFile = createFileOrFolder(tempDirPath, testName, false); - + //Now, we want to create a text file inside. String childName = "aaa.txt"; IRemoteFile file1 = createFileOrFolder(newArchiveFile.getAbsolutePath(), childName, false); assertNotNull(file1); - + childName = "bbb.txt"; IRemoteFile file2 = createFileOrFolder(newArchiveFile.getAbsolutePath(), childName, false); assertNotNull(file2); - + //Create a folder childName = "folder1"; IRemoteFile folder1 = createFileOrFolder(newArchiveFile.getAbsolutePath(), childName, true); assertNotNull(folder1); - + //Now, check the contents String[] levelOneNamesToCheck = {"aaa.txt", "bbb.txt", "folder1"}; int[] levalOneTypesToCheck = {TYPE_FILE, TYPE_FILE, TYPE_FOLDER}; checkFolderContents(newArchiveFile, levelOneNamesToCheck, levalOneTypesToCheck); - + //Now, create some files inside the folder. String secondLevelChildName = "ccc.exe"; IRemoteFile levelTwoChild1 = createFileOrFolder(folder1.getAbsolutePath(), secondLevelChildName, false); assertNotNull(levelTwoChild1); - + secondLevelChildName = "ddd.bat"; IRemoteFile levelTwoChild2 = createFileOrFolder(folder1.getAbsolutePath(), secondLevelChildName, false); assertNotNull(levelTwoChild2); - + secondLevelChildName = "another Folder"; //folder with space IRemoteFile levelTwoChild3 = createFileOrFolder(folder1.getAbsolutePath(), secondLevelChildName, true); assertNotNull(levelTwoChild3); - + //Now, check the contents String[] levelTwoNamesToCheck = {"ccc.exe", "ddd.bat", "another Folder"}; int[] levalTwoTypesToCheck = {TYPE_FILE, TYPE_FILE, TYPE_FOLDER}; checkFolderContents(folder1, levelTwoNamesToCheck, levalTwoTypesToCheck); - + //Now rename one of the text file in the first level: IRemoteFile childToRename = (IRemoteFile)getChildFromFolder(newArchiveFile, "aaa.txt"); fss.rename(childToRename, "aaa1.txt", mon); //Now rename one of the folder in the first level childToRename = (IRemoteFile)getChildFromFolder(newArchiveFile, "folder1"); fss.rename(childToRename, "folder2", mon); - + //Check the result of rename String[] newLevelOneNamesToCheck = {"aaa1.txt", "bbb.txt", "folder2"}; checkFolderContents(newArchiveFile, newLevelOneNamesToCheck, levalOneTypesToCheck); - + //Now rename one of the text file in the second level: IRemoteFile thisFolder = (IRemoteFile)getChildFromFolder(newArchiveFile, "folder2"); childToRename = (IRemoteFile)getChildFromFolder(thisFolder, "ddd.bat"); @@ -747,7 +752,7 @@ public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { //Now rename one of the folder in the second level childToRename = (IRemoteFile)getChildFromFolder(thisFolder, "another Folder"); fss.rename(childToRename, "some folder$", mon); - + //Check the result of rename String[] newLevelTwoNamesToCheck = {"ccc.exe", "ddd1.bat", "some folder$"}; checkFolderContents(thisFolder, newLevelTwoNamesToCheck, levalTwoTypesToCheck); @@ -755,15 +760,16 @@ public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { public void testDeleteTarVirtualFile() throws Exception { //-test-author-:XuanChen - if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + //create the source for testing first createSourceTarFiles(); - + String sourceFileName = tarSourceFileName1; IRemoteFile sourceTarFile = (IRemoteFile)getChildFromFolder(tempDir, sourceFileName); assertNotNull(sourceTarFile); - + //delete a file from level 2 String parentForFileToDeleteName ="META-INF"; IRemoteFile parentForFileToDelete = (IRemoteFile)getChildFromFolder(sourceTarFile, parentForFileToDeleteName); @@ -775,50 +781,50 @@ public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { fss.delete(fileToToDelete, mon); fileToToDelete = (IRemoteFile)getChildFromFolder(parentForFileToDelete, deleteFileName); assertNull(fileToToDelete); - + //then, get directory "java" under org/eclipse/dstore/core String parentForDirectoryToDeleteName ="org"; IRemoteFile parentForDirectoryToDelete = (IRemoteFile)getChildFromFolder(sourceTarFile, parentForDirectoryToDeleteName); assertNotNull(parentForDirectoryToDelete); - + parentForDirectoryToDeleteName ="eclipse"; parentForDirectoryToDelete = (IRemoteFile)getChildFromFolder(parentForDirectoryToDelete, parentForDirectoryToDeleteName); assertNotNull(parentForDirectoryToDelete); - + parentForDirectoryToDeleteName ="dstore"; parentForDirectoryToDelete = (IRemoteFile)getChildFromFolder(parentForDirectoryToDelete, parentForDirectoryToDeleteName); assertNotNull(parentForDirectoryToDelete); - + parentForDirectoryToDeleteName ="core"; parentForDirectoryToDelete = (IRemoteFile)getChildFromFolder(parentForDirectoryToDelete, parentForDirectoryToDeleteName); assertNotNull(parentForDirectoryToDelete); - + String directoryToDeleteName = "java"; IRemoteFile directoryToDelete = (IRemoteFile)getChildFromFolder(parentForDirectoryToDelete, directoryToDeleteName); //Now, delete this directory fss.delete(directoryToDelete, mon); directoryToDelete = (IRemoteFile)getChildFromFolder(parentForDirectoryToDelete, directoryToDeleteName); - + //check result of this operation String[] contents = {"client", "miners", "model", "server", "util", "Activator.java"}; int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FOLDER, TYPE_FOLDER, TYPE_FOLDER, TYPE_FILE}; checkFolderContents(parentForDirectoryToDelete, contents, typesToCheck); - + //And check this directory is not there any more. directoryToDelete = (IRemoteFile)getChildFromFolder(parentForDirectoryToDelete, directoryToDeleteName); assertNull(directoryToDelete); - + //Now, delete some files and folder inside the a virtual folder. parentForFileToDelete = (IRemoteFile)getChildFromFolder(parentForDirectoryToDelete, "model"); deleteFileName = "DE.java"; fileToToDelete = (IRemoteFile)getChildFromFolder(parentForFileToDelete, deleteFileName); assertNotNull(fileToToDelete); - + fss.delete(fileToToDelete, mon); - + //check the result fileToToDelete = (IRemoteFile)getChildFromFolder(parentForFileToDelete, deleteFileName); - + assertNull(fileToToDelete); } @@ -826,20 +832,21 @@ public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { public void testCopyBatchToTarArchiveFile() throws Exception { //-test-author-:XuanChen - if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + createSourceTarFiles(); createSourceFolders(); - + String tarTargetFileName = tarSourceFileName1; IRemoteFile targetTarFile = (IRemoteFile)getChildFromFolder(tempDir, tarTargetFileName); assertNotNull(targetTarFile); - + //Now, copy the source folder. String sourceFolderName = folderToCopyName3; IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir,sourceFolderName); assertNotNull(sourceFolder); - + //Now, copy one of the folder from the sourceFolder into copiedTargetZipFile IRemoteFile[] sourceFiles = new IRemoteFile[3]; //Also add some of its children into the batch. @@ -850,29 +857,29 @@ public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { String childToCopyName3 = "epdcdump01.hex12a"; sourceFiles[2] = (IRemoteFile)getChildFromFolder(sourceFolder, childToCopyName3); fss.copyBatch(sourceFiles, targetTarFile, mon); - + //Checking the first copied folder Object theCopiedChild = getChildFromFolder(targetTarFile, childToCopyName1); - + assertNotNull(theCopiedChild); - + //Also make sure the copied child has the right contents. String[] childrenToCheck1 = {"adsf", "eclipse-SDK-3.3M6-win32.zip", "epdcdump01.hex12", "epdcdump01.hex12aaaa"}; - + int[] typesToCheck1 = {TYPE_FILE, TYPE_FILE, TYPE_FILE, TYPE_FILE}; checkFolderContents((IRemoteFile)theCopiedChild, childrenToCheck1, typesToCheck1); - + //Checking the second copied folder theCopiedChild = getChildFromFolder(targetTarFile, childToCopyName2); - + assertNotNull(theCopiedChild); - + //Also make sure the copied child has the right contents. String[] childrenToCheck2 = {"features"}; - + int[] typesToCheck2 = {TYPE_FOLDER}; checkFolderContents((IRemoteFile)theCopiedChild, childrenToCheck2, typesToCheck2); - + //Checking the third copied file theCopiedChild = getChildFromFolder(targetTarFile, childToCopyName3); assertNotNull(theCopiedChild); @@ -883,40 +890,41 @@ public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { public void testOpenFileFromTarArchive() throws Exception { - if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + //create the source for testing first createTarSourceForOpen(); - + String tarTargetFileName = tarSourceForOpenTest; IRemoteFile targetTarFile = (IRemoteFile)getChildFromFolder(tempDir, tarTargetFileName); assertNotNull(targetTarFile); - + //Now get the contents of the virtual file we want to download: String fileContentToVerifyName1 = "MANIFEST.MF"; - + //Get its parent first. IRemoteFile itsParentFolder = (IRemoteFile)getChildFromFolder(tempDir,tarSourceForOpenFolderName1); assertNotNull(itsParentFolder); - + //Then get this file: IRemoteFile thisVirtualFile = (IRemoteFile)getChildFromFolder(itsParentFolder, fileContentToVerifyName1); assertNotNull(thisVirtualFile); - + //Now, we want to download the content of this file //We could just construct a dummy localpath for it. String tempPath = getWorkspace().getRoot().getLocation().append("temp").toString(); IFileStore temp = createDir(tempPath, true); String localPath = tempPath + File.separator + fileContentToVerifyName1; fss.download(thisVirtualFile, localPath, thisVirtualFile.getEncoding(), mon); - + //now, verify the content of the local file IFileStore localFile = temp.getChild(fileContentToVerifyName1); //Check the content of the download file: boolean sameContent = compareContent(getContents(fileContentString1), localFile.openInputStream(EFS.NONE, null)); assertTrue(sameContent); - - + + //now, we got the contents of another virtual file we want to download: String fileContentToVerifyName2 = "Activator.java"; itsParentFolder = (IRemoteFile)getChildFromFolder(tempDir,tarSourceForOpenFolderName2); @@ -931,14 +939,14 @@ public abstract class FileServiceArchiveBaseTest extends FileServiceBaseTest { assertNotNull(thisVirtualFile); localPath = tempPath + File.separator + fileContentToVerifyName2; fss.download(thisVirtualFile, localPath, thisVirtualFile.getEncoding(), mon); - + //now, verify the content of the local file localFile = temp.getChild(fileContentToVerifyName2); //Check the content of the download file: sameContent = compareContent(getContents(fileContentString1), localFile.openInputStream(EFS.NONE, null)); assertTrue(sameContent); } - + diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileServiceArchiveTest.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileServiceArchiveTest.java index 582831943e9..64e27794fe7 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileServiceArchiveTest.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileServiceArchiveTest.java @@ -24,14 +24,13 @@ import org.eclipse.rse.core.subsystems.ISystemDragDropAdapter; import org.eclipse.rse.files.ui.resources.UniversalFileTransferUtility; import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; -import org.eclipse.rse.tests.RSETestsPlugin; public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { - + protected String zipSourceFileName1 = "closedBefore.zip"; protected String zipSourceFileName2 = "mynewzip.zip"; - + protected String ZIP_SOURCE_DIR = ""; protected String TEST_DIR = ""; protected String SYSTEM_TYPE_ID = IRSESystemType.SYSTEMTYPE_LOCAL_ID; @@ -51,7 +50,7 @@ public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { tarSourceForOpenTest = "tarSourceForOpen.tar"; testName = "dummy.tar"; } - + public void createSourceZipFiles() throws Exception { createSourceZipFiles(fss); @@ -62,7 +61,7 @@ public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { String tempPath = getWorkspace().getRoot().getLocation().append("temp").toString(); IFileStore temp = createDir(tempPath, true); String content = getRandomString(); - + //Now, we need to construct a "closeBefore.zip" archive file //We will construct the content of the zip file in folder "RemoteSystemsConnections" //Then we copy this folder into a zip file by RSE API. @@ -91,12 +90,12 @@ public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { IFileStore filter_pool1_xml = filter_pool1.getChild("filterPool_Team Filter Pool.xmi"); content = getRandomString(); createFile(filter_pool1_xml, content); - + IFileStore ibm_cmdsIFS = Filters.getChild("ibm.cmdsIFS"); createDir(ibm_cmdsIFS, true); IFileStore ibm_cmdsLocal = Filters.getChild("ibm.cmdsLocal"); createDir(ibm_cmdsLocal, true); - + IFileStore ibm_files = Filters.getChild("ibm.files"); createDir(ibm_files, true); //create another directory inside this one @@ -106,7 +105,7 @@ public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { IFileStore filter_pool2_xml = filter_pool2.getChild("filterPool_Team Filter Pool.xmi"); content = getRandomString(); createFile(filter_pool2_xml, content); - + IFileStore ibm_files_aix = Filters.getChild("ibm.files.aix"); createDir(ibm_files_aix, true); //create another directory inside this one @@ -116,7 +115,7 @@ public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { IFileStore filter_pool3_xml = filter_pool3.getChild("filterPool_Team Filter Pool.xmi"); content = getRandomString(); createFile(filter_pool3_xml, content); - + IFileStore ibm_iles_powerlinux = Filters.getChild("ibm.files.powerlinux"); createDir(ibm_iles_powerlinux, true); //create another directory inside this one @@ -126,7 +125,7 @@ public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { IFileStore filter_pool4_xml = filter_pool4.getChild("filterPool_Team Filter Pool.xmi"); content = getRandomString(); createFile(filter_pool4_xml, content); - + IFileStore ibm_files400 = Filters.getChild("ibm.files400"); createDir(ibm_files400, true); //create another directory inside this one @@ -136,7 +135,7 @@ public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { IFileStore filter_pool5_xml = filter_pool5.getChild("filterPool_Team Filter Pool.xmi"); content = getRandomString(); createFile(filter_pool5_xml, content); - + IFileStore ibm_filesLocal = Filters.getChild("ibm.filesLocal"); createDir(ibm_filesLocal, true); //create another directory inside this one @@ -146,7 +145,7 @@ public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { IFileStore filter_pool6_xml = filter_pool6.getChild("filterPool_Team Filter Pool.xmi"); content = getRandomString(); createFile(filter_pool6_xml, content); - + IFileStore ibm_filesIFS = Filters.getChild("ibm.filesIFS"); createDir(ibm_filesIFS, true); //create another directory inside this one @@ -156,7 +155,7 @@ public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { IFileStore filter_pool7_xml = filter_pool7.getChild("filterPool_Team Filter Pool.xmi"); content = getRandomString(); createFile(filter_pool7_xml, content); - + IFileStore ibm_filesWindows = Filters.getChild("ibm.filesWindows"); createDir(ibm_filesWindows, true); //create another directory inside this one @@ -166,7 +165,7 @@ public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { IFileStore filter_pool8_xml = filter_pool8.getChild("filterPool_Team Filter Pool.xmi"); content = getRandomString(); createFile(filter_pool8_xml, content); - + IFileStore ibm_jobs400 = Filters.getChild("ibm.jobs400"); createDir(ibm_jobs400, true); //create another directory inside this one @@ -176,12 +175,12 @@ public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { IFileStore filter_pool9_xml = filter_pool9.getChild("filterPool_Team Filter Pool.xmi"); content = getRandomString(); createFile(filter_pool9_xml, content); - + //create file inside the Team folder. IFileStore profile_xml = Team.getChild("profile.xmi"); content = getRandomString(); createFile(profile_xml, content); - + //Now create another folder TypeFilters in the RemoteSystemsConnections folder IFileStore TypeFilters = RemoteSystemsConnections.getChild("TypeFilters"); createDir(TypeFilters, true); @@ -211,7 +210,7 @@ public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { createFile(compatibility, content); IFileStore project = RemoteSystemsConnections.getChild(".project"); createFile(project, content); - + //Now, we need to create the content of mynewzip.zip file IFileStore folder_6YLT5Xa = temp.getChild(folderToCopyName2); createDir(folder_6YLT5Xa, true); @@ -246,11 +245,11 @@ public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { IFileStore epdcdump01_hex12ab = dummyFolder.getChild("epdcdump01.hex12ab"); content = getRandomString(); createFile(epdcdump01_hex12ab, content); - + IRemoteFile targetDir = null; if (inputFss != fss) { - //Create the tempDir inside the inputFss + //Create the tempDir inside the inputFss try { IRemoteFile homeDirectory = inputFss.getRemoteFileObject(".", mon); @@ -275,39 +274,40 @@ public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { fromSet.addResource(sourceFolderToCopy1); ISystemResourceSet tempObjects1 = srcAdapter1.doDrag(fromSet, mon); UniversalFileTransferUtility.uploadResourcesFromWorkspace((SystemWorkspaceResourceSet)tempObjects1, targetDir, mon, true); - + IRemoteFile sourceFolderToCopy2 = localFss.getRemoteFileObject(tempPath + '\\' + folderToCopyName2, mon); ISystemDragDropAdapter srcAdapter2 = (ISystemDragDropAdapter) ((IAdaptable) sourceFolderToCopy2).getAdapter(ISystemDragDropAdapter.class); SystemRemoteResourceSet fromSet2 = new SystemRemoteResourceSet(localFss, srcAdapter2); fromSet2.addResource(sourceFolderToCopy2); ISystemResourceSet tempObjects2 = srcAdapter2.doDrag(fromSet2, mon); UniversalFileTransferUtility.uploadResourcesFromWorkspace((SystemWorkspaceResourceSet)tempObjects2, targetDir, mon, true); - + IRemoteFile zipSource1 = createFileOrFolder(inputFss, targetDir.getAbsolutePath(), zipSourceFileName1, false); assertNotNull(zipSource1); IRemoteFile zipSourceFolder = (IRemoteFile)getChildFromFolder(inputFss, targetDir, folderToCopyName1); inputFss.copy(zipSourceFolder, zipSource1, folderToCopyName1, mon); - + IRemoteFile zipSource2 = createFileOrFolder(inputFss, targetDir.getAbsolutePath(), zipSourceFileName2, false); assertNotNull(zipSource2); IRemoteFile zipSourceFolder2 = (IRemoteFile)getChildFromFolder(inputFss, targetDir, folderToCopyName2); inputFss.copy(zipSourceFolder2, zipSource2, folderToCopyName2, mon); - + //Then, we need to retrieve children of the tempDir to cache their information. inputFss.resolveFilterString(targetDir, null, mon); - + //Then, delete the temp folder in the junit workspace. temp.delete(EFS.NONE, mon); - + return targetDir; } - - + + public void testCreateZipFile() throws Exception { //-test-author-:XuanChen - if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + //Create the zip file first. String testName = "dummy.zip"; IRemoteFile newArchiveFile = createFileOrFolder(tempDirPath, testName, false); @@ -316,106 +316,107 @@ public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { assertTrue(newArchiveFile.canRead()); assertTrue(newArchiveFile.canWrite()); assertEquals(newArchiveFile.getName(), testName); - + //fss.resolveFilterString(filterString, monitor) - + //Now, we want to create a text file inside. String childName = "aaa.txt"; IRemoteFile file1 = createFileOrFolder(newArchiveFile.getAbsolutePath(), childName, false); assertNotNull(file1); - + childName = "bbb.txt"; IRemoteFile file2 = createFileOrFolder(newArchiveFile.getAbsolutePath(), childName, false); assertNotNull(file2); - + //Create a folder childName = "folder1"; IRemoteFile folder1 = createFileOrFolder(newArchiveFile.getAbsolutePath(), childName, true); assertNotNull(folder1); - + //Now, check the contents String[] namesToCheck = {"aaa.txt", "bbb.txt", "folder1"}; int[] typesToCheck = {TYPE_FILE, TYPE_FILE, TYPE_FOLDER}; checkFolderContents(newArchiveFile, namesToCheck, typesToCheck); - + //Now, create some files inside the folder. String secondLevelChildName = "ccc.exe"; IRemoteFile levelTwoChild1 = createFileOrFolder(folder1.getAbsolutePath(), secondLevelChildName, false); assertNotNull(levelTwoChild1); - + secondLevelChildName = "ddd.bat"; IRemoteFile levelTwoChild2 = createFileOrFolder(folder1.getAbsolutePath(), secondLevelChildName, false); assertNotNull(levelTwoChild2); - + secondLevelChildName = "another Folder"; //folder with space IRemoteFile levelTwoChild3 = createFileOrFolder(folder1.getAbsolutePath(), secondLevelChildName, true); assertNotNull(levelTwoChild3); - + //Now, check the contents String[] namesToCheck1 = {"ccc.exe", "ddd.bat", "another Folder"}; int[] typesToCheck1 = {TYPE_FILE, TYPE_FILE, TYPE_FOLDER}; checkFolderContents(folder1, namesToCheck1, typesToCheck1); - + return; - + } - + public void testRenameVirtualFile() throws Exception { //-test-author-:XuanChen - if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + //Create the zip file first. String testName = "dummy.zip"; IRemoteFile newArchiveFile = createFileOrFolder(tempDirPath, testName, false); - + //Now, we want to create a text file inside. String childName = "aaa.txt"; IRemoteFile file1 = createFileOrFolder(newArchiveFile.getAbsolutePath(), childName, false); assertNotNull(file1); - + childName = "bbb.txt"; IRemoteFile file2 = createFileOrFolder(newArchiveFile.getAbsolutePath(), childName, false); assertNotNull(file2); - + //Create a folder childName = "folder1"; IRemoteFile folder1 = createFileOrFolder(newArchiveFile.getAbsolutePath(), childName, true); assertNotNull(folder1); - + //Now, check the contents String[] levelOneNamesToCheck = {"aaa.txt", "bbb.txt", "folder1"}; int[] levalOneTypesToCheck = {TYPE_FILE, TYPE_FILE, TYPE_FOLDER}; checkFolderContents(newArchiveFile, levelOneNamesToCheck, levalOneTypesToCheck); - + //Now, create some files inside the folder. String secondLevelChildName = "ccc.exe"; IRemoteFile levelTwoChild1 = createFileOrFolder(folder1.getAbsolutePath(), secondLevelChildName, false); assertNotNull(levelTwoChild1); - + secondLevelChildName = "ddd.bat"; IRemoteFile levelTwoChild2 = createFileOrFolder(folder1.getAbsolutePath(), secondLevelChildName, false); assertNotNull(levelTwoChild2); - + secondLevelChildName = "another Folder"; //folder with space IRemoteFile levelTwoChild3 = createFileOrFolder(folder1.getAbsolutePath(), secondLevelChildName, true); assertNotNull(levelTwoChild3); - + //Now, check the contents String[] levelTwoNamesToCheck = {"ccc.exe", "ddd.bat", "another Folder"}; int[] levalTwoTypesToCheck = {TYPE_FILE, TYPE_FILE, TYPE_FOLDER}; checkFolderContents(folder1, levelTwoNamesToCheck, levalTwoTypesToCheck); - + //Now rename one of the text file in the first level: IRemoteFile childToRename = (IRemoteFile)getChildFromFolder(newArchiveFile, "aaa.txt"); fss.rename(childToRename, "aaa1.txt", mon); //Now rename one of the folder in the first level childToRename = (IRemoteFile)getChildFromFolder(newArchiveFile, "folder1"); fss.rename(childToRename, "folder2", mon); - + //Check the result of rename String[] newLevelOneNamesToCheck = {"aaa1.txt", "bbb.txt", "folder2"}; checkFolderContents(newArchiveFile, newLevelOneNamesToCheck, levalOneTypesToCheck); - + //Now rename one of the text file in the second level: IRemoteFile thisFolder = (IRemoteFile)getChildFromFolder(newArchiveFile, "folder2"); childToRename = (IRemoteFile)getChildFromFolder(thisFolder, "ddd.bat"); @@ -423,366 +424,377 @@ public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { //Now rename one of the folder in the second level childToRename = (IRemoteFile)getChildFromFolder(thisFolder, "another Folder"); fss.rename(childToRename, "some folder$", mon); - + //Check the result of rename String[] newLevelTwoNamesToCheck = {"ccc.exe", "ddd1.bat", "some folder$"}; checkFolderContents(thisFolder, newLevelTwoNamesToCheck, levalTwoTypesToCheck); - + return; - + } - + public void testMoveVirtualFile() throws Exception { //-test-author-:XuanChen - if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + //Create the source data needed for testing createSourceZipFiles(); - + //then, create a folder inside the tempDir String folderName = "folder1"; IRemoteFile folder1 = createFileOrFolder(tempDirPath, folderName, true); assertNotNull(folder1); - + String sourceZipFileName = zipSourceFileName1; IRemoteFile sourceZipFile = (IRemoteFile)getChildFromFolder(tempDir, sourceZipFileName); - + //Now, copy one of the folder from the zip file into folder1 Object[] children = fss.resolveFilterString(sourceZipFile, null, mon); IRemoteFile originalVirtualFolder = (IRemoteFile)children[0]; String movedFolderName = originalVirtualFolder.getName(); fss.move(originalVirtualFolder, folder1, movedFolderName, mon); - - + + Object movedVirtualFolder = getChildFromFolder(folder1, movedFolderName); - + assertNotNull(movedVirtualFolder); - + String[] contents = {"Team", "TypeFilters", "xuanchentp", ".compatibility", ".project"}; int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FOLDER, TYPE_FILE, TYPE_FILE}; checkFolderContents((IRemoteFile)movedVirtualFolder, contents, typesToCheck); - + //Now, make sure the moved virtual folder is gone from its original zip file children = fss.resolveFilterString(sourceZipFile, null, mon); assertTrue(children.length == 0); } - + public void testMoveVirtualFileLevelTwo() throws Exception { //-test-author-:XuanChen - if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + createSourceZipFiles(); - + //then, create a folder inside the tempDir String folderName = "folder1"; IRemoteFile folder1 = createFileOrFolder(tempDirPath, folderName, true); assertNotNull(folder1); - + String sourceZipFileName = zipSourceFileName1; IRemoteFile sourceZipFile = (IRemoteFile)getChildFromFolder(tempDir, sourceZipFileName); assertNotNull(sourceZipFile); - + //Now, move one of the level two folder from the zip file into folder1 IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(sourceZipFile, folderToCopyName1); IRemoteFile secondLevelChild = (IRemoteFile)getChildFromFolder(firstLevelChild, "Team"); String movedFolderName = secondLevelChild.getName(); - + //copy this level two childer into folder1 fss.move(secondLevelChild, folder1, movedFolderName, mon); - + Object movedVirtualFolder = getChildFromFolder(folder1, movedFolderName); - + assertNotNull(movedVirtualFolder); - + String[] contents = {"Connections", "Filters", "profile.xmi"}; int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FILE}; checkFolderContents((IRemoteFile)movedVirtualFolder, contents, typesToCheck); - + //Now, make sure the moved virtual folder is gone from its original zip file Object originalVirtualFolder = getChildFromFolder(firstLevelChild, movedFolderName); - + assertNull(originalVirtualFolder); //we should not be able to find it. } - + public void testMoveToArchiveFile() throws Exception { //-test-author-:XuanChen - if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + createSourceZipFiles(); createSourceFolders(); - + String targetZipFileName = zipSourceFileName1; IRemoteFile targetZipFile = (IRemoteFile)getChildFromFolder(tempDir, targetZipFileName); assertNotNull(targetZipFile); - + String sourceFolderName = folderToCopyName3; IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir, sourceFolderName); assertNotNull(sourceFolder); - + //Now, move one of the folder from the sourceFolder into copiedTargetZipFile fss.move(sourceFolder, targetZipFile, sourceFolder.getName(), mon); - + Object theMovedChild = getChildFromFolder(targetZipFile, sourceFolderName); assertNotNull(theMovedChild); - + //Also make sure the copied child has the right contents. String[] childrenToCheck = {"aaaaaaaa", "aaaab", "epdcdump01.hex12a", "RSE-SDK-2.0RC1.zip"}; - + int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FILE, TYPE_FILE}; checkFolderContents((IRemoteFile)theMovedChild, childrenToCheck, typesToCheck); - + //make sure the original folder is gone. //make sure the original folder is gone. IRemoteFile tempDirRemoteFile = fss.getRemoteFileObject(tempDirPath, mon); Object originalSource = getChildFromFolder(tempDirRemoteFile, sourceFolderName); assertNull(originalSource); } - + public void testMoveToVirtualFileLevelOne() throws Exception { //-test-author-:XuanChen - if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + createSourceZipFiles(); createSourceFolders(); - + String targetZipFileName = zipSourceFileName1; IRemoteFile targetZipFile = (IRemoteFile)getChildFromFolder(tempDir, targetZipFileName); assertNotNull(targetZipFile); - + String sourceFolderName = folderToCopyName3; IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir, sourceFolderName); assertNotNull(sourceFolder); - + //Now, move one of the folder from the sourceFolder into a first level virtual file in targetZipFile //Get one of its first level children, and move the folder to there. IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(targetZipFile, folderToCopyName1); - + fss.move(sourceFolder, firstLevelChild, sourceFolderName, mon); - + Object theMovedChild = getChildFromFolder(firstLevelChild, sourceFolderName); - + assertNotNull(theMovedChild); - + //Also make sure the copied child has the right contents. String[] childrenToCheck = {"aaaaaaaa", "aaaab", "epdcdump01.hex12a", "RSE-SDK-2.0RC1.zip"}; int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FILE, TYPE_FILE}; checkFolderContents((IRemoteFile)theMovedChild, childrenToCheck, typesToCheck); - + //make sure the original folder is gone. IRemoteFile tempDirRemoteFile = fss.getRemoteFileObject(tempDirPath, mon); Object originalSource = getChildFromFolder(tempDirRemoteFile, sourceFolderName); assertNull(originalSource); } - + public void testMoveToVirtualFileLevelTwo() throws Exception { //-test-author-:XuanChen - if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + createSourceZipFiles(); createSourceFolders(); - + String targetZipFileName = zipSourceFileName1; IRemoteFile targetZipFile = (IRemoteFile)getChildFromFolder(tempDir, targetZipFileName); assertTrue(targetZipFile != null); - + String sourceFolderName = folderToCopyName3; IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir, sourceFolderName); assertTrue(sourceFolder != null); - + //Get one of its second level children, and move the folder to there. IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(targetZipFile, folderToCopyName1); IRemoteFile secondLevelChild = (IRemoteFile)getChildFromFolder(firstLevelChild, "Team"); - + fss.move(sourceFolder, secondLevelChild, sourceFolder.getName(), mon); - + Object theMovedChild = getChildFromFolder(secondLevelChild, sourceFolderName); - + assertNotNull(theMovedChild); - + //Also make sure the copied child has the right contents. String[] childrenToCheck = {"aaaaaaaa", "aaaab", "epdcdump01.hex12a", "RSE-SDK-2.0RC1.zip"}; int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FILE, TYPE_FILE}; checkFolderContents((IRemoteFile)theMovedChild, childrenToCheck, typesToCheck); - + //make sure the original folder is gone. IRemoteFile tempDirRemoteFile = fss.getRemoteFileObject(tempDirPath, mon); Object originalSource = getChildFromFolder(tempDirRemoteFile, sourceFolderName); assertNull(originalSource); } - - + + public void testCopyVirtualFile() throws Exception { //-test-author-:XuanChen - if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + createSourceZipFiles(); - + String sourceZipFileName = zipSourceFileName1; IRemoteFile sourceZipFile = (IRemoteFile)getChildFromFolder(tempDir, sourceZipFileName); assertNotNull(sourceZipFile); - + //then, create a folder inside the tempDir String folderName = "folder1"; IRemoteFile folder1 = createFileOrFolder(tempDirPath, folderName, true); assertNotNull(folder1); - + //Now, copy one of the folder from the zip file into folder1 IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(sourceZipFile, folderToCopyName1); fss.copy(firstLevelChild, folder1, folderToCopyName1, mon); - + Object copiedVirtualFolder = getChildFromFolder(folder1, folderToCopyName1); - + assertNotNull(copiedVirtualFolder); - + String[] contents = {"Team", "TypeFilters", "xuanchentp", ".compatibility", ".project"}; int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FOLDER, TYPE_FILE, TYPE_FILE}; checkFolderContents((IRemoteFile)copiedVirtualFolder, contents, typesToCheck); } - + public void testCopyVirtualFileLevelTwo() throws Exception { //-test-author-:XuanChen - if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + createSourceZipFiles(); - + //copy the zip file first. String sourceZipFileName = zipSourceFileName1; IRemoteFile sourceZipFile = (IRemoteFile)getChildFromFolder(tempDir, sourceZipFileName); assertNotNull(sourceZipFile); - + //then, create a folder inside the tempDir String folderName = "folder1"; IRemoteFile folder1 = createFileOrFolder(tempDirPath, folderName, true); assertNotNull(folder1); - + //Now, copy one of the level two folder from the zip file into folder1 IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(sourceZipFile, folderToCopyName1); IRemoteFile secondLevelChild = (IRemoteFile)getChildFromFolder(firstLevelChild, "Team"); //copy this level two children into folder1 fss.copy(secondLevelChild, folder1, secondLevelChild.getName(), mon); - + Object copiedVirtualFolder = getChildFromFolder(folder1, secondLevelChild.getName()); - + assertNotNull(copiedVirtualFolder); - + String[] contents = {"Connections", "Filters", "profile.xmi"}; int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FILE}; checkFolderContents((IRemoteFile)copiedVirtualFolder, contents, typesToCheck); } - - + + public void testCopyToArchiveFile() throws Exception { //-test-author-:XuanChen - if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + createSourceZipFiles(); createSourceFolders(); - + String targetZipFileName = zipSourceFileName1; IRemoteFile targetZipFile = (IRemoteFile)getChildFromFolder(tempDir, targetZipFileName); assertNotNull(targetZipFile); - + String sourceFolderName = folderToCopyName3; IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir, sourceFolderName); assertNotNull(sourceFolder); - + //Now, copy one of the folder from the sourceFolder into copiedTargetZipFile fss.copy(sourceFolder, targetZipFile, sourceFolder.getName(), mon); - + Object theCopiedChild = getChildFromFolder(targetZipFile, sourceFolderName); - + assertNotNull(theCopiedChild); - + //Also make sure the copied child has the right contents. String[] childrenToCheck = {"aaaaaaaa", "aaaab", "epdcdump01.hex12a", "RSE-SDK-2.0RC1.zip"}; - + int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FILE, TYPE_FILE}; checkFolderContents((IRemoteFile)theCopiedChild, childrenToCheck, typesToCheck); } - - - + + + public void testCopyToVirtualFileLevelOne() throws Exception { //-test-author-:XuanChen - if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + createSourceZipFiles(); createSourceFolders(); - - String targetZipFileName = zipSourceFileName1; + + String targetZipFileName = zipSourceFileName1; IRemoteFile targetZipFile = (IRemoteFile)getChildFromFolder(tempDir, targetZipFileName); assertNotNull(targetZipFile); - + String sourceFolderName = folderToCopyName3; IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir, sourceFolderName); assertNotNull(sourceFolder); - + //Now, copy one of the folder from the sourceFolder into a first level virtual file in targetZipFile //Get one of its first level children, and copy the folder to there. //Now, copy one of the level two folder from the zip file into folder1 IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(targetZipFile, folderToCopyName1); - + fss.copy(sourceFolder, firstLevelChild, sourceFolder.getName(), mon); - + Object theCopiedChild = getChildFromFolder(firstLevelChild, sourceFolderName); - + assertNotNull(theCopiedChild); - + //Also make sure the copied child has the right contents. String[] childrenToCheck = {"aaaaaaaa", "aaaab", "epdcdump01.hex12a", "RSE-SDK-2.0RC1.zip"}; int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FILE, TYPE_FILE}; checkFolderContents((IRemoteFile)theCopiedChild, childrenToCheck, typesToCheck); } - + public void testCopyToVirtualFileLevelTwo() throws Exception { //-test-author-:XuanChen - if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + createSourceZipFiles(); createSourceFolders(); - + String zipTargetFileName = zipSourceFileName1; IRemoteFile targetZipFile = (IRemoteFile)getChildFromFolder(tempDir, zipTargetFileName); assertNotNull(targetZipFile); - + String sourceFolderName = folderToCopyName3; IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir, folderToCopyName3); assertNotNull(sourceFolder); - + //Get one of its second level children, and copy the folder to there. //Now, copy one of the level two folder from the zip file into folder1 IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(targetZipFile, folderToCopyName1); IRemoteFile secondLevelChild = (IRemoteFile)getChildFromFolder(firstLevelChild, "TypeFilters"); - + fss.copy(sourceFolder, secondLevelChild, sourceFolder.getName(), mon); - + Object theCopiedChild = getChildFromFolder(secondLevelChild, sourceFolderName); - + assertNotNull(theCopiedChild); - + //Also make sure the copied child has the right contents. String[] childrenToCheck = {"aaaaaaaa", "aaaab", "epdcdump01.hex12a", "RSE-SDK-2.0RC1.zip"}; int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FILE, TYPE_FILE}; checkFolderContents((IRemoteFile)theCopiedChild, childrenToCheck, typesToCheck); } - + public void testCopyBatchToArchiveFile() throws Exception { //-test-author-:XuanChen - if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + createSourceZipFiles(); createSourceFolders(); - + String zipTargetFileName = zipSourceFileName1; IRemoteFile targetZipFile = (IRemoteFile)getChildFromFolder(tempDir,zipTargetFileName); assertNotNull(targetZipFile); - + //Now, copy the source folder. String sourceFolderName = folderToCopyName3; IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir,sourceFolderName); assertNotNull(sourceFolder); - + //Now, copy one of the folder from the sourceFolder into copiedTargetZipFile IRemoteFile[] sourceFiles = new IRemoteFile[3]; //Also add some of its children into the batch. @@ -793,29 +805,29 @@ public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { String childToCopyName3 = "epdcdump01.hex12a"; sourceFiles[2] = (IRemoteFile)getChildFromFolder(sourceFolder, childToCopyName3); fss.copyBatch(sourceFiles, targetZipFile, mon); - + //Checking the first copied folder Object theCopiedChild = getChildFromFolder(targetZipFile, childToCopyName1); - + assertNotNull(theCopiedChild); - + //Also make sure the copied child has the right contents. String[] childrenToCheck1 = {"adsf", "eclipse-SDK-3.3M6-win32.zip", "epdcdump01.hex12", "epdcdump01.hex12aaaa"}; - + int[] typesToCheck1 = {TYPE_FILE, TYPE_FILE, TYPE_FILE, TYPE_FILE}; checkFolderContents((IRemoteFile)theCopiedChild, childrenToCheck1, typesToCheck1); - + //Checking the second copied folder theCopiedChild = getChildFromFolder(targetZipFile, childToCopyName2); - + assertNotNull(theCopiedChild); - + //Also make sure the copied child has the right contents. String[] childrenToCheck2 = {"features"}; - + int[] typesToCheck2 = {TYPE_FOLDER}; checkFolderContents((IRemoteFile)theCopiedChild, childrenToCheck2, typesToCheck2); - + //Checking the third copied file theCopiedChild = getChildFromFolder(targetZipFile, childToCopyName3); assertNotNull(theCopiedChild); @@ -824,31 +836,32 @@ public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { public void testCopyBatchToVirtualFileLevelOne() throws Exception { //-test-author-:XuanChen - if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + createSourceZipFiles(); createSourceFolders(); - + String zipTargetFileName = zipSourceFileName1; IRemoteFile targetZipFile = (IRemoteFile)getChildFromFolder(tempDir, zipTargetFileName); assertNotNull(targetZipFile); - + String sourceFolderName = folderToCopyName3; IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir, sourceFolderName); assertNotNull(sourceFolder); - + //Now, copy one of the folder from the sourceFolder into a first level virtual file in targetZipFile //Get one of its first level children, and copy the folder to there. Object[] childrenOfTargetZipFile = fss.resolveFilterString(targetZipFile, null, mon); - + IRemoteFile[] sourceFiles = new IRemoteFile[1]; sourceFiles[0] = sourceFolder; fss.copyBatch(sourceFiles, ((IRemoteFile)childrenOfTargetZipFile[0]), mon); Object theCopiedChild = getChildFromFolder(((IRemoteFile)childrenOfTargetZipFile[0]), sourceFolderName); - + assertNotNull(theCopiedChild); - + //Also make sure the copied child has the right contents. String[] childrenToCheck = {"aaaaaaaa", "aaaab", "epdcdump01.hex12a", "RSE-SDK-2.0RC1.zip"}; int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FILE, TYPE_FILE}; @@ -857,25 +870,26 @@ public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { public void testCopyBatchToVirtualFileLevelTwo() throws Exception { //-test-author-:XuanChen - if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + createSourceZipFiles(); createSourceFolders(); - + String zipTargetFileName = zipSourceFileName1; IRemoteFile targetZipFile = (IRemoteFile)getChildFromFolder(tempDir, zipTargetFileName); assertNotNull(targetZipFile); - + //Now, copy the source folder. String sourceFolderName = folderToCopyName3; IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir, sourceFolderName); assertNotNull(sourceFolder); - + //Get one of its second level children, and copy the folder to there. //Now, copy one of the level two folder from the zip file into folder1 IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(targetZipFile, folderToCopyName1); IRemoteFile secondLevelChild = (IRemoteFile)getChildFromFolder(firstLevelChild, "TypeFilters"); - + IRemoteFile[] sourceFiles = new IRemoteFile[3]; //Also add some of its children into the batch. String childToCopyName1 = "aaaaaaaa"; @@ -885,30 +899,30 @@ public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { String childToCopyName3 = "epdcdump01.hex12a"; sourceFiles[2] = (IRemoteFile)getChildFromFolder(sourceFolder, childToCopyName3); fss.copyBatch(sourceFiles, secondLevelChild, mon); - - + + //Checking the first copied folder Object theCopiedChild = getChildFromFolder(secondLevelChild, childToCopyName1); - + assertNotNull(theCopiedChild); - + //Also make sure the copied child has the right contents. String[] childrenToCheck1 = {"adsf", "eclipse-SDK-3.3M6-win32.zip", "epdcdump01.hex12", "epdcdump01.hex12aaaa"}; - + int[] typesToCheck1 = {TYPE_FILE, TYPE_FILE, TYPE_FILE, TYPE_FILE}; checkFolderContents((IRemoteFile)theCopiedChild, childrenToCheck1, typesToCheck1); - + //Checking the second copied folder theCopiedChild = getChildFromFolder(secondLevelChild, childToCopyName2); - + assertNotNull(theCopiedChild); - + //Also make sure the copied child has the right contents. String[] childrenToCheck2 = {"features"}; - + int[] typesToCheck2 = {TYPE_FOLDER}; checkFolderContents((IRemoteFile)theCopiedChild, childrenToCheck2, typesToCheck2); - + //Checking the third copied file theCopiedChild = getChildFromFolder(secondLevelChild, childToCopyName3); assertNotNull(theCopiedChild); @@ -917,19 +931,20 @@ public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { public void testCopyBatchVirtualFile() throws Exception { //-test-author-:XuanChen - if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + createSourceZipFiles(); - + String sourceFileName = zipSourceFileName1; IRemoteFile sourceZipFile = (IRemoteFile)getChildFromFolder(tempDir,sourceFileName); assertNotNull(sourceZipFile); - + //then, create a folder inside the tempDir String folderName = "folder1"; IRemoteFile folder1 = createFileOrFolder(tempDirPath, folderName, true); assertNotNull(folder1); - + //Now, copy one of the folder from the zip file into folder1 Object[] children = fss.resolveFilterString(sourceZipFile, null, mon); IRemoteFile[] sourceFiles = new IRemoteFile[3]; @@ -943,19 +958,19 @@ public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { sourceFiles[2] = (IRemoteFile)getChildFromFolder((IRemoteFile)children[0], childToCopyName3); assertNotNull(sourceFiles[2]); fss.copyBatch(sourceFiles, folder1, mon); - + Object copiedVirtualFolder = getChildFromFolder(folder1, childToCopyName1); assertNotNull(copiedVirtualFolder); String[] contents1 = {"Connections", "Filters", "profile.xmi"}; int[] typesToCheck1 = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FILE}; checkFolderContents((IRemoteFile)copiedVirtualFolder, contents1, typesToCheck1); - + copiedVirtualFolder = getChildFromFolder(folder1, childToCopyName2); assertNotNull(copiedVirtualFolder); String[] contents2 = {"Connections", "Filters", "profile.xmi"}; int[] typesToCheck2 = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FILE}; checkFolderContents((IRemoteFile)copiedVirtualFolder, contents2, typesToCheck2); - + Object copiedVirtualFile = getChildFromFolder(folder1, childToCopyName3); assertNotNull(copiedVirtualFile); assertTrue(((IRemoteFile)copiedVirtualFile).isDirectory() != true); @@ -963,32 +978,33 @@ public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { public void testCopyBatchVirtualFileLevelTwo() throws Exception { //-test-author-:XuanChen - if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + createSourceZipFiles(); - + String sourceFileName = zipSourceFileName1; IRemoteFile sourceZipFile = (IRemoteFile)getChildFromFolder(tempDir, sourceFileName); assertNotNull(sourceZipFile); - + //then, create a folder inside the tempDir String folderName = "folder1"; IRemoteFile folder1 = createFileOrFolder(tempDirPath, folderName, true); assertNotNull(folder1); - + //Now, copy one of the level two folder from the zip file into folder1 IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(sourceZipFile, folderToCopyName1); IRemoteFile secondLevelChild = (IRemoteFile)getChildFromFolder(firstLevelChild, "Team"); - + IRemoteFile[] sourceFiles = new IRemoteFile[1]; sourceFiles[0] = secondLevelChild; //copy this level two childer into folder1 fss.copyBatch(sourceFiles, folder1, mon); - + Object copiedVirtualFolder = getChildFromFolder(folder1, secondLevelChild.getName()); - + assertNotNull(copiedVirtualFolder); - + String[] contents = {"Connections", "Filters", "profile.xmi"}; int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FILE}; checkFolderContents((IRemoteFile)copiedVirtualFolder, contents, typesToCheck); @@ -996,62 +1012,64 @@ public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { public void testCopyVirtualBatchToArchiveFile() throws Exception { //-test-author-:XuanChen - if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + createSourceZipFiles(); - + String zipTargetFileName = zipSourceFileName1; IRemoteFile targetZipFile = (IRemoteFile)getChildFromFolder(tempDir, zipTargetFileName); assertNotNull(targetZipFile); - + String sourcefileName = zipSourceFileName2; IRemoteFile sourceFile = (IRemoteFile)getChildFromFolder(tempDir, sourcefileName); assertNotNull(sourceFile); - + //Now, copy one of the folder from the sourceFile into copiedTargetZipFile IRemoteFile[] sourceFiles = new IRemoteFile[1]; String virutalFolderToCopyName = "6YLT5Xa"; IRemoteFile virtualFolderToCopy = (IRemoteFile)getChildFromFolder(sourceFile, virutalFolderToCopyName); sourceFiles[0] = virtualFolderToCopy; fss.copyBatch(sourceFiles, targetZipFile, mon); - + Object theCopiedChild = getChildFromFolder(targetZipFile, virutalFolderToCopyName); - + assertNotNull(theCopiedChild); - + //Also make sure the copied child has the right contents. String[] childrenToCheck = {"20070315a", "20070319", "20070320a", "20070404a", "dummyFolder"}; - + int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FOLDER, TYPE_FOLDER, TYPE_FOLDER}; checkFolderContents((IRemoteFile)theCopiedChild, childrenToCheck, typesToCheck); } public void testCopyVirtualBatchToVirtualFileLevelOne() throws Exception { //-test-author-:XuanChen - if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + createSourceZipFiles(); - + String zipTargetFileName = zipSourceFileName1; IRemoteFile targetZipFile = (IRemoteFile)getChildFromFolder(tempDir, zipTargetFileName); assertNotNull(targetZipFile); - + String sourcefileName = zipSourceFileName2; IRemoteFile sourceFile = (IRemoteFile)getChildFromFolder(tempDir, sourcefileName); assertNotNull(sourceFile); - + //Now, copy one of the folder from the sourceFolder into a first level virtual file in targetZipFile //Get one of its first level children, and copy the folder to there. Object[] childrenOfTargetZipFile = fss.resolveFilterString(targetZipFile, null, mon); - + IRemoteFile[] sourceFiles = new IRemoteFile[3]; - + String parentOfVirutalFolderToCopyName = "6YLT5Xa"; IRemoteFile parentOfVirtualFolderToCopy = (IRemoteFile)getChildFromFolder(sourceFile, parentOfVirutalFolderToCopyName); String virtualChildToCopyName1 = "20070315a"; String virtualChildToCopyName2 = "20070319"; String virtualChildToCopyName3 = "dummyFolder"; - + sourceFiles[0] = (IRemoteFile)getChildFromFolder(parentOfVirtualFolderToCopy, virtualChildToCopyName1); assertNotNull(sourceFiles[0]); sourceFiles[1] = (IRemoteFile)getChildFromFolder(parentOfVirtualFolderToCopy, virtualChildToCopyName2); @@ -1060,21 +1078,21 @@ public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { assertNotNull(sourceFiles[2]); fss.copyBatch(sourceFiles, ((IRemoteFile)childrenOfTargetZipFile[0]), mon); - + Object theCopiedChild = getChildFromFolder(((IRemoteFile)childrenOfTargetZipFile[0]), virtualChildToCopyName1); assertNotNull(theCopiedChild); //Also make sure the copied child has the right contents. String[] childrenToCheck1 = {"QB5ROUTaadd"}; int[] typesToCheck1 = {TYPE_FILE}; checkFolderContents((IRemoteFile)theCopiedChild, childrenToCheck1, typesToCheck1); - + theCopiedChild = getChildFromFolder(((IRemoteFile)childrenOfTargetZipFile[0]), virtualChildToCopyName2); assertNotNull(theCopiedChild); //Also make sure the copied child has the right contents. String[] childrenToCheck2 = {"QB5ROUTERa"}; int[] typesToCheck2 = {TYPE_FILE}; checkFolderContents((IRemoteFile)theCopiedChild, childrenToCheck2, typesToCheck2); - + theCopiedChild = getChildFromFolder(((IRemoteFile)childrenOfTargetZipFile[0]), virtualChildToCopyName3); assertNotNull(theCopiedChild); //Also make sure the copied child has the right contents. @@ -1085,74 +1103,76 @@ public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { public void testCopyVirtualBatchToVirtualFileLevelTwo() throws Exception { //-test-author-:XuanChen - if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + createSourceZipFiles(); - + String zipTargetFileName = zipSourceFileName1; IRemoteFile targetZipFile = (IRemoteFile)getChildFromFolder(tempDir, zipTargetFileName); assertNotNull(targetZipFile); - + String sourcefileName = zipSourceFileName2; IRemoteFile sourceFile = (IRemoteFile)getChildFromFolder(tempDir, sourcefileName); assertNotNull(sourceFile); - + //Get one of its second level children, and copy the folder to there. //Now, copy one of the level two folder from the zip file into folder1 IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(targetZipFile, folderToCopyName1); IRemoteFile secondLevelChild = (IRemoteFile)getChildFromFolder(firstLevelChild, "TypeFilters"); - + IRemoteFile[] sourceFiles = new IRemoteFile[1]; - + String parentOfVirutalFolderToCopyName = "6YLT5Xa"; IRemoteFile parentOfVirtualFolderToCopy = (IRemoteFile)getChildFromFolder(sourceFile, parentOfVirutalFolderToCopyName); String virtualFolderToCopyName = "dummyFolder"; IRemoteFile virtualFolderToCopy = (IRemoteFile)getChildFromFolder(parentOfVirtualFolderToCopy, virtualFolderToCopyName); - + sourceFiles[0] = virtualFolderToCopy; - + fss.copyBatch(sourceFiles, secondLevelChild, mon); - + Object theCopiedChild = getChildFromFolder(parentOfVirtualFolderToCopy, virtualFolderToCopyName); - + assertNotNull(theCopiedChild); - + //Also make sure the copied child has the right contents. String[] childrenToCheck = {"20070404a", "epdcdump01.hex12ab"}; int[] typesToCheck = {TYPE_FOLDER, TYPE_FILE}; checkFolderContents((IRemoteFile)theCopiedChild, childrenToCheck, typesToCheck); } - - - + + + public void testCopyToTarVirtualFileLevelOne() throws Exception { //-test-author-:XuanChen - if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + //create the source for testing first createSourceTarFiles(); createSourceFolders(); - + String tarTargetFileName = tarSourceFileName1; IRemoteFile targetTarFile = (IRemoteFile)getChildFromFolder(tempDir, tarTargetFileName); assertNotNull(targetTarFile); - + String sourceFolderName = folderToCopyName3; IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir, sourceFolderName); assertNotNull(sourceFolder); - + //Now, copy one of the folder from the sourceFolder into a first level virtual file in targetZipFile //Get one of its first level children, and copy the folder to there. IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(targetTarFile, "org"); assertNotNull(firstLevelChild); - + fss.copy(sourceFolder, firstLevelChild, sourceFolder.getName(), mon); - + Object theCopiedChild = getChildFromFolder(firstLevelChild, sourceFolderName); - + assertNotNull(theCopiedChild); - + //Also make sure the copied child has the right contents. String[] childrenToCheck = {"aaaaaaaa", "aaaab", "epdcdump01.hex12a", "RSE-SDK-2.0RC1.zip"}; int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FILE, TYPE_FILE}; @@ -1161,20 +1181,21 @@ public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { public void testCopyToTarVirtualFileLevelFour() throws Exception { //-test-author-:XuanChen - if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + //create the source for testing first createSourceTarFiles(); createSourceFolders(); - + String tarTargetFileName = tarSourceFileName1; IRemoteFile targetTarFile = (IRemoteFile)getChildFromFolder(tempDir, tarTargetFileName); assertNotNull(targetTarFile); - + String sourceFolderName = folderToCopyName3; IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir, sourceFolderName); assertNotNull(sourceFolder); - + //Get one of its fourth level children, and copy the folder to there. IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(targetTarFile, "org"); assertNotNull(firstLevelChild); @@ -1184,13 +1205,13 @@ public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { assertNotNull(thirdLevelChild); IRemoteFile fourLevelChild = (IRemoteFile)getChildFromFolder(thirdLevelChild, "core"); assertNotNull(fourLevelChild); - + //Object[] children = fss.resolveFilterString(sourceZipFile, null, mon); fss.copy(sourceFolder, fourLevelChild, sourceFolder.getName(), mon); - + Object theCopiedChild = getChildFromFolder(fourLevelChild, sourceFolderName); assertNotNull(theCopiedChild); - + //Also make sure the copied child has the right contents. String[] childrenToCheck = {"aaaaaaaa", "aaaab", "epdcdump01.hex12a", "RSE-SDK-2.0RC1.zip"}; int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FILE, TYPE_FILE}; @@ -1200,47 +1221,48 @@ public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { public void testCopyTarVirtualFileLevelFour() throws Exception { //-test-author-:XuanChen - if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + //create the source for testing first createSourceTarFiles(); - + String sourceFileName = tarSourceFileName1; IRemoteFile sourceTarFile = (IRemoteFile)getChildFromFolder(tempDir, sourceFileName); assertNotNull(sourceTarFile); - + //then, create a folder inside the tempDir String folderName = "folder1"; IRemoteFile folder1 = createFileOrFolder(tempDirPath, folderName, true); assertNotNull(folder1); - + //Now, copy one of the level four folder from the zip file into folder1 //The folder is org/eclipse/dstore/core //then, get directory "java" under org/eclipse/dstore/core String parentForDirectoryToCopyName ="org"; IRemoteFile parentForDirectoryToCopy = (IRemoteFile)getChildFromFolder(sourceTarFile, parentForDirectoryToCopyName); assertNotNull(parentForDirectoryToCopy); - + parentForDirectoryToCopyName ="eclipse"; parentForDirectoryToCopy = (IRemoteFile)getChildFromFolder(parentForDirectoryToCopy, parentForDirectoryToCopyName); assertNotNull(parentForDirectoryToCopy); - + parentForDirectoryToCopyName ="dstore"; parentForDirectoryToCopy = (IRemoteFile)getChildFromFolder(parentForDirectoryToCopy, parentForDirectoryToCopyName); assertNotNull(parentForDirectoryToCopy); - + String directoryToCopyName ="core"; IRemoteFile directoryToCopy = (IRemoteFile)getChildFromFolder(parentForDirectoryToCopy, directoryToCopyName); assertNotNull(directoryToCopy); - - + + //copy this level four children into folder1 fss.copy(directoryToCopy, folder1, directoryToCopyName, mon); - + Object copiedVirtualFolder = getChildFromFolder(folder1, directoryToCopyName); - + assertNotNull(copiedVirtualFolder); - + String[] contents = {"client", "java", "miners", "model", "server", "util", "Activator.java"}; int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FOLDER, TYPE_FOLDER, TYPE_FOLDER, TYPE_FOLDER, TYPE_FILE}; checkFolderContents((IRemoteFile)copiedVirtualFolder, contents, typesToCheck); @@ -1249,36 +1271,37 @@ public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { public void testMoveToTarVirtualFileLevelOne() throws Exception { //-test-author-:XuanChen - if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + //create the source for testing first createSourceTarFiles(); createSourceFolders(); - + String tarTargetFileName = tarSourceFileName1; IRemoteFile targetTarFile = (IRemoteFile)getChildFromFolder(tempDir, tarTargetFileName); assertNotNull(targetTarFile); - + String sourceFolderName = folderToCopyName3; IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir, sourceFolderName); assertNotNull(sourceFolder); - + //Now, copy one of the folder from the sourceFolder into a first level virtual file in targetZipFile //Get one of its first level children, and copy the folder to there. Object[] childrenOfTargetZipFile = fss.resolveFilterString(targetTarFile, null, mon); - + //Object[] children = fss.resolveFilterString(sourceZipFile, null, mon); fss.move(sourceFolder, ((IRemoteFile)childrenOfTargetZipFile[0]), sourceFolderName, mon); - + Object theMovedChild = getChildFromFolder(((IRemoteFile)childrenOfTargetZipFile[0]), sourceFolderName); - + assertNotNull(theMovedChild); - + //Also make sure the copied child has the right contents. String[] childrenToCheck = {"aaaaaaaa", "aaaab", "epdcdump01.hex12a", "RSE-SDK-2.0RC1.zip"}; int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FILE, TYPE_FILE}; checkFolderContents((IRemoteFile)theMovedChild, childrenToCheck, typesToCheck); - + //make sure the original folder is gone. Object originalSource = getChildFromFolder(tempDir, sourceFolderName); assertNull(originalSource); @@ -1286,20 +1309,21 @@ public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { public void testMoveToVirtualFileLevelFour() throws Exception { //-test-author-:XuanChen - if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + //create the source for testing first createSourceTarFiles(); createSourceFolders(); - + String tarTargetFileName = tarSourceFileName1; IRemoteFile targetTarFile = (IRemoteFile)getChildFromFolder(tempDir, tarTargetFileName); assertNotNull(targetTarFile); - + String sourceFolderName = folderToCopyName3; IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir, sourceFolderName); assertNotNull(sourceFolder); - + //Get one of its fourth level children, and copy the folder to there. IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(targetTarFile, "org"); assertNotNull(firstLevelChild); @@ -1309,19 +1333,19 @@ public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { assertNotNull(thirdLevelChild); IRemoteFile fourLevelChild = (IRemoteFile)getChildFromFolder(thirdLevelChild, "core"); assertNotNull(fourLevelChild); - + //Object[] children = fss.resolveFilterString(sourceZipFile, null, mon); fss.move(sourceFolder, fourLevelChild, sourceFolder.getName(), mon); - + Object theCopiedChild = getChildFromFolder(fourLevelChild, sourceFolderName); - + assertNotNull(theCopiedChild); - + //Also make sure the moved child has the right contents. String[] childrenToCheck = {"aaaaaaaa", "aaaab", "epdcdump01.hex12a", "RSE-SDK-2.0RC1.zip"}; int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FILE, TYPE_FILE}; checkFolderContents((IRemoteFile)theCopiedChild, childrenToCheck, typesToCheck); - + //make sure the original folder is gone. Object originalSource = getChildFromFolder(tempDir, sourceFolderName); assertNull(originalSource); @@ -1330,20 +1354,21 @@ public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { public void testMoveTarVirtualFileLevelFour() throws Exception { //-test-author-:XuanChen - if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + //create the source for testing first createSourceTarFiles(); - + String sourceFileName = tarSourceFileName1; IRemoteFile sourceTarFile = (IRemoteFile)getChildFromFolder(tempDir, sourceFileName); assertNotNull(sourceTarFile); - + //then, create a folder inside the tempDir String folderName = "folder1"; IRemoteFile folder1 = createFileOrFolder(tempDirPath, folderName, true); assertNotNull(folder1); - + //Get one of its fourth level children, and move it to the folder IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(sourceTarFile, "org"); assertNotNull(firstLevelChild); @@ -1354,18 +1379,18 @@ public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { IRemoteFile fourthLevelChild = (IRemoteFile)getChildFromFolder(thirdLevelChild, "core"); assertNotNull(fourthLevelChild); String movedFolderName = fourthLevelChild.getName(); - + //copy this level four children into folder1 fss.move(fourthLevelChild, folder1, movedFolderName, mon); - + Object copiedVirtualFolder = getChildFromFolder(folder1, movedFolderName); - + assertNotNull(copiedVirtualFolder); - + String[] contents = {"client", "java", "miners", "model", "server", "util", "Activator.java"}; int[] typesToCheck = {TYPE_FOLDER, TYPE_FOLDER, TYPE_FOLDER, TYPE_FOLDER, TYPE_FOLDER, TYPE_FOLDER, TYPE_FILE}; checkFolderContents((IRemoteFile)copiedVirtualFolder, contents, typesToCheck); - + //Now, make sure the moved virtual folder is gone from its original zip file //children = fss.resolveFilterString(sourceTarFile, null, mon); Object result = getChildFromFolder(thirdLevelChild, movedFolderName); @@ -1376,20 +1401,21 @@ public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { public void testCopyBatchToTarVirtualFileLevelFour() throws Exception { //-test-author-:XuanChen - if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + createSourceTarFiles(); createSourceFolders(); - + String tarTargetFileName = tarSourceFileName1; IRemoteFile targetTarFile = (IRemoteFile)getChildFromFolder(tempDir, tarTargetFileName); assertNotNull(targetTarFile); - + //Now, copy the source folder. String sourceFolderName = folderToCopyName3; IRemoteFile sourceFolder = (IRemoteFile)getChildFromFolder(tempDir, sourceFolderName); assertNotNull(sourceFolder); - + //Get one of its fourth level children, and copy the folder to there. IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(targetTarFile, "org"); assertNotNull(firstLevelChild); @@ -1399,7 +1425,7 @@ public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { assertNotNull(thirdLevelChild); IRemoteFile fourthLevelChild = (IRemoteFile)getChildFromFolder(thirdLevelChild, "core"); assertNotNull(fourthLevelChild); - + IRemoteFile[] sourceFiles = new IRemoteFile[3]; //Also add some of its children into the batch. String childToCopyName1 = "aaaaaaaa"; @@ -1409,30 +1435,30 @@ public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { String childToCopyName3 = "epdcdump01.hex12a"; sourceFiles[2] = (IRemoteFile)getChildFromFolder(sourceFolder, childToCopyName3); fss.copyBatch(sourceFiles, fourthLevelChild, mon); - - + + //Checking the first copied folder Object theCopiedChild = getChildFromFolder(fourthLevelChild, childToCopyName1); - + assertNotNull(theCopiedChild); - + //Also make sure the copied child has the right contents. String[] childrenToCheck1 = {"adsf", "eclipse-SDK-3.3M6-win32.zip", "epdcdump01.hex12", "epdcdump01.hex12aaaa"}; - + int[] typesToCheck1 = {TYPE_FILE, TYPE_FILE, TYPE_FILE, TYPE_FILE}; checkFolderContents((IRemoteFile)theCopiedChild, childrenToCheck1, typesToCheck1); - + //Checking the second copied folder theCopiedChild = getChildFromFolder(fourthLevelChild, childToCopyName2); - + assertNotNull(theCopiedChild); - + //Also make sure the copied child has the right contents. String[] childrenToCheck2 = {"features"}; - + int[] typesToCheck2 = {TYPE_FOLDER}; checkFolderContents((IRemoteFile)theCopiedChild, childrenToCheck2, typesToCheck2); - + //Checking the third copied file theCopiedChild = getChildFromFolder(fourthLevelChild, childToCopyName3); assertNotNull(theCopiedChild); @@ -1443,19 +1469,20 @@ public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { public void testCopyBatchTarVirtualFileLevelFive() throws Exception { //-test-author-:XuanChen - if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ - + if (isTestDisabled()) + return; + createSourceTarFiles(); - + String sourceFileName = tarSourceFileName1; IRemoteFile sourceTarFile = (IRemoteFile)getChildFromFolder(tempDir, sourceFileName); assertNotNull(sourceTarFile); - + //then, create a folder inside the tempDir String folderName = "folder1"; IRemoteFile folder1 = createFileOrFolder(tempDirPath, folderName, true); assertNotNull(folder1); - + //Get several of its fifth level children, and them into the folder. IRemoteFile firstLevelChild = (IRemoteFile)getChildFromFolder(sourceTarFile, "org"); assertNotNull(firstLevelChild); @@ -1465,34 +1492,34 @@ public class FileServiceArchiveTest extends FileServiceArchiveBaseTest { assertNotNull(thirdLevelChild); IRemoteFile fourthLevelChild = (IRemoteFile)getChildFromFolder(thirdLevelChild, "core"); assertNotNull(fourthLevelChild); - + IRemoteFile[] fifLevelChildrenToCopy = new IRemoteFile[3]; - - String firstToCopyName = "client"; + + String firstToCopyName = "client"; fifLevelChildrenToCopy[0] = (IRemoteFile)getChildFromFolder(fourthLevelChild, firstToCopyName); assertNotNull(fifLevelChildrenToCopy[0]); - String secondToCopyName = "miners"; + String secondToCopyName = "miners"; fifLevelChildrenToCopy[1] = (IRemoteFile)getChildFromFolder(fourthLevelChild, secondToCopyName); assertNotNull(fifLevelChildrenToCopy[1]); - String thirdToCopyName = "Activator.java"; + String thirdToCopyName = "Activator.java"; fifLevelChildrenToCopy[2] = (IRemoteFile)getChildFromFolder(fourthLevelChild, thirdToCopyName); assertNotNull(fifLevelChildrenToCopy[2]); - - + + fss.copyBatch(fifLevelChildrenToCopy, folder1, mon); - + Object copiedVirtualFolder1 = getChildFromFolder(folder1, firstToCopyName); assertNotNull(copiedVirtualFolder1); String[] contents1 = {"ClientConnection.java", "ConnectionStatus.java"}; int[] typesToCheck1 = {TYPE_FILE, TYPE_FILE}; checkFolderContents((IRemoteFile)copiedVirtualFolder1, contents1, typesToCheck1); - + Object copiedVirtualFolder2 = getChildFromFolder(folder1, secondToCopyName); assertNotNull(copiedVirtualFolder2); String[] contents2 = {"Miner.java", "MinerThread.java"}; int[] typesToCheck2 = {TYPE_FILE, TYPE_FILE}; checkFolderContents((IRemoteFile)copiedVirtualFolder2, contents2, typesToCheck2); - + Object copiedVirtualFolder3 = getChildFromFolder(folder1, thirdToCopyName); assertNotNull(copiedVirtualFolder3); } diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileServiceArchiveTestDStore.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileServiceArchiveTestDStore.java index 17481bba64f..f6afe8ae749 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileServiceArchiveTestDStore.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileServiceArchiveTestDStore.java @@ -34,12 +34,11 @@ import org.eclipse.rse.services.clientserver.messages.SystemMessageException; import org.eclipse.rse.services.files.IFileService; import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; -import org.eclipse.rse.tests.RSETestsPlugin; import org.eclipse.rse.ui.ISystemPreferencesConstants; import org.eclipse.rse.ui.RSEUIPlugin; public class FileServiceArchiveTestDStore extends FileServiceArchiveTest { - + private boolean fPreference_ALERT_SSL; private boolean fPreference_ALERT_NONSSL; @@ -49,11 +48,12 @@ public class FileServiceArchiveTestDStore extends FileServiceArchiveTest { */ public FileServiceArchiveTestDStore(String name) { super(name); + setTargetName("linux"); } public static junit.framework.Test suite() { TestSuite suite = new TestSuite("FileServiceArchiveTestDStore"); - + //zip file testing suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testCopyBatchToArchiveFile")); //$NON-NLS-1$ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testCopyBatchToVirtualFileLevelOne")); //$NON-NLS-1$ @@ -77,7 +77,7 @@ public class FileServiceArchiveTestDStore extends FileServiceArchiveTest { suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testMoveVirtualFileLevelTwo")); //$NON-NLS-1$ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testRenameVirtualFile")); //$NON-NLS-1$ //suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testRenameVirtualFileBigZip")); //$NON-NLS-1$ - + //tar file testing suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testCreateTarFile")); //$NON-NLS-1$ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testCopyTarVirtualFile")); //$NON-NLS-1$ @@ -95,14 +95,14 @@ public class FileServiceArchiveTestDStore extends FileServiceArchiveTest { suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testCopyBatchTarVirtualFileLevelFive")); suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testCopyBatchToTarArchiveFile")); suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testCopyBatchToTarVirtualFileLevelFour")); - + //super transfer suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testSuperTransferLocalToRemote")); suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testSuperTransferDStoreWindowsAndDStore")); suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testSuperTransferDStoreToLocal")); //open a virtual file in tar archive suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testOpenFileFromTarArchive")); //$NON-NLS-1$ - + //copy the virtual folder across connections suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testCopyVirtualFileFromDStoreToLocal")); //$NON-NLS-1$ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testCopyVirtualFileLevelTwoFromDStoreToLocal")); //$NON-NLS-1$ @@ -116,17 +116,17 @@ public class FileServiceArchiveTestDStore extends FileServiceArchiveTest { suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testCopyVFToVFLevelTwoFromDStoreToLocal")); //$NON-NLS-1$ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testCopyVFToVFFromLocalToDStore")); //$NON-NLS-1$ suite.addTest(TestSuite.createTest(FileServiceArchiveTestDStore.class, "testCopyVFToVFLevelTwoFromLocalToDStore")); //$NON-NLS-1$ - + return suite; } - - - + + + protected void setupFileSubSystem() { - + IHost dstoreHost = getLinuxHost(); assertNotNull(dstoreHost); - ISystemRegistry sr = SystemStartHere.getSystemRegistry(); + ISystemRegistry sr = SystemStartHere.getSystemRegistry(); ISubSystem[] ss = sr.getServiceSubSystems(dstoreHost, IFileService.class); for (int i=0; i 0); @@ -138,6 +143,7 @@ public class FileServiceTest extends RSEBaseConnectionTestCase { String rootName = roots[i].getName(); assertNotNull(rootName); System.out.println(rootName); + // DStore: NPE, bug 240710 IHostFile newHf = fs.getFile(null, rootName, new NullProgressMonitor()); assertTrue(newHf.isRoot()); assertTrue(newHf.exists()); @@ -151,7 +157,7 @@ public class FileServiceTest extends RSEBaseConnectionTestCase { public void testCaseSensitive() { //-test-author-:MartinOberhuber - if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCaseSensitive")) return; //$NON-NLS-1$ + if (isTestDisabled()) return; if (isWindows()) { assertFalse(fs.isCaseSensitive()); @@ -166,7 +172,7 @@ public class FileServiceTest extends RSEBaseConnectionTestCase { public void testCreateFile() throws SystemMessageException { //-test-author-:MartinOberhuber - if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$ + if (isTestDisabled()) return; String testName = getTestFileName(); IHostFile hf = fs.createFile(tempDirPath, testName, mon); //dstore-linux: bug 235492 @@ -187,7 +193,7 @@ public class FileServiceTest extends RSEBaseConnectionTestCase { public void testCreateCaseSensitive() throws SystemMessageException { //-test-author-:MartinOberhuber - if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateCaseSensitive")) return; //$NON-NLS-1$ + if (isTestDisabled()) return; String testName = getTestFileName(); String testName2 = testName.toUpperCase(); diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/RSEFileStoreTest.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/RSEFileStoreTest.java index 909c7715c1c..fdc2633eb7b 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/RSEFileStoreTest.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/RSEFileStoreTest.java @@ -7,6 +7,7 @@ * * Contributors: * Martin Oberhuber (Wind River) - initial API and implementation + * Martin Oberhuber (Wind River) - [240729] More flexible disabling of testcases *******************************************************************************/ package org.eclipse.rse.tests.subsystems.files; @@ -74,6 +75,11 @@ public class RSEFileStoreTest extends FileServiceBaseTest { public RSEFileStoreTest(String name, String propertiesFileName) { super(name); fPropertiesFileName = propertiesFileName; + if (propertiesFileName != null) { + int idx = propertiesFileName.indexOf("Connection.properties"); + String targetName = propertiesFileName.substring(0, idx); + setTargetName(targetName); + } } public static Test suite() { @@ -178,6 +184,8 @@ public class RSEFileStoreTest extends FileServiceBaseTest { public void testRecursiveGetParent() { //-test-author-:MartinOberhuber + if (isTestDisabled()) + return; IFileStore store = fTestStore; String homePath = store.toURI().getPath(); assertTrue("exists: " + store, store.fetchInfo().exists()); @@ -193,6 +201,8 @@ public class RSEFileStoreTest extends FileServiceBaseTest { public void testAppendOutputStream() throws Exception { //-test-author-:MartinOberhuber + if (isTestDisabled()) + return; IFileStore f = createFile("foo"); fOS = f.openOutputStream(EFS.APPEND, getDefaultProgressMonitor()); fOS.write("bar".getBytes()); @@ -211,6 +221,8 @@ public class RSEFileStoreTest extends FileServiceBaseTest { public void testPutInfo() throws Exception { //-test-author-:MartinOberhuber + if (isTestDisabled()) + return; IFileInfo testInfo = fTestStore.fetchInfo(); assertTrue("1.1", testInfo.exists()); assertTrue("1.2", testInfo.isDirectory()); @@ -250,6 +262,8 @@ public class RSEFileStoreTest extends FileServiceBaseTest { public void testDeleteSpecialCases() throws Exception { //-test-author-:MartinOberhuber + if (isTestDisabled()) + return; String testFileName = "noPerm.txt"; //$NON-NLS-1$ boolean exceptionThrown = false; @@ -350,6 +364,8 @@ public class RSEFileStoreTest extends FileServiceBaseTest { public void testModifyNonExisting() throws Exception { // -test-author-:MartinOberhuber + if (isTestDisabled()) + return; IFileStore store = fTestStore.getChild("nonExisting.txt"); IFileInfo info; boolean exceptionThrown = false; @@ -435,6 +451,8 @@ public class RSEFileStoreTest extends FileServiceBaseTest { public void testModifyReadOnly() throws Exception { //-test-author-:MartinOberhuber + if (isTestDisabled()) + return; IFileStore store = createFile("readOnly.txt"); IFileInfo info = store.fetchInfo(); info.setAttribute(EFS.ATTRIBUTE_READ_ONLY, true); @@ -494,6 +512,8 @@ public class RSEFileStoreTest extends FileServiceBaseTest { public void testMakeDeleteTree() throws Exception { // -test-author-:MartinOberhuber // Create folder + if (isTestDisabled()) + return; IFileStore treeStore = fTestStore.getChild("treeTest"); treeStore.mkdir(EFS.SHALLOW, getDefaultProgressMonitor()); @@ -597,6 +617,8 @@ public class RSEFileStoreTest extends FileServiceBaseTest { } public void test255files() throws Exception { + if (isTestDisabled()) + return; IFileStore f = fTestStore.getChild("f"); f.mkdir(EFS.SHALLOW, getDefaultProgressMonitor()); for (int i = 0; i < 255; i++) { diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/ui/mnemonics/MnemonicsTest.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/ui/mnemonics/MnemonicsTest.java index ba2a40c9731..ae4d3d4f173 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/ui/mnemonics/MnemonicsTest.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/ui/mnemonics/MnemonicsTest.java @@ -1,7 +1,7 @@ /******************************************************************************** * Copyright (c) 2007, 2008 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 + * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: @@ -24,23 +24,25 @@ import org.eclipse.rse.ui.SystemPreferencesManager; * Test various aspects of mnemonic generation and assignment. */ public class MnemonicsTest extends RSECoreTestCase { - + /* (non-Javadoc) * @see org.eclipse.rse.tests.core.RSECoreTestCase#setUp() */ protected void setUp() throws Exception { super.setUp(); } - + /* (non-Javadoc) * @see org.eclipse.rse.tests.core.RSECoreTestCase#tearDown() */ protected void tearDown() throws Exception { super.tearDown(); } - + public void testDefaultGeneration() { //-test-author-:DavidDykstal + if (isTestDisabled()) + return; Mnemonics mn = new Mnemonics(); mn.clear("abcde"); String result = mn.setUniqueMnemonic("A..."); @@ -48,9 +50,11 @@ public class MnemonicsTest extends RSECoreTestCase { result = mn.setUniqueMnemonic("F..."); assertEquals("&F...", result); } - + public void testAppendPolicies() { //-test-author-:DavidDykstal + if (isTestDisabled()) + return; setLocalePattern(".*"); // match all locales Mnemonics mn = new Mnemonics(); mn.clear("abcde"); @@ -61,9 +65,9 @@ public class MnemonicsTest extends RSECoreTestCase { result = mn.setUniqueMnemonic("H..."); assertEquals("&H...", result); } - + private void setLocalePattern(String pattern) { RSEUIPlugin.getDefault().getPluginPreferences().setValue(Mnemonics.APPEND_MNEMONICS_PATTERN_PREFERENCE, pattern); } - + }