-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
8 changed files
with
441 additions
and
58 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
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
89 changes: 89 additions & 0 deletions
89
src/test/java/coresearch/cvurl/io/utils/MockHttpClient.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 |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package coresearch.cvurl.io.utils; | ||
|
||
import javax.net.ssl.SSLContext; | ||
import javax.net.ssl.SSLParameters; | ||
import java.io.IOException; | ||
import java.net.Authenticator; | ||
import java.net.CookieHandler; | ||
import java.net.ProxySelector; | ||
import java.net.http.HttpClient; | ||
import java.net.http.HttpRequest; | ||
import java.net.http.HttpResponse; | ||
import java.time.Duration; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.concurrent.CompletableFuture; | ||
import java.util.concurrent.Executor; | ||
|
||
public class MockHttpClient extends HttpClient { | ||
|
||
public List<HttpRequest> requests = new ArrayList<>(); | ||
|
||
private MockHttpClient() { } | ||
|
||
public static MockHttpClient create() { | ||
return new MockHttpClient(); | ||
} | ||
|
||
@Override | ||
public Optional<CookieHandler> cookieHandler() { | ||
return Optional.empty(); | ||
} | ||
|
||
@Override | ||
public Optional<Duration> connectTimeout() { | ||
return Optional.empty(); | ||
} | ||
|
||
@Override | ||
public Redirect followRedirects() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Optional<ProxySelector> proxy() { | ||
return Optional.empty(); | ||
} | ||
|
||
@Override | ||
public SSLContext sslContext() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public SSLParameters sslParameters() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Optional<Authenticator> authenticator() { | ||
return Optional.empty(); | ||
} | ||
|
||
@Override | ||
public Version version() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Optional<Executor> executor() { | ||
return Optional.empty(); | ||
} | ||
|
||
@Override | ||
public <T> HttpResponse<T> send(HttpRequest request, HttpResponse.BodyHandler<T> responseBodyHandler) throws IOException, InterruptedException { | ||
requests.add(request); | ||
return null; | ||
} | ||
|
||
@Override | ||
public <T> CompletableFuture<HttpResponse<T>> sendAsync(HttpRequest request, HttpResponse.BodyHandler<T> responseBodyHandler) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public <T> CompletableFuture<HttpResponse<T>> sendAsync(HttpRequest request, HttpResponse.BodyHandler<T> responseBodyHandler, HttpResponse.PushPromiseHandler<T> pushPromiseHandler) { | ||
return null; | ||
} | ||
} |
Oops, something went wrong.