This repository has been archived by the owner on Sep 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
32e96d0
commit 851a6e9
Showing
6 changed files
with
50 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
17 | ||
jdk-21.0.1+12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 37 additions & 1 deletion
38
src/test/java/com/github/libgraviton/workerbase/util/DownloadClientTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,50 @@ | ||
package com.github.libgraviton.workerbase.util; | ||
|
||
import com.github.libgraviton.workertestbase.WorkerTestExtension; | ||
import com.github.tomakehurst.wiremock.stubbing.StubMapping; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import java.io.File; | ||
import java.util.Map; | ||
|
||
import static com.github.tomakehurst.wiremock.client.WireMock.*; | ||
|
||
public class DownloadClientTest { | ||
|
||
@RegisterExtension | ||
public static WorkerTestExtension workerTestExtension = (new WorkerTestExtension()) | ||
.setStartWiremock(true); | ||
|
||
@Test | ||
public void testBasicDownload() { | ||
DownloadClient.downloadFile("", "", Map.of()); | ||
String target = "/tmp/PDF-TEST-FILE.pdf"; | ||
String url = workerTestExtension.getWiremockUrl() + "/test.pdf"; | ||
|
||
StubMapping redir = workerTestExtension.getWireMockServer() | ||
.stubFor( | ||
get(urlMatching("/test.pdf")) | ||
.withHeader("FRANZ", equalTo("TEST")) | ||
.willReturn( | ||
aResponse().withStatus(301).withHeader("location", "/file/test.pdf") | ||
) | ||
); | ||
|
||
StubMapping filestub = workerTestExtension.getWireMockServer() | ||
.stubFor( | ||
get(urlMatching("/file/test.pdf")) | ||
// the transient headers | ||
.willReturn( | ||
aResponse().withBodyFile("test.pdf").withStatus(200) | ||
) | ||
); | ||
|
||
DownloadClient.downloadFile(url, target, Map.of("FRANZ", "TEST")); | ||
|
||
File file = new File(target); | ||
Assertions.assertEquals(7021, file.length()); | ||
file.delete(); | ||
} | ||
|
||
} |
File renamed without changes.