Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorslewis2014-10-14 20:11:49 +0000
committerslewis2014-10-14 20:11:49 +0000
commit194b6887237a00b6be8c4614babffa4fce6cc18c (patch)
tree1dc02ec2ce76dda3e93e5f4702befb9fc2278cd0 /tests
parentd42f18de0bd535101a7866edb94f58bba5a2819b (diff)
downloadorg.eclipse.ecf-194b6887237a00b6be8c4614babffa4fce6cc18c.tar.gz
org.eclipse.ecf-194b6887237a00b6be8c4614babffa4fce6cc18c.tar.xz
org.eclipse.ecf-194b6887237a00b6be8c4614babffa4fce6cc18c.zip
Changes associated with bug
https://bugs.eclipse.org/bugs/show_bug.cgi?id=445729 As per comment https://bugs.eclipse.org/bugs/show_bug.cgi?id=445729#c3 these changes were originally submitted by J Langley via gerrit https://git.eclipse.org/r/#/c/34754/ Small changes needed to be made to the original submission, and he and I apparently did not do the right thing to make those changes via gerrit. So I applied these changes to master directly. Change-Id: I286fe2325ee9fd724067b4281882eb39fffdd440
Diffstat (limited to 'tests')
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.filetransfer/src/org/eclipse/ecf/tests/filetransfer/ScpFileBrowseTest.java110
1 files changed, 110 insertions, 0 deletions
diff --git a/tests/bundles/org.eclipse.ecf.tests.filetransfer/src/org/eclipse/ecf/tests/filetransfer/ScpFileBrowseTest.java b/tests/bundles/org.eclipse.ecf.tests.filetransfer/src/org/eclipse/ecf/tests/filetransfer/ScpFileBrowseTest.java
new file mode 100644
index 000000000..de582fabd
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.filetransfer/src/org/eclipse/ecf/tests/filetransfer/ScpFileBrowseTest.java
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * Copyright (c) 2014 CohesionForce Inc
+ * 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:
+ * CohesionForce Inc - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.ecf.tests.filetransfer;
+
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import org.eclipse.ecf.core.security.ConnectContextFactory;
+import org.eclipse.ecf.core.security.IConnectContext;
+import org.eclipse.ecf.filetransfer.events.IRemoteFileSystemBrowseEvent;
+
+public class ScpFileBrowseTest extends AbstractBrowseTestCase {
+
+ protected File[] roots;
+
+ protected File[] files;
+
+ // Using a countdown latch to wait until we get the proper number
+ // of browse results
+ CountDownLatch latch = new CountDownLatch(1);
+
+ String username;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ IConnectContext cctx;
+ username = System.getProperty("user.name");
+ cctx = ConnectContextFactory.createUsernamePasswordConnectContext(
+ username, null);
+
+ this.adapter.setConnectContextForAuthentication(cctx);
+
+ roots = File.listRoots();
+ final List files = new ArrayList();
+ for (int i = 0; i < roots.length; i++) {
+ final File[] fs = roots[i].listFiles();
+ if (fs != null)
+ for (int j = 0; j < fs.length; j++) {
+ if (fs[j].exists())
+ files.add(fs[j]);
+ }
+ }
+ this.files = (File[]) files.toArray(new File[] {});
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ this.roots = null;
+ this.files = null;
+ }
+
+ public void testBrowseRoots() throws Exception {
+ latch = new CountDownLatch(roots.length);
+ for (int i = 0; i < roots.length; i++) {
+ if (roots[i].exists()) {
+ URL url = new URL("scp://"+username+"@localhost:"
+ + roots[i].getAbsolutePath());
+ System.out.println("Browsing: " + url);
+ testBrowse(url);
+ } else {
+ System.out.println("Skipping: " + roots[i].toString());
+ latch.countDown();
+ }
+ // Need to sleep to give the connection time to close out
+ Thread.sleep(100);
+ }
+ assertTrue(latch.await(60, TimeUnit.SECONDS));
+ }
+
+ @Override
+ protected void handleFileSystemBrowseEvent(IRemoteFileSystemBrowseEvent event) {
+ trace("handleFileSystemBrowseEvent(" + event + ")");
+ if (event.getException() != null) {
+ trace(event.getException().toString());
+ }
+ latch.countDown();
+ }
+
+ public void testFileBrowse() throws Exception {
+ latch = new CountDownLatch(files.length);
+ for (int i = 0; i < files.length; i++) {
+ if (files[i].isDirectory() && files[i].exists()) {
+ URL url = new URL("scp://"+username+"@localhost:"
+ + files[i].getAbsolutePath());
+ System.out.println("Browsing: " + url);
+ testBrowse(url);
+ } else {
+ System.out.println("Skipping: " + files[i].toString());
+ latch.countDown();
+ }
+ // Need to sleep to give the connection time to close out
+ Thread.sleep(100);
+ }
+ assertTrue(latch.await(60, TimeUnit.SECONDS));
+ }
+
+}

Back to the top