Search in sources :

Example 1 with IRemoteFileSystemBrowseEvent

use of org.eclipse.ecf.filetransfer.events.IRemoteFileSystemBrowseEvent in project ecf by eclipse.

the class AbstractFileSystemBrowser method createRemoteFileEvent.

/**
 * @return file system directory event
 */
protected IRemoteFileSystemEvent createRemoteFileEvent() {
    return new IRemoteFileSystemBrowseEvent() {

        public IFileID getFileID() {
            return fileID;
        }

        public Exception getException() {
            return exception;
        }

        public String toString() {
            // $NON-NLS-1$
            StringBuffer buf = new StringBuffer("RemoteFileSystemBrowseEvent[");
            // $NON-NLS-1$ //$NON-NLS-2$
            buf.append("fileID=").append(fileID).append(";");
            List list = (remoteFiles != null) ? Arrays.asList(remoteFiles) : null;
            // $NON-NLS-1$ //$NON-NLS-2$
            buf.append("files=").append(list).append("]");
            return buf.toString();
        }

        public IRemoteFile[] getRemoteFiles() {
            return remoteFiles;
        }
    };
}
Also used : IRemoteFileSystemBrowseEvent(org.eclipse.ecf.filetransfer.events.IRemoteFileSystemBrowseEvent) IRemoteFile(org.eclipse.ecf.filetransfer.IRemoteFile) List(java.util.List)

Example 2 with IRemoteFileSystemBrowseEvent

use of org.eclipse.ecf.filetransfer.events.IRemoteFileSystemBrowseEvent in project ecf by eclipse.

the class URLBrowseTest method testBrowseUnknownHost.

public void testBrowseUnknownHost() throws Exception {
    testBrowse(new URL(URLRetrieveTestUnknownHost.HTTP_UNKNOWN_HOST_URL));
    Thread.sleep(3000);
    assertHasEventCount(events, IRemoteFileSystemBrowseEvent.class, 1);
    IRemoteFileSystemBrowseEvent event = (IRemoteFileSystemBrowseEvent) events.get(0);
    assertNotNull(event);
    final IRemoteFile[] remoteFiles = event.getRemoteFiles();
    assertNull(remoteFiles);
    Exception e = event.getException();
    assertNotNull(e);
    if (e instanceof BrowseFileTransferException) {
        BrowseFileTransferException ifte = (BrowseFileTransferException) e;
        assertTrue(ifte.getCause() instanceof UnknownHostException);
    } else
        fail("Event exception is not instance of BrowseFileTransferException");
}
Also used : BrowseFileTransferException(org.eclipse.ecf.filetransfer.BrowseFileTransferException) UnknownHostException(java.net.UnknownHostException) IRemoteFileSystemBrowseEvent(org.eclipse.ecf.filetransfer.events.IRemoteFileSystemBrowseEvent) IRemoteFile(org.eclipse.ecf.filetransfer.IRemoteFile) URL(java.net.URL) BrowseFileTransferException(org.eclipse.ecf.filetransfer.BrowseFileTransferException) UnknownHostException(java.net.UnknownHostException)

Example 3 with IRemoteFileSystemBrowseEvent

use of org.eclipse.ecf.filetransfer.events.IRemoteFileSystemBrowseEvent in project ecf by eclipse.

the class URLBrowseTest method testBrowseURLs.

public void testBrowseURLs() throws Exception {
    for (int i = 0; i < testURLs.length; i++) {
        testBrowse(testURLs[i]);
        Thread.sleep(10000);
    }
    assertHasEventCount(events, IRemoteFileSystemBrowseEvent.class, 3);
    for (Iterator iterator = events.iterator(); iterator.hasNext(); ) {
        IRemoteFileSystemBrowseEvent event = (IRemoteFileSystemBrowseEvent) iterator.next();
        assertNotNull(event);
        final IRemoteFile[] remoteFiles = event.getRemoteFiles();
        assertNotNull(remoteFiles);
        assertEquals(1, remoteFiles.length);
        if (event.getFileID().getName().equals("http://google.com:80")) {
            verifyRemoteFilesWithoutLastModifiedAndContentLength(remoteFiles);
        } else {
            verifyRemoteFiles(remoteFiles);
        }
    }
}
Also used : IRemoteFileSystemBrowseEvent(org.eclipse.ecf.filetransfer.events.IRemoteFileSystemBrowseEvent) Iterator(java.util.Iterator) IRemoteFile(org.eclipse.ecf.filetransfer.IRemoteFile)

Aggregations

IRemoteFile (org.eclipse.ecf.filetransfer.IRemoteFile)3 IRemoteFileSystemBrowseEvent (org.eclipse.ecf.filetransfer.events.IRemoteFileSystemBrowseEvent)3 URL (java.net.URL)1 UnknownHostException (java.net.UnknownHostException)1 Iterator (java.util.Iterator)1 List (java.util.List)1 BrowseFileTransferException (org.eclipse.ecf.filetransfer.BrowseFileTransferException)1