use of org.codice.ddf.cxf.client.ClientBuilderFactory in project ddf by codice.
the class SolrRestTest method setUp.
@Before
public void setUp() {
EncryptionService encryptionService = mock(EncryptionService.class);
when(encryptionService.decrypt(anyString())).thenReturn("test");
ClientBuilderFactory clientBuilderFactory = mock(ClientBuilderFactory.class);
SecureCxfClientFactory secureCxfClientFactory = mock(SecureCxfClientFactory.class);
ClientBuilder clientBuilder = new ClientBuilderImpl(mock(OAuthSecurity.class), mock(SamlSecurity.class), mock(SecurityLogger.class), mock(SecurityManager.class)) {
@Override
public SecureCxfClientFactory build() {
return secureCxfClientFactory;
}
};
when(clientBuilderFactory.getClientBuilder()).thenReturn(clientBuilder);
solrRest = new SolrRest(clientBuilderFactory, encryptionService);
}
use of org.codice.ddf.cxf.client.ClientBuilderFactory in project ddf by codice.
the class CrlGeneratorTest method testHttpUrl.
@Test
public void testHttpUrl() {
ClientBuilderFactory clientBuilderFactory = getCxfClient(demEncodedCrl);
CrlGenerator crlGenerator = new CrlGenerator(clientBuilderFactory, eventAdmin);
crlGenerator.setSecurityLogger(mock(SecurityLogger.class));
crlGenerator.setCrlLocationUrl("http://testurl:8993");
crlGenerator.setCrlByUrlEnabled(true);
crlGenerator.run();
assertTrue(!PropertiesLoader.getInstance().loadProperties(CrlGenerator.issuerEncryptionPropertiesLocation).containsKey(CrlGenerator.CRL_PROPERTY_KEY));
assertTrue(!PropertiesLoader.getInstance().loadProperties(CrlGenerator.issuerSignaturePropertiesLocation).containsKey(CrlGenerator.CRL_PROPERTY_KEY));
assertTrue(!PropertiesLoader.getInstance().loadProperties(CrlGenerator.serverEncryptionPropertiesLocation).containsKey(CrlGenerator.CRL_PROPERTY_KEY));
assertTrue(!PropertiesLoader.getInstance().loadProperties(CrlGenerator.serverSignaturePropertiesLocation).containsKey(CrlGenerator.CRL_PROPERTY_KEY));
}
use of org.codice.ddf.cxf.client.ClientBuilderFactory 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;
}
use of org.codice.ddf.cxf.client.ClientBuilderFactory in project ddf by codice.
the class CrlGeneratorTest method testSetCrlLocationUrl.
@Test
public void testSetCrlLocationUrl() {
ClientBuilderFactory clientBuilderFactory = getCxfClient(demEncodedCrl);
ScheduledExecutorService scheduler = mock(ScheduledExecutorService.class);
CrlGenerator crlGenerator = new CrlGenerator(clientBuilderFactory, eventAdmin, scheduler);
crlGenerator.setSecurityLogger(mock(SecurityLogger.class));
crlGenerator.setCrlByUrlEnabled(true);
when(scheduler.scheduleAtFixedRate(crlGenerator, 0, 30, TimeUnit.MINUTES)).thenReturn(null);
crlGenerator.setCrlLocationUrl("https://testurl:8993");
Mockito.verify(scheduler, times(1)).scheduleAtFixedRate(crlGenerator, 0, 30, TimeUnit.MINUTES);
// Will set handler value (not null)
ScheduledFuture handler = mock(ScheduledFuture.class);
when(scheduler.scheduleAtFixedRate(crlGenerator, 0, 30, TimeUnit.MINUTES)).thenReturn(handler);
crlGenerator.setCrlLocationUrl("https://testurl:8993");
// Next time we call setCrlLocationUrl, the first handler should be chanced
crlGenerator.setCrlLocationUrl("https://testurl:8993");
Mockito.verify(handler, times(1)).cancel(false);
}
Aggregations