com.android.repository.testframework
Class FakeDownloader

java.lang.Object
  extended by com.android.repository.testframework.FakeDownloader
All Implemented Interfaces:
Downloader

public class FakeDownloader
extends java.lang.Object
implements Downloader

Fake implementation of Downloader that returns some specified content for specified URLs.


Constructor Summary
FakeDownloader(MockFileOp fop)
           
 
Method Summary
 java.io.InputStream downloadAndStream(java.net.URL url, SettingsController controller, ProgressIndicator indicator)
          Gets a stream associated with the content at the given URL.
 java.io.File downloadFully(java.net.URL url, SettingsController settings, ProgressIndicator indicator)
          Downloads the content at the given URL to a temporary file and returns a handle to that file.
 java.lang.String getFileName(java.net.URL url)
           
 void registerUrl(java.net.URL url, byte[] data)
           
 void registerUrl(java.net.URL url, java.io.InputStream content)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FakeDownloader

public FakeDownloader(MockFileOp fop)
Method Detail

registerUrl

public void registerUrl(java.net.URL url,
                        byte[] data)

registerUrl

public void registerUrl(java.net.URL url,
                        java.io.InputStream content)
                 throws java.io.IOException
Throws:
java.io.IOException

getFileName

@NonNull
public java.lang.String getFileName(java.net.URL url)

downloadAndStream

@NonNull
public java.io.InputStream downloadAndStream(@NonNull
                                                     java.net.URL url,
                                                     @Nullable
                                                     SettingsController controller,
                                                     @NonNull
                                                     ProgressIndicator indicator)
                                      throws java.io.IOException
Description copied from interface: Downloader
Gets a stream associated with the content at the given URL. This could be achieved by downloading the file completely, streaming it directly, or some combination.

Specified by:
downloadAndStream in interface Downloader
Parameters:
url - The URL to fetch.
controller - Settings (e.g. proxy configuration) for the connection.
indicator - Facility for showing download progress and logging.
Returns:
An InputStream corresponding to the specified content, or null if the download is cancelled.
Throws:
java.io.IOException

downloadFully

@Nullable
public java.io.File downloadFully(@NonNull
                                           java.net.URL url,
                                           @Nullable
                                           SettingsController settings,
                                           @NonNull
                                           ProgressIndicator indicator)
                           throws java.io.IOException
Description copied from interface: Downloader
Downloads the content at the given URL to a temporary file and returns a handle to that file.

Specified by:
downloadFully in interface Downloader
Parameters:
url - The URL to fetch.
settings - Settings (e.g. proxy configuration) for the connection.
indicator - Facility for showing download progress and logging.
Returns:
The temporary file, or null if the download is cancelled.
Throws:
java.io.IOException