use of org.codice.ddf.cxf.client.impl.ClientBuilderImpl in project ddf by codice.
the class OcspCheckerTest method setup.
@Before
public void setup() throws Exception {
MockitoAnnotations.initMocks(this);
when(goodWebClient.type(anyString())).thenReturn(goodWebClient);
when(goodWebClient.accept(anyString())).thenReturn(goodWebClient);
when(goodWebClient.post(any())).thenReturn(goodResponse);
when(revokedWebClient.type(anyString())).thenReturn(revokedWebClient);
when(revokedWebClient.accept(anyString())).thenReturn(revokedWebClient);
when(revokedWebClient.post(any())).thenReturn(revokedResponse);
when(unknownWebClient.type(anyString())).thenReturn(unknownWebClient);
when(unknownWebClient.accept(anyString())).thenReturn(unknownWebClient);
when(unknownWebClient.post(any())).thenReturn(unknownResponse);
when(brokenWebClient.type(anyString())).thenReturn(brokenWebClient);
when(brokenWebClient.accept(anyString())).thenReturn(brokenWebClient);
when(brokenWebClient.post(any())).thenReturn(brokenResponse);
when(goodSecureCxfClientFactory.getWebClient()).thenReturn(goodWebClient);
when(revokedSecureCxfClientFactory.getWebClient()).thenReturn(revokedWebClient);
when(unknownSecureCxfClientFactory.getWebClient()).thenReturn(unknownWebClient);
when(brokenSecureCxfClientFactory.getWebClient()).thenReturn(brokenWebClient);
when(goodResponse.getEntity()).then(getResourceStreamAsAnswer("goodOcspResponse.streamData"));
when(revokedResponse.getEntity()).then(getResourceStreamAsAnswer("revokedOcspResponse.streamData"));
when(unknownResponse.getEntity()).then(getResourceStreamAsAnswer("unknownOcspResponse.streamData"));
when(brokenResponse.getEntity()).thenReturn(null);
ClientBuilder<WebClient> clientBuilder = new ClientBuilderImpl<WebClient>(mock(OAuthSecurity.class), mock(SamlSecurity.class), mock(SecurityLogger.class), mock(SecurityManager.class)) {
@Override
public SecureCxfClientFactory<WebClient> build() {
try {
if (inGoodList.matches(new URI(endpointUrl))) {
return goodSecureCxfClientFactory;
}
if (inRevokedList.matches(new URI(endpointUrl))) {
return revokedSecureCxfClientFactory;
}
if (inUnknownList.matches(new URI(endpointUrl))) {
return unknownSecureCxfClientFactory;
}
if (inBrokenList.matches(new URI(endpointUrl))) {
return brokenSecureCxfClientFactory;
}
return null;
} catch (URISyntaxException e) {
return null;
}
}
};
when(factory.<WebClient>getClientBuilder()).thenReturn(clientBuilder);
}
use of org.codice.ddf.cxf.client.impl.ClientBuilderImpl in project ddf by codice.
the class CrlGeneratorTest method getCxfClient.
private ClientBuilderFactory getCxfClient(byte[] message) {
Response response = mock(Response.class);
when(response.getEntity()).thenReturn(new ByteArrayInputStream(message));
WebClient webClient = mock(WebClient.class);
when(webClient.get()).thenReturn(response);
SecureCxfClientFactory<WebClient> secureCxfClientFactory = mock(SecureCxfClientFactory.class);
when(secureCxfClientFactory.getWebClient()).thenReturn(webClient);
ClientBuilderFactory clientBuilderFactory = mock(ClientBuilderFactory.class);
ClientBuilder<WebClient> clientBuilder = new ClientBuilderImpl<WebClient>(mock(OAuthSecurity.class), mock(SamlSecurity.class), mock(SecurityLogger.class), mock(SecurityManager.class)) {
@Override
public SecureCxfClientFactory<WebClient> build() {
return secureCxfClientFactory;
}
};
when(clientBuilderFactory.<WebClient>getClientBuilder()).thenReturn(clientBuilder);
return clientBuilderFactory;
}
Aggregations