diff --git a/rse/tests/org.eclipse.rse.tests/META-INF/MANIFEST.MF b/rse/tests/org.eclipse.rse.tests/META-INF/MANIFEST.MF index 55bb5a0e0c2..cf3bb3d35d4 100644 --- a/rse/tests/org.eclipse.rse.tests/META-INF/MANIFEST.MF +++ b/rse/tests/org.eclipse.rse.tests/META-INF/MANIFEST.MF @@ -14,6 +14,7 @@ Require-Bundle: org.junit, org.eclipse.rse.ui, org.eclipse.rse.subsystems.files.core, org.eclipse.rse.subsystems.shells.core, - org.eclipse.rse.tests.framework + org.eclipse.rse.tests.framework, + org.eclipse.rse.services Eclipse-LazyStart: true Bundle-RequiredExecutionEnvironment: J2SE-1.4 diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/RSECombinedTestSuite.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/RSECombinedTestSuite.java index b47b3e3cd98..eb4b7b3a289 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/RSECombinedTestSuite.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/RSECombinedTestSuite.java @@ -13,6 +13,7 @@ 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; @@ -49,6 +50,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()); return suite; } diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/files/FileServiceTest.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/files/FileServiceTest.java new file mode 100644 index 00000000000..e695851356e --- /dev/null +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/files/FileServiceTest.java @@ -0,0 +1,133 @@ +/******************************************************************************* + * 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: + * Martin Oberhuber (Wind River) - initial API and implementation + *******************************************************************************/ +package org.eclipse.rse.tests.files; + +import java.io.File; +import java.io.IOException; + +import org.eclipse.core.runtime.IProgressMonitor; +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.model.SystemStartHere; +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.core.connection.RSEBaseConnectionTestCase; + +public class FileServiceTest extends RSEBaseConnectionTestCase { + + private IFileServiceSubSystem fss; + private IFileService fs; + private File tempDir; + private String tempDirPath; + private IProgressMonitor mon = new NullProgressMonitor(); + + public void setUp() { + IHost localHost = getLocalSystemConnection(); + ISystemRegistry sr = SystemStartHere.getSystemRegistry(); + ISubSystem[] ss = sr.getServiceSubSystems(IFileService.class, localHost); + for (int i=0; i"; //$NON-NLS-1$ + } + //Fallback: Windows + return "a !@#${a}' file%^&()_ =[]+-;,."; //$NON-NLS-1$ + } + + public void testCaseSensitive() { + if (isWindows()) { + assertFalse(fss.getSubSystemConfiguration().isCaseSensitive()); + assertFalse(fss.isCaseSensitive()); + assertFalse(fs.isCaseSensitive()); //FAIL due to bug 168586 + } else { + assertTrue(fss.getSubSystemConfiguration().isCaseSensitive()); + assertTrue(fss.isCaseSensitive()); + assertTrue(fs.isCaseSensitive()); + } + } + + public void testCreateFile() throws SystemMessageException { + String testName = getTestFileName(); + IHostFile hf = fs.createFile(mon, tempDirPath, testName); + assertTrue(hf.exists()); + assertTrue(hf.canRead()); + assertTrue(hf.canWrite()); + assertEquals(hf.getName(), testName); + + File theFile = new File(tempDir, testName); + assertTrue(theFile.exists()); + } + + public void testCreateCaseSensitive() throws SystemMessageException { + String testName = getTestFileName(); + String testName2 = testName.toUpperCase(); + IHostFile hf = fs.createFile(mon, tempDirPath, testName); + if (fss.isCaseSensitive()) { + //UNIX: uppercase version must be distinct + IHostFile hf2 = fs.getFile(mon, tempDirPath, testName2); + assertFalse(hf2.exists()); + hf2 = fs.createFolder(mon, tempDirPath, testName2); + assertTrue(hf2.exists()); + assertTrue(hf2.isDirectory()); + } else { + //Windows: uppercase version must be the same + IHostFile hf2 = fs.getFile(mon, tempDirPath, testName2); + assertTrue(hf2.exists()); + try { + hf2 = fs.createFolder(mon, tempDirPath, testName2); + } catch(SystemMessageException e) { + assertNotNull(e); + } + assertTrue(hf2.exists()); + assertFalse(hf2.isDirectory()); + assertEquals(hf.getModifiedDate(), hf2.getModifiedDate()); + assertEquals(hf.getSize(), hf2.getSize()); + } + } + +} diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/files/RSEFileTestSuite.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/files/RSEFileTestSuite.java new file mode 100644 index 00000000000..ffcdbb10db4 --- /dev/null +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/files/RSEFileTestSuite.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * 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: + * Martin Oberhuber (Wind River) - initial API and implementation + *******************************************************************************/ +package org.eclipse.rse.tests.files; + +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.eclipse.rse.tests.framework.DelegatingTestSuiteHolder; + +public class RSEFileTestSuite extends DelegatingTestSuiteHolder { + /** + * Standard Java application main method. Allows to launch the test + * suite from outside as part of nightly runs, headless runs or other. + *

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

+ * @param args The standard Java application command line parameters passed in. + */ + public static void main(String[] args) { + junit.textui.TestRunner.run(suite()); + } + + /** + * Combine all test into a suite and returns the test suite instance. + *

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

+ * @return The test suite instance. + */ + public static Test suite() { + TestSuite suite = new TestSuite("RSE File Test Suite"); //$NON-NLS-1$ + // add the single test suites to the overall one here. + suite.addTestSuite(FileServiceTest.class); + + return suite; + } + + /* (non-Javadoc) + * @see org.eclipse.rse.tests.framework.AbstractTestSuiteHolder#getTestSuite() + */ + public TestSuite getTestSuite() { + return (TestSuite)RSEFileTestSuite.suite(); + } + +}