mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-03 23:25:26 +02:00
[add] FTP files subsystem and service test case
This commit is contained in:
parent
bbd2e76c13
commit
009f393206
8 changed files with 191 additions and 10 deletions
|
@ -16,7 +16,11 @@ Require-Bundle: org.junit,
|
|||
org.eclipse.rse.subsystems.shells.core,
|
||||
org.eclipse.rse.tests.framework,
|
||||
org.eclipse.ui.views,
|
||||
org.eclipse.rse.services
|
||||
org.eclipse.rse.services,
|
||||
org.eclipse.rse.services.files.ftp,
|
||||
org.eclipse.rse.subsystems.files.ftp,
|
||||
org.apache.commons.net,
|
||||
com.ibm.icu
|
||||
Eclipse-LazyStart: true
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.4
|
||||
Export-Package: org.eclipse.rse.tests,
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
<suite type="org.eclipse.rse.tests.core.connection.RSEConnectionTestSuite" name="RSE Connection Test Suite"/>
|
||||
<type name="org.eclipse.rse.tests.core.connection.RSEConnectionTestSuite" class="org.eclipse.rse.tests.core.connection.RSEConnectionTestSuite" />
|
||||
|
||||
<suite type="org.eclipse.rse.tests.files.RSEFileTestSuite" name="RSE File Test Suite"/>
|
||||
<type name="org.eclipse.rse.tests.files.RSEFileTestSuite" class="org.eclipse.rse.tests.files.RSEFileTestSuite" />
|
||||
<suite type="org.eclipse.rse.tests.subsystems.files.RSEFileSubsystemTestSuite" name="RSE File Subsystem Test Suite"/>
|
||||
<type name="org.eclipse.rse.tests.subsystems.files.RSEFileSubsystemTestSuite" class="org.eclipse.rse.tests.subsystems.files.RSEFileSubsystemTestSuite" />
|
||||
</extension>
|
||||
|
||||
<extension point="org.eclipse.rse.ui.subsystemConfigurations">
|
||||
|
|
|
@ -14,9 +14,9 @@ import junit.framework.Test;
|
|||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.rse.tests.core.connection.RSEConnectionTestSuite;
|
||||
import org.eclipse.rse.tests.files.RSEFileTestSuite;
|
||||
import org.eclipse.rse.tests.framework.DelegatingTestSuiteHolder;
|
||||
import org.eclipse.rse.tests.internal.RSEInternalFrameworkTestSuite;
|
||||
import org.eclipse.rse.tests.subsystems.files.RSEFileSubsystemTestSuite;
|
||||
|
||||
/**
|
||||
* Main class bundling all single specialized test suites into a
|
||||
|
@ -51,7 +51,7 @@ public class RSECombinedTestSuite extends DelegatingTestSuiteHolder {
|
|||
// add the single test suites to the overall one here.
|
||||
suite.addTest(RSEInternalFrameworkTestSuite.suite());
|
||||
suite.addTest(RSEConnectionTestSuite.suite());
|
||||
suite.addTest(RSEFileTestSuite.suite());
|
||||
suite.addTest(RSEFileSubsystemTestSuite.suite());
|
||||
|
||||
return suite;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,11 @@ RSEConnectionTestCase.testConnectionRemoval=true
|
|||
RSEConnectionTestCase.testConnect=true
|
||||
RSEConnectionTestCase.testResolveFilterString=true
|
||||
|
||||
FileServiceTest.testCaseSensitive=true
|
||||
FileServiceTest.testCreateFile=true
|
||||
FileServiceTest.testCreateCaseSensitive=true
|
||||
FTPFileSubsystemTestCase.testFTPAccessToHost_ftp_suse_com=true
|
||||
|
||||
#
|
||||
# The following section contains externalized string for the single classes
|
||||
#
|
||||
|
|
|
@ -0,0 +1,145 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 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:
|
||||
* Uwe Stieber (Wind River) - initial API and implementation.
|
||||
*******************************************************************************/
|
||||
package org.eclipse.rse.tests.subsystems.files;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.commons.net.ftp.FTPClient;
|
||||
import org.apache.commons.net.ftp.FTPFile;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.rse.core.model.IHost;
|
||||
import org.eclipse.rse.core.model.ISystemRegistry;
|
||||
import org.eclipse.rse.core.subsystems.ISubSystem;
|
||||
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
|
||||
import org.eclipse.rse.services.files.IFileService;
|
||||
import org.eclipse.rse.services.files.IHostFile;
|
||||
import org.eclipse.rse.services.files.ftp.FTPService;
|
||||
import org.eclipse.rse.subsystems.files.ftp.FTPFileSubSystemConfiguration;
|
||||
import org.eclipse.rse.tests.RSETestsPlugin;
|
||||
import org.eclipse.rse.tests.core.connection.IRSEConnectionProperties;
|
||||
import org.eclipse.rse.tests.core.connection.RSEBaseConnectionTestCase;
|
||||
import org.eclipse.rse.ui.RSEUIPlugin;
|
||||
|
||||
/**
|
||||
* Test cases for FTP based remote host access.
|
||||
*/
|
||||
public class FTPFileSubsystemTestCase extends RSEBaseConnectionTestCase {
|
||||
private ISubSystem subSystem;
|
||||
private IHost connection;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.tests.core.RSECoreTestCase#tearDown()
|
||||
*/
|
||||
protected void tearDown() throws Exception {
|
||||
if (subSystem != null && subSystem.isConnected()) {
|
||||
subSystem.disconnect(true);
|
||||
}
|
||||
if (connection != null) {
|
||||
getConnectionManager().removeConnection(connection.getSystemProfileName(), connection.getName());
|
||||
}
|
||||
|
||||
subSystem = null;
|
||||
connection = null;
|
||||
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the FTP read access via ftp://ftp.suse.com
|
||||
*/
|
||||
public void testFTPAccessToHost_ftp_suse_com() {
|
||||
if (!RSETestsPlugin.isTestCaseEnabled("FTPFileSubsystemTestCase.testFTPAccessToHost_ftp_suse_com")) return; //$NON-NLS-1$
|
||||
|
||||
ISystemRegistry systemRegistry = RSEUIPlugin.getTheSystemRegistry();
|
||||
assertNotNull("Failed to get RSE system registry instance!", systemRegistry); //$NON-NLS-1$
|
||||
|
||||
// Calculate the location of the test connection properties
|
||||
IPath location = getTestDataLocation("testFTPAccessToHost_ftp_suse_com", false); //$NON-NLS-1$
|
||||
assertNotNull("Cannot locate test data! Missing test data location?", location); //$NON-NLS-1$
|
||||
location = location.append("connection.properties"); //$NON-NLS-1$
|
||||
assertNotNull("Failed to construct location to 'connection.properties' test data file!", location); //$NON-NLS-1$
|
||||
assertTrue("Required test data file seems to be not a file!", location.toFile().isFile()); //$NON-NLS-1$
|
||||
assertTrue("Required test data file is not readable!", location.toFile().canRead()); //$NON-NLS-1$
|
||||
|
||||
// Load the 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
|
||||
systemRegistry.expandHost(connection);
|
||||
|
||||
Exception exception = null;
|
||||
String cause = null;
|
||||
|
||||
subSystem = null;
|
||||
try {
|
||||
subSystem = getConnectionManager().getFileSubSystem(connection, "ftp.files"); //$NON-NLS-1$
|
||||
} catch(Exception e) {
|
||||
exception = e;
|
||||
cause = e.getLocalizedMessage();
|
||||
}
|
||||
assertNull("Failed to get ftp.files subsystem! Possible cause: " + cause, exception); //$NON-NLS-1$
|
||||
assertNotNull("No ftp.files subystem", subSystem); //$NON-NLS-1$
|
||||
|
||||
// we expect that the subsystem is not connected yet
|
||||
assertFalse("ftp.files subsystem is unexpectedly connected!", subSystem.isConnected()); //$NON-NLS-1$
|
||||
try {
|
||||
subSystem.connect();
|
||||
} catch(Exception e) {
|
||||
exception = e;
|
||||
cause = e.getLocalizedMessage();
|
||||
}
|
||||
assertNull("Failed to connect ftp.files subsystem to host " + properties.getProperty(IRSEConnectionProperties.ATTR_NAME) + "! Possible cause: " + cause, exception); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
assertTrue("Failed to connect ftp.files subsystem to host " + properties.getProperty(IRSEConnectionProperties.ATTR_NAME) + "! Unknown cause!", subSystem.isConnected()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
// expand the subsystem
|
||||
systemRegistry.expandSubSystem(subSystem);
|
||||
|
||||
ISubSystemConfiguration configuration = systemRegistry.getSubSystemConfiguration(subSystem);
|
||||
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;
|
||||
IFileService service = ftpConfiguration.getFileService(connection);
|
||||
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$
|
||||
FTPService ftpService = (FTPService)service;
|
||||
|
||||
// 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();
|
||||
} catch (IOException e) {
|
||||
exception = e;
|
||||
cause = e.getLocalizedMessage();
|
||||
}
|
||||
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$
|
||||
}
|
||||
}
|
|
@ -8,7 +8,7 @@
|
|||
* Contributors:
|
||||
* Martin Oberhuber (Wind River) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.rse.tests.files;
|
||||
package org.eclipse.rse.tests.subsystems.files;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -23,6 +23,7 @@ import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
|
|||
import org.eclipse.rse.services.files.IFileService;
|
||||
import org.eclipse.rse.services.files.IHostFile;
|
||||
import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
|
||||
import org.eclipse.rse.tests.RSETestsPlugin;
|
||||
import org.eclipse.rse.tests.core.connection.RSEBaseConnectionTestCase;
|
||||
|
||||
public class FileServiceTest extends RSEBaseConnectionTestCase {
|
||||
|
@ -80,6 +81,8 @@ public class FileServiceTest extends RSEBaseConnectionTestCase {
|
|||
}
|
||||
|
||||
public void testCaseSensitive() {
|
||||
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCaseSensitive")) return; //$NON-NLS-1$
|
||||
|
||||
if (isWindows()) {
|
||||
assertFalse(fss.getSubSystemConfiguration().isCaseSensitive());
|
||||
assertFalse(fss.isCaseSensitive());
|
||||
|
@ -92,6 +95,8 @@ public class FileServiceTest extends RSEBaseConnectionTestCase {
|
|||
}
|
||||
|
||||
public void testCreateFile() throws SystemMessageException {
|
||||
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateFile")) return; //$NON-NLS-1$
|
||||
|
||||
String testName = getTestFileName();
|
||||
IHostFile hf = fs.createFile(mon, tempDirPath, testName);
|
||||
assertTrue(hf.exists());
|
||||
|
@ -109,6 +114,8 @@ public class FileServiceTest extends RSEBaseConnectionTestCase {
|
|||
}
|
||||
|
||||
public void testCreateCaseSensitive() throws SystemMessageException {
|
||||
if (!RSETestsPlugin.isTestCaseEnabled("FileServiceTest.testCreateCaseSensitive")) return; //$NON-NLS-1$
|
||||
|
||||
String testName = getTestFileName();
|
||||
String testName2 = testName.toUpperCase();
|
||||
IHostFile hf = fs.createFile(mon, tempDirPath, testName);
|
|
@ -8,14 +8,14 @@
|
|||
* Contributors:
|
||||
* Martin Oberhuber (Wind River) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.rse.tests.files;
|
||||
package org.eclipse.rse.tests.subsystems.files;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.rse.tests.framework.DelegatingTestSuiteHolder;
|
||||
|
||||
public class RSEFileTestSuite extends DelegatingTestSuiteHolder {
|
||||
public class RSEFileSubsystemTestSuite extends DelegatingTestSuiteHolder {
|
||||
/**
|
||||
* Standard Java application main method. Allows to launch the test
|
||||
* suite from outside as part of nightly runs, headless runs or other.
|
||||
|
@ -38,9 +38,10 @@ public class RSEFileTestSuite extends DelegatingTestSuiteHolder {
|
|||
* @return The test suite instance.
|
||||
*/
|
||||
public static Test suite() {
|
||||
TestSuite suite = new TestSuite("RSE File Test Suite"); //$NON-NLS-1$
|
||||
TestSuite suite = new TestSuite("RSE File Subsystem Test Suite"); //$NON-NLS-1$
|
||||
// add the single test suites to the overall one here.
|
||||
suite.addTestSuite(FileServiceTest.class);
|
||||
suite.addTestSuite(FTPFileSubsystemTestCase.class);
|
||||
|
||||
return suite;
|
||||
}
|
||||
|
@ -49,7 +50,7 @@ public class RSEFileTestSuite extends DelegatingTestSuiteHolder {
|
|||
* @see org.eclipse.rse.tests.framework.AbstractTestSuiteHolder#getTestSuite()
|
||||
*/
|
||||
public TestSuite getTestSuite() {
|
||||
return (TestSuite)RSEFileTestSuite.suite();
|
||||
return (TestSuite)RSEFileSubsystemTestSuite.suite();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
###############################################################################
|
||||
# Copyright (c) 2006 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:
|
||||
# Uwe Stieber (Wind River) - initial contribution.
|
||||
###############################################################################
|
||||
|
||||
# Do not change the properties within this file without changing
|
||||
# the consuming unittest too!
|
||||
name = test_ftp.suse.com
|
||||
profile_name = junit_test_profile
|
||||
system_type = FTP Only
|
||||
address = ftp.suse.com
|
||||
userid = anonymous
|
||||
password = rseunittest@eclipse.org
|
Loading…
Add table
Reference in a new issue