Modified test mocks for compatibility with JDK 10 build environments
This commit is contained in:
parent
d2aaea1938
commit
4d46f2c6d1
4
pom.xml
4
pom.xml
@ -149,13 +149,13 @@
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>2.15.0</version>
|
||||
<version>2.17.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<version>2.15.0</version>
|
||||
<version>2.17.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -62,7 +62,6 @@ import static org.mockito.Mockito.*;
|
||||
public class HTTPVaultConnectorOfflineTest {
|
||||
private static final String INVALID_URL = "foo:/\\1nv4l1d_UrL";
|
||||
|
||||
private static HttpClientBuilder httpMockBuilder = mock(HttpClientBuilder.class);
|
||||
private static CloseableHttpClient httpMock = mock(CloseableHttpClient.class);
|
||||
private CloseableHttpResponse responseMock = mock(CloseableHttpResponse.class);
|
||||
|
||||
@ -78,7 +77,7 @@ public class HTTPVaultConnectorOfflineTest {
|
||||
* @return Mocked HTTP client builder.
|
||||
*/
|
||||
public static HttpClientBuilder create() {
|
||||
return httpMockBuilder;
|
||||
return new MockedHttpClientBuilder();
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
@ -90,14 +89,8 @@ public class HTTPVaultConnectorOfflineTest {
|
||||
.make()
|
||||
.load(HttpClientBuilder.class.getClassLoader(), ClassReloadingStrategy.fromInstalledAgent());
|
||||
|
||||
// Ignore SSL context settings.
|
||||
when(httpMockBuilder.setSSLSocketFactory(any())).thenReturn(httpMockBuilder);
|
||||
|
||||
// Re-initialize HTTP mock to ensure fresh (empty) results.
|
||||
httpMock = mock(CloseableHttpClient.class);
|
||||
|
||||
// Mock actual client creation.
|
||||
when(httpMockBuilder.build()).thenReturn(httpMock);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -486,4 +479,15 @@ public class HTTPVaultConnectorOfflineTest {
|
||||
when(responseMock.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), status, ""));
|
||||
when(responseMock.getEntity()).thenReturn(new StringEntity(body, type));
|
||||
}
|
||||
|
||||
/**
|
||||
* Mocked {@link HttpClientBuilder} that always returns the mocked client.
|
||||
*/
|
||||
private static class MockedHttpClientBuilder extends HttpClientBuilder {
|
||||
@Override
|
||||
public CloseableHttpClient build() {
|
||||
return httpMock;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user