Class FileDownloader
- java.lang.Object
-
- com.adobe.cq.testing.selenium.junit.extensions.FileDownloader
-
- All Implemented Interfaces:
net.lightbody.bmp.filters.ResponseFilter
public class FileDownloader extends java.lang.Object implements net.lightbody.bmp.filters.ResponseFilterResponseFilterthat intercepts and downloads files. Inspired from https://github.com/selenide/selenide/issues/196#issuecomment-168674086
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCONFIG_DEFAULT_DOWNLOAD_PATHDefault download path for temporarily downloaded files
-
Constructor Summary
Constructors Constructor Description FileDownloader()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description FileDownloaderaddContentType(java.lang.String contentType)Adds a newContent-Typeheader value that should be intercepted.FileDownloaderdeleteTempFiles(boolean deleteTempFiles)Sets if temporarily downloaded files should be deleted on process exit.voidfilterResponse(io.netty.handler.codec.http.HttpResponse response, net.lightbody.bmp.util.HttpMessageContents contents, net.lightbody.bmp.util.HttpMessageInfo messageInfo)Filtering method that intercepts and downloads the files.FileDownloadersetDownloadPath(java.lang.String path)Sets the desired temporary files download path.static FileDownloaderwithContent(java.lang.String contentType)Creates aFileDownloaderthat intercepts specifiedContent-Typestatic FileDownloaderwithContents(java.lang.String... contentType)Creates aFileDownloaderthat intercepts specifiedContent-Types.
-
-
-
Field Detail
-
CONFIG_DEFAULT_DOWNLOAD_PATH
public static final java.lang.String CONFIG_DEFAULT_DOWNLOAD_PATH
Default download path for temporarily downloaded files- See Also:
- Constant Field Values
-
-
Method Detail
-
addContentType
public FileDownloader addContentType(java.lang.String contentType)
Adds a newContent-Typeheader value that should be intercepted.- Parameters:
contentType- TheContent-Typeheader value that should be intercepted- Returns:
- Self, for fluent method calls
-
deleteTempFiles
public FileDownloader deleteTempFiles(boolean deleteTempFiles)
Sets if temporarily downloaded files should be deleted on process exit.- Parameters:
deleteTempFiles-trueif temporary files should be deleted,falseotherwise- Returns:
- Self, for fluent method calls
-
setDownloadPath
public FileDownloader setDownloadPath(java.lang.String path)
Sets the desired temporary files download path.- Parameters:
path- The desired download path- Returns:
- Self, for fluent method calls
-
withContent
public static FileDownloader withContent(java.lang.String contentType)
Creates aFileDownloaderthat intercepts specifiedContent-Type- Parameters:
contentType- TheContent-Typeto be intercepted- Returns:
- Self, for fluent method calls
-
withContents
public static FileDownloader withContents(java.lang.String... contentType)
Creates aFileDownloaderthat intercepts specifiedContent-Types.- Parameters:
contentType- TheContent-Types to be intercepted- Returns:
- Self, for fluent method calls
-
filterResponse
public void filterResponse(io.netty.handler.codec.http.HttpResponse response, net.lightbody.bmp.util.HttpMessageContents contents, net.lightbody.bmp.util.HttpMessageInfo messageInfo)Filtering method that intercepts and downloads the files.- Specified by:
filterResponsein interfacenet.lightbody.bmp.filters.ResponseFilter- See Also:
ResponseFilter.filterResponse(HttpResponse, HttpMessageContents, HttpMessageInfo)
-
-