Search in sources :

Example 1 with FileSizeUtilities

use of org.phoenicis.tools.files.FileSizeUtilities in project POL-POM-5 by PlayOnLinux.

the class DownloaderTest method testGet_DownloadFile_FileIsDownloaded.

@Test
public void testGet_DownloadFile_FileIsDownloaded() throws Exception {
    mockServer.when(request().withMethod("GET").withPath("/test.txt")).respond(response().withStatusCode(200).withHeaders(new Header("Content-Type", "application/config")).withBody("Content file to download"));
    File temporaryFile = File.createTempFile("test", "txt");
    temporaryFile.deleteOnExit();
    new Downloader(new FileSizeUtilities()).get(mockServerURL, temporaryFile, e -> {
    });
    String fileContent = IOUtils.toString(new FileReader(temporaryFile));
    assertEquals("Content file to download", fileContent);
}
Also used : FileSizeUtilities(org.phoenicis.tools.files.FileSizeUtilities) Header(org.mockserver.model.Header) FileReader(java.io.FileReader) File(java.io.File) Test(org.junit.Test)

Example 2 with FileSizeUtilities

use of org.phoenicis.tools.files.FileSizeUtilities in project POL-POM-5 by PlayOnLinux.

the class DownloaderTest method testGet_DownloadFileInAString_FileIsDownloaded.

@Test
public void testGet_DownloadFileInAString_FileIsDownloaded() throws Exception {
    mockServer.when(request().withMethod("GET").withPath("/test2.txt")).respond(response().withStatusCode(200).withHeaders(new Header("Content-Type", "application/config")).withBody("Content file to download 2"));
    String result = new Downloader(new FileSizeUtilities()).get(mockServerURLFile2, e -> {
    });
    assertEquals("Content file to download 2", result);
}
Also used : FileSizeUtilities(org.phoenicis.tools.files.FileSizeUtilities) Header(org.mockserver.model.Header) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 Header (org.mockserver.model.Header)2 FileSizeUtilities (org.phoenicis.tools.files.FileSizeUtilities)2 File (java.io.File)1 FileReader (java.io.FileReader)1